@chkit/plugin-codegen 0.1.0-beta.17 → 0.1.0-beta.18
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-artifacts.d.ts","sourceRoot":"","sources":["../../src/generators/migration-artifacts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"migration-artifacts.d.ts","sourceRoot":"","sources":["../../src/generators/migration-artifacts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,+BAA+B,EAC/B,gCAAgC,EACjC,MAAM,aAAa,CAAA;AAiBpB,wBAAsB,0BAA0B,CAC9C,KAAK,EAAE,+BAA+B,GACrC,OAAO,CAAC,gCAAgC,CAAC,CA2C3C"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { readdir, readFile } from 'node:fs/promises';
|
|
2
|
-
import {
|
|
3
|
-
import { dirname, join } from 'node:path';
|
|
2
|
+
import { join } from 'node:path';
|
|
4
3
|
import { normalizeCodegenOptions } from '../options.js';
|
|
5
4
|
import { renderHeader } from './shared.js';
|
|
6
5
|
function escapeTemplateLiteral(sql) {
|
|
@@ -23,11 +22,12 @@ export async function generateMigrationArtifacts(input) {
|
|
|
23
22
|
})));
|
|
24
23
|
const header = renderHeader(toolVersion);
|
|
25
24
|
const migrationsArray = renderMigrationsArray(migrations);
|
|
26
|
-
const sqlSplitterSource = await readSqlSplitterSource();
|
|
27
25
|
// biome-ignore lint/style/useTemplate: join+concat is clearer here
|
|
28
26
|
const content = [
|
|
29
27
|
...header,
|
|
30
28
|
'',
|
|
29
|
+
"import { extractExecutableStatements } from '@chkit/core/utils'",
|
|
30
|
+
'',
|
|
31
31
|
'export interface MigrationEntry {',
|
|
32
32
|
' name: string',
|
|
33
33
|
' sql: string',
|
|
@@ -40,8 +40,6 @@ export async function generateMigrationArtifacts(input) {
|
|
|
40
40
|
'',
|
|
41
41
|
migrationsArray,
|
|
42
42
|
'',
|
|
43
|
-
sqlSplitterSource,
|
|
44
|
-
'',
|
|
45
43
|
RUN_MIGRATIONS_FUNCTION,
|
|
46
44
|
].join('\n').trimEnd() + '\n';
|
|
47
45
|
return {
|
|
@@ -50,27 +48,6 @@ export async function generateMigrationArtifacts(input) {
|
|
|
50
48
|
migrationCount: migrations.length,
|
|
51
49
|
};
|
|
52
50
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Reads the sql-splitter.ts source from @chkit/core and strips the export
|
|
55
|
-
* keywords so the functions are inlined as module-private in the generated file.
|
|
56
|
-
*/
|
|
57
|
-
async function readSqlSplitterSource() {
|
|
58
|
-
const require = createRequire(import.meta.url);
|
|
59
|
-
const corePath = require.resolve('@chkit/core');
|
|
60
|
-
const coreDir = dirname(corePath);
|
|
61
|
-
const splitterPath = join(coreDir, 'sql-splitter.ts');
|
|
62
|
-
let source;
|
|
63
|
-
try {
|
|
64
|
-
source = await readFile(splitterPath, 'utf8');
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
// Fallback: try .js in case we're running from dist
|
|
68
|
-
const jsPath = join(coreDir, 'sql-splitter.js');
|
|
69
|
-
source = await readFile(jsPath, 'utf8');
|
|
70
|
-
}
|
|
71
|
-
// Strip export keywords — these become module-private functions in the generated file
|
|
72
|
-
return source.replace(/^export /gm, '');
|
|
73
|
-
}
|
|
74
51
|
// The runMigrations function is static — it doesn't depend on the SQL splitter source,
|
|
75
52
|
// so it's safe to keep as a constant string.
|
|
76
53
|
const RUN_MIGRATIONS_FUNCTION = `/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-artifacts.js","sourceRoot":"","sources":["../../src/generators/migration-artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"migration-artifacts.js","sourceRoot":"","sources":["../../src/generators/migration-artifacts.ts"],"names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AAM,UAAU,GAAG,MAAM,OAAO,CAAC,GAAG,CAClC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QAC5B,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;QAChC,GAAG,EAAE,MAAM,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC;KAC7D,CAAC,CAAC,CACJ,CAAA;IAED,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,CAAC,CAAA;IACxC,MAAM,eAAe,GAAG,qBAAqB,CAAC,UAAU,CAAC,CAAA;IAEzD,mEAAmE;IACnE,MAAM,OAAO,GAAG;QACd,GAAG,MAAM;QACT,EAAE;QACF,iEAAiE;QACjE,EAAE;QACF,mCAAmC;QACnC,gBAAgB;QAChB,eAAe;QACf,GAAG;QACH,EAAE;QACF,sCAAsC;QACtC,uCAAuC;QACvC,uCAAuC;QACvC,GAAG;QACH,EAAE;QACF,eAAe;QACf,EAAE;QACF,uBAAuB;KACxB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAA;IAE7B,OAAO;QACL,OAAO;QACP,OAAO,EAAE,UAAU,CAAC,iBAAiB;QACrC,cAAc,EAAE,UAAU,CAAC,MAAM;KAClC,CAAA;AACH,CAAC;AAED,uFAAuF;AACvF,6CAA6C;AAC7C,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgD9B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chkit/plugin-codegen",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.18",
|
|
4
4
|
"description": "TypeScript type and Zod schema generation plugin for chkit",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ObsessionDB",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"clean": "rm -rf dist"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@chkit/core": "0.1.0-beta.
|
|
45
|
+
"@chkit/core": "0.1.0-beta.18"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"zod": "^4.3.6"
|