ylyx-cli 1.0.7 → 1.0.9

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/config.js CHANGED
@@ -86,11 +86,9 @@ function writeIfAllowed(filePath, content, force) {
86
86
 
87
87
  function deriveDefaultVariantContent(baseContent, mode) {
88
88
  const isDev = mode === 'dev';
89
- const isProd = mode === 'prod';
90
89
 
91
90
  let content = baseContent || '';
92
91
  const devRe = /let\s+isDev\s*=\s*[^;]*;/;
93
- const prodRe = /let\s+isProd\s*=\s*[^;]*;/;
94
92
 
95
93
  if (devRe.test(content)) {
96
94
  content = content.replace(devRe, `let isDev = ${isDev};`);
@@ -98,11 +96,12 @@ function deriveDefaultVariantContent(baseContent, mode) {
98
96
  content = `let isDev = ${isDev};\n` + content;
99
97
  }
100
98
 
101
- if (prodRe.test(content)) {
102
- content = content.replace(prodRe, `let isProd = ${isProd};`);
103
- } else {
104
- content = `let isProd = ${isProd};\n` + content;
105
- }
99
+ // isProd 已废弃:prod 使用 isDev=false 表示
100
+ // 删除历史遗留的 isProd 变量与输出字段(若存在)
101
+ content = content.replace(/let\s+isProd\s*=\s*[^;]*;\s*\r?\n?/g, '');
102
+ content = content.replace(/window\.config\.IS_PROD\s*=\s*[^;]*;\s*\r?\n?/g, '');
103
+ // 删除对象形式的 IS_PROD 字段(例如 IS_PROD: isProd,)
104
+ content = content.replace(/^\s*IS_PROD\s*:\s*[^,}]*,?\s*\r?\n?/gm, '');
106
105
 
107
106
  return content;
108
107
  }
package/lib/deploy.js CHANGED
@@ -63,6 +63,17 @@ function sanitizeBuildDirName(name) {
63
63
  .slice(0, 80);
64
64
  }
65
65
 
66
+ function getBuildDirBaseName({ buildDir, localDir }) {
67
+ // buildDir 可能是路径:只取最后一级目录名
68
+ if (buildDir != null && String(buildDir).trim()) {
69
+ const normalized = String(buildDir).trim().replace(/\\/g, '/').replace(/\/+$/, '');
70
+ const last = normalized.split('/').filter(Boolean).pop();
71
+ if (last) return sanitizeBuildDirName(last);
72
+ }
73
+ // 兜底:使用 localDir 的最后一段目录名
74
+ return sanitizeBuildDirName(path.basename(path.resolve(localDir || process.cwd())));
75
+ }
76
+
66
77
  async function zipDirAsTopFolder({ srcDir, zipPath, topFolderName }) {
67
78
  fs.ensureDirSync(path.dirname(zipPath));
68
79
  await new Promise((resolve, reject) => {
@@ -234,14 +245,11 @@ async function deploy(overrides = {}) {
234
245
 
235
246
  // 正式服:仅压缩
236
247
  if (env === 'prod') {
237
- const buildDirName = sanitizeBuildDirName(
238
- cfg.buildDir != null && cfg.buildDir !== ''
239
- ? String(cfg.buildDir).replace(/\//g, '').replace(/\\/g, '')
240
- : path.basename(path.resolve(localFolderPath)).replace(/[\\/]/g, '')
241
- );
248
+ const buildDirName = getBuildDirBaseName({ buildDir: cfg.buildDir, localDir: localFolderPath });
242
249
  const ts = formatTimestampCompact(new Date());
243
250
  const hashLetters = computeDirHashLetters(localFolderPath); // 纯字母
244
- const zipBaseName = `${buildDirName}${ts}${hashLetters}`;
251
+ // 优化命名:更可读、更易分割(buildDir-时间-哈希)
252
+ const zipBaseName = `${buildDirName}-${ts}-${hashLetters}`;
245
253
  fs.ensureDirSync(cfg.zipOutDir);
246
254
  const zipName = `${zipBaseName}.zip`;
247
255
  const zipPath = path.join(cfg.zipOutDir, zipName);
@@ -317,14 +325,10 @@ async function deploy(overrides = {}) {
317
325
 
318
326
  // 测试服可选:部署后压缩(延续之前的可选开关)
319
327
  if (cfg.zipAfter) {
320
- const buildDirName = sanitizeBuildDirName(
321
- cfg.buildDir != null && cfg.buildDir !== ''
322
- ? String(cfg.buildDir).replace(/\//g, '').replace(/\\/g, '')
323
- : path.basename(path.resolve(localFolderPath)).replace(/[\\/]/g, '')
324
- );
328
+ const buildDirName = getBuildDirBaseName({ buildDir: cfg.buildDir, localDir: localFolderPath });
325
329
  const ts = formatTimestampCompact(new Date());
326
330
  const hashLetters = computeDirHashLetters(localFolderPath); // 纯字母
327
- const zipBaseName = `${buildDirName}${ts}${hashLetters}`;
331
+ const zipBaseName = `${buildDirName}-${ts}-${hashLetters}`;
328
332
  fs.ensureDirSync(cfg.zipOutDir);
329
333
  const zipName = `${zipBaseName}.zip`;
330
334
  const zipPath = path.join(cfg.zipOutDir, zipName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ylyx-cli",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "公司内部代码生成模板脚手架工具,支持快速生成项目初始结构和代码模板",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
@@ -1,5 +1,4 @@
1
- let isDev = true; //研发 以上都为false 时 为测试环境
2
- let isProd = true; //线上为true.测试为false
1
+ let isDev = true; // dev=true 为研发环境;prod 环境用 isDev=false 表示
3
2
  let AUTO_ORIGIN = window.location.origin;
4
3
 
5
4
  // 研发环境