@htyf-mp/cli 0.3.12-alpha.8 → 0.4.0

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.0",
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": "c1e6aa38bbfda7957c3270cb34a2fa03a37ff533"
86
86
  }
package/src/config.mjs CHANGED
@@ -24,6 +24,10 @@ export class ProjectConfig {
24
24
  [CONSTANTS.TEMPLATE_TYPES.WEB_TEMPLATE]: {
25
25
  name: 'web-template',
26
26
  tempPath: '_web_temp_'
27
+ },
28
+ [CONSTANTS.TEMPLATE_TYPES.TARO_TEMPLATE]: {
29
+ name: 'taro-template',
30
+ tempPath: '_taro_temp_'
27
31
  }
28
32
  };
29
33
  }
package/src/constants.mjs CHANGED
@@ -28,6 +28,7 @@ export const CONSTANTS = {
28
28
  APP_TEMPLATE: 'app-template',
29
29
  GAME_TEMPLATE: 'game-template',
30
30
  WEB_TEMPLATE: 'web-template',
31
+ TARO_TEMPLATE: 'taro-template',
31
32
  }
32
33
  };
33
34
 
@@ -202,6 +202,8 @@ export class ProjectInitializer {
202
202
  appType = 'web';
203
203
  } else if (templateType === CONSTANTS.TEMPLATE_TYPES.APP_TEMPLATE) {
204
204
  appType = 'app';
205
+ } else if (templateType === CONSTANTS.TEMPLATE_TYPES.TARO_TEMPLATE) {
206
+ appType = 'app';
205
207
  }
206
208
  projectConfig.type = appType;
207
209
  // 写入配置文件
@@ -281,6 +283,11 @@ export class ProjectInitializer {
281
283
 
282
284
  if (templateType === CONSTANTS.TEMPLATE_TYPES.GAME_TEMPLATE) {
283
285
  commands.push(chalk.white(' npm install'));
286
+ } else if (templateType === CONSTANTS.TEMPLATE_TYPES.TARO_TEMPLATE) {
287
+ commands.push(
288
+ chalk.white(' npm install'),
289
+ chalk.white(' npm run dev:htyf')
290
+ );
284
291
  } else {
285
292
  commands.push(
286
293
  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 => {