create-aiot 2.0.3-beta.1 → 2.0.3-beta.10

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/lib/bin.js CHANGED
@@ -1,39 +1,27 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
- return new (P || (P = Promise))(function (resolve, reject) {
6
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
- step((generator = generator.apply(thisArg, _arguments || [])).next());
10
- });
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- const commander_1 = require("@aiot-toolkit/commander");
14
- const prompts_1 = require("@inquirer/prompts");
15
- const _1 = require(".");
16
- function main() {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- if (process.argv.length <= 2) {
19
- const answer = yield (0, prompts_1.select)({
20
- message: 'Select a framework:',
21
- choices: [
22
- {
23
- value: 'ux'
24
- }
25
- ]
26
- });
27
- process.argv.push(answer);
28
- }
29
- // 创建命令行配置
30
- const config = {
31
- name: 'create-aiot',
32
- description: 'create aiot project',
33
- version: require('../package.json').version,
34
- commandList: [yield (0, _1.getCrerateXtsCommand)(), yield (0, _1.getUxCreateCommand)()]
35
- };
36
- commander_1.Command.registeProgram(config);
3
+
4
+ var _commander = require("@aiot-toolkit/commander");
5
+ var _prompts = require("@inquirer/prompts");
6
+ var _ = require(".");
7
+ async function main() {
8
+ if (process.argv.length <= 2) {
9
+ const answer = await (0, _prompts.select)({
10
+ message: 'Select a framework:',
11
+ choices: [{
12
+ value: 'ux'
13
+ }]
37
14
  });
15
+ process.argv.push(answer);
16
+ }
17
+
18
+ // 创建命令行配置
19
+ const config = {
20
+ name: 'create-aiot',
21
+ description: 'create aiot project',
22
+ version: require('../package.json').version,
23
+ commandList: [await (0, _.getCrerateXtsCommand)(), await (0, _.getUxCreateCommand)()]
24
+ };
25
+ _commander.Command.registeProgram(config);
38
26
  }
39
- main();
27
+ main();
package/lib/index.js CHANGED
@@ -1,145 +1,129 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getUxCreateCommand = getUxCreateCommand;
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
16
6
  exports.getCrerateXtsCommand = getCrerateXtsCommand;
17
- const shared_utils_1 = require("@aiot-toolkit/shared-utils");
18
- const fs_1 = __importDefault(require("fs"));
19
- const path_1 = __importDefault(require("path"));
20
- const TemplateUtil_1 = __importDefault(require("./utils/TemplateUtil"));
21
- function createAction(options, projectType) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- try {
24
- const templateList = yield TemplateUtil_1.default.requestTemplateList(projectType);
25
- const { name, aspect, packageName, template, eslint = false } = options;
26
- const templateItem = templateList.find((item) => item.name === template);
27
- if (templateItem) {
28
- const param = {
29
- name,
30
- template: templateItem,
31
- packageName,
32
- tools: {
33
- eslint
34
- },
35
- aspect
36
- };
37
- yield TemplateUtil_1.default.createProject(param, {
38
- data: { appName: name, packageName },
39
- includes: (path) => {
40
- const stats = fs_1.default.statSync(path);
41
- if (stats.isDirectory()) {
42
- return ['src'].includes(path_1.default.basename(path));
43
- }
44
- else {
45
- return ['.json', '.ux'].includes(path_1.default.extname(path));
46
- }
47
- }
48
- });
49
- }
50
- else {
51
- throw new Error('');
52
- }
53
- }
54
- catch (error) {
55
- shared_utils_1.ColorConsole.error(`Create project error: ${error}`);
56
- process.exit();
7
+ exports.getUxCreateCommand = getUxCreateCommand;
8
+ var _sharedUtils = require("@aiot-toolkit/shared-utils");
9
+ var _fs = _interopRequireDefault(require("fs"));
10
+ var _path = _interopRequireDefault(require("path"));
11
+ var _TemplateUtil = _interopRequireDefault(require("./utils/TemplateUtil"));
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ async function createAction(options, projectType) {
14
+ try {
15
+ const templateList = await _TemplateUtil.default.requestTemplateList(projectType);
16
+ const {
17
+ name,
18
+ aspect,
19
+ packageName,
20
+ template,
21
+ eslint = false
22
+ } = options;
23
+ const templateItem = templateList.find(item => item.name === template);
24
+ if (templateItem) {
25
+ const param = {
26
+ name,
27
+ template: templateItem,
28
+ packageName,
29
+ tools: {
30
+ eslint
31
+ },
32
+ aspect
33
+ };
34
+ await _TemplateUtil.default.createProject(param, {
35
+ data: {
36
+ appName: name,
37
+ packageName
38
+ },
39
+ includes: path => {
40
+ const stats = _fs.default.statSync(path);
41
+ if (stats.isDirectory()) {
42
+ return ['src'].includes(_path.default.basename(path));
43
+ } else {
44
+ return ['.json', '.ux'].includes(_path.default.extname(path));
45
+ }
57
46
  }
58
- });
47
+ });
48
+ } else {
49
+ throw new Error('');
50
+ }
51
+ } catch (error) {
52
+ _sharedUtils.ColorConsole.error(`Create project error: ${error}`);
53
+ process.exit();
54
+ }
59
55
  }
