@julien-lin/universal-pwa-cli 1.3.8 → 1.3.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/dist/index.cjs +251 -218
- package/dist/index.js +251 -218
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -126,7 +126,7 @@ var init_environment_detector = __esm({
|
|
|
126
126
|
|
|
127
127
|
// src/index.ts
|
|
128
128
|
var import_commander = require("commander");
|
|
129
|
-
var
|
|
129
|
+
var import_chalk9 = __toESM(require("chalk"), 1);
|
|
130
130
|
|
|
131
131
|
// src/commands/init.ts
|
|
132
132
|
var import_universal_pwa_core2 = require("@julien-lin/universal-pwa-core");
|
|
@@ -136,7 +136,7 @@ var import_universal_pwa_core5 = require("@julien-lin/universal-pwa-core");
|
|
|
136
136
|
var import_universal_pwa_core6 = require("@julien-lin/universal-pwa-core");
|
|
137
137
|
var import_universal_pwa_core7 = require("@julien-lin/universal-pwa-core");
|
|
138
138
|
var import_universal_pwa_core8 = require("@julien-lin/universal-pwa-core");
|
|
139
|
-
var
|
|
139
|
+
var import_chalk3 = __toESM(require("chalk"), 1);
|
|
140
140
|
var import_fs2 = require("fs");
|
|
141
141
|
var import_glob = require("glob");
|
|
142
142
|
var import_path2 = require("path");
|
|
@@ -457,6 +457,24 @@ async function getEffectiveConfig(projectPath, cliOptions) {
|
|
|
457
457
|
};
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
+
// src/utils/ui-utils.ts
|
|
461
|
+
var import_chalk2 = __toESM(require("chalk"), 1);
|
|
462
|
+
function displayPWABanner() {
|
|
463
|
+
const banner = `
|
|
464
|
+
${import_chalk2.default.bold.cyan("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")}
|
|
465
|
+
${import_chalk2.default.bold.cyan("\u2551")} ${import_chalk2.default.bold.cyan("\u2551")}
|
|
466
|
+
${import_chalk2.default.bold.cyan("\u2551")} ${import_chalk2.default.bold.magenta("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2557 \u2566 \u2566 \u2554\u2550\u2557 \u2554\u2550\u2557")} ${import_chalk2.default.bold.cyan("\u2551")}
|
|
467
|
+
${import_chalk2.default.bold.cyan("\u2551")} ${import_chalk2.default.bold.magenta("\u2560\u2550\u2557 \u2554\u2550\u255D \u2551\u2551\u2551 \u2560\u2550\u2563 \u2551 \u2551")} ${import_chalk2.default.bold.cyan("\u2551")}
|
|
468
|
+
${import_chalk2.default.bold.cyan("\u2551")} ${import_chalk2.default.bold.magenta("\u2551 \u2551 \u255A\u2550\u2557 \u255A\u2569\u255D \u2551 \u2551 \u255A\u2550\u255D")} ${import_chalk2.default.bold.cyan("\u2551")}
|
|
469
|
+
${import_chalk2.default.bold.cyan("\u2551")} ${import_chalk2.default.bold.cyan("\u2551")}
|
|
470
|
+
${import_chalk2.default.bold.cyan("\u2551")} ${import_chalk2.default.bold.yellow("Progressive Web App Generator")} ${import_chalk2.default.bold.cyan("\u2551")}
|
|
471
|
+
${import_chalk2.default.bold.cyan("\u2551")} ${import_chalk2.default.dim("Transformez vos apps en PWA en quelques clics")} ${import_chalk2.default.bold.cyan("\u2551")}
|
|
472
|
+
${import_chalk2.default.bold.cyan("\u2551")} ${import_chalk2.default.bold.cyan("\u2551")}
|
|
473
|
+
${import_chalk2.default.bold.cyan("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")}
|
|
474
|
+
`;
|
|
475
|
+
console.log(banner);
|
|
476
|
+
}
|
|
477
|
+
|
|
460
478
|
// src/utils/error-codes.ts
|
|
461
479
|
var ERROR_MESSAGES = {
|
|
462
480
|
["E1001" /* PROJECT_PATH_NOT_FOUND */]: {
|
|
@@ -690,9 +708,10 @@ async function initCommand(options = {}) {
|
|
|
690
708
|
);
|
|
691
709
|
if (configFile.config && configFile.filePath) {
|
|
692
710
|
console.log(
|
|
693
|
-
|
|
711
|
+
import_chalk3.default.gray(`\u{1F4C4} Using configuration from ${configFile.filePath}`)
|
|
694
712
|
);
|
|
695
713
|
}
|
|
714
|
+
displayPWABanner();
|
|
696
715
|
const {
|
|
697
716
|
projectPath = process.cwd(),
|
|
698
717
|
name,
|
|
@@ -722,10 +741,10 @@ async function initCommand(options = {}) {
|
|
|
722
741
|
const errorCode = "E1001" /* PROJECT_PATH_NOT_FOUND */;
|
|
723
742
|
const errorMessage = formatError(errorCode, result.projectPath);
|
|
724
743
|
result.errors.push(errorMessage);
|
|
725
|
-
console.log(
|
|
744
|
+
console.log(import_chalk3.default.red(`\u2717 ${errorMessage}`));
|
|
726
745
|
return result;
|
|
727
746
|
}
|
|
728
|
-
console.log(
|
|
747
|
+
console.log(import_chalk3.default.blue("\u{1F50D} Scanning project..."));
|
|
729
748
|
const scanResult = await (0, import_universal_pwa_core2.scanProject)({
|
|
730
749
|
projectPath: result.projectPath,
|
|
731
750
|
includeAssets: true,
|
|
@@ -738,28 +757,28 @@ async function initCommand(options = {}) {
|
|
|
738
757
|
result.architecture = scanResult.architecture?.architecture ?? "static";
|
|
739
758
|
}
|
|
740
759
|
console.log(
|
|
741
|
-
|
|
760
|
+
import_chalk3.default.green(`\u2713 Framework detected: ${result.framework ?? "Unknown"}`)
|
|
742
761
|
);
|
|
743
|
-
console.log(
|
|
762
|
+
console.log(import_chalk3.default.green(`\u2713 Architecture: ${result.architecture}`));
|
|
744
763
|
const httpsCheck = (0, import_universal_pwa_core7.checkProjectHttps)({ projectPath: result.projectPath });
|
|
745
764
|
if (httpsCheck && typeof httpsCheck === "object" && "isSecure" in httpsCheck && "isLocalhost" in httpsCheck) {
|
|
746
765
|
if (!httpsCheck.isSecure && !httpsCheck.isLocalhost) {
|
|
747
766
|
const warning = httpsCheck.warning ?? "HTTPS required for production PWA";
|
|
748
767
|
result.warnings.push(warning);
|
|
749
|
-
console.log(
|
|
768
|
+
console.log(import_chalk3.default.yellow(`\u26A0 ${warning}`));
|
|
750
769
|
}
|
|
751
770
|
}
|
|
752
771
|
let finalOutputDir;
|
|
753
772
|
if (outputDir) {
|
|
754
773
|
finalOutputDir = outputDir.startsWith("/") || process.platform === "win32" && /^[A-Z]:/.test(outputDir) ? (0, import_path2.resolve)(outputDir) : (0, import_path2.join)(result.projectPath, outputDir);
|
|
755
|
-
console.log(
|
|
774
|
+
console.log(import_chalk3.default.gray(` Using output directory: ${finalOutputDir}`));
|
|
756
775
|
} else {
|
|
757
776
|
const distDir = (0, import_path2.join)(result.projectPath, "dist");
|
|
758
777
|
const publicDir = (0, import_path2.join)(result.projectPath, "public");
|
|
759
778
|
if ((result.framework === "react" || result.framework === "nextjs") && (0, import_fs2.existsSync)(distDir)) {
|
|
760
779
|
finalOutputDir = distDir;
|
|
761
780
|
console.log(
|
|
762
|
-
|
|
781
|
+
import_chalk3.default.gray(` Using dist/ directory (production build detected)`)
|
|
763
782
|
);
|
|
764
783
|
} else if (result.framework === "wordpress") {
|
|
765
784
|
finalOutputDir = publicDir;
|
|
@@ -794,7 +813,7 @@ async function initCommand(options = {}) {
|
|
|
794
813
|
transaction.backupFile(swRelative);
|
|
795
814
|
}
|
|
796
815
|
}
|
|
797
|
-
console.log(
|
|
816
|
+
console.log(import_chalk3.default.blue("\u{1F4DD} Generating manifest.json..."));
|
|
798
817
|
const appName = name ?? (result.framework ? `${result.framework} App` : "My PWA");
|
|
799
818
|
const normalizedShortName = shortName && typeof shortName === "string" && shortName.trim().length > 0 ? shortName.trim() : void 0;
|
|
800
819
|
let appShortName;
|
|
@@ -812,7 +831,7 @@ async function initCommand(options = {}) {
|
|
|
812
831
|
if (!skipIcons && iconSource) {
|
|
813
832
|
const iconSourcePath = (0, import_fs2.existsSync)(iconSource) ? iconSource : (0, import_path2.join)(result.projectPath, iconSource);
|
|
814
833
|
if ((0, import_fs2.existsSync)(iconSourcePath)) {
|
|
815
|
-
console.log(
|
|
834
|
+
console.log(import_chalk3.default.blue("\u{1F3A8} Generating icons..."));
|
|
816
835
|
try {
|
|
817
836
|
const iconResult = await (0, import_universal_pwa_core4.generateIcons)({
|
|
818
837
|
sourceImage: iconSourcePath,
|
|
@@ -827,18 +846,18 @@ async function initCommand(options = {}) {
|
|
|
827
846
|
if (validation.errors.length > 0) {
|
|
828
847
|
validation.errors.forEach((error) => {
|
|
829
848
|
result.errors.push(`Icon validation: ${error}`);
|
|
830
|
-
console.log(
|
|
849
|
+
console.log(import_chalk3.default.red(`\u2717 ${error}`));
|
|
831
850
|
});
|
|
832
851
|
}
|
|
833
852
|
if (validation.warnings.length > 0) {
|
|
834
853
|
validation.warnings.forEach((warning) => {
|
|
835
854
|
result.warnings.push(`Icon validation: ${warning}`);
|
|
836
|
-
console.log(
|
|
855
|
+
console.log(import_chalk3.default.yellow(`\u26A0 ${warning}`));
|
|
837
856
|
});
|
|
838
857
|
}
|
|
839
858
|
if (validation.suggestions.length > 0) {
|
|
840
859
|
validation.suggestions.forEach((suggestion) => {
|
|
841
|
-
console.log(
|
|
860
|
+
console.log(import_chalk3.default.blue(`\u{1F4A1} ${suggestion}`));
|
|
842
861
|
});
|
|
843
862
|
}
|
|
844
863
|
}
|
|
@@ -852,21 +871,21 @@ async function initCommand(options = {}) {
|
|
|
852
871
|
iconPaths.push("/apple-touch-icon.png");
|
|
853
872
|
}
|
|
854
873
|
console.log(
|
|
855
|
-
|
|
874
|
+
import_chalk3.default.green(`\u2713 Generated ${result.iconsGenerated} icons`)
|
|
856
875
|
);
|
|
857
876
|
if ((0, import_fs2.existsSync)(appleTouchIconPath)) {
|
|
858
|
-
console.log(
|
|
877
|
+
console.log(import_chalk3.default.green(`\u2713 Generated apple-touch-icon.png`));
|
|
859
878
|
}
|
|
860
879
|
} catch (error) {
|
|
861
880
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
862
881
|
result.errors.push(`Failed to generate icons: ${errorMessage}`);
|
|
863
|
-
console.log(
|
|
882
|
+
console.log(import_chalk3.default.red(`\u2717 Failed to generate icons: ${errorMessage}`));
|
|
864
883
|
}
|
|
865
884
|
} else {
|
|
866
885
|
const errorCode = "E3001" /* ICON_SOURCE_NOT_FOUND */;
|
|
867
886
|
const warningMessage = formatError(errorCode, iconSourcePath);
|
|
868
887
|
result.warnings.push(warningMessage);
|
|
869
|
-
console.log(
|
|
888
|
+
console.log(import_chalk3.default.yellow(`\u26A0 ${warningMessage}`));
|
|
870
889
|
}
|
|
871
890
|
}
|
|
872
891
|
let finalShortName = "PWA";
|
|
@@ -911,13 +930,13 @@ async function initCommand(options = {}) {
|
|
|
911
930
|
transaction.trackCreatedFile(manifestRelative);
|
|
912
931
|
}
|
|
913
932
|
}
|
|
914
|
-
console.log(
|
|
933
|
+
console.log(import_chalk3.default.green(`\u2713 Manifest generated: ${manifestPath}`));
|
|
915
934
|
} else {
|
|
916
935
|
result.warnings.push(
|
|
917
936
|
"No icons provided. Manifest generated with placeholder icon. Please provide an icon source with --icon-source for production."
|
|
918
937
|
);
|
|
919
938
|
console.log(
|
|
920
|
-
|
|
939
|
+
import_chalk3.default.yellow("\u26A0 Generating manifest with placeholder icon")
|
|
921
940
|
);
|
|
922
941
|
const manifestMinimalOptions = {
|
|
923
942
|
name: appName,
|
|
@@ -951,21 +970,21 @@ async function initCommand(options = {}) {
|
|
|
951
970
|
transaction.trackCreatedFile(manifestRelative);
|
|
952
971
|
}
|
|
953
972
|
}
|
|
954
|
-
console.log(
|
|
973
|
+
console.log(import_chalk3.default.green(`\u2713 Manifest generated: ${manifestPath}`));
|
|
955
974
|
}
|
|
956
975
|
} catch (error) {
|
|
957
976
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
958
977
|
const errorCode = detectErrorCode(errorMessage);
|
|
959
978
|
const formattedError = formatError(errorCode, errorMessage);
|
|
960
979
|
result.errors.push(formattedError);
|
|
961
|
-
console.log(
|
|
980
|
+
console.log(import_chalk3.default.red(`\u2717 ${formattedError}`));
|
|
962
981
|
if (transaction) {
|
|
963
982
|
transaction.rollback();
|
|
964
983
|
}
|
|
965
984
|
return result;
|
|
966
985
|
}
|
|
967
986
|
if (!skipServiceWorker) {
|
|
968
|
-
console.log(
|
|
987
|
+
console.log(import_chalk3.default.blue("\u2699\uFE0F Generating service worker..."));
|
|
969
988
|
try {
|
|
970
989
|
const factory = (0, import_universal_pwa_core8.getBackendFactory)();
|
|
971
990
|
let backendIntegration = null;
|
|
@@ -973,10 +992,7 @@ async function initCommand(options = {}) {
|
|
|
973
992
|
backendIntegration = factory.detectBackend(result.projectPath);
|
|
974
993
|
}
|
|
975
994
|
if (!backendIntegration && result.framework && factory && typeof factory === "object" && "getIntegration" in factory) {
|
|
976
|
-
backendIntegration = factory.getIntegration(
|
|
977
|
-
result.framework,
|
|
978
|
-
result.projectPath
|
|
979
|
-
);
|
|
995
|
+
backendIntegration = factory.getIntegration(result.framework, result.projectPath);
|
|
980
996
|
if (backendIntegration && typeof backendIntegration === "object" && "detect" in backendIntegration) {
|
|
981
997
|
const detect = backendIntegration.detect;
|
|
982
998
|
const detectionResult = detect();
|
|
@@ -996,7 +1012,7 @@ async function initCommand(options = {}) {
|
|
|
996
1012
|
const name2 = backendIntegration.name ?? "Backend";
|
|
997
1013
|
const confidence = detectionResult?.confidence ?? "unknown";
|
|
998
1014
|
console.log(
|
|
999
|
-
|
|
1015
|
+
import_chalk3.default.blue(
|
|
1000
1016
|
` Using ${name2} optimized config (confidence: ${confidence})`
|
|
1001
1017
|
)
|
|
1002
1018
|
);
|
|
@@ -1018,21 +1034,19 @@ async function initCommand(options = {}) {
|
|
|
1018
1034
|
iconSource
|
|
1019
1035
|
);
|
|
1020
1036
|
const cacheStrategies = optimizationResult && typeof optimizationResult === "object" && "cacheStrategies" in optimizationResult ? optimizationResult.cacheStrategies ?? [] : [];
|
|
1021
|
-
const runtimeCaching = cacheStrategies.map(
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
}
|
|
1030
|
-
);
|
|
1037
|
+
const runtimeCaching = cacheStrategies.map((strategy) => {
|
|
1038
|
+
const strategyObj = strategy;
|
|
1039
|
+
return {
|
|
1040
|
+
urlPattern: strategyObj.urlPattern,
|
|
1041
|
+
handler: strategyObj.handler,
|
|
1042
|
+
options: strategyObj.options
|
|
1043
|
+
};
|
|
1044
|
+
});
|
|
1031
1045
|
if (runtimeCaching.length > 0) {
|
|
1032
1046
|
const apiType = optimizationResult.apiType ?? "unknown";
|
|
1033
1047
|
const strategiesCount = cacheStrategies?.length ?? 0;
|
|
1034
1048
|
console.log(
|
|
1035
|
-
|
|
1049
|
+
import_chalk3.default.gray(
|
|
1036
1050
|
` Detected ${apiType} API, applying ${strategiesCount} adaptive cache strategy(ies)`
|
|
1037
1051
|
)
|
|
1038
1052
|
);
|
|
@@ -1064,23 +1078,23 @@ async function initCommand(options = {}) {
|
|
|
1064
1078
|
);
|
|
1065
1079
|
if (highPrioritySuggestions.length > 0) {
|
|
1066
1080
|
console.log(
|
|
1067
|
-
|
|
1081
|
+
import_chalk3.default.yellow(
|
|
1068
1082
|
`\u26A0 ${highPrioritySuggestions.length} high-priority asset optimization suggestion(s) found`
|
|
1069
1083
|
)
|
|
1070
1084
|
);
|
|
1071
1085
|
highPrioritySuggestions.slice(0, 3).forEach((suggestion) => {
|
|
1072
|
-
console.log(
|
|
1086
|
+
console.log(import_chalk3.default.gray(` - ${suggestion.suggestion}`));
|
|
1073
1087
|
});
|
|
1074
1088
|
}
|
|
1075
1089
|
}
|
|
1076
1090
|
}
|
|
1077
1091
|
result.serviceWorkerPath = swResult.swPath;
|
|
1078
1092
|
console.log(
|
|
1079
|
-
|
|
1093
|
+
import_chalk3.default.green(
|
|
1080
1094
|
`\u2713 Service worker generated: ${result.serviceWorkerPath}`
|
|
1081
1095
|
)
|
|
1082
1096
|
);
|
|
1083
|
-
console.log(
|
|
1097
|
+
console.log(import_chalk3.default.gray(` Pre-cached ${swResult.count} files`));
|
|
1084
1098
|
const swRelative = (0, import_path2.relative)(result.projectPath, swResult.swPath);
|
|
1085
1099
|
if (swRelative && !swRelative.startsWith("..")) {
|
|
1086
1100
|
const wasBackedUp = transaction.getState().backups.some((b) => {
|
|
@@ -1096,7 +1110,7 @@ async function initCommand(options = {}) {
|
|
|
1096
1110
|
const errorCode = detectErrorCode(errorMessage);
|
|
1097
1111
|
const formattedError = formatError(errorCode, errorMessage);
|
|
1098
1112
|
result.errors.push(formattedError);
|
|
1099
|
-
console.log(
|
|
1113
|
+
console.log(import_chalk3.default.red(`\u2717 ${formattedError}`));
|
|
1100
1114
|
if (transaction) {
|
|
1101
1115
|
transaction.rollback();
|
|
1102
1116
|
}
|
|
@@ -1104,7 +1118,7 @@ async function initCommand(options = {}) {
|
|
|
1104
1118
|
}
|
|
1105
1119
|
}
|
|
1106
1120
|
if (!skipInjection) {
|
|
1107
|
-
console.log(
|
|
1121
|
+
console.log(import_chalk3.default.blue("\u{1F489} Injecting meta-tags..."));
|
|
1108
1122
|
try {
|
|
1109
1123
|
const htmlFiles = await (0, import_glob.glob)("**/*.{html,twig,html.twig,blade.php}", {
|
|
1110
1124
|
cwd: result.projectPath,
|
|
@@ -1144,7 +1158,7 @@ async function initCommand(options = {}) {
|
|
|
1144
1158
|
if (bladeCount > 0) fileTypes.push(`${bladeCount} Blade`);
|
|
1145
1159
|
const typeSummary = fileTypes.length > 0 ? ` (${fileTypes.join(", ")})` : "";
|
|
1146
1160
|
console.log(
|
|
1147
|
-
|
|
1161
|
+
import_chalk3.default.gray(
|
|
1148
1162
|
` Found ${htmlFiles.length} template file(s)${typeSummary}${maxHtmlFiles && maxHtmlFiles > 0 ? ` (processing ${htmlFilesToProcess.length})` : ""}`
|
|
1149
1163
|
)
|
|
1150
1164
|
);
|
|
@@ -1192,7 +1206,7 @@ async function initCommand(options = {}) {
|
|
|
1192
1206
|
let progressBar = null;
|
|
1193
1207
|
if (totalFiles > 10) {
|
|
1194
1208
|
progressBar = new import_cli_progress.default.SingleBar({
|
|
1195
|
-
format:
|
|
1209
|
+
format: import_chalk3.default.blue("\u{1F489} Injecting meta-tags") + " |{bar}| {percentage}% | {value}/{total} files | ETA: {eta}s",
|
|
1196
1210
|
barCompleteChar: "\u2588",
|
|
1197
1211
|
barIncompleteChar: "\u2591",
|
|
1198
1212
|
hideCursor: true
|
|
@@ -1259,7 +1273,7 @@ async function initCommand(options = {}) {
|
|
|
1259
1273
|
if (totalFiles <= 10 && item) {
|
|
1260
1274
|
const relativePath2 = (0, import_path2.relative)(result.projectPath, item);
|
|
1261
1275
|
console.log(
|
|
1262
|
-
|
|
1276
|
+
import_chalk3.default.gray(
|
|
1263
1277
|
` \u2713 ${relativePath2}: ${injectionResult?.injected?.length ?? 0} tag(s) injected`
|
|
1264
1278
|
)
|
|
1265
1279
|
);
|
|
@@ -1269,14 +1283,14 @@ async function initCommand(options = {}) {
|
|
|
1269
1283
|
if (totalFiles <= 10 && item) {
|
|
1270
1284
|
const relativePath2 = (0, import_path2.relative)(result.projectPath, item);
|
|
1271
1285
|
console.log(
|
|
1272
|
-
|
|
1286
|
+
import_chalk3.default.gray(` \u2298 ${relativePath2}: already has PWA tags`)
|
|
1273
1287
|
);
|
|
1274
1288
|
}
|
|
1275
1289
|
} else {
|
|
1276
1290
|
if (totalFiles <= 10 && item) {
|
|
1277
1291
|
const relativePath2 = (0, import_path2.relative)(result.projectPath, item);
|
|
1278
1292
|
console.log(
|
|
1279
|
-
|
|
1293
|
+
import_chalk3.default.yellow(
|
|
1280
1294
|
` \u26A0 ${relativePath2}: no tags injected (check warnings)`
|
|
1281
1295
|
)
|
|
1282
1296
|
);
|
|
@@ -1300,13 +1314,10 @@ async function initCommand(options = {}) {
|
|
|
1300
1314
|
const item = failedObj.item ?? "unknown file";
|
|
1301
1315
|
const error = failedObj.error ?? "Unknown error";
|
|
1302
1316
|
const errorCode = detectErrorCode(new Error(error));
|
|
1303
|
-
const warningMessage = formatError(
|
|
1304
|
-
errorCode,
|
|
1305
|
-
`${item}: ${error}`
|
|
1306
|
-
);
|
|
1317
|
+
const warningMessage = formatError(errorCode, `${item}: ${error}`);
|
|
1307
1318
|
result.warnings.push(warningMessage);
|
|
1308
1319
|
if (totalFiles <= 10) {
|
|
1309
|
-
console.log(
|
|
1320
|
+
console.log(import_chalk3.default.yellow(`\u26A0 ${warningMessage}`));
|
|
1310
1321
|
}
|
|
1311
1322
|
}
|
|
1312
1323
|
result.htmlFilesInjected = injectedCount;
|
|
@@ -1316,28 +1327,28 @@ async function initCommand(options = {}) {
|
|
|
1316
1327
|
) ? "template file(s)" : "HTML file(s)";
|
|
1317
1328
|
if (injectedCount > 0) {
|
|
1318
1329
|
console.log(
|
|
1319
|
-
|
|
1330
|
+
import_chalk3.default.green(
|
|
1320
1331
|
`\u2713 Injected meta-tags in ${injectedCount} ${fileTypeLabel}`
|
|
1321
1332
|
)
|
|
1322
1333
|
);
|
|
1323
1334
|
}
|
|
1324
1335
|
if (skippedCount > 0) {
|
|
1325
1336
|
console.log(
|
|
1326
|
-
|
|
1337
|
+
import_chalk3.default.gray(
|
|
1327
1338
|
` ${skippedCount} ${fileTypeLabel} already had PWA tags`
|
|
1328
1339
|
)
|
|
1329
1340
|
);
|
|
1330
1341
|
}
|
|
1331
1342
|
if (errorCount > 0) {
|
|
1332
1343
|
console.log(
|
|
1333
|
-
|
|
1344
|
+
import_chalk3.default.yellow(
|
|
1334
1345
|
` ${errorCount} ${fileTypeLabel} had errors (see warnings above)`
|
|
1335
1346
|
)
|
|
1336
1347
|
);
|
|
1337
1348
|
}
|
|
1338
1349
|
if (injectedCount === 0 && skippedCount === 0 && errorCount === 0 && totalFiles > 0) {
|
|
1339
1350
|
console.log(
|
|
1340
|
-
|
|
1351
|
+
import_chalk3.default.yellow(
|
|
1341
1352
|
`\u26A0 No tags were injected in ${totalFiles} ${fileTypeLabel}. Check if files contain valid HTML structure.`
|
|
1342
1353
|
)
|
|
1343
1354
|
);
|
|
@@ -1347,7 +1358,7 @@ async function initCommand(options = {}) {
|
|
|
1347
1358
|
const errorCode = detectErrorCode(errorMessage);
|
|
1348
1359
|
const formattedError = formatError(errorCode, errorMessage);
|
|
1349
1360
|
result.errors.push(formattedError);
|
|
1350
|
-
console.log(
|
|
1361
|
+
console.log(import_chalk3.default.red(`\u2717 ${formattedError}`));
|
|
1351
1362
|
if (transaction) {
|
|
1352
1363
|
transaction.rollback();
|
|
1353
1364
|
}
|
|
@@ -1359,14 +1370,14 @@ async function initCommand(options = {}) {
|
|
|
1359
1370
|
if (transaction) {
|
|
1360
1371
|
transaction.commit();
|
|
1361
1372
|
}
|
|
1362
|
-
console.log(
|
|
1373
|
+
console.log(import_chalk3.default.green("\n\u2705 PWA setup completed successfully!"));
|
|
1363
1374
|
} else {
|
|
1364
1375
|
if (transaction) {
|
|
1365
|
-
console.log(
|
|
1376
|
+
console.log(import_chalk3.default.yellow("\n\u{1F504} Rolling back changes due to errors..."));
|
|
1366
1377
|
transaction.rollback();
|
|
1367
1378
|
}
|
|
1368
1379
|
console.log(
|
|
1369
|
-
|
|
1380
|
+
import_chalk3.default.red(
|
|
1370
1381
|
`
|
|
1371
1382
|
\u274C PWA setup completed with ${result.errors.length} error(s)`
|
|
1372
1383
|
)
|
|
@@ -1378,10 +1389,10 @@ async function initCommand(options = {}) {
|
|
|
1378
1389
|
const errorCode = detectErrorCode(errorMessage);
|
|
1379
1390
|
const formattedError = formatError(errorCode, errorMessage);
|
|
1380
1391
|
result.errors.push(formattedError);
|
|
1381
|
-
console.log(
|
|
1392
|
+
console.log(import_chalk3.default.red(`\u2717 ${formattedError}`));
|
|
1382
1393
|
if (transaction) {
|
|
1383
1394
|
console.log(
|
|
1384
|
-
|
|
1395
|
+
import_chalk3.default.yellow("\n\u{1F504} Rolling back changes due to unexpected error...")
|
|
1385
1396
|
);
|
|
1386
1397
|
transaction.rollback();
|
|
1387
1398
|
}
|
|
@@ -1390,7 +1401,7 @@ async function initCommand(options = {}) {
|
|
|
1390
1401
|
}
|
|
1391
1402
|
|
|
1392
1403
|
// src/commands/preview.ts
|
|
1393
|
-
var
|
|
1404
|
+
var import_chalk4 = __toESM(require("chalk"), 1);
|
|
1394
1405
|
var import_fs3 = require("fs");
|
|
1395
1406
|
var import_path3 = require("path");
|
|
1396
1407
|
var import_universal_pwa_core9 = require("@julien-lin/universal-pwa-core");
|
|
@@ -1414,48 +1425,48 @@ async function previewCommand(options = {}) {
|
|
|
1414
1425
|
result.errors.push(`Project path does not exist: ${resolvedPath}`);
|
|
1415
1426
|
return result;
|
|
1416
1427
|
}
|
|
1417
|
-
console.log(
|
|
1428
|
+
console.log(import_chalk4.default.blue("\u{1F50D} Checking PWA setup..."));
|
|
1418
1429
|
const manifestPath = (0, import_path3.join)(resolvedPath, "public", "manifest.json");
|
|
1419
1430
|
const manifestPathAlt = (0, import_path3.join)(resolvedPath, "manifest.json");
|
|
1420
1431
|
if ((0, import_fs3.existsSync)(manifestPath) || (0, import_fs3.existsSync)(manifestPathAlt)) {
|
|
1421
1432
|
result.manifestExists = true;
|
|
1422
|
-
console.log(
|
|
1433
|
+
console.log(import_chalk4.default.green("\u2713 manifest.json found"));
|
|
1423
1434
|
} else {
|
|
1424
1435
|
result.warnings.push("manifest.json not found");
|
|
1425
|
-
console.log(
|
|
1436
|
+
console.log(import_chalk4.default.yellow("\u26A0 manifest.json not found"));
|
|
1426
1437
|
}
|
|
1427
1438
|
const swPath = (0, import_path3.join)(resolvedPath, "public", "sw.js");
|
|
1428
1439
|
const swPathAlt = (0, import_path3.join)(resolvedPath, "sw.js");
|
|
1429
1440
|
if ((0, import_fs3.existsSync)(swPath) || (0, import_fs3.existsSync)(swPathAlt)) {
|
|
1430
1441
|
result.serviceWorkerExists = true;
|
|
1431
|
-
console.log(
|
|
1442
|
+
console.log(import_chalk4.default.green("\u2713 Service worker found"));
|
|
1432
1443
|
} else {
|
|
1433
1444
|
result.warnings.push("Service worker (sw.js) not found");
|
|
1434
|
-
console.log(
|
|
1445
|
+
console.log(import_chalk4.default.yellow("\u26A0 Service worker (sw.js) not found"));
|
|
1435
1446
|
}
|
|
1436
1447
|
try {
|
|
1437
1448
|
const httpsCheck = (0, import_universal_pwa_core9.checkProjectHttps)({ projectPath: resolvedPath });
|
|
1438
1449
|
if (!httpsCheck.isSecure && !httpsCheck.isLocalhost && httpsCheck.warning) {
|
|
1439
1450
|
result.warnings.push(httpsCheck.warning);
|
|
1440
|
-
console.log(
|
|
1451
|
+
console.log(import_chalk4.default.yellow(`\u26A0 ${httpsCheck.warning}`));
|
|
1441
1452
|
}
|
|
1442
1453
|
} catch {
|
|
1443
1454
|
}
|
|
1444
|
-
console.log(
|
|
1455
|
+
console.log(import_chalk4.default.blue(`
|
|
1445
1456
|
\u{1F4E6} PWA Preview would be available at: ${result.url}`));
|
|
1446
|
-
console.log(
|
|
1457
|
+
console.log(import_chalk4.default.gray(" (Server not started in preview mode - use a static server like `serve` or `http-server`)"));
|
|
1447
1458
|
result.success = result.errors.length === 0;
|
|
1448
1459
|
if (result.success) {
|
|
1449
|
-
console.log(
|
|
1460
|
+
console.log(import_chalk4.default.green("\n\u2705 PWA preview check completed"));
|
|
1450
1461
|
} else {
|
|
1451
|
-
console.log(
|
|
1462
|
+
console.log(import_chalk4.default.red(`
|
|
1452
1463
|
\u274C PWA preview check failed with ${result.errors.length} error(s)`));
|
|
1453
1464
|
}
|
|
1454
1465
|
return result;
|
|
1455
1466
|
} catch (error) {
|
|
1456
1467
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1457
1468
|
result.errors.push(`Unexpected error: ${errorMessage}`);
|
|
1458
|
-
console.log(
|
|
1469
|
+
console.log(import_chalk4.default.red(`\u2717 Unexpected error: ${errorMessage}`));
|
|
1459
1470
|
return result;
|
|
1460
1471
|
}
|
|
1461
1472
|
}
|
|
@@ -1464,7 +1475,7 @@ async function previewCommand(options = {}) {
|
|
|
1464
1475
|
var import_fs4 = require("fs");
|
|
1465
1476
|
var import_path4 = require("path");
|
|
1466
1477
|
var import_glob2 = require("glob");
|
|
1467
|
-
var
|
|
1478
|
+
var import_chalk5 = __toESM(require("chalk"), 1);
|
|
1468
1479
|
var import_universal_pwa_core10 = require("@julien-lin/universal-pwa-core");
|
|
1469
1480
|
async function verifyCommand(options = {}) {
|
|
1470
1481
|
const {
|
|
@@ -1489,7 +1500,7 @@ async function verifyCommand(options = {}) {
|
|
|
1489
1500
|
result.errors.push(`Project path does not exist: ${result.projectPath}`);
|
|
1490
1501
|
return result;
|
|
1491
1502
|
}
|
|
1492
|
-
console.log(
|
|
1503
|
+
console.log(import_chalk5.default.blue("\u{1F50D} Verifying PWA setup..."));
|
|
1493
1504
|
const finalOutputDir = outputDir ? outputDir.startsWith("/") ? outputDir : (0, import_path4.join)(result.projectPath, outputDir) : (0, import_path4.join)(result.projectPath, "public");
|
|
1494
1505
|
result.outputDir = finalOutputDir;
|
|
1495
1506
|
const htmlFiles = await (0, import_glob2.glob)("**/*.html", {
|
|
@@ -1497,7 +1508,7 @@ async function verifyCommand(options = {}) {
|
|
|
1497
1508
|
ignore: ["**/node_modules/**", "**/.next/**", "**/.nuxt/**", "**/dist/**"],
|
|
1498
1509
|
absolute: true
|
|
1499
1510
|
});
|
|
1500
|
-
console.log(
|
|
1511
|
+
console.log(import_chalk5.default.blue("\u{1F50D} Running comprehensive PWA validation..."));
|
|
1501
1512
|
const validationResult = await (0, import_universal_pwa_core10.validatePWA)({
|
|
1502
1513
|
projectPath: result.projectPath,
|
|
1503
1514
|
outputDir: finalOutputDir,
|
|
@@ -1505,38 +1516,38 @@ async function verifyCommand(options = {}) {
|
|
|
1505
1516
|
strict: false
|
|
1506
1517
|
});
|
|
1507
1518
|
result.validationResult = validationResult;
|
|
1508
|
-
console.log(
|
|
1509
|
-
console.log(
|
|
1510
|
-
console.log(
|
|
1511
|
-
console.log(
|
|
1519
|
+
console.log(import_chalk5.default.blue("\n\u{1F4CA} PWA Validation Results:"));
|
|
1520
|
+
console.log(import_chalk5.default.gray(` Score: ${validationResult.score}/100`));
|
|
1521
|
+
console.log(import_chalk5.default.gray(` Errors: ${validationResult.errors.length}`));
|
|
1522
|
+
console.log(import_chalk5.default.gray(` Warnings: ${validationResult.warnings.length}`));
|
|
1512
1523
|
if (validationResult.errors.length > 0) {
|
|
1513
|
-
console.log(
|
|
1524
|
+
console.log(import_chalk5.default.red("\n\u274C Errors:"));
|
|
1514
1525
|
validationResult.errors.forEach((error) => {
|
|
1515
|
-
console.log(
|
|
1526
|
+
console.log(import_chalk5.default.red(` \u2717 [${error.code}] ${error.message}`));
|
|
1516
1527
|
if (error.file) {
|
|
1517
|
-
console.log(
|
|
1528
|
+
console.log(import_chalk5.default.gray(` File: ${error.file}`));
|
|
1518
1529
|
}
|
|
1519
1530
|
if (error.suggestion) {
|
|
1520
|
-
console.log(
|
|
1531
|
+
console.log(import_chalk5.default.yellow(` \u{1F4A1} ${error.suggestion}`));
|
|
1521
1532
|
}
|
|
1522
1533
|
});
|
|
1523
1534
|
}
|
|
1524
1535
|
if (validationResult.warnings.length > 0) {
|
|
1525
|
-
console.log(
|
|
1536
|
+
console.log(import_chalk5.default.yellow("\n\u26A0\uFE0F Warnings:"));
|
|
1526
1537
|
validationResult.warnings.forEach((warning) => {
|
|
1527
|
-
console.log(
|
|
1538
|
+
console.log(import_chalk5.default.yellow(` \u26A0 [${warning.code}] ${warning.message}`));
|
|
1528
1539
|
if (warning.file) {
|
|
1529
|
-
console.log(
|
|
1540
|
+
console.log(import_chalk5.default.gray(` File: ${warning.file}`));
|
|
1530
1541
|
}
|
|
1531
1542
|
if (warning.suggestion) {
|
|
1532
|
-
console.log(
|
|
1543
|
+
console.log(import_chalk5.default.gray(` \u{1F4A1} ${warning.suggestion}`));
|
|
1533
1544
|
}
|
|
1534
1545
|
});
|
|
1535
1546
|
}
|
|
1536
1547
|
if (validationResult.suggestions.length > 0) {
|
|
1537
|
-
console.log(
|
|
1548
|
+
console.log(import_chalk5.default.blue("\n\u{1F4A1} Suggestions:"));
|
|
1538
1549
|
validationResult.suggestions.forEach((suggestion) => {
|
|
1539
|
-
console.log(
|
|
1550
|
+
console.log(import_chalk5.default.gray(` \u2022 ${suggestion}`));
|
|
1540
1551
|
});
|
|
1541
1552
|
}
|
|
1542
1553
|
result.errors.push(...validationResult.errors.map((e) => e.message));
|
|
@@ -1556,28 +1567,28 @@ async function verifyCommand(options = {}) {
|
|
|
1556
1567
|
"icon-152x152.png",
|
|
1557
1568
|
"icon-384x384.png"
|
|
1558
1569
|
];
|
|
1559
|
-
console.log(
|
|
1570
|
+
console.log(import_chalk5.default.blue("\u{1F4CB} Checking required PWA files..."));
|
|
1560
1571
|
for (const file of requiredFiles) {
|
|
1561
1572
|
const filePath = (0, import_path4.join)(finalOutputDir, file);
|
|
1562
1573
|
if ((0, import_fs4.existsSync)(filePath)) {
|
|
1563
1574
|
result.filesFound.push(file);
|
|
1564
|
-
console.log(
|
|
1575
|
+
console.log(import_chalk5.default.green(` \u2713 ${file}`));
|
|
1565
1576
|
} else {
|
|
1566
1577
|
result.filesMissing.push(file);
|
|
1567
1578
|
result.errors.push(`Missing required file: ${file}`);
|
|
1568
|
-
console.log(
|
|
1579
|
+
console.log(import_chalk5.default.red(` \u2717 ${file} (MISSING)`));
|
|
1569
1580
|
}
|
|
1570
1581
|
}
|
|
1571
|
-
console.log(
|
|
1582
|
+
console.log(import_chalk5.default.blue("\u{1F4CB} Checking recommended PWA files..."));
|
|
1572
1583
|
for (const file of recommendedFiles) {
|
|
1573
1584
|
const filePath = (0, import_path4.join)(finalOutputDir, file);
|
|
1574
1585
|
if ((0, import_fs4.existsSync)(filePath)) {
|
|
1575
1586
|
result.filesFound.push(file);
|
|
1576
|
-
console.log(
|
|
1587
|
+
console.log(import_chalk5.default.green(` \u2713 ${file}`));
|
|
1577
1588
|
} else {
|
|
1578
1589
|
result.filesMissing.push(file);
|
|
1579
1590
|
result.warnings.push(`Missing recommended file: ${file}`);
|
|
1580
|
-
console.log(
|
|
1591
|
+
console.log(import_chalk5.default.yellow(` \u26A0 ${file} (recommended)`));
|
|
1581
1592
|
}
|
|
1582
1593
|
}
|
|
1583
1594
|
if (checkDocker) {
|
|
@@ -1585,7 +1596,7 @@ async function verifyCommand(options = {}) {
|
|
|
1585
1596
|
const dockerfileExists = (0, import_fs4.existsSync)(dockerfilePath);
|
|
1586
1597
|
result.dockerfileFound = dockerfileExists;
|
|
1587
1598
|
if (dockerfileExists) {
|
|
1588
|
-
console.log(
|
|
1599
|
+
console.log(import_chalk5.default.blue("\u{1F433} Checking Dockerfile..."));
|
|
1589
1600
|
const dockerfileContent = (0, import_fs4.readFileSync)(dockerfilePath, "utf-8");
|
|
1590
1601
|
const pwaFilesInDockerfile = [
|
|
1591
1602
|
"sw.js",
|
|
@@ -1603,7 +1614,7 @@ async function verifyCommand(options = {}) {
|
|
|
1603
1614
|
}
|
|
1604
1615
|
if (needsUpdate) {
|
|
1605
1616
|
result.warnings.push("Dockerfile may not copy all PWA files");
|
|
1606
|
-
console.log(
|
|
1617
|
+
console.log(import_chalk5.default.yellow(" \u26A0 Dockerfile may need updates to copy PWA files"));
|
|
1607
1618
|
if (!dockerfileContent.includes("sw.js")) {
|
|
1608
1619
|
result.dockerfileSuggestions.push("COPY sw.js /usr/share/nginx/html/");
|
|
1609
1620
|
}
|
|
@@ -1617,55 +1628,55 @@ async function verifyCommand(options = {}) {
|
|
|
1617
1628
|
result.dockerfileSuggestions.push("COPY apple-touch-icon.png /usr/share/nginx/html/");
|
|
1618
1629
|
}
|
|
1619
1630
|
if (result.dockerfileSuggestions.length > 0) {
|
|
1620
|
-
console.log(
|
|
1631
|
+
console.log(import_chalk5.default.yellow("\n Suggested Dockerfile additions:"));
|
|
1621
1632
|
result.dockerfileSuggestions.forEach((suggestion) => {
|
|
1622
|
-
console.log(
|
|
1633
|
+
console.log(import_chalk5.default.gray(` ${suggestion}`));
|
|
1623
1634
|
});
|
|
1624
1635
|
}
|
|
1625
1636
|
} else {
|
|
1626
|
-
console.log(
|
|
1637
|
+
console.log(import_chalk5.default.green(" \u2713 Dockerfile appears to copy PWA files"));
|
|
1627
1638
|
}
|
|
1628
1639
|
} else {
|
|
1629
|
-
console.log(
|
|
1640
|
+
console.log(import_chalk5.default.gray(" \u2139 No Dockerfile found (skipping Docker checks)"));
|
|
1630
1641
|
}
|
|
1631
1642
|
}
|
|
1632
1643
|
result.success = validationResult.isValid && result.filesMissing.length === 0;
|
|
1633
|
-
console.log(
|
|
1634
|
-
console.log(
|
|
1635
|
-
console.log(
|
|
1636
|
-
console.log(
|
|
1637
|
-
console.log(
|
|
1638
|
-
console.log(
|
|
1639
|
-
console.log(
|
|
1640
|
-
console.log(
|
|
1641
|
-
console.log(
|
|
1642
|
-
console.log(
|
|
1643
|
-
console.log(
|
|
1644
|
-
console.log(
|
|
1644
|
+
console.log(import_chalk5.default.blue("\n\u{1F4CA} Summary:"));
|
|
1645
|
+
console.log(import_chalk5.default.gray(` Files found: ${result.filesFound.length}`));
|
|
1646
|
+
console.log(import_chalk5.default.gray(` Files missing: ${result.filesMissing.length}`));
|
|
1647
|
+
console.log(import_chalk5.default.gray(` Warnings: ${result.warnings.length}`));
|
|
1648
|
+
console.log(import_chalk5.default.gray(` Errors: ${result.errors.length}`));
|
|
1649
|
+
console.log(import_chalk5.default.gray(` PWA Score: ${validationResult.score}/100`));
|
|
1650
|
+
console.log(import_chalk5.default.blue("\n\u{1F4CB} Validation Details:"));
|
|
1651
|
+
console.log(import_chalk5.default.gray(` Manifest: ${validationResult.details.manifest.exists ? "\u2713" : "\u2717"} ${validationResult.details.manifest.valid ? "Valid" : "Invalid"}`));
|
|
1652
|
+
console.log(import_chalk5.default.gray(` Icons: ${validationResult.details.icons.exists ? "\u2713" : "\u2717"} ${validationResult.details.icons.has192x192 ? "192\u2713" : "192\u2717"} ${validationResult.details.icons.has512x512 ? "512\u2713" : "512\u2717"}`));
|
|
1653
|
+
console.log(import_chalk5.default.gray(` Service Worker: ${validationResult.details.serviceWorker.exists ? "\u2713" : "\u2717"} ${validationResult.details.serviceWorker.valid ? "Valid" : "Invalid"}`));
|
|
1654
|
+
console.log(import_chalk5.default.gray(` Meta Tags: ${validationResult.details.metaTags.valid ? "\u2713 Valid" : "\u2717 Invalid"}`));
|
|
1655
|
+
console.log(import_chalk5.default.gray(` HTTPS: ${validationResult.details.https.isSecure ? "\u2713 Secure" : "\u26A0 Not verified"}`));
|
|
1645
1656
|
if (result.success && validationResult.score >= 90) {
|
|
1646
|
-
console.log(
|
|
1657
|
+
console.log(import_chalk5.default.green("\n\u2705 PWA setup is complete and highly compliant!"));
|
|
1647
1658
|
} else if (result.success && validationResult.score >= 70) {
|
|
1648
|
-
console.log(
|
|
1659
|
+
console.log(import_chalk5.default.yellow("\n\u26A0\uFE0F PWA setup is complete but could be improved."));
|
|
1649
1660
|
} else if (result.success) {
|
|
1650
|
-
console.log(
|
|
1661
|
+
console.log(import_chalk5.default.yellow("\n\u26A0\uFE0F PWA setup is complete but has compliance issues."));
|
|
1651
1662
|
} else {
|
|
1652
|
-
console.log(
|
|
1663
|
+
console.log(import_chalk5.default.red("\n\u274C PWA setup has critical issues that need to be fixed."));
|
|
1653
1664
|
if (result.dockerfileNeedsUpdate) {
|
|
1654
|
-
console.log(
|
|
1665
|
+
console.log(import_chalk5.default.yellow("\n\u{1F4A1} Tip: Update your Dockerfile to copy PWA files."));
|
|
1655
1666
|
}
|
|
1656
1667
|
}
|
|
1657
1668
|
return result;
|
|
1658
1669
|
} catch (error) {
|
|
1659
1670
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1660
1671
|
result.errors.push(`Verification failed: ${errorMessage}`);
|
|
1661
|
-
console.log(
|
|
1672
|
+
console.log(import_chalk5.default.red(`\u2717 Verification failed: ${errorMessage}`));
|
|
1662
1673
|
return result;
|
|
1663
1674
|
}
|
|
1664
1675
|
}
|
|
1665
1676
|
|
|
1666
1677
|
// src/commands/remove.ts
|
|
1667
1678
|
var import_universal_pwa_core11 = require("@julien-lin/universal-pwa-core");
|
|
1668
|
-
var
|
|
1679
|
+
var import_chalk6 = __toESM(require("chalk"), 1);
|
|
1669
1680
|
var import_fs6 = require("fs");
|
|
1670
1681
|
var import_glob4 = require("glob");
|
|
1671
1682
|
var import_path6 = require("path");
|
|
@@ -1756,10 +1767,10 @@ async function removeCommand(options = {}) {
|
|
|
1756
1767
|
const errorCode = "E1001" /* PROJECT_PATH_NOT_FOUND */;
|
|
1757
1768
|
const errorMessage = formatError(errorCode, result.projectPath);
|
|
1758
1769
|
result.errors.push(errorMessage);
|
|
1759
|
-
console.log(
|
|
1770
|
+
console.log(import_chalk6.default.red(`\u2717 ${errorMessage}`));
|
|
1760
1771
|
return result;
|
|
1761
1772
|
}
|
|
1762
|
-
console.log(
|
|
1773
|
+
console.log(import_chalk6.default.blue("\u{1F50D} Scanning project for PWA files..."));
|
|
1763
1774
|
const scanResult = await (0, import_universal_pwa_core11.scanProject)({
|
|
1764
1775
|
projectPath: result.projectPath,
|
|
1765
1776
|
includeAssets: false,
|
|
@@ -1785,7 +1796,7 @@ async function removeCommand(options = {}) {
|
|
|
1785
1796
|
}
|
|
1786
1797
|
}
|
|
1787
1798
|
result.outputDir = finalOutputDir;
|
|
1788
|
-
console.log(
|
|
1799
|
+
console.log(import_chalk6.default.gray(` Output directory: ${finalOutputDir}`));
|
|
1789
1800
|
transaction = new Transaction({
|
|
1790
1801
|
projectPath: result.projectPath,
|
|
1791
1802
|
outputDir: (0, import_path6.relative)(result.projectPath, finalOutputDir) || void 0,
|
|
@@ -1800,7 +1811,7 @@ async function removeCommand(options = {}) {
|
|
|
1800
1811
|
pwaFiles.push(...workboxFiles.map((f) => (0, import_path6.relative)(finalOutputDir, f)));
|
|
1801
1812
|
}
|
|
1802
1813
|
if (!skipFiles) {
|
|
1803
|
-
console.log(
|
|
1814
|
+
console.log(import_chalk6.default.blue("\u{1F5D1}\uFE0F Removing PWA files..."));
|
|
1804
1815
|
for (const file of pwaFiles) {
|
|
1805
1816
|
const filePath = (0, import_path6.join)(finalOutputDir, file);
|
|
1806
1817
|
if ((0, import_fs6.existsSync)(filePath)) {
|
|
@@ -1811,29 +1822,29 @@ async function removeCommand(options = {}) {
|
|
|
1811
1822
|
}
|
|
1812
1823
|
(0, import_fs6.rmSync)(filePath, { force: true });
|
|
1813
1824
|
result.filesRemoved.push(file);
|
|
1814
|
-
console.log(
|
|
1825
|
+
console.log(import_chalk6.default.green(` \u2713 Removed ${file}`));
|
|
1815
1826
|
} catch (error) {
|
|
1816
1827
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1817
1828
|
result.warnings.push(`Failed to remove ${file}: ${errorMessage}`);
|
|
1818
|
-
console.log(
|
|
1829
|
+
console.log(import_chalk6.default.yellow(` \u26A0 Failed to remove ${file}: ${errorMessage}`));
|
|
1819
1830
|
}
|
|
1820
1831
|
}
|
|
1821
1832
|
}
|
|
1822
1833
|
if (result.filesRemoved.length === 0) {
|
|
1823
|
-
console.log(
|
|
1834
|
+
console.log(import_chalk6.default.gray(" No PWA files found to remove"));
|
|
1824
1835
|
} else {
|
|
1825
|
-
console.log(
|
|
1836
|
+
console.log(import_chalk6.default.green(`\u2713 Removed ${result.filesRemoved.length} file(s)`));
|
|
1826
1837
|
}
|
|
1827
1838
|
}
|
|
1828
1839
|
if (!skipHtmlRestore) {
|
|
1829
|
-
console.log(
|
|
1840
|
+
console.log(import_chalk6.default.blue("\u{1F489} Restoring HTML files..."));
|
|
1830
1841
|
const htmlFiles = await (0, import_glob4.glob)("**/*.html", {
|
|
1831
1842
|
cwd: result.projectPath,
|
|
1832
1843
|
ignore: ["**/node_modules/**", "**/.next/**", "**/.nuxt/**"],
|
|
1833
1844
|
absolute: true
|
|
1834
1845
|
});
|
|
1835
1846
|
if (htmlFiles.length > 0) {
|
|
1836
|
-
console.log(
|
|
1847
|
+
console.log(import_chalk6.default.gray(` Found ${htmlFiles.length} HTML file(s)`));
|
|
1837
1848
|
for (const htmlFile of htmlFiles) {
|
|
1838
1849
|
try {
|
|
1839
1850
|
const htmlRelative = (0, import_path6.relative)(result.projectPath, htmlFile);
|
|
@@ -1845,21 +1856,21 @@ async function removeCommand(options = {}) {
|
|
|
1845
1856
|
if (removed.length > 0) {
|
|
1846
1857
|
(0, import_fs6.writeFileSync)(htmlFile, restoredHtml, "utf-8");
|
|
1847
1858
|
result.htmlFilesRestored++;
|
|
1848
|
-
console.log(
|
|
1859
|
+
console.log(import_chalk6.default.green(` \u2713 Restored ${htmlRelative} (removed ${removed.length} PWA element(s))`));
|
|
1849
1860
|
}
|
|
1850
1861
|
} catch (error) {
|
|
1851
1862
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1852
1863
|
result.warnings.push(`Failed to restore ${htmlFile}: ${errorMessage}`);
|
|
1853
|
-
console.log(
|
|
1864
|
+
console.log(import_chalk6.default.yellow(` \u26A0 Failed to restore ${htmlFile}: ${errorMessage}`));
|
|
1854
1865
|
}
|
|
1855
1866
|
}
|
|
1856
1867
|
if (result.htmlFilesRestored > 0) {
|
|
1857
|
-
console.log(
|
|
1868
|
+
console.log(import_chalk6.default.green(`\u2713 Restored ${result.htmlFilesRestored} HTML file(s)`));
|
|
1858
1869
|
} else {
|
|
1859
|
-
console.log(
|
|
1870
|
+
console.log(import_chalk6.default.gray(" No PWA meta-tags found in HTML files"));
|
|
1860
1871
|
}
|
|
1861
1872
|
} else {
|
|
1862
|
-
console.log(
|
|
1873
|
+
console.log(import_chalk6.default.gray(" No HTML files found"));
|
|
1863
1874
|
}
|
|
1864
1875
|
}
|
|
1865
1876
|
result.success = result.errors.length === 0;
|
|
@@ -1867,15 +1878,15 @@ async function removeCommand(options = {}) {
|
|
|
1867
1878
|
if (transaction) {
|
|
1868
1879
|
transaction.commit();
|
|
1869
1880
|
}
|
|
1870
|
-
console.log(
|
|
1871
|
-
console.log(
|
|
1872
|
-
console.log(
|
|
1881
|
+
console.log(import_chalk6.default.green("\n\u2705 PWA removal completed successfully!"));
|
|
1882
|
+
console.log(import_chalk6.default.gray(` Files removed: ${result.filesRemoved.length}`));
|
|
1883
|
+
console.log(import_chalk6.default.gray(` HTML files restored: ${result.htmlFilesRestored}`));
|
|
1873
1884
|
} else {
|
|
1874
1885
|
if (transaction) {
|
|
1875
|
-
console.log(
|
|
1886
|
+
console.log(import_chalk6.default.yellow("\n\u{1F504} Rolling back changes due to errors..."));
|
|
1876
1887
|
transaction.rollback();
|
|
1877
1888
|
}
|
|
1878
|
-
console.log(
|
|
1889
|
+
console.log(import_chalk6.default.red(`
|
|
1879
1890
|
\u274C PWA removal completed with ${result.errors.length} error(s)`));
|
|
1880
1891
|
}
|
|
1881
1892
|
return result;
|
|
@@ -1884,9 +1895,9 @@ async function removeCommand(options = {}) {
|
|
|
1884
1895
|
const errorCode = "E9001" /* UNEXPECTED_ERROR */;
|
|
1885
1896
|
const formattedError = formatError(errorCode, errorMessage);
|
|
1886
1897
|
result.errors.push(formattedError);
|
|
1887
|
-
console.log(
|
|
1898
|
+
console.log(import_chalk6.default.red(`\u2717 ${formattedError}`));
|
|
1888
1899
|
if (transaction) {
|
|
1889
|
-
console.log(
|
|
1900
|
+
console.log(import_chalk6.default.yellow("\n\u{1F504} Rolling back changes due to unexpected error..."));
|
|
1890
1901
|
transaction.rollback();
|
|
1891
1902
|
}
|
|
1892
1903
|
return result;
|
|
@@ -1897,7 +1908,7 @@ async function removeCommand(options = {}) {
|
|
|
1897
1908
|
var import_universal_pwa_core12 = require("@julien-lin/universal-pwa-core");
|
|
1898
1909
|
var import_node_fs = require("fs");
|
|
1899
1910
|
var import_node_path2 = require("path");
|
|
1900
|
-
var
|
|
1911
|
+
var import_chalk7 = __toESM(require("chalk"), 1);
|
|
1901
1912
|
var import_inquirer = __toESM(require("inquirer"), 1);
|
|
1902
1913
|
async function generateConfigCommand(options = {}) {
|
|
1903
1914
|
const projectPath = options.projectPath ?? process.cwd();
|
|
@@ -1917,7 +1928,7 @@ async function generateConfigCommand(options = {}) {
|
|
|
1917
1928
|
result.errors.push(`Project path not found: ${resolvedPath}`);
|
|
1918
1929
|
return result;
|
|
1919
1930
|
}
|
|
1920
|
-
console.log(
|
|
1931
|
+
console.log(import_chalk7.default.blue("\u{1F50D} Scanning project..."));
|
|
1921
1932
|
const scanResult = await (0, import_universal_pwa_core12.scanProject)({
|
|
1922
1933
|
projectPath: resolvedPath,
|
|
1923
1934
|
includeAssets: true,
|
|
@@ -1929,8 +1940,8 @@ async function generateConfigCommand(options = {}) {
|
|
|
1929
1940
|
}
|
|
1930
1941
|
const framework = scanResult.framework?.framework ?? "Unknown";
|
|
1931
1942
|
const architecture = scanResult.architecture?.architecture ?? "static";
|
|
1932
|
-
console.log(
|
|
1933
|
-
console.log(
|
|
1943
|
+
console.log(import_chalk7.default.green(`\u2713 Framework detected: ${framework}`));
|
|
1944
|
+
console.log(import_chalk7.default.green(`\u2713 Architecture: ${architecture}`));
|
|
1934
1945
|
let config = generateConfigFromScan(scanResult);
|
|
1935
1946
|
if (isInteractive) {
|
|
1936
1947
|
config = await promptConfigOptions(config);
|
|
@@ -1955,12 +1966,12 @@ async function generateConfigCommand(options = {}) {
|
|
|
1955
1966
|
(0, import_node_fs.writeFileSync)(filePath, content, "utf-8");
|
|
1956
1967
|
result.success = true;
|
|
1957
1968
|
result.filePath = filePath;
|
|
1958
|
-
console.log(
|
|
1959
|
-
console.log(
|
|
1969
|
+
console.log(import_chalk7.default.green(`\u2713 Configuration file generated: ${fileName}`));
|
|
1970
|
+
console.log(import_chalk7.default.gray(` Location: ${filePath}`));
|
|
1960
1971
|
return result;
|
|
1961
1972
|
} catch (error) {
|
|
1962
1973
|
result.errors.push(error instanceof Error ? error.message : String(error));
|
|
1963
|
-
console.error(
|
|
1974
|
+
console.error(import_chalk7.default.red(`\u2717 Error: ${result.errors[0]}`));
|
|
1964
1975
|
return result;
|
|
1965
1976
|
}
|
|
1966
1977
|
}
|
|
@@ -2211,7 +2222,7 @@ var import_universal_pwa_core13 = require("@julien-lin/universal-pwa-core");
|
|
|
2211
2222
|
var import_inquirer2 = __toESM(require("inquirer"), 1);
|
|
2212
2223
|
var import_fs8 = require("fs");
|
|
2213
2224
|
var import_path8 = require("path");
|
|
2214
|
-
var
|
|
2225
|
+
var import_chalk8 = __toESM(require("chalk"), 1);
|
|
2215
2226
|
init_environment_detector();
|
|
2216
2227
|
|
|
2217
2228
|
// src/utils/suggestions.ts
|
|
@@ -2460,88 +2471,108 @@ async function promptInitOptions(projectPath, framework, architecture = null) {
|
|
|
2460
2471
|
const defaultShortName = suggestions.name.shortName;
|
|
2461
2472
|
const defaultIconSource = suggestions.icons.length > 0 ? suggestions.icons[0].path : void 0;
|
|
2462
2473
|
const envDetection = detectEnvironment(projectPath, framework);
|
|
2463
|
-
console.log(
|
|
2474
|
+
console.log(import_chalk8.default.blue("\n\u{1F4CB} Configuration PWA\n"));
|
|
2464
2475
|
if (suggestions.name.confidence === "high") {
|
|
2465
|
-
console.log(
|
|
2476
|
+
console.log(
|
|
2477
|
+
import_chalk8.default.gray(
|
|
2478
|
+
`\u{1F4A1} Suggestion: Nom "${suggestions.name.name}" (${suggestions.name.source})`
|
|
2479
|
+
)
|
|
2480
|
+
);
|
|
2466
2481
|
}
|
|
2467
2482
|
if (suggestions.icons.length > 0) {
|
|
2468
|
-
console.log(
|
|
2483
|
+
console.log(
|
|
2484
|
+
import_chalk8.default.gray(
|
|
2485
|
+
`\u{1F4A1} Suggestion: ${suggestions.icons.length} ic\xF4ne(s) trouv\xE9e(s)`
|
|
2486
|
+
)
|
|
2487
|
+
);
|
|
2469
2488
|
}
|
|
2470
2489
|
if (suggestions.colors.confidence === "high") {
|
|
2471
|
-
console.log(
|
|
2472
|
-
}
|
|
2473
|
-
const environmentAnswer = await import_inquirer2.default.prompt(
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2490
|
+
console.log(import_chalk8.default.gray(`\u{1F4A1} Suggestion: Couleurs bas\xE9es sur ${framework}`));
|
|
2491
|
+
}
|
|
2492
|
+
const environmentAnswer = await import_inquirer2.default.prompt(
|
|
2493
|
+
[
|
|
2494
|
+
{
|
|
2495
|
+
type: "list",
|
|
2496
|
+
name: "environment",
|
|
2497
|
+
message: import_chalk8.default.bold("\u{1F3AF} O\xF9 g\xE9n\xE9rer les fichiers PWA?"),
|
|
2498
|
+
choices: [
|
|
2499
|
+
{
|
|
2500
|
+
name: `${import_chalk8.default.green("\u2713")} Local (d\xE9veloppement) - G\xE9n\xE8re dans public/`,
|
|
2501
|
+
value: "local",
|
|
2502
|
+
short: "Local"
|
|
2503
|
+
},
|
|
2504
|
+
{
|
|
2505
|
+
name: `${import_chalk8.default.cyan("\u{1F4E6}")} Production (build) - G\xE9n\xE8re dans ${envDetection.suggestedOutputDir}/`,
|
|
2506
|
+
value: "production",
|
|
2507
|
+
short: "Production"
|
|
2508
|
+
}
|
|
2509
|
+
],
|
|
2510
|
+
default: envDetection.environment
|
|
2511
|
+
}
|
|
2512
|
+
]
|
|
2513
|
+
);
|
|
2493
2514
|
if (envDetection.indicators.length > 0) {
|
|
2494
|
-
console.log(
|
|
2515
|
+
console.log(import_chalk8.default.gray(` ${envDetection.indicators.join(", ")}`));
|
|
2495
2516
|
}
|
|
2496
2517
|
const configAnswers = await import_inquirer2.default.prompt([
|
|
2497
2518
|
{
|
|
2498
2519
|
type: "input",
|
|
2499
2520
|
name: "name",
|
|
2500
|
-
message: "Nom de l'application:",
|
|
2521
|
+
message: import_chalk8.default.bold("\u{1F4F1} Nom de l'application:"),
|
|
2501
2522
|
default: defaultName,
|
|
2502
|
-
validate: validateName
|
|
2523
|
+
validate: validateName,
|
|
2524
|
+
prefix: import_chalk8.default.cyan("?")
|
|
2503
2525
|
},
|
|
2504
2526
|
{
|
|
2505
2527
|
type: "input",
|
|
2506
2528
|
name: "shortName",
|
|
2507
|
-
message:
|
|
2529
|
+
message: import_chalk8.default.bold(
|
|
2530
|
+
"\u{1F4CC} Nom court (max 12 caract\xE8res, pour l'\xE9cran d'accueil):"
|
|
2531
|
+
),
|
|
2508
2532
|
default: (answers) => {
|
|
2509
2533
|
return answers.name ? answers.name.substring(0, 12) : defaultShortName;
|
|
2510
2534
|
},
|
|
2511
2535
|
validate: validateShortName,
|
|
2512
|
-
filter: filterShortName
|
|
2536
|
+
filter: filterShortName,
|
|
2537
|
+
prefix: import_chalk8.default.cyan("?")
|
|
2513
2538
|
},
|
|
2514
2539
|
{
|
|
2515
2540
|
type: "input",
|
|
2516
2541
|
name: "iconSource",
|
|
2517
|
-
message: "Chemin vers l'image source pour les ic\xF4nes:",
|
|
2542
|
+
message: import_chalk8.default.bold("\u{1F3A8} Chemin vers l'image source pour les ic\xF4nes:"),
|
|
2518
2543
|
default: defaultIconSource,
|
|
2519
|
-
validate: (input) => validateIconSource(input, projectPath)
|
|
2544
|
+
validate: (input) => validateIconSource(input, projectPath),
|
|
2545
|
+
prefix: import_chalk8.default.cyan("?")
|
|
2520
2546
|
},
|
|
2521
2547
|
{
|
|
2522
2548
|
type: "confirm",
|
|
2523
2549
|
name: "skipIcons",
|
|
2524
|
-
message:
|
|
2550
|
+
message: import_chalk8.default.bold(
|
|
2551
|
+
"\u{1F5BC}\uFE0F G\xE9n\xE9rer les ic\xF4nes PWA \xE0 partir de cette image?"
|
|
2552
|
+
),
|
|
2525
2553
|
default: true,
|
|
2526
2554
|
when: (answers) => {
|
|
2527
2555
|
return answers.iconSource && answers.iconSource.trim().length > 0;
|
|
2528
|
-
}
|
|
2556
|
+
},
|
|
2557
|
+
prefix: import_chalk8.default.cyan("?")
|
|
2529
2558
|
},
|
|
2530
2559
|
{
|
|
2531
2560
|
type: "input",
|
|
2532
2561
|
name: "themeColor",
|
|
2533
|
-
message: "Couleur du th\xE8me (hex, ex: #ffffff):",
|
|
2562
|
+
message: import_chalk8.default.bold("\u{1F3A8} Couleur du th\xE8me (hex, ex: #ffffff):"),
|
|
2534
2563
|
default: suggestions.colors.themeColor,
|
|
2535
2564
|
validate: (input) => validateHexColor(input, "themeColor"),
|
|
2536
|
-
filter: filterHexColor
|
|
2565
|
+
filter: filterHexColor,
|
|
2566
|
+
prefix: import_chalk8.default.cyan("?")
|
|
2537
2567
|
},
|
|
2538
2568
|
{
|
|
2539
2569
|
type: "input",
|
|
2540
2570
|
name: "backgroundColor",
|
|
2541
|
-
message: "Couleur de fond (hex, ex: #000000):",
|
|
2571
|
+
message: import_chalk8.default.bold("\u2B1C Couleur de fond (hex, ex: #000000):"),
|
|
2542
2572
|
default: suggestions.colors.backgroundColor,
|
|
2543
2573
|
validate: (input) => validateHexColor(input, "backgroundColor"),
|
|
2544
|
-
filter: filterHexColor
|
|
2574
|
+
filter: filterHexColor,
|
|
2575
|
+
prefix: import_chalk8.default.cyan("?")
|
|
2545
2576
|
}
|
|
2546
2577
|
]);
|
|
2547
2578
|
configAnswers.skipIcons = !configAnswers.skipIcons;
|
|
@@ -2554,16 +2585,18 @@ async function promptInitOptions(projectPath, framework, architecture = null) {
|
|
|
2554
2585
|
if (!configAnswers.shortName || configAnswers.shortName.trim().length === 0) {
|
|
2555
2586
|
configAnswers.shortName = defaultShortName;
|
|
2556
2587
|
}
|
|
2588
|
+
const installButton = configAnswers.installButton ?? true;
|
|
2557
2589
|
return {
|
|
2558
2590
|
...environmentAnswer,
|
|
2559
|
-
...configAnswers
|
|
2591
|
+
...configAnswers,
|
|
2592
|
+
installButton
|
|
2560
2593
|
};
|
|
2561
2594
|
}
|
|
2562
2595
|
|
|
2563
2596
|
// package.json
|
|
2564
2597
|
var package_default = {
|
|
2565
2598
|
name: "@julien-lin/universal-pwa-cli",
|
|
2566
|
-
version: "1.3.
|
|
2599
|
+
version: "1.3.9",
|
|
2567
2600
|
description: "CLI to transform any web project into a PWA",
|
|
2568
2601
|
keywords: [
|
|
2569
2602
|
"pwa",
|
|
@@ -2664,14 +2697,14 @@ program.command("init").description("Initialize PWA in your project").option("-p
|
|
|
2664
2697
|
const hasOptions = options.name || options.shortName || options.iconSource || options.themeColor || options.backgroundColor || options.skipIcons !== void 0;
|
|
2665
2698
|
let finalOptions = { ...options };
|
|
2666
2699
|
if (!hasOptions) {
|
|
2667
|
-
console.log(
|
|
2700
|
+
console.log(import_chalk9.default.blue("\u{1F50D} Scanning project..."));
|
|
2668
2701
|
const scanResult = await (0, import_universal_pwa_core13.scanProject)({
|
|
2669
2702
|
projectPath,
|
|
2670
2703
|
includeAssets: false,
|
|
2671
2704
|
includeArchitecture: false
|
|
2672
2705
|
});
|
|
2673
|
-
console.log(
|
|
2674
|
-
console.log(
|
|
2706
|
+
console.log(import_chalk9.default.green(`\u2713 Framework detected: ${scanResult.framework.framework ?? "Unknown"}`));
|
|
2707
|
+
console.log(import_chalk9.default.green(`\u2713 Architecture: ${scanResult.architecture.architecture}`));
|
|
2675
2708
|
const promptAnswers = await promptInitOptions(
|
|
2676
2709
|
projectPath,
|
|
2677
2710
|
scanResult.framework.framework,
|
|
@@ -2686,10 +2719,10 @@ program.command("init").description("Initialize PWA in your project").option("-p
|
|
|
2686
2719
|
finalOptions.outputDir = "build";
|
|
2687
2720
|
} else {
|
|
2688
2721
|
finalOptions.outputDir = "dist";
|
|
2689
|
-
console.log(
|
|
2690
|
-
console.log(
|
|
2691
|
-
console.log(
|
|
2692
|
-
console.log(
|
|
2722
|
+
console.log(import_chalk9.default.yellow("\u26A0 dist/ directory not found. Run build first:"));
|
|
2723
|
+
console.log(import_chalk9.default.gray(" npm run build"));
|
|
2724
|
+
console.log(import_chalk9.default.gray(" or"));
|
|
2725
|
+
console.log(import_chalk9.default.gray(" pnpm build"));
|
|
2693
2726
|
}
|
|
2694
2727
|
} else {
|
|
2695
2728
|
finalOptions.outputDir = "public";
|
|
@@ -2721,7 +2754,7 @@ program.command("init").description("Initialize PWA in your project").option("-p
|
|
|
2721
2754
|
});
|
|
2722
2755
|
process.exit(result.success ? 0 : 1);
|
|
2723
2756
|
} catch (error) {
|
|
2724
|
-
console.error(
|
|
2757
|
+
console.error(import_chalk9.default.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
2725
2758
|
process.exit(1);
|
|
2726
2759
|
}
|
|
2727
2760
|
});
|
|
@@ -2734,31 +2767,31 @@ program.command("preview").description("Preview PWA setup").option("-p, --projec
|
|
|
2734
2767
|
});
|
|
2735
2768
|
process.exit(result.success ? 0 : 1);
|
|
2736
2769
|
} catch (error) {
|
|
2737
|
-
console.error(
|
|
2770
|
+
console.error(import_chalk9.default.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
2738
2771
|
process.exit(1);
|
|
2739
2772
|
}
|
|
2740
2773
|
});
|
|
2741
2774
|
program.command("scan").description("Scan project and detect framework/architecture").option("-p, --project-path <path>", "Project path", process.cwd()).action(async (options) => {
|
|
2742
2775
|
try {
|
|
2743
|
-
console.log(
|
|
2776
|
+
console.log(import_chalk9.default.blue("\u{1F50D} Scanning project..."));
|
|
2744
2777
|
const result = await (0, import_universal_pwa_core13.scanProject)({
|
|
2745
2778
|
projectPath: options.projectPath ?? process.cwd(),
|
|
2746
2779
|
includeAssets: true,
|
|
2747
2780
|
includeArchitecture: true
|
|
2748
2781
|
});
|
|
2749
|
-
console.log(
|
|
2782
|
+
console.log(import_chalk9.default.green(`
|
|
2750
2783
|
\u2713 Framework: ${result.framework.framework ?? "Unknown"}`));
|
|
2751
|
-
console.log(
|
|
2752
|
-
console.log(
|
|
2753
|
-
console.log(
|
|
2784
|
+
console.log(import_chalk9.default.green(`\u2713 Architecture: ${result.architecture.architecture}`));
|
|
2785
|
+
console.log(import_chalk9.default.green(`\u2713 Build Tool: ${result.architecture.buildTool ?? "Unknown"}`));
|
|
2786
|
+
console.log(import_chalk9.default.gray(`
|
|
2754
2787
|
Assets found:`));
|
|
2755
|
-
console.log(
|
|
2756
|
-
console.log(
|
|
2757
|
-
console.log(
|
|
2758
|
-
console.log(
|
|
2788
|
+
console.log(import_chalk9.default.gray(` - JavaScript: ${result.assets.javascript.length} files`));
|
|
2789
|
+
console.log(import_chalk9.default.gray(` - CSS: ${result.assets.css.length} files`));
|
|
2790
|
+
console.log(import_chalk9.default.gray(` - Images: ${result.assets.images.length} files`));
|
|
2791
|
+
console.log(import_chalk9.default.gray(` - Fonts: ${result.assets.fonts.length} files`));
|
|
2759
2792
|
process.exit(0);
|
|
2760
2793
|
} catch (error) {
|
|
2761
|
-
console.error(
|
|
2794
|
+
console.error(import_chalk9.default.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
2762
2795
|
process.exit(1);
|
|
2763
2796
|
}
|
|
2764
2797
|
});
|
|
@@ -2773,7 +2806,7 @@ program.command("generate-config").description("Generate universal-pwa config fi
|
|
|
2773
2806
|
});
|
|
2774
2807
|
process.exit(result.success ? 0 : 1);
|
|
2775
2808
|
} catch (error) {
|
|
2776
|
-
console.error(
|
|
2809
|
+
console.error(import_chalk9.default.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
2777
2810
|
process.exit(1);
|
|
2778
2811
|
}
|
|
2779
2812
|
});
|
|
@@ -2786,7 +2819,7 @@ program.command("verify").description("Verify PWA setup and check for missing fi
|
|
|
2786
2819
|
});
|
|
2787
2820
|
process.exit(result.success ? 0 : 1);
|
|
2788
2821
|
} catch (error) {
|
|
2789
|
-
console.error(
|
|
2822
|
+
console.error(import_chalk9.default.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
2790
2823
|
process.exit(1);
|
|
2791
2824
|
}
|
|
2792
2825
|
});
|
|
@@ -2801,7 +2834,7 @@ program.command("remove").description("Remove PWA files and restore HTML files")
|
|
|
2801
2834
|
});
|
|
2802
2835
|
process.exit(result.success ? 0 : 1);
|
|
2803
2836
|
} catch (error) {
|
|
2804
|
-
console.error(
|
|
2837
|
+
console.error(import_chalk9.default.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
2805
2838
|
process.exit(1);
|
|
2806
2839
|
}
|
|
2807
2840
|
});
|