@nextsparkjs/cli 0.1.0-beta.4 → 0.1.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +138 -33
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1690,6 +1690,14 @@ async function updateReadme(config) {
1690
1690
  );
1691
1691
  await fs2.writeFile(readmePath, content, "utf-8");
1692
1692
  }
1693
+ async function copyEnvExampleToEnv() {
1694
+ const projectRoot = process.cwd();
1695
+ const envExamplePath = path2.resolve(projectRoot, ".env.example");
1696
+ const envPath = path2.resolve(projectRoot, ".env");
1697
+ if (await fs2.pathExists(envExamplePath) && !await fs2.pathExists(envPath)) {
1698
+ await fs2.copy(envExamplePath, envPath);
1699
+ }
1700
+ }
1693
1701
 
1694
1702
  // src/wizard/generators/messages-generator.ts
1695
1703
  import fs3 from "fs-extra";
@@ -2197,6 +2205,65 @@ import fs6 from "fs-extra";
2197
2205
  // src/wizard/generators/index.ts
2198
2206
  var __filename4 = fileURLToPath4(import.meta.url);
2199
2207
  var __dirname4 = path5.dirname(__filename4);
2208
+ async function generateInitialRegistries() {
2209
+ const projectRoot = process.cwd();
2210
+ const registriesDir = path5.join(projectRoot, ".nextspark", "registries");
2211
+ await fs7.ensureDir(registriesDir);
2212
+ await fs7.writeFile(path5.join(registriesDir, "block-registry.ts"), `// Auto-generated by nextspark init
2213
+ import type { ComponentType } from 'react'
2214
+
2215
+ export const BLOCK_REGISTRY: Record<string, {
2216
+ name: string
2217
+ slug: string
2218
+ componentPath: string
2219
+ fields?: unknown[]
2220
+ examples?: unknown[]
2221
+ }> = {}
2222
+
2223
+ export const BLOCK_COMPONENTS: Record<string, React.LazyExoticComponent<ComponentType<any>>> = {}
2224
+ `);
2225
+ await fs7.writeFile(path5.join(registriesDir, "theme-registry.ts"), `// Auto-generated by nextspark init
2226
+ export const THEME_REGISTRY: Record<string, unknown> = {}
2227
+ `);
2228
+ await fs7.writeFile(path5.join(registriesDir, "entity-registry.ts"), `// Auto-generated by nextspark init
2229
+ export const ENTITY_REGISTRY: Record<string, unknown> = {}
2230
+ `);
2231
+ await fs7.writeFile(path5.join(registriesDir, "entity-registry.client.ts"), `// Auto-generated by nextspark init
2232
+ export const CLIENT_ENTITY_REGISTRY: Record<string, unknown> = {}
2233
+ export function parseChildEntity(path: string) { return null }
2234
+ export function getEntityApiPath(entity: string) { return \`/api/\${entity}\` }
2235
+ export function clientMetaSystemAdapter() { return {} }
2236
+ export type ClientEntityConfig = Record<string, unknown>
2237
+ `);
2238
+ await fs7.writeFile(path5.join(registriesDir, "billing-registry.ts"), `// Auto-generated by nextspark init
2239
+ export const BILLING_REGISTRY = { plans: [], features: [] }
2240
+ `);
2241
+ await fs7.writeFile(path5.join(registriesDir, "plugin-registry.ts"), `// Auto-generated by nextspark init
2242
+ export const PLUGIN_REGISTRY: Record<string, unknown> = {}
2243
+ `);
2244
+ await fs7.writeFile(path5.join(registriesDir, "testing-registry.ts"), `// Auto-generated by nextspark init
2245
+ export const FLOW_REGISTRY: Record<string, unknown> = {}
2246
+ export const FEATURE_REGISTRY: Record<string, unknown> = {}
2247
+ export const TAGS_REGISTRY: Record<string, unknown> = {}
2248
+ export const COVERAGE_SUMMARY = { total: 0, covered: 0 }
2249
+ export type FlowEntry = unknown
2250
+ export type FeatureEntry = unknown
2251
+ `);
2252
+ await fs7.writeFile(path5.join(registriesDir, "docs-registry.ts"), `// Auto-generated by nextspark init
2253
+ export const DOCS_REGISTRY = { sections: [], pages: [] }
2254
+ export type DocSectionMeta = { title: string; slug: string }
2255
+ `);
2256
+ await fs7.writeFile(path5.join(registriesDir, "index.ts"), `// Auto-generated by nextspark init
2257
+ export * from './block-registry'
2258
+ export * from './theme-registry'
2259
+ export * from './entity-registry'
2260
+ export * from './entity-registry.client'
2261
+ export * from './billing-registry'
2262
+ export * from './plugin-registry'
2263
+ export * from './testing-registry'
2264
+ export * from './docs-registry'
2265
+ `);
2266
+ }
2200
2267
  function getTemplatesDir3() {
2201
2268
  try {
2202
2269
  const corePkgPath = __require.resolve("@nextsparkjs/core/package.json");
@@ -2402,6 +2469,8 @@ async function generateProject(config) {
2402
2469
  await updateGitignore(config);
2403
2470
  await generateEnvExample(config);
2404
2471
  await updateReadme(config);
2472
+ await copyEnvExampleToEnv();
2473
+ await generateInitialRegistries();
2405
2474
  }
2406
2475
 
2407
2476
  // src/wizard/presets.ts
@@ -2707,6 +2776,16 @@ function showConfigPreview(config) {
2707
2776
  }
2708
2777
 
2709
2778
  // src/wizard/index.ts
2779
+ function getProjectInfoFromOptions(options) {
2780
+ if (options.name && options.slug && options.description) {
2781
+ return {
2782
+ projectName: options.name,
2783
+ projectSlug: options.slug,
2784
+ projectDescription: options.description
2785
+ };
2786
+ }
2787
+ return null;
2788
+ }
2710
2789
  async function runWizard(options = { mode: "interactive" }) {
2711
2790
  showBanner();
2712
2791
  showModeIndicator(options);
@@ -2733,7 +2812,7 @@ async function runWizard(options = { mode: "interactive" }) {
2733
2812
  }
2734
2813
  let config;
2735
2814
  if (options.preset) {
2736
- config = await runPresetMode(options.preset);
2815
+ config = await runPresetMode(options.preset, options);
2737
2816
  } else {
2738
2817
  switch (options.mode) {
2739
2818
  case "quick":
@@ -2750,15 +2829,17 @@ async function runWizard(options = { mode: "interactive" }) {
2750
2829
  }
2751
2830
  showConfigSummary(config);
2752
2831
  showConfigPreview(config);
2753
- console.log("");
2754
- const proceed = await confirm5({
2755
- message: "Proceed with project generation?",
2756
- default: true
2757
- });
2758
- if (!proceed) {
2832
+ if (!options.yes) {
2759
2833
  console.log("");
2760
- showInfo("Project generation cancelled. No changes were made.");
2761
- process.exit(0);
2834
+ const proceed = await confirm5({
2835
+ message: "Proceed with project generation?",
2836
+ default: true
2837
+ });
2838
+ if (!proceed) {
2839
+ console.log("");
2840
+ showInfo("Project generation cancelled. No changes were made.");
2841
+ process.exit(0);
2842
+ }
2762
2843
  }
2763
2844
  await copyNpmrc();
2764
2845
  console.log("");
@@ -2782,6 +2863,20 @@ async function runWizard(options = { mode: "interactive" }) {
2782
2863
  if (selectedTheme || selectedPlugins.length > 0) {
2783
2864
  await installThemeAndPlugins(selectedTheme, selectedPlugins);
2784
2865
  }
2866
+ const installSpinner = ora7({
2867
+ text: "Installing dependencies...",
2868
+ prefixText: " "
2869
+ }).start();
2870
+ try {
2871
+ execSync("pnpm install", {
2872
+ cwd: process.cwd(),
2873
+ stdio: "pipe"
2874
+ });
2875
+ installSpinner.succeed("Dependencies installed!");
2876
+ } catch (error) {
2877
+ installSpinner.fail("Failed to install dependencies");
2878
+ console.log(chalk11.yellow(' Run "pnpm install" manually to install dependencies'));
2879
+ }
2785
2880
  showNextSteps(config, selectedTheme);
2786
2881
  } catch (error) {
2787
2882
  if (error instanceof Error) {
@@ -2807,14 +2902,21 @@ function showModeIndicator(options) {
2807
2902
  console.log("");
2808
2903
  }
2809
2904
  }
2810
- async function runPresetMode(presetName) {
2905
+ async function runPresetMode(presetName, options) {
2811
2906
  if (!presetName) {
2812
2907
  throw new Error("Preset name is required for preset mode");
2813
2908
  }
2814
- showSection("Project Information", 1, 1);
2815
- showInfo("Using preset defaults. Only project information is required.");
2816
- console.log("");
2817
- const projectInfo = await promptProjectInfo();
2909
+ const projectInfoFromOptions = getProjectInfoFromOptions(options);
2910
+ let projectInfo;
2911
+ if (projectInfoFromOptions) {
2912
+ projectInfo = projectInfoFromOptions;
2913
+ showInfo(`Project: ${projectInfo.projectName} (${projectInfo.projectSlug})`);
2914
+ } else {
2915
+ showSection("Project Information", 1, 1);
2916
+ showInfo("Using preset defaults. Only project information is required.");
2917
+ console.log("");
2918
+ projectInfo = await promptProjectInfo();
2919
+ }
2818
2920
  const config = applyPreset(projectInfo, presetName);
2819
2921
  return config;
2820
2922
  }
@@ -2884,35 +2986,35 @@ function formatDevTool(tool) {
2884
2986
  function showNextSteps(config, referenceTheme = null) {
2885
2987
  console.log("");
2886
2988
  console.log(chalk11.cyan(" " + "=".repeat(60)));
2887
- console.log(chalk11.bold.green(" \u2728 NextSpark project created successfully!"));
2989
+ console.log(chalk11.bold.green(" \u2728 NextSpark project ready!"));
2888
2990
  console.log(chalk11.cyan(" " + "=".repeat(60)));
2889
2991
  console.log("");
2890
2992
  console.log(chalk11.bold.white(" Next steps:"));
2891
2993
  console.log("");
2892
- console.log(chalk11.white(" 1. Install dependencies:"));
2893
- console.log(chalk11.cyan(" pnpm install"));
2994
+ console.log(chalk11.white(" 1. Configure your .env file:"));
2995
+ console.log(chalk11.gray(" Edit these values in .env:"));
2894
2996
  console.log("");
2895
- console.log(chalk11.white(" 2. Set up your environment:"));
2896
- console.log(chalk11.gray(" Copy .env.example to .env and configure:"));
2897
- console.log(chalk11.yellow(" - DATABASE_URL"));
2898
- console.log(chalk11.yellow(" - BETTER_AUTH_SECRET"));
2899
- console.log(chalk11.yellow(` - NEXT_PUBLIC_ACTIVE_THEME=${config.projectSlug}`));
2997
+ console.log(chalk11.yellow(" DATABASE_URL"));
2998
+ console.log(chalk11.gray(" PostgreSQL connection string"));
2999
+ console.log(chalk11.dim(" Example: postgresql://user:pass@localhost:5432/mydb"));
2900
3000
  console.log("");
2901
- console.log(chalk11.white(" 3. Generate registries:"));
2902
- console.log(chalk11.cyan(" pnpm build:registries"));
3001
+ console.log(chalk11.yellow(" BETTER_AUTH_SECRET"));
3002
+ console.log(chalk11.gray(" Generate with:"));
3003
+ console.log(chalk11.cyan(" openssl rand -base64 32"));
2903
3004
  console.log("");
2904
- console.log(chalk11.white(" 4. Run database migrations:"));
3005
+ console.log(chalk11.white(" 2. Run database migrations:"));
2905
3006
  console.log(chalk11.cyan(" pnpm db:migrate"));
2906
3007
  console.log("");
2907
- console.log(chalk11.white(" 5. Start the development server:"));
3008
+ console.log(chalk11.white(" 3. Start the development server:"));
2908
3009
  console.log(chalk11.cyan(" pnpm dev"));
2909
3010
  console.log("");
2910
3011
  console.log(chalk11.gray(" " + "-".repeat(60)));
2911
- console.log(chalk11.gray(` Your theme: ${chalk11.white(`contents/themes/${config.projectSlug}/`)}`));
3012
+ console.log(chalk11.gray(` Theme: ${chalk11.white(`contents/themes/${config.projectSlug}/`)}`));
3013
+ console.log(chalk11.gray(` Active theme: ${chalk11.green(`NEXT_PUBLIC_ACTIVE_THEME=${config.projectSlug}`)}`));
2912
3014
  if (referenceTheme) {
2913
- console.log(chalk11.gray(` Reference theme: ${chalk11.white(`contents/themes/${referenceTheme}/`)}`));
3015
+ console.log(chalk11.gray(` Reference: ${chalk11.white(`contents/themes/${referenceTheme}/`)}`));
2914
3016
  }
2915
- console.log(chalk11.gray(" Documentation: https://nextspark.dev/docs"));
3017
+ console.log(chalk11.gray(" Docs: https://nextspark.dev/docs"));
2916
3018
  console.log("");
2917
3019
  }
2918
3020
  function findLocalCoreTarball() {
@@ -3000,7 +3102,7 @@ function hasExistingProject() {
3000
3102
  const projectRoot = process.cwd();
3001
3103
  return existsSync8(join7(projectRoot, "contents")) || existsSync8(join7(projectRoot, ".nextspark"));
3002
3104
  }
3003
- function generateInitialRegistries(registriesDir) {
3105
+ function generateInitialRegistries2(registriesDir) {
3004
3106
  writeFileSync2(join7(registriesDir, "block-registry.ts"), `// Auto-generated by nextspark init
3005
3107
  import type { ComponentType } from 'react'
3006
3108
 
@@ -3065,7 +3167,7 @@ async function simpleInit(options) {
3065
3167
  if (!existsSync8(registriesDir) || options.force) {
3066
3168
  mkdirSync2(registriesDir, { recursive: true });
3067
3169
  spinner.text = "Creating .nextspark/registries/";
3068
- generateInitialRegistries(registriesDir);
3170
+ generateInitialRegistries2(registriesDir);
3069
3171
  spinner.text = "Generated initial registries";
3070
3172
  }
3071
3173
  const tsconfigPath = join7(projectRoot, "tsconfig.json");
@@ -3120,7 +3222,10 @@ async function initCommand(options) {
3120
3222
  preset: options.preset,
3121
3223
  theme: options.theme,
3122
3224
  plugins: parsePlugins(options.plugins),
3123
- yes: options.yes
3225
+ yes: options.yes,
3226
+ name: options.name,
3227
+ slug: options.slug,
3228
+ description: options.description
3124
3229
  };
3125
3230
  await runWizard(wizardOptions);
3126
3231
  }
@@ -3597,7 +3702,7 @@ registry.command("build").description("Build all registries").action(registryBui
3597
3702
  registry.command("watch").description("Watch and rebuild registries on changes").action(registryWatchCommand);
3598
3703
  program.command("registry:build").description("Build all registries (alias)").action(registryBuildCommand);
3599
3704
  program.command("registry:watch").description("Watch and rebuild registries (alias)").action(registryWatchCommand);
3600
- program.command("init").description("Initialize NextSpark project").option("-f, --force", "Overwrite existing configuration").option("--wizard", "Run full project wizard").option("--quick", "Quick wizard mode (essential steps only)").option("--expert", "Expert wizard mode (all options)").option("--preset <name>", "Use preset configuration (saas, blog, crm)").option("--theme <name>", "Pre-select theme (default, blog, crm, productivity, none)").option("--plugins <list>", "Pre-select plugins (comma-separated)").option("-y, --yes", "Skip confirmations").option("--registries-only", "Only create registries (no wizard)").action(initCommand);
3705
+ program.command("init").description("Initialize NextSpark project").option("-f, --force", "Overwrite existing configuration").option("--wizard", "Run full project wizard").option("--quick", "Quick wizard mode (essential steps only)").option("--expert", "Expert wizard mode (all options)").option("--preset <name>", "Use preset configuration (saas, blog, crm)").option("--theme <name>", "Pre-select theme (default, blog, crm, productivity, none)").option("--plugins <list>", "Pre-select plugins (comma-separated)").option("-y, --yes", "Skip confirmations").option("--registries-only", "Only create registries (no wizard)").option("--name <name>", "Project name (non-interactive mode)").option("--slug <slug>", "Project slug (non-interactive mode)").option("--description <desc>", "Project description (non-interactive mode)").action(initCommand);
3601
3706
  program.command("add:plugin <package>").description("Add a plugin to your project").option("-v, --version <version>", "Specific version to install").option("-f, --force", "Overwrite if already exists").option("--skip-postinstall", "Skip postinstall hooks").option("--no-deps", "Skip installing dependencies").option("--dry-run", "Show what would be done without making changes").action(addPluginCommand);
3602
3707
  program.command("add:theme <package>").description("Add a theme to your project").option("-v, --version <version>", "Specific version to install").option("-f, --force", "Overwrite if already exists").option("--skip-postinstall", "Skip postinstall hooks").option("--no-deps", "Skip installing dependencies").option("--dry-run", "Show what would be done without making changes").action(addThemeCommand);
3603
3708
  program.command("doctor").description("Run health check on NextSpark project").action(doctorCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextsparkjs/cli",
3
- "version": "0.1.0-beta.4",
3
+ "version": "0.1.0-beta.6",
4
4
  "description": "NextSpark CLI - Complete development toolkit",
5
5
  "type": "module",
6
6
  "bin": {