nextworks 0.2.0-alpha.7 → 0.2.0-alpha.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/README.md +23 -22
- package/dist/cli_manifests/blocks_manifest.json +13 -32
- package/dist/commands/blocks.d.ts +1 -0
- package/dist/commands/blocks.d.ts.map +1 -1
- package/dist/commands/blocks.js +536 -9
- package/dist/commands/blocks.js.map +1 -1
- package/dist/commands/remove-blocks.js +2 -2
- package/dist/commands/remove-blocks.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/kits/blocks/.nextworks/docs/BLOCKS_QUICKSTART.md +1 -1
- package/dist/kits/blocks/.nextworks/docs/BLOCKS_README.md +2 -3
- package/dist/kits/blocks/.nextworks/docs/THEME_GUIDE.md +269 -269
- package/dist/kits/blocks/app/templates/digitalagency/components/About.tsx +71 -99
- package/dist/kits/blocks/app/templates/digitalagency/components/CTA.tsx +40 -74
- package/dist/kits/blocks/app/templates/digitalagency/components/Contact.tsx +123 -227
- package/dist/kits/blocks/app/templates/digitalagency/components/Footer.tsx +89 -89
- package/dist/kits/blocks/app/templates/digitalagency/components/Hero.tsx +83 -90
- package/dist/kits/blocks/app/templates/digitalagency/components/Navbar.tsx +121 -168
- package/dist/kits/blocks/app/templates/digitalagency/components/NetworkPattern.tsx +288 -297
- package/dist/kits/blocks/app/templates/digitalagency/components/Portfolio.tsx +157 -157
- package/dist/kits/blocks/app/templates/gallery/PresetThemeVars.tsx +1 -2
- package/dist/kits/blocks/app/templates/gallery/page.tsx +300 -303
- package/dist/kits/blocks/app/templates/productlaunch/PresetThemeVars.tsx +1 -0
- package/dist/kits/blocks/app/templates/productlaunch/components/About.tsx +0 -94
- package/dist/kits/blocks/app/templates/productlaunch/components/CTA.tsx +2 -45
- package/dist/kits/blocks/app/templates/productlaunch/components/FAQ.tsx +4 -11
- package/dist/kits/blocks/app/templates/productlaunch/components/Features.tsx +1 -2
- package/dist/kits/blocks/app/templates/productlaunch/components/Footer.tsx +1 -1
- package/dist/kits/blocks/app/templates/productlaunch/components/Hero.tsx +6 -7
- package/dist/kits/blocks/app/templates/productlaunch/components/Navbar.tsx +8 -54
- package/dist/kits/blocks/app/templates/productlaunch/components/Pricing.tsx +1 -1
- package/dist/kits/blocks/app/templates/productlaunch/components/ProcessTimeline.tsx +1 -1
- package/dist/kits/blocks/app/templates/productlaunch/components/ServicesGrid.tsx +1 -1
- package/dist/kits/blocks/app/templates/productlaunch/components/Team.tsx +1 -1
- package/dist/kits/blocks/app/templates/productlaunch/components/Testimonials.tsx +2 -1
- package/dist/kits/blocks/app/templates/productlaunch/components/TrustBadges.tsx +1 -1
- package/dist/kits/blocks/app/templates/saasdashboard/README.md +1 -1
- package/dist/kits/blocks/app/templates/saasdashboard/components/Contact.tsx +0 -47
- package/dist/kits/blocks/app/templates/saasdashboard/components/Dashboard.tsx +2 -2
- package/dist/kits/blocks/app/templates/saasdashboard/components/Features.tsx +0 -1
- package/dist/kits/blocks/app/templates/saasdashboard/components/Hero.tsx +0 -1
- package/dist/kits/blocks/app/templates/saasdashboard/components/Hero_mask.tsx +0 -1
- package/dist/kits/blocks/app/templates/saasdashboard/components/Navbar.tsx +4 -46
- package/dist/kits/blocks/app/templates/saasdashboard/components/SmoothScroll.tsx +3 -4
- package/dist/kits/blocks/app/templates/saasdashboard/components/Testimonials.tsx +1 -1
- package/dist/kits/blocks/components/enhanced-theme-provider.tsx +17 -5
- package/dist/kits/blocks/components/sections/CTA.tsx +0 -1
- package/dist/kits/blocks/components/sections/FAQ.tsx +0 -11
- package/dist/kits/blocks/components/sections/Features.tsx +2 -4
- package/dist/kits/blocks/components/sections/HeroMotion.tsx +1 -1
- package/dist/kits/blocks/components/sections/HeroOverlay.tsx +2 -2
- package/dist/kits/blocks/components/sections/HeroSplit.tsx +1 -1
- package/dist/kits/blocks/components/sections/Navbar.tsx +1 -4
- package/dist/kits/blocks/components/sections/PortfolioSimple.tsx +0 -1
- package/dist/kits/blocks/components/sections/ServicesGrid.tsx +1 -1
- package/dist/kits/blocks/components/theme-provider.tsx +0 -33
- package/dist/kits/blocks/components/ui/theme-selector.tsx +0 -4
- package/dist/kits/blocks/lib/utils.ts +0 -3
- package/dist/kits/blocks/package-deps.json +40 -40
- package/dist/utils/installation-tracker.d.ts +2 -2
- package/dist/utils/installation-tracker.d.ts.map +1 -1
- package/dist/utils/installation-tracker.js +11 -11
- package/dist/utils/installation-tracker.js.map +1 -1
- package/dist/utils/package-manager.js +1 -1
- package/dist/utils/package-manager.js.map +1 -1
- package/package.json +2 -2
package/dist/commands/blocks.js
CHANGED
|
@@ -37,7 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.addBlocks = addBlocks;
|
|
40
|
-
// inquirer is ESM-only
|
|
40
|
+
// `inquirer` is ESM-only; load it via runtime `import()` for CJS builds and fall back if unavailable.
|
|
41
41
|
const file_operations_1 = require("../utils/file-operations");
|
|
42
42
|
const installation_tracker_1 = require("../utils/installation-tracker");
|
|
43
43
|
const package_manager_1 = require("../utils/package-manager");
|
|
@@ -53,7 +53,7 @@ async function addBlocks(options = {}) {
|
|
|
53
53
|
// Behavior:
|
|
54
54
|
// - No flags: install core + sections + templates by default.
|
|
55
55
|
// - --sections: install core + sections only.
|
|
56
|
-
// - --templates: install core + templates only.
|
|
56
|
+
// - --templates: install core + sections + templates only.
|
|
57
57
|
// - --sections --templates: core + sections + templates (same as default).
|
|
58
58
|
// - --ui-only: install core only (bare UI primitives, no sections/templates).
|
|
59
59
|
const explicitGroups = [];
|
|
@@ -61,6 +61,105 @@ async function addBlocks(options = {}) {
|
|
|
61
61
|
typeof options.templates === "boolean" ||
|
|
62
62
|
typeof options.gallery === "boolean" ||
|
|
63
63
|
typeof options.uiOnly === "boolean";
|
|
64
|
+
if (options.dryRun) {
|
|
65
|
+
// Dry-run: compute the same install plan as a real run, but don't write anything.
|
|
66
|
+
let groupsToInstall = [];
|
|
67
|
+
if (options.uiOnly) {
|
|
68
|
+
// uiOnly overrides other flags if set
|
|
69
|
+
console.log("Flag: --ui-only");
|
|
70
|
+
groupsToInstall = manifest.groups
|
|
71
|
+
? ["core"].filter((g) => g in manifest.groups)
|
|
72
|
+
: [];
|
|
73
|
+
}
|
|
74
|
+
else if (anyGroupFlag) {
|
|
75
|
+
if (options.sections)
|
|
76
|
+
explicitGroups.push("sections");
|
|
77
|
+
if (options.templates)
|
|
78
|
+
explicitGroups.push("sections", "templates");
|
|
79
|
+
if (options.gallery)
|
|
80
|
+
explicitGroups.push("sections", "gallery");
|
|
81
|
+
console.log("Flags: " + explicitGroups.join(", "));
|
|
82
|
+
groupsToInstall = manifest.groups
|
|
83
|
+
? ["core", ...explicitGroups].filter((g) => g in manifest.groups)
|
|
84
|
+
: [];
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
// Default: core + sections
|
|
88
|
+
console.log("No flags passed");
|
|
89
|
+
explicitGroups.push("sections");
|
|
90
|
+
groupsToInstall = manifest.groups
|
|
91
|
+
? ["core", ...explicitGroups].filter((g) => g in manifest.groups)
|
|
92
|
+
: [];
|
|
93
|
+
}
|
|
94
|
+
const files = groupsToInstall.length > 0 && manifest.groups
|
|
95
|
+
? groupsToInstall.flatMap((groupName) => {
|
|
96
|
+
const group = manifest.groups?.[groupName];
|
|
97
|
+
return group?.files ?? [];
|
|
98
|
+
})
|
|
99
|
+
: manifest.files || [];
|
|
100
|
+
const filesToCopy = [];
|
|
101
|
+
const missingFiles = [];
|
|
102
|
+
for (const file of files) {
|
|
103
|
+
const kitSource = path_1.default.join(kitDir, file);
|
|
104
|
+
if (await (0, file_operations_1.fileExists)(kitSource)) {
|
|
105
|
+
filesToCopy.push(file);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const projectSource = path_1.default.join(process.cwd(), file);
|
|
109
|
+
if (await (0, file_operations_1.fileExists)(projectSource)) {
|
|
110
|
+
console.log(`ℹ️ Skipping ${file} (already exists in project)`);
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
missingFiles.push(file);
|
|
114
|
+
}
|
|
115
|
+
console.log("Blocks kit - dry-run ...");
|
|
116
|
+
console.log("Files to be copied into project:");
|
|
117
|
+
filesToCopy.forEach((file) => console.log(file));
|
|
118
|
+
// Read kit dependencies (but do not write package.json).
|
|
119
|
+
const depsPath = path_1.default.join(kitDir, "package-deps.json");
|
|
120
|
+
try {
|
|
121
|
+
const deps = await (0, file_operations_1.readJsonFile)(depsPath);
|
|
122
|
+
console.log("Dependencies:");
|
|
123
|
+
console.log(deps);
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
console.log("⚠️ No package-deps.json found for blocks or failed to read it");
|
|
127
|
+
}
|
|
128
|
+
if (missingFiles.length > 0) {
|
|
129
|
+
console.log("\n⚠️ The following files referenced by the blocks manifest were not found in the kit:");
|
|
130
|
+
missingFiles.forEach((f) => console.log(` • ${f}`));
|
|
131
|
+
}
|
|
132
|
+
// Patching plan (no changes are made in dry-run).
|
|
133
|
+
const mode = await (0, file_operations_1.detectProjectRootMode)(process.cwd());
|
|
134
|
+
const detectedLayoutPath = mode === "src" ? "src/app/layout.tsx" : "app/layout.tsx";
|
|
135
|
+
const detectedPagesAppPath = mode === "src" ? "src/pages/_app.tsx" : "pages/_app.tsx";
|
|
136
|
+
const appRouterLayoutExists = await (0, file_operations_1.fileExists)(detectedLayoutPath);
|
|
137
|
+
const pagesRouterAppExists = await (0, file_operations_1.fileExists)(detectedPagesAppPath);
|
|
138
|
+
if (appRouterLayoutExists && pagesRouterAppExists) {
|
|
139
|
+
console.log(`Would patch ${detectedLayoutPath} (wrap with AppProviders)`);
|
|
140
|
+
console.log(`Would patch ${detectedPagesAppPath} (wrap with AppProviders)`);
|
|
141
|
+
console.log(`Would ensure ${mode === "src" ? "src/pages/_document.tsx" : "pages/_document.tsx"} includes suppressHydrationWarning`);
|
|
142
|
+
}
|
|
143
|
+
else if (appRouterLayoutExists) {
|
|
144
|
+
console.log(`Would patch ${detectedLayoutPath} (wrap with AppProviders)`);
|
|
145
|
+
}
|
|
146
|
+
else if (pagesRouterAppExists) {
|
|
147
|
+
console.log(`Would patch ${detectedPagesAppPath} (wrap with AppProviders)`);
|
|
148
|
+
console.log(`Would ensure ${mode === "src" ? "src/pages/_document.tsx" : "pages/_document.tsx"} includes suppressHydrationWarning`);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
console.log("ℹ️ No router entrypoints detected for patching (expected app/layout.tsx or pages/_app.tsx)");
|
|
152
|
+
}
|
|
153
|
+
// Where templates live (router-dependent; URLs are the same).
|
|
154
|
+
if (pagesRouterAppExists && !appRouterLayoutExists) {
|
|
155
|
+
console.log(` (Pages Router install: files live under ${mode === "src" ? "src/pages/templates/<template>/index.tsx" : "pages/templates/<template>/index.tsx"})`);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
console.log(` (App Router install: files live under ${mode === "src" ? "src/app/templates" : "app/templates"})`);
|
|
159
|
+
}
|
|
160
|
+
console.log("No changes were made.");
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
64
163
|
if (options.uiOnly) {
|
|
65
164
|
// uiOnly overrides other flags if set
|
|
66
165
|
const groupsToInstall = manifest.groups
|
|
@@ -119,15 +218,19 @@ async function addBlocks(options = {}) {
|
|
|
119
218
|
if (anyGroupFlag) {
|
|
120
219
|
if (options.sections)
|
|
121
220
|
explicitGroups.push("sections");
|
|
122
|
-
if (options.templates)
|
|
221
|
+
if (options.templates) {
|
|
222
|
+
explicitGroups.push("sections");
|
|
123
223
|
explicitGroups.push("templates");
|
|
124
|
-
|
|
224
|
+
}
|
|
225
|
+
if (options.gallery) {
|
|
226
|
+
explicitGroups.push("sections");
|
|
125
227
|
explicitGroups.push("gallery");
|
|
228
|
+
}
|
|
126
229
|
}
|
|
127
230
|
else {
|
|
128
231
|
// No flags passed: include sections and templates by default so templates
|
|
129
232
|
// always have their section dependencies available.
|
|
130
|
-
explicitGroups.push("sections"
|
|
233
|
+
explicitGroups.push("sections");
|
|
131
234
|
}
|
|
132
235
|
const groupsToInstall = manifest.groups
|
|
133
236
|
? ["core", ...explicitGroups].filter((g) => g in manifest.groups)
|
|
@@ -204,8 +307,8 @@ async function addBlocks(options = {}) {
|
|
|
204
307
|
}
|
|
205
308
|
const appRouterLayoutExists = await (0, file_operations_1.fileExists)(detectedLayoutPath);
|
|
206
309
|
const pagesRouterAppExists = await (0, file_operations_1.fileExists)(detectedPagesAppPath);
|
|
207
|
-
// Hybrid projects
|
|
208
|
-
// In that case
|
|
310
|
+
// Hybrid projects may have both /app and /pages.
|
|
311
|
+
// In that case patch BOTH entrypoints so routes in either router
|
|
209
312
|
// are wrapped with providers.
|
|
210
313
|
if (appRouterLayoutExists && pagesRouterAppExists) {
|
|
211
314
|
try {
|
|
@@ -288,7 +391,7 @@ async function addBlocks(options = {}) {
|
|
|
288
391
|
// Make app-providers.tsx point at the Pages-safe implementation.
|
|
289
392
|
// (The kit defaults to App Router; Pages Router can't import @nextworks/blocks-core/server.)
|
|
290
393
|
//
|
|
291
|
-
// Patch whichever path exists
|
|
394
|
+
// Patch whichever path exists.
|
|
292
395
|
const candidateAppProvidersPaths = [
|
|
293
396
|
"components/app-providers.tsx",
|
|
294
397
|
"src/components/app-providers.tsx",
|
|
@@ -321,7 +424,7 @@ async function addBlocks(options = {}) {
|
|
|
321
424
|
// Make app-providers.tsx point at the Pages-safe implementation.
|
|
322
425
|
// (The kit defaults to App Router; Pages Router can't import @nextworks/blocks-core/server.)
|
|
323
426
|
//
|
|
324
|
-
// Patch whichever path exists
|
|
427
|
+
// Patch whichever path exists.
|
|
325
428
|
const candidateAppProvidersPaths = [
|
|
326
429
|
"components/app-providers.tsx",
|
|
327
430
|
"src/components/app-providers.tsx",
|
|
@@ -384,4 +487,428 @@ async function addBlocks(options = {}) {
|
|
|
384
487
|
throw error;
|
|
385
488
|
}
|
|
386
489
|
}
|
|
490
|
+
// export async function dryRunAddBlocks(
|
|
491
|
+
// options: AddBlocksOptions = {},
|
|
492
|
+
// ): Promise<void> {
|
|
493
|
+
// // - This should do whatever addBlocks does EXCEPT actually copying files.
|
|
494
|
+
// console.log("Dry-run blocks kit...");
|
|
495
|
+
// try {
|
|
496
|
+
// const kitDir = resolveAssetPath("kits", "blocks");
|
|
497
|
+
// const manifestPath = resolveAssetPath(
|
|
498
|
+
// "cli_manifests",
|
|
499
|
+
// "blocks_manifest.json",
|
|
500
|
+
// );
|
|
501
|
+
// const manifest = (await readJsonFile(manifestPath)) as BlocksManifest;
|
|
502
|
+
// // Decide which groups to install.
|
|
503
|
+
// // Core is always included to satisfy the contract that sections/templates rely on core.
|
|
504
|
+
// // Behavior:
|
|
505
|
+
// // - No flags: install core + sections + templates by default.
|
|
506
|
+
// // - --sections: install core + sections only.
|
|
507
|
+
// // - --templates: install core + templates only.
|
|
508
|
+
// // - --sections --templates: core + sections + templates (same as default).
|
|
509
|
+
// // - --ui-only: install core only (bare UI primitives, no sections/templates).
|
|
510
|
+
// const explicitGroups: string[] = [];
|
|
511
|
+
// const anyGroupFlag =
|
|
512
|
+
// typeof options.sections === "boolean" ||
|
|
513
|
+
// typeof options.templates === "boolean" ||
|
|
514
|
+
// typeof options.gallery === "boolean" ||
|
|
515
|
+
// typeof options.uiOnly === "boolean";
|
|
516
|
+
// if (options.uiOnly) {
|
|
517
|
+
// // uiOnly overrides other flags if set
|
|
518
|
+
// const groupsToInstall: string[] = manifest.groups
|
|
519
|
+
// ? ["core"].filter((g) => g in manifest.groups!)
|
|
520
|
+
// : [];
|
|
521
|
+
// const files: string[] =
|
|
522
|
+
// groupsToInstall.length > 0 && manifest.groups
|
|
523
|
+
// ? groupsToInstall.flatMap((groupName) => {
|
|
524
|
+
// const group = manifest.groups?.[groupName];
|
|
525
|
+
// return group?.files ?? [];
|
|
526
|
+
// })
|
|
527
|
+
// : manifest.files || [];
|
|
528
|
+
// const filesToCopy: string[] = [];
|
|
529
|
+
// const missingFiles: string[] = [];
|
|
530
|
+
// for (const file of files) {
|
|
531
|
+
// const kitSource = path.join(kitDir, file);
|
|
532
|
+
// if (await fileExists(kitSource)) {
|
|
533
|
+
// filesToCopy.push(file);
|
|
534
|
+
// } else {
|
|
535
|
+
// const projectSource = path.join(process.cwd(), file);
|
|
536
|
+
// if (await fileExists(projectSource)) {
|
|
537
|
+
// console.log(`ℹ️ Skipping ${file} (already exists in project)`);
|
|
538
|
+
// } else {
|
|
539
|
+
// missingFiles.push(file);
|
|
540
|
+
// }
|
|
541
|
+
// }
|
|
542
|
+
// }
|
|
543
|
+
// // - Logging filesToCopy
|
|
544
|
+
// console.log("Blocks kit dry-run ...");
|
|
545
|
+
// console.log("Files to be copied into project:");
|
|
546
|
+
// filesToCopy.map((file) => {
|
|
547
|
+
// console.log(file);
|
|
548
|
+
// });
|
|
549
|
+
// // if (filesToCopy.length > 0) {
|
|
550
|
+
// // await copyFiles(kitDir, process.cwd(), filesToCopy);
|
|
551
|
+
// // } else {
|
|
552
|
+
// // console.log(
|
|
553
|
+
// // "⚠️ No files to copy from the blocks kit (all files missing or already present)",
|
|
554
|
+
// // );
|
|
555
|
+
// // }
|
|
556
|
+
// // -
|
|
557
|
+
// // Update package.json and track install as usual
|
|
558
|
+
// const depsPath = path.join(kitDir, "package-deps.json");
|
|
559
|
+
// let deps: any = {};
|
|
560
|
+
// try {
|
|
561
|
+
// deps = await readJsonFile(depsPath);
|
|
562
|
+
// // - For now, I simply console.log the deps object, which is not the final thing,
|
|
563
|
+
// // - as user might already have some of the dependencies installed.
|
|
564
|
+
// // - Go into file-operations, see exactly
|
|
565
|
+
// // - what happens in updatePackageJson right before it writes so package.json
|
|
566
|
+
// // - Dry-run log dependencies
|
|
567
|
+
// console.log("Dependencies of the blocks kit:");
|
|
568
|
+
// console.log(deps);
|
|
569
|
+
// // await updatePackageJson(deps, {
|
|
570
|
+
// // pm: options.pm ?? (await detectPackageManager(process.cwd())),
|
|
571
|
+
// // });
|
|
572
|
+
// } catch (err) {
|
|
573
|
+
// console.log(
|
|
574
|
+
// "⚠️ No package-deps.json found for blocks or failed to read it",
|
|
575
|
+
// );
|
|
576
|
+
// }
|
|
577
|
+
// // await addInstalledKit(
|
|
578
|
+
// // "blocks",
|
|
579
|
+
// // Object.keys(deps.dependencies || {}),
|
|
580
|
+
// // Object.keys(deps.devDependencies || {}),
|
|
581
|
+
// // filesToCopy,
|
|
582
|
+
// // );
|
|
583
|
+
// // console.log(
|
|
584
|
+
// // "✓ blocks core UI primitives installed successfully (ui-only mode)!",
|
|
585
|
+
// // );
|
|
586
|
+
// // if (missingFiles.length > 0) {
|
|
587
|
+
// // console.log(
|
|
588
|
+
// // "\n⚠️ The following files referenced by the blocks manifest were not found in the kit and were not copied:",
|
|
589
|
+
// // );
|
|
590
|
+
// // missingFiles.forEach((f) => console.log(` • ${f}`));
|
|
591
|
+
// // console.log(
|
|
592
|
+
// // "You may need to copy these files manually (for example placeholder assets under public/placeholders) or reconcile the kit files.",
|
|
593
|
+
// // );
|
|
594
|
+
// // }
|
|
595
|
+
// return;
|
|
596
|
+
// }
|
|
597
|
+
// if (anyGroupFlag) {
|
|
598
|
+
// if (options.sections) explicitGroups.push("sections");
|
|
599
|
+
// if (options.templates) explicitGroups.push("templates");
|
|
600
|
+
// if (options.gallery) explicitGroups.push("gallery");
|
|
601
|
+
// } else {
|
|
602
|
+
// // No flags passed: include sections and templates by default so templates
|
|
603
|
+
// // always have their section dependencies available.
|
|
604
|
+
// explicitGroups.push("sections", "templates");
|
|
605
|
+
// }
|
|
606
|
+
// const groupsToInstall: string[] = manifest.groups
|
|
607
|
+
// ? ["core", ...explicitGroups].filter((g) => g in manifest.groups!)
|
|
608
|
+
// : [];
|
|
609
|
+
// const files: string[] =
|
|
610
|
+
// groupsToInstall.length > 0 && manifest.groups
|
|
611
|
+
// ? groupsToInstall.flatMap((groupName) => {
|
|
612
|
+
// const group = manifest.groups?.[groupName];
|
|
613
|
+
// return group?.files ?? [];
|
|
614
|
+
// })
|
|
615
|
+
// : manifest.files || [];
|
|
616
|
+
// const filesToCopy: string[] = [];
|
|
617
|
+
// const missingFiles: string[] = [];
|
|
618
|
+
// // Determine which files are present in the kit and which are missing
|
|
619
|
+
// for (const file of files) {
|
|
620
|
+
// const kitSource = path.join(kitDir, file);
|
|
621
|
+
// // If the file exists in the kit, schedule it for copy
|
|
622
|
+
// if (await fileExists(kitSource)) {
|
|
623
|
+
// filesToCopy.push(file);
|
|
624
|
+
// } else {
|
|
625
|
+
// // If the file is already present in the user's project root, skip copying
|
|
626
|
+
// const projectSource = path.join(process.cwd(), file);
|
|
627
|
+
// if (await fileExists(projectSource)) {
|
|
628
|
+
// console.log(`ℹ️ Skipping ${file} (already exists in project)`);
|
|
629
|
+
// } else {
|
|
630
|
+
// missingFiles.push(file);
|
|
631
|
+
// }
|
|
632
|
+
// }
|
|
633
|
+
// }
|
|
634
|
+
// // - Logging filesToCopy
|
|
635
|
+
// console.log("Blocks kit dry-run ...");
|
|
636
|
+
// console.log("Files to be copied into project:");
|
|
637
|
+
// filesToCopy.map((file) => {
|
|
638
|
+
// console.log(file);
|
|
639
|
+
// });
|
|
640
|
+
// // Copy available files
|
|
641
|
+
// // if (filesToCopy.length > 0) {
|
|
642
|
+
// // await copyFiles(kitDir, process.cwd(), filesToCopy);
|
|
643
|
+
// // } else {
|
|
644
|
+
// // console.log(
|
|
645
|
+
// // "⚠️ No files to copy from the blocks kit (all files missing or already present)",
|
|
646
|
+
// // );
|
|
647
|
+
// // }
|
|
648
|
+
// // Update package.json with dependencies from the kit
|
|
649
|
+
// const depsPath = path.join(kitDir, "package-deps.json");
|
|
650
|
+
// let deps: any = {};
|
|
651
|
+
// try {
|
|
652
|
+
// deps = await readJsonFile(depsPath);
|
|
653
|
+
// // - Dry-run log dependencies
|
|
654
|
+
// console.log("Dependencies of the blocks kit:");
|
|
655
|
+
// console.log(deps);
|
|
656
|
+
// // await updatePackageJson(deps, {
|
|
657
|
+
// // pm: options.pm ?? (await detectPackageManager(process.cwd())),
|
|
658
|
+
// // });
|
|
659
|
+
// } catch (err) {
|
|
660
|
+
// console.log(
|
|
661
|
+
// "⚠️ No package-deps.json found for blocks or failed to read it",
|
|
662
|
+
// );
|
|
663
|
+
// }
|
|
664
|
+
// // Track the installation
|
|
665
|
+
// // await addInstalledKit(
|
|
666
|
+
// // "blocks",
|
|
667
|
+
// // Object.keys(deps.dependencies || {}),
|
|
668
|
+
// // Object.keys(deps.devDependencies || {}),
|
|
669
|
+
// // filesToCopy,
|
|
670
|
+
// // );
|
|
671
|
+
// // console.log("✓ blocks kit installed successfully!");
|
|
672
|
+
// // - ------------------------------------------------------------
|
|
673
|
+
// // - Dry-run log patching of layout.tsx / _app.tsx:
|
|
674
|
+
// // let layoutUpgraded = false;
|
|
675
|
+
// // let pagesAppUpgraded = false;
|
|
676
|
+
// // Offer to auto-upgrade the root layout to use AppProviders (App Router)
|
|
677
|
+
// // (supports both root app/layout.tsx and src/app/layout.tsx)
|
|
678
|
+
// // const mode = await detectProjectRootMode(process.cwd());
|
|
679
|
+
// // const detectedLayoutPath =
|
|
680
|
+
// // mode === "src" ? "src/app/layout.tsx" : "app/layout.tsx";
|
|
681
|
+
// // const detectedPagesAppPath =
|
|
682
|
+
// // mode === "src" ? "src/pages/_app.tsx" : "pages/_app.tsx";
|
|
683
|
+
// // Dynamically load inquirer to avoid ESM/CJS interop issues when
|
|
684
|
+
// // the CLI is compiled to CommonJS but inquirer is ESM-only.
|
|
685
|
+
// // let promptFn: any;
|
|
686
|
+
// // try {
|
|
687
|
+
// // // Use a runtime dynamic import via the Function constructor to ensure
|
|
688
|
+
// // // we call the native import() at runtime and avoid TypeScript
|
|
689
|
+
// // // transpilation turning this into a require() call.
|
|
690
|
+
// // const inquirerModule = await new Function('return import("inquirer")')();
|
|
691
|
+
// // // inquirer exports a default object with prompt; support both shapes
|
|
692
|
+
// // promptFn = inquirerModule?.default?.prompt ?? inquirerModule?.prompt;
|
|
693
|
+
// // } catch (err) {
|
|
694
|
+
// // console.log(
|
|
695
|
+
// // "⚠️ Could not load optional interactive prompt (inquirer). Skipping optional prompts.",
|
|
696
|
+
// // );
|
|
697
|
+
// // promptFn = null;
|
|
698
|
+
// // }
|
|
699
|
+
// // const appRouterLayoutExists = await fileExists(detectedLayoutPath);
|
|
700
|
+
// // const pagesRouterAppExists = await fileExists(detectedPagesAppPath);
|
|
701
|
+
// // Hybrid projects may have both /app and /pages.
|
|
702
|
+
// // In that case patch BOTH entrypoints so routes in either router
|
|
703
|
+
// // are wrapped with providers.
|
|
704
|
+
// // if (appRouterLayoutExists && pagesRouterAppExists) {
|
|
705
|
+
// // try {
|
|
706
|
+
// // await updateLayoutWithAppProviders();
|
|
707
|
+
// // layoutUpgraded = true;
|
|
708
|
+
// // } catch (err) {
|
|
709
|
+
// // console.log("⚠️ Failed to update app/layout.tsx automatically:", err);
|
|
710
|
+
// // }
|
|
711
|
+
// // try {
|
|
712
|
+
// // await updatePagesAppWithAppProviders();
|
|
713
|
+
// // await ensurePagesDocumentSuppressHydrationWarning();
|
|
714
|
+
// // // Ensure pages/_app.tsx uses the Pages-safe AppProviders implementation.
|
|
715
|
+
// // const candidatePagesAppProvidersPaths = [
|
|
716
|
+
// // "components/app-providers.pages.tsx",
|
|
717
|
+
// // "src/components/app-providers.pages.tsx",
|
|
718
|
+
// // ];
|
|
719
|
+
// // for (const appProvidersPath of candidatePagesAppProvidersPaths) {
|
|
720
|
+
// // if (await fileExists(appProvidersPath)) {
|
|
721
|
+
// // const fsExtraModule = await import("fs-extra");
|
|
722
|
+
// // await fsExtraModule.default.writeFile(
|
|
723
|
+
// // appProvidersPath,
|
|
724
|
+
// // '"use client";\n\nimport * as React from "react";\n\nimport { BlocksAppProviders } from "./providers/BlocksAppProviders";\n\nexport default function AppProviders({ children }: { children: React.ReactNode }) {\n return (\n <div className="antialiased">\n <BlocksAppProviders>{children}</BlocksAppProviders>\n </div>\n );\n}\n',
|
|
725
|
+
// // );
|
|
726
|
+
// // }
|
|
727
|
+
// // }
|
|
728
|
+
// // // Ensure root components/app-providers.tsx points to the App Router variant
|
|
729
|
+
// // // so app/layout.tsx imports the correct implementation.
|
|
730
|
+
// // const candidateRootAppProvidersPaths = [
|
|
731
|
+
// // "components/app-providers.tsx",
|
|
732
|
+
// // "src/components/app-providers.tsx",
|
|
733
|
+
// // ];
|
|
734
|
+
// // for (const appProvidersPath of candidateRootAppProvidersPaths) {
|
|
735
|
+
// // if (await fileExists(appProvidersPath)) {
|
|
736
|
+
// // const fsExtraModule = await import("fs-extra");
|
|
737
|
+
// // await fsExtraModule.default.writeFile(
|
|
738
|
+
// // appProvidersPath,
|
|
739
|
+
// // 'export { default } from "./app-providers.app";\n',
|
|
740
|
+
// // );
|
|
741
|
+
// // }
|
|
742
|
+
// // }
|
|
743
|
+
// // pagesAppUpgraded = true;
|
|
744
|
+
// // } catch (err) {
|
|
745
|
+
// // console.log("⚠️ Failed to update pages/_app.tsx automatically:", err);
|
|
746
|
+
// // }
|
|
747
|
+
// // } else if (appRouterLayoutExists) {
|
|
748
|
+
// // if (options.yes) {
|
|
749
|
+
// // try {
|
|
750
|
+
// // await updateLayoutWithAppProviders();
|
|
751
|
+
// // layoutUpgraded = true;
|
|
752
|
+
// // } catch (err) {
|
|
753
|
+
// // console.log(
|
|
754
|
+
// // "⚠️ Failed to update app/layout.tsx automatically:",
|
|
755
|
+
// // err,
|
|
756
|
+
// // );
|
|
757
|
+
// // }
|
|
758
|
+
// // } else if (promptFn) {
|
|
759
|
+
// // const { upgradeLayout } = await promptFn([
|
|
760
|
+
// // {
|
|
761
|
+
// // type: "confirm",
|
|
762
|
+
// // name: "upgradeLayout",
|
|
763
|
+
// // message: `Would you like the CLI to automatically wrap your ${detectedLayoutPath} with AppProviders and add suppressHydrationWarning to the <html> tag?`,
|
|
764
|
+
// // default: true,
|
|
765
|
+
// // },
|
|
766
|
+
// // ]);
|
|
767
|
+
// // if (upgradeLayout) {
|
|
768
|
+
// // try {
|
|
769
|
+
// // await updateLayoutWithAppProviders();
|
|
770
|
+
// // layoutUpgraded = true;
|
|
771
|
+
// // } catch (err) {
|
|
772
|
+
// // console.log(
|
|
773
|
+
// // "⚠️ Failed to update app/layout.tsx automatically:",
|
|
774
|
+
// // err,
|
|
775
|
+
// // );
|
|
776
|
+
// // }
|
|
777
|
+
// // }
|
|
778
|
+
// // }
|
|
779
|
+
// // } else if (await fileExists(detectedPagesAppPath)) {
|
|
780
|
+
// // // Pages Router support:
|
|
781
|
+
// // // - patch pages/_app.tsx (+ ensure _document.tsx hydration safety)
|
|
782
|
+
// // // - switch the kit-provided app-providers entrypoint to the Pages-safe variant
|
|
783
|
+
// // if (options.yes) {
|
|
784
|
+
// // try {
|
|
785
|
+
// // await updatePagesAppWithAppProviders();
|
|
786
|
+
// // await ensurePagesDocumentSuppressHydrationWarning();
|
|
787
|
+
// // // Make app-providers.tsx point at the Pages-safe implementation.
|
|
788
|
+
// // // (The kit defaults to App Router; Pages Router can't import @nextworks/blocks-core/server.)
|
|
789
|
+
// // //
|
|
790
|
+
// // // Patch whichever path exists.
|
|
791
|
+
// // const candidateAppProvidersPaths = [
|
|
792
|
+
// // "components/app-providers.tsx",
|
|
793
|
+
// // "src/components/app-providers.tsx",
|
|
794
|
+
// // ];
|
|
795
|
+
// // for (const appProvidersPath of candidateAppProvidersPaths) {
|
|
796
|
+
// // if (await fileExists(appProvidersPath)) {
|
|
797
|
+
// // const fsExtraModule = await import("fs-extra");
|
|
798
|
+
// // await fsExtraModule.default.writeFile(
|
|
799
|
+
// // appProvidersPath,
|
|
800
|
+
// // 'export { default } from "./app-providers.pages";\n',
|
|
801
|
+
// // );
|
|
802
|
+
// // }
|
|
803
|
+
// // }
|
|
804
|
+
// // pagesAppUpgraded = true;
|
|
805
|
+
// // } catch (err) {
|
|
806
|
+
// // console.log(
|
|
807
|
+
// // "⚠️ Failed to update pages/_app.tsx automatically:",
|
|
808
|
+
// // err,
|
|
809
|
+
// // );
|
|
810
|
+
// // }
|
|
811
|
+
// // } else if (promptFn) {
|
|
812
|
+
// // const { upgradePagesApp } = await promptFn([
|
|
813
|
+
// // {
|
|
814
|
+
// // type: "confirm",
|
|
815
|
+
// // name: "upgradePagesApp",
|
|
816
|
+
// // message: `Would you like the CLI to automatically wrap your ${detectedPagesAppPath} with AppProviders (and ensure suppressHydrationWarning in pages/_document.tsx)?`,
|
|
817
|
+
// // default: true,
|
|
818
|
+
// // },
|
|
819
|
+
// // ]);
|
|
820
|
+
// // if (upgradePagesApp) {
|
|
821
|
+
// // try {
|
|
822
|
+
// // await updatePagesAppWithAppProviders();
|
|
823
|
+
// // await ensurePagesDocumentSuppressHydrationWarning();
|
|
824
|
+
// // // Make app-providers.tsx point at the Pages-safe implementation.
|
|
825
|
+
// // // (The kit defaults to App Router; Pages Router can't import @nextworks/blocks-core/server.)
|
|
826
|
+
// // //
|
|
827
|
+
// // // Patch whichever path exists.
|
|
828
|
+
// // const candidateAppProvidersPaths = [
|
|
829
|
+
// // "components/app-providers.tsx",
|
|
830
|
+
// // "src/components/app-providers.tsx",
|
|
831
|
+
// // ];
|
|
832
|
+
// // for (const appProvidersPath of candidateAppProvidersPaths) {
|
|
833
|
+
// // if (await fileExists(appProvidersPath)) {
|
|
834
|
+
// // const fsExtraModule = await import("fs-extra");
|
|
835
|
+
// // await fsExtraModule.default.writeFile(
|
|
836
|
+
// // appProvidersPath,
|
|
837
|
+
// // 'export { default } from "./app-providers.pages";\n',
|
|
838
|
+
// // );
|
|
839
|
+
// // }
|
|
840
|
+
// // }
|
|
841
|
+
// // pagesAppUpgraded = true;
|
|
842
|
+
// // } catch (err) {
|
|
843
|
+
// // console.log(
|
|
844
|
+
// // "⚠️ Failed to update pages/_app.tsx automatically:",
|
|
845
|
+
// // err,
|
|
846
|
+
// // );
|
|
847
|
+
// // }
|
|
848
|
+
// // }
|
|
849
|
+
// // }
|
|
850
|
+
// // }
|
|
851
|
+
// // console.log("\n📋 Next steps:");
|
|
852
|
+
// // console.log("- Templates added. Try these routes in your browser:");
|
|
853
|
+
// // console.log(" /templates/productlaunch");
|
|
854
|
+
// // console.log(" /templates/saasdashboard");
|
|
855
|
+
// // console.log(" /templates/digitalagency");
|
|
856
|
+
// // console.log(" /templates/gallery (blocks gallery)");
|
|
857
|
+
// // - The dry-run should log WHERE files are installed depending on router type ...
|
|
858
|
+
// // Note: depending on router type, the templates are installed into different folders,
|
|
859
|
+
// // but the URLs are the same.
|
|
860
|
+
// // if (pagesRouterAppExists && !appRouterLayoutExists) {
|
|
861
|
+
// // console.log(
|
|
862
|
+
// // ` (Pages Router install: files live under ${mode === "src" ? "src/pages/templates/<template>/index.tsx" : "pages/templates/<template>/index.tsx"})`,
|
|
863
|
+
// // );
|
|
864
|
+
// // } else {
|
|
865
|
+
// // console.log(
|
|
866
|
+
// // ` (App Router install: files live under ${mode === "src" ? "src/app/templates" : "app/templates"})`,
|
|
867
|
+
// // );
|
|
868
|
+
// // }
|
|
869
|
+
// // const pm = options.pm ?? (await detectPackageManager(process.cwd()));
|
|
870
|
+
// // const installCmd = getInstallCommand(pm);
|
|
871
|
+
// // if (layoutUpgraded) {
|
|
872
|
+
// // console.log(
|
|
873
|
+
// // `1. ${detectedLayoutPath} was updated to wrap the app with AppProviders and add suppressHydrationWarning.`,
|
|
874
|
+
// // );
|
|
875
|
+
// // console.log(
|
|
876
|
+
// // "2. Ensure Tailwind is configured and app/globals.css is present (copied if available).",
|
|
877
|
+
// // );
|
|
878
|
+
// // console.log(`3. Install new dependencies: ${installCmd}`);
|
|
879
|
+
// // } else if (pagesAppUpgraded) {
|
|
880
|
+
// // console.log(
|
|
881
|
+
// // `1. ${detectedPagesAppPath} was updated to wrap the app with AppProviders (and fonts).`,
|
|
882
|
+
// // );
|
|
883
|
+
// // console.log(
|
|
884
|
+
// // "2. pages/_document.tsx was ensured/updated to include suppressHydrationWarning.",
|
|
885
|
+
// // );
|
|
886
|
+
// // console.log(`3. Install new dependencies: ${installCmd}`);
|
|
887
|
+
// // } else {
|
|
888
|
+
// // console.log(
|
|
889
|
+
// // `1. Wrap your app with the AppProviders wrapper in ${detectedLayoutPath} (App Router) or ${detectedPagesAppPath} (Pages Router):`,
|
|
890
|
+
// // );
|
|
891
|
+
// // console.log(' import AppProviders from "@/components/app-providers";');
|
|
892
|
+
// // console.log(
|
|
893
|
+
// // " Wrap your application with <AppProviders> to enable fonts, presets, CSS variable injection, session provider, and the app toaster.",
|
|
894
|
+
// // );
|
|
895
|
+
// // console.log(
|
|
896
|
+
// // "2. Ensure Tailwind is configured and app/globals.css is present (copied if available).",
|
|
897
|
+
// // );
|
|
898
|
+
// // console.log(`3. Install new dependencies: ${installCmd}`);
|
|
899
|
+
// // }
|
|
900
|
+
// if (missingFiles.length > 0) {
|
|
901
|
+
// console.log(
|
|
902
|
+
// "\n⚠️ The following files referenced by the blocks manifest were not found in the kit and were not copied:",
|
|
903
|
+
// );
|
|
904
|
+
// missingFiles.forEach((f) => console.log(` • ${f}`));
|
|
905
|
+
// console.log(
|
|
906
|
+
// "You may need to copy these files manually (for example placeholder assets under public/placeholders) or reconcile the kit files.",
|
|
907
|
+
// );
|
|
908
|
+
// }
|
|
909
|
+
// } catch (error) {
|
|
910
|
+
// console.log("❌ Failed to install blocks kit");
|
|
911
|
+
// throw error;
|
|
912
|
+
// }
|
|
913
|
+
// }
|
|
387
914
|
//# sourceMappingURL=blocks.js.map
|