create-aiot 2.0.2-dev.6 → 2.0.2-dev.7

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/index.js CHANGED
@@ -16,36 +16,43 @@ exports.getCrerateXtsCommand = exports.getUxCreateCommand = void 0;
16
16
  const fs_1 = __importDefault(require("fs"));
17
17
  const path_1 = __importDefault(require("path"));
18
18
  const TemplateUtil_1 = __importDefault(require("./utils/TemplateUtil"));
19
+ const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
19
20
  function createAction(options, projectType) {
20
21
  return __awaiter(this, void 0, void 0, function* () {
21
- const templateList = yield TemplateUtil_1.default.requestTemplateList(projectType);
22
- const { name, aspect, packageName, template, eslint = false } = 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
- TemplateUtil_1.default.createProject(param, {
35
- data: { appName: name, packageName },
36
- includes: (path) => {
37
- const stats = fs_1.default.statSync(path);
38
- if (stats.isDirectory()) {
39
- return ['src'].includes(path_1.default.basename(path));
40
- }
41
- else {
42
- return ['.json', '.ux'].includes(path_1.default.extname(path));
22
+ try {
23
+ const templateList = yield TemplateUtil_1.default.requestTemplateList(projectType);
24
+ const { name, aspect, packageName, template, eslint = false } = options;
25
+ const templateItem = templateList.find((item) => item.name === template);
26
+ if (templateItem) {
27
+ const param = {
28
+ name,
29
+ template: templateItem,
30
+ packageName,
31
+ tools: {
32
+ eslint
33
+ },
34
+ aspect
35
+ };
36
+ yield TemplateUtil_1.default.createProject(param, {
37
+ data: { appName: name, packageName },
38
+ includes: (path) => {
39
+ const stats = fs_1.default.statSync(path);
40
+ if (stats.isDirectory()) {
41
+ return ['src'].includes(path_1.default.basename(path));
42
+ }
43
+ else {
44
+ return ['.json', '.ux'].includes(path_1.default.extname(path));
45
+ }
43
46
  }
44
- }
45
- });
47
+ });
48
+ }
49
+ else {
50
+ throw new Error('');
51
+ }
46
52
  }
47
- else {
48
- console.log('template error');
53
+ catch (error) {
54
+ ColorConsole_1.default.error(`Create project error: ${error}`);
55
+ process.exit();
49
56
  }
50
57
  });
51
58
  }
@@ -69,6 +69,7 @@ class TemplateUtil {
69
69
  fs_extra_1.default.mkdirSync(projectAbsolutePath);
70
70
  // 复制模板
71
71
  if (template) {
72
+ ColorConsole_1.default.info('Create project start ...');
72
73
  const { path } = template;
73
74
  // 远程
74
75
  if (['http', 'git'].find((item) => path.startsWith(item))) {
@@ -96,6 +97,7 @@ class TemplateUtil {
96
97
  yield item(projectAbsolutePath, param);
97
98
  }
98
99
  }
100
+ ColorConsole_1.default.success(`Create project finish. project path: ${projectAbsolutePath}`);
99
101
  });
100
102
  }
101
103
  /**
@@ -146,14 +148,7 @@ class TemplateUtil {
146
148
  static changeFileName(projectAbsolutePath) {
147
149
  const oldPath = path_1.default.join(projectAbsolutePath, '_gitignore');
148
150
  const newPath = path_1.default.join(projectAbsolutePath, '.gitignore');
149
- fs_extra_1.default.rename(oldPath, newPath, (err) => {
150
- if (err) {
151
- ColorConsole_1.default.throw(`File _gitignore rename error ${err}`);
152
- }
153
- else {
154
- ColorConsole_1.default.log(`File .gitignore rename success`);
155
- }
156
- });
151
+ fs_extra_1.default.renameSync(oldPath, newPath);
157
152
  }
158
153
  }
159
154
  exports.default = TemplateUtil;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-aiot",
3
- "version": "2.0.2-dev.6",
3
+ "version": "2.0.2-dev.7",
4
4
  "description": "An easy way to start aiot project",
5
5
  "main": "lib/index.js",
6
6
  "keywords": [
@@ -23,7 +23,7 @@
23
23
  "test": "node ./__tests__/create-aiot.test.js"
24
24
  },
25
25
  "dependencies": {
26
- "@aiot-toolkit/commander": "2.0.2-dev.6",
26
+ "@aiot-toolkit/commander": "2.0.2-dev.7",
27
27
  "@inquirer/prompts": "^4.1.0",
28
28
  "ansi-colors": "^4.1.3",
29
29
  "cli-progress": "^3.12.0",
@@ -32,5 +32,5 @@
32
32
  "devDependencies": {
33
33
  "@types/cli-progress": "^3.11.0"
34
34
  },
35
- "gitHead": "736a21d4d2f4fcc102766312d2529e426f27b6c4"
35
+ "gitHead": "26fa71dd55c1f68727ccc2d627a40822074b8ba1"
36
36
  }