jjb-cmd 1.0.1 → 1.0.4

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.
File without changes
package/.idea/modules.xml CHANGED
@@ -2,7 +2,7 @@
2
2
  <project version="4">
3
3
  <component name="ProjectModuleManager">
4
4
  <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/jjb-cli.iml" filepath="$PROJECT_DIR$/.idea/jjb-cli.iml" />
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/jjb-cmd.iml" filepath="$PROJECT_DIR$/.idea/jjb-cmd.iml" />
6
6
  </modules>
7
7
  </component>
8
8
  </project>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 jjb-front-team <https://www.cqjjb.cn>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 jjb-front-team <https://www.cqjjb.cn>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/bin/command.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  const commander = require('commander');
4
4
  const cliScripts = require('../src/cli.pull.js');
5
+ const MergeScripts = require('../src/cli.merge.js');
5
6
 
6
7
  commander.command('v').description('-- 查看版本').action(() => {
7
8
  console.log('当前版本 v1.0.0');
@@ -9,15 +10,15 @@ commander.command('v').description('-- 查看版本').action(() => {
9
10
 
10
11
  commander.command('help').description('-- 帮助').action(() => {
11
12
  console.log('使用方法:');
12
- console.log('1.jjb-cli v -- 查看版本。');
13
- console.log('2.jjb-cli help -- 帮助。');
14
- console.log('3.jjb-cli view res -- 预览资源。');
15
- console.log('4.jjb-cli [actionName (有效值 pull)] [...args] -- 基础功能。');
13
+ console.log('1.jjb-cmd v -- 查看版本。');
14
+ console.log('2.jjb-cmd help -- 帮助。');
15
+ console.log('3.jjb-cmd view res -- 预览资源。');
16
+ console.log('4.jjb-cmd [actionName (有效值 pull)] [...args] -- 基础功能。');
16
17
  });
17
18
 
18
19
  commander.command('view res').description('-- 预览资源').action(() => {
19
20
  console.log('当前可资源:');
20
- console.log('[common, admin-components]');
21
+ console.log('[common, react-admin-component]');
21
22
  });
22
23
 
23
24
  // pull 命令
@@ -25,4 +26,15 @@ commander.command('pull -- <文件夹名称必填。>').description('-- 文件
25
26
  cliScripts(res);
26
27
  });
27
28
 
29
+ //多省多应用命令
30
+ commander.command('mp -- <multi prov多省多应用启动dev>').description('-- multi prov多省多应用合并').action(res => {
31
+ MergeScripts(res);
32
+ console.log('start test')
33
+ });
34
+
35
+ //多省单应用
36
+ commander.command('sp -- <single prov多省单应用>').description('-- single prov多省单应用').action(res => {
37
+
38
+ });
39
+
28
40
  commander.parse(process.argv);
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
- {
2
- "name": "jjb-cmd",
3
- "version": "1.0.1",
4
- "description": "",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "node bin/command.js help"
8
- },
9
- "bin": {
10
- "jjb-cli": "bin/command.js"
11
- },
12
- "author": "jjb-front-team",
13
- "license": "MIT",
14
- "dependencies": {
15
- "request": "2.88.2",
16
- "commander": "1.3.2",
17
- "compressing": "^1.5.1"
18
- }
19
- }
1
+ {
2
+ "name": "jjb-cmd",
3
+ "version": "1.0.4",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "node bin/command.js help"
8
+ },
9
+ "bin": {
10
+ "jjb-cmd": "bin/command.js"
11
+ },
12
+ "author": "jjb-front-team",
13
+ "license": "MIT",
14
+ "dependencies": {
15
+ "request": "2.88.2",
16
+ "commander": "1.3.2",
17
+ "compressing": "^1.5.1"
18
+ }
19
+ }
@@ -0,0 +1,69 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const utils = require('./util.js');
4
+
5
+ //项目路径
6
+ let projectPath = '';
7
+ //项目脚手架路径
8
+ let vesselPath = '';
9
+ //input传入参数 指令:地区:环境 start:chongqing:dev
10
+ let commandArr = [];
11
+ //application数据
12
+ let applicationData = {};
13
+ const fromFileData = {};
14
+
15
+ /**
16
+ * input 指令:地区:环境 start:chongqing:dev
17
+ */
18
+ module.exports = input => {
19
+ commandArr = input.split(':');
20
+ projectPath = path.resolve('./project');
21
+ vesselPath = path.resolve('./vessel/src');
22
+ const inputRegion = commandArr[1];
23
+ const settingJson = JSON.parse(fs.readFileSync(`${projectPath}/${inputRegion}/setting.json`).toString());
24
+ TileItems(settingJson.items, () => {
25
+ fromFileData.router.forEach(itemPath => {
26
+ const itemPathArr = itemPath.split(inputRegion);
27
+ console.log(itemPath)
28
+ const filePathArr = itemPathArr.split('/');
29
+ const application = filePathArr[1];
30
+ if (!applicationData[application]) {
31
+ applicationData[application] = {
32
+ routerConfig: [],
33
+ routerPath: []
34
+ };
35
+ }
36
+ applicationJson[application].routerConfig.push(`{ path: '${fromItem.path}', component: () => import('${fromItem.file}') }`);
37
+ applicationJson[application].routerPath.push(fromItem.path);
38
+ utils.CreatePaths(vesselPath, filePathArr.slice(2, filePathArr.length - 1)).then(() => {
39
+ const filePath = filePathArr.slice(2, filePathArr.length);
40
+ const fileContent = fs.readFileSync(`${projectPath}/${inputRegion}/${filePath.join('/')}`).toString();
41
+ fs.writeFileSync(`${projectPath}/${inputRegion}/${filePath.join('/')}`, fileContent);
42
+ });
43
+ });
44
+ });
45
+ };
46
+
47
+ /**
48
+ * 平铺,展开所有路径
49
+ * @param items
50
+ * @param cb
51
+ * @constructor
52
+ */
53
+ function TileItems (items, cb) {
54
+ items.forEach((item, index) => {
55
+ const region = item.region;
56
+ item.from.forEach((from, fromIndex) => {
57
+ const pathArr = [];
58
+ utils.DeepScanner(projectPath + '/' + region + '/' + from.file, pathArr);
59
+ if (!fromFileData[from.fileType]) {
60
+ fromFileData[from.fileType] = pathArr;
61
+ } else {
62
+ fromFileData[from.fileType] = fromFileData[from.fileType].concat(pathArr);
63
+ }
64
+ if (index === items.length - 1 && fromIndex === item.from.length - 1) {
65
+ cb();
66
+ }
67
+ });
68
+ })
69
+ }
package/src/cli.pull.js CHANGED
@@ -17,9 +17,10 @@ const CLOUD_PROJECT = {
17
17
  token: 'G4HJRsHr9D7Ssmixegw2',
18
18
  projectId: 279
19
19
  },
20
- 'admin-components': {
21
- token: '9S83hVV4PKDbsPY9yT5D',
22
- projectId: 280
20
+ 'react-admin-component': {
21
+ token: 'FT3pKzxpRynFkmddJ9Bs',
22
+ projectId: 340,
23
+ localName: 'components'
23
24
  }
24
25
  };
25
26
 
@@ -46,11 +47,9 @@ module.exports = input => {
46
47
  const srcAll = fs.readdirSync(dirUnzip);
47
48
  srcAll.forEach(dirName => {
48
49
  if (dirName.indexOf('-master-') !== -1) {
49
- const nowName = dirName.split('-')[ 0 ];
50
- const nowPath = srcDir + '\\' + nowName;
50
+ const nowPath = srcDir + '\\' + cloudObj.localName;
51
51
  utils.DeleteDirAllFile(nowPath, () => {
52
52
  fs.mkdirSync(nowPath);
53
- console.log(nowPath);
54
53
  utils.CopyFolder(dirUnzip + dirName, nowPath);
55
54
  setTimeout(() => {
56
55
  const isMutilate = fs.existsSync(srcDir + '\\' + 'application');
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="JavaScriptLibraryMappings">
4
- <includedPredefinedLibrary name="Node.js Core" />
5
- </component>
6
- </project>