@nextsparkjs/cli 0.1.0-beta.100 → 0.1.0-beta.101

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextsparkjs/cli",
3
- "version": "0.1.0-beta.100",
3
+ "version": "0.1.0-beta.101",
4
4
  "description": "NextSpark CLI - Complete development toolkit",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,10 +0,0 @@
1
- import {
2
- addPlugin,
3
- addPluginCommand
4
- } from "./chunk-5GBCARGX.js";
5
- import "./chunk-DGUM43GV.js";
6
- export {
7
- addPlugin,
8
- addPluginCommand
9
- };
10
- //# sourceMappingURL=add-plugin-Q7DOR7XO.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/add-plugin.ts","../src/lib/package-fetcher.ts","../src/lib/validator.ts","../src/lib/installer.ts","../src/lib/config-updater.ts","../src/lib/postinstall/index.ts","../src/lib/postinstall/templates.ts","../src/lib/postinstall/env-vars.ts","../src/lib/postinstall/migrations.ts","../src/lib/postinstall/script-runner.ts","../src/lib/theme-detector.ts"],"sourcesContent":["import chalk from 'chalk'\nimport ora from 'ora'\nimport { fetchPackage } from '../lib/package-fetcher.js'\nimport { validatePlugin } from '../lib/validator.js'\nimport { installPlugin } from '../lib/installer.js'\nimport { runPostinstall } from '../lib/postinstall/index.js'\nimport { detectActiveTheme } from '../lib/theme-detector.js'\nimport { existsSync, readFileSync } from 'fs'\nimport { join } from 'path'\nimport type { InstallOptions, PostinstallContext } from '../types/nextspark-package.js'\n\ninterface AddPluginOptions extends InstallOptions {\n installingPlugins?: Set<string>\n}\n\nexport async function addPlugin(\n packageSpec: string,\n options: AddPluginOptions = {}\n): Promise<void> {\n const spinner = ora(`Adding plugin ${packageSpec}`).start()\n\n let cleanup: (() => void) | null = null\n\n try {\n // Pre-checks\n const contentsDir = join(process.cwd(), 'contents')\n if (!existsSync(contentsDir)) {\n spinner.fail('contents/ directory not found. Run \"nextspark init\" first.')\n return\n }\n\n // Fetch package\n spinner.text = 'Downloading package...'\n const { packageJson, extractedPath, cleanup: cleanupFn } = await fetchPackage(\n packageSpec,\n options.version\n )\n cleanup = cleanupFn\n\n // Validate\n spinner.text = 'Validating plugin...'\n const validation = validatePlugin(packageJson, extractedPath)\n\n if (!validation.valid) {\n spinner.fail('Invalid plugin')\n validation.errors.forEach(e => console.log(chalk.red(` ✗ ${e}`)))\n return\n }\n\n if (validation.warnings.length > 0) {\n validation.warnings.forEach(w => console.log(chalk.yellow(` ⚠ ${w}`)))\n }\n\n // Install\n spinner.text = 'Installing plugin...'\n spinner.stop()\n\n const result = await installPlugin(extractedPath, packageJson, options)\n\n // Postinstall\n if (!options.skipPostinstall) {\n const coreVersion = getCoreVersion()\n const context: PostinstallContext = {\n activeTheme: detectActiveTheme(),\n projectRoot: process.cwd(),\n pluginName: result.name,\n coreVersion,\n timestamp: Date.now(),\n installingPlugins: options.installingPlugins || new Set([packageSpec])\n }\n\n await runPostinstall(packageJson, result.installedPath, context)\n }\n\n console.log(chalk.green(`\\n ✓ Plugin ${result.name} installed successfully!`))\n console.log(chalk.gray(` Location: contents/plugins/${result.name}/`))\n\n } catch (error) {\n spinner.fail('Failed to add plugin')\n if (error instanceof Error) {\n console.log(chalk.red(` ${error.message}`))\n }\n throw error\n } finally {\n if (cleanup) cleanup()\n }\n}\n\nfunction getCoreVersion(): string {\n const pkgPath = join(process.cwd(), 'node_modules', '@nextsparkjs', 'core', 'package.json')\n if (existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))\n return pkg.version || '0.0.0'\n } catch {\n return '0.0.0'\n }\n }\n return '0.0.0'\n}\n\nexport function addPluginCommand(packageSpec: string, options: Record<string, unknown>): Promise<void> {\n return addPlugin(packageSpec, {\n force: options.force as boolean,\n skipDeps: options.noDeps as boolean,\n dryRun: options.dryRun as boolean,\n skipPostinstall: options.skipPostinstall as boolean,\n version: options.version as string\n })\n}\n","import { execSync } from 'child_process'\nimport { mkdtempSync, readdirSync, rmSync, existsSync, readFileSync, copyFileSync } from 'fs'\nimport { tmpdir } from 'os'\nimport { join, isAbsolute } from 'path'\nimport * as tar from 'tar'\nimport type { NextSparkPackageJson, FetchResult } from '../types/nextspark-package.js'\n\nexport async function fetchPackage(\n packageSpec: string,\n version?: string\n): Promise<FetchResult> {\n // Detectar si es path local\n if (packageSpec.endsWith('.tgz') || packageSpec.startsWith('./') || packageSpec.startsWith('/') || isAbsolute(packageSpec)) {\n return fetchLocalPackage(packageSpec)\n }\n\n return fetchNpmPackage(packageSpec, version)\n}\n\nasync function fetchLocalPackage(filePath: string): Promise<FetchResult> {\n const absolutePath = isAbsolute(filePath)\n ? filePath\n : join(process.cwd(), filePath)\n\n if (!existsSync(absolutePath)) {\n throw new Error(`Local package not found: ${absolutePath}`)\n }\n\n const tempDir = mkdtempSync(join(tmpdir(), 'nextspark-add-'))\n\n try {\n // Copiar .tgz a temp y extraer\n const tgzPath = join(tempDir, 'package.tgz')\n copyFileSync(absolutePath, tgzPath)\n\n await tar.x({\n file: tgzPath,\n cwd: tempDir,\n })\n\n const extractedPath = join(tempDir, 'package')\n const packageJson = JSON.parse(\n readFileSync(join(extractedPath, 'package.json'), 'utf-8')\n )\n\n return {\n packageJson,\n extractedPath,\n cleanup: () => rmSync(tempDir, { recursive: true, force: true })\n }\n } catch (error) {\n rmSync(tempDir, { recursive: true, force: true })\n throw error\n }\n}\n\nasync function fetchNpmPackage(\n packageName: string,\n version?: string\n): Promise<FetchResult> {\n const spec = version ? `${packageName}@${version}` : packageName\n const tempDir = mkdtempSync(join(tmpdir(), 'nextspark-add-'))\n\n try {\n console.log(` Downloading ${spec}...`)\n\n // npm pack descarga el .tgz sin instalar\n execSync(`npm pack ${spec} --pack-destination \"${tempDir}\"`, {\n stdio: 'pipe',\n encoding: 'utf-8'\n })\n\n const tgzFile = readdirSync(tempDir).find(f => f.endsWith('.tgz'))\n if (!tgzFile) {\n throw new Error(`Failed to download package: ${spec}`)\n }\n\n await tar.x({\n file: join(tempDir, tgzFile),\n cwd: tempDir,\n })\n\n const extractedPath = join(tempDir, 'package')\n\n if (!existsSync(extractedPath)) {\n throw new Error(`Package extraction failed for: ${spec}`)\n }\n\n const packageJson = JSON.parse(\n readFileSync(join(extractedPath, 'package.json'), 'utf-8')\n )\n\n return {\n packageJson,\n extractedPath,\n cleanup: () => rmSync(tempDir, { recursive: true, force: true })\n }\n } catch (error) {\n rmSync(tempDir, { recursive: true, force: true })\n\n // Mejorar mensaje de error\n if (error instanceof Error) {\n if (error.message.includes('404') || error.message.includes('not found')) {\n throw new Error(`Package not found: ${spec}. Verify the package name exists on npm.`)\n }\n if (error.message.includes('ENETUNREACH') || error.message.includes('ENOTFOUND')) {\n throw new Error(`Network error. Check your internet connection.`)\n }\n }\n throw error\n }\n}\n","import { existsSync, readFileSync } from 'fs'\nimport { join } from 'path'\nimport type { NextSparkPackageJson, ValidationResult, PeerDepIssue } from '../types/nextspark-package.js'\n\nexport function validatePlugin(\n packageJson: NextSparkPackageJson,\n extractedPath: string\n): ValidationResult {\n const errors: string[] = []\n const warnings: string[] = []\n const peerDepIssues: PeerDepIssue[] = []\n\n // 1. Verificar plugin.config.ts\n if (!existsSync(join(extractedPath, 'plugin.config.ts'))) {\n errors.push('Missing plugin.config.ts - not a valid NextSpark plugin')\n }\n\n // 2. Verificar nextspark metadata\n if (!packageJson.nextspark) {\n warnings.push('Missing nextspark field in package.json (recommended)')\n } else if (packageJson.nextspark.type !== 'plugin') {\n warnings.push(`nextspark.type is \"${packageJson.nextspark.type}\", expected \"plugin\"`)\n }\n\n // 3. Verificar peerDependencies\n const peerDeps = packageJson.peerDependencies || {}\n if (!peerDeps['@nextsparkjs/core']) {\n warnings.push('Plugin should have @nextsparkjs/core as peerDependency')\n }\n\n // 4. Validar compatibilidad de peerDeps con proyecto\n const projectPkgPath = join(process.cwd(), 'package.json')\n if (existsSync(projectPkgPath)) {\n const projectPkg = JSON.parse(readFileSync(projectPkgPath, 'utf-8'))\n const projectDeps = {\n ...projectPkg.dependencies,\n ...projectPkg.devDependencies\n }\n\n for (const [name, required] of Object.entries(peerDeps)) {\n const installed = projectDeps[name]\n if (!installed) {\n peerDepIssues.push({\n name,\n required: required as string,\n installed: null,\n severity: 'warning'\n })\n }\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n warnings,\n peerDepIssues\n }\n}\n\nexport function validateTheme(\n packageJson: NextSparkPackageJson,\n extractedPath: string\n): ValidationResult {\n const errors: string[] = []\n const warnings: string[] = []\n const peerDepIssues: PeerDepIssue[] = []\n\n // 1. Verificar config/theme.config.ts\n const configPath = join(extractedPath, 'config', 'theme.config.ts')\n if (!existsSync(configPath)) {\n errors.push('Missing config/theme.config.ts - not a valid NextSpark theme')\n }\n\n // 2. Verificar nextspark metadata\n if (!packageJson.nextspark) {\n warnings.push('Missing nextspark field in package.json (recommended)')\n } else if (packageJson.nextspark.type !== 'theme') {\n warnings.push(`nextspark.type is \"${packageJson.nextspark.type}\", expected \"theme\"`)\n }\n\n return {\n valid: errors.length === 0,\n errors,\n warnings,\n peerDepIssues\n }\n}\n","import { existsSync, cpSync, rmSync, mkdirSync, readFileSync, writeFileSync } from 'fs'\nimport { join } from 'path'\nimport chalk from 'chalk'\nimport type { NextSparkPackageJson, InstallOptions, InstallResult } from '../types/nextspark-package.js'\nimport { updateTsConfig, registerInPackageJson } from './config-updater.js'\n\nexport async function installPlugin(\n extractedPath: string,\n packageJson: NextSparkPackageJson,\n options: InstallOptions = {}\n): Promise<InstallResult> {\n const pluginName = extractPluginName(packageJson.name)\n const targetDir = join(process.cwd(), 'contents', 'plugins', pluginName)\n\n // Dry run: only show what would be done\n if (options.dryRun) {\n console.log(chalk.cyan('\\n [Dry Run] Would perform:'))\n console.log(` - Copy to: contents/plugins/${pluginName}/`)\n if (packageJson.dependencies && Object.keys(packageJson.dependencies).length > 0) {\n console.log(` - Install deps: ${Object.keys(packageJson.dependencies).join(', ')}`)\n }\n console.log(` - Update tsconfig.json paths`)\n console.log(` - Register in package.json`)\n return { success: true, installedPath: targetDir, name: pluginName }\n }\n\n // Check if already exists\n if (existsSync(targetDir)) {\n if (!options.force) {\n throw new Error(\n `Plugin \"${pluginName}\" already exists at ${targetDir}.\\n` +\n `Use --force to overwrite.`\n )\n }\n console.log(chalk.yellow(` Removing existing plugin...`))\n rmSync(targetDir, { recursive: true, force: true })\n }\n\n // Ensure contents/plugins directory exists\n const pluginsDir = join(process.cwd(), 'contents', 'plugins')\n if (!existsSync(pluginsDir)) {\n mkdirSync(pluginsDir, { recursive: true })\n }\n\n // Copy files\n console.log(` Copying to contents/plugins/${pluginName}/...`)\n cpSync(extractedPath, targetDir, { recursive: true })\n\n // Plugin dependencies are handled by pnpm workspaces\n // The pnpm-workspace.yaml includes contents/plugins/* so each plugin\n // gets its own node_modules when `pnpm install` is run at root\n const deps = packageJson.dependencies || {}\n const depCount = Object.keys(deps).length\n if (depCount > 0) {\n console.log(` Plugin has ${depCount} dependencies (will be installed via workspace)`)\n }\n\n // Update configs\n await updateTsConfig(pluginName, 'plugin')\n await registerInPackageJson(packageJson.name, packageJson.version || '0.0.0', 'plugin')\n\n // Register plugin in active theme's config\n await registerPluginInThemeConfig(pluginName)\n\n return {\n success: true,\n installedPath: targetDir,\n name: pluginName\n }\n}\n\nexport async function installTheme(\n extractedPath: string,\n packageJson: NextSparkPackageJson,\n options: InstallOptions = {}\n): Promise<InstallResult> {\n const themeName = extractThemeName(packageJson.name)\n const targetDir = join(process.cwd(), 'contents', 'themes', themeName)\n\n if (options.dryRun) {\n console.log(chalk.cyan('\\n [Dry Run] Would perform:'))\n console.log(` - Copy to: contents/themes/${themeName}/`)\n if (packageJson.requiredPlugins?.length) {\n console.log(` - Install required plugins: ${packageJson.requiredPlugins.join(', ')}`)\n }\n console.log(` - Update tsconfig.json paths`)\n console.log(` - Register in package.json`)\n return { success: true, installedPath: targetDir, name: themeName }\n }\n\n if (existsSync(targetDir)) {\n if (!options.force) {\n throw new Error(\n `Theme \"${themeName}\" already exists at ${targetDir}.\\n` +\n `Use --force to overwrite.`\n )\n }\n console.log(chalk.yellow(` Removing existing theme...`))\n rmSync(targetDir, { recursive: true, force: true })\n }\n\n // Ensure contents/themes directory exists\n const themesDir = join(process.cwd(), 'contents', 'themes')\n if (!existsSync(themesDir)) {\n mkdirSync(themesDir, { recursive: true })\n }\n\n // Copy files\n console.log(` Copying to contents/themes/${themeName}/...`)\n cpSync(extractedPath, targetDir, { recursive: true })\n\n // Update configs\n await updateTsConfig(themeName, 'theme')\n await registerInPackageJson(packageJson.name, packageJson.version || '0.0.0', 'theme')\n\n return {\n success: true,\n installedPath: targetDir,\n name: themeName\n }\n}\n\nfunction extractPluginName(npmName: string): string {\n return npmName\n .replace(/^@[^/]+\\//, '') // @scope/name → name\n .replace(/^nextspark-plugin-/, '') // nextspark-plugin-foo → foo\n .replace(/^plugin-/, '') // plugin-foo → foo\n}\n\nfunction extractThemeName(npmName: string): string {\n return npmName\n .replace(/^@[^/]+\\//, '') // @scope/name → name\n .replace(/^nextspark-theme-/, '') // nextspark-theme-foo → foo\n .replace(/^theme-/, '') // theme-foo → foo\n}\n\n/**\n * Register a plugin in the active theme's theme.config.ts\n */\nasync function registerPluginInThemeConfig(pluginName: string): Promise<void> {\n // Find active theme from .env\n const envPath = join(process.cwd(), '.env')\n let activeTheme = 'starter'\n\n if (existsSync(envPath)) {\n const envContent = readFileSync(envPath, 'utf-8')\n const match = envContent.match(/NEXT_PUBLIC_ACTIVE_THEME=[\"']?([^\"'\\s\\n]+)[\"']?/)\n if (match) {\n activeTheme = match[1]\n }\n }\n\n // Find theme.config.ts\n const themeConfigPath = join(process.cwd(), 'contents', 'themes', activeTheme, 'config', 'theme.config.ts')\n\n if (!existsSync(themeConfigPath)) {\n console.log(chalk.gray(` Theme config not found, skipping plugin registration`))\n return\n }\n\n try {\n let content = readFileSync(themeConfigPath, 'utf-8')\n\n // Check if plugin is already registered\n if (content.includes(`'${pluginName}'`) || content.includes(`\"${pluginName}\"`)) {\n console.log(chalk.gray(` Plugin ${pluginName} already registered in theme config`))\n return\n }\n\n // Find the plugins array and add the plugin\n // Match patterns like: plugins: [] or plugins: ['existing'] (supports multiline arrays)\n const pluginsArrayMatch = content.match(/plugins:\\s*\\[([^\\]]*)\\]/s)\n\n if (pluginsArrayMatch) {\n const existingPlugins = pluginsArrayMatch[1].trim()\n const newPlugins = existingPlugins\n ? `${existingPlugins}, '${pluginName}'`\n : `'${pluginName}'`\n\n content = content.replace(\n /plugins:\\s*\\[([^\\]]*)\\]/s,\n `plugins: [${newPlugins}]`\n )\n\n writeFileSync(themeConfigPath, content)\n console.log(` Registered plugin in theme.config.ts`)\n }\n } catch (error) {\n console.log(chalk.yellow(` Could not register plugin in theme config: ${error}`))\n }\n}\n","import { existsSync, readFileSync, writeFileSync } from 'fs'\nimport { join } from 'path'\n\nexport async function updateTsConfig(name: string, type: 'plugin' | 'theme'): Promise<void> {\n const tsconfigPath = join(process.cwd(), 'tsconfig.json')\n\n if (!existsSync(tsconfigPath)) {\n console.log(' Warning: tsconfig.json not found, skipping path update')\n return\n }\n\n try {\n const content = readFileSync(tsconfigPath, 'utf-8')\n const tsconfig = JSON.parse(content)\n\n if (!tsconfig.compilerOptions) {\n tsconfig.compilerOptions = {}\n }\n if (!tsconfig.compilerOptions.paths) {\n tsconfig.compilerOptions.paths = {}\n }\n\n const pathKey = type === 'plugin'\n ? `@plugins/${name}/*`\n : `@themes/${name}/*`\n\n const pathValue = type === 'plugin'\n ? [`./contents/plugins/${name}/*`]\n : [`./contents/themes/${name}/*`]\n\n // Solo añadir si no existe\n if (!tsconfig.compilerOptions.paths[pathKey]) {\n tsconfig.compilerOptions.paths[pathKey] = pathValue\n writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2) + '\\n')\n console.log(` Updated tsconfig.json with ${pathKey} path`)\n }\n } catch (error) {\n console.log(' Warning: Could not update tsconfig.json')\n }\n}\n\nexport async function registerInPackageJson(\n npmName: string,\n version: string,\n type: 'plugin' | 'theme'\n): Promise<void> {\n const pkgPath = join(process.cwd(), 'package.json')\n\n if (!existsSync(pkgPath)) {\n console.log(' Warning: package.json not found, skipping registration')\n return\n }\n\n try {\n const content = readFileSync(pkgPath, 'utf-8')\n const pkg = JSON.parse(content)\n\n if (!pkg.nextspark) {\n pkg.nextspark = {}\n }\n\n const key = type === 'plugin' ? 'plugins' : 'themes'\n if (!pkg.nextspark[key]) {\n pkg.nextspark[key] = []\n }\n\n // Registrar nombre y versión\n const entry = { name: npmName, version }\n const existingIndex = pkg.nextspark[key].findIndex(\n (e: { name: string }) => e.name === npmName\n )\n\n if (existingIndex >= 0) {\n pkg.nextspark[key][existingIndex] = entry\n } else {\n pkg.nextspark[key].push(entry)\n }\n\n writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\\n')\n console.log(` Registered ${type} in package.json`)\n } catch (error) {\n console.log(' Warning: Could not update package.json')\n }\n}\n","import chalk from 'chalk'\nimport type { NextSparkPackageJson, PostinstallContext } from '../../types/nextspark-package.js'\nimport { processTemplates } from './templates.js'\nimport { processEnvVars } from './env-vars.js'\nimport { registerMigrations } from './migrations.js'\nimport { runCustomScript } from './script-runner.js'\nimport { existsSync } from 'fs'\nimport { join } from 'path'\n\nexport async function runPostinstall(\n packageJson: NextSparkPackageJson,\n installedPath: string,\n context: PostinstallContext\n): Promise<void> {\n const postinstall = packageJson.nextspark?.postinstall\n if (!postinstall) {\n return\n }\n\n console.log(chalk.blue('\\n Running postinstall hooks...'))\n\n // 1. Instalar plugins requeridos (con tracking para evitar loops)\n if (postinstall.requiredPlugins?.length) {\n for (const plugin of postinstall.requiredPlugins) {\n // Evitar recursion infinita\n if (context.installingPlugins.has(plugin)) {\n console.log(chalk.yellow(` Skipping ${plugin} (already being installed)`))\n continue\n }\n\n const pluginExists = await checkPluginExists(plugin)\n if (!pluginExists) {\n console.log(` Installing required plugin: ${plugin}`)\n context.installingPlugins.add(plugin)\n\n // Importar dinamicamente para evitar dependencia circular\n const { addPlugin } = await import('../../commands/add-plugin.js')\n await addPlugin(plugin, { installingPlugins: context.installingPlugins })\n }\n }\n }\n\n // 2. Procesar templates\n if (postinstall.templates?.length) {\n const needsTheme = postinstall.templates.some(t =>\n t.to.includes('${activeTheme}')\n )\n\n if (needsTheme && !context.activeTheme) {\n console.log(chalk.yellow('\\n Warning: Templates require an active theme but none detected.'))\n console.log(chalk.gray(' Set NEXT_PUBLIC_ACTIVE_THEME or install a theme first.'))\n console.log(chalk.gray(' Skipping template installation.\\n'))\n } else {\n await processTemplates(postinstall.templates, installedPath, context)\n }\n }\n\n // 3. Variables de entorno\n if (postinstall.envVars?.length) {\n await processEnvVars(postinstall.envVars)\n }\n\n // 4. Migrations\n if (postinstall.migrations?.length) {\n await registerMigrations(postinstall.migrations, installedPath)\n }\n\n // 5. Script custom (CON CONFIRMACION)\n if (postinstall.script) {\n await runCustomScript(postinstall.script, installedPath, context)\n }\n\n // 6. Mensajes finales\n if (postinstall.messages) {\n console.log('')\n if (postinstall.messages.success) {\n console.log(chalk.green(` ${postinstall.messages.success}`))\n }\n if (postinstall.messages.docs) {\n console.log(chalk.gray(` Docs: ${postinstall.messages.docs}`))\n }\n if (postinstall.messages.nextSteps?.length) {\n console.log(chalk.blue('\\n Next steps:'))\n postinstall.messages.nextSteps.forEach((step, i) => {\n console.log(chalk.gray(` ${i + 1}. ${step}`))\n })\n }\n }\n}\n\nasync function checkPluginExists(pluginName: string): Promise<boolean> {\n const name = pluginName\n .replace(/^@[^/]+\\//, '')\n .replace(/^nextspark-plugin-/, '')\n .replace(/^plugin-/, '')\n\n return existsSync(join(process.cwd(), 'contents', 'plugins', name))\n}\n\nexport { PostinstallContext }\n","import { existsSync, cpSync, mkdirSync } from 'fs'\nimport { join, dirname } from 'path'\nimport chalk from 'chalk'\nimport type { PostinstallContext } from '../../types/nextspark-package.js'\n\ninterface TemplateConfig {\n from: string\n to: string\n condition?: 'exists' | '!exists' | 'always' | 'prompt'\n description?: string\n}\n\nexport async function processTemplates(\n templates: TemplateConfig[],\n sourcePath: string,\n context: PostinstallContext\n): Promise<void> {\n for (const template of templates) {\n const from = join(sourcePath, template.from)\n const to = resolveVariables(template.to, context)\n\n if (!existsSync(from)) {\n console.log(chalk.yellow(` Warning: Template source not found: ${template.from}`))\n continue\n }\n\n const targetExists = existsSync(to)\n const condition = template.condition || '!exists'\n const desc = template.description || template.to\n\n switch (condition) {\n case '!exists':\n if (targetExists) {\n console.log(chalk.gray(` Skipping ${desc} (already exists)`))\n continue\n }\n break\n\n case 'exists':\n if (!targetExists) {\n console.log(chalk.gray(` Skipping ${desc} (target doesn't exist)`))\n continue\n }\n break\n\n case 'prompt':\n if (targetExists) {\n // For now, skip if exists when prompting not implemented\n console.log(chalk.gray(` Skipping ${desc} (already exists, use --force to overwrite)`))\n continue\n }\n break\n\n case 'always':\n break\n }\n\n const parentDir = dirname(to)\n if (!existsSync(parentDir)) {\n mkdirSync(parentDir, { recursive: true })\n }\n\n console.log(chalk.gray(` Copying ${desc}...`))\n cpSync(from, to, { recursive: true })\n }\n}\n\nfunction resolveVariables(path: string, context: PostinstallContext): string {\n let resolved = path\n\n if (context.activeTheme) {\n resolved = resolved.replace(/\\$\\{activeTheme\\}/g, context.activeTheme)\n }\n resolved = resolved.replace(/\\$\\{projectRoot\\}/g, context.projectRoot)\n resolved = resolved.replace(/\\$\\{timestamp\\}/g, context.timestamp.toString())\n resolved = resolved.replace(/\\$\\{coreVersion\\}/g, context.coreVersion)\n\n if (context.pluginName) {\n resolved = resolved.replace(/\\$\\{pluginName\\}/g, context.pluginName)\n }\n if (context.themeName) {\n resolved = resolved.replace(/\\$\\{themeName\\}/g, context.themeName)\n }\n\n const unresolvedMatch = resolved.match(/\\$\\{([^}]+)\\}/)\n if (unresolvedMatch) {\n throw new Error(`Unresolved template variable: ${unresolvedMatch[0]}`)\n }\n\n if (!resolved.startsWith('/')) {\n resolved = join(context.projectRoot, resolved)\n }\n\n return resolved\n}\n","import { existsSync, readFileSync, writeFileSync, appendFileSync } from 'fs'\nimport { join } from 'path'\nimport chalk from 'chalk'\n\ninterface EnvVarConfig {\n key: string\n description: string\n required: boolean\n default?: string\n}\n\nexport async function processEnvVars(envVars: EnvVarConfig[]): Promise<void> {\n const envExamplePath = join(process.cwd(), '.env.example')\n const envPath = join(process.cwd(), '.env')\n\n let added = 0\n\n // Read existing vars to avoid duplicates\n const existingVars = new Set<string>()\n if (existsSync(envExamplePath)) {\n const content = readFileSync(envExamplePath, 'utf-8')\n const matches = content.match(/^[A-Z_][A-Z0-9_]*=/gm)\n if (matches) {\n matches.forEach(m => existingVars.add(m.replace('=', '')))\n }\n }\n\n const newLines: string[] = []\n\n for (const envVar of envVars) {\n if (existingVars.has(envVar.key)) {\n continue\n }\n\n const value = envVar.default || ''\n const requiredMark = envVar.required ? ' (required)' : ''\n newLines.push(`# ${envVar.description}${requiredMark}`)\n newLines.push(`${envVar.key}=${value}`)\n newLines.push('')\n added++\n }\n\n if (newLines.length > 0) {\n const content = '\\n' + newLines.join('\\n')\n\n if (existsSync(envExamplePath)) {\n appendFileSync(envExamplePath, content)\n } else {\n writeFileSync(envExamplePath, content.trim() + '\\n')\n }\n\n console.log(chalk.gray(` Added ${added} env vars to .env.example`))\n }\n}\n","import { existsSync, mkdirSync, cpSync } from 'fs'\nimport { join, basename } from 'path'\nimport chalk from 'chalk'\n\nexport async function registerMigrations(\n migrations: string[],\n installedPath: string\n): Promise<void> {\n const migrationsDir = join(process.cwd(), 'migrations')\n\n if (!existsSync(migrationsDir)) {\n mkdirSync(migrationsDir, { recursive: true })\n }\n\n let copied = 0\n\n for (const migration of migrations) {\n const sourcePath = join(installedPath, migration)\n\n if (!existsSync(sourcePath)) {\n console.log(chalk.yellow(` Warning: Migration not found: ${migration}`))\n continue\n }\n\n const fileName = basename(migration)\n const targetPath = join(migrationsDir, fileName)\n\n if (existsSync(targetPath)) {\n console.log(chalk.gray(` Migration ${fileName} already exists, skipping`))\n continue\n }\n\n cpSync(sourcePath, targetPath)\n copied++\n }\n\n if (copied > 0) {\n console.log(chalk.gray(` Copied ${copied} migration(s) to /migrations`))\n }\n}\n","import { existsSync } from 'fs'\nimport { join } from 'path'\nimport chalk from 'chalk'\nimport type { PostinstallContext } from '../../types/nextspark-package.js'\n\nexport async function runCustomScript(\n scriptPath: string,\n installedPath: string,\n context: PostinstallContext\n): Promise<void> {\n const fullPath = join(installedPath, scriptPath)\n\n if (!existsSync(fullPath)) {\n console.log(chalk.yellow(` Warning: Postinstall script not found: ${scriptPath}`))\n return\n }\n\n console.log('')\n console.log(chalk.yellow(' Warning: This package wants to run a custom postinstall script:'))\n console.log(chalk.gray(` ${scriptPath}`))\n console.log('')\n console.log(chalk.gray(' Custom scripts can execute arbitrary code.'))\n console.log(chalk.gray(' Only allow if you trust the package author.'))\n console.log(chalk.gray(' Skipping script execution (manual approval required).'))\n console.log('')\n\n // In MVP, we skip custom scripts by default for security\n // In future versions, we could add --allow-scripts flag or prompts\n}\n","import { existsSync, readFileSync, readdirSync } from 'node:fs'\nimport { join } from 'node:path'\n\n/**\n * Detects the currently active theme in the project\n * Priority:\n * 1. NEXT_PUBLIC_ACTIVE_THEME environment variable\n * 2. activeTheme in nextspark.config.ts\n * 3. NEXT_PUBLIC_ACTIVE_THEME in .env file\n * 4. Single installed theme (if only one exists)\n * 5. null if cannot be determined\n */\nexport function detectActiveTheme(): string | null {\n // 1. Environment variable (for CI/CD and development)\n if (process.env.NEXT_PUBLIC_ACTIVE_THEME) {\n return process.env.NEXT_PUBLIC_ACTIVE_THEME\n }\n\n // 2. nextspark.config.ts (project configuration) - simplified check\n const configPath = join(process.cwd(), 'nextspark.config.ts')\n if (existsSync(configPath)) {\n try {\n const content = readFileSync(configPath, 'utf-8')\n // Simple regex to extract activeTheme value\n const match = content.match(/activeTheme\\s*:\\s*['\"]([^'\"]+)['\"]/)\n if (match) {\n return match[1]\n }\n } catch {\n // Ignore read errors\n }\n }\n\n // 3. .env file\n const envPath = join(process.cwd(), '.env')\n if (existsSync(envPath)) {\n try {\n const content = readFileSync(envPath, 'utf-8')\n const match = content.match(/NEXT_PUBLIC_ACTIVE_THEME=(.+)/)\n if (match) {\n return match[1].trim()\n }\n } catch {\n // Ignore read errors\n }\n }\n\n // 4. Single installed theme\n const themesDir = join(process.cwd(), 'contents', 'themes')\n if (existsSync(themesDir)) {\n try {\n const themes = readdirSync(themesDir, { withFileTypes: true })\n .filter((d) => d.isDirectory())\n .map((d) => d.name)\n if (themes.length === 1) {\n return themes[0]\n }\n } catch {\n // Ignore read errors\n }\n }\n\n // 5. Cannot determine\n return null\n}\n\n/**\n * Returns a list of all available themes in the project\n */\nexport function getAvailableThemes(): string[] {\n const themesDir = join(process.cwd(), 'contents', 'themes')\n if (!existsSync(themesDir)) {\n return []\n }\n\n try {\n return readdirSync(themesDir, { withFileTypes: true })\n .filter((d) => d.isDirectory())\n .map((d) => d.name)\n } catch {\n return []\n }\n}\n"],"mappings":";AAAA,OAAOA,YAAW;AAClB,OAAO,SAAS;;;ACDhB,SAAS,gBAAgB;AACzB,SAAS,aAAa,aAAa,QAAQ,YAAY,cAAc,oBAAoB;AACzF,SAAS,cAAc;AACvB,SAAS,MAAM,kBAAkB;AACjC,YAAY,SAAS;AAGrB,eAAsB,aACpB,aACA,SACsB;AAEtB,MAAI,YAAY,SAAS,MAAM,KAAK,YAAY,WAAW,IAAI,KAAK,YAAY,WAAW,GAAG,KAAK,WAAW,WAAW,GAAG;AAC1H,WAAO,kBAAkB,WAAW;AAAA,EACtC;AAEA,SAAO,gBAAgB,aAAa,OAAO;AAC7C;AAEA,eAAe,kBAAkB,UAAwC;AACvE,QAAM,eAAe,WAAW,QAAQ,IACpC,WACA,KAAK,QAAQ,IAAI,GAAG,QAAQ;AAEhC,MAAI,CAAC,WAAW,YAAY,GAAG;AAC7B,UAAM,IAAI,MAAM,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D,OAAK,QAAQ,IAAI,GAAG,gBAAgB,gBAAgB,QAAQ,cAAc;AAC1F,MAAIF,aAAW,OAAO,GAAG;AACvB,QAAI;AACF,YAAM,MAAM,KAAK,MAAMC,cAAa,SAAS,OAAO,CAAC;AACrD,aAAO,IAAI,WAAW;AAAA,IACxB,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,iBAAiB,aAAqB,SAAiD;AACrG,SAAO,UAAU,aAAa;AAAA,IAC5B,OAAO,QAAQ;AAAA,IACf,UAAU,QAAQ;AAAA,IAClB,QAAQ,QAAQ;AAAA,IAChB,iBAAiB,QAAQ;AAAA,IACzB,SAAS,QAAQ;AAAA,EACnB,CAAC;AACH;","names":["chalk","existsSync","readFileSync","join","existsSync","rmSync","readFileSync","writeFileSync","join","existsSync","readFileSync","join","join","existsSync","rmSync","readFileSync","writeFileSync","chalk","existsSync","cpSync","mkdirSync","join","chalk","existsSync","readFileSync","writeFileSync","join","chalk","existsSync","mkdirSync","cpSync","join","chalk","existsSync","join","chalk","existsSync","join","chalk","addPlugin","existsSync","readFileSync","readdirSync","join","existsSync","readFileSync","join","chalk"]}
@@ -1,11 +0,0 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
- export {
9
- __require
10
- };
11
- //# sourceMappingURL=chunk-DGUM43GV.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,435 +0,0 @@
1
- // src/utils/paths.ts
2
- import { existsSync } from "fs";
3
- import { resolve, join, dirname } from "path";
4
- import { fileURLToPath } from "url";
5
- var __filename = fileURLToPath(import.meta.url);
6
- var __dirname = dirname(__filename);
7
- function getCoreDir() {
8
- const cwd = process.cwd();
9
- const npmCorePath = resolve(cwd, "node_modules", "@nextsparkjs", "core");
10
- if (existsSync(npmCorePath)) {
11
- return npmCorePath;
12
- }
13
- const monorepoCorePath = resolve(__dirname, "..", "..", "..", "..", "core");
14
- if (existsSync(monorepoCorePath)) {
15
- return monorepoCorePath;
16
- }
17
- const cwdMonorepoCorePath = resolve(cwd, "..", "..", "packages", "core");
18
- if (existsSync(cwdMonorepoCorePath)) {
19
- return cwdMonorepoCorePath;
20
- }
21
- throw new Error(
22
- "Could not find @nextsparkjs/core. Make sure it is installed as a dependency or you are running from within the monorepo."
23
- );
24
- }
25
- function getCoreScriptPath(scriptName) {
26
- const coreDir = getCoreDir();
27
- return resolve(coreDir, "scripts", `${scriptName}.js`);
28
- }
29
- function getProjectRoot() {
30
- return process.cwd();
31
- }
32
- function isMonorepoMode() {
33
- const cwd = process.cwd();
34
- const npmCorePath = resolve(cwd, "node_modules", "@nextsparkjs", "core");
35
- return !existsSync(npmCorePath);
36
- }
37
- function getAIWorkflowDir() {
38
- const cwd = process.cwd();
39
- const nmPath = join(cwd, "node_modules", "@nextsparkjs", "ai-workflow");
40
- if (existsSync(nmPath)) return nmPath;
41
- const webNmPath = join(cwd, "web", "node_modules", "@nextsparkjs", "ai-workflow");
42
- if (existsSync(webNmPath)) return webNmPath;
43
- const monoPath = join(cwd, "packages", "ai-workflow");
44
- if (existsSync(monoPath)) return monoPath;
45
- return null;
46
- }
47
-
48
- // src/commands/dev.ts
49
- import { spawn } from "child_process";
50
- import chalk from "chalk";
51
- import ora from "ora";
52
- async function devCommand(options) {
53
- const spinner = ora("Starting development environment...").start();
54
- try {
55
- const coreDir = getCoreDir();
56
- const projectRoot = getProjectRoot();
57
- const mode = isMonorepoMode() ? "monorepo" : "npm";
58
- spinner.succeed(`Core found at: ${coreDir} (${mode} mode)`);
59
- const processes = [];
60
- if (options.registry) {
61
- console.log(chalk.blue("\n[Registry] Starting registry builder with watch mode..."));
62
- const registryProcess = spawn("node", ["scripts/build/registry.mjs", "--watch"], {
63
- cwd: coreDir,
64
- stdio: "inherit",
65
- env: {
66
- ...process.env,
67
- NEXTSPARK_PROJECT_ROOT: projectRoot
68
- }
69
- });
70
- processes.push(registryProcess);
71
- registryProcess.on("error", (err) => {
72
- console.error(chalk.red(`[Registry] Error: ${err.message}`));
73
- });
74
- }
75
- console.log(chalk.green(`
76
- [Dev] Starting Next.js dev server on port ${options.port}...`));
77
- const devProcess = spawn("npx", ["next", "dev", "-p", options.port], {
78
- cwd: projectRoot,
79
- stdio: "inherit",
80
- shell: true,
81
- env: {
82
- ...process.env,
83
- NEXTSPARK_CORE_DIR: coreDir
84
- }
85
- });
86
- processes.push(devProcess);
87
- devProcess.on("error", (err) => {
88
- console.error(chalk.red(`[Dev] Error: ${err.message}`));
89
- process.exit(1);
90
- });
91
- const cleanup = () => {
92
- console.log(chalk.yellow("\nShutting down..."));
93
- processes.forEach((p) => {
94
- if (!p.killed) {
95
- p.kill("SIGTERM");
96
- }
97
- });
98
- process.exit(0);
99
- };
100
- process.on("SIGINT", cleanup);
101
- process.on("SIGTERM", cleanup);
102
- devProcess.on("exit", (code) => {
103
- cleanup();
104
- process.exit(code ?? 0);
105
- });
106
- } catch (error) {
107
- spinner.fail("Failed to start development environment");
108
- if (error instanceof Error) {
109
- console.error(chalk.red(error.message));
110
- }
111
- process.exit(1);
112
- }
113
- }
114
-
115
- // src/commands/build.ts
116
- import { spawn as spawn2 } from "child_process";
117
- import { existsSync as existsSync2, readFileSync } from "fs";
118
- import { join as join2 } from "path";
119
- import chalk2 from "chalk";
120
- import ora2 from "ora";
121
- function loadProjectEnv(projectRoot) {
122
- const envPath = join2(projectRoot, ".env");
123
- const envVars = {};
124
- if (existsSync2(envPath)) {
125
- const content = readFileSync(envPath, "utf-8");
126
- for (const line of content.split("\n")) {
127
- const trimmed = line.trim();
128
- if (trimmed && !trimmed.startsWith("#")) {
129
- const [key, ...valueParts] = trimmed.split("=");
130
- if (key && valueParts.length > 0) {
131
- let value = valueParts.join("=");
132
- if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
133
- value = value.slice(1, -1);
134
- }
135
- envVars[key] = value;
136
- }
137
- }
138
- }
139
- }
140
- return envVars;
141
- }
142
- async function buildCommand(options) {
143
- const spinner = ora2("Preparing production build...").start();
144
- try {
145
- const coreDir = getCoreDir();
146
- const projectRoot = getProjectRoot();
147
- spinner.succeed("Core package found");
148
- const projectEnv = loadProjectEnv(projectRoot);
149
- if (options.registry) {
150
- spinner.start("Generating registries...");
151
- await new Promise((resolve2, reject) => {
152
- const registryProcess = spawn2("node", ["scripts/build/registry.mjs"], {
153
- cwd: coreDir,
154
- stdio: "pipe",
155
- env: {
156
- ...projectEnv,
157
- ...process.env,
158
- NEXTSPARK_PROJECT_ROOT: projectRoot
159
- }
160
- });
161
- let stderr = "";
162
- registryProcess.stderr?.on("data", (data) => {
163
- stderr += data.toString();
164
- });
165
- registryProcess.on("close", (code) => {
166
- if (code === 0) {
167
- resolve2();
168
- } else {
169
- reject(new Error(`Registry generation failed: ${stderr}`));
170
- }
171
- });
172
- registryProcess.on("error", reject);
173
- });
174
- spinner.succeed("Registries generated");
175
- }
176
- spinner.start("Building for production...");
177
- const buildProcess = spawn2("npx", ["next", "build"], {
178
- cwd: projectRoot,
179
- stdio: "inherit",
180
- shell: true,
181
- env: {
182
- ...projectEnv,
183
- ...process.env,
184
- NEXTSPARK_CORE_DIR: coreDir,
185
- NODE_ENV: "production"
186
- }
187
- });
188
- buildProcess.on("error", (err) => {
189
- spinner.fail("Build failed");
190
- console.error(chalk2.red(err.message));
191
- process.exit(1);
192
- });
193
- buildProcess.on("close", (code) => {
194
- if (code === 0) {
195
- console.log(chalk2.green("\nBuild completed successfully!"));
196
- process.exit(0);
197
- } else {
198
- console.error(chalk2.red(`
199
- Build failed with exit code ${code}`));
200
- process.exit(code ?? 1);
201
- }
202
- });
203
- } catch (error) {
204
- spinner.fail("Build preparation failed");
205
- if (error instanceof Error) {
206
- console.error(chalk2.red(error.message));
207
- }
208
- process.exit(1);
209
- }
210
- }
211
-
212
- // src/commands/generate.ts
213
- import { spawn as spawn3 } from "child_process";
214
- import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
215
- import { join as join3 } from "path";
216
- import chalk3 from "chalk";
217
- import ora3 from "ora";
218
- function loadProjectEnv2(projectRoot) {
219
- const envPath = join3(projectRoot, ".env");
220
- const envVars = {};
221
- if (existsSync3(envPath)) {
222
- const content = readFileSync2(envPath, "utf-8");
223
- for (const line of content.split("\n")) {
224
- const trimmed = line.trim();
225
- if (trimmed && !trimmed.startsWith("#")) {
226
- const [key, ...valueParts] = trimmed.split("=");
227
- if (key && valueParts.length > 0) {
228
- let value = valueParts.join("=");
229
- if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
230
- value = value.slice(1, -1);
231
- }
232
- envVars[key] = value;
233
- }
234
- }
235
- }
236
- }
237
- return envVars;
238
- }
239
- async function generateCommand(options) {
240
- const spinner = ora3("Preparing registry generation...").start();
241
- try {
242
- const coreDir = getCoreDir();
243
- const projectRoot = getProjectRoot();
244
- const mode = isMonorepoMode() ? "monorepo" : "npm";
245
- spinner.succeed(`Core found at: ${coreDir} (${mode} mode)`);
246
- const projectEnv = loadProjectEnv2(projectRoot);
247
- const watchArg = options.watch ? ["--watch"] : [];
248
- const action = options.watch ? "Watching" : "Generating";
249
- console.log(chalk3.blue(`
250
- ${action} registries...`));
251
- const generateProcess = spawn3("node", ["scripts/build/registry.mjs", ...watchArg], {
252
- cwd: coreDir,
253
- stdio: "inherit",
254
- env: {
255
- ...projectEnv,
256
- ...process.env,
257
- NEXTSPARK_PROJECT_ROOT: projectRoot
258
- }
259
- });
260
- generateProcess.on("error", (err) => {
261
- console.error(chalk3.red(`Error: ${err.message}`));
262
- process.exit(1);
263
- });
264
- generateProcess.on("close", (code) => {
265
- if (code === 0) {
266
- if (!options.watch) {
267
- console.log(chalk3.green("\nRegistry generation completed!"));
268
- }
269
- process.exit(0);
270
- } else {
271
- console.error(chalk3.red(`
272
- Registry generation failed with exit code ${code}`));
273
- process.exit(code ?? 1);
274
- }
275
- });
276
- if (options.watch) {
277
- const cleanup = () => {
278
- console.log(chalk3.yellow("\nStopping watcher..."));
279
- if (!generateProcess.killed) {
280
- generateProcess.kill("SIGTERM");
281
- }
282
- process.exit(0);
283
- };
284
- process.on("SIGINT", cleanup);
285
- process.on("SIGTERM", cleanup);
286
- }
287
- } catch (error) {
288
- spinner.fail("Registry generation failed");
289
- if (error instanceof Error) {
290
- console.error(chalk3.red(error.message));
291
- }
292
- process.exit(1);
293
- }
294
- }
295
-
296
- // src/commands/registry.ts
297
- import { spawn as spawn4 } from "child_process";
298
- import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
299
- import { join as join4 } from "path";
300
- import chalk4 from "chalk";
301
- import ora4 from "ora";
302
- function loadProjectEnv3(projectRoot) {
303
- const envPath = join4(projectRoot, ".env");
304
- const envVars = {};
305
- if (existsSync4(envPath)) {
306
- const content = readFileSync3(envPath, "utf-8");
307
- for (const line of content.split("\n")) {
308
- const trimmed = line.trim();
309
- if (trimmed && !trimmed.startsWith("#")) {
310
- const [key, ...valueParts] = trimmed.split("=");
311
- if (key && valueParts.length > 0) {
312
- let value = valueParts.join("=");
313
- if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
314
- value = value.slice(1, -1);
315
- }
316
- envVars[key] = value;
317
- }
318
- }
319
- }
320
- }
321
- return envVars;
322
- }
323
- async function registryBuildCommand() {
324
- const spinner = ora4("Building registries...").start();
325
- try {
326
- const coreDir = getCoreDir();
327
- const projectRoot = getProjectRoot();
328
- const mode = isMonorepoMode() ? "monorepo" : "npm";
329
- const projectEnv = loadProjectEnv3(projectRoot);
330
- spinner.text = `Building registries (${mode} mode)...`;
331
- const buildProcess = spawn4("node", ["scripts/build/registry.mjs"], {
332
- cwd: coreDir,
333
- stdio: "pipe",
334
- env: {
335
- ...projectEnv,
336
- ...process.env,
337
- NEXTSPARK_PROJECT_ROOT: projectRoot
338
- }
339
- });
340
- let stdout = "";
341
- let stderr = "";
342
- buildProcess.stdout?.on("data", (data) => {
343
- stdout += data.toString();
344
- });
345
- buildProcess.stderr?.on("data", (data) => {
346
- stderr += data.toString();
347
- });
348
- buildProcess.on("close", (code) => {
349
- if (code === 0) {
350
- spinner.succeed("Registries built successfully");
351
- if (stdout.trim()) {
352
- console.log(chalk4.gray(stdout.trim()));
353
- }
354
- process.exit(0);
355
- } else {
356
- spinner.fail("Registry build failed");
357
- if (stderr.trim()) {
358
- console.error(chalk4.red(stderr.trim()));
359
- }
360
- process.exit(code ?? 1);
361
- }
362
- });
363
- buildProcess.on("error", (err) => {
364
- spinner.fail("Registry build failed");
365
- console.error(chalk4.red(err.message));
366
- process.exit(1);
367
- });
368
- } catch (error) {
369
- spinner.fail("Registry build failed");
370
- if (error instanceof Error) {
371
- console.error(chalk4.red(error.message));
372
- }
373
- process.exit(1);
374
- }
375
- }
376
- async function registryWatchCommand() {
377
- const spinner = ora4("Starting registry watcher...").start();
378
- try {
379
- const coreDir = getCoreDir();
380
- const projectRoot = getProjectRoot();
381
- const mode = isMonorepoMode() ? "monorepo" : "npm";
382
- spinner.succeed(`Registry watcher started (${mode} mode)`);
383
- console.log(chalk4.blue("\nWatching for changes... Press Ctrl+C to stop.\n"));
384
- const projectEnv = loadProjectEnv3(projectRoot);
385
- const watchProcess = spawn4("node", ["scripts/build/registry.mjs", "--watch"], {
386
- cwd: coreDir,
387
- stdio: "inherit",
388
- env: {
389
- ...projectEnv,
390
- ...process.env,
391
- NEXTSPARK_PROJECT_ROOT: projectRoot
392
- }
393
- });
394
- watchProcess.on("error", (err) => {
395
- console.error(chalk4.red(`Watcher error: ${err.message}`));
396
- process.exit(1);
397
- });
398
- const cleanup = () => {
399
- console.log(chalk4.yellow("\nStopping registry watcher..."));
400
- if (!watchProcess.killed) {
401
- watchProcess.kill("SIGTERM");
402
- }
403
- process.exit(0);
404
- };
405
- process.on("SIGINT", cleanup);
406
- process.on("SIGTERM", cleanup);
407
- watchProcess.on("close", (code) => {
408
- if (code !== 0) {
409
- console.error(chalk4.red(`
410
- Watcher exited with code ${code}`));
411
- }
412
- process.exit(code ?? 0);
413
- });
414
- } catch (error) {
415
- spinner.fail("Failed to start registry watcher");
416
- if (error instanceof Error) {
417
- console.error(chalk4.red(error.message));
418
- }
419
- process.exit(1);
420
- }
421
- }
422
-
423
- export {
424
- getCoreDir,
425
- getCoreScriptPath,
426
- getProjectRoot,
427
- isMonorepoMode,
428
- getAIWorkflowDir,
429
- devCommand,
430
- buildCommand,
431
- generateCommand,
432
- registryBuildCommand,
433
- registryWatchCommand
434
- };
435
- //# sourceMappingURL=chunk-QXD4PBX6.js.map