zenstack-kit 0.1.3 → 0.1.5

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/README.md CHANGED
@@ -124,6 +124,7 @@ Options:
124
124
  - `-m, --migrations <path>` - Migrations directory
125
125
  - `--baseline` - Create snapshot only, no migration
126
126
  - `--create-initial` - Create snapshot and initial migration
127
+ - `-c, --config <path>` - Path to zenstack-kit config file
127
128
 
128
129
  ### `zenstack-kit migrate:generate`
129
130
 
@@ -138,6 +139,7 @@ Options:
138
139
  - `-s, --schema <path>` - Path to ZenStack schema
139
140
  - `-m, --migrations <path>` - Migrations directory
140
141
  - `--dialect <dialect>` - Database dialect (`sqlite`, `postgres`, `mysql`)
142
+ - `-c, --config <path>` - Path to zenstack-kit config file
141
143
 
142
144
  ### `zenstack-kit migrate:apply`
143
145
 
@@ -153,6 +155,8 @@ Options:
153
155
  - `--url <url>` - Database connection URL (overrides config)
154
156
  - `--table <name>` - Migrations table name (default: `_prisma_migrations`)
155
157
  - `--db-schema <name>` - Database schema for migrations table (PostgreSQL only, default: `public`)
158
+ - `--preview` - Preview pending migrations without applying
159
+ - `-c, --config <path>` - Path to zenstack-kit config file
156
160
 
157
161
  ### `zenstack-kit pull`
158
162
 
@@ -166,6 +170,7 @@ Options:
166
170
  - `-o, --output <path>` - Output path for schema (default: `./schema.zmodel`)
167
171
  - `--dialect <dialect>` - Database dialect
168
172
  - `--url <url>` - Database connection URL
173
+ - `-c, --config <path>` - Path to zenstack-kit config file
169
174
 
170
175
  Features:
171
176
  - Detects tables, columns, and types
