create-aiot 2.0.2-dev.8 → 2.0.3-beta.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 (36) hide show
  1. package/lib/bin.js +0 -3
  2. package/lib/index.js +4 -5
  3. package/lib/interface/IProjectParam.d.ts +9 -0
  4. package/lib/template/template.json +6 -1
  5. package/lib/template/ux/android-demo/package.json +17 -0
  6. package/lib/template/ux/android-demo/src/CardDemo/index.ux +24 -0
  7. package/lib/template/ux/android-demo/src/Common/logo.png +0 -0
  8. package/lib/template/ux/android-demo/src/Demo/index.ux +48 -0
  9. package/lib/template/ux/android-demo/src/DemoDetail/index.ux +27 -0
  10. package/lib/template/ux/android-demo/src/app.ux +14 -0
  11. package/lib/template/ux/android-demo/src/global.js +34 -0
  12. package/lib/template/ux/android-demo/src/manifest.json +56 -0
  13. package/lib/template/ux/android-demo/src/sitemap.json +4 -0
  14. package/lib/template/ux/vela-demo/README.md +25 -0
  15. package/lib/template/ux/vela-demo/_gitignore +5 -0
  16. package/lib/template/{vela-demo → ux/vela-demo}/package.json +1 -5
  17. package/lib/utils/Common.d.ts +12 -0
  18. package/lib/utils/Common.js +20 -0
  19. package/lib/utils/TemplateUtil.d.ts +20 -13
  20. package/lib/utils/TemplateUtil.js +28 -58
  21. package/lib/utils/xts/XtsTemplateUtil.d.ts +9 -0
  22. package/lib/utils/xts/XtsTemplateUtil.js +39 -0
  23. package/package.json +6 -7
  24. package/lib/template/ux/project.config.json +0 -5
  25. package/lib/template/ux/src/app.ux +0 -3
  26. /package/lib/template/{vela-demo → ux/android-demo}/README.md +0 -0
  27. /package/lib/template/{vela-demo → ux/android-demo}/_gitignore +0 -0
  28. /package/lib/template/{vela-demo → ux/vela-demo}/src/app.ux +0 -0
  29. /package/lib/template/{vela-demo → ux/vela-demo}/src/common/logo.png +0 -0
  30. /package/lib/template/{vela-demo → ux/vela-demo}/src/config-watch.json +0 -0
  31. /package/lib/template/{vela-demo → ux/vela-demo}/src/i18n/defaults.json +0 -0
  32. /package/lib/template/{vela-demo → ux/vela-demo}/src/i18n/en.json +0 -0
  33. /package/lib/template/{vela-demo → ux/vela-demo}/src/i18n/zh-CN.json +0 -0
  34. /package/lib/template/{vela-demo → ux/vela-demo}/src/manifest.json +0 -0
  35. /package/lib/template/{vela-demo → ux/vela-demo}/src/pages/detail/detail.ux +0 -0
  36. /package/lib/template/{vela-demo → ux/vela-demo}/src/pages/index/index.ux +0 -0
package/lib/bin.js CHANGED
@@ -21,9 +21,6 @@ function main() {
21
21
  choices: [
22
22
  {
23
23
  value: 'ux'
24
- },
25
- {
26
- value: 'xts'
27
24
  }
28
25
  ]
29
26
  });
package/lib/index.js CHANGED
@@ -12,11 +12,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getCrerateXtsCommand = exports.getUxCreateCommand = void 0;
15
+ exports.getUxCreateCommand = getUxCreateCommand;
16
+ exports.getCrerateXtsCommand = getCrerateXtsCommand;
17
+ const shared_utils_1 = require("@aiot-toolkit/shared-utils");
16
18
  const fs_1 = __importDefault(require("fs"));
17
19
  const path_1 = __importDefault(require("path"));
18
20
  const TemplateUtil_1 = __importDefault(require("./utils/TemplateUtil"));
