Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
static-ci
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
陈峰
8 years ago
Commit
6bb36875b0e1622cf9ec42fba71589e61bd4de9e
1 parent
aae8bf8a
单独保存sourcemap并提供接口访问
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
81 additions
and
1 deletions
.gitignore
app.js
apps/api/actions/source-map.js
apps/api/index.js
apps/api/routers.js
apps/ci/build.js
config/config.js
.gitignore
View file @
6bb3687
...
...
@@ -5,6 +5,7 @@ node_modules/
db/**
packages/
sourcemap/
.idea/
...
...
app.js
View file @
6bb3687
...
...
@@ -16,6 +16,7 @@ import Socket from 'socket.io';
import
config
from
'./config/config'
;
import
webApp
from
'./apps/web'
;
import
api
from
'./apps/api'
;
import
ws
from
'./lib/ws'
;
import
errorHandle
from
'./middleware/error-handle'
;
...
...
@@ -41,6 +42,7 @@ app.use(convert(body({
})));
app
.
use
(
mount
(
'/'
,
webApp
));
app
.
use
(
mount
(
'/'
,
api
));
// app.on('error', function(err, ctx) {
// console.log(err);
// switch (ctx.accepts('json', 'html', 'text')) {
...
...
apps/api/actions/source-map.js
0 → 100644
View file @
6bb3687
import
config
from
'../../../config/config'
;
import
fs
from
'fs'
;
import
path
from
'path'
;
import
Router
from
'koa-router'
;
let
r
=
new
Router
();
r
.
get
(
'/load'
,
(
ctx
,
next
)
=>
{
const
reqPath
=
ctx
.
request
.
query
.
path
;
const
filePath
=
path
.
join
(
config
.
sourceMapDir
,
reqPath
);
if
(
fs
.
existsSync
(
filePath
))
{
const
rs
=
fs
.
createReadStream
(
filePath
,
{
encoding
:
'utf-8'
});
const
fileName
=
path
.
basename
(
filePath
)
ctx
.
set
(
'Content-Type'
,
'application/javascript; charset=utf-8'
);
ctx
.
response
.
body
=
rs
;
return
;
}
return
next
();
});
export
default
r
;
\ No newline at end of file
...
...
apps/api/index.js
0 → 100644
View file @
6bb3687
/**
* web ui 模块
*
* @author: jiang
*/
import
path
from
'path'
;
import
Koa
from
'koa'
;
import
routers
from
'./routers'
const
app
=
new
Koa
();
routers
(
app
);
export
default
app
;
\ No newline at end of file
...
...
apps/api/routers.js
0 → 100644
View file @
6bb3687
import
Router
from
'koa-router'
;
import
sourceMap
from
'./actions/source-map'
;
const
r
=
new
Router
();
export
default
function
(
app
)
{
r
.
use
(
'/sourcemap'
,
sourceMap
.
routes
(),
sourceMap
.
allowedMethods
());
app
.
use
(
r
.
routes
(),
r
.
allowedMethods
());
}
\ No newline at end of file
...
...
apps/ci/build.js
View file @
6bb3687
...
...
@@ -52,6 +52,8 @@ class Build {
self
.
version
=
pkg
.
version
;
self
.
pkgName
=
pkg
.
name
;
sh
.
rm
(
'-rf'
,
path
.
join
(
self
.
codePath
,
'public/dist/'
));
return
self
.
_installdep
();
}).
then
(()
=>
{
return
self
.
_buildScript
();
...
...
@@ -75,6 +77,10 @@ class Build {
get
buildPath
()
{
return
path
.
join
(
config
.
buildDir
,
this
.
project
.
name
,
this
.
buildTime
,
this
.
pkgName
);
}
get
sourceMapPath
()
{
return
path
.
join
(
config
.
sourceMapDir
,
this
.
project
.
name
);
}
get
rootPath
()
{
return
path
.
join
(
config
.
buildDir
,
this
.
project
.
name
,
this
.
buildTime
);
...
...
@@ -91,6 +97,10 @@ class Build {
if
(
!
sh
.
test
(
'-e'
,
config
.
codeDir
))
{
sh
.
mkdir
(
'-p'
,
config
.
codeDir
);
}
if
(
!
sh
.
test
(
'-e'
,
config
.
sourceMapDir
))
{
sh
.
mkdir
(
'-p'
,
config
.
sourceMapDir
);
}
if
(
!
sh
.
test
(
'-e'
,
this
.
rootPath
))
{
sh
.
mkdir
(
'-p'
,
this
.
rootPath
);
...
...
@@ -216,11 +226,23 @@ class Build {
this
.
_log
(
'>>>>>>>>> clone to deploy folder >>>>>>>>>>'
);
return
new
Promise
((
resolve
,
reject
)
=>
{
let
projectRoot
=
`
public
/
dist
/
$
{
self
.
pkgName
}
/`
;
let
copyPath
=
path
.
join
(
self
.
codePath
,
projectRoot
);
self
.
_state
(
'clone to deploy'
);
sh
.
cd
(
copyPath
);
sh
.
find
(
'.'
).
filter
(
file
=>
file
.
match
(
/
\.
map$/
)).
forEach
(
file
=>
{
const
destFile
=
path
.
join
(
this
.
sourceMapPath
,
file
);
const
firdir
=
path
.
dirname
(
destFile
);
if
(
!
sh
.
test
(
'-e'
,
firdir
))
{
sh
.
mkdir
(
'-p'
,
firdir
);
}
sh
.
mv
(
path
.
join
(
copyPath
,
file
),
destFile
)
});
// assets folder & version folder
var
child
=
sh
.
cp
(
'-r'
,
path
.
join
(
self
.
codePath
,
projectRoot
)
,
self
.
buildPath
);
var
child
=
sh
.
cp
(
'-r'
,
copyPath
,
self
.
buildPath
);
if
(
child
.
code
===
0
)
{
console
.
log
(
'cope to deploy success'
);
...
...
config/config.js
View file @
6bb3687
...
...
@@ -8,6 +8,7 @@ const defaults = {
port
:
6006
,
codeDir
:
path
.
normalize
(
__dirname
+
'/../code/'
),
// 代码位置
buildDir
:
path
.
normalize
(
__dirname
+
'/../packages/'
),
// 静态资源包位置
sourceMapDir
:
path
.
normalize
(
__dirname
+
'/../sourcemap/'
),
// sourcemap位置
dbDir
:
path
.
normalize
(
__dirname
+
'/../db'
),
ci
:
path
.
normalize
(
__dirname
+
'/../apps/ci'
)
};
...
...
Please
register
or
login
to post a comment