@julien-lin/universal-pwa-cli 1.2.0 → 1.2.2

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/dist/index.cjs CHANGED
@@ -137,7 +137,16 @@ async function initCommand(options = {}) {
137
137
  result.warnings.push(`Icon source not found: ${iconSourcePath}`);
138
138
  }
139
139
  }
140
- const finalShortName = appShortName && typeof appShortName === "string" && appShortName.trim().length > 0 ? appShortName.trim().substring(0, 12) : appName && appName.length > 0 ? appName.substring(0, 12) : "PWA";
140
+ let finalShortName = "PWA";
141
+ if (appShortName && typeof appShortName === "string" && appShortName.trim().length > 0) {
142
+ finalShortName = appShortName.trim().substring(0, 12);
143
+ } else if (appName && typeof appName === "string" && appName.length > 0) {
144
+ finalShortName = appName.substring(0, 12);
145
+ }
146
+ if (!finalShortName || finalShortName.trim().length === 0) {
147
+ finalShortName = "PWA";
148
+ }
149
+ finalShortName = String(finalShortName).trim().substring(0, 12) || "PWA";
141
150
  let manifestPath;
142
151
  if (iconPaths.length > 0) {
143
152
  const manifestWithIcons = (0, import_universal_pwa_core2.generateManifest)({
@@ -470,6 +479,12 @@ async function promptInitOptions(projectPath, framework) {
470
479
  }
471
480
  ]);
472
481
  answers.skipIcons = !answers.skipIcons;
482
+ if (!answers.name || answers.name.trim().length === 0) {
483
+ answers.name = defaultName;
484
+ }
485
+ if (!answers.shortName || answers.shortName.trim().length === 0) {
486
+ answers.shortName = defaultShortName;
487
+ }
473
488
  return answers;
474
489
  }
475
490
 
@@ -505,11 +520,11 @@ program.command("init").description("Initialize PWA in your project").option("-p
505
520
  const promptAnswers = await promptInitOptions(projectPath, scanResult.framework.framework);
506
521
  finalOptions = {
507
522
  ...options,
508
- name: promptAnswers.name,
509
- shortName: promptAnswers.shortName,
510
- iconSource: promptAnswers.iconSource || void 0,
511
- themeColor: promptAnswers.themeColor || void 0,
512
- backgroundColor: promptAnswers.backgroundColor || void 0,
523
+ name: promptAnswers.name?.trim() || "My PWA",
524
+ shortName: promptAnswers.shortName?.trim() || promptAnswers.name?.trim().substring(0, 12) || "PWA",
525
+ iconSource: promptAnswers.iconSource && promptAnswers.iconSource.trim().length > 0 ? promptAnswers.iconSource.trim() : void 0,
526
+ themeColor: promptAnswers.themeColor && promptAnswers.themeColor.trim().length > 0 ? promptAnswers.themeColor.trim() : void 0,
527
+ backgroundColor: promptAnswers.backgroundColor && promptAnswers.backgroundColor.trim().length > 0 ? promptAnswers.backgroundColor.trim() : void 0,
513
528
  skipIcons: promptAnswers.skipIcons
514
529
  };
515
530
  }
package/dist/index.js CHANGED
@@ -114,7 +114,16 @@ async function initCommand(options = {}) {
114
114
  result.warnings.push(`Icon source not found: ${iconSourcePath}`);
115
115
  }
116
116
  }
117
- const finalShortName = appShortName && typeof appShortName === "string" && appShortName.trim().length > 0 ? appShortName.trim().substring(0, 12) : appName && appName.length > 0 ? appName.substring(0, 12) : "PWA";
117
+ let finalShortName = "PWA";
118
+ if (appShortName && typeof appShortName === "string" && appShortName.trim().length > 0) {
119
+ finalShortName = appShortName.trim().substring(0, 12);
120
+ } else if (appName && typeof appName === "string" && appName.length > 0) {
121
+ finalShortName = appName.substring(0, 12);
122
+ }
123
+ if (!finalShortName || finalShortName.trim().length === 0) {
124
+ finalShortName = "PWA";
125
+ }
126
+ finalShortName = String(finalShortName).trim().substring(0, 12) || "PWA";
118
127
  let manifestPath;
119
128
  if (iconPaths.length > 0) {
120
129
  const manifestWithIcons = generateManifest({
@@ -447,6 +456,12 @@ async function promptInitOptions(projectPath, framework) {
447
456
  }
448
457
  ]);
449
458
  answers.skipIcons = !answers.skipIcons;
459
+ if (!answers.name || answers.name.trim().length === 0) {
460
+ answers.name = defaultName;
461
+ }
462
+ if (!answers.shortName || answers.shortName.trim().length === 0) {
463
+ answers.shortName = defaultShortName;
464
+ }
450
465
  return answers;
451
466
  }
452
467
 
@@ -481,11 +496,11 @@ program.command("init").description("Initialize PWA in your project").option("-p
481
496
  const promptAnswers = await promptInitOptions(projectPath, scanResult.framework.framework);
482
497
  finalOptions = {
483
498
  ...options,
484
- name: promptAnswers.name,
485
- shortName: promptAnswers.shortName,
486
- iconSource: promptAnswers.iconSource || void 0,
487
- themeColor: promptAnswers.themeColor || void 0,
488
- backgroundColor: promptAnswers.backgroundColor || void 0,
499
+ name: promptAnswers.name?.trim() || "My PWA",
500
+ shortName: promptAnswers.shortName?.trim() || promptAnswers.name?.trim().substring(0, 12) || "PWA",
501
+ iconSource: promptAnswers.iconSource && promptAnswers.iconSource.trim().length > 0 ? promptAnswers.iconSource.trim() : void 0,
502
+ themeColor: promptAnswers.themeColor && promptAnswers.themeColor.trim().length > 0 ? promptAnswers.themeColor.trim() : void 0,
503
+ backgroundColor: promptAnswers.backgroundColor && promptAnswers.backgroundColor.trim().length > 0 ? promptAnswers.backgroundColor.trim() : void 0,
489
504
  skipIcons: promptAnswers.skipIcons
490
505
  };
491
506
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@julien-lin/universal-pwa-cli",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "CLI pour transformer n'importe quel projet web en PWA",
5
5
  "keywords": [
6
6
  "pwa",
@@ -45,7 +45,7 @@
45
45
  "inquirer": "^12.0.0",
46
46
  "pino": "^9.14.0",
47
47
  "zod": "^4.2.1",
48
- "@julien-lin/universal-pwa-core": "^1.2.0"
48
+ "@julien-lin/universal-pwa-core": "^1.2.2"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@vitest/coverage-v8": "^2.1.4",