yamchart 0.1.4 → 0.3.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.
@@ -0,0 +1,75 @@
1
+ import {
2
+ checkForUpdate
3
+ } from "./chunk-3CLMQNNR.js";
4
+ import {
5
+ detail,
6
+ error,
7
+ info,
8
+ spinner,
9
+ success
10
+ } from "./chunk-HJVVHYVN.js";
11
+
12
+ // src/commands/update.ts
13
+ import { execSync } from "child_process";
14
+ import { readFile, writeFile, mkdir, access } from "fs/promises";
15
+ import { join, dirname } from "path";
16
+ import { fileURLToPath } from "url";
17
+ var __dirname = dirname(fileURLToPath(import.meta.url));
18
+ async function runUpdate(currentVersion) {
19
+ const spin = spinner("Checking for updates...");
20
+ const update = await checkForUpdate(currentVersion);
21
+ spin.stop();
22
+ if (!update) {
23
+ success(`yamchart ${currentVersion} is the latest version`);
24
+ } else {
25
+ info(`Update available: ${update.current} \u2192 ${update.latest}`);
26
+ const installSpin = spinner("Installing yamchart@latest...");
27
+ try {
28
+ execSync("npm install -g yamchart@latest", { stdio: "pipe" });
29
+ installSpin.stop();
30
+ success(`Updated yamchart ${update.current} \u2192 ${update.latest}`);
31
+ } catch {
32
+ installSpin.stop();
33
+ error("Automatic install failed. Run manually:");
34
+ detail("npm install -g yamchart@latest");
35
+ return;
36
+ }
37
+ }
38
+ await refreshDocs();
39
+ }
40
+ async function refreshDocs() {
41
+ const projectFile = join(process.cwd(), "yamchart.yaml");
42
+ try {
43
+ await access(projectFile);
44
+ } catch {
45
+ return;
46
+ }
47
+ const bundled = await readBundledReference();
48
+ if (!bundled) return;
49
+ const refPath = join(process.cwd(), "docs", "yamchart-reference.md");
50
+ try {
51
+ const existing = await readFile(refPath, "utf-8");
52
+ if (existing === bundled) return;
53
+ } catch {
54
+ }
55
+ await mkdir(join(process.cwd(), "docs"), { recursive: true });
56
+ await writeFile(refPath, bundled, "utf-8");
57
+ success("Updated docs/yamchart-reference.md");
58
+ }
59
+ async function readBundledReference() {
60
+ const distPath = join(__dirname, "templates", "default", "docs", "yamchart-reference.md");
61
+ const srcPath = join(__dirname, "..", "templates", "default", "docs", "yamchart-reference.md");
62
+ for (const path of [distPath, srcPath]) {
63
+ try {
64
+ return await readFile(path, "utf-8");
65
+ } catch {
66
+ continue;
67
+ }
68
+ }
69
+ return null;
70
+ }
71
+ export {
72
+ refreshDocs,
73
+ runUpdate
74
+ };
75
+ //# sourceMappingURL=update-QHLCWS56.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/update.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport { readFile, writeFile, mkdir, access } from 'fs/promises';\nimport { join, dirname } from 'path';\nimport { fileURLToPath } from 'url';\nimport * as output from '../utils/output.js';\nimport { checkForUpdate } from '../utils/update-check.js';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nexport async function runUpdate(currentVersion: string): Promise<void> {\n const spin = output.spinner('Checking for updates...');\n\n const update = await checkForUpdate(currentVersion);\n\n spin.stop();\n\n if (!update) {\n output.success(`yamchart ${currentVersion} is the latest version`);\n } else {\n output.info(`Update available: ${update.current} → ${update.latest}`);\n const installSpin = output.spinner('Installing yamchart@latest...');\n try {\n execSync('npm install -g yamchart@latest', { stdio: 'pipe' });\n installSpin.stop();\n output.success(`Updated yamchart ${update.current} → ${update.latest}`);\n } catch {\n installSpin.stop();\n output.error('Automatic install failed. Run manually:');\n output.detail('npm install -g yamchart@latest');\n return;\n }\n }\n\n // Refresh project docs if we're in a yamchart project\n await refreshDocs();\n}\n\n/**\n * Refresh docs/yamchart-reference.md from the bundled template.\n * Only runs when yamchart.yaml exists in the current directory.\n */\nexport async function refreshDocs(): Promise<void> {\n const projectFile = join(process.cwd(), 'yamchart.yaml');\n try {\n await access(projectFile);\n } catch {\n return; // Not in a yamchart project\n }\n\n const bundled = await readBundledReference();\n if (!bundled) return;\n\n const refPath = join(process.cwd(), 'docs', 'yamchart-reference.md');\n\n try {\n const existing = await readFile(refPath, 'utf-8');\n if (existing === bundled) return; // Already up to date\n } catch {\n // File doesn't exist — create it\n }\n\n await mkdir(join(process.cwd(), 'docs'), { recursive: true });\n await writeFile(refPath, bundled, 'utf-8');\n output.success('Updated docs/yamchart-reference.md');\n}\n\nasync function readBundledReference(): Promise<string | null> {\n // Production: dist/templates/default/docs/yamchart-reference.md\n const distPath = join(__dirname, 'templates', 'default', 'docs', 'yamchart-reference.md');\n // Development: src/commands → src/templates\n const srcPath = join(__dirname, '..', 'templates', 'default', 'docs', 'yamchart-reference.md');\n\n for (const path of [distPath, srcPath]) {\n try {\n return await readFile(path, 'utf-8');\n } catch {\n continue;\n }\n }\n return null;\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,UAAU,WAAW,OAAO,cAAc;AACnD,SAAS,MAAM,eAAe;AAC9B,SAAS,qBAAqB;AAI9B,IAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AAExD,eAAsB,UAAU,gBAAuC;AACrE,QAAM,OAAc,QAAQ,yBAAyB;AAErD,QAAM,SAAS,MAAM,eAAe,cAAc;AAElD,OAAK,KAAK;AAEV,MAAI,CAAC,QAAQ;AACX,IAAO,QAAQ,YAAY,cAAc,wBAAwB;AAAA,EACnE,OAAO;AACL,IAAO,KAAK,qBAAqB,OAAO,OAAO,WAAM,OAAO,MAAM,EAAE;AACpE,UAAM,cAAqB,QAAQ,+BAA+B;AAClE,QAAI;AACF,eAAS,kCAAkC,EAAE,OAAO,OAAO,CAAC;AAC5D,kBAAY,KAAK;AACjB,MAAO,QAAQ,oBAAoB,OAAO,OAAO,WAAM,OAAO,MAAM,EAAE;AAAA,IACxE,QAAQ;AACN,kBAAY,KAAK;AACjB,MAAO,MAAM,yCAAyC;AACtD,MAAO,OAAO,gCAAgC;AAC9C;AAAA,IACF;AAAA,EACF;AAGA,QAAM,YAAY;AACpB;AAMA,eAAsB,cAA6B;AACjD,QAAM,cAAc,KAAK,QAAQ,IAAI,GAAG,eAAe;AACvD,MAAI;AACF,UAAM,OAAO,WAAW;AAAA,EAC1B,QAAQ;AACN;AAAA,EACF;AAEA,QAAM,UAAU,MAAM,qBAAqB;AAC3C,MAAI,CAAC,QAAS;AAEd,QAAM,UAAU,KAAK,QAAQ,IAAI,GAAG,QAAQ,uBAAuB;AAEnE,MAAI;AACF,UAAM,WAAW,MAAM,SAAS,SAAS,OAAO;AAChD,QAAI,aAAa,QAAS;AAAA,EAC5B,QAAQ;AAAA,EAER;AAEA,QAAM,MAAM,KAAK,QAAQ,IAAI,GAAG,MAAM,GAAG,EAAE,WAAW,KAAK,CAAC;AAC5D,QAAM,UAAU,SAAS,SAAS,OAAO;AACzC,EAAO,QAAQ,oCAAoC;AACrD;AAEA,eAAe,uBAA+C;AAE5D,QAAM,WAAW,KAAK,WAAW,aAAa,WAAW,QAAQ,uBAAuB;AAExF,QAAM,UAAU,KAAK,WAAW,MAAM,aAAa,WAAW,QAAQ,uBAAuB;AAE7F,aAAW,QAAQ,CAAC,UAAU,OAAO,GAAG;AACtC,QAAI;AACF,aAAO,MAAM,SAAS,MAAM,OAAO;AAAA,IACrC,QAAQ;AACN;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yamchart",
3
- "version": "0.1.4",
3
+ "version": "0.3.1",
4
4
  "description": "Git-native business intelligence dashboards",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -42,9 +42,10 @@
