rigjs 2.0.0-alpha.12 → 2.0.0-alpha.15
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/built/index.js +83 -83
- package/demo/cicd.rig.json5 +1 -0
- package/lib/build/index.ts +21 -17
- package/package.json +1 -1
package/demo/cicd.rig.json5
CHANGED
package/lib/build/index.ts
CHANGED
|
@@ -4,23 +4,26 @@ import CICDCmd from '@/classes/cicd/CICDCmd';
|
|
|
4
4
|
import shell from 'shelljs';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import fs from 'fs';
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
const JSON5 = require('json5');
|
|
9
|
+
|
|
10
|
+
const replaceDefine = (target: string, defines?: Define) => {
|
|
8
11
|
const dirs = fs.readdirSync(target);
|
|
9
|
-
for (let dir of dirs){
|
|
12
|
+
for (let dir of dirs) {
|
|
10
13
|
const stat = fs.statSync(path.join(target, dir));
|
|
11
|
-
if (stat.isDirectory()){
|
|
12
|
-
replaceDefine(path.join(target, dir),defines);
|
|
13
|
-
}else{
|
|
14
|
-
if (defines){
|
|
14
|
+
if (stat.isDirectory()) {
|
|
15
|
+
replaceDefine(path.join(target, dir), defines);
|
|
16
|
+
} else {
|
|
17
|
+
if (defines) {
|
|
15
18
|
const namePieces = dir.split('.');
|
|
16
19
|
const fileType = namePieces[namePieces.length - 1];
|
|
17
|
-
if (['js','ts'].indexOf(fileType)>=0){
|
|
20
|
+
if (['js', 'ts','html'].indexOf(fileType) >= 0) {
|
|
18
21
|
let file = fs.readFileSync(path.join(target, dir)).toString();
|
|
19
22
|
const replaceArr = Object.keys(defines);
|
|
20
|
-
for (let replace of replaceArr){
|
|
21
|
-
file = file.replace(new RegExp(replace,'g'),defines[replace] as string);
|
|
23
|
+
for (let replace of replaceArr) {
|
|
24
|
+
file = file.replace(new RegExp(replace, 'g'), defines[replace] as string);
|
|
22
25
|
}
|
|
23
|
-
fs.writeFileSync(path.join(target, dir),file);
|
|
26
|
+
fs.writeFileSync(path.join(target, dir), file);
|
|
24
27
|
}
|
|
25
28
|
}
|
|
26
29
|
}
|
|
@@ -34,17 +37,18 @@ export default async (cmd: any) => {
|
|
|
34
37
|
console.log(cicd)
|
|
35
38
|
//build by cicdCmd and cicdConfig
|
|
36
39
|
console.log(cicdCmd.endpoints);
|
|
37
|
-
|
|
40
|
+
const regexPublicPath = new RegExp('\\$public_path', 'g');
|
|
38
41
|
for (let i = 0; i < cicdCmd.endpoints.length; i++) {
|
|
39
42
|
const ep = cicdCmd.endpoints[i];
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
|
|
44
|
+
ep.build = ep.build.replace(regexPublicPath, ep.publicPath);
|
|
45
|
+
try {
|
|
42
46
|
//替换define中的$public_path
|
|
43
|
-
ep.defines =
|
|
44
|
-
}catch (e) {
|
|
45
|
-
console.log(e.message);
|
|
47
|
+
ep.defines = JSON5.parse(JSON5.stringify(ep.defines).replace(regexPublicPath, ep.publicPath));
|
|
48
|
+
} catch (e) {
|
|
49
|
+
console.log('JSON5 error:', e.message);
|
|
46
50
|
}
|
|
47
|
-
console.log('exec build:', ep.build);
|
|
51
|
+
console.log('exec build:', ep, ep.build, ep.defines);
|
|
48
52
|
shell.exec(ep.build);
|
|
49
53
|
replaceDefine(path.join(cicd.source.root_path, ep.dir), ep.defines);
|
|
50
54
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rigjs",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.15",
|
|
4
4
|
"description": "A multi-repos dev tool based on yarn and git.Rig is inspired by cocoapods. Not like those monorepo solutions,rig is a tool for organizing multi-repos.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"modular",
|