@aj-shadow/z-build-project 0.0.0-aj-beta.221
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +26 -0
- package/LICENSE.txt +96 -0
- package/README.md +5 -0
- package/npm-shrinkwrap.json +13 -0
- package/package.json +10 -0
- package/package_release.json +26 -0
- package/project/server/_build/z-build-project.prj +3 -0
- package/project/server/bottleneck-queue.js +35 -0
- package/project/server/build-all.js +122 -0
- package/project/server/build-client-bundle.js +84 -0
- package/project/server/build-client-js.js +58 -0
- package/project/server/build-client-jsx.js +59 -0
- package/project/server/build-client-rc-bundle.js +72 -0
- package/project/server/build-server-js.js +62 -0
- package/project/server/build-server-rc.js +68 -0
- package/project/server/build.js +294 -0
- package/project/server/child-build-data.js +87 -0
- package/project/server/child-client-bundle.js +376 -0
- package/project/server/child-client-js.js +279 -0
- package/project/server/child-client-jsx.js +175 -0
- package/project/server/child-client-rc-bundle.js +115 -0
- package/project/server/child-server-js.js +165 -0
- package/project/server/child-server-rc.js +118 -0
- package/project/server/git-global.js +75 -0
- package/project/server/git-tasks.js +768 -0
- package/project/server/log.js +53 -0
- package/project/server/npm-install-all.js +129 -0
- package/project/server/pendings.js +21 -0
- package/project/server/process.js +218 -0
- package/project/server/project.js +102 -0
- package/project/server/repo-manager.js +106 -0
- package/project/server/service/commands.js +332 -0
- package/project/server/task-clean.js +45 -0
- package/project/server/task-list.js +27 -0
- package/project/server/task-runner-glob.js +83 -0
- package/project/server/task-runner.js +292 -0
- package/project/server/task-simple.js +56 -0
- package/project/server/task.js +59 -0
- package/project/server/workspace.js +317 -0
- package/project/z-build-project.tree +37 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const ChildBuildData = require('./child-build-data');
|
|
5
|
+
const Log = require('./log');
|
|
6
|
+
const Pendings = require('./pendings');
|
|
7
|
+
const TaskRunnerGlob = require('./task-runner-glob');
|
|
8
|
+
const Clc = require('cli-color');
|
|
9
|
+
const Babel = require('@babel/core');
|
|
10
|
+
const Fs = require('fs');
|
|
11
|
+
const Path = require('path');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ChildClientJsx {
|
|
15
|
+
static BUILD_RELEASE_START = '#BUILD_RELEASE_START';
|
|
16
|
+
static BUILD_RELEASE_START_COMMENT_LINE = '// #BUILD_RELEASE_START';
|
|
17
|
+
static BUILD_RELEASE_START_COMMENT_ALL = '/* #BUILD_RELEASE_START';
|
|
18
|
+
static BUILD_RELEASE_STOP = '#BUILD_RELEASE_STOP';
|
|
19
|
+
static BUILD_RELEASE_STOP_COMMENT_LINE = '// #BUILD_RELEASE_STOP';
|
|
20
|
+
static BUILD_RELEASE_STOP_COMMENT_ALL = '#BUILD_RELEASE_STOP */';
|
|
21
|
+
static BUILD_DEBUG_START = '#BUILD_DEBUG_START';
|
|
22
|
+
static BUILD_DEBUG_START_COMMENT_LINE = '// #BUILD_DEBUG_START';
|
|
23
|
+
static BUILD_DEBUG_START_COMMENT_ALL = '/* #BUILD_DEBUG_START';
|
|
24
|
+
static BUILD_DEBUG_STOP = '#BUILD_DEBUG_STOP';
|
|
25
|
+
static BUILD_DEBUG_STOP_COMMENT_LINE = '// #BUILD_DEBUG_STOP';
|
|
26
|
+
static BUILD_DEBUG_STOP_COMMENT_ALL = '#BUILD_DEBUG_STOP */';
|
|
27
|
+
|
|
28
|
+
constructor(appName, name, silent, repo, source, dest, nodeEnv) {
|
|
29
|
+
this.appName = appName;
|
|
30
|
+
this.name = name;
|
|
31
|
+
this.silent = silent;
|
|
32
|
+
this.repo = repo;
|
|
33
|
+
this.source = source;
|
|
34
|
+
this.dest = dest;
|
|
35
|
+
this.isDebug = 'development' === nodeEnv;
|
|
36
|
+
process.env.NODE_ENV = nodeEnv;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
task(cb) {
|
|
40
|
+
const resolvedPath = Path.resolve(this.repo ? Path.resolve(this.repo) : '.');
|
|
41
|
+
const buildDataPath = Path.resolve(`..${Path.sep}Generated${Path.sep}Build${Path.sep}${this.appName}-${this.name.replaceAll(':', '-').replaceAll('/', '-')}`);
|
|
42
|
+
ChildBuildData.getBuildData(buildDataPath, (buildData) => {
|
|
43
|
+
TaskRunnerGlob.glob(this.source, this.dest, resolvedPath, null, cb, (srcFile, dstFile, done) => {
|
|
44
|
+
let shallBuild = true;
|
|
45
|
+
const pendings = new Pendings(1, null);
|
|
46
|
+
dstFile = dstFile.substring(0, dstFile.length - 2) + 's';
|
|
47
|
+
Fs.lstat(dstFile, (err, stat) => {
|
|
48
|
+
if(shallBuild) {
|
|
49
|
+
if(!!err && 'ENOENT' === err.code) {
|
|
50
|
+
shallBuild = false;
|
|
51
|
+
this._build(pendings, srcFile, dstFile, buildDataPath, buildData, done);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this._setBuildData(pendings, buildDataPath, buildData, done);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this._setBuildData(pendings, buildDataPath, buildData, done);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
pendings.inc();
|
|
62
|
+
Fs.lstat(srcFile, (err, stat) => {
|
|
63
|
+
if(shallBuild) {
|
|
64
|
+
const mTimeMs = buildData.map.get(srcFile);
|
|
65
|
+
if(mTimeMs === stat.mtimeMs) {
|
|
66
|
+
this._setBuildData(pendings, buildDataPath, buildData, done);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
shallBuild = false;
|
|
70
|
+
this._build(pendings, srcFile, dstFile, buildDataPath, buildData, done);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
this._setBuildData(pendings, buildDataPath, buildData, done);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
_setBuildData(pendings, buildDataPath, buildData, done) {
|
|
82
|
+
if(pendings.dec()) {
|
|
83
|
+
ChildBuildData.setBuildData(buildDataPath, buildData, done);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
_build(pendings, srcFile, dstFile, buildDataPath, buildData, cb) {
|
|
88
|
+
Fs.readFile(srcFile, (err, data) => {
|
|
89
|
+
if(err) {
|
|
90
|
+
Log.log(Clc.red(`Could not read: '`) + srcFile + Clc.red(`'.`), err);
|
|
91
|
+
if(pendings.dec()) {
|
|
92
|
+
ChildBuildData.setBuildData(buildDataPath, buildData, cb);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
TaskRunnerGlob.verifyPath(dstFile, (err) => {
|
|
97
|
+
if(err) {
|
|
98
|
+
if(pendings.dec()) {
|
|
99
|
+
cb();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
data = this._macro(data);
|
|
104
|
+
Babel.transform(data, {
|
|
105
|
+
plugins: ["@babel/plugin-transform-react-jsx"],
|
|
106
|
+
}, (err, result) => {
|
|
107
|
+
if(err) {
|
|
108
|
+
Log.log(Clc.red('plugin-transform-react-jsx error:'), srcFile, err);
|
|
109
|
+
if(pendings.dec()) {
|
|
110
|
+
ChildBuildData.setBuildData(buildDataPath, buildData, cb);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
ChildBuildData.write(srcFile, dstFile, result.code, buildData, () => {
|
|
115
|
+
if(pendings.dec()) {
|
|
116
|
+
ChildBuildData.setBuildData(buildDataPath, buildData, cb);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
_macro(data) {
|
|
128
|
+
const mightHaveMacro = data.indexOf('#');
|
|
129
|
+
if(-1 !== mightHaveMacro) {
|
|
130
|
+
if('string' !== typeof data) {
|
|
131
|
+
data = data.toString();
|
|
132
|
+
}
|
|
133
|
+
if(this.isDebug) {
|
|
134
|
+
data = data.replaceAll(ChildClientJsx.BUILD_DEBUG_START, ChildClientJsx.BUILD_DEBUG_START_COMMENT_LINE);
|
|
135
|
+
data = data.replaceAll(ChildClientJsx.BUILD_DEBUG_STOP, ChildClientJsx.BUILD_DEBUG_STOP_COMMENT_LINE);
|
|
136
|
+
data = data.replaceAll(ChildClientJsx.BUILD_RELEASE_START, ChildClientJsx.BUILD_RELEASE_START_COMMENT_ALL);
|
|
137
|
+
data = data.replaceAll(ChildClientJsx.BUILD_RELEASE_STOP, ChildClientJsx.BUILD_RELEASE_STOP_COMMENT_ALL);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
data = data.replaceAll(ChildClientJsx.BUILD_RELEASE_START, ChildClientJsx.BUILD_RELEASE_START_COMMENT_LINE);
|
|
141
|
+
data = data.replaceAll(ChildClientJsx.BUILD_RELEASE_STOP, ChildClientJsx.BUILD_RELEASE_STOP_COMMENT_LINE);
|
|
142
|
+
data = data.replaceAll(ChildClientJsx.BUILD_DEBUG_START, ChildClientJsx.BUILD_DEBUG_START_COMMENT_ALL);
|
|
143
|
+
data = data.replaceAll(ChildClientJsx.BUILD_DEBUG_STOP, ChildClientJsx.BUILD_DEBUG_STOP_COMMENT_ALL);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return data;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
process.nextTick(() => {
|
|
152
|
+
const parameters = JSON.parse(process.argv[2]);
|
|
153
|
+
let isDone = false;
|
|
154
|
+
const childClientJsx = new ChildClientJsx(...parameters);
|
|
155
|
+
process.on('exit', (code) => {
|
|
156
|
+
if(!isDone) {
|
|
157
|
+
console.log(' EXIT CLIENT JSX - WITHOUT DONE', childClientJsx.name, childClientJsx.pendings);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
//if('Client:AppLayer/client-jsx' === childClientJsx.name) {
|
|
161
|
+
// console.log('START CLIENT JSX', childClientJsx.name);
|
|
162
|
+
//}
|
|
163
|
+
childClientJsx.task(() => {
|
|
164
|
+
if(!isDone) {
|
|
165
|
+
//if('Client:AppLayer/client-jsx' === childClientJsx.name) {
|
|
166
|
+
// console.log(' DONE CLIENT JSX', childClientJsx.name);
|
|
167
|
+
//}
|
|
168
|
+
isDone = true;
|
|
169
|
+
process.send(0);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
console.log(' DONE CLIENT JSX - AGAIN', childClientJsx.name);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const Log = require('./log');
|
|
5
|
+
const TaskRunnerGlob = require('./task-runner-glob');
|
|
6
|
+
const Clc = require('cli-color');
|
|
7
|
+
const Fs = require('fs');
|
|
8
|
+
const Path = require('path');
|
|
9
|
+
const Zlib = require('zlib');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ChildClientRcBundle {
|
|
13
|
+
constructor(appName, name, silent, bundleName, repo, source, dest, remove, nodeEnv, buildEnv) {
|
|
14
|
+
this.appName = appName;
|
|
15
|
+
this.name = name;
|
|
16
|
+
this.silent = silent;
|
|
17
|
+
this.bundleName = bundleName;
|
|
18
|
+
this.repo = repo;
|
|
19
|
+
this.source = source;
|
|
20
|
+
this.dest = dest;
|
|
21
|
+
this.remove = remove;
|
|
22
|
+
process.env.NODE_ENV = nodeEnv;
|
|
23
|
+
this.production = 1 === buildEnv;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
task(cb) {
|
|
27
|
+
const resolvedPath = Path.resolve(this.repo ? Path.resolve(this.repo) : '.');
|
|
28
|
+
const buffers = [];
|
|
29
|
+
TaskRunnerGlob.glob(this.source, this.dest, resolvedPath, null, () => {
|
|
30
|
+
const dstFile = `${this.dest}${Path.sep}${this.bundleName}`;
|
|
31
|
+
if(this.production) {
|
|
32
|
+
const buffer = buffers.join('');
|
|
33
|
+
Zlib.gzip(buffer, (err, data) => {
|
|
34
|
+
if(err) {
|
|
35
|
+
Log.log(`Bundle ${this.name} error:`, err);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
Fs.writeFile(dstFile + '.gzip', data, (err) => {
|
|
39
|
+
if(err) {
|
|
40
|
+
Log.log(Clc.red(`Could not write: '`) + dstFile + Clc.red(`'.`), err);
|
|
41
|
+
}
|
|
42
|
+
cb();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
const writeStream = Fs.createWriteStream(dstFile, {flags: 'w'});
|
|
48
|
+
buffers.forEach((buffer) => {
|
|
49
|
+
if(buffer) {
|
|
50
|
+
writeStream.write(buffer);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
writeStream.end(() => {
|
|
54
|
+
cb();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}, (srcFile, dstFile, cb) => {
|
|
58
|
+
Fs.readFile(srcFile, (err, data) => {
|
|
59
|
+
if(err) {
|
|
60
|
+
Log.log(Clc.red(`Could not read: '`) + srcFile + Clc.red(`'.`), err);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
if(this.production) {
|
|
64
|
+
const formattedData = data.toString()
|
|
65
|
+
.replace(/([^0-9a-zA-Z\.\%\-#])\s+/g, "$1")
|
|
66
|
+
.replace(/\s([^0-9a-zA-Z\.\%\-#]+)/g, "$1")
|
|
67
|
+
.replace(/;}/g, "}")
|
|
68
|
+
.replace(/\/\*.*?\*\//g, "");
|
|
69
|
+
buffers.push(this._removeText(formattedData, this.remove));
|
|
70
|
+
}
|
|
71
|
+
else if(this.remove) {
|
|
72
|
+
buffers.push(this._removeText(data.toString(), this.remove));
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
buffers.push(data);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
cb();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
_removeText(text, remove) {
|
|
84
|
+
if(Array.isArray(remove)) {
|
|
85
|
+
for(let i = 0; i < this.remove.length; ++i) {
|
|
86
|
+
text = this._removeText(text, this.remove[i]);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
text = text.replace(remove, '');
|
|
91
|
+
}
|
|
92
|
+
return text
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
process.nextTick(() => {
|
|
98
|
+
const parameters = JSON.parse(process.argv[2]);
|
|
99
|
+
let isDone = false;
|
|
100
|
+
const childClientRcBundle = new ChildClientRcBundle(...parameters);
|
|
101
|
+
process.on('exit', (code) => {
|
|
102
|
+
if(!isDone) {
|
|
103
|
+
console.log(' EXIT BUNDLE RC - WITHOUT DONE', childClientRcBundle.name);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
childClientRcBundle.task(() => {
|
|
107
|
+
if(!isDone) {
|
|
108
|
+
isDone = true;
|
|
109
|
+
process.send(0);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
console.log(' DONE BUNDLE RC - AGAIN', childClientRcBundle.name);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const ChildBuildData = require('./child-build-data');
|
|
5
|
+
const Pendings = require('./pendings');
|
|
6
|
+
const TaskRunnerGlob = require('./task-runner-glob');
|
|
7
|
+
const Clc = require('cli-color');
|
|
8
|
+
const Fs = require('fs');
|
|
9
|
+
const Os = require('os');
|
|
10
|
+
const Path = require('path');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ChildServerJs {
|
|
14
|
+
static BUILD_RELEASE_START = '#BUILD_RELEASE_START';
|
|
15
|
+
static BUILD_RELEASE_START_COMMENT_LINE = '// #BUILD_RELEASE_START';
|
|
16
|
+
static BUILD_RELEASE_START_COMMENT_ALL = '/* #BUILD_RELEASE_START';
|
|
17
|
+
static BUILD_RELEASE_STOP = '#BUILD_RELEASE_STOP';
|
|
18
|
+
static BUILD_RELEASE_STOP_COMMENT_LINE = '// #BUILD_RELEASE_STOP';
|
|
19
|
+
static BUILD_RELEASE_STOP_COMMENT_ALL = '#BUILD_RELEASE_STOP */';
|
|
20
|
+
static BUILD_DEBUG_START = '#BUILD_DEBUG_START';
|
|
21
|
+
static BUILD_DEBUG_START_COMMENT_LINE = '// #BUILD_DEBUG_START';
|
|
22
|
+
static BUILD_DEBUG_START_COMMENT_ALL = '/* #BUILD_DEBUG_START';
|
|
23
|
+
static BUILD_DEBUG_STOP = '#BUILD_DEBUG_STOP';
|
|
24
|
+
static BUILD_DEBUG_STOP_COMMENT_LINE = '// #BUILD_DEBUG_STOP';
|
|
25
|
+
static BUILD_DEBUG_STOP_COMMENT_ALL = '#BUILD_DEBUG_STOP */';
|
|
26
|
+
|
|
27
|
+
constructor(appName, name, silent, repo, source, dest, nodeEnv, replaceCondition, replaceHandle) {
|
|
28
|
+
this.appName = appName;
|
|
29
|
+
this.name = name;
|
|
30
|
+
this.silent = silent;
|
|
31
|
+
this.repo = repo;
|
|
32
|
+
this.source = source;
|
|
33
|
+
this.dest = dest;
|
|
34
|
+
this.replaceCondition = null !== replaceCondition ? new RegExp(replaceCondition, 'g') : null;
|
|
35
|
+
this.replaceHandle = null !== replaceHandle ? new Function('match', 'parameters', replaceHandle) : null;
|
|
36
|
+
this.isDebug = 'development' === nodeEnv;
|
|
37
|
+
process.env.NODE_ENV = nodeEnv;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
task(cb) {
|
|
41
|
+
const buildDataPath = Path.resolve(`..${Path.sep}Generated${Path.sep}Build${Path.sep}${this.appName}-${this.name.replaceAll(':', '-').replaceAll('/', '-')}`);
|
|
42
|
+
const resolvedPath = Path.resolve(this.repo ? Path.resolve(this.repo) : '.');
|
|
43
|
+
ChildBuildData.getBuildData(buildDataPath, (buildData) => {
|
|
44
|
+
TaskRunnerGlob.glob(this.source, this.dest, resolvedPath, null, cb, (srcFile, dstFile, done) => {
|
|
45
|
+
let shallBuild = true;
|
|
46
|
+
const pendings = new Pendings(1, null);
|
|
47
|
+
Fs.lstat(dstFile, (err, stat) => {
|
|
48
|
+
if(shallBuild) {
|
|
49
|
+
if(!!err && 'ENOENT' === err.code) {
|
|
50
|
+
shallBuild = false;
|
|
51
|
+
this._build(pendings, srcFile, dstFile, buildDataPath, buildData, done);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this._setBuildData(pendings, buildDataPath, buildData, done);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this._setBuildData(pendings, buildDataPath, buildData, done);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
pendings.inc();
|
|
62
|
+
Fs.lstat(srcFile, (err, stat) => {
|
|
63
|
+
if(shallBuild) {
|
|
64
|
+
const mTimeMs = buildData.map.get(srcFile);
|
|
65
|
+
if(mTimeMs === stat.mtimeMs) {
|
|
66
|
+
this._setBuildData(pendings, buildDataPath, buildData, done);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
shallBuild = false;
|
|
70
|
+
this._build(pendings, srcFile, dstFile, buildDataPath, buildData, done);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
this._setBuildData(pendings, buildDataPath, buildData, done);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
_setBuildData(pendings, buildDataPath, buildData, done) {
|
|
82
|
+
if(pendings.dec()) {
|
|
83
|
+
ChildBuildData.setBuildData(buildDataPath, buildData, done);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
_build(pendings, srcFile, dstFile, buildDataPath, buildData, cb) {
|
|
88
|
+
Fs.readFile(srcFile, (err, data) => {
|
|
89
|
+
if(err) {
|
|
90
|
+
if(pendings.dec()) {
|
|
91
|
+
process.nextTick(cb, err);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
TaskRunnerGlob.verifyPath(dstFile, (err) => {
|
|
96
|
+
if(err) {
|
|
97
|
+
if(pendings.dec()) {
|
|
98
|
+
process.nextTick(cb, err);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
data = this._macro(data);
|
|
103
|
+
if(this.replaceHandle) {
|
|
104
|
+
if('string' !== typeof data) {
|
|
105
|
+
data = data.toString();
|
|
106
|
+
}
|
|
107
|
+
data = data.replace(this.replaceCondition, (...parameters) => {
|
|
108
|
+
const match = parameters.shift();
|
|
109
|
+
return this.replaceHandle(match, parameters);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
ChildBuildData.write(srcFile, dstFile, data, buildData, () => {
|
|
113
|
+
if(pendings.dec()) {
|
|
114
|
+
ChildBuildData.setBuildData(buildDataPath, buildData, cb);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
_macro(data) {
|
|
124
|
+
const mightHaveMacro = data.indexOf('#');
|
|
125
|
+
if(-1 !== mightHaveMacro) {
|
|
126
|
+
if('string' !== typeof data) {
|
|
127
|
+
data = data.toString();
|
|
128
|
+
}
|
|
129
|
+
if(this.isDebug) {
|
|
130
|
+
data = data.replaceAll(ChildServerJs.BUILD_DEBUG_START, ChildServerJs.BUILD_DEBUG_START_COMMENT_LINE);
|
|
131
|
+
data = data.replaceAll(ChildServerJs.BUILD_DEBUG_STOP, ChildServerJs.BUILD_DEBUG_STOP_COMMENT_LINE);
|
|
132
|
+
data = data.replaceAll(ChildServerJs.BUILD_RELEASE_START, ChildServerJs.BUILD_RELEASE_START_COMMENT_ALL);
|
|
133
|
+
data = data.replaceAll(ChildServerJs.BUILD_RELEASE_STOP, ChildServerJs.BUILD_RELEASE_STOP_COMMENT_ALL);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
data = data.replaceAll(ChildServerJs.BUILD_RELEASE_START, ChildServerJs.BUILD_RELEASE_START_COMMENT_LINE);
|
|
137
|
+
data = data.replaceAll(ChildServerJs.BUILD_RELEASE_STOP, ChildServerJs.BUILD_RELEASE_STOP_COMMENT_LINE);
|
|
138
|
+
data = data.replaceAll(ChildServerJs.BUILD_DEBUG_START, ChildServerJs.BUILD_DEBUG_START_COMMENT_ALL);
|
|
139
|
+
data = data.replaceAll(ChildServerJs.BUILD_DEBUG_STOP, ChildServerJs.BUILD_DEBUG_STOP_COMMENT_ALL);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return data;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
process.nextTick(() => {
|
|
148
|
+
const parameters = JSON.parse(process.argv[2]);
|
|
149
|
+
let isDone = false;
|
|
150
|
+
const childServerJs = new ChildServerJs(...parameters);
|
|
151
|
+
process.on('exit', (code) => {
|
|
152
|
+
if(!isDone) {
|
|
153
|
+
console.log(' EXIT SERVER JS - WITHOUT DONE', childServerJs.name, childServerJs.pendings);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
childServerJs.task(() => {
|
|
157
|
+
if(!isDone) {
|
|
158
|
+
isDone = true;
|
|
159
|
+
process.send(0);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
console.log(' DONE SERVER JS - AGAIN', childServerJs.name, childServerJs.pendings);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const ChildBuildData = require('./child-build-data');
|
|
5
|
+
const Log = require('./log');
|
|
6
|
+
const Pendings = require('./pendings');
|
|
7
|
+
const TaskRunnerGlob = require('./task-runner-glob');
|
|
8
|
+
const Clc = require('cli-color');
|
|
9
|
+
const Fs = require('fs');
|
|
10
|
+
const Path = require('path');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ChildServerRc {
|
|
14
|
+
constructor(appName, name, silent, repo, source, dest, nodeEnv) {
|
|
15
|
+
this.appName = appName;
|
|
16
|
+
this.name = name;
|
|
17
|
+
this.silent = silent;
|
|
18
|
+
this.repo = repo;
|
|
19
|
+
this.source = source;
|
|
20
|
+
this.dest = dest;
|
|
21
|
+
process.env.NODE_ENV = nodeEnv;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
task(cb) {
|
|
25
|
+
const buildDataPath = Path.resolve(`..${Path.sep}Generated${Path.sep}Build${Path.sep}${this.appName}-${this.name.replaceAll(':', '-').replaceAll('/', '-')}`);
|
|
26
|
+
const resolvedPath = Path.resolve(this.repo ? Path.resolve(this.repo) : '.');
|
|
27
|
+
ChildBuildData.getBuildData(buildDataPath, (buildData) => {
|
|
28
|
+
TaskRunnerGlob.glob(this.source, this.dest, resolvedPath, null, cb, (srcFile, dstFile, done) => {
|
|
29
|
+
let shallBuild = true;
|
|
30
|
+
const pendings = new Pendings(1, null);
|
|
31
|
+
Fs.lstat(dstFile, (err, stat) => {
|
|
32
|
+
if(shallBuild) {
|
|
33
|
+
if(!!err && 'ENOENT' === err.code) {
|
|
34
|
+
shallBuild = false;
|
|
35
|
+
this._build(pendings, srcFile, dstFile, buildDataPath, buildData, done);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
this._setBuildData(pendings, buildDataPath, buildData, done);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this._setBuildData(pendings, buildDataPath, buildData, done);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
pendings.inc();
|
|
46
|
+
Fs.lstat(srcFile, (err, stat) => {
|
|
47
|
+
if(shallBuild) {
|
|
48
|
+
const mTimeMs = buildData.map.get(srcFile);
|
|
49
|
+
if(mTimeMs === stat.mtimeMs) {
|
|
50
|
+
this._setBuildData(pendings, buildDataPath, buildData, done);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
shallBuild = false;
|
|
54
|
+
this._build(pendings, srcFile, dstFile, buildDataPath, buildData, done);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this._setBuildData(pendings, buildDataPath, buildData, done);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
_setBuildData(pendings, buildDataPath, buildData, done) {
|
|
66
|
+
if(pendings.dec()) {
|
|
67
|
+
ChildBuildData.setBuildData(buildDataPath, buildData, done);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
_build(pendings, srcFile, dstFile, buildDataPath, buildData, cb) {
|
|
72
|
+
Fs.readFile(srcFile, (err, data) => {
|
|
73
|
+
if(err) {
|
|
74
|
+
Log.log(Clc.red(`Could not read: '`) + srcFile + Clc.red(`'.`), err);
|
|
75
|
+
if(pendings.dec()) {
|
|
76
|
+
cb();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
TaskRunnerGlob.verifyPath(dstFile, (err) => {
|
|
81
|
+
if(err) {
|
|
82
|
+
if(pendings.dec()) {
|
|
83
|
+
cb();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
ChildBuildData.write(srcFile, dstFile, data, buildData, () => {
|
|
88
|
+
if(pendings.dec()) {
|
|
89
|
+
ChildBuildData.setBuildData(buildDataPath, buildData, cb);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
process.nextTick(() => {
|
|
101
|
+
const parameters = JSON.parse(process.argv[2]);
|
|
102
|
+
let isDone = false;
|
|
103
|
+
const childServerRc = new ChildServerRc(...parameters);
|
|
104
|
+
process.on('exit', (code) => {
|
|
105
|
+
if(!isDone) {
|
|
106
|
+
console.log(' EXIT SERVER RC - WITHOUT DONE', childServerRc.name, childServerRc.pendings);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
childServerRc.task(() => {
|
|
110
|
+
if(!isDone) {
|
|
111
|
+
isDone = true;
|
|
112
|
+
process.send(0);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
console.log(' DONE SERVER RC - AGAIN', childServerRc.name);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const Log = require('./log');
|
|
5
|
+
const dynamicConfig = Reflect.get(global, 'dynamicConfig@actorjs_global');
|
|
6
|
+
const Clc = require('cli-color');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class GitGlobal {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.taskName = '';
|
|
12
|
+
this.result = null;
|
|
13
|
+
this.ready = false;
|
|
14
|
+
this.all = dynamicConfig.parameters.has('all');
|
|
15
|
+
this.repo = dynamicConfig.parameters.get('repo');
|
|
16
|
+
this.initiated = false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
init(taskName, all) {
|
|
20
|
+
this.originalTask = taskName;
|
|
21
|
+
this.result = null;
|
|
22
|
+
this.ready = false;
|
|
23
|
+
this.all = undefined === all ? this.all : all;
|
|
24
|
+
this.initiated = true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getTaskName(currentTaskName) {
|
|
28
|
+
if(this.initiated) {
|
|
29
|
+
return this.originalTask;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return currentTaskName;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getResult() {
|
|
37
|
+
if(this.initiated) {
|
|
38
|
+
return this.result;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
Log.log(Clc.red('Error:'), 'GitGlobal is not initiated.');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
setResult(result) {
|
|
46
|
+
if(this.initiated) {
|
|
47
|
+
this.result = result;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
getReady() {
|
|
52
|
+
if(this.initiated) {
|
|
53
|
+
return this.ready;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
Log.log(Clc.red('Error:'), 'GitGlobal is not initiated.');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
setReady(ready) {
|
|
61
|
+
if(this.initiated) {
|
|
62
|
+
this.ready = ready;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
getAll() {
|
|
67
|
+
return this.all;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
getRepo() {
|
|
71
|
+
return this.repo;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
module.exports = GitGlobal;
|