42
42
  "picocolors": "^1.1.0",
43
43
  "yaml": "^2.7.0",
44
44
  "zod": "^3.24.0",
45
+ "@yamchart/auth-local": "0.1.0",
45
46
  "@yamchart/query": "0.1.2",
46
- "@yamchart/schema": "0.1.2",
47
- "@yamchart/server": "0.1.2"
47
+ "@yamchart/server": "0.1.2",
48
+ "@yamchart/schema": "0.1.2"
48
49
  },
49
50
  "devDependencies": {
50
51
  "@types/node": "^22.0.0",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/validate.ts","../src/utils/config.ts","../src/utils/output.ts"],"sourcesContent":["import { readFile, readdir, access } from 'fs/promises';\nimport { join, extname, relative } from 'path';\nimport { parse as parseYaml } from 'yaml';\nimport {\n ProjectSchema,\n ConnectionSchema,\n ChartSchema,\n DashboardSchema,\n} from '@yamchart/schema';\nimport { parseModelMetadata } from '@yamchart/query';\n\nexport interface ValidationError {\n file: string;\n line?: number;\n message: string;\n suggestion?: string;\n}\n\nexport interface ValidationResult {\n success: boolean;\n errors: ValidationError[];\n warnings: ValidationError[];\n stats: {\n files: number;\n passed: number;\n failed: number;\n };\n dryRunStats?: {\n passed: number;\n failed: number;\n };\n}\n\nexport interface ValidateOptions {\n dryRun: boolean;\n connection?: string;\n}\n\ninterface LoadedConfig {\n project: { name: string; version: string; defaults?: { connection?: string } } | null;\n connections: Map<string, { name: string; type: string }>;\n models: Map<string, { name: string; sql: string }>;\n charts: Map<string, { name: string; source: { model?: string; sql?: string } }>;\n dashboards: Map<string, { name: string; layout: unknown }>;\n}\n\nexport async function validateProject(\n projectDir: string,\n options: ValidateOptions\n): Promise<ValidationResult> {\n const errors: ValidationError[] = [];\n const warnings: ValidationError[] = [];\n let filesChecked = 0;\n let filesPassed = 0;\n\n const config: LoadedConfig = {\n project: null,\n connections: new Map(),\n models: new Map(),\n charts: new Map(),\n dashboards: new Map(),\n };\n\n // Phase 1: Schema validation\n\n // Validate yamchart.yaml\n const projectPath = join(projectDir, 'yamchart.yaml');\n try {\n await access(projectPath);\n filesChecked++;\n const content = await readFile(projectPath, 'utf-8');\n const parsed = parseYaml(content);\n const result = ProjectSchema.safeParse(parsed);\n\n if (result.success) {\n config.project = result.data;\n filesPassed++;\n } else {\n errors.push({\n file: 'yamchart.yaml',\n message: `Invalid schema: ${result.error.errors[0]?.message || 'Unknown error'}`,\n });\n }\n } catch {\n errors.push({\n file: 'yamchart.yaml',\n message: 'yamchart.yaml not found',\n });\n return {\n success: false,\n errors,\n warnings,\n stats: { files: filesChecked, passed: filesPassed, failed: filesChecked - filesPassed },\n };\n }\n\n // Validate connections\n const connectionsDir = join(projectDir, 'connections');\n try {\n await access(connectionsDir);\n const files = await readdir(connectionsDir);\n\n for (const file of files) {\n if (extname(file) !== '.yaml' && extname(file) !== '.yml') continue;\n filesChecked++;\n\n const filePath = join(connectionsDir, file);\n const content = await readFile(filePath, 'utf-8');\n const parsed = parseYaml(content);\n const result = ConnectionSchema.safeParse(parsed);\n\n if (result.success) {\n config.connections.set(result.data.name, result.data);\n filesPassed++;\n } else {\n errors.push({\n file: `connections/${file}`,\n message: `Invalid schema: ${result.error.errors[0]?.message || 'Unknown error'}`,\n });\n }\n }\n } catch {\n // No connections directory is ok\n }\n\n // Validate models\n const modelsDir = join(projectDir, 'models');\n const modelStats = { filesChecked: 0, filesPassed: 0 };\n try {\n await access(modelsDir);\n await validateModelsDir(modelsDir, projectDir, config, errors, modelStats);\n filesChecked += modelStats.filesChecked;\n filesPassed += modelStats.filesPassed;\n } catch {\n // No models directory is ok\n }\n\n // Validate charts\n const chartsDir = join(projectDir, 'charts');\n try {\n await access(chartsDir);\n const files = await readdir(chartsDir);\n\n for (const file of files) {\n if (extname(file) !== '.yaml' && extname(file) !== '.yml') continue;\n filesChecked++;\n\n const filePath = join(chartsDir, file);\n const content = await readFile(filePath, 'utf-8');\n const parsed = parseYaml(content);\n const result = ChartSchema.safeParse(parsed);\n\n if (result.success) {\n config.charts.set(result.data.name, result.data);\n filesPassed++;\n } else {\n errors.push({\n file: `charts/${file}`,\n message: `Invalid schema: ${result.error.errors[0]?.message || 'Unknown error'}`,\n });\n }\n }\n } catch {\n // No charts directory is ok\n }\n\n // Validate dashboards\n const dashboardsDir = join(projectDir, 'dashboards');\n try {\n await access(dashboardsDir);\n const files = await readdir(dashboardsDir);\n\n for (const file of files) {\n if (extname(file) !== '.yaml' && extname(file) !== '.yml') continue;\n filesChecked++;\n\n const filePath = join(dashboardsDir, file);\n const content = await readFile(filePath, 'utf-8');\n const parsed = parseYaml(content);\n const result = DashboardSchema.safeParse(parsed);\n\n if (result.success) {\n config.dashboards.set(result.data.name, result.data);\n filesPassed++;\n } else {\n errors.push({\n file: `dashboards/${file}`,\n message: `Invalid schema: ${result.error.errors[0]?.message || 'Unknown error'}`,\n });\n }\n }\n } catch {\n // No dashboards directory is ok\n }\n\n // Phase 2: Cross-reference validation\n crossReferenceValidation(config, errors, warnings);\n\n // Phase 3: Dry-run query validation (if enabled)\n let dryRunStats: { passed: number; failed: number } | undefined;\n if (options.dryRun) {\n dryRunStats = await dryRunValidation(projectDir, config, options.connection, errors);\n }\n\n return {\n success: errors.length === 0,\n errors,\n warnings,\n stats: {\n files: filesChecked,\n passed: filesPassed,\n failed: filesChecked - filesPassed,\n },\n dryRunStats,\n };\n}\n\nasync function validateModelsDir(\n dir: string,\n projectDir: string,\n config: LoadedConfig,\n errors: ValidationError[],\n stats: { filesChecked: number; filesPassed: number }\n): Promise<void> {\n const entries = await readdir(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = join(dir, entry.name);\n\n if (entry.isDirectory()) {\n await validateModelsDir(fullPath, projectDir, config, errors, stats);\n } else if (extname(entry.name) === '.sql') {\n stats.filesChecked++;\n const relPath = relative(projectDir, fullPath);\n const content = await readFile(fullPath, 'utf-8');\n\n try {\n const parsed = parseModelMetadata(content);\n config.models.set(parsed.name, { name: parsed.name, sql: parsed.sql });\n stats.filesPassed++;\n } catch (err) {\n errors.push({\n file: relPath,\n message: err instanceof Error ? err.message : 'Failed to parse model',\n });\n }\n }\n }\n}\n\nfunction crossReferenceValidation(\n config: LoadedConfig,\n errors: ValidationError[],\n warnings: ValidationError[]\n): void {\n // Check that charts reference existing models\n for (const [chartName, chart] of config.charts) {\n if (chart.source.model && !config.models.has(chart.source.model)) {\n const suggestion = findSimilar(chart.source.model, Array.from(config.models.keys()));\n errors.push({\n file: `charts/${chartName}.yaml`,\n message: `Unknown model reference \"${chart.source.model}\"`,\n suggestion: suggestion ? `Did you mean \"${suggestion}\"?` : undefined,\n });\n }\n }\n\n // Check that default connection exists\n if (config.project?.defaults?.connection) {\n const connName = config.project.defaults.connection;\n if (!config.connections.has(connName)) {\n const suggestion = findSimilar(connName, Array.from(config.connections.keys()));\n errors.push({\n file: 'yamchart.yaml',\n message: `Default connection \"${connName}\" not found`,\n suggestion: suggestion ? `Did you mean \"${suggestion}\"?` : undefined,\n });\n }\n }\n}\n\nfunction findSimilar(target: string, candidates: string[]): string | null {\n const threshold = 3; // Levenshtein distance threshold\n\n for (const candidate of candidates) {\n if (levenshtein(target.toLowerCase(), candidate.toLowerCase()) <= threshold) {\n return candidate;\n }\n }\n return null;\n}\n\nfunction levenshtein(a: string, b: string): number {\n const matrix: number[][] = [];\n\n for (let i = 0; i <= b.length; i++) {\n matrix[i] = [i];\n }\n for (let j = 0; j <= a.length; j++) {\n matrix[0]![j] = j;\n }\n\n for (let i = 1; i <= b.length; i++) {\n for (let j = 1; j <= a.length; j++) {\n if (b.charAt(i - 1) === a.charAt(j - 1)) {\n matrix[i]![j] = matrix[i - 1]![j - 1]!;\n } else {\n matrix[i]![j] = Math.min(\n matrix[i - 1]![j - 1]! + 1,\n matrix[i]![j - 1]! + 1,\n matrix[i - 1]![j]! + 1\n );\n }\n }\n }\n\n return matrix[b.length]![a.length]!;\n}\n\nasync function dryRunValidation(\n projectDir: string,\n config: LoadedConfig,\n connectionName: string | undefined,\n errors: ValidationError[]\n): Promise<{ passed: number; failed: number }> {\n const { DuckDBConnector } = await import('@yamchart/query');\n\n let passed = 0;\n let failed = 0;\n\n // Determine which connection to use\n const connName = connectionName || config.project?.defaults?.connection;\n if (!connName) {\n errors.push({\n file: 'yamchart.yaml',\n message: 'No connection specified for dry-run (use --connection or set defaults.connection)',\n });\n return { passed, failed: 1 };\n }\n\n const connection = config.connections.get(connName);\n if (!connection) {\n errors.push({\n file: 'yamchart.yaml',\n message: `Connection \"${connName}\" not found`,\n });\n return { passed, failed: 1 };\n }\n\n // Only DuckDB supported for now\n if (connection.type !== 'duckdb') {\n errors.push({\n file: `connections/${connName}.yaml`,\n message: `Dry-run not yet supported for connection type \"${connection.type}\"`,\n });\n return { passed, failed: 1 };\n }\n\n // Load full connection config to get path\n const connPath = join(projectDir, 'connections', `${connName}.yaml`);\n const connContent = await readFile(connPath, 'utf-8');\n const connConfig = parseYaml(connContent) as { config: { path: string } };\n\n // Resolve path relative to project\n const dbPath = connConfig.config.path.startsWith('/')\n ? connConfig.config.path\n : join(projectDir, connConfig.config.path);\n\n const connector = new DuckDBConnector({ path: dbPath });\n\n try {\n await connector.connect();\n\n for (const [modelName, model] of config.models) {\n const result = await connector.explain(model.sql);\n\n if (result.valid) {\n passed++;\n } else {\n failed++;\n errors.push({\n file: `models/${modelName}.sql`,\n message: result.error || 'Query validation failed',\n });\n }\n }\n } finally {\n await connector.disconnect();\n }\n\n return { passed, failed };\n}\n","import { access } from 'fs/promises';\nimport { join, dirname, resolve } from 'path';\nimport { config as loadDotenv } from 'dotenv';\n\n/**\n * Find the project root by looking for yamchart.yaml.\n * Searches current directory and parent directories.\n */\nexport async function findProjectRoot(startDir: string): Promise<string | null> {\n let currentDir = resolve(startDir);\n const root = dirname(currentDir);\n\n while (currentDir !== root) {\n const configPath = join(currentDir, 'yamchart.yaml');\n try {\n await access(configPath);\n return currentDir;\n } catch {\n currentDir = dirname(currentDir);\n }\n }\n\n // Check root directory too\n try {\n await access(join(root, 'yamchart.yaml'));\n return root;\n } catch {\n return null;\n }\n}\n\n/**\n * Load .env file from project directory.\n */\nexport function loadEnvFile(projectDir: string): void {\n loadDotenv({ path: join(projectDir, '.env') });\n}\n\n/**\n * Resolve ${VAR} syntax in a string from environment variables.\n */\nexport function resolveEnvVars(value: string): string {\n return value.replace(/\\$\\{([^}]+)\\}/g, (match, varName) => {\n const envValue = process.env[varName];\n if (envValue === undefined) {\n throw new Error(`Environment variable not found: ${varName}`);\n }\n return envValue;\n });\n}\n\n/**\n * Recursively resolve env vars in an object.\n */\nexport function resolveEnvVarsInObject<T>(obj: T): T {\n if (typeof obj === 'string') {\n return resolveEnvVars(obj) as T;\n }\n if (Array.isArray(obj)) {\n return obj.map(resolveEnvVarsInObject) as T;\n }\n if (obj !== null && typeof obj === 'object') {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n result[key] = resolveEnvVarsInObject(value);\n }\n return result as T;\n }\n return obj;\n}\n","import pc from 'picocolors';\nimport ora, { type Ora } from 'ora';\n\nexport const symbols = {\n success: pc.green('✓'),\n error: pc.red('✗'),\n warning: pc.yellow('⚠'),\n info: pc.blue('ℹ'),\n arrow: pc.dim('→'),\n};\n\nexport function success(message: string): void {\n console.log(`${symbols.success} ${message}`);\n}\n\nexport function error(message: string): void {\n console.log(`${symbols.error} ${message}`);\n}\n\nexport function warning(message: string): void {\n console.log(`${symbols.warning} ${message}`);\n}\n\nexport function info(message: string): void {\n console.log(`${symbols.info} ${message}`);\n}\n\nexport function detail(message: string): void {\n console.log(` ${symbols.arrow} ${message}`);\n}\n\nexport function newline(): void {\n console.log();\n}\n\nexport function header(title: string): void {\n console.log(pc.bold(title));\n newline();\n}\n\nexport function spinner(text: string): Ora {\n return ora({ text, color: 'cyan' }).start();\n}\n\nexport function box(lines: string[]): void {\n const maxLength = Math.max(...lines.map((l) => l.length));\n const width = maxLength + 4;\n const border = '─'.repeat(width);\n\n console.log(` ┌${border}┐`);\n for (const line of lines) {\n const padding = ' '.repeat(maxLength - line.length);\n console.log(` │ ${line}${padding} │`);\n }\n console.log(` └${border}┘`);\n}\n"],"mappings":";AAAA,SAAS,UAAU,SAAS,cAAc;AAC1C,SAAS,MAAM,SAAS,gBAAgB;AACxC,SAAS,SAAS,iBAAiB;AACnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AAqCnC,eAAsB,gBACpB,YACA,SAC2B;AAC3B,QAAM,SAA4B,CAAC;AACnC,QAAM,WAA8B,CAAC;AACrC,MAAI,eAAe;AACnB,MAA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C,EAAE,MAAM;AAC5C;AAEO,SAAS,IAAI,OAAuB;AACzC,QAAM,YAAY,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;AACxD,QAAM,QAAQ,YAAY;AAC1B,QAAM,SAAS,SAAI,OAAO,KAAK;AAE/B,UAAQ,IAAI,WAAM,MAAM,QAAG;AAC3B,aAAW,QAAQ,OAAO;AACxB,UAAM,UAAU,IAAI,OAAO,YAAY,KAAK,MAAM;AAClD,YAAQ,IAAI,aAAQ,IAAI,GAAG,OAAO,UAAK;AAAA,EACzC;AACA,UAAQ,IAAI,WAAM,MAAM,QAAG;AAC7B;","names":["access","join"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/dev.ts"],"sourcesContent":["import { createServer, type DashbookServer } from '@yamchart/server';\nimport * as output from '../utils/output.js';\nimport { validateProject } from './validate.js';\nimport { loadEnvFile } from '../utils/config.js';\n\nexport interface DevOptions {\n port: number;\n apiOnly: boolean;\n open: boolean;\n}\n\nexport async function runDevServer(\n projectDir: string,\n options: DevOptions\n): Promise<void> {\n // Load .env file\n loadEnvFile(projectDir);\n\n // Validate first\n output.header('Validating configuration...');\n\n const validation = await validateProject(projectDir, { dryRun: false });\n\n if (!validation.success) {\n for (const error of validation.errors) {\n output.error(error.file);\n output.detail(error.message);\n if (error.suggestion) {\n output.detail(error.suggestion);\n }\n }\n output.newline();\n output.error(`Validation failed with ${validation.errors.length} error(s)`);\n process.exit(1);\n }\n\n output.success(`Validation passed (${validation.stats.passed} files)`);\n output.newline();\n\n // Start server\n const spinner = output.spinner('Starting server...');\n\n let server: DashbookServer;\n\n try {\n server = await createServer({\n projectDir,\n port: options.port,\n watch: true,\n serveStatic: !options.apiOnly,\n });\n\n await server.start();\n spinner.stop();\n } catch (err) {\n spinner.fail('Failed to start server');\n output.error(err instanceof Error ? err.message : 'Unknown error');\n process.exit(1);\n }\n\n // Print status\n const project = server.configLoader.getProject();\n const charts = server.configLoader.getCharts();\n const models = server.configLoader.getModels();\n\n output.newline();\n output.box([\n `Dashbook v0.1.0`,\n ``,\n `Dashboard: http://localhost:${options.port}`,\n `API: http://localhost:${options.port}/api`,\n ``,\n `Project: ${project.name}`,\n `Charts: ${charts.length} loaded`,\n `Models: ${models.length} loaded`,\n ``,\n `Watching for changes...`,\n ]);\n output.newline();\n\n // Open browser\n if (options.open && !options.apiOnly) {\n const url = `http://localhost:${options.port}`;\n const { exec } = await import('child_process');\n const command = process.platform === 'darwin' ? 'open' :\n process.platform === 'win32' ? 'start' : 'xdg-open';\n exec(`${command} ${url}`);\n }\n\n // Handle shutdown\n const shutdown = async () => {\n output.newline();\n output.info('Shutting down...');\n await server.stop();\n process.exit(0);\n };\n\n process.on('SIGINT', shutdown);\n process.on('SIGTERM', shutdown);\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,oBAAyC;AAWlD,eAAsB,aACpB,YACA,SACe;AAEf,cAAY,UAAU;AAGtB,EAAO,OAAO,6BAA6B;AAE3C,QAAM,aAAa,MAAM,gBAAgB,YAAY,EAAE,QAAQ,MAAM,CAAC;AAEtE,MAAI,CAAC,WAAW,SAAS;AACvB,eAAWA,UAAS,WAAW,QAAQ;AACrC,MAAO,MAAMA,OAAM,IAAI;AACvB,MAAO,OAAOA,OAAM,OAAO;AAC3B,UAAIA,OAAM,YAAY;AACpB,QAAO,OAAOA,OAAM,UAAU;AAAA,MAChC;AAAA,IACF;AACA,IAAO,QAAQ;AACf,IAAO,MAAM,0BAA0B,WAAW,OAAO,MAAM,WAAW;AAC1E,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,EAAO,QAAQ,sBAAsB,WAAW,MAAM,MAAM,SAAS;AACrE,EAAO,QAAQ;AAGf,QAAMC,WAAiB,QAAQ,oBAAoB;AAEnD,MAAI;AAEJ,MAAI;AACF,aAAS,MAAM,aAAa;AAAA,MAC1B;AAAA,MACA,MAAM,QAAQ;AAAA,MACd,OAAO;AAAA,MACP,aAAa,CAAC,QA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