@nextsparkjs/cli 0.1.0-beta.69 → 0.1.0-beta.70
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/bin/nextspark.js
CHANGED
|
File without changes
|
|
@@ -158,60 +158,21 @@ function validateTheme(packageJson, extractedPath) {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
// src/lib/installer.ts
|
|
161
|
-
import { existsSync as
|
|
162
|
-
import { join as
|
|
161
|
+
import { existsSync as existsSync4, cpSync, rmSync as rmSync2, mkdirSync, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "fs";
|
|
162
|
+
import { join as join4 } from "path";
|
|
163
163
|
import chalk from "chalk";
|
|
164
164
|
|
|
165
|
-
// src/lib/package-manager.ts
|
|
166
|
-
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
167
|
-
import { join as join3 } from "path";
|
|
168
|
-
import { execSync as execSync2 } from "child_process";
|
|
169
|
-
function detectPackageManager() {
|
|
170
|
-
const cwd = process.cwd();
|
|
171
|
-
if (existsSync3(join3(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
172
|
-
if (existsSync3(join3(cwd, "yarn.lock"))) return "yarn";
|
|
173
|
-
if (existsSync3(join3(cwd, "package-lock.json"))) return "npm";
|
|
174
|
-
const pkgPath = join3(cwd, "package.json");
|
|
175
|
-
if (existsSync3(pkgPath)) {
|
|
176
|
-
try {
|
|
177
|
-
const pkg = JSON.parse(readFileSync3(pkgPath, "utf-8"));
|
|
178
|
-
if (pkg.packageManager) {
|
|
179
|
-
if (pkg.packageManager.startsWith("pnpm")) return "pnpm";
|
|
180
|
-
if (pkg.packageManager.startsWith("yarn")) return "yarn";
|
|
181
|
-
}
|
|
182
|
-
} catch {
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return "npm";
|
|
186
|
-
}
|
|
187
|
-
function getInstallCommand(pm, deps) {
|
|
188
|
-
const depsStr = deps.join(" ");
|
|
189
|
-
switch (pm) {
|
|
190
|
-
case "pnpm":
|
|
191
|
-
return `pnpm add ${depsStr}`;
|
|
192
|
-
case "yarn":
|
|
193
|
-
return `yarn add ${depsStr}`;
|
|
194
|
-
default:
|
|
195
|
-
return `npm install ${depsStr}`;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
async function runInstall(pm, deps) {
|
|
199
|
-
if (deps.length === 0) return;
|
|
200
|
-
const command = getInstallCommand(pm, deps);
|
|
201
|
-
execSync2(command, { stdio: "inherit", cwd: process.cwd() });
|
|
202
|
-
}
|
|
203
|
-
|
|
204
165
|
// src/lib/config-updater.ts
|
|
205
|
-
import { existsSync as
|
|
206
|
-
import { join as
|
|
166
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3, writeFileSync } from "fs";
|
|
167
|
+
import { join as join3 } from "path";
|
|
207
168
|
async function updateTsConfig(name, type) {
|
|
208
|
-
const tsconfigPath =
|
|
209
|
-
if (!
|
|
169
|
+
const tsconfigPath = join3(process.cwd(), "tsconfig.json");
|
|
170
|
+
if (!existsSync3(tsconfigPath)) {
|
|
210
171
|
console.log(" Warning: tsconfig.json not found, skipping path update");
|
|
211
172
|
return;
|
|
212
173
|
}
|
|
213
174
|
try {
|
|
214
|
-
const content =
|
|
175
|
+
const content = readFileSync3(tsconfigPath, "utf-8");
|
|
215
176
|
const tsconfig = JSON.parse(content);
|
|
216
177
|
if (!tsconfig.compilerOptions) {
|
|
217
178
|
tsconfig.compilerOptions = {};
|
|
@@ -231,13 +192,13 @@ async function updateTsConfig(name, type) {
|
|
|
231
192
|
}
|
|
232
193
|
}
|
|
233
194
|
async function registerInPackageJson(npmName, version, type) {
|
|
234
|
-
const pkgPath =
|
|
235
|
-
if (!
|
|
195
|
+
const pkgPath = join3(process.cwd(), "package.json");
|
|
196
|
+
if (!existsSync3(pkgPath)) {
|
|
236
197
|
console.log(" Warning: package.json not found, skipping registration");
|
|
237
198
|
return;
|
|
238
199
|
}
|
|
239
200
|
try {
|
|
240
|
-
const content =
|
|
201
|
+
const content = readFileSync3(pkgPath, "utf-8");
|
|
241
202
|
const pkg = JSON.parse(content);
|
|
242
203
|
if (!pkg.nextspark) {
|
|
243
204
|
pkg.nextspark = {};
|
|
@@ -265,7 +226,7 @@ async function registerInPackageJson(npmName, version, type) {
|
|
|
265
226
|
// src/lib/installer.ts
|
|
266
227
|
async function installPlugin(extractedPath, packageJson, options = {}) {
|
|
267
228
|
const pluginName = extractPluginName(packageJson.name);
|
|
268
|
-
const targetDir =
|
|
229
|
+
const targetDir = join4(process.cwd(), "contents", "plugins", pluginName);
|
|
269
230
|
if (options.dryRun) {
|
|
270
231
|
console.log(chalk.cyan("\n [Dry Run] Would perform:"));
|
|
271
232
|
console.log(` - Copy to: contents/plugins/${pluginName}/`);
|
|
@@ -276,7 +237,7 @@ async function installPlugin(extractedPath, packageJson, options = {}) {
|
|
|
276
237
|
console.log(` - Register in package.json`);
|
|
277
238
|
return { success: true, installedPath: targetDir, name: pluginName };
|
|
278
239
|
}
|
|
279
|
-
if (
|
|
240
|
+
if (existsSync4(targetDir)) {
|
|
280
241
|
if (!options.force) {
|
|
281
242
|
throw new Error(
|
|
282
243
|
`Plugin "${pluginName}" already exists at ${targetDir}.
|
|
@@ -286,24 +247,20 @@ Use --force to overwrite.`
|
|
|
286
247
|
console.log(chalk.yellow(` Removing existing plugin...`));
|
|
287
248
|
rmSync2(targetDir, { recursive: true, force: true });
|
|
288
249
|
}
|
|
289
|
-
const pluginsDir =
|
|
290
|
-
if (!
|
|
250
|
+
const pluginsDir = join4(process.cwd(), "contents", "plugins");
|
|
251
|
+
if (!existsSync4(pluginsDir)) {
|
|
291
252
|
mkdirSync(pluginsDir, { recursive: true });
|
|
292
253
|
}
|
|
293
254
|
console.log(` Copying to contents/plugins/${pluginName}/...`);
|
|
294
255
|
cpSync(extractedPath, targetDir, { recursive: true });
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
console.log(` Installing ${depNames.length} dependencies...`);
|
|
300
|
-
const pm = detectPackageManager();
|
|
301
|
-
const depsWithVersions = Object.entries(deps).map(([name, version]) => `${name}@${version}`);
|
|
302
|
-
await runInstall(pm, depsWithVersions);
|
|
303
|
-
}
|
|
256
|
+
const deps = packageJson.dependencies || {};
|
|
257
|
+
const depCount = Object.keys(deps).length;
|
|
258
|
+
if (depCount > 0) {
|
|
259
|
+
console.log(` Plugin has ${depCount} dependencies (will be installed via workspace)`);
|
|
304
260
|
}
|
|
305
261
|
await updateTsConfig(pluginName, "plugin");
|
|
306
262
|
await registerInPackageJson(packageJson.name, packageJson.version || "0.0.0", "plugin");
|
|
263
|
+
await registerPluginInThemeConfig(pluginName);
|
|
307
264
|
return {
|
|
308
265
|
success: true,
|
|
309
266
|
installedPath: targetDir,
|
|
@@ -312,7 +269,7 @@ Use --force to overwrite.`
|
|
|
312
269
|
}
|
|
313
270
|
async function installTheme(extractedPath, packageJson, options = {}) {
|
|
314
271
|
const themeName = extractThemeName(packageJson.name);
|
|
315
|
-
const targetDir =
|
|
272
|
+
const targetDir = join4(process.cwd(), "contents", "themes", themeName);
|
|
316
273
|
if (options.dryRun) {
|
|
317
274
|
console.log(chalk.cyan("\n [Dry Run] Would perform:"));
|
|
318
275
|
console.log(` - Copy to: contents/themes/${themeName}/`);
|
|
@@ -323,7 +280,7 @@ async function installTheme(extractedPath, packageJson, options = {}) {
|
|
|
323
280
|
console.log(` - Register in package.json`);
|
|
324
281
|
return { success: true, installedPath: targetDir, name: themeName };
|
|
325
282
|
}
|
|
326
|
-
if (
|
|
283
|
+
if (existsSync4(targetDir)) {
|
|
327
284
|
if (!options.force) {
|
|
328
285
|
throw new Error(
|
|
329
286
|
`Theme "${themeName}" already exists at ${targetDir}.
|
|
@@ -333,8 +290,8 @@ Use --force to overwrite.`
|
|
|
333
290
|
console.log(chalk.yellow(` Removing existing theme...`));
|
|
334
291
|
rmSync2(targetDir, { recursive: true, force: true });
|
|
335
292
|
}
|
|
336
|
-
const themesDir =
|
|
337
|
-
if (!
|
|
293
|
+
const themesDir = join4(process.cwd(), "contents", "themes");
|
|
294
|
+
if (!existsSync4(themesDir)) {
|
|
338
295
|
mkdirSync(themesDir, { recursive: true });
|
|
339
296
|
}
|
|
340
297
|
console.log(` Copying to contents/themes/${themeName}/...`);
|
|
@@ -353,23 +310,59 @@ function extractPluginName(npmName) {
|
|
|
353
310
|
function extractThemeName(npmName) {
|
|
354
311
|
return npmName.replace(/^@[^/]+\//, "").replace(/^nextspark-theme-/, "").replace(/^theme-/, "");
|
|
355
312
|
}
|
|
313
|
+
async function registerPluginInThemeConfig(pluginName) {
|
|
314
|
+
const envPath = join4(process.cwd(), ".env");
|
|
315
|
+
let activeTheme = "starter";
|
|
316
|
+
if (existsSync4(envPath)) {
|
|
317
|
+
const envContent = readFileSync4(envPath, "utf-8");
|
|
318
|
+
const match = envContent.match(/NEXT_PUBLIC_ACTIVE_THEME=["']?([^"'\s\n]+)["']?/);
|
|
319
|
+
if (match) {
|
|
320
|
+
activeTheme = match[1];
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
const themeConfigPath = join4(process.cwd(), "contents", "themes", activeTheme, "config", "theme.config.ts");
|
|
324
|
+
if (!existsSync4(themeConfigPath)) {
|
|
325
|
+
console.log(chalk.gray(` Theme config not found, skipping plugin registration`));
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
try {
|
|
329
|
+
let content = readFileSync4(themeConfigPath, "utf-8");
|
|
330
|
+
if (content.includes(`'${pluginName}'`) || content.includes(`"${pluginName}"`)) {
|
|
331
|
+
console.log(chalk.gray(` Plugin ${pluginName} already registered in theme config`));
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
const pluginsArrayMatch = content.match(/plugins:\s*\[([^\]]*)\]/s);
|
|
335
|
+
if (pluginsArrayMatch) {
|
|
336
|
+
const existingPlugins = pluginsArrayMatch[1].trim();
|
|
337
|
+
const newPlugins = existingPlugins ? `${existingPlugins}, '${pluginName}'` : `'${pluginName}'`;
|
|
338
|
+
content = content.replace(
|
|
339
|
+
/plugins:\s*\[([^\]]*)\]/s,
|
|
340
|
+
`plugins: [${newPlugins}]`
|
|
341
|
+
);
|
|
342
|
+
writeFileSync2(themeConfigPath, content);
|
|
343
|
+
console.log(` Registered plugin in theme.config.ts`);
|
|
344
|
+
}
|
|
345
|
+
} catch (error) {
|
|
346
|
+
console.log(chalk.yellow(` Could not register plugin in theme config: ${error}`));
|
|
347
|
+
}
|
|
348
|
+
}
|
|
356
349
|
|
|
357
350
|
// src/lib/postinstall/index.ts
|
|
358
351
|
import chalk6 from "chalk";
|
|
359
352
|
|
|
360
353
|
// src/lib/postinstall/templates.ts
|
|
361
|
-
import { existsSync as
|
|
362
|
-
import { join as
|
|
354
|
+
import { existsSync as existsSync5, cpSync as cpSync2, mkdirSync as mkdirSync2 } from "fs";
|
|
355
|
+
import { join as join5, dirname } from "path";
|
|
363
356
|
import chalk2 from "chalk";
|
|
364
357
|
async function processTemplates(templates, sourcePath, context) {
|
|
365
358
|
for (const template of templates) {
|
|
366
|
-
const from =
|
|
359
|
+
const from = join5(sourcePath, template.from);
|
|
367
360
|
const to = resolveVariables(template.to, context);
|
|
368
|
-
if (!
|
|
361
|
+
if (!existsSync5(from)) {
|
|
369
362
|
console.log(chalk2.yellow(` Warning: Template source not found: ${template.from}`));
|
|
370
363
|
continue;
|
|
371
364
|
}
|
|
372
|
-
const targetExists =
|
|
365
|
+
const targetExists = existsSync5(to);
|
|
373
366
|
const condition = template.condition || "!exists";
|
|
374
367
|
const desc = template.description || template.to;
|
|
375
368
|
switch (condition) {
|
|
@@ -395,7 +388,7 @@ async function processTemplates(templates, sourcePath, context) {
|
|
|
395
388
|
break;
|
|
396
389
|
}
|
|
397
390
|
const parentDir = dirname(to);
|
|
398
|
-
if (!
|
|
391
|
+
if (!existsSync5(parentDir)) {
|
|
399
392
|
mkdirSync2(parentDir, { recursive: true });
|
|
400
393
|
}
|
|
401
394
|
console.log(chalk2.gray(` Copying ${desc}...`));
|
|
@@ -421,21 +414,21 @@ function resolveVariables(path, context) {
|
|
|
421
414
|
throw new Error(`Unresolved template variable: ${unresolvedMatch[0]}`);
|
|
422
415
|
}
|
|
423
416
|
if (!resolved.startsWith("/")) {
|
|
424
|
-
resolved =
|
|
417
|
+
resolved = join5(context.projectRoot, resolved);
|
|
425
418
|
}
|
|
426
419
|
return resolved;
|
|
427
420
|
}
|
|
428
421
|
|
|
429
422
|
// src/lib/postinstall/env-vars.ts
|
|
430
|
-
import { existsSync as
|
|
431
|
-
import { join as
|
|
423
|
+
import { existsSync as existsSync6, readFileSync as readFileSync5, writeFileSync as writeFileSync3, appendFileSync } from "fs";
|
|
424
|
+
import { join as join6 } from "path";
|
|
432
425
|
import chalk3 from "chalk";
|
|
433
426
|
async function processEnvVars(envVars) {
|
|
434
|
-
const envExamplePath =
|
|
435
|
-
const envPath =
|
|
427
|
+
const envExamplePath = join6(process.cwd(), ".env.example");
|
|
428
|
+
const envPath = join6(process.cwd(), ".env");
|
|
436
429
|
let added = 0;
|
|
437
430
|
const existingVars = /* @__PURE__ */ new Set();
|
|
438
|
-
if (
|
|
431
|
+
if (existsSync6(envExamplePath)) {
|
|
439
432
|
const content = readFileSync5(envExamplePath, "utf-8");
|
|
440
433
|
const matches = content.match(/^[A-Z_][A-Z0-9_]*=/gm);
|
|
441
434
|
if (matches) {
|
|
@@ -456,34 +449,34 @@ async function processEnvVars(envVars) {
|
|
|
456
449
|
}
|
|
457
450
|
if (newLines.length > 0) {
|
|
458
451
|
const content = "\n" + newLines.join("\n");
|
|
459
|
-
if (
|
|
452
|
+
if (existsSync6(envExamplePath)) {
|
|
460
453
|
appendFileSync(envExamplePath, content);
|
|
461
454
|
} else {
|
|
462
|
-
|
|
455
|
+
writeFileSync3(envExamplePath, content.trim() + "\n");
|
|
463
456
|
}
|
|
464
457
|
console.log(chalk3.gray(` Added ${added} env vars to .env.example`));
|
|
465
458
|
}
|
|
466
459
|
}
|
|
467
460
|
|
|
468
461
|
// src/lib/postinstall/migrations.ts
|
|
469
|
-
import { existsSync as
|
|
470
|
-
import { join as
|
|
462
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync3, cpSync as cpSync3 } from "fs";
|
|
463
|
+
import { join as join7, basename } from "path";
|
|
471
464
|
import chalk4 from "chalk";
|
|
472
465
|
async function registerMigrations(migrations, installedPath) {
|
|
473
|
-
const migrationsDir =
|
|
474
|
-
if (!
|
|
466
|
+
const migrationsDir = join7(process.cwd(), "migrations");
|
|
467
|
+
if (!existsSync7(migrationsDir)) {
|
|
475
468
|
mkdirSync3(migrationsDir, { recursive: true });
|
|
476
469
|
}
|
|
477
470
|
let copied = 0;
|
|
478
471
|
for (const migration of migrations) {
|
|
479
|
-
const sourcePath =
|
|
480
|
-
if (!
|
|
472
|
+
const sourcePath = join7(installedPath, migration);
|
|
473
|
+
if (!existsSync7(sourcePath)) {
|
|
481
474
|
console.log(chalk4.yellow(` Warning: Migration not found: ${migration}`));
|
|
482
475
|
continue;
|
|
483
476
|
}
|
|
484
477
|
const fileName = basename(migration);
|
|
485
|
-
const targetPath =
|
|
486
|
-
if (
|
|
478
|
+
const targetPath = join7(migrationsDir, fileName);
|
|
479
|
+
if (existsSync7(targetPath)) {
|
|
487
480
|
console.log(chalk4.gray(` Migration ${fileName} already exists, skipping`));
|
|
488
481
|
continue;
|
|
489
482
|
}
|
|
@@ -496,12 +489,12 @@ async function registerMigrations(migrations, installedPath) {
|
|
|
496
489
|
}
|
|
497
490
|
|
|
498
491
|
// src/lib/postinstall/script-runner.ts
|
|
499
|
-
import { existsSync as
|
|
500
|
-
import { join as
|
|
492
|
+
import { existsSync as existsSync8 } from "fs";
|
|
493
|
+
import { join as join8 } from "path";
|
|
501
494
|
import chalk5 from "chalk";
|
|
502
495
|
async function runCustomScript(scriptPath, installedPath, context) {
|
|
503
|
-
const fullPath =
|
|
504
|
-
if (!
|
|
496
|
+
const fullPath = join8(installedPath, scriptPath);
|
|
497
|
+
if (!existsSync8(fullPath)) {
|
|
505
498
|
console.log(chalk5.yellow(` Warning: Postinstall script not found: ${scriptPath}`));
|
|
506
499
|
return;
|
|
507
500
|
}
|
|
@@ -516,8 +509,8 @@ async function runCustomScript(scriptPath, installedPath, context) {
|
|
|
516
509
|
}
|
|
517
510
|
|
|
518
511
|
// src/lib/postinstall/index.ts
|
|
519
|
-
import { existsSync as
|
|
520
|
-
import { join as
|
|
512
|
+
import { existsSync as existsSync9 } from "fs";
|
|
513
|
+
import { join as join9 } from "path";
|
|
521
514
|
async function runPostinstall(packageJson, installedPath, context) {
|
|
522
515
|
const postinstall = packageJson.nextspark?.postinstall;
|
|
523
516
|
if (!postinstall) {
|
|
@@ -534,7 +527,7 @@ async function runPostinstall(packageJson, installedPath, context) {
|
|
|
534
527
|
if (!pluginExists) {
|
|
535
528
|
console.log(` Installing required plugin: ${plugin}`);
|
|
536
529
|
context.installingPlugins.add(plugin);
|
|
537
|
-
const { addPlugin: addPlugin2 } = await import("./add-plugin-
|
|
530
|
+
const { addPlugin: addPlugin2 } = await import("./add-plugin-KIJLCOEQ.js");
|
|
538
531
|
await addPlugin2(plugin, { installingPlugins: context.installingPlugins });
|
|
539
532
|
}
|
|
540
533
|
}
|
|
@@ -578,18 +571,18 @@ async function runPostinstall(packageJson, installedPath, context) {
|
|
|
578
571
|
}
|
|
579
572
|
async function checkPluginExists(pluginName) {
|
|
580
573
|
const name = pluginName.replace(/^@[^/]+\//, "").replace(/^nextspark-plugin-/, "").replace(/^plugin-/, "");
|
|
581
|
-
return
|
|
574
|
+
return existsSync9(join9(process.cwd(), "contents", "plugins", name));
|
|
582
575
|
}
|
|
583
576
|
|
|
584
577
|
// src/lib/theme-detector.ts
|
|
585
|
-
import { existsSync as
|
|
586
|
-
import { join as
|
|
578
|
+
import { existsSync as existsSync10, readFileSync as readFileSync6, readdirSync as readdirSync2 } from "fs";
|
|
579
|
+
import { join as join10 } from "path";
|
|
587
580
|
function detectActiveTheme() {
|
|
588
581
|
if (process.env.NEXT_PUBLIC_ACTIVE_THEME) {
|
|
589
582
|
return process.env.NEXT_PUBLIC_ACTIVE_THEME;
|
|
590
583
|
}
|
|
591
|
-
const configPath =
|
|
592
|
-
if (
|
|
584
|
+
const configPath = join10(process.cwd(), "nextspark.config.ts");
|
|
585
|
+
if (existsSync10(configPath)) {
|
|
593
586
|
try {
|
|
594
587
|
const content = readFileSync6(configPath, "utf-8");
|
|
595
588
|
const match = content.match(/activeTheme\s*:\s*['"]([^'"]+)['"]/);
|
|
@@ -599,8 +592,8 @@ function detectActiveTheme() {
|
|
|
599
592
|
} catch {
|
|
600
593
|
}
|
|
601
594
|
}
|
|
602
|
-
const envPath =
|
|
603
|
-
if (
|
|
595
|
+
const envPath = join10(process.cwd(), ".env");
|
|
596
|
+
if (existsSync10(envPath)) {
|
|
604
597
|
try {
|
|
605
598
|
const content = readFileSync6(envPath, "utf-8");
|
|
606
599
|
const match = content.match(/NEXT_PUBLIC_ACTIVE_THEME=(.+)/);
|
|
@@ -610,8 +603,8 @@ function detectActiveTheme() {
|
|
|
610
603
|
} catch {
|
|
611
604
|
}
|
|
612
605
|
}
|
|
613
|
-
const themesDir =
|
|
614
|
-
if (
|
|
606
|
+
const themesDir = join10(process.cwd(), "contents", "themes");
|
|
607
|
+
if (existsSync10(themesDir)) {
|
|
615
608
|
try {
|
|
616
609
|
const themes = readdirSync2(themesDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
|
|
617
610
|
if (themes.length === 1) {
|
|
@@ -624,14 +617,14 @@ function detectActiveTheme() {
|
|
|
624
617
|
}
|
|
625
618
|
|
|
626
619
|
// src/commands/add-plugin.ts
|
|
627
|
-
import { existsSync as
|
|
628
|
-
import { join as
|
|
620
|
+
import { existsSync as existsSync11, readFileSync as readFileSync7 } from "fs";
|
|
621
|
+
import { join as join11 } from "path";
|
|
629
622
|
async function addPlugin(packageSpec, options = {}) {
|
|
630
623
|
const spinner = ora(`Adding plugin ${packageSpec}`).start();
|
|
631
624
|
let cleanup = null;
|
|
632
625
|
try {
|
|
633
|
-
const contentsDir =
|
|
634
|
-
if (!
|
|
626
|
+
const contentsDir = join11(process.cwd(), "contents");
|
|
627
|
+
if (!existsSync11(contentsDir)) {
|
|
635
628
|
spinner.fail('contents/ directory not found. Run "nextspark init" first.');
|
|
636
629
|
return;
|
|
637
630
|
}
|
|
@@ -680,8 +673,8 @@ async function addPlugin(packageSpec, options = {}) {
|
|
|
680
673
|
}
|
|
681
674
|
}
|
|
682
675
|
function getCoreVersion() {
|
|
683
|
-
const pkgPath =
|
|
684
|
-
if (
|
|
676
|
+
const pkgPath = join11(process.cwd(), "node_modules", "@nextsparkjs", "core", "package.json");
|
|
677
|
+
if (existsSync11(pkgPath)) {
|
|
685
678
|
try {
|
|
686
679
|
const pkg = JSON.parse(readFileSync7(pkgPath, "utf-8"));
|
|
687
680
|
return pkg.version || "0.0.0";
|
package/dist/cli.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
installTheme,
|
|
8
8
|
runPostinstall,
|
|
9
9
|
validateTheme
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-DXL5CEZD.js";
|
|
11
11
|
|
|
12
12
|
// src/cli.ts
|
|
13
13
|
import { config } from "dotenv";
|
|
@@ -1180,8 +1180,8 @@ async function runExpertPrompts() {
|
|
|
1180
1180
|
|
|
1181
1181
|
// src/wizard/generators/index.ts
|
|
1182
1182
|
import fs7 from "fs-extra";
|
|
1183
|
-
import
|
|
1184
|
-
import { fileURLToPath as
|
|
1183
|
+
import path6 from "path";
|
|
1184
|
+
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
1185
1185
|
|
|
1186
1186
|
// src/wizard/generators/theme-renamer.ts
|
|
1187
1187
|
import fs from "fs-extra";
|
|
@@ -2310,22 +2310,27 @@ async function installThemeAndPlugins(theme, plugins) {
|
|
|
2310
2310
|
|
|
2311
2311
|
// src/wizard/generators/env-setup.ts
|
|
2312
2312
|
import fs5 from "fs-extra";
|
|
2313
|
+
import path5 from "path";
|
|
2314
|
+
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
2315
|
+
var __filename5 = fileURLToPath5(import.meta.url);
|
|
2316
|
+
var __dirname5 = path5.dirname(__filename5);
|
|
2317
|
+
var ENV_TEMPLATE_PATH = path5.resolve(__dirname5, "../../../templates/env.template");
|
|
2313
2318
|
|
|
2314
2319
|
// src/wizard/generators/git-init.ts
|
|
2315
2320
|
import fs6 from "fs-extra";
|
|
2316
2321
|
|
|
2317
2322
|
// src/wizard/generators/index.ts
|
|
2318
|
-
var
|
|
2319
|
-
var
|
|
2323
|
+
var __filename6 = fileURLToPath6(import.meta.url);
|
|
2324
|
+
var __dirname6 = path6.dirname(__filename6);
|
|
2320
2325
|
function getTemplatesDir3() {
|
|
2321
2326
|
try {
|
|
2322
2327
|
const corePkgPath = __require.resolve("@nextsparkjs/core/package.json");
|
|
2323
|
-
return
|
|
2328
|
+
return path6.join(path6.dirname(corePkgPath), "templates");
|
|
2324
2329
|
} catch {
|
|
2325
2330
|
const possiblePaths = [
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2331
|
+
path6.resolve(__dirname6, "../../../../../core/templates"),
|
|
2332
|
+
path6.resolve(__dirname6, "../../../../core/templates"),
|
|
2333
|
+
path6.resolve(process.cwd(), "node_modules/@nextsparkjs/core/templates")
|
|
2329
2334
|
];
|
|
2330
2335
|
for (const p of possiblePaths) {
|
|
2331
2336
|
if (fs7.existsSync(p)) {
|
|
@@ -2347,6 +2352,8 @@ async function copyProjectFiles() {
|
|
|
2347
2352
|
{ src: "tsconfig.json", dest: "tsconfig.json", force: true },
|
|
2348
2353
|
{ src: "postcss.config.mjs", dest: "postcss.config.mjs", force: true },
|
|
2349
2354
|
{ src: "i18n.ts", dest: "i18n.ts", force: true },
|
|
2355
|
+
{ src: "pnpm-workspace.yaml", dest: "pnpm-workspace.yaml", force: true },
|
|
2356
|
+
// Enable workspace for themes/plugins - REQUIRED
|
|
2350
2357
|
{ src: "npmrc", dest: ".npmrc", force: false },
|
|
2351
2358
|
{ src: "tsconfig.cypress.json", dest: "tsconfig.cypress.json", force: false },
|
|
2352
2359
|
{ src: "cypress.d.ts", dest: "cypress.d.ts", force: false },
|
|
@@ -2354,8 +2361,8 @@ async function copyProjectFiles() {
|
|
|
2354
2361
|
{ src: "scripts/cy-run-prod.cjs", dest: "scripts/cy-run-prod.cjs", force: false }
|
|
2355
2362
|
];
|
|
2356
2363
|
for (const item of itemsToCopy) {
|
|
2357
|
-
const srcPath =
|
|
2358
|
-
const destPath =
|
|
2364
|
+
const srcPath = path6.join(templatesDir, item.src);
|
|
2365
|
+
const destPath = path6.join(projectDir, item.dest);
|
|
2359
2366
|
if (await fs7.pathExists(srcPath)) {
|
|
2360
2367
|
if (item.force || !await fs7.pathExists(destPath)) {
|
|
2361
2368
|
await fs7.copy(srcPath, destPath);
|
|
@@ -2364,7 +2371,7 @@ async function copyProjectFiles() {
|
|
|
2364
2371
|
}
|
|
2365
2372
|
}
|
|
2366
2373
|
async function updatePackageJson(config2) {
|
|
2367
|
-
const packageJsonPath =
|
|
2374
|
+
const packageJsonPath = path6.resolve(process.cwd(), "package.json");
|
|
2368
2375
|
let packageJson;
|
|
2369
2376
|
if (!await fs7.pathExists(packageJsonPath)) {
|
|
2370
2377
|
packageJson = {
|
|
@@ -2482,7 +2489,7 @@ async function updatePackageJson(config2) {
|
|
|
2482
2489
|
await fs7.writeJson(packageJsonPath, packageJson, { spaces: 2 });
|
|
2483
2490
|
}
|
|
2484
2491
|
async function updateGitignore(config2) {
|
|
2485
|
-
const gitignorePath =
|
|
2492
|
+
const gitignorePath = path6.resolve(process.cwd(), ".gitignore");
|
|
2486
2493
|
const entriesToAdd = `
|
|
2487
2494
|
# NextSpark
|
|
2488
2495
|
.nextspark/
|
|
@@ -2854,23 +2861,21 @@ async function runWizard(options = { mode: "interactive" }) {
|
|
|
2854
2861
|
try {
|
|
2855
2862
|
let selectedTheme = null;
|
|
2856
2863
|
let selectedPlugins = [];
|
|
2857
|
-
if (
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
showInfo(`Selected plugins: ${selectedPlugins.join(", ")}`);
|
|
2868
|
-
}
|
|
2869
|
-
} else if (options.mode !== "quick" && !options.yes) {
|
|
2870
|
-
selectedPlugins = await promptPluginsSelection(selectedTheme);
|
|
2871
|
-
} else if (selectedTheme) {
|
|
2872
|
-
selectedPlugins = getRequiredPlugins(selectedTheme);
|
|
2864
|
+
if (options.theme !== void 0) {
|
|
2865
|
+
selectedTheme = options.theme === "none" ? null : options.theme;
|
|
2866
|
+
showInfo(`Reference theme: ${selectedTheme || "None"}`);
|
|
2867
|
+
} else if (!options.preset && options.mode !== "quick") {
|
|
2868
|
+
selectedTheme = await promptThemeSelection();
|
|
2869
|
+
}
|
|
2870
|
+
if (options.plugins !== void 0) {
|
|
2871
|
+
selectedPlugins = options.plugins;
|
|
2872
|
+
if (selectedPlugins.length > 0) {
|
|
2873
|
+
showInfo(`Selected plugins: ${selectedPlugins.join(", ")}`);
|
|
2873
2874
|
}
|
|
2875
|
+
} else if (!options.preset && options.mode !== "quick" && !options.yes) {
|
|
2876
|
+
selectedPlugins = await promptPluginsSelection(selectedTheme);
|
|
2877
|
+
} else if (selectedTheme) {
|
|
2878
|
+
selectedPlugins = getRequiredPlugins(selectedTheme);
|
|
2874
2879
|
}
|
|
2875
2880
|
let config2;
|
|
2876
2881
|
if (options.preset) {
|
|
@@ -3320,11 +3325,11 @@ import chalk13 from "chalk";
|
|
|
3320
3325
|
|
|
3321
3326
|
// src/doctor/checks/dependencies.ts
|
|
3322
3327
|
import fs8 from "fs-extra";
|
|
3323
|
-
import
|
|
3328
|
+
import path7 from "path";
|
|
3324
3329
|
async function checkDependencies() {
|
|
3325
3330
|
const cwd = process.cwd();
|
|
3326
|
-
const nodeModulesPath =
|
|
3327
|
-
const packageJsonPath =
|
|
3331
|
+
const nodeModulesPath = path7.join(cwd, "node_modules");
|
|
3332
|
+
const packageJsonPath = path7.join(cwd, "package.json");
|
|
3328
3333
|
if (!await fs8.pathExists(packageJsonPath)) {
|
|
3329
3334
|
return {
|
|
3330
3335
|
name: "Dependencies",
|
|
@@ -3360,13 +3365,13 @@ async function checkDependencies() {
|
|
|
3360
3365
|
const criticalDeps = ["next", "react", "react-dom"];
|
|
3361
3366
|
for (const dep of criticalDeps) {
|
|
3362
3367
|
if (allDependencies[dep]) {
|
|
3363
|
-
const depPath =
|
|
3368
|
+
const depPath = path7.join(nodeModulesPath, dep);
|
|
3364
3369
|
if (!await fs8.pathExists(depPath)) {
|
|
3365
3370
|
missingDeps.push(dep);
|
|
3366
3371
|
}
|
|
3367
3372
|
}
|
|
3368
3373
|
}
|
|
3369
|
-
const nextsparksCorePath =
|
|
3374
|
+
const nextsparksCorePath = path7.join(nodeModulesPath, "@nextsparkjs", "core");
|
|
3370
3375
|
const hasNextSparkCore = await fs8.pathExists(nextsparksCorePath);
|
|
3371
3376
|
if (missingDeps.length > 0) {
|
|
3372
3377
|
return {
|
|
@@ -3393,7 +3398,7 @@ async function checkDependencies() {
|
|
|
3393
3398
|
|
|
3394
3399
|
// src/doctor/checks/config.ts
|
|
3395
3400
|
import fs9 from "fs-extra";
|
|
3396
|
-
import
|
|
3401
|
+
import path8 from "path";
|
|
3397
3402
|
var REQUIRED_CONFIG_FILES = [
|
|
3398
3403
|
"next.config.ts",
|
|
3399
3404
|
"tailwind.config.ts",
|
|
@@ -3404,10 +3409,10 @@ async function checkConfigs() {
|
|
|
3404
3409
|
const missingFiles = [];
|
|
3405
3410
|
const invalidFiles = [];
|
|
3406
3411
|
for (const file of REQUIRED_CONFIG_FILES) {
|
|
3407
|
-
const filePath =
|
|
3412
|
+
const filePath = path8.join(cwd, file);
|
|
3408
3413
|
if (file.endsWith(".ts")) {
|
|
3409
|
-
const jsPath =
|
|
3410
|
-
const mjsPath =
|
|
3414
|
+
const jsPath = path8.join(cwd, file.replace(".ts", ".js"));
|
|
3415
|
+
const mjsPath = path8.join(cwd, file.replace(".ts", ".mjs"));
|
|
3411
3416
|
const tsExists = await fs9.pathExists(filePath);
|
|
3412
3417
|
const jsExists = await fs9.pathExists(jsPath);
|
|
3413
3418
|
const mjsExists = await fs9.pathExists(mjsPath);
|
|
@@ -3422,7 +3427,7 @@ async function checkConfigs() {
|
|
|
3422
3427
|
missingFiles.push(file);
|
|
3423
3428
|
}
|
|
3424
3429
|
}
|
|
3425
|
-
const tsconfigPath =
|
|
3430
|
+
const tsconfigPath = path8.join(cwd, "tsconfig.json");
|
|
3426
3431
|
if (await fs9.pathExists(tsconfigPath)) {
|
|
3427
3432
|
try {
|
|
3428
3433
|
const content = await fs9.readFile(tsconfigPath, "utf-8");
|
|
@@ -3433,12 +3438,12 @@ async function checkConfigs() {
|
|
|
3433
3438
|
} else {
|
|
3434
3439
|
missingFiles.push("tsconfig.json");
|
|
3435
3440
|
}
|
|
3436
|
-
const configDir =
|
|
3441
|
+
const configDir = path8.join(cwd, "config");
|
|
3437
3442
|
if (await fs9.pathExists(configDir)) {
|
|
3438
3443
|
const configFiles = await fs9.readdir(configDir);
|
|
3439
3444
|
const tsConfigFiles = configFiles.filter((f) => f.endsWith(".ts"));
|
|
3440
3445
|
for (const file of tsConfigFiles) {
|
|
3441
|
-
const filePath =
|
|
3446
|
+
const filePath = path8.join(configDir, file);
|
|
3442
3447
|
try {
|
|
3443
3448
|
const content = await fs9.readFile(filePath, "utf-8");
|
|
3444
3449
|
if (content.trim().length === 0) {
|
|
@@ -3474,7 +3479,7 @@ async function checkConfigs() {
|
|
|
3474
3479
|
|
|
3475
3480
|
// src/doctor/checks/database.ts
|
|
3476
3481
|
import fs10 from "fs-extra";
|
|
3477
|
-
import
|
|
3482
|
+
import path9 from "path";
|
|
3478
3483
|
function parseEnvFile(content) {
|
|
3479
3484
|
const result = {};
|
|
3480
3485
|
const lines = content.split("\n");
|
|
@@ -3497,8 +3502,8 @@ function parseEnvFile(content) {
|
|
|
3497
3502
|
}
|
|
3498
3503
|
async function checkDatabase() {
|
|
3499
3504
|
const cwd = process.cwd();
|
|
3500
|
-
const envPath =
|
|
3501
|
-
const envLocalPath =
|
|
3505
|
+
const envPath = path9.join(cwd, ".env");
|
|
3506
|
+
const envLocalPath = path9.join(cwd, ".env.local");
|
|
3502
3507
|
let envVars = {};
|
|
3503
3508
|
if (await fs10.pathExists(envLocalPath)) {
|
|
3504
3509
|
try {
|
|
@@ -3557,20 +3562,20 @@ async function checkDatabase() {
|
|
|
3557
3562
|
|
|
3558
3563
|
// src/doctor/checks/imports.ts
|
|
3559
3564
|
import fs11 from "fs-extra";
|
|
3560
|
-
import
|
|
3565
|
+
import path10 from "path";
|
|
3561
3566
|
async function checkCorePackage(cwd) {
|
|
3562
|
-
const nodeModulesPath =
|
|
3567
|
+
const nodeModulesPath = path10.join(cwd, "node_modules", "@nextsparkjs", "core");
|
|
3563
3568
|
if (!await fs11.pathExists(nodeModulesPath)) {
|
|
3564
3569
|
return { accessible: false, reason: "@nextsparkjs/core not found in node_modules" };
|
|
3565
3570
|
}
|
|
3566
|
-
const packageJsonPath =
|
|
3571
|
+
const packageJsonPath = path10.join(nodeModulesPath, "package.json");
|
|
3567
3572
|
if (!await fs11.pathExists(packageJsonPath)) {
|
|
3568
3573
|
return { accessible: false, reason: "@nextsparkjs/core package.json not found" };
|
|
3569
3574
|
}
|
|
3570
3575
|
try {
|
|
3571
3576
|
const packageJson = await fs11.readJson(packageJsonPath);
|
|
3572
3577
|
const mainEntry = packageJson.main || packageJson.module || "./dist/index.js";
|
|
3573
|
-
const mainPath =
|
|
3578
|
+
const mainPath = path10.join(nodeModulesPath, mainEntry);
|
|
3574
3579
|
if (!await fs11.pathExists(mainPath)) {
|
|
3575
3580
|
return { accessible: false, reason: "@nextsparkjs/core entry point not found" };
|
|
3576
3581
|
}
|
|
@@ -3584,7 +3589,7 @@ async function scanForBrokenImports(cwd) {
|
|
|
3584
3589
|
const srcDirs = ["src", "app", "pages", "components", "lib"];
|
|
3585
3590
|
const existingDirs = [];
|
|
3586
3591
|
for (const dir of srcDirs) {
|
|
3587
|
-
const dirPath =
|
|
3592
|
+
const dirPath = path10.join(cwd, dir);
|
|
3588
3593
|
if (await fs11.pathExists(dirPath)) {
|
|
3589
3594
|
existingDirs.push(dirPath);
|
|
3590
3595
|
}
|
|
@@ -3598,7 +3603,7 @@ async function scanForBrokenImports(cwd) {
|
|
|
3598
3603
|
for (const file of files) {
|
|
3599
3604
|
if (filesScanned >= maxFilesToScan) break;
|
|
3600
3605
|
if (file.isFile() && (file.name.endsWith(".ts") || file.name.endsWith(".tsx"))) {
|
|
3601
|
-
const filePath =
|
|
3606
|
+
const filePath = path10.join(dir, file.name);
|
|
3602
3607
|
try {
|
|
3603
3608
|
const content = await fs11.readFile(filePath, "utf-8");
|
|
3604
3609
|
const importMatches = content.match(/from ['"](@?[^'"]+)['"]/g);
|
|
@@ -3606,16 +3611,16 @@ async function scanForBrokenImports(cwd) {
|
|
|
3606
3611
|
for (const match of importMatches) {
|
|
3607
3612
|
const importPath = match.replace(/from ['"]/g, "").replace(/['"]/g, "");
|
|
3608
3613
|
if (importPath.startsWith(".")) {
|
|
3609
|
-
const absoluteImportPath =
|
|
3614
|
+
const absoluteImportPath = path10.resolve(path10.dirname(filePath), importPath);
|
|
3610
3615
|
const possiblePaths = [
|
|
3611
3616
|
absoluteImportPath,
|
|
3612
3617
|
`${absoluteImportPath}.ts`,
|
|
3613
3618
|
`${absoluteImportPath}.tsx`,
|
|
3614
3619
|
`${absoluteImportPath}.js`,
|
|
3615
3620
|
`${absoluteImportPath}.jsx`,
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3621
|
+
path10.join(absoluteImportPath, "index.ts"),
|
|
3622
|
+
path10.join(absoluteImportPath, "index.tsx"),
|
|
3623
|
+
path10.join(absoluteImportPath, "index.js")
|
|
3619
3624
|
];
|
|
3620
3625
|
const exists = await Promise.any(
|
|
3621
3626
|
possiblePaths.map(async (p) => {
|
|
@@ -3643,7 +3648,7 @@ async function checkImports() {
|
|
|
3643
3648
|
const cwd = process.cwd();
|
|
3644
3649
|
const coreCheck = await checkCorePackage(cwd);
|
|
3645
3650
|
if (!coreCheck.accessible) {
|
|
3646
|
-
const packageJsonPath =
|
|
3651
|
+
const packageJsonPath = path10.join(cwd, "package.json");
|
|
3647
3652
|
let hasCoreDep = false;
|
|
3648
3653
|
if (await fs11.pathExists(packageJsonPath)) {
|
|
3649
3654
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextsparkjs/cli",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.70",
|
|
4
4
|
"description": "NextSpark CLI - Complete development toolkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -13,10 +13,6 @@
|
|
|
13
13
|
"bin",
|
|
14
14
|
"templates"
|
|
15
15
|
],
|
|
16
|
-
"scripts": {
|
|
17
|
-
"build": "tsup src/cli.ts --format esm --dts --outDir dist",
|
|
18
|
-
"dev": "tsup src/cli.ts --format esm --watch"
|
|
19
|
-
},
|
|
20
16
|
"dependencies": {
|
|
21
17
|
"@inquirer/prompts": "^7.2.0",
|
|
22
18
|
"@nextsparkjs/core": "^0.1.0-beta.54",
|
|
@@ -28,12 +24,12 @@
|
|
|
28
24
|
"tar": "^7.0.0"
|
|
29
25
|
},
|
|
30
26
|
"devDependencies": {
|
|
31
|
-
"@nextsparkjs/core": "workspace:*",
|
|
32
27
|
"@types/fs-extra": "^11.0.4",
|
|
33
28
|
"@types/node": "^20.0.0",
|
|
34
29
|
"@types/tar": "^6.1.0",
|
|
35
30
|
"tsup": "^8.0.0",
|
|
36
|
-
"typescript": "^5.0.0"
|
|
31
|
+
"typescript": "^5.0.0",
|
|
32
|
+
"@nextsparkjs/core": "0.1.0-beta.50"
|
|
37
33
|
},
|
|
38
34
|
"keywords": [
|
|
39
35
|
"nextspark",
|
|
@@ -50,5 +46,9 @@
|
|
|
50
46
|
},
|
|
51
47
|
"engines": {
|
|
52
48
|
"node": ">=18.0.0"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsup src/cli.ts --format esm --dts --outDir dist",
|
|
52
|
+
"dev": "tsup src/cli.ts --format esm --watch"
|
|
53
53
|
}
|
|
54
|
-
}
|
|
54
|
+
}
|