@depup/typeorm-extension 4.0.0-depup.0 → 4.2.0-depup.0
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/README.MD +35 -0
- package/README.md +2 -2
- package/bin/cli.mjs +11 -11
- package/bin/cli.mjs.map +1 -1
- package/changes.json +1 -1
- package/dist/index.d.mts +265 -170
- package/dist/index.mjs +873 -69
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -20
package/README.MD
CHANGED
|
@@ -27,6 +27,7 @@ This is a library to
|
|
|
27
27
|
- [Create](#create)
|
|
28
28
|
- [Drop](#drop)
|
|
29
29
|
- [Schema Drift](#schema-drift)
|
|
30
|
+
- [Generate Migration](#generate-migration)
|
|
30
31
|
- [Repair Migrations](#repair-migrations)
|
|
31
32
|
- [Instances](#instances)
|
|
32
33
|
- [Single](#single)
|
|
@@ -288,6 +289,27 @@ import { assertSchemaMatchesMetadata, getSchemaDrift } from 'typeorm-extension';
|
|
|
288
289
|
|
|
289
290
|
The same check is available on the command line as `typeorm-extension db drift`, which exits with code `1` on drift.
|
|
290
291
|
|
|
292
|
+
#### Generate Migration
|
|
293
|
+
|
|
294
|
+
`generateMigration` writes a migration file from the same schema comparison, using typeorm's own statements and file
|
|
295
|
+
templates. The data source must already be initialized.
|
|
296
|
+
|
|
297
|
+
```typescript
|
|
298
|
+
import { generateMigration } from 'typeorm-extension';
|
|
299
|
+
|
|
300
|
+
(async () => {
|
|
301
|
+
await generateMigration({
|
|
302
|
+
dataSource,
|
|
303
|
+
name: 'add-role',
|
|
304
|
+
directoryPath: 'src/migrations',
|
|
305
|
+
});
|
|
306
|
+
})();
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
The file is written as `<timestamp>-<name>.<language>`, by default into `migrations/`. Set `language: 'js'` (plus
|
|
310
|
+
`esm: true` for `export class` syntax) for a JavaScript migration, or `preview: true` to receive the statements without
|
|
311
|
+
writing a file.
|
|
312
|
+
|
|
291
313
|
#### Repair Migrations
|
|
292
314
|
|
|
293
315
|
Renaming a constraint is dialect-asymmetric and easy to get wrong. These helpers read the current state back from the
|
|
@@ -333,6 +355,19 @@ database is in **neither** the expected nor the desired state it raises a `Schem
|
|
|
333
355
|
quietly, since a repair migration which repairs nothing would otherwise pass for a successful one. Pass
|
|
334
356
|
`strict: false` per call to opt out.
|
|
335
357
|
|
|
358
|
+
`withDatabaseLock(queryRunner, name, fn, { timeout })` runs `fn` while holding a named advisory lock (`postgres`,
|
|
359
|
+
`mysql`, `mariadb`), for example so only one replica runs the migrations (with `migrationsRun` off, since
|
|
360
|
+
`initialize()` would run them before the lock is taken):
|
|
361
|
+
|
|
362
|
+
```typescript
|
|
363
|
+
const queryRunner = dataSource.createQueryRunner();
|
|
364
|
+
try {
|
|
365
|
+
await withDatabaseLock(queryRunner, 'migrations', () => dataSource.runMigrations());
|
|
366
|
+
} finally {
|
|
367
|
+
await queryRunner.release();
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
336
371
|
To get a better overview and understanding of these functions, check out the
|
|
337
372
|
[documentation](https://typeorm-extension.tada5hi.net/guide/database-api-reference.html).
|
|
338
373
|
|
package/README.md
CHANGED
|
@@ -13,8 +13,8 @@ npm install @depup/typeorm-extension
|
|
|
13
13
|
|
|
14
14
|
| Field | Value |
|
|
15
15
|
|-------|-------|
|
|
16
|
-
| Original | [typeorm-extension](https://www.npmjs.com/package/typeorm-extension) @ 4.
|
|
17
|
-
| Processed | 2026-
|
|
16
|
+
| Original | [typeorm-extension](https://www.npmjs.com/package/typeorm-extension) @ 4.2.0 |
|
|
17
|
+
| Processed | 2026-09-27 |
|
|
18
18
|
| Smoke test | failed |
|
|
19
19
|
| Deps updated | 2 |
|
|
20
20
|
|
package/bin/cli.mjs
CHANGED
|
@@ -54,16 +54,14 @@ function createLogger(level = LogLevel.Info) {
|
|
|
54
54
|
if (enabled(LogLevel.Debug)) write(`${tint(DIM, `${ICON_DEBUG} ${msg}`)}`);
|
|
55
55
|
},
|
|
56
56
|
section: (title) => {
|
|
57
|
-
if (enabled(LogLevel.Info))
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
57
|
+
if (!enabled(LogLevel.Info)) return;
|
|
58
|
+
write("");
|
|
59
|
+
write(tint(`${BOLD}${BLUE}`, title));
|
|
61
60
|
},
|
|
62
61
|
kv: (key, value, padTo = 0) => {
|
|
63
|
-
if (enabled(LogLevel.Info))
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
62
|
+
if (!enabled(LogLevel.Info)) return;
|
|
63
|
+
const pad = " ".repeat(Math.max(0, padTo - key.length));
|
|
64
|
+
write(` ${tint(DIM, key)}${pad} ${value}`);
|
|
67
65
|
},
|
|
68
66
|
blank: () => {
|
|
69
67
|
if (enabled(LogLevel.Info)) write("");
|
|
@@ -481,17 +479,19 @@ function defineCLISeedRunCommand() {
|
|
|
481
479
|
const dsPad = 9;
|
|
482
480
|
logger.kv("directory", source.directory, dsPad);
|
|
483
481
|
logger.kv("name", source.name, dsPad);
|
|
484
|
-
|
|
482
|
+
const dataSourceOptions = await buildDataSourceOptions({
|
|
485
483
|
dataSourceName: source.name,
|
|
486
484
|
directory: source.directory,
|
|
487
485
|
tsconfig: await pathResolver.tsconfig(),
|
|
488
486
|
preserveFilePaths: args.preserveFilePaths
|
|
489
|
-
})
|
|
487
|
+
});
|
|
488
|
+
setDataSourceOptions(dataSourceOptions);
|
|
490
489
|
if (name) {
|
|
491
490
|
logger.section("Seed");
|
|
492
491
|
logger.kv("name", name, 4);
|
|
493
492
|
}
|
|
494
|
-
const
|
|
493
|
+
const dataSource = await useDataSource();
|
|
494
|
+
const executor = new SeederExecutor(dataSource, {
|
|
495
495
|
root: args.root,
|
|
496
496
|
tsconfig: await pathResolver.tsconfig(),
|
|
497
497
|
preserveFilePaths: args.preserveFilePaths
|
package/bin/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","names":[],"sources":["../src/cli/logger.ts","../src/cli/exit.ts","../src/cli/commands/database/create.ts","../src/cli/commands/database/drift.ts","../src/cli/commands/database/drop.ts","../src/cli/commands/database/index.ts","../src/cli/commands/seed/create.ts","../src/cli/commands/seed/run.ts","../src/cli/commands/seed/index.ts","../src/cli/module.ts","../src/cli/index.ts"],"sourcesContent":["import process from 'node:process';\n\nexport const LogLevel = {\n Silent: 'silent',\n Info: 'info',\n Debug: 'debug',\n} as const;\nexport type LogLevel = typeof LogLevel[keyof typeof LogLevel];\n\nexport const LOG_LEVEL_VALUES: LogLevel[] = Object.values(LogLevel);\n\nconst RANK: Record<LogLevel, number> = {\n [LogLevel.Silent]: 0,\n [LogLevel.Info]: 1,\n [LogLevel.Debug]: 2,\n};\n\nconst RESET = '\\x1b[0m';\nconst BOLD = '\\x1b[1m';\nconst DIM = '\\x1b[2m';\nconst RED = '\\x1b[31m';\nconst GREEN = '\\x1b[32m';\nconst YELLOW = '\\x1b[33m';\nconst BLUE = '\\x1b[34m';\nconst CYAN = '\\x1b[36m';\n\nconst ICON_INFO = 'ℹ';\nconst ICON_SUCCESS = '✔';\nconst ICON_WARN = '⚠';\nconst ICON_ERROR = '✖';\nconst ICON_DEBUG = '›';\n\nexport type Logger = {\n info: (msg: string) => void;\n debug: (msg: string) => void;\n warn: (msg: string) => void;\n error: (msg: string) => void;\n success: (msg: string) => void;\n section: (title: string) => void;\n kv: (key: string, value: string, padTo?: number) => void;\n blank: () => void;\n};\n\nexport function createLogger(level: LogLevel = LogLevel.Info): Logger {\n const enabled = (target: LogLevel): boolean => RANK[level] >= RANK[target];\n const tty = process.stderr.isTTY;\n const tint = (code: string, text: string) => (tty ? `${code}${text}${RESET}` : text);\n const write = (line: string) => process.stderr.write(`${line}\\n`);\n\n return {\n info: (msg) => {\n if (enabled(LogLevel.Info)) {\n write(`${tint(CYAN, ICON_INFO)} ${msg}`);\n }\n },\n success: (msg) => {\n if (enabled(LogLevel.Info)) {\n write(`${tint(GREEN, ICON_SUCCESS)} ${msg}`);\n }\n },\n warn: (msg) => {\n if (enabled(LogLevel.Info)) {\n write(`${tint(YELLOW, ICON_WARN)} ${msg}`);\n }\n },\n error: (msg) => {\n write(`${tint(RED, ICON_ERROR)} ${msg}`);\n },\n debug: (msg) => {\n if (enabled(LogLevel.Debug)) {\n write(`${tint(DIM, `${ICON_DEBUG} ${msg}`)}`);\n }\n },\n section: (title) => {\n if (enabled(LogLevel.Info)) {\n write('');\n write(tint(`${BOLD}${BLUE}`, title));\n }\n },\n kv: (key, value, padTo = 0) => {\n if (enabled(LogLevel.Info)) {\n const pad = ' '.repeat(Math.max(0, padTo - key.length));\n write(` ${tint(DIM, key)}${pad} ${value}`);\n }\n },\n blank: () => {\n if (enabled(LogLevel.Info)) {\n write('');\n }\n },\n };\n}\n\nexport function normalizeLogLevel(input: string | undefined): LogLevel {\n if (!input) {\n return LogLevel.Info;\n }\n if ((LOG_LEVEL_VALUES as string[]).includes(input)) {\n return input as LogLevel;\n }\n throw new CLIUserError(\n `Unknown log level \"${input}\". Supported: ${LOG_LEVEL_VALUES.join(', ')}.`,\n );\n}\n\nexport class CLIUserError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'CLIUserError';\n }\n}\n","import process from 'node:process';\nimport type { Logger } from './logger';\nimport { CLIUserError } from './logger';\n\nexport const ExitCode = {\n Success: 0,\n UserError: 1,\n InternalError: 2,\n} as const;\nexport type ExitCode = typeof ExitCode[keyof typeof ExitCode];\n\nexport async function runWithExitCode(\n logger: Logger,\n fn: () => Promise<void>,\n): Promise<void> {\n try {\n await fn();\n process.exit(ExitCode.Success);\n } catch (err) {\n if (err instanceof CLIUserError) {\n logger.error(err.message);\n process.exit(ExitCode.UserError);\n }\n if (err instanceof Error) {\n logger.error(err.stack ?? err.message);\n } else {\n logger.error(String(err));\n }\n process.exit(ExitCode.InternalError);\n }\n}\n","import { defineCommand } from 'citty';\nimport process from 'node:process';\nimport { buildDataSourceOptions } from '../../../data-source';\nimport type { DatabaseCreateContextInput } from '../../../database';\nimport { createDatabase } from '../../../database';\nimport {\n PathResolverMode,\n createPathResolver,\n parseFilePath,\n} from '../../../utils';\nimport { runWithExitCode } from '../../exit';\nimport { LOG_LEVEL_VALUES, createLogger, normalizeLogLevel } from '../../logger';\n\nexport function defineCLIDatabaseCreateCommand() {\n return defineCommand({\n meta: {\n name: 'create',\n description: 'Create database.',\n },\n args: {\n preserveFilePaths: {\n type: 'boolean',\n default: false,\n description: 'This option indicates if file paths should be preserved.',\n },\n root: {\n type: 'string',\n alias: 'r',\n default: process.cwd(),\n description: 'Root directory of the project.',\n },\n tsconfig: {\n type: 'string',\n alias: 'tc',\n default: 'tsconfig.json',\n description: 'Name (or relative path incl. name) of the tsconfig file.',\n },\n dataSource: {\n type: 'string',\n alias: 'd',\n default: 'data-source',\n description: 'Name (or relative path incl. name) of the data-source file.',\n },\n synchronize: {\n type: 'enum',\n alias: 's',\n default: 'yes',\n options: ['yes', 'no'],\n description: 'Create database schema for all entities.',\n },\n initialDatabase: {\n type: 'string',\n description: 'Specify the initial database to connect to.',\n },\n 'log-level': {\n type: 'string',\n description: 'Logger verbosity.',\n valueHint: LOG_LEVEL_VALUES.join('|'),\n options: LOG_LEVEL_VALUES as string[],\n },\n },\n async run({ args }) {\n const logger = createLogger(normalizeLogLevel(args['log-level'] as string | undefined));\n await runWithExitCode(logger, async () => {\n logger.info('Creating database');\n\n const pathResolver = createPathResolver({\n root: args.root,\n tsconfig: args.tsconfig,\n mode: args.preserveFilePaths ?\n PathResolverMode.PRESERVE :\n PathResolverMode.AUTO,\n });\n\n const source = parseFilePath(await pathResolver.resolve(args.dataSource));\n\n logger.section('DataSource');\n const pad = 'directory'.length;\n logger.kv('directory', source.directory, pad);\n logger.kv('name', source.name, pad);\n\n const dataSourceOptions = await buildDataSourceOptions({\n directory: source.directory,\n dataSourceName: source.name,\n tsconfig: await pathResolver.tsconfig(),\n preserveFilePaths: args.preserveFilePaths,\n });\n\n const context : DatabaseCreateContextInput = {\n ifNotExist: true,\n options: dataSourceOptions,\n synchronize: args.synchronize === 'yes',\n };\n\n if (\n typeof args.initialDatabase === 'string' &&\n args.initialDatabase !== ''\n ) {\n context.initialDatabase = args.initialDatabase;\n }\n\n logger.blank();\n await createDatabase(context);\n logger.success('Created database.');\n });\n },\n });\n}\n","import { defineCommand } from 'citty';\nimport process from 'node:process';\nimport { buildDataSourceOptions } from '../../../data-source';\nimport { getSchemaDrift } from '../../../database';\nimport {\n PathResolverMode,\n createPathResolver,\n parseFilePath,\n} from '../../../utils';\nimport { runWithExitCode } from '../../exit';\nimport { \n CLIUserError, \n LOG_LEVEL_VALUES, \n createLogger, \n normalizeLogLevel, \n} from '../../logger';\n\nexport function defineCLIDatabaseDriftCommand() {\n return defineCommand({\n meta: {\n name: 'drift',\n description: 'Assert that the database schema matches the entity metadata.',\n },\n args: {\n preserveFilePaths: {\n type: 'boolean',\n default: false,\n description: 'This option indicates if file paths should be preserved.',\n },\n root: {\n type: 'string',\n alias: 'r',\n default: process.cwd(),\n description: 'Root directory of the project.',\n },\n tsconfig: {\n type: 'string',\n alias: 'tc',\n default: 'tsconfig.json',\n description: 'Name (or relative path incl. name) of the tsconfig file.',\n },\n dataSource: {\n type: 'string',\n alias: 'd',\n default: 'data-source',\n description: 'Name (or relative path incl. name) of the data-source file.',\n },\n skipWithoutMigrations: {\n type: 'boolean',\n default: false,\n description: 'Report no drift if the data-source has no migrations registered.',\n },\n 'log-level': {\n type: 'string',\n description: 'Logger verbosity.',\n valueHint: LOG_LEVEL_VALUES.join('|'),\n options: LOG_LEVEL_VALUES as string[],\n },\n },\n async run({ args }) {\n const logger = createLogger(normalizeLogLevel(args['log-level'] as string | undefined));\n await runWithExitCode(logger, async () => {\n logger.info('Checking schema drift');\n\n const pathResolver = createPathResolver({\n root: args.root,\n tsconfig: args.tsconfig,\n mode: args.preserveFilePaths ?\n PathResolverMode.PRESERVE :\n PathResolverMode.AUTO,\n });\n\n const source = parseFilePath(await pathResolver.resolve(args.dataSource));\n\n logger.section('DataSource');\n const pad = 'directory'.length;\n logger.kv('directory', source.directory, pad);\n logger.kv('name', source.name, pad);\n\n const dataSourceOptions = await buildDataSourceOptions({\n directory: source.directory,\n dataSourceName: source.name,\n tsconfig: await pathResolver.tsconfig(),\n preserveFilePaths: args.preserveFilePaths,\n });\n\n logger.blank();\n\n const drift = await getSchemaDrift(dataSourceOptions, { skipWithoutMigrations: args.skipWithoutMigrations });\n\n if (!drift.exists) {\n logger.success('No schema drift detected.');\n\n return;\n }\n\n logger.section('Statements');\n for (let i = 0; i < drift.up.length; i++) {\n const statement = drift.up[i];\n\n logger.warn(\n statement.parameters && statement.parameters.length > 0 ?\n `${statement.query} -- ${JSON.stringify(statement.parameters)}` :\n statement.query,\n );\n }\n\n logger.blank();\n\n throw new CLIUserError(\n `The database schema deviates from the entity metadata (${drift.up.length} statement(s) required to reconcile it).`,\n );\n });\n },\n });\n}\n","import { defineCommand } from 'citty';\nimport process from 'node:process';\nimport { buildDataSourceOptions } from '../../../data-source';\nimport type { DatabaseDropContext } from '../../../database';\nimport { dropDatabase } from '../../../database';\nimport {\n PathResolverMode,\n createPathResolver,\n parseFilePath,\n} from '../../../utils';\nimport { runWithExitCode } from '../../exit';\nimport { LOG_LEVEL_VALUES, createLogger, normalizeLogLevel } from '../../logger';\n\nexport function defineCLIDatabaseDropCommand() {\n return defineCommand({\n meta: {\n name: 'drop',\n description: 'Drop database.',\n },\n args: {\n preserveFilePaths: {\n type: 'boolean',\n default: false,\n description: 'This option indicates if file paths should be preserved.',\n },\n root: {\n type: 'string',\n alias: 'r',\n default: process.cwd(),\n description: 'Root directory of the project.',\n },\n tsconfig: {\n type: 'string',\n alias: 'tc',\n default: 'tsconfig.json',\n description: 'Name (or relative path incl. name) of the tsconfig file.',\n },\n dataSource: {\n type: 'string',\n alias: 'd',\n default: 'data-source',\n description: 'Name (or relative path incl. name) of the data-source file.',\n },\n initialDatabase: {\n type: 'string',\n description: 'Specify the initial database to connect to.',\n },\n 'log-level': {\n type: 'string',\n description: 'Logger verbosity.',\n valueHint: LOG_LEVEL_VALUES.join('|'),\n options: LOG_LEVEL_VALUES as string[],\n },\n },\n async run({ args }) {\n const logger = createLogger(normalizeLogLevel(args['log-level'] as string | undefined));\n await runWithExitCode(logger, async () => {\n logger.info('Dropping database');\n\n const pathResolver = createPathResolver({\n root: args.root,\n tsconfig: args.tsconfig,\n mode: args.preserveFilePaths ?\n PathResolverMode.PRESERVE :\n PathResolverMode.AUTO,\n });\n\n const source = parseFilePath(await pathResolver.resolve(args.dataSource));\n\n logger.section('DataSource');\n const pad = 'directory'.length;\n logger.kv('directory', source.directory, pad);\n logger.kv('name', source.name, pad);\n\n const dataSourceOptions = await buildDataSourceOptions({\n directory: source.directory,\n dataSourceName: source.name,\n tsconfig: await pathResolver.tsconfig(),\n preserveFilePaths: args.preserveFilePaths,\n });\n\n const context : DatabaseDropContext = {\n ifExist: true,\n options: dataSourceOptions,\n };\n\n if (\n typeof args.initialDatabase === 'string' &&\n args.initialDatabase !== ''\n ) {\n context.initialDatabase = args.initialDatabase;\n }\n\n logger.blank();\n await dropDatabase(context);\n logger.success('Dropped database.');\n });\n },\n });\n}\n","import { defineCommand } from 'citty';\nimport { defineCLIDatabaseCreateCommand } from './create';\nimport { defineCLIDatabaseDriftCommand } from './drift';\nimport { defineCLIDatabaseDropCommand } from './drop';\n\nexport * from './create';\nexport * from './drift';\nexport * from './drop';\n\nexport function defineCLIDatabaseCommand() {\n return defineCommand({\n meta: {\n name: 'db',\n description: 'Database operations.',\n },\n subCommands: {\n create: defineCLIDatabaseCreateCommand(),\n drift: defineCLIDatabaseDriftCommand(),\n drop: defineCLIDatabaseDropCommand(),\n },\n });\n}\n","import { defineCommand } from 'citty';\nimport { removeFileNameExtension } from 'locter';\nimport { isDirectory, parseFilePath } from '../../../utils';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport { pascalCase } from 'pascal-case';\nimport { buildSeederFileName, buildSeederFileTemplate } from '../../../seeder';\nimport { runWithExitCode } from '../../exit';\nimport { \n CLIUserError, \n LOG_LEVEL_VALUES, \n createLogger, \n normalizeLogLevel, \n} from '../../logger';\n\nexport function defineCLISeedCreateCommand() {\n return defineCommand({\n meta: {\n name: 'create',\n description: 'Create a seeder file.',\n },\n args: {\n root: {\n type: 'string',\n alias: 'r',\n default: process.cwd(),\n description: 'Root directory of the project.',\n },\n timestamp: {\n type: 'string',\n alias: 't',\n description: 'Custom timestamp for the seeder name.',\n },\n javascript: {\n type: 'boolean',\n alias: 'j',\n default: false,\n description: 'Generate a seeder file for JavaScript instead of TypeScript.',\n },\n name: {\n type: 'string',\n alias: 'n',\n required: true,\n description: 'Name (or relative path incl. name) of the seeder.',\n },\n 'log-level': {\n type: 'string',\n description: 'Logger verbosity.',\n valueHint: LOG_LEVEL_VALUES.join('|'),\n options: LOG_LEVEL_VALUES as string[],\n },\n },\n async run({ args }) {\n const logger = createLogger(normalizeLogLevel(args['log-level'] as string | undefined));\n await runWithExitCode(logger, async () => {\n logger.info('Creating seeder file');\n\n const parsedTimestamp = typeof args.timestamp === 'string' ?\n Number.parseInt(args.timestamp, 10) :\n Number.NaN;\n const timestamp = Number.isNaN(parsedTimestamp) ?\n Date.now() :\n parsedTimestamp;\n\n const sourcePath = parseFilePath(args.name, args.root);\n\n const dirNameIsDirectory = await isDirectory(sourcePath.directory);\n if (!dirNameIsDirectory) {\n throw new CLIUserError(\n `The output directory ${sourcePath.directory} does not exist.`,\n );\n }\n\n const nameWithoutExtension = removeFileNameExtension(sourcePath.name);\n\n const fileName = buildSeederFileName(sourcePath.name, timestamp, { javascript: args.javascript });\n const filePath = path.join(sourcePath.directory, fileName);\n const template = buildSeederFileTemplate(nameWithoutExtension, timestamp);\n\n logger.section('Seed');\n const pad = 'directory'.length;\n logger.kv('directory', sourcePath.directory, pad);\n logger.kv('fileName', fileName, pad);\n logger.kv('name', pascalCase(nameWithoutExtension), pad);\n\n try {\n await fs.promises.writeFile(filePath, template, { encoding: 'utf-8' });\n } catch {\n throw new CLIUserError(\n `The seed could not be written to the path ${filePath}.`,\n );\n }\n\n logger.blank();\n logger.success('Created seeder file.');\n });\n },\n });\n}\n","import { defineCommand } from 'citty';\nimport process from 'node:process';\nimport { buildDataSourceOptions, setDataSourceOptions, useDataSource } from '../../../data-source';\nimport { SeederExecutor } from '../../../seeder';\nimport {\n PathResolverMode,\n createPathResolver,\n parseFilePath,\n} from '../../../utils';\nimport { runWithExitCode } from '../../exit';\nimport { LOG_LEVEL_VALUES, createLogger, normalizeLogLevel } from '../../logger';\n\nexport function defineCLISeedRunCommand() {\n return defineCommand({\n meta: {\n name: 'run',\n description: 'Populate the database with an initial data set or generated data by a factory.',\n },\n args: {\n preserveFilePaths: {\n type: 'boolean',\n default: false,\n description: 'This option indicates if file paths should be preserved.',\n },\n root: {\n type: 'string',\n alias: 'r',\n default: process.cwd(),\n description: 'Root directory of the project.',\n },\n tsconfig: {\n type: 'string',\n alias: 'tc',\n default: 'tsconfig.json',\n description: 'Name (or relative path incl. name) of the tsconfig file.',\n },\n dataSource: {\n type: 'string',\n alias: 'd',\n default: 'data-source',\n description: 'Name (or relative path incl. name) of the data-source file.',\n },\n name: {\n type: 'string',\n alias: 'n',\n description: 'Name (or relative path incl. name) of the seeder.',\n },\n 'log-level': {\n type: 'string',\n description: 'Logger verbosity.',\n valueHint: LOG_LEVEL_VALUES.join('|'),\n options: LOG_LEVEL_VALUES as string[],\n },\n },\n async run({ args }) {\n const logger = createLogger(normalizeLogLevel(args['log-level'] as string | undefined));\n await runWithExitCode(logger, async () => {\n logger.info('Running seeders');\n\n const pathResolver = createPathResolver({\n root: args.root,\n tsconfig: args.tsconfig,\n mode: args.preserveFilePaths ?\n PathResolverMode.PRESERVE :\n PathResolverMode.AUTO,\n });\n\n let { name } = args;\n if (name) {\n name = await pathResolver.transform(name);\n }\n\n const source = parseFilePath(await pathResolver.resolve(args.dataSource));\n\n logger.section('DataSource');\n const dsPad = 'directory'.length;\n logger.kv('directory', source.directory, dsPad);\n logger.kv('name', source.name, dsPad);\n\n const dataSourceOptions = await buildDataSourceOptions({\n dataSourceName: source.name,\n directory: source.directory,\n tsconfig: await pathResolver.tsconfig(),\n preserveFilePaths: args.preserveFilePaths,\n });\n\n setDataSourceOptions(dataSourceOptions);\n\n if (name) {\n logger.section('Seed');\n logger.kv('name', name, 'name'.length);\n }\n\n const dataSource = await useDataSource();\n const executor = new SeederExecutor(dataSource, {\n root: args.root,\n tsconfig: await pathResolver.tsconfig(),\n preserveFilePaths: args.preserveFilePaths,\n });\n\n logger.blank();\n await executor.execute({ seedName: name });\n logger.success('Executed seeders.');\n });\n },\n });\n}\n","import { defineCommand } from 'citty';\nimport { defineCLISeedCreateCommand } from './create';\nimport { defineCLISeedRunCommand } from './run';\n\nexport * from './create';\nexport * from './run';\n\nexport function defineCLISeedCommand() {\n return defineCommand({\n meta: {\n name: 'seed',\n description: 'Seeder operations.',\n },\n subCommands: {\n create: defineCLISeedCreateCommand(),\n run: defineCLISeedRunCommand(),\n },\n });\n}\n","import { defineCommand } from 'citty';\nimport {\n defineCLIDatabaseCommand,\n defineCLIDatabaseCreateCommand,\n defineCLIDatabaseDropCommand,\n defineCLISeedCommand,\n defineCLISeedCreateCommand,\n defineCLISeedRunCommand,\n} from './commands';\n\nexport function createCLIEntryPointCommand() {\n return defineCommand({\n meta: {\n name: 'typeorm-extension',\n description: 'CLI for typeorm-extension.',\n },\n subCommands: {\n db: defineCLIDatabaseCommand(),\n seed: defineCLISeedCommand(),\n // Legacy colon-form aliases (kept for backwards compatibility with v3 invocations).\n 'db:create': defineCLIDatabaseCreateCommand(),\n 'db:drop': defineCLIDatabaseDropCommand(),\n 'seed:create': defineCLISeedCreateCommand(),\n 'seed:run': defineCLISeedRunCommand(),\n },\n });\n}\n","#!/usr/bin/env node\nimport 'reflect-metadata';\nimport { runMain } from 'citty';\nimport { createCLIEntryPointCommand } from './module';\n\nrunMain(createCLIEntryPointCommand());\n"],"mappings":";;;;;;;;;;AAEA,MAAa,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,OAAO,cAAc;EACjB,MAAM;GACF,MAAM;GACN,aAAa;EACjB;EACA,aAAa;GACT,IAAI,yBAAyB;GAC7B,MAAM,qBAAqB;GAE3B,aAAa,+BAA+B;GAC5C,WAAW,6BAA6B;GACxC,eAAe,2BAA2B;GAC1C,YAAY,wBAAwB;EACxC;CACJ,CAAC;AACL;;;ACrBA,QAAQ,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":[],"sources":["../src/cli/logger.ts","../src/cli/exit.ts","../src/cli/commands/database/create.ts","../src/cli/commands/database/drift.ts","../src/cli/commands/database/drop.ts","../src/cli/commands/database/index.ts","../src/cli/commands/seed/create.ts","../src/cli/commands/seed/run.ts","../src/cli/commands/seed/index.ts","../src/cli/module.ts","../src/cli/index.ts"],"sourcesContent":["import process from 'node:process';\n\nexport const LogLevel = {\n Silent: 'silent',\n Info: 'info',\n Debug: 'debug',\n} as const;\nexport type LogLevel = typeof LogLevel[keyof typeof LogLevel];\n\nexport const LOG_LEVEL_VALUES: LogLevel[] = Object.values(LogLevel);\n\nconst RANK: Record<LogLevel, number> = {\n [LogLevel.Silent]: 0,\n [LogLevel.Info]: 1,\n [LogLevel.Debug]: 2,\n};\n\nconst RESET = '\\x1b[0m';\nconst BOLD = '\\x1b[1m';\nconst DIM = '\\x1b[2m';\nconst RED = '\\x1b[31m';\nconst GREEN = '\\x1b[32m';\nconst YELLOW = '\\x1b[33m';\nconst BLUE = '\\x1b[34m';\nconst CYAN = '\\x1b[36m';\n\nconst ICON_INFO = 'ℹ';\nconst ICON_SUCCESS = '✔';\nconst ICON_WARN = '⚠';\nconst ICON_ERROR = '✖';\nconst ICON_DEBUG = '›';\n\nexport type Logger = {\n info: (msg: string) => void;\n debug: (msg: string) => void;\n warn: (msg: string) => void;\n error: (msg: string) => void;\n success: (msg: string) => void;\n section: (title: string) => void;\n kv: (key: string, value: string, padTo?: number) => void;\n blank: () => void;\n};\n\nexport function createLogger(level: LogLevel = LogLevel.Info): Logger {\n const enabled = (target: LogLevel): boolean => RANK[level] >= RANK[target];\n const tty = process.stderr.isTTY;\n const tint = (code: string, text: string) => (tty ? `${code}${text}${RESET}` : text);\n const write = (line: string) => process.stderr.write(`${line}\\n`);\n\n return {\n info: (msg) => {\n if (enabled(LogLevel.Info)) {\n write(`${tint(CYAN, ICON_INFO)} ${msg}`);\n }\n },\n success: (msg) => {\n if (enabled(LogLevel.Info)) {\n write(`${tint(GREEN, ICON_SUCCESS)} ${msg}`);\n }\n },\n warn: (msg) => {\n if (enabled(LogLevel.Info)) {\n write(`${tint(YELLOW, ICON_WARN)} ${msg}`);\n }\n },\n error: (msg) => {\n write(`${tint(RED, ICON_ERROR)} ${msg}`);\n },\n debug: (msg) => {\n if (enabled(LogLevel.Debug)) {\n write(`${tint(DIM, `${ICON_DEBUG} ${msg}`)}`);\n }\n },\n section: (title) => {\n if (!enabled(LogLevel.Info)) {\n return;\n }\n\n write('');\n write(tint(`${BOLD}${BLUE}`, title));\n },\n kv: (key, value, padTo = 0) => {\n if (!enabled(LogLevel.Info)) {\n return;\n }\n\n const pad = ' '.repeat(Math.max(0, padTo - key.length));\n write(` ${tint(DIM, key)}${pad} ${value}`);\n },\n blank: () => {\n if (enabled(LogLevel.Info)) {\n write('');\n }\n },\n };\n}\n\nexport function normalizeLogLevel(input: string | undefined): LogLevel {\n if (!input) {\n return LogLevel.Info;\n }\n if ((LOG_LEVEL_VALUES as string[]).includes(input)) {\n return input as LogLevel;\n }\n throw new CLIUserError(\n `Unknown log level \"${input}\". Supported: ${LOG_LEVEL_VALUES.join(', ')}.`,\n );\n}\n\nexport class CLIUserError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'CLIUserError';\n }\n}\n","import process from 'node:process';\nimport type { Logger } from './logger';\nimport { CLIUserError } from './logger';\n\nexport const ExitCode = {\n Success: 0,\n UserError: 1,\n InternalError: 2,\n} as const;\nexport type ExitCode = typeof ExitCode[keyof typeof ExitCode];\n\nexport async function runWithExitCode(\n logger: Logger,\n fn: () => Promise<void>,\n): Promise<void> {\n try {\n await fn();\n process.exit(ExitCode.Success);\n } catch (err) {\n if (err instanceof CLIUserError) {\n logger.error(err.message);\n process.exit(ExitCode.UserError);\n }\n if (err instanceof Error) {\n logger.error(err.stack ?? err.message);\n } else {\n logger.error(String(err));\n }\n process.exit(ExitCode.InternalError);\n }\n}\n","import { defineCommand } from 'citty';\nimport process from 'node:process';\nimport { buildDataSourceOptions } from '../../../data-source';\nimport type { DatabaseCreateContextInput } from '../../../database';\nimport { createDatabase } from '../../../database';\nimport {\n PathResolverMode,\n createPathResolver,\n parseFilePath,\n} from '../../../utils';\nimport { runWithExitCode } from '../../exit';\nimport { LOG_LEVEL_VALUES, createLogger, normalizeLogLevel } from '../../logger';\n\nexport function defineCLIDatabaseCreateCommand() {\n return defineCommand({\n meta: {\n name: 'create',\n description: 'Create database.',\n },\n args: {\n preserveFilePaths: {\n type: 'boolean',\n default: false,\n description: 'This option indicates if file paths should be preserved.',\n },\n root: {\n type: 'string',\n alias: 'r',\n default: process.cwd(),\n description: 'Root directory of the project.',\n },\n tsconfig: {\n type: 'string',\n alias: 'tc',\n default: 'tsconfig.json',\n description: 'Name (or relative path incl. name) of the tsconfig file.',\n },\n dataSource: {\n type: 'string',\n alias: 'd',\n default: 'data-source',\n description: 'Name (or relative path incl. name) of the data-source file.',\n },\n synchronize: {\n type: 'enum',\n alias: 's',\n default: 'yes',\n options: ['yes', 'no'],\n description: 'Create database schema for all entities.',\n },\n initialDatabase: {\n type: 'string',\n description: 'Specify the initial database to connect to.',\n },\n 'log-level': {\n type: 'string',\n description: 'Logger verbosity.',\n valueHint: LOG_LEVEL_VALUES.join('|'),\n options: LOG_LEVEL_VALUES as string[],\n },\n },\n async run({ args }) {\n const logger = createLogger(normalizeLogLevel(args['log-level'] as string | undefined));\n await runWithExitCode(logger, async () => {\n logger.info('Creating database');\n\n const pathResolver = createPathResolver({\n root: args.root,\n tsconfig: args.tsconfig,\n mode: args.preserveFilePaths ?\n PathResolverMode.PRESERVE :\n PathResolverMode.AUTO,\n });\n\n const source = parseFilePath(await pathResolver.resolve(args.dataSource));\n\n logger.section('DataSource');\n const pad = 'directory'.length;\n logger.kv('directory', source.directory, pad);\n logger.kv('name', source.name, pad);\n\n const dataSourceOptions = await buildDataSourceOptions({\n directory: source.directory,\n dataSourceName: source.name,\n tsconfig: await pathResolver.tsconfig(),\n preserveFilePaths: args.preserveFilePaths,\n });\n\n const context : DatabaseCreateContextInput = {\n ifNotExist: true,\n options: dataSourceOptions,\n synchronize: args.synchronize === 'yes',\n };\n\n if (\n typeof args.initialDatabase === 'string' &&\n args.initialDatabase !== ''\n ) {\n context.initialDatabase = args.initialDatabase;\n }\n\n logger.blank();\n await createDatabase(context);\n logger.success('Created database.');\n });\n },\n });\n}\n","import { defineCommand } from 'citty';\nimport process from 'node:process';\nimport { buildDataSourceOptions } from '../../../data-source';\nimport { getSchemaDrift } from '../../../database';\nimport {\n PathResolverMode,\n createPathResolver,\n parseFilePath,\n} from '../../../utils';\nimport { runWithExitCode } from '../../exit';\nimport { \n CLIUserError, \n LOG_LEVEL_VALUES, \n createLogger, \n normalizeLogLevel, \n} from '../../logger';\n\nexport function defineCLIDatabaseDriftCommand() {\n return defineCommand({\n meta: {\n name: 'drift',\n description: 'Assert that the database schema matches the entity metadata.',\n },\n args: {\n preserveFilePaths: {\n type: 'boolean',\n default: false,\n description: 'This option indicates if file paths should be preserved.',\n },\n root: {\n type: 'string',\n alias: 'r',\n default: process.cwd(),\n description: 'Root directory of the project.',\n },\n tsconfig: {\n type: 'string',\n alias: 'tc',\n default: 'tsconfig.json',\n description: 'Name (or relative path incl. name) of the tsconfig file.',\n },\n dataSource: {\n type: 'string',\n alias: 'd',\n default: 'data-source',\n description: 'Name (or relative path incl. name) of the data-source file.',\n },\n skipWithoutMigrations: {\n type: 'boolean',\n default: false,\n description: 'Report no drift if the data-source has no migrations registered.',\n },\n 'log-level': {\n type: 'string',\n description: 'Logger verbosity.',\n valueHint: LOG_LEVEL_VALUES.join('|'),\n options: LOG_LEVEL_VALUES as string[],\n },\n },\n async run({ args }) {\n const logger = createLogger(normalizeLogLevel(args['log-level'] as string | undefined));\n await runWithExitCode(logger, async () => {\n logger.info('Checking schema drift');\n\n const pathResolver = createPathResolver({\n root: args.root,\n tsconfig: args.tsconfig,\n mode: args.preserveFilePaths ?\n PathResolverMode.PRESERVE :\n PathResolverMode.AUTO,\n });\n\n const source = parseFilePath(await pathResolver.resolve(args.dataSource));\n\n logger.section('DataSource');\n const pad = 'directory'.length;\n logger.kv('directory', source.directory, pad);\n logger.kv('name', source.name, pad);\n\n const dataSourceOptions = await buildDataSourceOptions({\n directory: source.directory,\n dataSourceName: source.name,\n tsconfig: await pathResolver.tsconfig(),\n preserveFilePaths: args.preserveFilePaths,\n });\n\n logger.blank();\n\n const drift = await getSchemaDrift(dataSourceOptions, { skipWithoutMigrations: args.skipWithoutMigrations });\n\n if (!drift.exists) {\n logger.success('No schema drift detected.');\n\n return;\n }\n\n logger.section('Statements');\n for (let i = 0; i < drift.up.length; i++) {\n const statement = drift.up[i];\n\n logger.warn(\n statement.parameters && statement.parameters.length > 0 ?\n `${statement.query} -- ${JSON.stringify(statement.parameters)}` :\n statement.query,\n );\n }\n\n logger.blank();\n\n throw new CLIUserError(\n `The database schema deviates from the entity metadata (${drift.up.length} statement(s) required to reconcile it).`,\n );\n });\n },\n });\n}\n","import { defineCommand } from 'citty';\nimport process from 'node:process';\nimport { buildDataSourceOptions } from '../../../data-source';\nimport type { DatabaseDropContext } from '../../../database';\nimport { dropDatabase } from '../../../database';\nimport {\n PathResolverMode,\n createPathResolver,\n parseFilePath,\n} from '../../../utils';\nimport { runWithExitCode } from '../../exit';\nimport { LOG_LEVEL_VALUES, createLogger, normalizeLogLevel } from '../../logger';\n\nexport function defineCLIDatabaseDropCommand() {\n return defineCommand({\n meta: {\n name: 'drop',\n description: 'Drop database.',\n },\n args: {\n preserveFilePaths: {\n type: 'boolean',\n default: false,\n description: 'This option indicates if file paths should be preserved.',\n },\n root: {\n type: 'string',\n alias: 'r',\n default: process.cwd(),\n description: 'Root directory of the project.',\n },\n tsconfig: {\n type: 'string',\n alias: 'tc',\n default: 'tsconfig.json',\n description: 'Name (or relative path incl. name) of the tsconfig file.',\n },\n dataSource: {\n type: 'string',\n alias: 'd',\n default: 'data-source',\n description: 'Name (or relative path incl. name) of the data-source file.',\n },\n initialDatabase: {\n type: 'string',\n description: 'Specify the initial database to connect to.',\n },\n 'log-level': {\n type: 'string',\n description: 'Logger verbosity.',\n valueHint: LOG_LEVEL_VALUES.join('|'),\n options: LOG_LEVEL_VALUES as string[],\n },\n },\n async run({ args }) {\n const logger = createLogger(normalizeLogLevel(args['log-level'] as string | undefined));\n await runWithExitCode(logger, async () => {\n logger.info('Dropping database');\n\n const pathResolver = createPathResolver({\n root: args.root,\n tsconfig: args.tsconfig,\n mode: args.preserveFilePaths ?\n PathResolverMode.PRESERVE :\n PathResolverMode.AUTO,\n });\n\n const source = parseFilePath(await pathResolver.resolve(args.dataSource));\n\n logger.section('DataSource');\n const pad = 'directory'.length;\n logger.kv('directory', source.directory, pad);\n logger.kv('name', source.name, pad);\n\n const dataSourceOptions = await buildDataSourceOptions({\n directory: source.directory,\n dataSourceName: source.name,\n tsconfig: await pathResolver.tsconfig(),\n preserveFilePaths: args.preserveFilePaths,\n });\n\n const context : DatabaseDropContext = {\n ifExist: true,\n options: dataSourceOptions,\n };\n\n if (\n typeof args.initialDatabase === 'string' &&\n args.initialDatabase !== ''\n ) {\n context.initialDatabase = args.initialDatabase;\n }\n\n logger.blank();\n await dropDatabase(context);\n logger.success('Dropped database.');\n });\n },\n });\n}\n","import { defineCommand } from 'citty';\nimport { defineCLIDatabaseCreateCommand } from './create';\nimport { defineCLIDatabaseDriftCommand } from './drift';\nimport { defineCLIDatabaseDropCommand } from './drop';\n\nexport * from './create';\nexport * from './drift';\nexport * from './drop';\n\nexport function defineCLIDatabaseCommand() {\n return defineCommand({\n meta: {\n name: 'db',\n description: 'Database operations.',\n },\n subCommands: {\n create: defineCLIDatabaseCreateCommand(),\n drift: defineCLIDatabaseDriftCommand(),\n drop: defineCLIDatabaseDropCommand(),\n },\n });\n}\n","import { defineCommand } from 'citty';\nimport { removeFileNameExtension } from 'locter';\nimport { isDirectory, parseFilePath } from '../../../utils';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport { pascalCase } from 'pascal-case';\nimport { buildSeederFileName, buildSeederFileTemplate } from '../../../seeder';\nimport { runWithExitCode } from '../../exit';\nimport { \n CLIUserError, \n LOG_LEVEL_VALUES, \n createLogger, \n normalizeLogLevel, \n} from '../../logger';\n\nexport function defineCLISeedCreateCommand() {\n return defineCommand({\n meta: {\n name: 'create',\n description: 'Create a seeder file.',\n },\n args: {\n root: {\n type: 'string',\n alias: 'r',\n default: process.cwd(),\n description: 'Root directory of the project.',\n },\n timestamp: {\n type: 'string',\n alias: 't',\n description: 'Custom timestamp for the seeder name.',\n },\n javascript: {\n type: 'boolean',\n alias: 'j',\n default: false,\n description: 'Generate a seeder file for JavaScript instead of TypeScript.',\n },\n name: {\n type: 'string',\n alias: 'n',\n required: true,\n description: 'Name (or relative path incl. name) of the seeder.',\n },\n 'log-level': {\n type: 'string',\n description: 'Logger verbosity.',\n valueHint: LOG_LEVEL_VALUES.join('|'),\n options: LOG_LEVEL_VALUES as string[],\n },\n },\n async run({ args }) {\n const logger = createLogger(normalizeLogLevel(args['log-level'] as string | undefined));\n await runWithExitCode(logger, async () => {\n logger.info('Creating seeder file');\n\n const parsedTimestamp = typeof args.timestamp === 'string' ?\n Number.parseInt(args.timestamp, 10) :\n NaN;\n const timestamp = Number.isNaN(parsedTimestamp) ?\n Date.now() :\n parsedTimestamp;\n\n const sourcePath = parseFilePath(args.name, args.root);\n\n const dirNameIsDirectory = await isDirectory(sourcePath.directory);\n if (!dirNameIsDirectory) {\n throw new CLIUserError(\n `The output directory ${sourcePath.directory} does not exist.`,\n );\n }\n\n const nameWithoutExtension = removeFileNameExtension(sourcePath.name);\n\n const fileName = buildSeederFileName(sourcePath.name, timestamp, { javascript: args.javascript });\n const filePath = path.join(sourcePath.directory, fileName);\n const template = buildSeederFileTemplate(nameWithoutExtension, timestamp);\n\n logger.section('Seed');\n const pad = 'directory'.length;\n logger.kv('directory', sourcePath.directory, pad);\n logger.kv('fileName', fileName, pad);\n logger.kv('name', pascalCase(nameWithoutExtension), pad);\n\n try {\n await fs.promises.writeFile(filePath, template, { encoding: 'utf-8' });\n } catch {\n throw new CLIUserError(\n `The seed could not be written to the path ${filePath}.`,\n );\n }\n\n logger.blank();\n logger.success('Created seeder file.');\n });\n },\n });\n}\n","import { defineCommand } from 'citty';\nimport process from 'node:process';\nimport { buildDataSourceOptions, setDataSourceOptions, useDataSource } from '../../../data-source';\nimport { SeederExecutor } from '../../../seeder';\nimport {\n PathResolverMode,\n createPathResolver,\n parseFilePath,\n} from '../../../utils';\nimport { runWithExitCode } from '../../exit';\nimport { LOG_LEVEL_VALUES, createLogger, normalizeLogLevel } from '../../logger';\n\nexport function defineCLISeedRunCommand() {\n return defineCommand({\n meta: {\n name: 'run',\n description: 'Populate the database with an initial data set or generated data by a factory.',\n },\n args: {\n preserveFilePaths: {\n type: 'boolean',\n default: false,\n description: 'This option indicates if file paths should be preserved.',\n },\n root: {\n type: 'string',\n alias: 'r',\n default: process.cwd(),\n description: 'Root directory of the project.',\n },\n tsconfig: {\n type: 'string',\n alias: 'tc',\n default: 'tsconfig.json',\n description: 'Name (or relative path incl. name) of the tsconfig file.',\n },\n dataSource: {\n type: 'string',\n alias: 'd',\n default: 'data-source',\n description: 'Name (or relative path incl. name) of the data-source file.',\n },\n name: {\n type: 'string',\n alias: 'n',\n description: 'Name (or relative path incl. name) of the seeder.',\n },\n 'log-level': {\n type: 'string',\n description: 'Logger verbosity.',\n valueHint: LOG_LEVEL_VALUES.join('|'),\n options: LOG_LEVEL_VALUES as string[],\n },\n },\n async run({ args }) {\n const logger = createLogger(normalizeLogLevel(args['log-level'] as string | undefined));\n await runWithExitCode(logger, async () => {\n logger.info('Running seeders');\n\n const pathResolver = createPathResolver({\n root: args.root,\n tsconfig: args.tsconfig,\n mode: args.preserveFilePaths ?\n PathResolverMode.PRESERVE :\n PathResolverMode.AUTO,\n });\n\n let { name } = args;\n if (name) {\n name = await pathResolver.transform(name);\n }\n\n const source = parseFilePath(await pathResolver.resolve(args.dataSource));\n\n logger.section('DataSource');\n const dsPad = 'directory'.length;\n logger.kv('directory', source.directory, dsPad);\n logger.kv('name', source.name, dsPad);\n\n const dataSourceOptions = await buildDataSourceOptions({\n dataSourceName: source.name,\n directory: source.directory,\n tsconfig: await pathResolver.tsconfig(),\n preserveFilePaths: args.preserveFilePaths,\n });\n\n setDataSourceOptions(dataSourceOptions);\n\n if (name) {\n logger.section('Seed');\n logger.kv('name', name, 'name'.length);\n }\n\n const dataSource = await useDataSource();\n const executor = new SeederExecutor(dataSource, {\n root: args.root,\n tsconfig: await pathResolver.tsconfig(),\n preserveFilePaths: args.preserveFilePaths,\n });\n\n logger.blank();\n await executor.execute({ seedName: name });\n logger.success('Executed seeders.');\n });\n },\n });\n}\n","import { defineCommand } from 'citty';\nimport { defineCLISeedCreateCommand } from './create';\nimport { defineCLISeedRunCommand } from './run';\n\nexport * from './create';\nexport * from './run';\n\nexport function defineCLISeedCommand() {\n return defineCommand({\n meta: {\n name: 'seed',\n description: 'Seeder operations.',\n },\n subCommands: {\n create: defineCLISeedCreateCommand(),\n run: defineCLISeedRunCommand(),\n },\n });\n}\n","import { defineCommand } from 'citty';\nimport {\n defineCLIDatabaseCommand,\n defineCLIDatabaseCreateCommand,\n defineCLIDatabaseDropCommand,\n defineCLISeedCommand,\n defineCLISeedCreateCommand,\n defineCLISeedRunCommand,\n} from './commands';\n\nexport function createCLIEntryPointCommand() {\n return defineCommand({\n meta: {\n name: 'typeorm-extension',\n description: 'CLI for typeorm-extension.',\n },\n subCommands: {\n db: defineCLIDatabaseCommand(),\n seed: defineCLISeedCommand(),\n // Legacy colon-form aliases (kept for backwards compatibility with v3 invocations).\n 'db:create': defineCLIDatabaseCreateCommand(),\n 'db:drop': defineCLIDatabaseDropCommand(),\n 'seed:create': defineCLISeedCreateCommand(),\n 'seed:run': defineCLISeedRunCommand(),\n },\n });\n}\n","#!/usr/bin/env node\nimport 'reflect-metadata';\nimport { runMain } from 'citty';\nimport { createCLIEntryPointCommand } from './module';\n\nrunMain(createCLIEntryPointCommand());\n"],"mappings":";;;;;;;;;;AAEA,MAAa,WAAW;CACpB,QAAQ;CACR,MAAM;CACN,OAAO;AACX;AAGA,MAAa,mBAA+B,OAAO,OAAO,QAAQ;AAElE,MAAM,OAAiC;EAClC,SAAS,SAAS;EAClB,SAAS,OAAO;EAChB,SAAS,QAAQ;AACtB;AAEA,MAAM,QAAQ;AACd,MAAM,OAAO;AACb,MAAM,MAAM;AACZ,MAAM,MAAM;AACZ,MAAM,QAAQ;AACd,MAAM,SAAS;AACf,MAAM,OAAO;AACb,MAAM,OAAO;AAEb,MAAM,YAAY;AAClB,MAAM,eAAe;AACrB,MAAM,YAAY;AAClB,MAAM,aAAa;AACnB,MAAM,aAAa;AAanB,SAAgB,aAAa,QAAkB,SAAS,MAAc;CAClE,MAAM,WAAW,WAA8B,KAAK,UAAU,KAAK;CACnE,MAAM,MAAM,QAAQ,OAAO;CAC3B,MAAM,QAAQ,MAAc,SAAkB,MAAM,GAAG,OAAO,OAAO,UAAU;CAC/E,MAAM,SAAS,SAAiB,QAAQ,OAAO,MAAM,GAAG,KAAK,GAAG;CAEhE,OAAO;EACH,OAAO,QAAQ;GACX,IAAI,QAAQ,SAAS,IAAI,GACrB,MAAM,GAAG,KAAK,MAAM,SAAS,EAAE,GAAG,KAAK;EAE/C;EACA,UAAU,QAAQ;GACd,IAAI,QAAQ,SAAS,IAAI,GACrB,MAAM,GAAG,KAAK,OAAO,YAAY,EAAE,GAAG,KAAK;EAEnD;EACA,OAAO,QAAQ;GACX,IAAI,QAAQ,SAAS,IAAI,GACrB,MA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