60
- function getUxCreateCommand() {
61
- return __awaiter(this, void 0, void 0, function* () {
62
- const templateList = yield TemplateUtil_1.default.requestTemplateList('ux');
56
+ async function getUxCreateCommand() {
57
+ const templateList = await _TemplateUtil.default.requestTemplateList('ux');
58
+ return {
59
+ name: 'ux',
60
+ description: 'default',
61
+ paramList: [{
62
+ name: 'template',
63
+ description: 'prject template',
64
+ type: 'select',
65
+ enableInquirer: true,
66
+ choices: templateList.map(item => {
63
67
  return {
64
- name: 'ux',
65
- description: 'default',
66
- paramList: [
67
- {
68
- name: 'template',
69
- description: 'prject template',
70
- type: 'select',
71
- enableInquirer: true,
72
- choices: templateList.map((item) => {
73
- return {
74
- value: item.name,
75
- description: item.description
76
- };
77
- })
78
- },
79
- {
80
- name: 'name',
81
- description: 'poject name',
82
- enableInquirer: true,
83
- defaultValue: 'aiot-project',
84
- type: 'string',
85
- validate(value) {
86
- return TemplateUtil_1.default.validateProjectName(value);
87
- }
88
- }
89
- ],
90
- action: (option) => {
91
- createAction(option, 'ux');
92
- }
68
+ value: item.name,
69
+ description: item.description
93
70
  };
94
- });
71
+ })
72
+ }, {
73
+ name: 'name',
74
+ description: 'poject name',
75
+ enableInquirer: true,
76
+ defaultValue: 'aiot-project',
77
+ type: 'string',
78
+ validate(value) {
79
+ return _TemplateUtil.default.validateProjectName(value);
80
+ }
81
+ }],
82
+ action: option => {
83
+ createAction(option, 'ux');
84
+ }
85
+ };
95
86
  }
96
- function getCrerateXtsCommand() {
97
- return __awaiter(this, void 0, void 0, function* () {
98
- const templateList = yield TemplateUtil_1.default.requestTemplateList('xts');
87
+ async function getCrerateXtsCommand() {
88
+ const templateList = await _TemplateUtil.default.requestTemplateList('xts');
89
+ return {
90
+ name: 'xts',
91
+ description: 'create xts template project',
92
+ paramList: [{
93
+ name: 'template',
94
+ description: 'prject template',
95
+ type: 'select',
96
+ enableInquirer: true,
97
+ choices: templateList.map(item => {
99
98
  return {
100
- name: 'xts',
101
- description: 'create xts template project',
102
- paramList: [
103
- {
104
- name: 'template',
105
- description: 'prject template',
106
- type: 'select',
107
- enableInquirer: true,
108
- choices: templateList.map((item) => {
109
- return {
110
- value: item.name,
111
- description: item.description
112
- };
113
- })
114
- },
115
- {
116
- name: 'name',
117
- description: 'poject name',
118
- enableInquirer: true,
119
- defaultValue: 'xts-project',
120
- type: 'string',
121
- validate(value) {
122
- return TemplateUtil_1.default.validateProjectName(value);
123
- }
124
- },
125
- {
126
- name: 'packageName',
127
- description: 'package name',
128
- enableInquirer: true,
129
- defaultValue: 'xts.app.test',
130
- type: 'string'
131
- },
132
- {
133
- name: 'aspect',
134
- type: 'string',
135
- defaultValue: 'aspect1',
136
- description: 'Do you need to create some aspect, with multiple aspect names separated by commas',
137
- enableInquirer: true
138
- }
139
- ],
140
- action: (option) => {
141
- createAction(option, 'xts');
142
- }
99
+ value: item.name,
100
+ description: item.description
143
101
  };
144
- });
145
- }
102
+ })
103
+ }, {
104
+ name: 'name',
105
+ description: 'poject name',
106
+ enableInquirer: true,
107
+ defaultValue: 'xts-project',
108
+ type: 'string',
109
+ validate(value) {
110
+ return _TemplateUtil.default.validateProjectName(value);
111
+ }
112
+ }, {
113
+ name: 'packageName',
114
+ description: 'package name',
115
+ enableInquirer: true,
116
+ defaultValue: 'xts.app.test',
117
+ type: 'string'
118
+ }, {
119
+ name: 'aspect',
120
+ type: 'string',
121
+ defaultValue: 'aspect1',
122
+ description: 'Do you need to create some aspect, with multiple aspect names separated by commas',
123
+ enableInquirer: true
124
+ }],
125
+ action: option => {
126
+ createAction(option, 'xts');
127
+ }
128
+ };
129
+ }
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
@@ -1,20 +1,27 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const shared_utils_1 = require("@aiot-toolkit/shared-utils");
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _sharedUtils = require("@aiot-toolkit/shared-utils");
4
8
  class Common {
5
- /**
6
- * 遍历项目文件,替换词语
7
- * @param keywords
8
- * @param projectAbsolutePath
9
- */
10
- static performReplace(keywords, projectAbsolutePath) {
11
- const { data, includes } = keywords;
12
- const files = shared_utils_1.FileUtil.readAlldirSync(projectAbsolutePath, includes);
13
- if (files && files.length) {
14
- files.forEach((item) => {
15
- shared_utils_1.FileUtil.replaceFileContent(item, data);
16
- });
17
- }
9
+ /**
10
+ * 遍历项目文件,替换词语
11
+ * @param keywords
12
+ * @param projectAbsolutePath
13
+ */
14
+ static performReplace(keywords, projectAbsolutePath) {
15
+ const {
16
+ data,
17
+ includes
18
+ } = keywords;
19
+ const files = _sharedUtils.FileUtil.readAlldirSync(projectAbsolutePath, includes);
20
+ if (files && files.length) {
21
+ files.forEach(item => {
22
+ _sharedUtils.FileUtil.replaceFileContent(item, data);
23
+ });
18
24
  }
25
+ }
19
26
  }
20
- exports.default = Common;
27
+ var _default = exports.default = Common;
@@ -1,124 +1,127 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const shared_utils_1 = require("@aiot-toolkit/shared-utils");
16
- const prompts_1 = require("@inquirer/prompts");
17
- const fs_extra_1 = __importDefault(require("fs-extra"));
18
- const path_1 = __importDefault(require("path"));
19
- const Common_1 = __importDefault(require("./Common"));
20
- const XtsTemplateUtil_1 = __importDefault(require("./xts/XtsTemplateUtil"));
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _sharedUtils = require("@aiot-toolkit/shared-utils");
8
+ var _prompts = require("@inquirer/prompts");
9
+ var _fsExtra = _interopRequireDefault(require("fs-extra"));
10
+ var _path = _interopRequireDefault(require("path"));
11
+ var _Common = _interopRequireDefault(require("./Common"));
12
+ var _XtsTemplateUtil = _interopRequireDefault(require("./xts/XtsTemplateUtil"));
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
21
14
  const json = require('../template/template.json');
22
15
  /**
23
16
  * TemplateUtil
24
17
  */
25
18
  class TemplateUtil {
26
- static requestTemplateList(type) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- const item = json.find((item) => item.type === type);
29
- if (!item || !item.demoList) {
30
- shared_utils_1.ColorConsole.throw(`no`, { word: type, style: shared_utils_1.ColorConsole.getStyle(shared_utils_1.Loglevel.THROW) }, `template`);
31
- return [];
32
- }
33
- return item.demoList;
34
- });
19
+ static async requestTemplateList(type) {
20
+ const item = json.find(item => item.type === type);
21
+ if (!item || !item.demoList) {
22
+ _sharedUtils.ColorConsole.throw(`no`, {
23
+ word: type,
24
+ style: _sharedUtils.ColorConsole.getStyle(_sharedUtils.Loglevel.THROW)
25
+ }, `template`);
26
+ return [];
35
27
  }
36
- /**
37
- * 验证项目名称,只能包含:字母、数字、-、_
38
- * @param value
39
- * @returns
40
- */
41
- static validateProjectName(value) {
42
- const reg = /^[0-9a-zA-Z_\u4e00-\u9fa5\-]+$/;
43
- if (!value) {
44
- return `Please enter a project name`;
45
- }
46
- if (!reg.test(value)) {
47
- return 'The project name can contain only Chinese, letters, number, _ , -';
48
- }
49
- return true;
28
+ return item.demoList;
29
+ }
30
+
31
+ /**
32
+ * 验证项目名称,只能包含:字母、数字、-、_
33
+ * @param value
34
+ * @returns
35
+ */
36
+ static validateProjectName(value) {
37
+ const reg = /^[0-9a-zA-Z_\u4e00-\u9fa5\-]+$/;
38
+ if (!value) {
39
+ return `Please enter a project name`;
50
40
  }
51
- /**
52
- * 创建项目
53
- * @param param
54
- * @param keywords
55
- * @param plugins
56
- * @param cwd
57
- */
58
- static createProject(param,
59
- /**
60
- * 要替换的词语
61
- */
62
- keywords, plugins,
63
- /**
64
- * 项目根目录,默认为 process.cwd()
65
- */
66
- cwd) {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- const { name, template, aspect } = param;
69
- const usedCwd = cwd || process.cwd();
70
- // 获取项目名称和绝对路径,如果存在,则再次输入
71
- let projectName = name;
72
- let projectAbsolutePath = path_1.default.join(usedCwd, projectName);
73
- while (fs_extra_1.default.existsSync(projectAbsolutePath)) {
74
- shared_utils_1.ColorConsole.warn(`${projectAbsolutePath} exists. `);
75
- projectName = yield (0, prompts_1.input)({
76
- message: 'please new project name',
77
- validate: this.validateProjectName
78
- });
79
- projectAbsolutePath = path_1.default.join(usedCwd, projectName);
80
- }
81
- fs_extra_1.default.mkdirSync(projectAbsolutePath);
82
- // 复制模板
83
- if (template) {
84
- shared_utils_1.ColorConsole.info('Create project start ...');
85
- const { path } = template;
86
- // 远程
87
- if (['http', 'git'].find((item) => path.startsWith(item))) {
88
- yield shared_utils_1.NetworkUtil.gitClone(path, projectAbsolutePath);
89
- }
90
- //本地
91
- else {
92
- const templateAbsolutePath = path_1.default.join(__dirname, '../template/', path);
93
- fs_extra_1.default.copySync(templateAbsolutePath, projectAbsolutePath);
94
- // 修改_gitignore为.gitignore
95
- TemplateUtil.changeFileName(projectAbsolutePath);
96
- }
97
- }
98
- // 遍历项目文件,替换词语
99
- if (keywords && keywords.data) {
100
- // ux项目,添加toolkitVersion
101
- keywords['data']['toolkitVersion'] = require('../../package.json').version;
102
- Common_1.default.performReplace(keywords, projectAbsolutePath);
103
- }
104
- // xts项目-处理aspect内容
105
- aspect && XtsTemplateUtil_1.default.createAspect(projectAbsolutePath, aspect);
106
- // 执行插件
107
- if (plugins) {
108
- for (let item of plugins) {
109
- yield item(projectAbsolutePath, param);
110
- }
111
- }
112
- shared_utils_1.ColorConsole.success(`Create project finish. project path: ${projectAbsolutePath}`);
113
- });
41
+ if (!reg.test(value)) {
42
+ return 'The project name can contain only Chinese, letters, number, _ , -';
114
43
  }
115
- /**
116
- * 修改_gitignore为.gitignore
117
- */
118
- static changeFileName(projectAbsolutePath) {
119
- const oldPath = path_1.default.join(projectAbsolutePath, '_gitignore');
120
- const newPath = path_1.default.join(projectAbsolutePath, '.gitignore');
121
- fs_extra_1.default.renameSync(oldPath, newPath);
44
+ return true;
45
+ }
46
+
47
+ /**
48
+ * 创建项目
49
+ * @param param
50
+ * @param keywords
51
+ * @param plugins
52
+ * @param cwd
53
+ */
54
+ static async createProject(param,
55
+ /**
56
+ * 要替换的词语
57
+ */
58
+ keywords, plugins,
59
+ /**
60
+ * 项目根目录,默认为 process.cwd()
61
+ */
62
+ cwd) {
63
+ const {
64
+ name,
65
+ template,
66
+ aspect
67
+ } = param;
68
+ const usedCwd = cwd || process.cwd();
69
+
70
+ // 获取项目名称和绝对路径,如果存在,则再次输入
71
+ let projectName = name;
72
+ let projectAbsolutePath = _path.default.join(usedCwd, projectName);
73
+ while (_fsExtra.default.existsSync(projectAbsolutePath)) {
74
+ _sharedUtils.ColorConsole.warn(`${projectAbsolutePath} exists. `);
75
+ projectName = await (0, _prompts.input)({
76
+ message: 'please new project name',
77
+ validate: this.validateProjectName
78
+ });
79
+ projectAbsolutePath = _path.default.join(usedCwd, projectName);
122
80
  }
81
+ _fsExtra.default.mkdirSync(projectAbsolutePath);
82
+
83
+ // 复制模板
84
+ if (template) {
85
+ _sharedUtils.ColorConsole.info('Create project start ...');
86
+ const {
87
+ path
88
+ } = template;
89
+ // 远程
90
+ if (['http', 'git'].find(item => path.startsWith(item))) {
91
+ await _sharedUtils.NetworkUtil.gitClone(path, projectAbsolutePath);
92
+ }
93
+ //本地
94
+ else {
95
+ const templateAbsolutePath = _path.default.join(__dirname, '../template/', path);
96
+ _fsExtra.default.copySync(templateAbsolutePath, projectAbsolutePath);
97
+ // 修改_gitignore为.gitignore
98
+ TemplateUtil.changeFileName(projectAbsolutePath);
99
+ }
100
+ }
101
+ // 遍历项目文件,替换词语
102
+ if (keywords && keywords.data) {
103
+ // ux项目,添加toolkitVersion
104
+ keywords['data']['toolkitVersion'] = require('../../package.json').version;
105
+ _Common.default.performReplace(keywords, projectAbsolutePath);
106
+ }
107
+ // xts项目-处理aspect内容
108
+ aspect && _XtsTemplateUtil.default.createAspect(projectAbsolutePath, aspect);
109
+
110
+ // 执行插件
111
+ if (plugins) {
112
+ for (let item of plugins) {
113
+ await item(projectAbsolutePath, param);
114
+ }
115
+ }
116
+ _sharedUtils.ColorConsole.success(`Create project finish. project path: ${projectAbsolutePath}`);
117
+ }
118
+ /**
119
+ * 修改_gitignore为.gitignore
120
+ */
121
+ static changeFileName(projectAbsolutePath) {
122
+ const oldPath = _path.default.join(projectAbsolutePath, '_gitignore');
123
+ const newPath = _path.default.join(projectAbsolutePath, '.gitignore');
124
+ _fsExtra.default.renameSync(oldPath, newPath);
125
+ }
123
126
  }
124
- exports.default = TemplateUtil;
127
+ var _default = exports.default = TemplateUtil;
@@ -1,39 +1,42 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const path_1 = __importDefault(require("path"));
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const Common_1 = __importDefault(require("../Common"));
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _path = _interopRequireDefault(require("path"));
8
+ var _fsExtra = _interopRequireDefault(require("fs-extra"));
9
+ var _Common = _interopRequireDefault(require("../Common"));
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
11
  class XtsTemplateUtil {
10
- /**
11
- * xts项目-处理aspect内容
12
- * @param projectAbsolutePath
13
- * @param aspect
14
- */
15
- static createAspect(projectAbsolutePath, aspect) {
16
- // 按照逗号分割字符串,且去掉空格
17
- const aspects = aspect.replace(' ', '').split(',');
18
- const aspectAbsolutePath = path_1.default.join(__dirname, '../../template', 'xts', 'aspect1');
19
- // 循环生成自定义aspect
20
- aspects.map((aspectItem) => {
21
- const targetAspectPath = path_1.default.join(projectAbsolutePath, aspectItem);
22
- fs_extra_1.default.copySync(aspectAbsolutePath, targetAspectPath);
23
- // 替换关键字
24
- Common_1.default.performReplace({
25
- data: { aspectName: aspectItem },
26
- includes: (path) => {
27
- const stats = fs_extra_1.default.statSync(path);
28
- if (stats.isDirectory()) {
29
- return ['src'].includes(path_1.default.basename(path));
30
- }
31
- else {
32
- return ['.json', '.ux'].includes(path_1.default.extname(path));
33
- }
34
- }
35
- }, targetAspectPath);
36
- });
37
- }
12
+ /**
13
+ * xts项目-处理aspect内容
14
+ * @param projectAbsolutePath
15
+ * @param aspect
16
+ */
17
+ static createAspect(projectAbsolutePath, aspect) {
18
+ // 按照逗号分割字符串,且去掉空格
19
+ const aspects = aspect.replace(' ', '').split(',');
20
+ const aspectAbsolutePath = _path.default.join(__dirname, '../../template', 'xts', 'aspect1');
21
+ // 循环生成自定义aspect
22
+ aspects.map(aspectItem => {
23
+ const targetAspectPath = _path.default.join(projectAbsolutePath, aspectItem);
24
+ _fsExtra.default.copySync(aspectAbsolutePath, targetAspectPath);
25
+ // 替换关键字
26
+ _Common.default.performReplace({
27
+ data: {
28
+ aspectName: aspectItem
29
+ },
30
+ includes: path => {
31
+ const stats = _fsExtra.default.statSync(path);
32
+ if (stats.isDirectory()) {
33
+ return ['src'].includes(_path.default.basename(path));
34
+ } else {
35
+ return ['.json', '.ux'].includes(_path.default.extname(path));
36
+ }
37
+ }
38
+ }, targetAspectPath);
39
+ });
40
+ }
38
41
  }
39
- exports.default = XtsTemplateUtil;
42
+ var _default = exports.default = XtsTemplateUtil;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-aiot",
3
- "version": "2.0.3-beta.1",
3
+ "version": "2.0.3-beta.10",
4
4
  "description": "An easy way to start aiot project",
5
5
  "main": "lib/index.js",
6
6
  "keywords": [
@@ -23,13 +23,13 @@
23
23
  "test": "node ./__tests__/create-aiot.test.js"
24
24
  },
25
25
  "dependencies": {
26
- "@aiot-toolkit/commander": "2.0.3-beta.1",
27
- "@aiot-toolkit/shared-utils": "2.0.3-beta.1",
26
+ "@aiot-toolkit/commander": "2.0.3-beta.10",
27
+ "@aiot-toolkit/shared-utils": "2.0.3-beta.10",
28
28
  "@inquirer/prompts": "^3.0.3",
29
29
  "fs-extra": "^11.2.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/fs-extra": "^11.0.4"
33
33
  },
34
- "gitHead": "77b1b0aab9b5c227b5cc355b585a7c93761cc9a3"
34
+ "gitHead": "e591934b19bc474453ce11b63f0c8bb0d8eb8bd9"
35
35
  }