19
- const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
20
21
  function createAction(options, projectType) {
21
22
  return __awaiter(this, void 0, void 0, function* () {
22
23
  try {
@@ -51,7 +52,7 @@ function createAction(options, projectType) {
51
52
  }
52
53
  }
53
54
  catch (error) {
54
- ColorConsole_1.default.error(`Create project error: ${error}`);
55
+ shared_utils_1.ColorConsole.error(`Create project error: ${error}`);
55
56
  process.exit();
56
57
  }
57
58
  });
@@ -92,7 +93,6 @@ function getUxCreateCommand() {
92
93
  };
93
94
  });
94
95
  }
95
- exports.getUxCreateCommand = getUxCreateCommand;
96
96
  function getCrerateXtsCommand() {
97
97
  return __awaiter(this, void 0, void 0, function* () {
98
98
  const templateList = yield TemplateUtil_1.default.requestTemplateList('xts');
@@ -143,4 +143,3 @@ function getCrerateXtsCommand() {
143
143
  };
144
144
  });
145
145
  }
146
- exports.getCrerateXtsCommand = getCrerateXtsCommand;
@@ -3,11 +3,20 @@ import ITemplate from './ITemplate';
3
3
  * IProjectParam
4
4
  */
5
5
  export default interface IProjectParam {
6
+ /**
7
+ * 项目名
8
+ */
6
9
  name: string;
10
+ /**
11
+ * 模型对象,一般从 template.json 中获取
12
+ */
7
13
  template: ITemplate;
8
14
  tools: {
9
15
  eslint: boolean;
10
16
  };
11
17
  aspect?: string;
18
+ /**
19
+ * 包名
20
+ */
12
21
  packageName?: string;
13
22
  }
@@ -4,8 +4,13 @@
4
4
  "demoList": [
5
5
  {
6
6
  "name": "vela-demo",
7
- "path": "./vela-demo",
7
+ "path": "./ux/vela-demo",
8
8
  "description": "vela demo template"
9
+ },
10
+ {
11
+ "name": "android-demo",
12
+ "path": "./ux/android-demo",
13
+ "description": "android demo template"
9
14
  }
10
15
  ]
