@windrun-huaiin/dev-scripts 11.0.0 → 11.0.2
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.
|
@@ -7,6 +7,6 @@ export declare function registerBackendCoreCommands(program: Command): void;
|
|
|
7
7
|
export declare function syncBackendCoreRoutes(appDirInput: string, force?: boolean, cwd?: string): Promise<RouteSyncResult[]>;
|
|
8
8
|
export declare function listBackendCoreRoutes(): void;
|
|
9
9
|
export declare function syncBackendCorePrisma(schemaPathInput: string, cwd?: string): Promise<string>;
|
|
10
|
-
export declare function syncBackendCoreMigrations(destDirInput: string, force?: boolean, cwd?: string): Promise<RouteSyncResult[]>;
|
|
10
|
+
export declare function syncBackendCoreMigrations(destDirInput: string, schemaName?: string, force?: boolean, cwd?: string): Promise<RouteSyncResult[]>;
|
|
11
11
|
export {};
|
|
12
12
|
//# sourceMappingURL=backend-core.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend-core.d.ts","sourceRoot":"","sources":["../../src/commands/backend-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAYnC,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAiCD,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"backend-core.d.ts","sourceRoot":"","sources":["../../src/commands/backend-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAYnC,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAiCD,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,QAkF3D;AAED,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,MAAM,EACnB,KAAK,GAAE,OAAe,EACtB,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,eAAe,EAAE,CAAC,CAuB5B;AAED,wBAAgB,qBAAqB,SAKpC;AAED,wBAAsB,qBAAqB,CACzC,eAAe,EAAE,MAAM,EACvB,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,MAAM,CAAC,CA0CjB;AAED,wBAAsB,yBAAyB,CAC7C,YAAY,EAAE,MAAM,EACpB,UAAU,GAAE,MAAiB,EAC7B,KAAK,GAAE,OAAe,EACtB,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,eAAe,EAAE,CAAC,CA6C5B"}
|
|
@@ -95,11 +95,12 @@ function registerBackendCoreCommands(program) {
|
|
|
95
95
|
.command('migrations:sync')
|
|
96
96
|
.description('Copy backend-core SQL migrations into the host directory')
|
|
97
97
|
.option('--dest <dir>', 'Target migrations directory', 'prisma')
|
|
98
|
+
.option('--schema <name>', 'Database schema name (replaces "nextai" in SQL files)', 'nextai')
|
|
98
99
|
.option('--force', 'Overwrite existing files', false)
|
|
99
100
|
.action(async (opts) => {
|
|
100
101
|
const cwd = process.cwd();
|
|
101
102
|
try {
|
|
102
|
-
const results = await syncBackendCoreMigrations(opts.dest, opts.force, cwd);
|
|
103
|
+
const results = await syncBackendCoreMigrations(opts.dest, opts.schema, opts.force, cwd);
|
|
103
104
|
console.log('Migrations sync results:');
|
|
104
105
|
for (const r of results) {
|
|
105
106
|
console.log(`- ${r.status} :: ${r.file}`);
|
|
@@ -170,7 +171,7 @@ async function syncBackendCorePrisma(schemaPathInput, cwd = process.cwd()) {
|
|
|
170
171
|
: '';
|
|
171
172
|
return ['Appended backend-core models to', hostSchemaPath, schemaNote].filter(Boolean).join(' ');
|
|
172
173
|
}
|
|
173
|
-
async function syncBackendCoreMigrations(destDirInput, force = false, cwd = process.cwd()) {
|
|
174
|
+
async function syncBackendCoreMigrations(destDirInput, schemaName = 'nextai', force = false, cwd = process.cwd()) {
|
|
174
175
|
const pkgRoot = getBackendPackageRoot(cwd);
|
|
175
176
|
const sourceDir = path.join(pkgRoot, 'migrations');
|
|
176
177
|
const destDir = path.resolve(cwd, destDirInput);
|
|
@@ -187,7 +188,19 @@ async function syncBackendCoreMigrations(destDirInput, force = false, cwd = proc
|
|
|
187
188
|
results.push({ file: to, status: 'skip (exists)' });
|
|
188
189
|
continue;
|
|
189
190
|
}
|
|
190
|
-
|
|
191
|
+
// Read SQL content and replace schema name
|
|
192
|
+
const sqlContent = await fs.promises.readFile(from, 'utf8');
|
|
193
|
+
// Diff handle init-schema.sql file
|
|
194
|
+
let updatedContent;
|
|
195
|
+
if (file.name === 'init-schema.sql') {
|
|
196
|
+
// Just use 'schemaName' to replace 'nextai'
|
|
197
|
+
updatedContent = sqlContent.replace(/\bnextai\b/g, schemaName);
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
// Others use 'schemaName.' to replace 'nextai.'
|
|
201
|
+
updatedContent = sqlContent.replace(/nextai\./g, `${schemaName}.`);
|
|
202
|
+
}
|
|
203
|
+
await fs.promises.writeFile(to, updatedContent, 'utf8');
|
|
191
204
|
results.push({ file: to, status: exists ? 'overwritten' : 'copied' });
|
|
192
205
|
}
|
|
193
206
|
if (sqlFiles.length === 0) {
|
|
@@ -93,11 +93,12 @@ function registerBackendCoreCommands(program) {
|
|
|
93
93
|
.command('migrations:sync')
|
|
94
94
|
.description('Copy backend-core SQL migrations into the host directory')
|
|
95
95
|
.option('--dest <dir>', 'Target migrations directory', 'prisma')
|
|
96
|
+
.option('--schema <name>', 'Database schema name (replaces "nextai" in SQL files)', 'nextai')
|
|
96
97
|
.option('--force', 'Overwrite existing files', false)
|
|
97
98
|
.action(async (opts) => {
|
|
98
99
|
const cwd = process.cwd();
|
|
99
100
|
try {
|
|
100
|
-
const results = await syncBackendCoreMigrations(opts.dest, opts.force, cwd);
|
|
101
|
+
const results = await syncBackendCoreMigrations(opts.dest, opts.schema, opts.force, cwd);
|
|
101
102
|
console.log('Migrations sync results:');
|
|
102
103
|
for (const r of results) {
|
|
103
104
|
console.log(`- ${r.status} :: ${r.file}`);
|
|
@@ -168,7 +169,7 @@ async function syncBackendCorePrisma(schemaPathInput, cwd = process.cwd()) {
|
|
|
168
169
|
: '';
|
|
169
170
|
return ['Appended backend-core models to', hostSchemaPath, schemaNote].filter(Boolean).join(' ');
|
|
170
171
|
}
|
|
171
|
-
async function syncBackendCoreMigrations(destDirInput, force = false, cwd = process.cwd()) {
|
|
172
|
+
async function syncBackendCoreMigrations(destDirInput, schemaName = 'nextai', force = false, cwd = process.cwd()) {
|
|
172
173
|
const pkgRoot = getBackendPackageRoot(cwd);
|
|
173
174
|
const sourceDir = path.join(pkgRoot, 'migrations');
|
|
174
175
|
const destDir = path.resolve(cwd, destDirInput);
|
|
@@ -185,7 +186,19 @@ async function syncBackendCoreMigrations(destDirInput, force = false, cwd = proc
|
|
|
185
186
|
results.push({ file: to, status: 'skip (exists)' });
|
|
186
187
|
continue;
|
|
187
188
|
}
|
|
188
|
-
|
|
189
|
+
// Read SQL content and replace schema name
|
|
190
|
+
const sqlContent = await promises.readFile(from, 'utf8');
|
|
191
|
+
// Diff handle init-schema.sql file
|
|
192
|
+
let updatedContent;
|
|
193
|
+
if (file.name === 'init-schema.sql') {
|
|
194
|
+
// Just use 'schemaName' to replace 'nextai'
|
|
195
|
+
updatedContent = sqlContent.replace(/\bnextai\b/g, schemaName);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
// Others use 'schemaName.' to replace 'nextai.'
|
|
199
|
+
updatedContent = sqlContent.replace(/nextai\./g, `${schemaName}.`);
|
|
200
|
+
}
|
|
201
|
+
await promises.writeFile(to, updatedContent, 'utf8');
|
|
189
202
|
results.push({ file: to, status: exists ? 'overwritten' : 'copied' });
|
|
190
203
|
}
|
|
191
204
|
if (sqlFiles.length === 0) {
|