@htyf-mp/cli 0.3.12-alpha.8 → 0.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htyf-mp/cli",
3
- "version": "0.3.12-alpha.8",
3
+ "version": "0.4.1",
4
4
  "description": "红糖云服app小程序模板-cli",
5
5
  "type": "module",
6
6
  "bin": {
@@ -82,5 +82,5 @@
82
82
  "publishConfig": {
83
83
  "access": "public"
84
84
  },
85
- "gitHead": "5cc8ce86a85855cdc42d26940185dd63bc758b6b"
85
+ "gitHead": "0acb01b5020e4dd31d993ff5afa87008e1200de9"
86
86
  }
package/src/config.mjs CHANGED
@@ -13,6 +13,10 @@ export class ProjectConfig {
13
13
  };
14
14
 
15
15
  this.templates = {
16
+ [CONSTANTS.TEMPLATE_TYPES.TARO_TEMPLATE]: {
17
+ name: 'taro-template',
18
+ tempPath: '_taro_temp_'
19
+ },
16
20
  [CONSTANTS.TEMPLATE_TYPES.APP_TEMPLATE]: {
17
21
  name: 'app-template',
18
22
  tempPath: '_apps_temp_'
@@ -21,10 +25,6 @@ export class ProjectConfig {
21
25
  name: 'game-template',
22
26
  tempPath: '_game_temp_'
23
27
  },
24
- [CONSTANTS.TEMPLATE_TYPES.WEB_TEMPLATE]: {
25
- name: 'web-template',
26
- tempPath: '_web_temp_'
27
- }
28
28
  };
29
29
  }
30
30
 
package/src/constants.mjs CHANGED
@@ -25,9 +25,9 @@ export const CONSTANTS = {
25
25
  CODING: 'https://e.coding.net/dagouzhi/hongtangyun_mobile/htyf-cli.git'
26
26
  },
27
27
  TEMPLATE_TYPES: {
28
+ TARO_TEMPLATE: 'taro-template',
28
29
  APP_TEMPLATE: 'app-template',
29
30
  GAME_TEMPLATE: 'game-template',
30
- WEB_TEMPLATE: 'web-template',
31
31
  }
32
32
  };
33
33
 
@@ -198,10 +198,10 @@ export class ProjectInitializer {
198
198
  let appType = 'app';
199
199
  if (templateType === CONSTANTS.TEMPLATE_TYPES.GAME_TEMPLATE) {
200
200
  appType = 'game';
201
- } else if (templateType === CONSTANTS.TEMPLATE_TYPES.WEB_TEMPLATE) {
202
- appType = 'web';
203
201
  } else if (templateType === CONSTANTS.TEMPLATE_TYPES.APP_TEMPLATE) {
204
202
  appType = 'app';
203
+ } else if (templateType === CONSTANTS.TEMPLATE_TYPES.TARO_TEMPLATE) {
204
+ appType = 'app';
205
205
  }
206
206
  projectConfig.type = appType;
207
207
  // 写入配置文件
@@ -281,6 +281,11 @@ export class ProjectInitializer {
281
281
 
282
282
  if (templateType === CONSTANTS.TEMPLATE_TYPES.GAME_TEMPLATE) {
283
283
  commands.push(chalk.white(' npm install'));
284
+ } else if (templateType === CONSTANTS.TEMPLATE_TYPES.TARO_TEMPLATE) {
285
+ commands.push(
286
+ chalk.white(' npm install'),
287
+ chalk.white(' npm run dev:htyf')
288
+ );
284
289
  } else {
285
290
  commands.push(
286
291
  chalk.white(' npm install'),
@@ -3,7 +3,6 @@ import path from 'path';
3
3
  import fse from 'fs-extra';
4
4
  import { execa } from 'execa';
5
5
  import { Logger } from './logger.mjs';
6
- import { CONSTANTS } from './constants.mjs';
7
6
 
8
7
  /**
9
8
  * 模板处理器类
@@ -46,18 +45,17 @@ export class TemplateProcessor {
46
45
  path.join(tmpdir, 'README.md')
47
46
  ];
48
47
 
49
- // 根据模板类型移除不需要的模板
50
- if (templateType === CONSTANTS.TEMPLATE_TYPES.GAME_TEMPLATE) {
51
- pathsToRemove.push(path.join(tmpdir, 'mini-game-template'));
52
- }
53
- if (templateType === CONSTANTS.TEMPLATE_TYPES.APP_TEMPLATE) {
54
- pathsToRemove.push(path.join(tmpdir, 'mini-apps-template'));
55
- }
56
- if (templateType === CONSTANTS.TEMPLATE_TYPES.WEB_TEMPLATE) {
57
- pathsToRemove.push(
58
- path.join(tmpdir, 'mini-apps-template'),
59
- path.join(tmpdir, 'mini-game-template')
60
- );
48
+ const cliTemplatesDir = path.join(tmpdir, 'packages/cli');
49
+ const selectedTemplate = this.config.templates[templateType];
50
+ if (selectedTemplate) {
51
+ const selectedPath = path.join(cliTemplatesDir, selectedTemplate.tempPath);
52
+ Object.values(this.config.templates).forEach((template) => {
53
+ const templatePath = path.join(cliTemplatesDir, template.tempPath);
54
+ if (templatePath !== selectedPath) {
55
+ pathsToRemove.push(templatePath);
56
+ }
57
+ });
58
+ pathsToRemove.push(path.join(selectedPath, '.git'));
61
59
  }
62
60
 
63
61
  pathsToRemove.forEach(pathToRemove => {