ylyx-cli 1.0.7 → 1.0.8

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 (2) hide show
  1. package/lib/deploy.js +16 -12
  2. package/package.json +1 -1
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.8",
4
4
  "description": "公司内部代码生成模板脚手架工具,支持快速生成项目初始结构和代码模板",
5
5
  "main": "lib/index.js",
6
6
  "bin": {