@julien-lin/universal-pwa-cli 1.2.4 → 1.2.6
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 +26 -1
- package/dist/index.js +26 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -213,21 +213,46 @@ async function initCommand(options = {}) {
|
|
|
213
213
|
try {
|
|
214
214
|
const htmlFiles = await (0, import_glob.glob)("**/*.html", {
|
|
215
215
|
cwd: result.projectPath,
|
|
216
|
-
ignore: ["**/node_modules/**", "
|
|
216
|
+
ignore: ["**/node_modules/**", "**/.next/**", "**/.nuxt/**"],
|
|
217
217
|
absolute: true
|
|
218
218
|
});
|
|
219
|
+
htmlFiles.sort((a, b) => {
|
|
220
|
+
const aInDist = a.includes("/dist/");
|
|
221
|
+
const bInDist = b.includes("/dist/");
|
|
222
|
+
const aInPublic = a.includes("/public/");
|
|
223
|
+
const bInPublic = b.includes("/public/");
|
|
224
|
+
if (aInDist && !bInDist) return -1;
|
|
225
|
+
if (!aInDist && bInDist) return 1;
|
|
226
|
+
if (aInPublic && !bInPublic) return -1;
|
|
227
|
+
if (!aInPublic && bInPublic) return 1;
|
|
228
|
+
return 0;
|
|
229
|
+
});
|
|
219
230
|
let injectedCount = 0;
|
|
220
231
|
for (const htmlFile of htmlFiles.slice(0, 10)) {
|
|
221
232
|
try {
|
|
222
233
|
const normalizePathForInjection = (fullPath, basePath, outputDir2, fallback) => {
|
|
223
234
|
if (!fullPath) return fallback;
|
|
224
235
|
try {
|
|
236
|
+
const htmlInDist = htmlFile.includes("/dist/");
|
|
237
|
+
const swInDist = fullPath.includes("/dist/");
|
|
238
|
+
if (htmlInDist && swInDist) {
|
|
239
|
+
const distIndex = fullPath.indexOf("/dist/");
|
|
240
|
+
if (distIndex !== -1) {
|
|
241
|
+
const distPath = fullPath.substring(distIndex + 6);
|
|
242
|
+
return distPath.startsWith("/") ? distPath : `/${distPath}`;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
225
245
|
const rel = relativePath(fullPath, basePath);
|
|
226
246
|
let normalized = rel.startsWith("/") ? rel : `/${rel}`;
|
|
227
247
|
const outputDirName = outputDir2.replace(basePath, "").replace(/^\/+|\/+$/g, "");
|
|
228
248
|
if (outputDirName && normalized.startsWith(`/${outputDirName}/`)) {
|
|
229
249
|
normalized = normalized.replace(`/${outputDirName}/`, "/");
|
|
230
250
|
}
|
|
251
|
+
if (normalized.includes("/dist/")) {
|
|
252
|
+
const distIndex = normalized.indexOf("/dist/");
|
|
253
|
+
normalized = normalized.substring(distIndex + 6);
|
|
254
|
+
normalized = normalized.startsWith("/") ? normalized : `/${normalized}`;
|
|
255
|
+
}
|
|
231
256
|
return normalized;
|
|
232
257
|
} catch {
|
|
233
258
|
return fallback;
|
package/dist/index.js
CHANGED
|
@@ -190,21 +190,46 @@ async function initCommand(options = {}) {
|
|
|
190
190
|
try {
|
|
191
191
|
const htmlFiles = await glob("**/*.html", {
|
|
192
192
|
cwd: result.projectPath,
|
|
193
|
-
ignore: ["**/node_modules/**", "
|
|
193
|
+
ignore: ["**/node_modules/**", "**/.next/**", "**/.nuxt/**"],
|
|
194
194
|
absolute: true
|
|
195
195
|
});
|
|
196
|
+
htmlFiles.sort((a, b) => {
|
|
197
|
+
const aInDist = a.includes("/dist/");
|
|
198
|
+
const bInDist = b.includes("/dist/");
|
|
199
|
+
const aInPublic = a.includes("/public/");
|
|
200
|
+
const bInPublic = b.includes("/public/");
|
|
201
|
+
if (aInDist && !bInDist) return -1;
|
|
202
|
+
if (!aInDist && bInDist) return 1;
|
|
203
|
+
if (aInPublic && !bInPublic) return -1;
|
|
204
|
+
if (!aInPublic && bInPublic) return 1;
|
|
205
|
+
return 0;
|
|
206
|
+
});
|
|
196
207
|
let injectedCount = 0;
|
|
197
208
|
for (const htmlFile of htmlFiles.slice(0, 10)) {
|
|
198
209
|
try {
|
|
199
210
|
const normalizePathForInjection = (fullPath, basePath, outputDir2, fallback) => {
|
|
200
211
|
if (!fullPath) return fallback;
|
|
201
212
|
try {
|
|
213
|
+
const htmlInDist = htmlFile.includes("/dist/");
|
|
214
|
+
const swInDist = fullPath.includes("/dist/");
|
|
215
|
+
if (htmlInDist && swInDist) {
|
|
216
|
+
const distIndex = fullPath.indexOf("/dist/");
|
|
217
|
+
if (distIndex !== -1) {
|
|
218
|
+
const distPath = fullPath.substring(distIndex + 6);
|
|
219
|
+
return distPath.startsWith("/") ? distPath : `/${distPath}`;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
202
222
|
const rel = relativePath(fullPath, basePath);
|
|
203
223
|
let normalized = rel.startsWith("/") ? rel : `/${rel}`;
|
|
204
224
|
const outputDirName = outputDir2.replace(basePath, "").replace(/^\/+|\/+$/g, "");
|
|
205
225
|
if (outputDirName && normalized.startsWith(`/${outputDirName}/`)) {
|
|
206
226
|
normalized = normalized.replace(`/${outputDirName}/`, "/");
|
|
207
227
|
}
|
|
228
|
+
if (normalized.includes("/dist/")) {
|
|
229
|
+
const distIndex = normalized.indexOf("/dist/");
|
|
230
|
+
normalized = normalized.substring(distIndex + 6);
|
|
231
|
+
normalized = normalized.startsWith("/") ? normalized : `/${normalized}`;
|
|
232
|
+
}
|
|
208
233
|
return normalized;
|
|
209
234
|
} catch {
|
|
210
235
|
return fallback;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@julien-lin/universal-pwa-cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "CLI to transform any web project into a PWA",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pwa",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"inquirer": "^12.0.0",
|
|
63
63
|
"pino": "^9.14.0",
|
|
64
64
|
"zod": "^4.2.1",
|
|
65
|
-
"@julien-lin/universal-pwa-core": "^1.2.
|
|
65
|
+
"@julien-lin/universal-pwa-core": "^1.2.6"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@vitest/coverage-v8": "^2.1.4",
|