11
16
  },
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "{{ appName }}",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "engines": {
6
+ "node": ">=8.10"
7
+ },
8
+ "scripts": {
9
+ "start": "aiot start",
10
+ "build": "aiot build",
11
+ "release": "aiot release",
12
+ "lint": "eslint --format codeframe --fix --ext .ux,.js src/"
13
+ },
14
+ "devDependencies": {
15
+ "aiot-toolkit": "^{{ toolkitVersion }}"
16
+ }
17
+ }
@@ -0,0 +1,24 @@
1
+ <template>
2
+ <!-- template里只能有一个根节点 -->
3
+ <div class="demo-page">
4
+ <text>{{text}}</text>
5
+ <text>{{des}}</text>
6
+ </div>
7
+ </template>
8
+
9
+ <script>
10
+ export default {
11
+ private: {
12
+ text: '欢迎使用快应用卡片',
13
+ des: '卡片是一种轻量级的快应用,快应用卡片使快应用能够在其他app和系统里提供可扩展的app功能'
14
+ }
15
+ }
16
+ </script>
17
+
18
+ <style>
19
+ .demo-page {
20
+ flex: 1;
21
+ flex-direction: column;
22
+ align-items: center;
23
+ }
24
+ </style>
@@ -0,0 +1,48 @@
1
+ <template>
2
+ <!-- template里只能有一个根节点 -->
3
+ <div class="demo-page">
4
+ <text class="title">欢迎打开{{title}}</text>
5
+ <!-- 点击跳转详情页 -->
6
+ <input class="btn" type="button" value="跳转到详情页" onclick="routeDetail" />
7
+ </div>
8
+ </template>
9
+
10
+ <script>
11
+ import router from '@system.router'
12
+
13
+ export default {
14
+ // 页面级组件的数据模型,影响传入数据的覆盖机制:private内定义的属性不允许被覆盖
15
+ private: {
16
+ title: '示例页面'
17
+ },
18
+ routeDetail () {
19
+ // 跳转到应用内的某个页面,router用法详见:文档->接口->页面路由
20
+ router.push ({
21
+ uri: '/DemoDetail'
22
+ })
23
+ }
24
+ }
25
+ </script>
26
+
27
+ <style>
28
+ .demo-page {
29
+ flex-direction: column;
30
+ justify-content: center;
31
+ align-items: center;
32
+ }
33
+
34
+ .title {
35
+ font-size: 40px;
36
+ text-align: center;
37
+ }
38
+
39
+ .btn {
40
+ width: 550px;
41
+ height: 86px;
42
+ margin-top: 75px;
43
+ border-radius: 43px;
44
+ background-color: #09ba07;
45
+ font-size: 30px;
46
+ color: #ffffff;
47
+ }
48
+ </style>
@@ -0,0 +1,27 @@
1
+ <template>
2
+ <!-- template里只能有一个根节点 -->
3
+ <div class="demo-page">
4
+ <text class="title">{{text}}</text>
5
+ </div>
6
+ </template>
7
+
8
+ <script>
9
+ export default {
10
+ private: {
11
+ text: '欢迎打开详情页'
12
+ }
13
+ }
14
+ </script>
15
+
16
+ <style>
17
+ .demo-page {
18
+ flex-direction: column;
19
+ justify-content: center;
20
+ align-items: center;
21
+ }
22
+
23
+ .title {
24
+ font-size: 40px;
25
+ text-align: center;
26
+ }
27
+ </style>
@@ -0,0 +1,14 @@
1
+ <script>
2
+ /**
3
+ * @file 应用级别的配置,供所有页面公用
4
+ * 可在app.ux导出公用变量
5
+ * 其他src目录下的ux文件使用this.$app.$def.<paramName>即可调用此处导出的变量
6
+ * 文档地址: https://doc.quickapp.cn/framework/source-file.html#appux
7
+ */
8
+
9
+ // 引入全局函数定义文件global.js
10
+ import './global'
11
+
12
+ export default {}
13
+
14
+ </script>
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @file 全局能力的配置与获取
3
+ * 文档地址:https://doc.quickapp.cn/tutorial/framework/optimization-skills.html#%E4%BD%BF%E7%94%A8-globaljs
4
+ */
5
+
6
+ function getGlobalRef() {
7
+ return Object.getPrototypeOf(global) || global
8
+ }
9
+
10
+ const quickappGlobal = getGlobalRef()
11
+
12
+ /**
13
+ * 设置全局(被APP与Page共享)数据;
14
+ * @param key {string}
15
+ * @param val {*}
16
+ */
17
+ function setGlobalData(key, val) {
18
+ quickappGlobal[key] = val
19
+ }
20
+
21
+ /**
22
+ * 获取全局(被APP与Page共享)数据;
23
+ * @param key {string}
24
+ * @return {*}
25
+ */
26
+ function getGlobalData(key) {
27
+ return quickappGlobal[key]
28
+ }
29
+
30
+ // 两个方法默认定义在全局
31
+ setGlobalData('setGlobalData', setGlobalData)
32
+ setGlobalData('getGlobalData', getGlobalData)
33
+
34
+ export { setGlobalData, getGlobalData }
@@ -0,0 +1,56 @@
1
+ {
2
+ "package": "com.application.demo",
3
+ "name": "{{appName}}",
4
+ "versionName": "1.0.0",
5
+ "versionCode": 1,
6
+ "minPlatformVersion": 1070,
7
+ "icon": "/Common/logo.png",
8
+ "deviceTypeList": ["phone"],
9
+ "features": [
10
+ { "name": "system.prompt" },
11
+ { "name": "system.router" },
12
+ { "name": "system.shortcut" }
13
+ ],
14
+ "permissions": [
15
+ { "origin": "*" }
16
+ ],
17
+ "config": {
18
+ "logLevel": "log"
19
+ },
20
+ "router": {
21
+ "entry": "Demo",
22
+ "pages": {
23
+ "Demo": {
24
+ "component": "index"
25
+ },
26
+ "DemoDetail": {
27
+ "component": "index"
28
+ }
29
+ },
30
+ "widgets": {
31
+ "CardDemo": {
32
+ "name": "CardDemo",
33
+ "description": "快应用卡片展示",
34
+ "component": "index",
35
+ "path": "/CardDemo",
36
+ "features": []
37
+ }
38
+ }
39
+ },
40
+ "display": {
41
+ "titleBarBackgroundColor": "#f2f2f2",
42
+ "titleBarTextColor": "#414141",
43
+ "menu": false,
44
+ "menuBarData": {
45
+ "menuBar": true
46
+ },
47
+ "pages": {
48
+ "Demo": {
49
+ "titleBarText": "示例页"
50
+ },
51
+ "DemoDetail": {
52
+ "titleBarText": "详情页"
53
+ }
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "doc": "https://doc.quickapp.cn/framework/sitemap.html",
3
+ "rules": [{ "rule": "enable", "page": "*" }]
4
+ }
@@ -0,0 +1,25 @@
1
+ ## 快速上手
2
+
3
+ ### 1. 开发
4
+
5
+ ```
6
+ npm install
7
+ npm run start
8
+ ```
9
+
10
+ ### 2. 构建
11
+
12
+ ```
13
+ npm run build
14
+ npm run release
15
+ ```
16
+
17
+ ### 3. 调试
18
+
19
+ ```
20
+ npm run watch
21
+ ```
22
+
23
+ ## 了解更多
24
+
25
+ 你可以通过我们的[官方文档](https://iot.mi.com/vela/quickapp)熟悉和了解快应用。
@@ -0,0 +1,5 @@
1
+ /.nyc_output
2
+ /coverage
3
+ /node_modules
4
+ /dist
5
+ /build
@@ -12,11 +12,7 @@
12
12
  "lint": "eslint --format codeframe --fix --ext .ux,.js src/"
13
13
  },
14
14
  "devDependencies": {
15
- "@aiot-toolkit/velasim": "^0.1.23",
16
15
  "@aiot-toolkit/jsc": "^1.0.3",
17
- "aiot-toolkit": "^{{ toolkitVersion }}",
18
- "babel-eslint": "^10.0.1",
19
- "eslint": "^6.8.0",
20
- "eslint-plugin-ux": "^0.0.4"
16
+ "aiot-toolkit": "^{{ toolkitVersion }}"
21
17
  }
22
18
  }
@@ -0,0 +1,12 @@
1
+ declare class Common {
2
+ /**
3
+ * 遍历项目文件,替换词语
4
+ * @param keywords
5
+ * @param projectAbsolutePath
6
+ */
7
+ static performReplace(keywords: {
8
+ data: Record<string, string>;
9
+ includes?: (path: string) => boolean;
10
+ }, projectAbsolutePath: string): void;
11
+ }
12
+ export default Common;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const shared_utils_1 = require("@aiot-toolkit/shared-utils");
4
+ 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
+ }
18
+ }
19
+ }
20
+ exports.default = Common;
@@ -11,26 +11,33 @@ declare class TemplateUtil {
11
11
  * @returns
12
12
  */
13
13
  static validateProjectName(value: string): boolean | string;
14
- static createXtsProject(): Promise<void>;
15
- static createProject(param: IProjectParam, keywords?: {
16
- data: Record<string, string>;
17
- includes?: (path: string) => boolean;
18
- }, plugins?: ((projectPath: string, param: IProjectParam) => Promise<void>)[]): Promise<void>;
19
14
  /**
20
- * 遍历项目文件,替换词语
15
+ * 创建项目
16
+ * @param param
21
17
  * @param keywords
22
- * @param projectAbsolutePath
18
+ * @param plugins
19
+ * @param cwd
20
+ */
21
+ static createProject(param: IProjectParam,
22
+ /**
23
+ * 要替换的词语
23
24
  */
24
- static performReplace(keywords: {
25
+ keywords?: {
26
+ /**
27
+ * [原词]:新词
28
+ */
25
29
  data: Record<string, string>;
30
+ /**
31
+ * 是否对 path文件 执行替换操作
32
+ * @param path
33
+ * @returns
34
+ */
26
35
  includes?: (path: string) => boolean;
27
- }, projectAbsolutePath: string): void;
36
+ }, plugins?: ((projectPath: string, param: IProjectParam) => Promise<void>)[],
28
37
  /**
29
- * xts项目-处理aspect内容
30
- * @param projectAbsolutePath
31
- * @param aspect
38
+ * 项目根目录,默认为 process.cwd()
32
39
  */
33
- static createAspect(projectAbsolutePath: string, aspect: string): void;
40
+ cwd?: string): Promise<void>;
34
41
  /**
35
42
  * 修改_gitignore为.gitignore
36
43
  */
@@ -13,12 +13,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const shared_utils_1 = require("@aiot-toolkit/shared-utils");
16
- const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
17
- const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
18
- const NetworkUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/NetworkUtil"));
19
16
  const prompts_1 = require("@inquirer/prompts");
20
17
  const fs_extra_1 = __importDefault(require("fs-extra"));
21
18
  const path_1 = __importDefault(require("path"));
19
+ const Common_1 = __importDefault(require("./Common"));
20
+ const XtsTemplateUtil_1 = __importDefault(require("./xts/XtsTemplateUtil"));
22
21
  const json = require('../template/template.json');
23
22
  /**
24
23
  * TemplateUtil
@@ -28,7 +27,7 @@ class TemplateUtil {
28
27
  return __awaiter(this, void 0, void 0, function* () {
29
28
  const item = json.find((item) => item.type === type);
30
29
  if (!item || !item.demoList) {
31
- ColorConsole_1.default.throw(`no`, { word: type, style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Throw) }, `template`);
30
+ shared_utils_1.ColorConsole.throw(`no`, { word: type, style: shared_utils_1.ColorConsole.getStyle(shared_utils_1.Loglevel.THROW) }, `template`);
32
31
  return [];
33
32
  }
34
33
  return item.demoList;
@@ -49,31 +48,44 @@ class TemplateUtil {
49
48
  }
50
49
  return true;
51
50
  }
52
- static createXtsProject() {
53
- return __awaiter(this, void 0, void 0, function* () { });
54
- }
55
- static createProject(param, keywords, plugins) {
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) {
56
67
  return __awaiter(this, void 0, void 0, function* () {
57
68
  const { name, template, aspect } = param;
69
+ const usedCwd = cwd || process.cwd();
58
70
  // 获取项目名称和绝对路径,如果存在,则再次输入
59
71
  let projectName = name;
60
- let projectAbsolutePath = path_1.default.join(process.cwd(), projectName);
72
+ let projectAbsolutePath = path_1.default.join(usedCwd, projectName);
61
73
  while (fs_extra_1.default.existsSync(projectAbsolutePath)) {
62
- ColorConsole_1.default.warn(`${projectAbsolutePath} exists. `);
74
+ shared_utils_1.ColorConsole.warn(`${projectAbsolutePath} exists. `);
63
75
  projectName = yield (0, prompts_1.input)({
64
76
  message: 'please new project name',
65
77
  validate: this.validateProjectName
66
78
  });
67
- projectAbsolutePath = path_1.default.join(process.cwd(), projectName);
79
+ projectAbsolutePath = path_1.default.join(usedCwd, projectName);
68
80
  }
69
81
  fs_extra_1.default.mkdirSync(projectAbsolutePath);
70
82
  // 复制模板
71
83
  if (template) {
72
- ColorConsole_1.default.info('Create project start ...');
84
+ shared_utils_1.ColorConsole.info('Create project start ...');
73
85
  const { path } = template;
74
86
  // 远程
75
87
  if (['http', 'git'].find((item) => path.startsWith(item))) {
76
- yield NetworkUtil_1.default.gitClone(path, projectAbsolutePath);
88
+ yield shared_utils_1.NetworkUtil.gitClone(path, projectAbsolutePath);
77
89
  }
78
90
  //本地
79
91
  else {
@@ -87,59 +99,17 @@ class TemplateUtil {
87
99
  if (keywords && keywords.data) {
88
100
  // ux项目,添加toolkitVersion
89
101
  keywords['data']['toolkitVersion'] = require('../../package.json').version;
90
- TemplateUtil.performReplace(keywords, projectAbsolutePath);
102
+ Common_1.default.performReplace(keywords, projectAbsolutePath);
91
103
  }
92
104
  // xts项目-处理aspect内容
93
- aspect && TemplateUtil.createAspect(projectAbsolutePath, aspect);
105
+ aspect && XtsTemplateUtil_1.default.createAspect(projectAbsolutePath, aspect);
94
106
  // 执行插件
95
107
  if (plugins) {
96
108
  for (let item of plugins) {
97
109
  yield item(projectAbsolutePath, param);
98
110
  }
99
111
  }
100
- ColorConsole_1.default.success(`Create project finish. project path: ${projectAbsolutePath}`);
101
- });
102
- }
103
- /**
104
- * 遍历项目文件,替换词语
105
- * @param keywords
106
- * @param projectAbsolutePath
107
- */
108
- static performReplace(keywords, projectAbsolutePath) {
109
- const { data, includes } = keywords;
110
- const files = FileUtil_1.default.readAlldirSync(projectAbsolutePath, includes);
111
- if (files && files.length) {
112
- files.forEach((item) => {
113
- FileUtil_1.default.replaceFileContent(item, data);
114
- });
115
- }
116
- }
117
- /**
118
- * xts项目-处理aspect内容
119
- * @param projectAbsolutePath
120
- * @param aspect
121
- */
122
- static createAspect(projectAbsolutePath, aspect) {
123
- // 按照逗号分割字符串,且去掉空格
124
- const aspects = aspect.replace(' ', '').split(',');
125
- const aspectAbsolutePath = path_1.default.join(__dirname, '../template', 'xts', 'aspect1');
126
- // 循环生成自定义aspect
127
- aspects.map((aspectItem) => {
128
- const targetAspectPath = path_1.default.join(projectAbsolutePath, aspectItem);
129
- fs_extra_1.default.copySync(aspectAbsolutePath, targetAspectPath);
130
- // 替换关键字
131
- TemplateUtil.performReplace({
132
- data: { aspectName: aspectItem },
133
- includes: (path) => {
134
- const stats = fs_extra_1.default.statSync(path);
135
- if (stats.isDirectory()) {
136
- return ['src'].includes(path_1.default.basename(path));
137
- }
138
- else {
139
- return ['.json', '.ux'].includes(path_1.default.extname(path));
140
- }
141
- }
142
- }, targetAspectPath);
112
+ shared_utils_1.ColorConsole.success(`Create project finish. project path: ${projectAbsolutePath}`);
143
113
  });
144
114
  }
145
115
  /**
@@ -0,0 +1,9 @@
1
+ declare class XtsTemplateUtil {
2
+ /**
3
+ * xts项目-处理aspect内容
4
+ * @param projectAbsolutePath
5
+ * @param aspect
6
+ */
7
+ static createAspect(projectAbsolutePath: string, aspect: string): void;
8
+ }
9
+ export default XtsTemplateUtil;
@@ -0,0 +1,39 @@
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"));
9
+ 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
+ }
38
+ }
39
+ exports.default = XtsTemplateUtil;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-aiot",
3
- "version": "2.0.2-dev.8",
3
+ "version": "2.0.3-beta.1",
4
4
  "description": "An easy way to start aiot project",
