@htyf-mp/cli 0.2.16 → 0.2.18

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.2.16",
3
+ "version": "0.2.18",
4
4
  "description": "红糖云服app小程序模板-cli",
5
5
  "type": "module",
6
6
  "bin": {
package/src/build.mjs CHANGED
@@ -147,10 +147,11 @@ export async function mpBuildShell(newAppInfo, isGodot = false) {
147
147
  const scriptName = getMiniAppScriptId(appid, version);
148
148
 
149
149
  // 构建 app.json 配置
150
+ const appType = newAppInfo.type || (isGodot ? 'game' : 'app');
150
151
  const appJson = {
151
152
  ...newAppInfo,
152
153
  rotate: newAppInfo.rotate || 'portrait',
153
- type: isGodot ? 'game' : 'app', // Godot 项目类型为 'game',普通小程序为 'app'
154
+ type: appType, // 支持 app / game / web 等类型
154
155
  engines: '2.0.0',
155
156
  name: newAppInfo.name,
156
157
  appid,
@@ -207,7 +208,8 @@ export async function mpBuildShell(newAppInfo, isGodot = false) {
207
208
 
208
209
  // ========== 执行构建 ==========
209
210
  try {
210
- if (!isGodot) {
211
+ const isWeb = appType === 'web';
212
+ if (!isGodot && !isWeb) {
211
213
  // ========== 普通小程序构建流程 ==========
212
214
  Logger.info('使用 React Native 构建小程序包...');
213
215
 
@@ -247,7 +249,7 @@ export async function mpBuildShell(newAppInfo, isGodot = false) {
247
249
  timeout: 120000, // 2 分钟超时
248
250
  showCommand: false
249
251
  });
250
- } else {
252
+ } else if (isGodot) {
251
253
  // ========== Godot 游戏构建流程 ==========
252
254
  Logger.info('检测到 Godot 项目,开始执行 Godot 导出流程...');
253
255
 
@@ -286,7 +288,7 @@ export async function mpBuildShell(newAppInfo, isGodot = false) {
286
288
  // 将 app.json 复制到输出目录
287
289
  await fse.ensureDir(outputPath);
288
290
  await fse.copy(appJsonPath, path.join(outputPath, 'app.json'));
289
- if (!isGodot) {
291
+ if (!isGodot && appType !== 'web') {
290
292
  fse.copyFileSync(path.join(outputPath, '../manifest.json'), path.join(outputPath, 'manifest.json'));
291
293
  }
292
294
 
package/src/config.mjs CHANGED
@@ -20,6 +20,10 @@ export class ProjectConfig {
20
20
  [CONSTANTS.TEMPLATE_TYPES.GAME_TEMPLATE]: {
21
21
  name: 'game-template',
22
22
  tempPath: '_game_temp_'
23
+ },
24
+ [CONSTANTS.TEMPLATE_TYPES.WEB_TEMPLATE]: {
25
+ name: 'web-template',
26
+ tempPath: '_web_temp_'
23
27
  }
24
28
  };
25
29
  }
@@ -38,7 +42,7 @@ export class ProjectConfig {
38
42
  const timestamp = Date.now();
39
43
  const randomUuid = uuidv4();
40
44
  const uniqueString = `${timestamp}-${randomUuid}`;
41
- return md5(uniqueString);
45
+ return `htyfapp${md5(uniqueString)}`;
42
46
  }
43
47
 
44
48
  createProjectConfig(appName, displayName, appid, rotate) {
package/src/constants.mjs CHANGED
@@ -27,6 +27,7 @@ export const CONSTANTS = {
27
27
  TEMPLATE_TYPES: {
28
28
  APP_TEMPLATE: 'app-template',
29
29
  GAME_TEMPLATE: 'game-template',
30
+ WEB_TEMPLATE: 'web-template',
30
31
  }
31
32
  };
32
33
 
package/src/debug.mjs CHANGED
@@ -45,8 +45,10 @@ import { printQrcode } from './utils-functions.mjs';
45
45
  export async function mpDebugShell(newAppInfo, isGodot = false) {
46
46
  try {
47
47
  // ========== 参数验证 ==========
48
- // Godot 项目不需要 entry 字段,普通小程序需要
49
- if (!isGodot && !newAppInfo.entry) {
48
+ // Godot 项目不需要 entry 字段,Web 类型也不需要;
49
+ // 仅普通小程序(非 Godot 且非 Web)需要 entry
50
+ const isWeb = newAppInfo.type === 'web';
51
+ if (!isGodot && !isWeb && !newAppInfo.entry) {
50
52
  throw new Error('缺少必需的应用信息: entry');
51
53
  }
52
54
 
@@ -53,6 +53,12 @@ export class TemplateProcessor {
53
53
  if (templateType === CONSTANTS.TEMPLATE_TYPES.APP_TEMPLATE) {
54
54
  pathsToRemove.push(path.join(tmpdir, 'mini-apps-template'));
55
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
+ );
61
+ }
56
62
 
57
63
  pathsToRemove.forEach(pathToRemove => {
58
64
  try {