@nextsparkjs/cli 0.1.0-beta.8 → 0.1.0-beta.80
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 +9 -0
- package/dist/{add-plugin-GCPJ4FHE.js → add-plugin-KIJLCOEQ.js} +1 -1
- package/dist/{chunk-EE6EJYHE.js → chunk-DXL5CEZD.js} +113 -112
- package/dist/cli.js +1677 -446
- package/package.json +13 -11
- package/templates/env.template +165 -0
package/bin/nextspark.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
// Check Node.js version before importing anything
|
|
4
|
+
const nodeVersion = parseInt(process.versions.node.split('.')[0], 10);
|
|
5
|
+
if (nodeVersion < 18) {
|
|
6
|
+
console.error('\x1b[31m✗ NextSpark requires Node.js 18 or higher\x1b[0m');
|
|
7
|
+
console.error(` Current version: ${process.versions.node}`);
|
|
8
|
+
console.error(' Please upgrade Node.js: https://nodejs.org/');
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
import '../dist/cli.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x2)(function(x2) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x2 + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
1
8
|
// src/commands/add-plugin.ts
|
|
2
9
|
import chalk7 from "chalk";
|
|
3
10
|
import ora from "ora";
|
|
@@ -151,60 +158,21 @@ function validateTheme(packageJson, extractedPath) {
|
|
|
151
158
|
}
|
|
152
159
|
|
|
153
160
|
// src/lib/installer.ts
|
|
154
|
-
import { existsSync as
|
|
155
|
-
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";
|
|
156
163
|
import chalk from "chalk";
|
|
157
164
|
|
|
158
|
-
// src/lib/package-manager.ts
|
|
159
|
-
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
160
|
-
import { join as join3 } from "path";
|
|
161
|
-
import { execSync as execSync2 } from "child_process";
|
|
162
|
-
function detectPackageManager() {
|
|
163
|
-
const cwd = process.cwd();
|
|
164
|
-
if (existsSync3(join3(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
165
|
-
if (existsSync3(join3(cwd, "yarn.lock"))) return "yarn";
|
|
166
|
-
if (existsSync3(join3(cwd, "package-lock.json"))) return "npm";
|
|
167
|
-
const pkgPath = join3(cwd, "package.json");
|
|
168
|
-
if (existsSync3(pkgPath)) {
|
|
169
|
-
try {
|
|
170
|
-
const pkg = JSON.parse(readFileSync3(pkgPath, "utf-8"));
|
|
171
|
-
if (pkg.packageManager) {
|
|
172
|
-
if (pkg.packageManager.startsWith("pnpm")) return "pnpm";
|
|
173
|
-
if (pkg.packageManager.startsWith("yarn")) return "yarn";
|
|
174
|
-
}
|
|
175
|
-
} catch {
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return "npm";
|
|
179
|
-
}
|
|
180
|
-
function getInstallCommand(pm, deps) {
|
|
181
|
-
const depsStr = deps.join(" ");
|
|
182
|
-
switch (pm) {
|
|
183
|
-
case "pnpm":
|
|
184
|
-
return `pnpm add ${depsStr}`;
|
|
185
|
-
case "yarn":
|
|
186
|
-
return `yarn add ${depsStr}`;
|
|
187
|
-
default:
|
|
188
|
-
return `npm install ${depsStr}`;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
async function runInstall(pm, deps) {
|
|
192
|
-
if (deps.length === 0) return;
|
|
193
|
-
const command = getInstallCommand(pm, deps);
|
|
194
|
-
execSync2(command, { stdio: "inherit", cwd: process.cwd() });
|
|
195
|
-
}
|
|
196
|
-
|
|
197
165
|
// src/lib/config-updater.ts
|
|
198
|
-
import { existsSync as
|
|
199
|
-
import { join as
|
|
166
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3, writeFileSync } from "fs";
|
|
167
|
+
import { join as join3 } from "path";
|
|
200
168
|
async function updateTsConfig(name, type) {
|
|
201
|
-
const tsconfigPath =
|
|
202
|
-
if (!
|
|
169
|
+
const tsconfigPath = join3(process.cwd(), "tsconfig.json");
|
|
170
|
+
if (!existsSync3(tsconfigPath)) {
|
|
203
171
|
console.log(" Warning: tsconfig.json not found, skipping path update");
|
|
204
172
|
return;
|
|
205
173
|
}
|
|
206
174
|
try {
|
|
207
|
-
const content =
|
|
175
|
+
const content = readFileSync3(tsconfigPath, "utf-8");
|
|
208
176
|
const tsconfig = JSON.parse(content);
|
|
209
177
|
if (!tsconfig.compilerOptions) {
|
|
210
178
|
tsconfig.compilerOptions = {};
|
|
@@ -224,13 +192,13 @@ async function updateTsConfig(name, type) {
|
|
|
224
192
|
}
|
|
225
193
|
}
|
|
226
194
|
async function registerInPackageJson(npmName, version, type) {
|
|
227
|
-
const pkgPath =
|
|
228
|
-
if (!
|
|
195
|
+
const pkgPath = join3(process.cwd(), "package.json");
|
|
196
|
+
if (!existsSync3(pkgPath)) {
|
|
229
197
|
console.log(" Warning: package.json not found, skipping registration");
|
|
230
198
|
return;
|
|
231
199
|
}
|
|
232
200
|
try {
|
|
233
|
-
const content =
|
|
201
|
+
const content = readFileSync3(pkgPath, "utf-8");
|
|
234
202
|
const pkg = JSON.parse(content);
|
|
235
203
|
if (!pkg.nextspark) {
|
|
236
204
|
pkg.nextspark = {};
|
|
@@ -258,7 +226,7 @@ async function registerInPackageJson(npmName, version, type) {
|
|
|
258
226
|
// src/lib/installer.ts
|
|
259
227
|
async function installPlugin(extractedPath, packageJson, options = {}) {
|
|
260
228
|
const pluginName = extractPluginName(packageJson.name);
|
|
261
|
-
const targetDir =
|
|
229
|
+
const targetDir = join4(process.cwd(), "contents", "plugins", pluginName);
|
|
262
230
|
if (options.dryRun) {
|
|
263
231
|
console.log(chalk.cyan("\n [Dry Run] Would perform:"));
|
|
264
232
|
console.log(` - Copy to: contents/plugins/${pluginName}/`);
|
|
@@ -269,7 +237,7 @@ async function installPlugin(extractedPath, packageJson, options = {}) {
|
|
|
269
237
|
console.log(` - Register in package.json`);
|
|
270
238
|
return { success: true, installedPath: targetDir, name: pluginName };
|
|
271
239
|
}
|
|
272
|
-
if (
|
|
240
|
+
if (existsSync4(targetDir)) {
|
|
273
241
|
if (!options.force) {
|
|
274
242
|
throw new Error(
|
|
275
243
|
`Plugin "${pluginName}" already exists at ${targetDir}.
|
|
@@ -279,24 +247,20 @@ Use --force to overwrite.`
|
|
|
279
247
|
console.log(chalk.yellow(` Removing existing plugin...`));
|
|
280
248
|
rmSync2(targetDir, { recursive: true, force: true });
|
|
281
249
|
}
|
|
282
|
-
const pluginsDir =
|
|
283
|
-
if (!
|
|
250
|
+
const pluginsDir = join4(process.cwd(), "contents", "plugins");
|
|
251
|
+
if (!existsSync4(pluginsDir)) {
|
|
284
252
|
mkdirSync(pluginsDir, { recursive: true });
|
|
285
253
|
}
|
|
286
254
|
console.log(` Copying to contents/plugins/${pluginName}/...`);
|
|
287
255
|
cpSync(extractedPath, targetDir, { recursive: true });
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
console.log(` Installing ${depNames.length} dependencies...`);
|
|
293
|
-
const pm = detectPackageManager();
|
|
294
|
-
const depsWithVersions = Object.entries(deps).map(([name, version]) => `${name}@${version}`);
|
|
295
|
-
await runInstall(pm, depsWithVersions);
|
|
296
|
-
}
|
|
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)`);
|
|
297
260
|
}
|
|
298
261
|
await updateTsConfig(pluginName, "plugin");
|
|
299
262
|
await registerInPackageJson(packageJson.name, packageJson.version || "0.0.0", "plugin");
|
|
263
|
+
await registerPluginInThemeConfig(pluginName);
|
|
300
264
|
return {
|
|
301
265
|
success: true,
|
|
302
266
|
installedPath: targetDir,
|
|
@@ -305,7 +269,7 @@ Use --force to overwrite.`
|
|
|
305
269
|
}
|
|
306
270
|
async function installTheme(extractedPath, packageJson, options = {}) {
|
|
307
271
|
const themeName = extractThemeName(packageJson.name);
|
|
308
|
-
const targetDir =
|
|
272
|
+
const targetDir = join4(process.cwd(), "contents", "themes", themeName);
|
|
309
273
|
if (options.dryRun) {
|
|
310
274
|
console.log(chalk.cyan("\n [Dry Run] Would perform:"));
|
|
311
275
|
console.log(` - Copy to: contents/themes/${themeName}/`);
|
|
@@ -316,7 +280,7 @@ async function installTheme(extractedPath, packageJson, options = {}) {
|
|
|
316
280
|
console.log(` - Register in package.json`);
|
|
317
281
|
return { success: true, installedPath: targetDir, name: themeName };
|
|
318
282
|
}
|
|
319
|
-
if (
|
|
283
|
+
if (existsSync4(targetDir)) {
|
|
320
284
|
if (!options.force) {
|
|
321
285
|
throw new Error(
|
|
322
286
|
`Theme "${themeName}" already exists at ${targetDir}.
|
|
@@ -326,8 +290,8 @@ Use --force to overwrite.`
|
|
|
326
290
|
console.log(chalk.yellow(` Removing existing theme...`));
|
|
327
291
|
rmSync2(targetDir, { recursive: true, force: true });
|
|
328
292
|
}
|
|
329
|
-
const themesDir =
|
|
330
|
-
if (!
|
|
293
|
+
const themesDir = join4(process.cwd(), "contents", "themes");
|
|
294
|
+
if (!existsSync4(themesDir)) {
|
|
331
295
|
mkdirSync(themesDir, { recursive: true });
|
|
332
296
|
}
|
|
333
297
|
console.log(` Copying to contents/themes/${themeName}/...`);
|
|
@@ -346,23 +310,59 @@ function extractPluginName(npmName) {
|
|
|
346
310
|
function extractThemeName(npmName) {
|
|
347
311
|
return npmName.replace(/^@[^/]+\//, "").replace(/^nextspark-theme-/, "").replace(/^theme-/, "");
|
|
348
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
|
+
}
|
|
349
349
|
|
|
350
350
|
// src/lib/postinstall/index.ts
|
|
351
351
|
import chalk6 from "chalk";
|
|
352
352
|
|
|
353
353
|
// src/lib/postinstall/templates.ts
|
|
354
|
-
import { existsSync as
|
|
355
|
-
import { join as
|
|
354
|
+
import { existsSync as existsSync5, cpSync as cpSync2, mkdirSync as mkdirSync2 } from "fs";
|
|
355
|
+
import { join as join5, dirname } from "path";
|
|
356
356
|
import chalk2 from "chalk";
|
|
357
357
|
async function processTemplates(templates, sourcePath, context) {
|
|
358
358
|
for (const template of templates) {
|
|
359
|
-
const from =
|
|
359
|
+
const from = join5(sourcePath, template.from);
|
|
360
360
|
const to = resolveVariables(template.to, context);
|
|
361
|
-
if (!
|
|
361
|
+
if (!existsSync5(from)) {
|
|
362
362
|
console.log(chalk2.yellow(` Warning: Template source not found: ${template.from}`));
|
|
363
363
|
continue;
|
|
364
364
|
}
|
|
365
|
-
const targetExists =
|
|
365
|
+
const targetExists = existsSync5(to);
|
|
366
366
|
const condition = template.condition || "!exists";
|
|
367
367
|
const desc = template.description || template.to;
|
|
368
368
|
switch (condition) {
|
|
@@ -388,7 +388,7 @@ async function processTemplates(templates, sourcePath, context) {
|
|
|
388
388
|
break;
|
|
389
389
|
}
|
|
390
390
|
const parentDir = dirname(to);
|
|
391
|
-
if (!
|
|
391
|
+
if (!existsSync5(parentDir)) {
|
|
392
392
|
mkdirSync2(parentDir, { recursive: true });
|
|
393
393
|
}
|
|
394
394
|
console.log(chalk2.gray(` Copying ${desc}...`));
|
|
@@ -414,21 +414,21 @@ function resolveVariables(path, context) {
|
|
|
414
414
|
throw new Error(`Unresolved template variable: ${unresolvedMatch[0]}`);
|
|
415
415
|
}
|
|
416
416
|
if (!resolved.startsWith("/")) {
|
|
417
|
-
resolved =
|
|
417
|
+
resolved = join5(context.projectRoot, resolved);
|
|
418
418
|
}
|
|
419
419
|
return resolved;
|
|
420
420
|
}
|
|
421
421
|
|
|
422
422
|
// src/lib/postinstall/env-vars.ts
|
|
423
|
-
import { existsSync as
|
|
424
|
-
import { join as
|
|
423
|
+
import { existsSync as existsSync6, readFileSync as readFileSync5, writeFileSync as writeFileSync3, appendFileSync } from "fs";
|
|
424
|
+
import { join as join6 } from "path";
|
|
425
425
|
import chalk3 from "chalk";
|
|
426
426
|
async function processEnvVars(envVars) {
|
|
427
|
-
const envExamplePath =
|
|
428
|
-
const envPath =
|
|
427
|
+
const envExamplePath = join6(process.cwd(), ".env.example");
|
|
428
|
+
const envPath = join6(process.cwd(), ".env");
|
|
429
429
|
let added = 0;
|
|
430
430
|
const existingVars = /* @__PURE__ */ new Set();
|
|
431
|
-
if (
|
|
431
|
+
if (existsSync6(envExamplePath)) {
|
|
432
432
|
const content = readFileSync5(envExamplePath, "utf-8");
|
|
433
433
|
const matches = content.match(/^[A-Z_][A-Z0-9_]*=/gm);
|
|
434
434
|
if (matches) {
|
|
@@ -449,34 +449,34 @@ async function processEnvVars(envVars) {
|
|
|
449
449
|
}
|
|
450
450
|
if (newLines.length > 0) {
|
|
451
451
|
const content = "\n" + newLines.join("\n");
|
|
452
|
-
if (
|
|
452
|
+
if (existsSync6(envExamplePath)) {
|
|
453
453
|
appendFileSync(envExamplePath, content);
|
|
454
454
|
} else {
|
|
455
|
-
|
|
455
|
+
writeFileSync3(envExamplePath, content.trim() + "\n");
|
|
456
456
|
}
|
|
457
457
|
console.log(chalk3.gray(` Added ${added} env vars to .env.example`));
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
460
|
|
|
461
461
|
// src/lib/postinstall/migrations.ts
|
|
462
|
-
import { existsSync as
|
|
463
|
-
import { join as
|
|
462
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync3, cpSync as cpSync3 } from "fs";
|
|
463
|
+
import { join as join7, basename } from "path";
|
|
464
464
|
import chalk4 from "chalk";
|
|
465
465
|
async function registerMigrations(migrations, installedPath) {
|
|
466
|
-
const migrationsDir =
|
|
467
|
-
if (!
|
|
466
|
+
const migrationsDir = join7(process.cwd(), "migrations");
|
|
467
|
+
if (!existsSync7(migrationsDir)) {
|
|
468
468
|
mkdirSync3(migrationsDir, { recursive: true });
|
|
469
469
|
}
|
|
470
470
|
let copied = 0;
|
|
471
471
|
for (const migration of migrations) {
|
|
472
|
-
const sourcePath =
|
|
473
|
-
if (!
|
|
472
|
+
const sourcePath = join7(installedPath, migration);
|
|
473
|
+
if (!existsSync7(sourcePath)) {
|
|
474
474
|
console.log(chalk4.yellow(` Warning: Migration not found: ${migration}`));
|
|
475
475
|
continue;
|
|
476
476
|
}
|
|
477
477
|
const fileName = basename(migration);
|
|
478
|
-
const targetPath =
|
|
479
|
-
if (
|
|
478
|
+
const targetPath = join7(migrationsDir, fileName);
|
|
479
|
+
if (existsSync7(targetPath)) {
|
|
480
480
|
console.log(chalk4.gray(` Migration ${fileName} already exists, skipping`));
|
|
481
481
|
continue;
|
|
482
482
|
}
|
|
@@ -489,12 +489,12 @@ async function registerMigrations(migrations, installedPath) {
|
|
|
489
489
|
}
|
|
490
490
|
|
|
491
491
|
// src/lib/postinstall/script-runner.ts
|
|
492
|
-
import { existsSync as
|
|
493
|
-
import { join as
|
|
492
|
+
import { existsSync as existsSync8 } from "fs";
|
|
493
|
+
import { join as join8 } from "path";
|
|
494
494
|
import chalk5 from "chalk";
|
|
495
495
|
async function runCustomScript(scriptPath, installedPath, context) {
|
|
496
|
-
const fullPath =
|
|
497
|
-
if (!
|
|
496
|
+
const fullPath = join8(installedPath, scriptPath);
|
|
497
|
+
if (!existsSync8(fullPath)) {
|
|
498
498
|
console.log(chalk5.yellow(` Warning: Postinstall script not found: ${scriptPath}`));
|
|
499
499
|
return;
|
|
500
500
|
}
|
|
@@ -509,8 +509,8 @@ async function runCustomScript(scriptPath, installedPath, context) {
|
|
|
509
509
|
}
|
|
510
510
|
|
|
511
511
|
// src/lib/postinstall/index.ts
|
|
512
|
-
import { existsSync as
|
|
513
|
-
import { join as
|
|
512
|
+
import { existsSync as existsSync9 } from "fs";
|
|
513
|
+
import { join as join9 } from "path";
|
|
514
514
|
async function runPostinstall(packageJson, installedPath, context) {
|
|
515
515
|
const postinstall = packageJson.nextspark?.postinstall;
|
|
516
516
|
if (!postinstall) {
|
|
@@ -527,7 +527,7 @@ async function runPostinstall(packageJson, installedPath, context) {
|
|
|
527
527
|
if (!pluginExists) {
|
|
528
528
|
console.log(` Installing required plugin: ${plugin}`);
|
|
529
529
|
context.installingPlugins.add(plugin);
|
|
530
|
-
const { addPlugin: addPlugin2 } = await import("./add-plugin-
|
|
530
|
+
const { addPlugin: addPlugin2 } = await import("./add-plugin-KIJLCOEQ.js");
|
|
531
531
|
await addPlugin2(plugin, { installingPlugins: context.installingPlugins });
|
|
532
532
|
}
|
|
533
533
|
}
|
|
@@ -571,18 +571,18 @@ async function runPostinstall(packageJson, installedPath, context) {
|
|
|
571
571
|
}
|
|
572
572
|
async function checkPluginExists(pluginName) {
|
|
573
573
|
const name = pluginName.replace(/^@[^/]+\//, "").replace(/^nextspark-plugin-/, "").replace(/^plugin-/, "");
|
|
574
|
-
return
|
|
574
|
+
return existsSync9(join9(process.cwd(), "contents", "plugins", name));
|
|
575
575
|
}
|
|
576
576
|
|
|
577
577
|
// src/lib/theme-detector.ts
|
|
578
|
-
import { existsSync as
|
|
579
|
-
import { join as
|
|
578
|
+
import { existsSync as existsSync10, readFileSync as readFileSync6, readdirSync as readdirSync2 } from "fs";
|
|
579
|
+
import { join as join10 } from "path";
|
|
580
580
|
function detectActiveTheme() {
|
|
581
581
|
if (process.env.NEXT_PUBLIC_ACTIVE_THEME) {
|
|
582
582
|
return process.env.NEXT_PUBLIC_ACTIVE_THEME;
|
|
583
583
|
}
|
|
584
|
-
const configPath =
|
|
585
|
-
if (
|
|
584
|
+
const configPath = join10(process.cwd(), "nextspark.config.ts");
|
|
585
|
+
if (existsSync10(configPath)) {
|
|
586
586
|
try {
|
|
587
587
|
const content = readFileSync6(configPath, "utf-8");
|
|
588
588
|
const match = content.match(/activeTheme\s*:\s*['"]([^'"]+)['"]/);
|
|
@@ -592,8 +592,8 @@ function detectActiveTheme() {
|
|
|
592
592
|
} catch {
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
|
-
const envPath =
|
|
596
|
-
if (
|
|
595
|
+
const envPath = join10(process.cwd(), ".env");
|
|
596
|
+
if (existsSync10(envPath)) {
|
|
597
597
|
try {
|
|
598
598
|
const content = readFileSync6(envPath, "utf-8");
|
|
599
599
|
const match = content.match(/NEXT_PUBLIC_ACTIVE_THEME=(.+)/);
|
|
@@ -603,8 +603,8 @@ function detectActiveTheme() {
|
|
|
603
603
|
} catch {
|
|
604
604
|
}
|
|
605
605
|
}
|
|
606
|
-
const themesDir =
|
|
607
|
-
if (
|
|
606
|
+
const themesDir = join10(process.cwd(), "contents", "themes");
|
|
607
|
+
if (existsSync10(themesDir)) {
|
|
608
608
|
try {
|
|
609
609
|
const themes = readdirSync2(themesDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
|
|
610
610
|
if (themes.length === 1) {
|
|
@@ -617,14 +617,14 @@ function detectActiveTheme() {
|
|
|
617
617
|
}
|
|
618
618
|
|
|
619
619
|
// src/commands/add-plugin.ts
|
|
620
|
-
import { existsSync as
|
|
621
|
-
import { join as
|
|
620
|
+
import { existsSync as existsSync11, readFileSync as readFileSync7 } from "fs";
|
|
621
|
+
import { join as join11 } from "path";
|
|
622
622
|
async function addPlugin(packageSpec, options = {}) {
|
|
623
623
|
const spinner = ora(`Adding plugin ${packageSpec}`).start();
|
|
624
624
|
let cleanup = null;
|
|
625
625
|
try {
|
|
626
|
-
const contentsDir =
|
|
627
|
-
if (!
|
|
626
|
+
const contentsDir = join11(process.cwd(), "contents");
|
|
627
|
+
if (!existsSync11(contentsDir)) {
|
|
628
628
|
spinner.fail('contents/ directory not found. Run "nextspark init" first.');
|
|
629
629
|
return;
|
|
630
630
|
}
|
|
@@ -673,8 +673,8 @@ async function addPlugin(packageSpec, options = {}) {
|
|
|
673
673
|
}
|
|
674
674
|
}
|
|
675
675
|
function getCoreVersion() {
|
|
676
|
-
const pkgPath =
|
|
677
|
-
if (
|
|
676
|
+
const pkgPath = join11(process.cwd(), "node_modules", "@nextsparkjs", "core", "package.json");
|
|
677
|
+
if (existsSync11(pkgPath)) {
|
|
678
678
|
try {
|
|
679
679
|
const pkg = JSON.parse(readFileSync7(pkgPath, "utf-8"));
|
|
680
680
|
return pkg.version || "0.0.0";
|
|
@@ -695,10 +695,11 @@ function addPluginCommand(packageSpec, options) {
|
|
|
695
695
|
}
|
|
696
696
|
|
|
697
697
|
export {
|
|
698
|
+
__require,
|
|
698
699
|
fetchPackage,
|
|
699
700
|
validateTheme,
|
|
700
701
|
installTheme,
|
|
701
|
-
runPostinstall,
|
|
702
702
|
addPlugin,
|
|
703
|
-
addPluginCommand
|
|
703
|
+
addPluginCommand,
|
|
704
|
+
runPostinstall
|
|
704
705
|
};
|