5
5
  "main": "lib/index.js",
6
6
  "keywords": [
@@ -23,14 +23,13 @@
23
23
  "test": "node ./__tests__/create-aiot.test.js"
24
24
  },
25
25
  "dependencies": {
26
- "@aiot-toolkit/commander": "2.0.2-dev.8",
26
+ "@aiot-toolkit/commander": "2.0.3-beta.1",
27
+ "@aiot-toolkit/shared-utils": "2.0.3-beta.1",
27
28
  "@inquirer/prompts": "^3.0.3",
28
- "ansi-colors": "^4.1.3",
29
- "cli-progress": "^3.12.0",
30
- "simple-git": "^3.19.1"
29
+ "fs-extra": "^11.2.0"
31
30
  },
32
31
  "devDependencies": {
33
- "@types/cli-progress": "^3.11.0"
32
+ "@types/fs-extra": "^11.0.4"
34
33
  },
35
- "gitHead": "831575362ba47778c9441f95cec41ddded36cffc"
34
+ "gitHead": "77b1b0aab9b5c227b5cc355b585a7c93761cc9a3"
36
35
  }
@@ -1,5 +0,0 @@
1
- {
2
- "name": "{{appName}}",
3
- "version": "{{version}}",
4
- "projectType": "ux"
5
- }
@@ -1,3 +0,0 @@
1
- <template>
2
- appname is {{appName}}
3
- </template>