rigjs 1.0.34 → 2.0.0-alpha.1

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.
Files changed (54) hide show
  1. package/bin/rig.js +1 -1
  2. package/built/index.js +384 -0
  3. package/demo/.env.oem1 +4 -0
  4. package/demo/.env.oem2 +4 -0
  5. package/demo/babel.config.js +5 -0
  6. package/demo/cicd.rig.json5 +55 -0
  7. package/demo/jsconfig.json +19 -0
  8. package/demo/package.json +43 -11
  9. package/demo/package.rig.json5 +0 -6
  10. package/demo/public/favicon.ico +0 -0
  11. package/demo/public/index.html +17 -0
  12. package/demo/rig_helper.js +7 -7
  13. package/demo/src/App.vue +28 -0
  14. package/demo/src/assets/logo.png +0 -0
  15. package/demo/src/components/HelloWorld.vue +58 -0
  16. package/demo/src/main.js +8 -0
  17. package/demo/vue.config.js +8 -0
  18. package/demo/yarn.lock +6068 -0
  19. package/lib/build/index.ts +21 -0
  20. package/lib/check/index.d.ts +6 -0
  21. package/lib/check/index.js +0 -1
  22. package/lib/classes/cicd/CICD.ts +112 -0
  23. package/lib/classes/cicd/CICDCmd.ts +65 -0
  24. package/lib/classes/cicd/Deploy/AliDeploy.ts +46 -0
  25. package/lib/classes/cicd/Deploy/CDN.ts +126 -0
  26. package/lib/classes/cicd/Deploy/HuaweiDeploy.ts +0 -0
  27. package/lib/classes/cicd/Deploy/index.ts +0 -0
  28. package/lib/classes/cicd/DirLevel.ts +49 -0
  29. package/lib/classes/cicd/Endpoint.ts +87 -0
  30. package/lib/define/index.ts +47 -0
  31. package/lib/deploy/index.ts +60 -0
  32. package/lib/deps/index.d.ts +6 -0
  33. package/lib/env/index.d.ts +4 -0
  34. package/lib/info/index.d.ts +6 -0
  35. package/lib/init/cicd.rig.json5 +9 -0
  36. package/lib/init/index.d.ts +6 -0
  37. package/lib/init/index.js +49 -34
  38. package/lib/init/rig_helper.js +14 -0
  39. package/lib/install/index.d.ts +5 -0
  40. package/lib/install/index.js +1 -2
  41. package/lib/postinstall/index.d.ts +6 -0
  42. package/lib/preinstall/index.d.ts +6 -0
  43. package/lib/rig/index.ts +49 -0
  44. package/lib/tag/index.d.ts +6 -0
  45. package/lib/tag/index.js +0 -3
  46. package/lib/utils/fsHelper.ts +10 -0
  47. package/lib/utils/index.js +4 -1
  48. package/lib/utils/{regex.js → regex.ts} +9 -3
  49. package/package.json +16 -3
  50. package/tsconfig.json +50 -0
  51. package/.github/workflows/npm-publish.yml +0 -44
  52. package/demo/package.rig2.json5 +0 -8
  53. package/demo/test.js +0 -18
  54. package/lib/rig/index.js +0 -17
package/lib/init/index.js CHANGED
@@ -4,24 +4,22 @@
4
4
  * @author Wang Bo (ralwayne@163.com)
5
5
  * @date 2020/10/9 6:14 PM
6
6
  */
7
- const shell = require('shelljs');
8
7
  const fs = require('fs');
9
- const path = require('path');
10
8
  const json5 = require('json5');
11
- const inquirer = require('inquirer');
12
9
  const chalk = require('chalk');
13
10
  let log = console.log;
14
11
  let green = chalk.green;
15
- let red = chalk.red;
16
12
  let redBright = chalk.redBright;
17
13
 
18
- let yellow = chalk.yellow;
19
-
20
14
  //加载命令控制器
21
15
 
