build: allow node package depends on workspace packages (#11892)

This commit is contained in:
forehalo
2025-04-23 10:04:58 +00:00
parent 64997d4a0e
commit c00671dd84
28 changed files with 326 additions and 325 deletions

View File

@@ -1,5 +1,5 @@
import { writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { appendFileSync, writeFileSync } from 'node:fs';
import { join, parse } from 'node:path';
import { fileURLToPath } from 'node:url';
import { Logger } from '@nestjs/common';
@@ -45,15 +45,21 @@ export class CreateCommand extends CommandRunner {
const timestamp = Date.now();
const content = this.createScript(upperFirst(camelCase(name)) + timestamp);
const fileName = `${timestamp}-${kebabCase(name)}.ts`;
const filePath = join(
const migrationDir = join(
fileURLToPath(import.meta.url),
'../../migrations',
fileName
'../../migrations'
);
const fileName = `${timestamp}-${kebabCase(name)}.ts`;
const filePath = join(migrationDir, fileName);
this.logger.log(`Creating ${fileName}...`);
writeFileSync(filePath, content);
const indexFile = join(migrationDir, 'index.ts');
appendFileSync(
indexFile,
`export * from './${parse(fileName).name}';`,
'utf-8'
);
this.logger.log(`Migration file created at ${filePath}`);
this.logger.log('Done');
}