@@ -289,6 +294,11 @@ const { db, destroy } = await createKyselyAdapter({
289
294
  await destroy();
290
295
  ```
291
296
 
297
+ ## Experimental
298
+
299
+ The `introspectSchema` API is experimental and uses a simplified parser. Expect
300
+ limitations with complex schemas.
301
+
292
302
  ## Prisma Compatibility
293
303
 
294
304
  zenstack-kit is designed to be compatible with Prisma's migration system:
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/cli/app.tsx"],"names":[],"mappings":";AAEA;;;;;;;;GAQG;AAuSH,wBAAgB,MAAM,SAkBrB"}
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/cli/app.tsx"],"names":[],"mappings":";AAEA;;;;;;;;GAQG;AA0SH,wBAAgB,MAAM,SAkBrB"}
package/dist/cli/app.js CHANGED
@@ -77,6 +77,9 @@ function parseArgs() {
77
77
  else if (arg === "--force" || arg === "-f") {
78
78
  options.force = true;
79
79
  }
80
+ else if (arg === "--config" || arg === "-c") {
81
+ options.config = args[++i];
82
+ }
80
83
  }
81
84
  return { command, options };
82
85
  }
@@ -98,7 +101,7 @@ function Status({ type, message }) {
98
101
  }
99
102
  // Help display component
100
103
  function HelpDisplay() {
101
- return (_jsxs(Box, { flexDirection: "column", paddingY: 1, children: [_jsx(Text, { bold: true, color: "cyan", children: "zenstack-kit" }), _jsx(Text, { dimColor: true, children: "Database tooling for ZenStack schemas" }), _jsx(Text, { children: " " }), _jsx(Text, { bold: true, children: "Commands:" }), commands.filter(c => c.value !== "exit").map((cmd) => (_jsxs(Box, { marginLeft: 2, children: [_jsx(Box, { width: 20, children: _jsx(Text, { color: "yellow", children: cmd.label }) }), _jsx(Text, { dimColor: true, children: cmd.description })] }, cmd.value))), _jsx(Text, { children: " " }), _jsx(Text, { bold: true, children: "Options:" }), _jsxs(Box, { marginLeft: 2, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "-s, --schema <path> Path to ZenStack schema" }), _jsx(Text, { dimColor: true, children: "-m, --migrations <path> Migrations directory" }), _jsx(Text, { dimColor: true, children: "-n, --name <name> Migration name" }), _jsx(Text, { dimColor: true, children: "--dialect <dialect> Database dialect (sqlite, postgres, mysql)" }), _jsx(Text, { dimColor: true, children: "--url <url> Database connection URL" }), _jsx(Text, { dimColor: true, children: "--create-initial Create initial migration (skip prompt)" }), _jsx(Text, { dimColor: true, children: "--baseline Create baseline only (skip prompt)" }), _jsx(Text, { dimColor: true, children: "--preview Preview pending migrations without applying" }), _jsx(Text, { dimColor: true, children: "-f, --force Force operation without confirmation" })] })] }));
104
+ return (_jsxs(Box, { flexDirection: "column", paddingY: 1, children: [_jsx(Text, { bold: true, color: "cyan", children: "zenstack-kit" }), _jsx(Text, { dimColor: true, children: "Database tooling for ZenStack schemas" }), _jsx(Text, { children: " " }), _jsx(Text, { bold: true, children: "Commands:" }), commands.filter(c => c.value !== "exit").map((cmd) => (_jsxs(Box, { marginLeft: 2, children: [_jsx(Box, { width: 20, children: _jsx(Text, { color: "yellow", children: cmd.label }) }), _jsx(Text, { dimColor: true, children: cmd.description })] }, cmd.value))), _jsx(Text, { children: " " }), _jsx(Text, { bold: true, children: "Options:" }), _jsxs(Box, { marginLeft: 2, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "-s, --schema <path> Path to ZenStack schema" }), _jsx(Text, { dimColor: true, children: "-m, --migrations <path> Migrations directory" }), _jsx(Text, { dimColor: true, children: "-n, --name <name> Migration name" }), _jsx(Text, { dimColor: true, children: "--dialect <dialect> Database dialect (sqlite, postgres, mysql)" }), _jsx(Text, { dimColor: true, children: "--url <url> Database connection URL" }), _jsx(Text, { dimColor: true, children: "--create-initial Create initial migration (skip prompt)" }), _jsx(Text, { dimColor: true, children: "--baseline Create baseline only (skip prompt)" }), _jsx(Text, { dimColor: true, children: "--preview Preview pending migrations without applying" }), _jsx(Text, { dimColor: true, children: "-f, --force Force operation without confirmation" }), _jsx(Text, { dimColor: true, children: "-c, --config <path> Path to zenstack-kit config file" })] })] }));
102
105
  }
103
106
  function CliApp({ initialCommand, options }) {
104
107
  const { exit } = useApp();
@@ -20,6 +20,7 @@ export interface CommandOptions {
20
20
  createInitial?: boolean;
21
21
  preview?: boolean;
22
22
  force?: boolean;
23
+ config?: string;
23
24
  }
24
25
  export interface CommandContext {
25
26
  cwd: string;
@@ -41,6 +42,7 @@ export declare class CommandError extends Error {
41
42
  */
42
43
  export declare function resolveConfig(ctx: CommandContext): Promise<{
43
44
  config: ZenStackKitConfig;
45
+ configDir: string;
44
46
  schemaPath: string;
45
47
  outputPath: string;
46
48
  dialect: "sqlite" | "postgres" | "mysql";
@@ -1 +1 @@
1
- {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkBH,OAAO,KAAK,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,MAAM,KAAK,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;AAE9F,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,cAAc,CAAC;IACxB,GAAG,EAAE,KAAK,CAAC;IACX,oBAAoB,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,cAAc,CAAC,CAAC;IAC9D,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,UAAU,GAAG,gBAAgB,CAAC,CAAC;IAC/D,iBAAiB,CAAC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;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA0GxE;AAED;;GAEG;AACH,wBAAsB,OAAO,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA0FhE;AAED;;GAEG;AACH,wBAAsB,OAAO,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAmEhE"}
@@ -19,8 +19,11 @@ export class CommandError extends Error {
19
19
  * Load and validate config, returning resolved paths
20
20
  */
21
21
  export async function resolveConfig(ctx) {
22
- const loaded = await loadConfig(ctx.cwd);
22
+ const loaded = await loadConfig(ctx.cwd, ctx.options.config);
23
23
  if (!loaded) {
24
+ if (ctx.options.config) {
25
+ throw new CommandError(`Config file not found: ${ctx.options.config}`);
26
+ }
24
27
  throw new CommandError("No zenstack-kit config file found.");
25
28
  }
26
29
  const { config, configDir } = loaded;
@@ -30,7 +33,7 @@ export async function resolveConfig(ctx) {
30
33
  // Resolve paths relative to config file location
31
34
  const schemaPath = path.resolve(configDir, relativeSchemaPath);
32
35
  const outputPath = path.resolve(configDir, relativeOutputPath);
33
- return { config, schemaPath, outputPath, dialect };
36
+ return { config, configDir, schemaPath, outputPath, dialect };
34
37
  }
35
38
  /**
36
39
  * Validate that the schema file exists (schemaPath should be absolute)
@@ -121,6 +124,7 @@ export async function runMigrateGenerate(ctx) {
121
124
  }
122
125
  ctx.log("success", `Migration created: ${migration.folderName}/migration.sql`);
123
126
  ctx.log("info", `Path: ${migration.folderPath}`);
127
+ ctx.log("info", "Next: run 'zenstack-kit migrate apply' (or --preview to review SQL).");
124
128
  }
125
129
  /**
126
130
  * migrate:apply command
@@ -146,7 +150,7 @@ export async function runMigrateApply(ctx) {
146
150
  const databasePath = dialect === "sqlite" ? connectionUrl : undefined;
147
151
  // Preview mode - show pending migrations without applying
148
152
  if (ctx.options.preview) {
149
- ctx.log("info", "Preview mode - showing pending migrations:");
153
+ ctx.log("info", "Preview mode - no changes will be applied.");
150
154
  const preview = await previewPrismaMigrations({
151
155
  migrationsFolder: outputPath,
152
156
  dialect,
@@ -162,8 +166,12 @@ export async function runMigrateApply(ctx) {
162
166
  }
163
167
  return;
164
168
  }
169
+ ctx.log("info", `Pending migrations: ${preview.pending.length}`);
170
+ if (preview.alreadyApplied.length > 0) {
171
+ ctx.log("info", `${preview.alreadyApplied.length} migration(s) already applied`);
172
+ }
165
173
  for (const migration of preview.pending) {
166
- ctx.log("info", `Pending: ${migration.name}`);
174
+ ctx.log("info", `Migration: ${migration.name}`);
167
175
  ctx.log("info", `SQL:\n${migration.sql}`);
168
176
  }
169
177
  return;
@@ -290,13 +298,14 @@ export async function runInit(ctx) {
290
298
  * pull command
291
299
  */
292
300
  export async function runPull(ctx) {
293
- const { config, dialect, outputPath: migrationsPath } = await resolveConfig(ctx);
301
+ const { config, configDir, dialect, outputPath: migrationsPath } = await resolveConfig(ctx);
294
302
  const connectionUrl = getConnectionUrl(config, dialect);
295
303
  if (dialect !== "sqlite" && !connectionUrl) {
296
304
  throw new CommandError("Database connection URL is required for non-sqlite dialects.");
297
305
  }
298
306
  const databasePath = dialect === "sqlite" ? connectionUrl : undefined;
299
- const schemaOutputPath = ctx.options.output || config.schema || "./schema.zmodel";
307
+ const relativeSchemaOutputPath = ctx.options.output || config.schema || "./schema.zmodel";
308
+ const schemaOutputPath = path.resolve(configDir, relativeSchemaOutputPath);
300
309
  // Check for existing files that would be affected
301
310
  const existingFiles = [];
302
311
  if (fs.existsSync(schemaOutputPath)) {
@@ -334,6 +343,7 @@ export async function runPull(ctx) {
334
343
  });
335
344
  ctx.log("success", `Schema generated: ${result.outputPath}`);
336
345
  ctx.log("info", `${result.tableCount} table(s) introspected`);
346
+ ctx.log("info", "Next: review the schema, then run 'zenstack-kit init' to reset the snapshot.");
337
347
  // If we have existing migrations, warn about resetting
338
348
  if (snapshotExists || migrations.length > 0) {
339
349
  ctx.log("warning", "You should run 'zenstack-kit init' to reset the snapshot after reviewing the schema.");
@@ -7,5 +7,5 @@ export interface LoadedConfig {
7
7
  configPath: string;
8
8
  configDir: string;
9
9
  }
10
- export declare function loadConfig(cwd: string): Promise<LoadedConfig | null>;
10
+ export declare function loadConfig(cwd: string, configPath?: string): Promise<LoadedConfig | null>;
11
11
  //# sourceMappingURL=loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAUpD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CA4B1E"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAUpD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CA+B/F"}
@@ -10,32 +10,34 @@ const CONFIG_FILES = [
10
10
  "zenstack-kit.config.mjs",
11
11
  "zenstack-kit.config.cjs",
12
12
  ];
13
- export async function loadConfig(cwd) {
14
- const configPath = CONFIG_FILES.map((file) => path.join(cwd, file)).find((file) => fs.existsSync(file));
15
- if (!configPath) {
13
+ export async function loadConfig(cwd, configPath) {
14
+ const resolvedConfigPath = configPath ? path.resolve(cwd, configPath) : null;
15
+ const configPathToLoad = resolvedConfigPath ??
16
+ CONFIG_FILES.map((file) => path.join(cwd, file)).find((file) => fs.existsSync(file));
17
+ if (!configPathToLoad) {
16
18
  return null;
17
19
  }
18
- const ext = path.extname(configPath);
20
+ const ext = path.extname(configPathToLoad);
19
21
  let config;
20
22
  if (ext === ".cjs") {
21
23
  const require = createRequire(import.meta.url);
22
- const loaded = require(configPath);
24
+ const loaded = require(configPathToLoad);
23
25
  config = (loaded.default ?? loaded);
24
26
  }
25
27
  else if (ext === ".js" || ext === ".mjs") {
26
- const loaded = await import(pathToFileUrl(configPath));
28
+ const loaded = await import(pathToFileUrl(configPathToLoad));
27
29
  config = (loaded.default ?? loaded);
28
30
  }
29
31
  else {
30
32
  const { default: jiti } = await import("jiti");
31
33
  const loader = jiti(import.meta.url, { interopDefault: true });
32
- const loaded = loader(configPath);
34
+ const loaded = loader(configPathToLoad);
33
35
  config = (loaded.default ?? loaded);
34
36
  }
35
37
  return {
36
38
  config,
37
- configPath,
38
- configDir: path.dirname(configPath),
39
+ configPath: configPathToLoad,
40
+ configDir: path.dirname(configPathToLoad),
39
41
  };
40
42
  }
41
43
  function pathToFileUrl(filePath) {
@@ -0,0 +1,52 @@
1
+ import type { KyselyDialect } from "../../sql/kysely-adapter.js";
2
+ export interface ApplyPrismaMigrationsOptions {
3
+ /** Migrations folder path */
4
+ migrationsFolder: string;
5
+ /** Database dialect */
6
+ dialect: KyselyDialect;
7
+ /** Database connection URL */
8
+ connectionUrl?: string;
9
+ /** SQLite database path */
10
+ databasePath?: string;
11
+ /** Migrations table name (default: _prisma_migrations) */
12
+ migrationsTable?: string;
13
+ /** Migrations schema (PostgreSQL only, default: public) */
14
+ migrationsSchema?: string;
15
+ }
16
+ export interface ApplyPrismaMigrationsResult {
17
+ applied: Array<{
18
+ migrationName: string;
19
+ duration: number;
20
+ }>;
21
+ alreadyApplied: string[];
22
+ failed?: {
23
+ migrationName: string;
24
+ error: string;
25
+ };
26
+ coherenceErrors?: MigrationCoherenceError[];
27
+ }
28
+ export interface MigrationCoherenceError {
29
+ type: "missing_from_log" | "missing_from_db" | "missing_from_disk" | "order_mismatch" | "checksum_mismatch";
30
+ migrationName: string;
31
+ details: string;
32
+ }
33
+ export interface MigrationCoherenceResult {
34
+ isCoherent: boolean;
35
+ errors: MigrationCoherenceError[];
36
+ }
37
+ export interface PreviewPrismaMigrationsResult {
38
+ pending: Array<{
39
+ name: string;
40
+ sql: string;
41
+ }>;
42
+ alreadyApplied: string[];
43
+ }
44
+ /**
45
+ * Apply pending Prisma migrations
46
+ */
47
+ export declare function applyPrismaMigrations(options: ApplyPrismaMigrationsOptions): Promise<ApplyPrismaMigrationsResult>;
48
+ /**
49
+ * Preview pending migrations without applying them
50
+ */
51
+ export declare function previewPrismaMigrations(options: ApplyPrismaMigrationsOptions): Promise<PreviewPrismaMigrationsResult>;
52
+ //# sourceMappingURL=apply.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../src/migrations/prisma/apply.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAIjE,MAAM,WAAW,4BAA4B;IAC3C,6BAA6B;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,uBAAuB;IACvB,OAAO,EAAE,aAAa,CAAC;IACvB,8BAA8B;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2BAA2B;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,2DAA2D;IAC3D,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,KAAK,CAAC;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5D,cAAc,EAAE,M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