@julien-lin/universal-pwa-cli 1.3.17 → 1.3.20
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 +93 -7
- package/dist/index.js +94 -7
- package/package.json +2 -4
package/dist/index.cjs
CHANGED
|
@@ -467,10 +467,11 @@ var import_universal_pwa_core9 = require("@julien-lin/universal-pwa-core");
|
|
|
467
467
|
|
|
468
468
|
// src/utils/ui-utils.ts
|
|
469
469
|
var import_chalk2 = __toESM(require("chalk"), 1);
|
|
470
|
-
|
|
471
|
-
|
|
470
|
+
function stripAnsi(s) {
|
|
471
|
+
return s.replace(/\u001B\[\d*(?:;\d*)*[a-zA-Z]/g, "");
|
|
472
|
+
}
|
|
472
473
|
function visibleWidth(s) {
|
|
473
|
-
return (
|
|
474
|
+
return stripAnsi(s).length;
|
|
474
475
|
}
|
|
475
476
|
function padRightVisible(s, width) {
|
|
476
477
|
const w = visibleWidth(s);
|
|
@@ -813,7 +814,9 @@ async function initCommand(options = {}) {
|
|
|
813
814
|
finalBasePath = normalizeBasePath(effectiveBasePath);
|
|
814
815
|
if (finalBasePath !== "/") {
|
|
815
816
|
console.log(
|
|
816
|
-
import_chalk3.default.gray(
|
|
817
|
+
import_chalk3.default.gray(
|
|
818
|
+
` Base path: ${finalBasePath}${rawBasePath ? "" : " (auto)"}`
|
|
819
|
+
)
|
|
817
820
|
);
|
|
818
821
|
}
|
|
819
822
|
} catch (error) {
|
|
@@ -1504,6 +1507,91 @@ async function initCommand(options = {}) {
|
|
|
1504
1507
|
}
|
|
1505
1508
|
return result;
|
|
1506
1509
|
}
|
|
1510
|
+
if (result.framework === "nextjs") {
|
|
1511
|
+
try {
|
|
1512
|
+
console.log(
|
|
1513
|
+
import_chalk3.default.blue("\u{1F489} Injecting metadata into Next.js layout files...")
|
|
1514
|
+
);
|
|
1515
|
+
const layoutFiles = await (0, import_glob.glob)(
|
|
1516
|
+
["**/app/layout.{ts,tsx}", "**/src/app/layout.{ts,tsx}"],
|
|
1517
|
+
{
|
|
1518
|
+
cwd: result.projectPath,
|
|
1519
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/.next/**"],
|
|
1520
|
+
absolute: true
|
|
1521
|
+
}
|
|
1522
|
+
);
|
|
1523
|
+
if (layoutFiles.length > 0) {
|
|
1524
|
+
console.log(
|
|
1525
|
+
import_chalk3.default.gray(
|
|
1526
|
+
` Found ${layoutFiles.length} Next.js layout file(s)`
|
|
1527
|
+
)
|
|
1528
|
+
);
|
|
1529
|
+
for (const layoutFile of layoutFiles) {
|
|
1530
|
+
const layoutRelativePath = (0, import_path2.relative)(
|
|
1531
|
+
result.projectPath,
|
|
1532
|
+
layoutFile
|
|
1533
|
+
);
|
|
1534
|
+
if (layoutRelativePath && !layoutRelativePath.startsWith("..")) {
|
|
1535
|
+
transaction.backupFile(layoutRelativePath);
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
let nextJsInjectedCount = 0;
|
|
1539
|
+
for (const layoutFile of layoutFiles) {
|
|
1540
|
+
try {
|
|
1541
|
+
const injectionResult = (0, import_universal_pwa_core6.injectNextJsMetadataInFile)(layoutFile, {
|
|
1542
|
+
manifestPath: result.manifestPath || "/manifest.json",
|
|
1543
|
+
basePath: finalBasePath
|
|
1544
|
+
});
|
|
1545
|
+
if (injectionResult.modified) {
|
|
1546
|
+
nextJsInjectedCount++;
|
|
1547
|
+
const relativePath2 = (0, import_path2.relative)(result.projectPath, layoutFile);
|
|
1548
|
+
console.log(
|
|
1549
|
+
import_chalk3.default.gray(` \u2713 ${relativePath2}: metadata injected`)
|
|
1550
|
+
);
|
|
1551
|
+
} else if (injectionResult.skipped.length > 0) {
|
|
1552
|
+
const relativePath2 = (0, import_path2.relative)(result.projectPath, layoutFile);
|
|
1553
|
+
console.log(
|
|
1554
|
+
import_chalk3.default.gray(
|
|
1555
|
+
` \u2298 ${relativePath2}: manifest already present`
|
|
1556
|
+
)
|
|
1557
|
+
);
|
|
1558
|
+
} else {
|
|
1559
|
+
const relativePath2 = (0, import_path2.relative)(result.projectPath, layoutFile);
|
|
1560
|
+
console.log(
|
|
1561
|
+
import_chalk3.default.yellow(
|
|
1562
|
+
` \u26A0 ${relativePath2}: could not inject metadata`
|
|
1563
|
+
)
|
|
1564
|
+
);
|
|
1565
|
+
if (injectionResult.warnings.length > 0) {
|
|
1566
|
+
injectionResult.warnings.forEach((warning) => {
|
|
1567
|
+
result.warnings.push(`${relativePath2}: ${warning}`);
|
|
1568
|
+
});
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
} catch (error) {
|
|
1572
|
+
const relativePath2 = (0, import_path2.relative)(result.projectPath, layoutFile);
|
|
1573
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
1574
|
+
result.warnings.push(
|
|
1575
|
+
`${relativePath2}: Failed to process - ${errorMsg}`
|
|
1576
|
+
);
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
if (nextJsInjectedCount > 0) {
|
|
1580
|
+
result.htmlFilesInjected += nextJsInjectedCount;
|
|
1581
|
+
console.log(
|
|
1582
|
+
import_chalk3.default.green(
|
|
1583
|
+
`\u2713 Injected metadata in ${nextJsInjectedCount} Next.js layout file(s)`
|
|
1584
|
+
)
|
|
1585
|
+
);
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
} catch (error) {
|
|
1589
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1590
|
+
result.warnings.push(
|
|
1591
|
+
`Next.js layout injection failed: ${errorMessage}`
|
|
1592
|
+
);
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1507
1595
|
}
|
|
1508
1596
|
result.success = result.errors.length === 0;
|
|
1509
1597
|
if (result.success) {
|
|
@@ -2744,7 +2832,7 @@ async function promptInitOptions(projectPath, framework, architecture = null) {
|
|
|
2744
2832
|
// package.json
|
|
2745
2833
|
var package_default = {
|
|
2746
2834
|
name: "@julien-lin/universal-pwa-cli",
|
|
2747
|
-
version: "1.3.
|
|
2835
|
+
version: "1.3.20",
|
|
2748
2836
|
description: "CLI to transform any web project into a PWA",
|
|
2749
2837
|
keywords: [
|
|
2750
2838
|
"pwa",
|
|
@@ -2814,8 +2902,6 @@ var package_default = {
|
|
|
2814
2902
|
glob: "^13.0.0",
|
|
2815
2903
|
inquirer: "^13.2.2",
|
|
2816
2904
|
pino: "^10.3.0",
|
|
2817
|
-
"string-width": "^8.1.1",
|
|
2818
|
-
"strip-ansi": "^7.1.2",
|
|
2819
2905
|
zod: "^4.3.6"
|
|
2820
2906
|
},
|
|
2821
2907
|
devDependencies: {
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
} from "@julien-lin/universal-pwa-core";
|
|
23
23
|
import {
|
|
24
24
|
injectMetaTagsInFile,
|
|
25
|
+
injectNextJsMetadataInFile,
|
|
25
26
|
processInParallel
|
|
26
27
|
} from "@julien-lin/universal-pwa-core";
|
|
27
28
|
import { checkProjectHttps } from "@julien-lin/universal-pwa-core";
|
|
@@ -361,10 +362,11 @@ import {
|
|
|
361
362
|
|
|
362
363
|
// src/utils/ui-utils.ts
|
|
363
364
|
import chalk2 from "chalk";
|
|
364
|
-
|
|
365
|
-
|
|
365
|
+
function stripAnsi(s) {
|
|
366
|
+
return s.replace(/\u001B\[\d*(?:;\d*)*[a-zA-Z]/g, "");
|
|
367
|
+
}
|
|
366
368
|
function visibleWidth(s) {
|
|
367
|
-
return
|
|
369
|
+
return stripAnsi(s).length;
|
|
368
370
|
}
|
|
369
371
|
function padRightVisible(s, width) {
|
|
370
372
|
const w = visibleWidth(s);
|
|
@@ -707,7 +709,9 @@ async function initCommand(options = {}) {
|
|
|
707
709
|
finalBasePath = normalizeBasePath(effectiveBasePath);
|
|
708
710
|
if (finalBasePath !== "/") {
|
|
709
711
|
console.log(
|
|
710
|
-
chalk3.gray(
|
|
712
|
+
chalk3.gray(
|
|
713
|
+
` Base path: ${finalBasePath}${rawBasePath ? "" : " (auto)"}`
|
|
714
|
+
)
|
|
711
715
|
);
|
|
712
716
|
}
|
|
713
717
|
} catch (error) {
|
|
@@ -1398,6 +1402,91 @@ async function initCommand(options = {}) {
|
|
|
1398
1402
|
}
|
|
1399
1403
|
return result;
|
|
1400
1404
|
}
|
|
1405
|
+
if (result.framework === "nextjs") {
|
|
1406
|
+
try {
|
|
1407
|
+
console.log(
|
|
1408
|
+
chalk3.blue("\u{1F489} Injecting metadata into Next.js layout files...")
|
|
1409
|
+
);
|
|
1410
|
+
const layoutFiles = await glob(
|
|
1411
|
+
["**/app/layout.{ts,tsx}", "**/src/app/layout.{ts,tsx}"],
|
|
1412
|
+
{
|
|
1413
|
+
cwd: result.projectPath,
|
|
1414
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/.next/**"],
|
|
1415
|
+
absolute: true
|
|
1416
|
+
}
|
|
1417
|
+
);
|
|
1418
|
+
if (layoutFiles.length > 0) {
|
|
1419
|
+
console.log(
|
|
1420
|
+
chalk3.gray(
|
|
1421
|
+
` Found ${layoutFiles.length} Next.js layout file(s)`
|
|
1422
|
+
)
|
|
1423
|
+
);
|
|
1424
|
+
for (const layoutFile of layoutFiles) {
|
|
1425
|
+
const layoutRelativePath = relative(
|
|
1426
|
+
result.projectPath,
|
|
1427
|
+
layoutFile
|
|
1428
|
+
);
|
|
1429
|
+
if (layoutRelativePath && !layoutRelativePath.startsWith("..")) {
|
|
1430
|
+
transaction.backupFile(layoutRelativePath);
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
let nextJsInjectedCount = 0;
|
|
1434
|
+
for (const layoutFile of layoutFiles) {
|
|
1435
|
+
try {
|
|
1436
|
+
const injectionResult = injectNextJsMetadataInFile(layoutFile, {
|
|
1437
|
+
manifestPath: result.manifestPath || "/manifest.json",
|
|
1438
|
+
basePath: finalBasePath
|
|
1439
|
+
});
|
|
1440
|
+
if (injectionResult.modified) {
|
|
1441
|
+
nextJsInjectedCount++;
|
|
1442
|
+
const relativePath2 = relative(result.projectPath, layoutFile);
|
|
1443
|
+
console.log(
|
|
1444
|
+
chalk3.gray(` \u2713 ${relativePath2}: metadata injected`)
|
|
1445
|
+
);
|
|
1446
|
+
} else if (injectionResult.skipped.length > 0) {
|
|
1447
|
+
const relativePath2 = relative(result.projectPath, layoutFile);
|
|
1448
|
+
console.log(
|
|
1449
|
+
chalk3.gray(
|
|
1450
|
+
` \u2298 ${relativePath2}: manifest already present`
|
|
1451
|
+
)
|
|
1452
|
+
);
|
|
1453
|
+
} else {
|
|
1454
|
+
const relativePath2 = relative(result.projectPath, layoutFile);
|
|
1455
|
+
console.log(
|
|
1456
|
+
chalk3.yellow(
|
|
1457
|
+
` \u26A0 ${relativePath2}: could not inject metadata`
|
|
1458
|
+
)
|
|
1459
|
+
);
|
|
1460
|
+
if (injectionResult.warnings.length > 0) {
|
|
1461
|
+
injectionResult.warnings.forEach((warning) => {
|
|
1462
|
+
result.warnings.push(`${relativePath2}: ${warning}`);
|
|
1463
|
+
});
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
} catch (error) {
|
|
1467
|
+
const relativePath2 = relative(result.projectPath, layoutFile);
|
|
1468
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
1469
|
+
result.warnings.push(
|
|
1470
|
+
`${relativePath2}: Failed to process - ${errorMsg}`
|
|
1471
|
+
);
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
if (nextJsInjectedCount > 0) {
|
|
1475
|
+
result.htmlFilesInjected += nextJsInjectedCount;
|
|
1476
|
+
console.log(
|
|
1477
|
+
chalk3.green(
|
|
1478
|
+
`\u2713 Injected metadata in ${nextJsInjectedCount} Next.js layout file(s)`
|
|
1479
|
+
)
|
|
1480
|
+
);
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
} catch (error) {
|
|
1484
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1485
|
+
result.warnings.push(
|
|
1486
|
+
`Next.js layout injection failed: ${errorMessage}`
|
|
1487
|
+
);
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1401
1490
|
}
|
|
1402
1491
|
result.success = result.errors.length === 0;
|
|
1403
1492
|
if (result.success) {
|
|
@@ -2636,7 +2725,7 @@ async function promptInitOptions(projectPath, framework, architecture = null) {
|
|
|
2636
2725
|
// package.json
|
|
2637
2726
|
var package_default = {
|
|
2638
2727
|
name: "@julien-lin/universal-pwa-cli",
|
|
2639
|
-
version: "1.3.
|
|
2728
|
+
version: "1.3.20",
|
|
2640
2729
|
description: "CLI to transform any web project into a PWA",
|
|
2641
2730
|
keywords: [
|
|
2642
2731
|
"pwa",
|
|
@@ -2706,8 +2795,6 @@ var package_default = {
|
|
|
2706
2795
|
glob: "^13.0.0",
|
|
2707
2796
|
inquirer: "^13.2.2",
|
|
2708
2797
|
pino: "^10.3.0",
|
|
2709
|
-
"string-width": "^8.1.1",
|
|
2710
|
-
"strip-ansi": "^7.1.2",
|
|
2711
2798
|
zod: "^4.3.6"
|
|
2712
2799
|
},
|
|
2713
2800
|
devDependencies: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@julien-lin/universal-pwa-cli",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.20",
|
|
4
4
|
"description": "CLI to transform any web project into a PWA",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pwa",
|
|
@@ -63,10 +63,8 @@
|
|
|
63
63
|
"glob": "^13.0.0",
|
|
64
64
|
"inquirer": "^13.2.2",
|
|
65
65
|
"pino": "^10.3.0",
|
|
66
|
-
"string-width": "^8.1.1",
|
|
67
|
-
"strip-ansi": "^7.1.2",
|
|
68
66
|
"zod": "^4.3.6",
|
|
69
|
-
"@julien-lin/universal-pwa-core": "^1.3.
|
|
67
|
+
"@julien-lin/universal-pwa-core": "^1.3.20"
|
|
70
68
|
},
|
|
71
69
|
"devDependencies": {
|
|
72
70
|
"@vitest/coverage-v8": "^4.0.18",
|