@betterstart/cli 0.1.0 → 0.1.1
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/dist/{chunk-GEH43BA4.js → chunk-G4KI4DVB.js} +2 -2
- package/dist/{chunk-46UVIUJF.js → chunk-J2XUG4RG.js} +9 -3
- package/dist/chunk-J2XUG4RG.js.map +1 -0
- package/dist/{chunk-PWRI4LKM.js → chunk-NKRQYAS6.js} +56 -56
- package/dist/chunk-NKRQYAS6.js.map +1 -0
- package/dist/cli.js +3 -3
- package/dist/config/index.d.ts +4 -89
- package/dist/config/index.js +2 -2
- package/dist/core/index.js +2 -2
- package/dist/import-resolver-BaZ-rzkH.d.ts +123 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.d.ts +2 -2
- package/dist/{types-BouTOvVr.d.ts → types-eI549DEG.d.ts} +1 -1
- package/package.json +3 -2
- package/dist/chunk-46UVIUJF.js.map +0 -1
- package/dist/chunk-PWRI4LKM.js.map +0 -1
- package/dist/import-resolver-BJOCLFnH.d.ts +0 -38
- /package/dist/{chunk-GEH43BA4.js.map → chunk-G4KI4DVB.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ImportResolver,
|
|
3
3
|
MONOREPO_IMPORT_PATHS
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NKRQYAS6.js";
|
|
5
5
|
|
|
6
6
|
// src/utils.ts
|
|
7
7
|
import fs from "fs";
|
|
@@ -176,4 +176,4 @@ export {
|
|
|
176
176
|
quotePropertyName,
|
|
177
177
|
singularizeLabel
|
|
178
178
|
};
|
|
179
|
-
//# sourceMappingURL=chunk-
|
|
179
|
+
//# sourceMappingURL=chunk-G4KI4DVB.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
detectPreset,
|
|
3
3
|
getDefaultConfig,
|
|
4
4
|
getPreset
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-NKRQYAS6.js";
|
|
6
6
|
import {
|
|
7
7
|
ConfigurationError,
|
|
8
8
|
getLogger
|
|
@@ -36,7 +36,13 @@ async function loadConfigFile(configPath) {
|
|
|
36
36
|
const content = fs.readFileSync(configPath, "utf-8");
|
|
37
37
|
return JSON.parse(content);
|
|
38
38
|
}
|
|
39
|
-
if (ext === ".ts"
|
|
39
|
+
if (ext === ".ts") {
|
|
40
|
+
const { createJiti } = await import("jiti");
|
|
41
|
+
const jiti = createJiti(import.meta.url);
|
|
42
|
+
const module = await jiti.import(configPath);
|
|
43
|
+
return module.default || module;
|
|
44
|
+
}
|
|
45
|
+
if (ext === ".js" || ext === ".mjs") {
|
|
40
46
|
const configUrl = `file://${configPath}`;
|
|
41
47
|
const module = await import(configUrl);
|
|
42
48
|
return module.default || module;
|
|
@@ -220,4 +226,4 @@ export {
|
|
|
220
226
|
validateConfig,
|
|
221
227
|
checkPaths
|
|
222
228
|
};
|
|
223
|
-
//# sourceMappingURL=chunk-
|
|
229
|
+
//# sourceMappingURL=chunk-J2XUG4RG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/config/loader.ts"],"sourcesContent":["/**\n * Configuration loader for @betterstart/cli\n * Handles loading, merging, and resolving configuration\n */\n\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport { ConfigurationError } from '../core/errors'\nimport { getLogger } from '../core/logger'\nimport { detectPreset, getDefaultConfig, getPreset } from './presets'\nimport type { BetterstartConfig, ResolvedConfig, ResolvedPaths, UserConfig } from './types'\n\n// ============================================================================\n// Configuration File Names\n// ============================================================================\n\n/**\n * Supported configuration file names (in priority order)\n */\nexport const CONFIG_FILE_NAMES = [\n 'betterstart.config.ts',\n 'betterstart.config.js',\n 'betterstart.config.mjs',\n 'betterstart.config.json',\n '.betterstartrc.json',\n '.betterstartrc'\n]\n\n// ============================================================================\n// Configuration Loading\n// ============================================================================\n\n/**\n * Find the configuration file in a directory\n * @param cwd - Directory to search in\n * @returns Path to the config file or undefined if not found\n */\nexport function findConfigFile(cwd: string): string | undefined {\n for (const fileName of CONFIG_FILE_NAMES) {\n const filePath = path.join(cwd, fileName)\n if (fs.existsSync(filePath)) {\n return filePath\n }\n }\n return undefined\n}\n\n/**\n * Load configuration from a file\n * @param configPath - Path to the configuration file\n * @returns The loaded configuration\n */\nexport async function loadConfigFile(configPath: string): Promise<UserConfig> {\n const ext = path.extname(configPath)\n const logger = getLogger()\n\n try {\n if (ext === '.json' || configPath.endsWith('.betterstartrc')) {\n // Load JSON config\n const content = fs.readFileSync(configPath, 'utf-8')\n return JSON.parse(content) as UserConfig\n }\n\n if (ext === '.ts') {\n // Use jiti to transpile TypeScript config at runtime\n const { createJiti } = await import('jiti')\n const jiti = createJiti(import.meta.url)\n const module = await jiti.import(configPath)\n return ((module as Record<string, unknown>).default || module) as UserConfig\n }\n\n if (ext === '.js' || ext === '.mjs') {\n const configUrl = `file://${configPath}`\n const module = await import(configUrl)\n return (module.default || module) as UserConfig\n }\n\n throw new ConfigurationError(`Unsupported config file type: ${ext}`, { path: configPath })\n } catch (error) {\n if (error instanceof ConfigurationError) {\n throw error\n }\n logger.error(`Failed to load config file: ${configPath}`)\n throw new ConfigurationError(\n `Failed to load configuration from ${configPath}: ${error instanceof Error ? error.message : String(error)}`,\n { path: configPath, originalError: error }\n )\n }\n}\n\n/**\n * Deep merge two configuration objects\n * Arrays are replaced, not merged\n */\nfunction deepMerge<T extends Record<string, unknown>>(base: T, override: Partial<T>): T {\n const result = { ...base }\n\n for (const key of Object.keys(override) as Array<keyof T>) {\n const baseValue = base[key]\n const overrideValue = override[key]\n\n if (overrideValue === undefined) {\n continue\n }\n\n if (\n typeof baseValue === 'object' &&\n baseValue !== null &&\n !Array.isArray(baseValue) &&\n typeof overrideValue === 'object' &&\n overrideValue !== null &&\n !Array.isArray(overrideValue)\n ) {\n // Recursively merge objects\n result[key] = deepMerge(\n baseValue as Record<string, unknown>,\n overrideValue as Record<string, unknown>\n ) as T[keyof T]\n } else {\n // Replace arrays and primitives\n result[key] = overrideValue as T[keyof T]\n }\n }\n\n return result\n}\n\n/**\n * Load configuration from a directory\n * Automatically finds and loads the config file, or uses defaults\n *\n * @param cwd - Directory to load config from (defaults to process.cwd())\n * @param presetName - Optional preset name to use as base\n * @returns The loaded and merged configuration\n */\nexport async function loadConfig(cwd?: string, presetName?: string): Promise<BetterstartConfig> {\n const workingDir = cwd || process.cwd()\n const logger = getLogger()\n\n // Get base configuration from preset or auto-detection\n let baseConfig: UserConfig\n if (presetName) {\n const preset = getPreset(presetName)\n if (!preset) {\n throw new ConfigurationError(`Unknown preset: ${presetName}`, {\n availablePresets: ['nextjs-monorepo', 'nextjs-standalone', 'custom']\n })\n }\n baseConfig = preset.config\n logger.debug(`Using preset: ${presetName}`)\n } else {\n baseConfig = getDefaultConfig(workingDir)\n const detectedPreset = detectPreset(workingDir)\n logger.debug(`Auto-detected preset: ${detectedPreset.name}`)\n }\n\n // Look for config file\n const configPath = findConfigFile(workingDir)\n let userConfig: UserConfig = {}\n\n if (configPath) {\n logger.debug(`Loading config from: ${configPath}`)\n userConfig = await loadConfigFile(configPath)\n }\n\n // Merge configurations\n const mergedConfig = deepMerge(\n baseConfig as Record<string, unknown>,\n userConfig as Record<string, unknown>\n )\n\n return mergedConfig as unknown as BetterstartConfig\n}\n\n// ============================================================================\n// Path Resolution\n// ============================================================================\n\n/**\n * Find the project root directory\n * Looks for common root indicators (package.json, pnpm-workspace.yaml, turbo.json)\n *\n * @param startDir - Directory to start searching from\n * @returns The project root directory\n */\nexport function findProjectRoot(startDir: string): string {\n let currentDir = path.resolve(startDir)\n const _rootIndicators = ['pnpm-workspace.yaml', 'turbo.json', 'package.json']\n\n // Walk up the directory tree\n while (currentDir !== path.dirname(currentDir)) {\n // Check for monorepo root indicators first\n if (\n fs.existsSync(path.join(currentDir, 'pnpm-workspace.yaml')) ||\n fs.existsSync(path.join(currentDir, 'turbo.json'))\n ) {\n return currentDir\n }\n\n // Check for package.json\n if (fs.existsSync(path.join(currentDir, 'package.json'))) {\n // If there's a package.json but no monorepo indicators,\n // check if parent has monorepo indicators\n const parentDir = path.dirname(currentDir)\n if (\n fs.existsSync(path.join(parentDir, 'pnpm-workspace.yaml')) ||\n fs.existsSync(path.join(parentDir, 'turbo.json'))\n ) {\n return parentDir\n }\n // Otherwise, this package.json is our root\n return currentDir\n }\n\n currentDir = path.dirname(currentDir)\n }\n\n // Fallback to start directory\n return path.resolve(startDir)\n}\n\n/**\n * Resolve configuration paths to absolute paths\n *\n * @param config - The configuration to resolve\n * @param projectRoot - The project root directory\n * @returns Configuration with resolved absolute paths\n */\nexport function resolvePaths(config: BetterstartConfig, projectRoot: string): ResolvedPaths {\n const root = path.resolve(projectRoot)\n\n // Resolve main paths\n const appPath = path.resolve(root, config.paths.app)\n const databasePath = path.resolve(root, config.paths.database)\n const libPath = path.resolve(root, config.paths.lib)\n const hooksPath = path.resolve(root, config.paths.hooks)\n const schemasPath = path.resolve(root, config.paths.schemas)\n\n // Resolve output paths relative to their parent packages\n const outputPaths = {\n actions: path.resolve(libPath, config.paths.output.actions),\n hooks: path.resolve(hooksPath, config.paths.output.hooks),\n components: path.resolve(appPath, config.paths.output.components),\n pages: path.resolve(appPath, config.paths.output.pages),\n emails: path.resolve(appPath, config.paths.output.emails)\n }\n\n return {\n root,\n app: appPath,\n database: databasePath,\n lib: libPath,\n hooks: hooksPath,\n schemas: schemasPath,\n output: outputPaths\n }\n}\n\n/**\n * Fully resolve configuration including paths\n *\n * @param config - The configuration to resolve\n * @param projectRoot - The project root directory (optional, auto-detected if not provided)\n * @returns Fully resolved configuration\n */\nexport function resolveConfig(config: BetterstartConfig, projectRoot?: string): ResolvedConfig {\n const root = projectRoot || findProjectRoot(process.cwd())\n const resolvedPaths = resolvePaths(config, root)\n\n return {\n ...config,\n paths: resolvedPaths\n }\n}\n\n// ============================================================================\n// Configuration Helper\n// ============================================================================\n\n/**\n * Helper function for defining configuration in betterstart.config.ts\n * Provides type checking and autocomplete\n *\n * @example\n * ```ts\n * // betterstart.config.ts\n * import { defineConfig } from '@betterstart/cli'\n *\n * export default defineConfig({\n * paths: {\n * app: 'apps/web',\n * database: 'packages/database'\n * }\n * })\n * ```\n */\nexport function defineConfig(config: UserConfig): UserConfig {\n return config\n}\n\n// ============================================================================\n// Validation\n// ============================================================================\n\n/**\n * Validate a configuration\n * @param config - The configuration to validate\n * @returns Array of validation errors (empty if valid)\n */\nexport function validateConfig(config: BetterstartConfig): string[] {\n const errors: string[] = []\n\n // Validate paths\n if (!config.paths) {\n errors.push('Configuration must have a \"paths\" object')\n } else {\n if (!config.paths.app) errors.push('paths.app is required')\n if (!config.paths.database) errors.push('paths.database is required')\n if (!config.paths.lib) errors.push('paths.lib is required')\n if (!config.paths.hooks) errors.push('paths.hooks is required')\n if (!config.paths.schemas) errors.push('paths.schemas is required')\n }\n\n // Validate database config\n if (!config.database) {\n errors.push('Configuration must have a \"database\" object')\n } else {\n if (config.database.provider !== 'drizzle') {\n errors.push('database.provider must be \"drizzle\"')\n }\n }\n\n // Validate UI config\n if (!config.ui) {\n errors.push('Configuration must have a \"ui\" object')\n } else {\n if (config.ui.framework !== 'shadcn') {\n errors.push('ui.framework must be \"shadcn\"')\n }\n }\n\n return errors\n}\n\n/**\n * Check if resolved paths exist and are accessible\n * @param paths - The resolved paths to check\n * @returns Object with path existence status\n */\nexport function checkPaths(paths: ResolvedPaths): Record<keyof ResolvedPaths, boolean> {\n const exists = (p: string) => {\n try {\n fs.accessSync(p)\n return true\n } catch {\n return false\n }\n }\n\n return {\n root: exists(paths.root),\n app: exists(paths.app),\n database: exists(paths.database),\n lib: exists(paths.lib),\n hooks: exists(paths.hooks),\n schemas: exists(paths.schemas),\n output: {\n actions: exists(paths.output.actions),\n hooks: exists(paths.output.hooks),\n components: exists(paths.output.components),\n pages: exists(paths.output.pages),\n emails: exists(paths.output.emails)\n }\n } as unknown as Record<keyof Resolved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,EACF;AAEA,SAAO;AACT;AAOO,SAAS,WAAW,OAA4D;AACrF,QAAM,SAAS,CAAC,MAAc;AAC5B,QAAI;AACF,SAAG,WAAW,CAAC;AACf,aAAO;AAAA,IACT,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM,OAAO,MAAM,IAAI;AAAA,IACvB,KAAK,OAAO,MAAM,GAAG;AAAA,IACrB,UAAU,OAAO,MAAM,QAAQ;AAAA,IAC/B,KAAK,OAAO,MAAM,GAAG;AAAA,IACrB,OAAO,OAAO,MAAM,KAAK;AAAA,IACzB,SAAS,OAAO,MAAM,OAAO;AAAA,IAC7B,QAAQ;AAAA,MACN,SAAS,OAAO,MAAM,OAAO,OAAO;AAAA,MACpC,OAAO,OAAO,MAAM,OAAO,KAAK;AAAA,MAChC,YAAY,OAAO,MAAM,OAAO,UAAU;AAAA,MAC1C,OAAO,OAAO,MAAM,OAAO,KAAK;AAAA,MAChC,QAAQ,OAAO,MAAM,OAAO,MAAM;AAAA,IACpC;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,56 +1,3 @@
|
|
|
1
|
-
// src/config/import-resolver.ts
|
|
2
|
-
var ImportResolver = class {
|
|
3
|
-
constructor(imports) {
|
|
4
|
-
this.imports = imports;
|
|
5
|
-
}
|
|
6
|
-
/** Import path for database package (db instance, table schemas) */
|
|
7
|
-
get database() {
|
|
8
|
-
return this.imports.database;
|
|
9
|
-
}
|
|
10
|
-
/** Import path for admin UI components */
|
|
11
|
-
get adminUi() {
|
|
12
|
-
return this.imports.adminUi;
|
|
13
|
-
}
|
|
14
|
-
/** Import path for public/web UI components */
|
|
15
|
-
get webUi() {
|
|
16
|
-
return this.imports.webUi;
|
|
17
|
-
}
|
|
18
|
-
/** Import path for React Query hooks */
|
|
19
|
-
get hooks() {
|
|
20
|
-
return this.imports.hooks;
|
|
21
|
-
}
|
|
22
|
-
/** Import path for utility functions (cn, truncate, hexToOklab) */
|
|
23
|
-
get utils() {
|
|
24
|
-
return this.imports.utils;
|
|
25
|
-
}
|
|
26
|
-
/** Import path for lib base (renderMarkdownInline, etc.) */
|
|
27
|
-
get lib() {
|
|
28
|
-
return this.imports.lib;
|
|
29
|
-
}
|
|
30
|
-
/** Import path for lib/markdown sub-module */
|
|
31
|
-
get libMarkdown() {
|
|
32
|
-
return this.imports.libMarkdown;
|
|
33
|
-
}
|
|
34
|
-
/** Import path for table-meta type augmentation */
|
|
35
|
-
get tableMeta() {
|
|
36
|
-
return `${this.imports.types}/table-meta`;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Resolve the import path for a schema's server actions.
|
|
40
|
-
* Replaces `{name}` placeholder with the actual schema name.
|
|
41
|
-
*/
|
|
42
|
-
actions(schemaName) {
|
|
43
|
-
return this.imports.actions.replace("{name}", schemaName);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Get the escaped lib import path for use in regex matching.
|
|
47
|
-
* Used by hook.ts to update existing hook files.
|
|
48
|
-
*/
|
|
49
|
-
get libEscaped() {
|
|
50
|
-
return this.imports.lib.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
1
|
// src/config/presets.ts
|
|
55
2
|
import fs from "fs";
|
|
56
3
|
import path from "path";
|
|
@@ -240,8 +187,60 @@ function getDefaultConfig(cwd) {
|
|
|
240
187
|
return preset.config;
|
|
241
188
|
}
|
|
242
189
|
|
|
190
|
+
// src/config/import-resolver.ts
|
|
191
|
+
var ImportResolver = class {
|
|
192
|
+
constructor(imports) {
|
|
193
|
+
this.imports = imports;
|
|
194
|
+
}
|
|
195
|
+
/** Import path for database package (db instance, table schemas) */
|
|
196
|
+
get database() {
|
|
197
|
+
return this.imports.database;
|
|
198
|
+
}
|
|
199
|
+
/** Import path for admin UI components */
|
|
200
|
+
get adminUi() {
|
|
201
|
+
return this.imports.adminUi;
|
|
202
|
+
}
|
|
203
|
+
/** Import path for public/web UI components */
|
|
204
|
+
get webUi() {
|
|
205
|
+
return this.imports.webUi;
|
|
206
|
+
}
|
|
207
|
+
/** Import path for React Query hooks */
|
|
208
|
+
get hooks() {
|
|
209
|
+
return this.imports.hooks;
|
|
210
|
+
}
|
|
211
|
+
/** Import path for utility functions (cn, truncate, hexToOklab) */
|
|
212
|
+
get utils() {
|
|
213
|
+
return this.imports.utils;
|
|
214
|
+
}
|
|
215
|
+
/** Import path for lib base (renderMarkdownInline, etc.) */
|
|
216
|
+
get lib() {
|
|
217
|
+
return this.imports.lib;
|
|
218
|
+
}
|
|
219
|
+
/** Import path for lib/markdown sub-module */
|
|
220
|
+
get libMarkdown() {
|
|
221
|
+
return this.imports.libMarkdown;
|
|
222
|
+
}
|
|
223
|
+
/** Import path for table-meta type augmentation */
|
|
224
|
+
get tableMeta() {
|
|
225
|
+
return `${this.imports.types}/table-meta`;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Resolve the import path for a schema's server actions.
|
|
229
|
+
* Replaces `{name}` placeholder with the actual schema name.
|
|
230
|
+
*/
|
|
231
|
+
actions(schemaName) {
|
|
232
|
+
return this.imports.actions.replace("{name}", schemaName);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Get the escaped lib import path for use in regex matching.
|
|
236
|
+
* Used by hook.ts to update existing hook files.
|
|
237
|
+
*/
|
|
238
|
+
get libEscaped() {
|
|
239
|
+
return this.imports.lib.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
|
|
243
243
|
export {
|
|
244
|
-
ImportResolver,
|
|
245
244
|
DEFAULT_OUTPUT_PATHS,
|
|
246
245
|
DEFAULT_DATABASE_CONFIG,
|
|
247
246
|
DEFAULT_UI_CONFIG,
|
|
@@ -255,6 +254,7 @@ export {
|
|
|
255
254
|
getPreset,
|
|
256
255
|
getPresetNames,
|
|
257
256
|
detectPreset,
|
|
258
|
-
getDefaultConfig
|
|
257
|
+
getDefaultConfig,
|
|
258
|
+
ImportResolver
|
|
259
259
|
};
|
|
260
|
-
//# sourceMappingURL=chunk-
|
|
260
|
+
//# sourceMappingURL=chunk-NKRQYAS6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/config/presets.ts","../src/config/import-resolver.ts"],"sourcesContent":["/**\n * Project presets for common project structures\n * Each preset provides default configuration for a specific project type\n */\n\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport type { ImportPaths, Preset, UserConfig } from './types'\n\n// ============================================================================\n// Default Configuration Values\n// ============================================================================\n\n/**\n * Default output paths\n */\nexport const DEFAULT_OUTPUT_PATHS = {\n actions: 'src/actions',\n hooks: 'src',\n components: 'components',\n pages: 'app/(admin)/admin',\n emails: 'emails'\n}\n\n/**\n * Default database configuration\n */\nexport const DEFAULT_DATABASE_CONFIG = {\n provider: 'drizzle' as const,\n schemaFile: 'src/schema.ts',\n migrationsDir: 'drizzle',\n autoMigrate: true\n}\n\n/**\n * Default UI configuration\n */\nexport const DEFAULT_UI_CONFIG = {\n framework: 'shadcn' as const,\n components: {\n path: '@/components/ui',\n adminPath: '@/components/admin'\n }\n}\n\n/**\n * Monorepo import paths (for @betterstart/* packages)\n */\nexport const MONOREPO_IMPORT_PATHS: ImportPaths = {\n database: '@betterstart/database',\n adminUi: '@betterstart/admin-ui',\n webUi: '@betterstart/web-ui',\n hooks: '@betterstart/hooks',\n utils: '@betterstart/utils',\n types: '@betterstart/types',\n lib: '@betterstart/lib',\n actions: '@betterstart/lib/actions/{name}',\n libMarkdown: '@betterstart/lib/markdown'\n}\n\n/**\n * Standalone import paths (for @/ alias in single Next.js apps)\n */\nexport const STANDALONE_IMPORT_PATHS: ImportPaths = {\n database: '@/lib/db',\n adminUi: '@/components/ui',\n webUi: '@/components/ui',\n hooks: '@/hooks',\n utils: '@/lib/utils',\n types: '@/types',\n lib: '@/lib',\n actions: '@/lib/actions/{name}',\n libMarkdown: '@/lib/markdown'\n}\n\n/**\n * Default generator configuration\n */\nexport const DEFAULT_GENERATOR_CONFIG = {\n core: [\n 'database',\n 'actions',\n 'hooks',\n 'columns',\n 'table',\n 'page',\n 'page-content',\n 'form',\n 'create-page',\n 'edit-page',\n 'navigation'\n ] as string[],\n optional: ['csv-upload', 'json-upload'] as string[]\n}\n\n// ============================================================================\n// Presets\n// ============================================================================\n\n/**\n * Next.js monorepo preset (Turborepo/pnpm style)\n * Similar to the current betterstart structure\n */\nexport const nextjsMonorepoPreset: Preset = {\n name: 'nextjs-monorepo',\n description: 'Next.js app in a Turborepo/pnpm monorepo structure',\n detect: (cwd: string) => {\n // Check for pnpm-workspace.yaml or turbo.json\n const hasPnpmWorkspace = fs.existsSync(path.join(cwd, 'pnpm-workspace.yaml'))\n const hasTurboJson = fs.existsSync(path.join(cwd, 'turbo.json'))\n const hasAppsDir = fs.existsSync(path.join(cwd, 'apps'))\n const hasPackagesDir = fs.existsSync(path.join(cwd, 'packages'))\n\n return (hasPnpmWorkspace || hasTurboJson) && (hasAppsDir || hasPackagesDir)\n },\n config: {\n paths: {\n app: 'apps/web',\n database: 'packages/database',\n lib: 'packages/lib',\n hooks: 'packages/hooks',\n schemas: 'packages/codegen/src/schemas',\n output: {\n actions: 'src/actions',\n hooks: 'src',\n components: 'app/(admin)/admin',\n pages: 'app/(admin)/admin',\n emails: 'emails'\n }\n },\n imports: MONOREPO_IMPORT_PATHS,\n database: {\n ...DEFAULT_DATABASE_CONFIG\n },\n ui: {\n framework: 'shadcn',\n components: {\n path: '@betterstart/admin-ui',\n adminPath: '@betterstart/admin-ui'\n }\n },\n generators: {\n ...DEFAULT_GENERATOR_CONFIG\n },\n plugins: []\n }\n}\n\n/**\n * Standalone Next.js preset\n * For single Next.js apps without monorepo structure\n */\nexport const nextjsStandalonePreset: Preset = {\n name: 'nextjs-standalone',\n description: 'Standalone Next.js application',\n detect: (cwd: string) => {\n const hasNextConfig =\n fs.existsSync(path.join(cwd, 'next.config.js')) ||\n fs.existsSync(path.join(cwd, 'next.config.mjs')) ||\n fs.existsSync(path.join(cwd, 'next.config.ts'))\n const hasPackageJson = fs.existsSync(path.join(cwd, 'package.json'))\n\n if (!hasNextConfig || !hasPackageJson) return false\n\n // Make sure it's not a monorepo\n const hasPnpmWorkspace = fs.existsSync(path.join(cwd, 'pnpm-workspace.yaml'))\n const hasTurboJson = fs.existsSync(path.join(cwd, 'turbo.json'))\n\n return !(hasPnpmWorkspace || hasTurboJson)\n },\n config: {\n paths: {\n app: '.',\n database: '.',\n lib: '.',\n hooks: '.',\n schemas: 'schemas',\n output: {\n actions: 'src/actions',\n hooks: 'src/hooks',\n components: 'src/components/admin',\n pages: 'src/app/(admin)/admin',\n emails: 'src/emails'\n }\n },\n imports: STANDALONE_IMPORT_PATHS,\n database: {\n ...DEFAULT_DATABASE_CONFIG,\n schemaFile: 'src/db/schema.ts',\n migrationsDir: 'src/db/migrations'\n },\n ui: {\n ...DEFAULT_UI_CONFIG\n },\n generators: {\n ...DEFAULT_GENERATOR_CONFIG\n },\n plugins: []\n }\n}\n\n/**\n * Custom/minimal preset\n * Provides minimal defaults, user must configure paths\n */\nexport const customPreset: Preset = {\n name: 'custom',\n description: 'Custom project structure - configure paths manually',\n config: {\n paths: {\n app: '.',\n database: '.',\n lib: '.',\n hooks: '.',\n schemas: 'schemas',\n output: DEFAULT_OUTPUT_PATHS\n },\n imports: STANDALONE_IMPORT_PATHS,\n database: DEFAULT_DATABASE_CONFIG,\n ui: DEFAULT_UI_CONFIG,\n generators: DEFAULT_GENERATOR_CONFIG,\n plugins: []\n }\n}\n\n// ============================================================================\n// Preset Registry\n// ============================================================================\n\n/**\n * All available presets\n */\nexport const presets: Record<string, Preset> = {\n 'nextjs-monorepo': nextjsMonorepoPreset,\n 'nextjs-standalone': nextjsStandalonePreset,\n custom: customPreset\n}\n\n/**\n * Get a preset by name\n */\nexport function getPreset(name: string): Preset | undefined {\n return presets[name]\n}\n\n/**\n * Get all preset names\n */\nexport function getPresetNames(): string[] {\n return Object.keys(presets)\n}\n\n/**\n * Auto-detect the best preset for a project\n * @param cwd - The project root directory\n * @returns The detected preset or 'custom' if none match\n */\nexport function detectPreset(cwd: string): Preset {\n // Try presets in order of specificity\n const presetOrder = ['nextjs-monorepo', 'nextjs-standalone']\n\n for (const presetName of presetOrder) {\n const preset = presets[presetName]\n if (preset.detect?.(cwd)) {\n return preset\n }\n }\n\n return customPreset\n}\n\n/**\n * Get the default configuration based on project detection\n */\nexport function getDefaultConfig(cwd: string): UserConfig {\n const preset = detectPreset(cwd)\n return preset.config\n}\n","import type { ImportPaths } from './types'\n\n/**\n * Resolves import paths from config for use in generated code.\n * All generators should use this instead of hardcoding import paths.\n */\nexport class ImportResolver {\n constructor(private readonly imports: ImportPaths) {}\n\n /** Import path for database package (db instance, table schemas) */\n get database(): string {\n return this.imports.database\n }\n\n /** Import path for admin UI components */\n get adminUi(): string {\n return this.imports.adminUi\n }\n\n /** Import path for public/web UI components */\n get webUi(): string {\n return this.imports.webUi\n }\n\n /** Import path for React Query hooks */\n get hooks(): string {\n return this.imports.hooks\n }\n\n /** Import path for utility functions (cn, truncate, hexToOklab) */\n get utils(): string {\n return this.imports.utils\n }\n\n /** Import path for lib base (renderMarkdownInline, etc.) */\n get lib(): string {\n return this.imports.lib\n }\n\n /** Import path for lib/markdown sub-module */\n get libMarkdown(): string {\n return this.imports.libMarkdown\n }\n\n /** Import path for table-meta type augmentation */\n get tableMeta(): string {\n return `${this.imports.types}/table-meta`\n }\n\n /**\n * Resolve the import path for a schema's server actions.\n * Replaces `{name}` placeholder with the actual schema name.\n */\n actions(schemaName: string): string {\n return this.imports.actions.replace('{name}', schemaName)\n }\n\n /**\n * Get the escaped lib import path for use in regex matching.\n * Used by hook.ts to update existing hook files.\n */\n get libEscaped(): string {\n return this.imports.lib.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n }\n}\n"],"mappings":";AAKA,OAAO,QAAQ;AACf,OAAO,UAAU;AAUV,IAAM,uBAAuB;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A,EACtB;AAAA;AAAA,EAGA,IAAI,UAAkB;AACpB,WAAO,KAAK,QAAQ;AAAA,EACtB;AAAA;AAAA,EAGA,IAAI,QAAgB;AAClB,WAAO,KAAK,QAAQ;AAAA,EACtB;AAAA;AAAA,EAGA,IAAI,QAAgB;AAClB,WAAO,KAAK,QAAQ;AAAA,EACtB;AAAA;AAAA,EAGA,IAAI,QAAgB;AAClB,WAAO,KAAK,QAAQ;AAAA,EACtB;AAAA;AAAA,EAGA,IAAI,MAAc;AAChB,WAAO,KAAK,QAAQ;AAAA,EACtB;AAAA;AAAA,EAGA,IAAI,cAAsB;AACxB,WAAO,KAAK,QAAQ;AAAA,EACtB;AAAA;AAAA,EAGA,IAAI,YAAoB;AACtB,WAAO,GAAG,KAAK,QAAQ,KAAK;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,QAAQ,YAA4B;AAClC,WAAO,KAAK,QAAQ,QAAQ,QAAQ,UAAU,UAAU;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,aAAqB;AACvB,WAAO,KAAK,QAAQ,IAAI,QAAQ,uBAAuB,MAAM;AAAA,EAC/D;AACF;","names":[]}
|
package/dist/cli.js
CHANGED
|
@@ -3,16 +3,16 @@ import {
|
|
|
3
3
|
findProjectRoot,
|
|
4
4
|
loadConfig,
|
|
5
5
|
resolveConfig
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-J2XUG4RG.js";
|
|
7
7
|
import {
|
|
8
8
|
toKebabCase,
|
|
9
9
|
toPascalCase
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-G4KI4DVB.js";
|
|
11
11
|
import {
|
|
12
12
|
detectPreset,
|
|
13
13
|
getPresetNames,
|
|
14
14
|
presets
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-NKRQYAS6.js";
|
|
16
16
|
import {
|
|
17
17
|
SchemaValidationError,
|
|
18
18
|
createConsoleLogger,
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,93 +1,8 @@
|
|
|
1
|
-
export { I as ImportResolver } from '../import-resolver-
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
1
|
+
export { C as CONFIG_FILE_NAMES, I as ImportResolver, e as checkPaths, d as defineConfig, f as findConfigFile, b as findProjectRoot, a as loadConfig, l as loadConfigFile, c as resolveConfig, r as resolvePaths, v as validateConfig } from '../import-resolver-BaZ-rzkH.js';
|
|
2
|
+
import { I as ImportPaths, P as Preset, U as UserConfig } from '../types-eI549DEG.js';
|
|
3
|
+
export { B as BetterstartConfig, j as BetterstartPlugin, C as CustomGenerator, b as DatabaseConfig, D as DatabaseProvider, k as DeepPartial, F as FieldTypeHandler, p as GenerateOptions, h as GeneratedFile, G as GeneratorConfig, e as GeneratorName, n as GeneratorOptions, o as InitOptions, O as OutputPaths, i as PluginCommand, g as PluginContext, f as PluginHooks, a as ProjectPaths, m as ProjectType, q as RemoveOptions, l as ResolvedConfig, R as ResolvedPaths, d as UIConfig, c as UIFramework } from '../types-eI549DEG.js';
|
|
4
4
|
import '../logger-awLb347n.js';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Configuration loader for @betterstart/cli
|
|
8
|
-
* Handles loading, merging, and resolving configuration
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Supported configuration file names (in priority order)
|
|
13
|
-
*/
|
|
14
|
-
declare const CONFIG_FILE_NAMES: string[];
|
|
15
|
-
/**
|
|
16
|
-
* Find the configuration file in a directory
|
|
17
|
-
* @param cwd - Directory to search in
|
|
18
|
-
* @returns Path to the config file or undefined if not found
|
|
19
|
-
*/
|
|
20
|
-
declare function findConfigFile(cwd: string): string | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* Load configuration from a file
|
|
23
|
-
* @param configPath - Path to the configuration file
|
|
24
|
-
* @returns The loaded configuration
|
|
25
|
-
*/
|
|
26
|
-
declare function loadConfigFile(configPath: string): Promise<UserConfig>;
|
|
27
|
-
/**
|
|
28
|
-
* Load configuration from a directory
|
|
29
|
-
* Automatically finds and loads the config file, or uses defaults
|
|
30
|
-
*
|
|
31
|
-
* @param cwd - Directory to load config from (defaults to process.cwd())
|
|
32
|
-
* @param presetName - Optional preset name to use as base
|
|
33
|
-
* @returns The loaded and merged configuration
|
|
34
|
-
*/
|
|
35
|
-
declare function loadConfig(cwd?: string, presetName?: string): Promise<BetterstartConfig>;
|
|
36
|
-
/**
|
|
37
|
-
* Find the project root directory
|
|
38
|
-
* Looks for common root indicators (package.json, pnpm-workspace.yaml, turbo.json)
|
|
39
|
-
*
|
|
40
|
-
* @param startDir - Directory to start searching from
|
|
41
|
-
* @returns The project root directory
|
|
42
|
-
*/
|
|
43
|
-
declare function findProjectRoot(startDir: string): string;
|
|
44
|
-
/**
|
|
45
|
-
* Resolve configuration paths to absolute paths
|
|
46
|
-
*
|
|
47
|
-
* @param config - The configuration to resolve
|
|
48
|
-
* @param projectRoot - The project root directory
|
|
49
|
-
* @returns Configuration with resolved absolute paths
|
|
50
|
-
*/
|
|
51
|
-
declare function resolvePaths(config: BetterstartConfig, projectRoot: string): ResolvedPaths;
|
|
52
|
-
/**
|
|
53
|
-
* Fully resolve configuration including paths
|
|
54
|
-
*
|
|
55
|
-
* @param config - The configuration to resolve
|
|
56
|
-
* @param projectRoot - The project root directory (optional, auto-detected if not provided)
|
|
57
|
-
* @returns Fully resolved configuration
|
|
58
|
-
*/
|
|
59
|
-
declare function resolveConfig(config: BetterstartConfig, projectRoot?: string): ResolvedConfig;
|
|
60
|
-
/**
|
|
61
|
-
* Helper function for defining configuration in betterstart.config.ts
|
|
62
|
-
* Provides type checking and autocomplete
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```ts
|
|
66
|
-
* // betterstart.config.ts
|
|
67
|
-
* import { defineConfig } from '@betterstart/cli'
|
|
68
|
-
*
|
|
69
|
-
* export default defineConfig({
|
|
70
|
-
* paths: {
|
|
71
|
-
* app: 'apps/web',
|
|
72
|
-
* database: 'packages/database'
|
|
73
|
-
* }
|
|
74
|
-
* })
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
declare function defineConfig(config: UserConfig): UserConfig;
|
|
78
|
-
/**
|
|
79
|
-
* Validate a configuration
|
|
80
|
-
* @param config - The configuration to validate
|
|
81
|
-
* @returns Array of validation errors (empty if valid)
|
|
82
|
-
*/
|
|
83
|
-
declare function validateConfig(config: BetterstartConfig): string[];
|
|
84
|
-
/**
|
|
85
|
-
* Check if resolved paths exist and are accessible
|
|
86
|
-
* @param paths - The resolved paths to check
|
|
87
|
-
* @returns Object with path existence status
|
|
88
|
-
*/
|
|
89
|
-
declare function checkPaths(paths: ResolvedPaths): Record<keyof ResolvedPaths, boolean>;
|
|
90
|
-
|
|
91
6
|
/**
|
|
92
7
|
* Project presets for common project structures
|
|
93
8
|
* Each preset provides default configuration for a specific project type
|
|
@@ -175,4 +90,4 @@ declare function detectPreset(cwd: string): Preset;
|
|
|
175
90
|
*/
|
|
176
91
|
declare function getDefaultConfig(cwd: string): UserConfig;
|
|
177
92
|
|
|
178
|
-
export {
|
|
93
|
+
export { DEFAULT_DATABASE_CONFIG, DEFAULT_GENERATOR_CONFIG, DEFAULT_OUTPUT_PATHS, DEFAULT_UI_CONFIG, ImportPaths, MONOREPO_IMPORT_PATHS, Preset, STANDALONE_IMPORT_PATHS, UserConfig, customPreset, detectPreset, getDefaultConfig, getPreset, getPresetNames, nextjsMonorepoPreset, nextjsStandalonePreset, presets };
|
package/dist/config/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
resolveConfig,
|
|
10
10
|
resolvePaths,
|
|
11
11
|
validateConfig
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-J2XUG4RG.js";
|
|
13
13
|
import {
|
|
14
14
|
DEFAULT_DATABASE_CONFIG,
|
|
15
15
|
DEFAULT_GENERATOR_CONFIG,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
nextjsMonorepoPreset,
|
|
27
27
|
nextjsStandalonePreset,
|
|
28
28
|
presets
|
|
29
|
-
} from "../chunk-
|
|
29
|
+
} from "../chunk-NKRQYAS6.js";
|
|
30
30
|
import "../chunk-WY6BC55D.js";
|
|
31
31
|
export {
|
|
32
32
|
CONFIG_FILE_NAMES,
|
package/dist/core/index.js
CHANGED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { U as UserConfig, B as BetterstartConfig, R as ResolvedPaths, l as ResolvedConfig, I as ImportPaths } from './types-eI549DEG.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration loader for @betterstart/cli
|
|
5
|
+
* Handles loading, merging, and resolving configuration
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Supported configuration file names (in priority order)
|
|
10
|
+
*/
|
|
11
|
+
declare const CONFIG_FILE_NAMES: string[];
|
|
12
|
+
/**
|
|
13
|
+
* Find the configuration file in a directory
|
|
14
|
+
* @param cwd - Directory to search in
|
|
15
|
+
* @returns Path to the config file or undefined if not found
|
|
16
|
+
*/
|
|
17
|
+
declare function findConfigFile(cwd: string): string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Load configuration from a file
|
|
20
|
+
* @param configPath - Path to the configuration file
|
|
21
|
+
* @returns The loaded configuration
|
|
22
|
+
*/
|
|
23
|
+
declare function loadConfigFile(configPath: string): Promise<UserConfig>;
|
|
24
|
+
/**
|
|
25
|
+
* Load configuration from a directory
|
|
26
|
+
* Automatically finds and loads the config file, or uses defaults
|
|
27
|
+
*
|
|
28
|
+
* @param cwd - Directory to load config from (defaults to process.cwd())
|
|
29
|
+
* @param presetName - Optional preset name to use as base
|
|
30
|
+
* @returns The loaded and merged configuration
|
|
31
|
+
*/
|
|
32
|
+
declare function loadConfig(cwd?: string, presetName?: string): Promise<BetterstartConfig>;
|
|
33
|
+
/**
|
|
34
|
+
* Find the project root directory
|
|
35
|
+
* Looks for common root indicators (package.json, pnpm-workspace.yaml, turbo.json)
|
|
36
|
+
*
|
|
37
|
+
* @param startDir - Directory to start searching from
|
|
38
|
+
* @returns The project root directory
|
|
39
|
+
*/
|
|
40
|
+
declare function findProjectRoot(startDir: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Resolve configuration paths to absolute paths
|
|
43
|
+
*
|
|
44
|
+
* @param config - The configuration to resolve
|
|
45
|
+
* @param projectRoot - The project root directory
|
|
46
|
+
* @returns Configuration with resolved absolute paths
|
|
47
|
+
*/
|
|
48
|
+
declare function resolvePaths(config: BetterstartConfig, projectRoot: string): ResolvedPaths;
|
|
49
|
+
/**
|
|
50
|
+
* Fully resolve configuration including paths
|
|
51
|
+
*
|
|
52
|
+
* @param config - The configuration to resolve
|
|
53
|
+
* @param projectRoot - The project root directory (optional, auto-detected if not provided)
|
|
54
|
+
* @returns Fully resolved configuration
|
|
55
|
+
*/
|
|
56
|
+
declare function resolveConfig(config: BetterstartConfig, projectRoot?: string): ResolvedConfig;
|
|
57
|
+
/**
|
|
58
|
+
* Helper function for defining configuration in betterstart.config.ts
|
|
59
|
+
* Provides type checking and autocomplete
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* // betterstart.config.ts
|
|
64
|
+
* import { defineConfig } from '@betterstart/cli'
|
|
65
|
+
*
|
|
66
|
+
* export default defineConfig({
|
|
67
|
+
* paths: {
|
|
68
|
+
* app: 'apps/web',
|
|
69
|
+
* database: 'packages/database'
|
|
70
|
+
* }
|
|
71
|
+
* })
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
declare function defineConfig(config: UserConfig): UserConfig;
|
|
75
|
+
/**
|
|
76
|
+
* Validate a configuration
|
|
77
|
+
* @param config - The configuration to validate
|
|
78
|
+
* @returns Array of validation errors (empty if valid)
|
|
79
|
+
*/
|
|
80
|
+
declare function validateConfig(config: BetterstartConfig): string[];
|
|
81
|
+
/**
|
|
82
|
+
* Check if resolved paths exist and are accessible
|
|
83
|
+
* @param paths - The resolved paths to check
|
|
84
|
+
* @returns Object with path existence status
|
|
85
|
+
*/
|
|
86
|
+
declare function checkPaths(paths: ResolvedPaths): Record<keyof ResolvedPaths, boolean>;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Resolves import paths from config for use in generated code.
|
|
90
|
+
* All generators should use this instead of hardcoding import paths.
|
|
91
|
+
*/
|
|
92
|
+
declare class ImportResolver {
|
|
93
|
+
private readonly imports;
|
|
94
|
+
constructor(imports: ImportPaths);
|
|
95
|
+
/** Import path for database package (db instance, table schemas) */
|
|
96
|
+
get database(): string;
|
|
97
|
+
/** Import path for admin UI components */
|
|
98
|
+
get adminUi(): string;
|
|
99
|
+
/** Import path for public/web UI components */
|
|
100
|
+
get webUi(): string;
|
|
101
|
+
/** Import path for React Query hooks */
|
|
102
|
+
get hooks(): string;
|
|
103
|
+
/** Import path for utility functions (cn, truncate, hexToOklab) */
|
|
104
|
+
get utils(): string;
|
|
105
|
+
/** Import path for lib base (renderMarkdownInline, etc.) */
|
|
106
|
+
get lib(): string;
|
|
107
|
+
/** Import path for lib/markdown sub-module */
|
|
108
|
+
get libMarkdown(): string;
|
|
109
|
+
/** Import path for table-meta type augmentation */
|
|
110
|
+
get tableMeta(): string;
|
|
111
|
+
/**
|
|
112
|
+
* Resolve the import path for a schema's server actions.
|
|
113
|
+
* Replaces `{name}` placeholder with the actual schema name.
|
|
114
|
+
*/
|
|
115
|
+
actions(schemaName: string): string;
|
|
116
|
+
/**
|
|
117
|
+
* Get the escaped lib import path for use in regex matching.
|
|
118
|
+
* Used by hook.ts to update existing hook files.
|
|
119
|
+
*/
|
|
120
|
+
get libEscaped(): string;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export { CONFIG_FILE_NAMES as C, ImportResolver as I, loadConfig as a, findProjectRoot as b, resolveConfig as c, defineConfig as d, checkPaths as e, findConfigFile as f, loadConfigFile as l, resolvePaths as r, validateConfig as v };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { I as ImportResolver } from './import-resolver-BaZ-rzkH.js';
|
|
2
|
+
export { d as defineConfig } from './import-resolver-BaZ-rzkH.js';
|
|
3
|
+
import { B as BetterstartConfig } from './types-eI549DEG.js';
|
|
4
|
+
export { U as UserConfig } from './types-eI549DEG.js';
|
|
1
5
|
import { S as Schema, G as GeneratorOptions, F as FormSchema, a as SchemaField, M as MonorepoPaths } from './types-ByX_gl6y.js';
|
|
2
6
|
export { A as AutoSlugify, C as ColumnType, b as FieldType, k as FormActions, l as FormColumn, i as FormField, h as FormFieldType, j as FormStep, g as GenerationResult, N as NestedSlugLookup, d as SchemaActions, c as SchemaColumn, f as SchemaFilter, e as SchemaSearch } from './types-ByX_gl6y.js';
|
|
3
|
-
import { I as ImportResolver } from './import-resolver-BJOCLFnH.js';
|
|
4
|
-
import { B as BetterstartConfig } from './types-BouTOvVr.js';
|
|
5
7
|
import './logger-awLb347n.js';
|
|
6
8
|
|
|
7
9
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
defineConfig,
|
|
2
3
|
findProjectRoot,
|
|
3
4
|
loadConfig,
|
|
4
5
|
resolveConfig
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-J2XUG4RG.js";
|
|
6
7
|
import {
|
|
7
8
|
ensureDir,
|
|
8
9
|
getImportResolver,
|
|
@@ -20,8 +21,8 @@ import {
|
|
|
20
21
|
toPascalCase,
|
|
21
22
|
toScreamingSnakeCase,
|
|
22
23
|
toSnakeCase
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-G4KI4DVB.js";
|
|
25
|
+
import "./chunk-NKRQYAS6.js";
|
|
25
26
|
import "./chunk-WY6BC55D.js";
|
|
26
27
|
|
|
27
28
|
// src/generators/actions.ts
|
|
@@ -11321,6 +11322,7 @@ export {
|
|
|
11321
11322
|
TARGET_CONFIGS,
|
|
11322
11323
|
addAllComponents,
|
|
11323
11324
|
addComponents,
|
|
11325
|
+
defineConfig,
|
|
11324
11326
|
ensureDir,
|
|
11325
11327
|
ensureIdField,
|
|
11326
11328
|
exportExists,
|