@korajs/cli 0.1.5 → 0.1.8
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/bin.cjs +83 -81
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +49 -61
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-TZPACPP6.js → chunk-AUDUNRYA.js} +27 -11
- package/dist/chunk-AUDUNRYA.js.map +1 -0
- package/dist/create.cjs.map +1 -1
- package/dist/create.js +1 -1
- package/package.json +1 -1
- package/templates/react-basic/package.json.hbs +2 -0
- package/templates/react-basic/src/kora-worker.ts +3 -0
- package/templates/react-basic/src/main.tsx +7 -2
- package/templates/react-basic/vite.config.ts +3 -0
- package/templates/react-sync/package.json.hbs +2 -0
- package/templates/react-sync/src/kora-worker.ts +3 -0
- package/templates/react-sync/src/main.tsx +4 -1
- package/templates/react-sync/vite.config.ts +3 -0
- package/dist/chunk-TZPACPP6.js.map +0 -1
package/dist/bin.cjs
CHANGED
|
@@ -146,17 +146,32 @@ async function findSchemaFile(projectRoot) {
|
|
|
146
146
|
}
|
|
147
147
|
return null;
|
|
148
148
|
}
|
|
149
|
-
async function
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
149
|
+
async function hasTsxInstalled(projectRoot) {
|
|
150
|
+
try {
|
|
151
|
+
await (0, import_promises.access)((0, import_node_path.join)(projectRoot, "node_modules", "tsx", "package.json"));
|
|
152
|
+
return true;
|
|
153
|
+
} catch {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async function resolveProjectBinaryEntryPoint(projectRoot, packageName, binaryName) {
|
|
158
|
+
const pkgJsonPath = (0, import_node_path.join)(projectRoot, "node_modules", packageName, "package.json");
|
|
159
|
+
try {
|
|
160
|
+
const content = await (0, import_promises.readFile)(pkgJsonPath, "utf-8");
|
|
161
|
+
const pkg = JSON.parse(content);
|
|
162
|
+
let binPath;
|
|
163
|
+
if (typeof pkg.bin === "string") {
|
|
164
|
+
binPath = pkg.bin;
|
|
165
|
+
} else if (typeof pkg.bin === "object" && pkg.bin !== null) {
|
|
166
|
+
binPath = pkg.bin[binaryName];
|
|
167
|
+
}
|
|
168
|
+
if (!binPath) return null;
|
|
169
|
+
const fullPath = (0, import_node_path.join)(projectRoot, "node_modules", packageName, binPath);
|
|
170
|
+
await (0, import_promises.access)(fullPath);
|
|
171
|
+
return fullPath;
|
|
172
|
+
} catch {
|
|
173
|
+
return null;
|
|
158
174
|
}
|
|
159
|
-
return null;
|
|
160
175
|
}
|
|
161
176
|
function isKoraProject(pkg) {
|
|
162
177
|
if (typeof pkg !== "object" || pkg === null) return false;
|
|
@@ -473,8 +488,8 @@ function resolveKoraVersion() {
|
|
|
473
488
|
|
|
474
489
|
// src/commands/dev/dev-command.ts
|
|
475
490
|
var import_promises4 = require("fs/promises");
|
|
476
|
-
var import_node_path5 = require("path");
|
|
477
491
|
var import_node_path6 = require("path");
|
|
492
|
+
var import_node_path7 = require("path");
|
|
478
493
|
var import_citty2 = require("citty");
|
|
479
494
|
|
|
480
495
|
// src/commands/dev/kora-config.ts
|
|
@@ -513,20 +528,17 @@ async function findKoraConfigFile(projectRoot) {
|
|
|
513
528
|
return null;
|
|
514
529
|
}
|
|
515
530
|
async function loadTypeScriptConfig(configPath, projectRoot) {
|
|
516
|
-
|
|
517
|
-
if (!tsxBinary) {
|
|
531
|
+
if (!await hasTsxInstalled(projectRoot)) {
|
|
518
532
|
throw new Error(
|
|
519
533
|
`Found TypeScript config at ${configPath}, but "tsx" is not installed in this project. Install tsx or use kora.config.js.`
|
|
520
534
|
);
|
|
521
535
|
}
|
|
522
|
-
const script = [
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
"
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
].join(";");
|
|
529
|
-
const output = await runCommand(tsxBinary, ["--eval", script, configPath], projectRoot);
|
|
536
|
+
const script = "const configPath = process.argv[process.argv.length - 1];import('node:url').then(u => import(u.pathToFileURL(configPath).href)).then(mod => { const v = mod.default ?? mod; process.stdout.write(JSON.stringify(v)) }).catch(e => { process.stderr.write(String(e)); process.exit(1) })";
|
|
537
|
+
const output = await runCommand(
|
|
538
|
+
process.execPath,
|
|
539
|
+
["--import", "tsx", "--eval", script, configPath],
|
|
540
|
+
projectRoot
|
|
541
|
+
);
|
|
530
542
|
try {
|
|
531
543
|
return JSON.parse(output);
|
|
532
544
|
} catch {
|
|
@@ -579,9 +591,7 @@ var ProcessManager = class {
|
|
|
579
591
|
const options = {
|
|
580
592
|
cwd: config.cwd,
|
|
581
593
|
env: { ...process.env, ...config.env },
|
|
582
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
583
|
-
// On Windows, .cmd shims require shell to execute
|
|
584
|
-
shell: process.platform === "win32"
|
|
594
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
585
595
|
};
|
|
586
596
|
const child = (0, import_node_child_process4.spawn)(config.command, config.args, options);
|
|
587
597
|
let resolveExit;
|
|
@@ -663,6 +673,7 @@ function delay(ms) {
|
|
|
663
673
|
// src/commands/dev/schema-watcher.ts
|
|
664
674
|
var import_node_child_process5 = require("child_process");
|
|
665
675
|
var import_node_fs3 = require("fs");
|
|
676
|
+
var import_node_path5 = require("path");
|
|
666
677
|
var SchemaWatcher = class {
|
|
667
678
|
constructor(config) {
|
|
668
679
|
this.config = config;
|
|
@@ -690,16 +701,10 @@ var SchemaWatcher = class {
|
|
|
690
701
|
this.watcher = null;
|
|
691
702
|
}
|
|
692
703
|
async regenerate() {
|
|
693
|
-
const
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
const tsxBinary = await resolveProjectBinary(this.config.projectRoot, "tsx");
|
|
698
|
-
if (!tsxBinary) {
|
|
699
|
-
process.stderr.write('[kora] Could not find "tsx" binary. Falling back to node.\n');
|
|
700
|
-
}
|
|
701
|
-
const command = tsxBinary ?? process.execPath;
|
|
702
|
-
const args = [koraBinary, "generate", "types", "--schema", this.config.schemaPath];
|
|
704
|
+
const koraBinJs = (0, import_node_path5.join)(this.config.projectRoot, "node_modules", "@korajs", "cli", "dist", "bin.js");
|
|
705
|
+
const hasTsx = await hasTsxInstalled(this.config.projectRoot);
|
|
706
|
+
const command = process.execPath;
|
|
707
|
+
const args = hasTsx ? ["--import", "tsx", koraBinJs, "generate", "types", "--schema", this.config.schemaPath] : [koraBinJs, "generate", "types", "--schema", this.config.schemaPath];
|
|
703
708
|
await spawnCommand(command, args, this.config.projectRoot);
|
|
704
709
|
this.config.onRegenerate?.();
|
|
705
710
|
}
|
|
@@ -793,25 +798,25 @@ var devCommand = (0, import_citty2.defineCommand)({
|
|
|
793
798
|
const configSyncEnabled = config?.dev?.sync === void 0 || config.dev.sync === true || typeof config.dev.sync === "object" && config.dev.sync.enabled !== false;
|
|
794
799
|
const configWatchEnabled = config?.dev?.watch === void 0 || config.dev.watch === true || typeof config.dev.watch === "object" && config.dev.watch.enabled !== false;
|
|
795
800
|
const watchDebounceMs = typeof config?.dev?.watch === "object" && typeof config.dev.watch.debounceMs === "number" ? config.dev.watch.debounceMs : 300;
|
|
796
|
-
const
|
|
797
|
-
if (!
|
|
798
|
-
throw new DevServerError("vite", (0,
|
|
801
|
+
const viteEntryPoint = await resolveProjectBinaryEntryPoint(projectRoot, "vite", "vite");
|
|
802
|
+
if (!viteEntryPoint) {
|
|
803
|
+
throw new DevServerError("vite", (0, import_node_path6.join)(projectRoot, "node_modules", ".bin", "vite"));
|
|
799
804
|
}
|
|
800
805
|
const syncServerFile = await findSyncServerFile(projectRoot);
|
|
801
806
|
let managedSyncStore = normalizeManagedSyncStore(config, projectRoot);
|
|
802
807
|
const postgresEnvRequested = isPostgresEnvRequested(config);
|
|
803
808
|
const syncAllowed = args["no-sync"] !== true && configSyncEnabled;
|
|
804
809
|
let shouldStartSync = syncAllowed && (syncServerFile !== null || managedSyncStore !== null);
|
|
805
|
-
let
|
|
810
|
+
let hasTsx = false;
|
|
806
811
|
if (shouldStartSync && syncServerFile !== null) {
|
|
807
|
-
|
|
808
|
-
if (!
|
|
809
|
-
logger.warn('Sync server detected, but
|
|
812
|
+
hasTsx = await hasTsxInstalled(projectRoot);
|
|
813
|
+
if (!hasTsx) {
|
|
814
|
+
logger.warn('Sync server detected, but "tsx" is not installed. Skipping sync.');
|
|
810
815
|
}
|
|
811
816
|
}
|
|
812
817
|
if (shouldStartSync && syncServerFile === null && managedSyncStore) {
|
|
813
818
|
const hasServerPackage = await fileExists(
|
|
814
|
-
(0,
|
|
819
|
+
(0, import_node_path6.join)(projectRoot, "node_modules", "@korajs", "server", "package.json")
|
|
815
820
|
);
|
|
816
821
|
if (!hasServerPackage) {
|
|
817
822
|
logger.warn(
|
|
@@ -828,7 +833,7 @@ var devCommand = (0, import_citty2.defineCommand)({
|
|
|
828
833
|
}
|
|
829
834
|
let configuredSchemaPath = null;
|
|
830
835
|
if (typeof config?.schema === "string") {
|
|
831
|
-
const candidate = (0,
|
|
836
|
+
const candidate = (0, import_node_path7.resolve)(projectRoot, config.schema);
|
|
832
837
|
if (await fileExists(candidate)) {
|
|
833
838
|
configuredSchemaPath = candidate;
|
|
834
839
|
} else {
|
|
@@ -868,7 +873,7 @@ var devCommand = (0, import_citty2.defineCommand)({
|
|
|
868
873
|
logger.info("Starting development environment:");
|
|
869
874
|
logger.blank();
|
|
870
875
|
logger.step(` Vite dev server on port ${vitePort}`);
|
|
871
|
-
if (shouldStartSync &&
|
|
876
|
+
if (shouldStartSync && hasTsx && syncServerFile) {
|
|
872
877
|
logger.step(` Sync server on port ${syncPort}`);
|
|
873
878
|
} else if (shouldStartSync && syncServerFile === null && managedSyncStore !== null) {
|
|
874
879
|
logger.step(` Managed sync server on port ${syncPort} (${managedSyncStore.type})`);
|
|
@@ -887,16 +892,16 @@ var devCommand = (0, import_citty2.defineCommand)({
|
|
|
887
892
|
logger.blank();
|
|
888
893
|
processManager.spawn({
|
|
889
894
|
label: "vite",
|
|
890
|
-
command:
|
|
891
|
-
args: ["--port", String(vitePort)],
|
|
895
|
+
command: process.execPath,
|
|
896
|
+
args: [viteEntryPoint, "--port", String(vitePort)],
|
|
892
897
|
cwd: projectRoot,
|
|
893
898
|
onExit: onManagedProcessExit
|
|
894
899
|
});
|
|
895
|
-
if (shouldStartSync &&
|
|
900
|
+
if (shouldStartSync && hasTsx && syncServerFile) {
|
|
896
901
|
processManager.spawn({
|
|
897
902
|
label: "sync",
|
|
898
|
-
command:
|
|
899
|
-
args: [syncServerFile],
|
|
903
|
+
command: process.execPath,
|
|
904
|
+
args: ["--import", "tsx", syncServerFile],
|
|
900
905
|
cwd: projectRoot,
|
|
901
906
|
env: {
|
|
902
907
|
PORT: String(syncPort),
|
|
@@ -940,7 +945,7 @@ var devCommand = (0, import_citty2.defineCommand)({
|
|
|
940
945
|
}
|
|
941
946
|
});
|
|
942
947
|
async function findSyncServerFile(projectRoot) {
|
|
943
|
-
const candidates = [(0,
|
|
948
|
+
const candidates = [(0, import_node_path6.join)(projectRoot, "server.ts"), (0, import_node_path6.join)(projectRoot, "server.js")];
|
|
944
949
|
for (const candidate of candidates) {
|
|
945
950
|
try {
|
|
946
951
|
await (0, import_promises4.access)(candidate);
|
|
@@ -964,7 +969,7 @@ function normalizeManagedSyncStore(config, projectRoot) {
|
|
|
964
969
|
const store = sync.store;
|
|
965
970
|
if (store === void 0) return { type: "memory" };
|
|
966
971
|
if (store === "memory") return { type: "memory" };
|
|
967
|
-
if (store === "sqlite") return { type: "sqlite", filename: (0,
|
|
972
|
+
if (store === "sqlite") return { type: "sqlite", filename: (0, import_node_path6.join)(projectRoot, "kora-sync.db") };
|
|
968
973
|
if (store === "postgres") {
|
|
969
974
|
const connectionString = process.env.DATABASE_URL;
|
|
970
975
|
if (!connectionString) return null;
|
|
@@ -973,7 +978,7 @@ function normalizeManagedSyncStore(config, projectRoot) {
|
|
|
973
978
|
if (typeof store === "object" && store !== null) {
|
|
974
979
|
if (store.type === "memory") return { type: "memory" };
|
|
975
980
|
if (store.type === "sqlite") {
|
|
976
|
-
const filename = typeof store.filename === "string" && store.filename.length > 0 ? (0,
|
|
981
|
+
const filename = typeof store.filename === "string" && store.filename.length > 0 ? (0, import_node_path7.resolve)(projectRoot, store.filename) : (0, import_node_path6.join)(projectRoot, "kora-sync.db");
|
|
977
982
|
return { type: "sqlite", filename };
|
|
978
983
|
}
|
|
979
984
|
if (store.type === "postgres" && typeof store.connectionString === "string") {
|
|
@@ -1037,7 +1042,7 @@ await new Promise(() => {});
|
|
|
1037
1042
|
|
|
1038
1043
|
// src/commands/generate/generate-command.ts
|
|
1039
1044
|
var import_promises5 = require("fs/promises");
|
|
1040
|
-
var
|
|
1045
|
+
var import_node_path8 = require("path");
|
|
1041
1046
|
var import_citty3 = require("citty");
|
|
1042
1047
|
|
|
1043
1048
|
// src/commands/generate/type-generator.ts
|
|
@@ -1168,7 +1173,7 @@ var generateCommand = (0, import_citty3.defineCommand)({
|
|
|
1168
1173
|
}
|
|
1169
1174
|
let schemaPath;
|
|
1170
1175
|
if (args.schema && typeof args.schema === "string") {
|
|
1171
|
-
schemaPath = (0,
|
|
1176
|
+
schemaPath = (0, import_node_path8.resolve)(args.schema);
|
|
1172
1177
|
} else {
|
|
1173
1178
|
const found = await findSchemaFile(projectRoot);
|
|
1174
1179
|
if (!found) {
|
|
@@ -1191,8 +1196,8 @@ var generateCommand = (0, import_citty3.defineCommand)({
|
|
|
1191
1196
|
}
|
|
1192
1197
|
const output = generateTypes(schema);
|
|
1193
1198
|
const outputFile = typeof args.output === "string" ? args.output : "kora/generated/types.ts";
|
|
1194
|
-
const outputPath = (0,
|
|
1195
|
-
await (0, import_promises5.mkdir)((0,
|
|
1199
|
+
const outputPath = (0, import_node_path8.resolve)(projectRoot, outputFile);
|
|
1200
|
+
await (0, import_promises5.mkdir)((0, import_node_path8.dirname)(outputPath), { recursive: true });
|
|
1196
1201
|
await (0, import_promises5.writeFile)(outputPath, output, "utf-8");
|
|
1197
1202
|
logger.success(`Generated types at ${outputPath}`);
|
|
1198
1203
|
}
|
|
@@ -1214,7 +1219,7 @@ function isSchemaDefinition(value) {
|
|
|
1214
1219
|
|
|
1215
1220
|
// src/commands/migrate/migrate-command.ts
|
|
1216
1221
|
var import_promises6 = require("fs/promises");
|
|
1217
|
-
var
|
|
1222
|
+
var import_node_path10 = require("path");
|
|
1218
1223
|
var import_citty4 = require("citty");
|
|
1219
1224
|
|
|
1220
1225
|
// src/commands/migrate/migration-generator.ts
|
|
@@ -1784,10 +1789,10 @@ async function loadPostgresModule() {
|
|
|
1784
1789
|
|
|
1785
1790
|
// src/commands/migrate/schema-loader.ts
|
|
1786
1791
|
var import_node_child_process6 = require("child_process");
|
|
1787
|
-
var
|
|
1792
|
+
var import_node_path9 = require("path");
|
|
1788
1793
|
var import_node_url4 = require("url");
|
|
1789
1794
|
async function loadSchemaDefinition(schemaPath, projectRoot) {
|
|
1790
|
-
const ext = (0,
|
|
1795
|
+
const ext = (0, import_node_path9.extname)(schemaPath);
|
|
1791
1796
|
const moduleValue = ext === ".ts" || ext === ".mts" || ext === ".cts" ? await loadTypeScriptModule(schemaPath, projectRoot) : await import(`${(0, import_node_url4.pathToFileURL)(schemaPath).href}?t=${Date.now()}-${Math.random()}`);
|
|
1792
1797
|
return extractSchema2(moduleValue);
|
|
1793
1798
|
}
|
|
@@ -1808,20 +1813,17 @@ function isSchemaDefinition2(value) {
|
|
|
1808
1813
|
return typeof object.version === "number" && typeof object.collections === "object" && object.collections !== null && typeof object.relations === "object" && object.relations !== null;
|
|
1809
1814
|
}
|
|
1810
1815
|
async function loadTypeScriptModule(schemaPath, projectRoot) {
|
|
1811
|
-
|
|
1812
|
-
if (!tsxBinary) {
|
|
1816
|
+
if (!await hasTsxInstalled(projectRoot)) {
|
|
1813
1817
|
throw new Error(
|
|
1814
1818
|
`Schema file is TypeScript (${schemaPath}) but local "tsx" was not found. Install tsx in the project.`
|
|
1815
1819
|
);
|
|
1816
1820
|
}
|
|
1817
|
-
const script = [
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
"
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
].join(";");
|
|
1824
|
-
const output = await runCommand2(tsxBinary, ["--eval", script, schemaPath], projectRoot);
|
|
1821
|
+
const script = "const modulePath = process.argv[process.argv.length - 1];import('node:url').then(u => import(u.pathToFileURL(modulePath).href)).then(mod => { const v = mod.default ?? mod; process.stdout.write(JSON.stringify(v)) }).catch(e => { process.stderr.write(String(e)); process.exit(1) })";
|
|
1822
|
+
const output = await runCommand2(
|
|
1823
|
+
process.execPath,
|
|
1824
|
+
["--import", "tsx", "--eval", script, schemaPath],
|
|
1825
|
+
projectRoot
|
|
1826
|
+
);
|
|
1825
1827
|
try {
|
|
1826
1828
|
return JSON.parse(output);
|
|
1827
1829
|
} catch {
|
|
@@ -1903,12 +1905,12 @@ var migrateCommand = (0, import_citty4.defineCommand)({
|
|
|
1903
1905
|
throw new InvalidProjectError(process.cwd());
|
|
1904
1906
|
}
|
|
1905
1907
|
const config = await loadKoraConfig(projectRoot);
|
|
1906
|
-
const resolvedSchemaPath = typeof args.schema === "string" ? (0,
|
|
1908
|
+
const resolvedSchemaPath = typeof args.schema === "string" ? (0, import_node_path10.resolve)(projectRoot, args.schema) : typeof config?.schema === "string" ? (0, import_node_path10.resolve)(projectRoot, config.schema) : await findSchemaFile(projectRoot);
|
|
1907
1909
|
if (!resolvedSchemaPath) {
|
|
1908
1910
|
throw new SchemaNotFoundError(["src/schema.ts", "schema.ts", "src/schema.js", "schema.js"]);
|
|
1909
1911
|
}
|
|
1910
1912
|
const currentSchema = await loadSchemaDefinition(resolvedSchemaPath, projectRoot);
|
|
1911
|
-
const snapshotFile = (0,
|
|
1913
|
+
const snapshotFile = (0, import_node_path10.join)(projectRoot, SNAPSHOT_PATH);
|
|
1912
1914
|
const previousSchema = await readSchemaSnapshot(snapshotFile);
|
|
1913
1915
|
if (!previousSchema) {
|
|
1914
1916
|
if (args["dry-run"] === true) {
|
|
@@ -1921,7 +1923,7 @@ var migrateCommand = (0, import_citty4.defineCommand)({
|
|
|
1921
1923
|
return;
|
|
1922
1924
|
}
|
|
1923
1925
|
const diff = diffSchemas(previousSchema, currentSchema);
|
|
1924
|
-
const outputDir = typeof args["output-dir"] === "string" ? (0,
|
|
1926
|
+
const outputDir = typeof args["output-dir"] === "string" ? (0, import_node_path10.resolve)(projectRoot, args["output-dir"]) : (0, import_node_path10.resolve)(projectRoot, MIGRATIONS_DIR);
|
|
1925
1927
|
if (!diff.hasChanges) {
|
|
1926
1928
|
logger.success("No schema changes detected.");
|
|
1927
1929
|
if (args.apply === true) {
|
|
@@ -2025,7 +2027,7 @@ function isInteractiveTerminal() {
|
|
|
2025
2027
|
return process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
2026
2028
|
}
|
|
2027
2029
|
async function writeSchemaSnapshot(path, schema) {
|
|
2028
|
-
await (0, import_promises6.mkdir)((0,
|
|
2030
|
+
await (0, import_promises6.mkdir)((0, import_node_path10.dirname)(path), { recursive: true });
|
|
2029
2031
|
await (0, import_promises6.writeFile)(path, `${JSON.stringify(schema, null, 2)}
|
|
2030
2032
|
`, "utf-8");
|
|
2031
2033
|
}
|
|
@@ -2033,7 +2035,7 @@ async function writeMigrationFile(outputDir, fromVersion, toVersion, generated)
|
|
|
2033
2035
|
const existing = await (0, import_promises6.readdir)(outputDir).catch(() => []);
|
|
2034
2036
|
const sequence = existing.filter((file) => /^\d{3}-/.test(file)).length + 1;
|
|
2035
2037
|
const filename = `${String(sequence).padStart(3, "0")}-v${fromVersion}-to-v${toVersion}.ts`;
|
|
2036
|
-
const path = (0,
|
|
2038
|
+
const path = (0, import_node_path10.join)(outputDir, filename);
|
|
2037
2039
|
const migrationId = filename.replace(/\.ts$/, "");
|
|
2038
2040
|
const fileContent = [
|
|
2039
2041
|
`export const up = ${JSON.stringify(generated.up, null, 2)} as const`,
|
|
@@ -2046,7 +2048,7 @@ async function writeMigrationFile(outputDir, fromVersion, toVersion, generated)
|
|
|
2046
2048
|
""
|
|
2047
2049
|
].join("\n");
|
|
2048
2050
|
await (0, import_promises6.writeFile)(path, fileContent, "utf-8");
|
|
2049
|
-
await writeMigrationManifest((0,
|
|
2051
|
+
await writeMigrationManifest((0, import_node_path10.join)(outputDir, `${migrationId}.json`), {
|
|
2050
2052
|
id: migrationId,
|
|
2051
2053
|
fromVersion,
|
|
2052
2054
|
toVersion,
|
|
@@ -2067,13 +2069,13 @@ async function listMigrationManifests(outputDir) {
|
|
|
2067
2069
|
const manifests = [];
|
|
2068
2070
|
for (const file of migrationFiles) {
|
|
2069
2071
|
const id = file.replace(/\.ts$/, "");
|
|
2070
|
-
const manifestPath = (0,
|
|
2072
|
+
const manifestPath = (0, import_node_path10.join)(outputDir, `${id}.json`);
|
|
2071
2073
|
const jsonManifest = await readMigrationManifest(manifestPath);
|
|
2072
2074
|
if (jsonManifest) {
|
|
2073
2075
|
manifests.push({ ...jsonManifest, id });
|
|
2074
2076
|
continue;
|
|
2075
2077
|
}
|
|
2076
|
-
const migrationPath = (0,
|
|
2078
|
+
const migrationPath = (0, import_node_path10.join)(outputDir, file);
|
|
2077
2079
|
const sourceManifest = await readMigrationManifestFromSource(migrationPath, id);
|
|
2078
2080
|
manifests.push(sourceManifest);
|
|
2079
2081
|
}
|
|
@@ -2149,18 +2151,18 @@ function parseLiteralExport(source, exportName) {
|
|
|
2149
2151
|
}
|
|
2150
2152
|
function resolveSqliteApplyPath(dbArg, projectRoot, config) {
|
|
2151
2153
|
if (typeof dbArg === "string") {
|
|
2152
|
-
return (0,
|
|
2154
|
+
return (0, import_node_path10.resolve)(projectRoot, dbArg);
|
|
2153
2155
|
}
|
|
2154
2156
|
const sync = config?.dev?.sync;
|
|
2155
2157
|
if (typeof sync === "object" && sync !== null) {
|
|
2156
2158
|
if (sync.store === "sqlite") {
|
|
2157
|
-
return (0,
|
|
2159
|
+
return (0, import_node_path10.join)(projectRoot, "kora-sync.db");
|
|
2158
2160
|
}
|
|
2159
2161
|
if (typeof sync.store === "object" && sync.store !== null && sync.store.type === "sqlite") {
|
|
2160
2162
|
if (typeof sync.store.filename === "string" && sync.store.filename.length > 0) {
|
|
2161
|
-
return (0,
|
|
2163
|
+
return (0, import_node_path10.resolve)(projectRoot, sync.store.filename);
|
|
2162
2164
|
}
|
|
2163
|
-
return (0,
|
|
2165
|
+
return (0, import_node_path10.join)(projectRoot, "kora-sync.db");
|
|
2164
2166
|
}
|
|
2165
2167
|
}
|
|
2166
2168
|
return void 0;
|