@windrun-huaiin/dev-scripts 11.0.0 → 11.0.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.
@@ -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,QAiF3D;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,KAAK,GAAE,OAAe,EACtB,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,eAAe,EAAE,CAAC,CAgC5B"}
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,CAqC5B"}
@@ -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,10 @@ async function syncBackendCoreMigrations(destDirInput, force = false, cwd = proc
187
188
  results.push({ file: to, status: 'skip (exists)' });
188
189
  continue;
189
190
  }
190
- await fs.promises.copyFile(from, to);
191
+ // Read SQL content and replace schema name
192
+ const sqlContent = await fs.promises.readFile(from, 'utf8');
193
+ const updatedContent = sqlContent.replace(/nextai\./g, `${schemaName}.`);
194
+ await fs.promises.writeFile(to, updatedContent, 'utf8');
191
195
  results.push({ file: to, status: exists ? 'overwritten' : 'copied' });
192
196
  }
193
197
  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,10 @@ async function syncBackendCoreMigrations(destDirInput, force = false, cwd = proc
185
186
  results.push({ file: to, status: 'skip (exists)' });
186
187
  continue;
187
188
  }
188
- await promises.copyFile(from, to);
189
+ // Read SQL content and replace schema name
190
+ const sqlContent = await promises.readFile(from, 'utf8');
191
+ const updatedContent = sqlContent.replace(/nextai\./g, `${schemaName}.`);
192
+ await promises.writeFile(to, updatedContent, 'utf8');
189
193
  results.push({ file: to, status: exists ? 'overwritten' : 'copied' });
190
194
  }
191
195
  if (sqlFiles.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windrun-huaiin/dev-scripts",
3
- "version": "11.0.0",
3
+ "version": "11.0.1",
4
4
  "description": "Development scripts for multilingual projects",
5
5
  "main": "dist/index.js",
6
6
  "bin": {