22
- const load = async (cmd) => {
16
+ const load = async () => {
23
17
  try {
24
18
  console.log(chalk.blue('exec init'));
19
+ const pkg = JSON.parse(fs.readFileSync(`${process.cwd()}/package.json`));
20
+
21
+
22
+
25
23
  //检查当前目录是否存在package.json
26
24
  if (!(fs.existsSync('package.json') && fs.lstatSync('package.json').isFile())) {
27
25
  console.log(chalk.red('Please run this in the root directory of project!Must have a validate package.json'));
@@ -32,7 +30,7 @@ const load = async (cmd) => {
32
30
  console.log(chalk.green('package.rig.json5 already exists~'));
33
31
  } else {
34
32
  //创建package.rig.json5.json5
35
- let template =`[
33
+ let template = `[
36
34
  // {
37
35
  // name: "your project name",
38
36
  // source: "git ssh url",
@@ -43,26 +41,43 @@ const load = async (cmd) => {
43
41
  console.log(chalk.green('create package.rig.json5'));
44
42
  fs.writeFileSync('./package.rig.json5', template);
45
43
  }
46
- if (fs.existsSync('rig_helper.js')){
44
+ if (fs.existsSync(`${process.cwd()}/rig_helper.js`)) {
47
45
  console.log(chalk.green('rig_helper.js already exists~'));
48
- }else{
49
- let rigHelper = `const json5 = require('json5');
46
+ } else {
47
+ console.log(chalk.green('create rig_helper.js'));
48
+ let template = `const json5 = require('json5');
50
49
  const fs = require('fs');
51
50
  const getPkgs = () => {
52
- let pkgArr = json5.parse(fs.readFileSync('./package.rig.json5'));
53
- let flatPkgArr = pkgArr.map((item, index) => {
54
- return item.name;
55
- });
56
- console.log(flatPkgArr);
57
- return flatPkgArr;
51
+ \tlet pkgArr = json5.parse(fs.readFileSync('./package.rig.json5'));
52
+ \tlet flatPkgArr = pkgArr.map((item, index) => {
53
+ \t\treturn item.name;
54
+ \t});
55
+ \tconsole.log(flatPkgArr);
56
+ \treturn flatPkgArr;
58
57
  }
59
58
 
60
59
  module.exports = {
61
- getPkgs
60
+ \tgetPkgs
62
61
  }
63
62
  `
64
- console.log(chalk.green('create rig_helper.js'));
65
- fs.writeFileSync('./rig_helper.js', rigHelper);
63
+ fs.writeFileSync(`${process.cwd()}/rig_helper.js`, template);
64
+ }
65
+ if (fs.existsSync(`${process.cwd()}/cicd.rig.json5`)) {
66
+ console.log(chalk.green('cicd.rig.json5 already exists~'));
67
+ } else {
68
+ console.log(chalk.green('create cicd.rig.json5'));
69
+ let template = `{
70
+ tree_schema: '{app}/{env}/{oem}',
71
+ source: {
72
+ root_path: 'dist',
73
+ },
74
+ target: {},
75
+ endpoints: {},
76
+ groups: [],
77
+ }
78
+ `;
79
+ fs.writeFileSync(`${process.cwd()}/cicd.rig.json5`, template);
80
+
66
81
  }
67
82
  //检查rigs是否存在
68
83
  if (fs.existsSync('./rigs') && fs.lstatSync('./rigs').isDirectory()) {
@@ -111,21 +126,21 @@ module.exports = {
111
126
  "rigs/*",
112
127
  "rigs_dev/*"
113
128
  ],
114
- scripts:{
115
- preinstall:"rig preinstall",
116
- postinstall:"rig postinstall",
129
+ scripts: {
130
+ preinstall: "rig preinstall",
131
+ postinstall: "rig postinstall",
117
132
  },
118
- devDependencies:{
119
- json5:'2.1.3'
133
+ devDependencies: {
134
+ json5: '2.1.3'
120
135
  }
121
136
  }
122
137
  pkgJSON.private = inserted.private;
123
138
  //初始化workspaces
124
139
  if (pkgJSON.workspaces && pkgJSON.workspaces instanceof Array) {
125
- if (pkgJSON.workspaces.indexOf('rigs/*')===-1) {
140
+ if (pkgJSON.workspaces.indexOf('rigs/*') === -1) {
126
141
  pkgJSON.workspaces.push('rigs/*')
127
142
  }
128
- if (pkgJSON.workspaces.indexOf('rigs_dev/*')===-1) {
143
+ if (pkgJSON.workspaces.indexOf('rigs_dev/*') === -1) {
129
144
  pkgJSON.workspaces.push('rigs_dev/*')
130
145
  }
131
146
 
@@ -134,26 +149,26 @@ module.exports = {
134
149
  }
135
150
  //初始化pre/post-install
136
151
  if (pkgJSON.scripts && pkgJSON.scripts instanceof Object) {
137
- if (pkgJSON.scripts.preinstall && pkgJSON.scripts.preinstall.indexOf(inserted.scripts.preinstall)<0) {
152
+ if (pkgJSON.scripts.preinstall && pkgJSON.scripts.preinstall.indexOf(inserted.scripts.preinstall) < 0) {
138
153
  pkgJSON.scripts.preinstall = `${pkgJSON.scripts.preinstall} && ${inserted.scripts.preinstall}`
139
- }else{
154
+ } else {
140
155
  pkgJSON.scripts.preinstall = inserted.scripts.preinstall;
141
156
  }
142
- if (pkgJSON.scripts.postinstall && pkgJSON.scripts.postinstall.indexOf(inserted.scripts.postinstall)<0) {
157
+ if (pkgJSON.scripts.postinstall && pkgJSON.scripts.postinstall.indexOf(inserted.scripts.postinstall) < 0) {
143
158
  pkgJSON.scripts.postinstall = `${pkgJSON.scripts.postinstall} && ${inserted.scripts.postinstall}`
144
- }else{
159
+ } else {
145
160
  pkgJSON.scripts.postinstall = inserted.scripts.postinstall;
146
161
  }
147
162
  } else {
148
163
  pkgJSON.scripts = inserted.scripts
149
164
  }
150
- if (pkgJSON.devDependencies){
165
+ if (pkgJSON.devDependencies) {
151
166
  //TODO:可优化
152
167
  pkgJSON.devDependencies.json5 = inserted.devDependencies.json5;
153
- }else{
168
+ } else {
154
169
  pkgJSON.devDependencies = inserted.devDependencies;
155
170
  }
156
- fs.writeFileSync('package.json', JSON.stringify(pkgJSON,null,2));
171
+ fs.writeFileSync('package.json', JSON.stringify(pkgJSON, null, 2));
157
172
  log(green('package.json updated'))
158
173
  } catch (e) {
159
174
  log(redBright(e.message));
@@ -0,0 +1,14 @@
1
+ const json5 = require('json5');
2
+ const fs = require('fs');
3
+ const getPkgs = () => {
4
+ let pkgArr = json5.parse(fs.readFileSync('./package.rig.json5'));
5
+ let flatPkgArr = pkgArr.map((item, index) => {
6
+ return item.name;
7
+ });
8
+ console.log(flatPkgArr);
9
+ return flatPkgArr;
10
+ }
11
+
12
+ module.exports = {
13
+ getPkgs
14
+ }
@@ -0,0 +1,5 @@
1
+ declare namespace install {
2
+ function load(): void;
3
+
4
+ }
5
+ export default install;
@@ -7,7 +7,7 @@
7
7
  const shell = require('shelljs');
8
8
  const print = require('../print')
9
9
  //加载命令控制器
10
- const load = async (cmd) => {
10
+ const load = async () => {
11
11
  print.info('start installing\n');
12
12
  try {
13
13
  let yarnProcess = shell.exec('yarn install',{silent:true});
@@ -24,6 +24,5 @@ const load = async (cmd) => {
24
24
  }
25
25
  }
26
26
  module.exports = {
27
- name: 'install',
28
27
  load
29
28
  }
@@ -0,0 +1,6 @@
1
+ declare namespace postinstall {
2
+ function load(): void;
3
+ const name: string;
4
+
5
+ }
6
+ export default postinstall;
@@ -0,0 +1,6 @@
1
+ declare namespace preinstall {
2
+ function load(): void;
3
+ const name: string;
4
+
5
+ }
6
+ export default preinstall;
@@ -0,0 +1,49 @@
1
+ import {Command} from 'commander';
2
+
3
+ const program = new Command();
4
+ console.log('Hello');
5
+
6
+ import check from '../check';
7
+
8
+ program.command('check').action(check.load);
9
+ import init from '../init';
10
+
11
+ program.command('init').action(init.load);
12
+ import install from '../install';
13
+
14
+ program.command('install').action(install.load);
15
+ program.command('i').action(install.load);
16
+ import preinstall from '../preinstall';
17
+ import postinstall from '../postinstall';
18
+
19
+ program.command('preinstall').action(preinstall.load);
20
+ program.command('postinstall').action(postinstall.load);
21
+ import tag from '../tag';
22
+
23
+ program.command('tag').action(tag.load);
24
+ import info from '../info';
25
+
26
+ program.command('info').action(info.load);
27
+ import build from '../build';
28
+
29
+ program.command('build')
30
+ .option('-s, --schema <schema>', 'specify params in tree_schema')
31
+ .option('-p , --params <params>', 'replace words in cicd.rig.json5, only words in ${} are replacable')
32
+ .action(build);
33
+ // import define from '../define';
34
+ //
35
+ // program.command('define')
36
+ // .option('-s, --schema <schema>', 'specify params in tree_schema')
37
+ // .option('-p , --params <params>', 'replace words in cicd.rig.json5, only words in ${} are replacable')
38
+ // .action(define);
39
+ import deploy from '../deploy';
40
+
41
+ program.command('deploy')
42
+ .option('-s, --schema <schema>', 'specify params in tree_schema')
43
+ .option('-p , --params <params>', 'replace words in cicd.rig.json5, only words in ${} are replacable')
44
+ .action(deploy);
45
+ import env from '../env';
46
+
47
+ program.option('-e, --env <env>', 'specify env').action(env.load);
48
+ program.version(require('../../package.json').version, '-v,--version');
49
+ program.parse(process.argv);
@@ -0,0 +1,6 @@
1
+ declare namespace tag {
2
+ function load(): void;
3
+ const name: string;
4
+
5
+ }
6
+ export default tag;
package/lib/tag/index.js CHANGED
@@ -5,13 +5,10 @@
5
5
  * @date 2020/10/15 3:28 PM
6
6
  */
7
7
  const fs = require('fs');
8
- const JSON5 = require('json5');
9
8
  const shell = require('shelljs');
10
9
  const chalk = require('chalk');
11
10
  const print = require('../print');
12
11
  let red = chalk.red;
13
- let greenBright = chalk.greenBright;
14
- let redBright = chalk.redBright;
15
12
 
16
13
 
17
14
  const load = async ()=>{
@@ -0,0 +1,10 @@
1
+ import fs from 'fs';
2
+
3
+ const JSON5 = require('json5');
4
+ const readCICDConfig = () => {
5
+ const cicdStr = fs.readFileSync(`${process.cwd()}/cicd.rig.json5`);
6
+ return JSON5.parse(cicdStr);
7
+ }
8
+ export default {
9
+ readCICDConfig
10
+ }
@@ -5,6 +5,9 @@
5
5
  * @date 2020/10/10 3:58 PM
6
6
  */
7
7
  const regex = require('./regex');
8
+ const fsHelper = require('./fsHelper');
9
+
8
10
  module.exports ={
9
- regex
11
+ regex,
12
+ fsHelper
10
13
  }
@@ -6,7 +6,13 @@
6
6
  */
7
7
  const gitURL = /(?:git|ssh|https?|git@[-\w.]+):(\/\/)?(.*?)(\.git)(\/?|\#[-\d\w._]+?)$/;
8
8
  const path = /^(\/\w+){0,2}\/?$/;
9
- module.exports = {
10
- gitURL,
11
- path
9
+ /**
10
+ * 文字下划线中划线
11
+ * @type {RegExp}
12
+ */
13
+ const dynamicDir = /(^\[[\w\-]+\]$)|(^\{[\w\-]+\}$)/
14
+ export default {
15
+ gitURL,
16
+ path,
17
+ dynamicDir
12
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rigjs",
3
- "version": "1.0.34",
3
+ "version": "2.0.0-alpha.1",
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",
@@ -28,14 +28,27 @@
28
28
  "c": "d demo && node ../lib/rig/index.js check",
29
29
  "envmake": "cd demo && node ../lib/rig/index.js --env prod_view_zhs",
30
30
  "t": "node lib/rig/index.js tag",
31
- "deliver": "npm publish --registry=https://registry.npmjs.org"
31
+ "deliver": "npm publish --registry=https://registry.npmjs.org",
32
+ "build": "esbuild lib/rig/index.ts --platform=node --bundle --minify --outfile=built/index.js --external:shelljs"
32
33
  },
33
34
  "dependencies": {
35
+ "@types/ali-oss": "^6.16.3",
36
+ "@types/json5": "^2.2.0",
37
+ "@types/qs": "^6.9.7",
38
+ "@types/shelljs": "^0.8.11",
39
+ "@types/uuid": "^8.3.4",
40
+ "ali-oss": "^6.17.1",
41
+ "axios": "^0.26.1",
34
42
  "chalk": "^4.1.0",
35
43
  "commander": "6.1.0",
44
+ "dayjs": "^1.11.0",
36
45
  "inquirer": "7.3.3",
37
46
  "json5": "2.1.3",
38
47
  "ora": "^5.1.0",
39
- "shelljs": "^0.8.4"
48
+ "shelljs": "^0.8.4",
49
+ "uuid": "^8.3.2"
50
+ },
51
+ "devDependencies": {
52
+ "@types/node": "^17.0.21"
40
53
  }
41
54
  }
package/tsconfig.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2015",
4
+ "module": "CommonJS",
5
+ "strict": true,
6
+ "importHelpers": true,
7
+ "moduleResolution": "node",
8
+ "esModuleInterop": true,
9
+ "experimentalDecorators": true,
10
+ "allowSyntheticDefaultImports": true,
11
+ "sourceMap": true,
12
+ "baseUrl": ".",
13
+ "resolveJsonModule": true,
14
+ "outDir": "./built",
15
+ "allowJs": true,
16
+ "types": [
17
+ "node"
18
+ ],
19
+ "paths": {
20
+ "@/*": [
21
+ "./lib/*"
22
+ ],
23
+ "@root/*": [
24
+ "./*"
25
+ ],
26
+ "@static/*": [
27
+ "static/*"
28
+ ],
29
+ "tslib": [
30
+ "node_modules/tslib/tslib.d.ts"
31
+ ]
32
+ },
33
+ "lib": [
34
+ "es2015"
35
+ ]
36
+ },
37
+ "include": [
38
+ "index.ts",
39
+ "rigs/**/*.ts",
40
+ "src/**/*.ts",
41
+ "lib/**/*.ts",
42
+ "lib/**/*.d.ts",
43
+ "lib/**/*.js",
44
+ "test/**/*.ts",
45
+ "typings/**/*.ts",
46
+ ],
47
+ "exclude": [
48
+ "node_modules"
49
+ ]
50
+ }
@@ -1,44 +0,0 @@
1
- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3
-
4
- name: Node.js Package
5
-
6
- on:
7
- push:
8
- branches:
9
- - main
10
-
11
- jobs:
12
- build:
13
- runs-on: ubuntu-latest
14
- steps:
15
- - uses: actions/checkout@v2
16
- - uses: actions/setup-node@v1
17
- with:
18
- node-version: 12
19
-
20
- publish-npm:
21
- needs: build
22
- runs-on: ubuntu-latest
23
- steps:
24
- - uses: actions/checkout@v2
25
- - uses: actions/setup-node@v1
26
- with:
27
- node-version: 12
28
- registry-url: https://registry.npmjs.org/
29
- - run: npm publish
30
- env:
31
- NODE_AUTH_TOKEN: ${{secrets.npm_token}}
32
-
33
- publish-gpr:
34
- needs: build
35
- runs-on: ubuntu-latest
36
- steps:
37
- - uses: actions/checkout@v2
38
- - uses: actions/setup-node@v1
39
- with:
40
- node-version: 12
41
- registry-url: https://npm.pkg.github.com/
42
- - run: npm publish
43
- env:
44
- NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -1,8 +0,0 @@
1
- [
2
- {
3
- name: "r-foundation",
4
- source: "git@git.rys.cn:f2e-common/r-foundation.git",
5
- version: "1.0.1",
6
- dev: true
7
- }
8
- ]
package/demo/test.js DELETED
@@ -1,18 +0,0 @@
1
- // const fs = require('fs');
2
- // let pkgStr = fs.readFileSync('package.json').toString();
3
- // let pkg = JSON.parse(pkgStr);
4
- // console.log(pkg);
5
- // pkg.info = 'test';
6
- // // fs.('package.json');
7
- // fs.writeFileSync('package.json', JSON.stringify(pkg,null,2));
8
- // pkgStr = fs.readFileSync('package.json').toString();
9
- // pkg = JSON.parse(pkgStr);
10
- // console.log(pkg);
11
- //
12
- console.log(/^([a-z]+-){1,3}([0-9]+)(\.([0-9]+)){3}$/.test('a-a-1.2.1.1'));
13
- //cmd
14
- // console.log(/^(\.([0-9]+)){3}$/.test('a-a-1.2.1.1'));
15
- console.log('a-a-1.2.1.1'.split(/(?<=[a-z])-(?=[0-9])/));
16
-
17
- //抓取版本
18
-
package/lib/rig/index.js DELETED
@@ -1,17 +0,0 @@
1
- const { Command } = require('commander');
2
- const program = new Command();
3
- const fs = require('fs');
4
- program.command('check').action(require('../check').load);
5
- program.command('init').action(require('../init').load);
6
- program.command('install').action(require('../install').load);
7
- program.command('i').action(require('../install').load);
8
- program.command('publish').action(require('../publish').load);
9
- program.command('p').action(require('../publish').load);
10
- program.command('preinstall').action(require('../preinstall').load);
11
- program.command('postinstall').action(require('../postinstall').load);
12
- program.command('tag').action(require('../tag').load);
13
- program.command('info').action(require('../info').load);
14
- program.option('-e, --env <env>', 'specify env').action(require('../env').load);
15
-
16
- program.version(require('../../package.json').version,'-v,--version');
17
- program.parse(process.argv);