@anarchitects/nx-typeorm 0.0.3 → 0.1.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 +155 -49
- package/dist/executors/cache-clear/executor.d.ts +6 -0
- package/dist/executors/cache-clear/executor.d.ts.map +1 -0
- package/dist/executors/cache-clear/executor.js +5 -0
- package/dist/executors/cache-clear/schema.json +28 -0
- package/dist/executors/ensure-schema/executor.d.ts +1 -5
- package/dist/executors/ensure-schema/executor.d.ts.map +1 -1
- package/dist/executors/ensure-schema/executor.js +1 -1
- package/dist/executors/entity-create/executor.d.ts +6 -0
- package/dist/executors/entity-create/executor.d.ts.map +1 -0
- package/dist/executors/entity-create/executor.js +15 -0
- package/dist/executors/entity-create/schema.json +23 -0
- package/dist/executors/generate/executor.d.ts +1 -7
- package/dist/executors/generate/executor.d.ts.map +1 -1
- package/dist/executors/generate/executor.js +12 -24
- package/dist/executors/generate/schema.json +11 -1
- package/dist/executors/init/executor.d.ts +6 -0
- package/dist/executors/init/executor.d.ts.map +1 -0
- package/dist/executors/init/executor.js +24 -0
- package/dist/executors/init/schema.json +40 -0
- package/dist/executors/migration-create/executor.d.ts +6 -0
- package/dist/executors/migration-create/executor.d.ts.map +1 -0
- package/dist/executors/migration-create/executor.js +19 -0
- package/dist/executors/migration-create/schema.json +31 -0
- package/dist/executors/migration-show/executor.d.ts +6 -0
- package/dist/executors/migration-show/executor.d.ts.map +1 -0
- package/dist/executors/migration-show/executor.js +5 -0
- package/dist/executors/migration-show/schema.json +28 -0
- package/dist/executors/query/executor.d.ts +6 -0
- package/dist/executors/query/executor.d.ts.map +1 -0
- package/dist/executors/query/executor.js +9 -0
- package/dist/executors/query/schema.json +33 -0
- package/dist/executors/revert/executor.d.ts +1 -5
- package/dist/executors/revert/executor.d.ts.map +1 -1
- package/dist/executors/revert/executor.js +8 -19
- package/dist/executors/revert/schema.json +7 -1
- package/dist/executors/run/executor.d.ts +1 -6
- package/dist/executors/run/executor.d.ts.map +1 -1
- package/dist/executors/run/executor.js +7 -18
- package/dist/executors/run/schema.json +6 -0
- package/dist/executors/schema-drop/executor.d.ts +6 -0
- package/dist/executors/schema-drop/executor.d.ts.map +1 -0
- package/dist/executors/schema-drop/executor.js +5 -0
- package/dist/executors/schema-drop/schema.json +28 -0
- package/dist/executors/schema-log/executor.d.ts +6 -0
- package/dist/executors/schema-log/executor.d.ts.map +1 -0
- package/dist/executors/schema-log/executor.js +5 -0
- package/dist/executors/schema-log/schema.json +28 -0
- package/dist/executors/schema-sync/executor.d.ts +6 -0
- package/dist/executors/schema-sync/executor.d.ts.map +1 -0
- package/dist/executors/schema-sync/executor.js +5 -0
- package/dist/executors/schema-sync/schema.json +28 -0
- package/dist/executors/seed/executor.d.ts +1 -7
- package/dist/executors/seed/executor.d.ts.map +1 -1
- package/dist/executors/seed/executor.js +1 -1
- package/dist/executors/subscriber-create/executor.d.ts +6 -0
- package/dist/executors/subscriber-create/executor.d.ts.map +1 -0
- package/dist/executors/subscriber-create/executor.js +13 -0
- package/dist/executors/subscriber-create/schema.json +23 -0
- package/dist/executors/version/executor.d.ts +6 -0
- package/dist/executors/version/executor.d.ts.map +1 -0
- package/dist/executors/version/executor.js +5 -0
- package/dist/executors/version/schema.json +14 -0
- package/dist/generators/bootstrap/files/app/env.example__tmpl__ +55 -1
- package/dist/generators/bootstrap/files/app/src/data-source.ts__tmpl__ +6 -0
- package/dist/generators/bootstrap/files/app/src/typeorm.datasource.ts__tmpl__ +1 -15
- package/dist/generators/bootstrap/files/app/tools/typeorm/connection-options.ts__tmpl__ +292 -0
- package/dist/generators/bootstrap/files/app/tools/typeorm/datasource.migrations.ts__tmpl__ +2 -7
- package/dist/generators/bootstrap/files/lib/project.json.partial__tmpl__ +3 -1
- package/dist/generators/bootstrap/generator.d.ts +5 -1
- package/dist/generators/bootstrap/generator.d.ts.map +1 -1
- package/dist/generators/bootstrap/generator.js +179 -31
- package/dist/generators/bootstrap/schema.json +18 -1
- package/dist/generators/init/generator.d.ts +4 -0
- package/dist/generators/init/generator.d.ts.map +1 -0
- package/dist/generators/init/generator.js +31 -0
- package/dist/generators/init/schema.json +18 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.json +48 -0
- package/dist/plugin/index.d.ts +9 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +241 -0
- package/dist/plugins/typeorm.d.ts +1 -6
- package/dist/plugins/typeorm.d.ts.map +1 -1
- package/dist/plugins/typeorm.js +1 -161
- package/dist/utils/cli.d.ts +17 -0
- package/dist/utils/cli.d.ts.map +1 -0
- package/dist/utils/cli.js +55 -0
- package/dist/{executors → utils}/shared.d.ts +12 -9
- package/dist/utils/shared.d.ts.map +1 -0
- package/dist/utils/shared.js +260 -0
- package/package.json +6 -7
- package/dist/executors/shared.d.ts.map +0 -1
- package/dist/executors/shared.js +0 -71
- package/dist/generators/bootstrap/files/app/tools/typeorm/datasource.runtime.ts__tmpl__ +0 -9
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"title": "TypeORM Migration Show Executor",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"projectRoot": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"description": "Project root when it cannot be inferred from the Nx project configuration."
|
|
9
|
+
},
|
|
10
|
+
"dataSource": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "Path to the TypeORM data source file used for migrations."
|
|
13
|
+
},
|
|
14
|
+
"moduleSystem": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"enum": ["auto", "commonjs", "esm"],
|
|
17
|
+
"default": "auto",
|
|
18
|
+
"description": "Override module-system detection used to select the TypeORM CLI runner."
|
|
19
|
+
},
|
|
20
|
+
"args": {
|
|
21
|
+
"type": "array",
|
|
22
|
+
"items": {
|
|
23
|
+
"type": "string"
|
|
24
|
+
},
|
|
25
|
+
"description": "Additional CLI arguments passed through to the TypeORM command."
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import type { QueryExecutorOptions } from './schema.js';
|
|
3
|
+
export default function runQuery(options: QueryExecutorOptions, context: ExecutorContext): Promise<{
|
|
4
|
+
success: boolean;
|
|
5
|
+
}>;
|
|
6
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/query/executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,wBAA8B,QAAQ,CACpC,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,eAAe;;GAezB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { runDataSourceTypeormCommand } from '../../utils/cli.js';
|
|
2
|
+
export default async function runQuery(options, context) {
|
|
3
|
+
const query = options.query?.trim();
|
|
4
|
+
if (!query) {
|
|
5
|
+
throw new Error('Provide a SQL query via the query option.');
|
|
6
|
+
}
|
|
7
|
+
const exitCode = await runDataSourceTypeormCommand('query', options, context, [query]);
|
|
8
|
+
return { success: exitCode === 0 };
|
|
9
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"title": "TypeORM Query Executor",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"query": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"description": "SQL query to execute."
|
|
9
|
+
},
|
|
10
|
+
"projectRoot": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "Project root when it cannot be inferred from the Nx project configuration."
|
|
13
|
+
},
|
|
14
|
+
"dataSource": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "Path to the TypeORM data source file used for query execution."
|
|
17
|
+
},
|
|
18
|
+
"moduleSystem": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"enum": ["auto", "commonjs", "esm"],
|
|
21
|
+
"default": "auto",
|
|
22
|
+
"description": "Override module-system detection used to select the TypeORM CLI runner."
|
|
23
|
+
},
|
|
24
|
+
"args": {
|
|
25
|
+
"type": "array",
|
|
26
|
+
"items": {
|
|
27
|
+
"type": "string"
|
|
28
|
+
},
|
|
29
|
+
"description": "Additional CLI arguments passed through to the TypeORM command."
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"required": ["query"]
|
|
33
|
+
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import {
|
|
3
|
-
export interface RevertExecutorOptions extends BaseExecutorOptions {
|
|
4
|
-
count?: number;
|
|
5
|
-
args?: string[];
|
|
6
|
-
}
|
|
2
|
+
import type { RevertExecutorOptions } from './schema.js';
|
|
7
3
|
export default function revertMigrations(options: RevertExecutorOptions, context: ExecutorContext): Promise<{
|
|
8
4
|
success: boolean;
|
|
9
5
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/revert/executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/revert/executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,wBAA8B,gBAAgB,CAC5C,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,eAAe;;GAgBzB"}
|
|
@@ -1,22 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ensureArgs, ensureProjectRoot, relativeToWorkspace, splitCommand, } from '../shared.js';
|
|
3
|
-
import { spawn } from '../../utils/spawn.js';
|
|
1
|
+
import { runDataSourceTypeormCommand } from '../../utils/cli.js';
|
|
4
2
|
export default async function revertMigrations(options, context) {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
'typeorm-ts-node-commonjs',
|
|
12
|
-
'migration:revert',
|
|
13
|
-
'-d',
|
|
14
|
-
relativeToWorkspace(context.root, paths.dataSource),
|
|
15
|
-
];
|
|
16
|
-
if (options.count && options.count > 0) {
|
|
17
|
-
args.push('--revert', String(options.count));
|
|
3
|
+
const count = options.count && options.count > 0 ? options.count : 1;
|
|
4
|
+
for (let index = 0; index < count; index += 1) {
|
|
5
|
+
const exitCode = await runDataSourceTypeormCommand('migration:revert', options, context);
|
|
6
|
+
if (exitCode !== 0) {
|
|
7
|
+
return { success: false };
|
|
8
|
+
}
|
|
18
9
|
}
|
|
19
|
-
|
|
20
|
-
const exitCode = await spawn(command, args, { cwd: context.root });
|
|
21
|
-
return { success: exitCode === 0 };
|
|
10
|
+
return { success: true };
|
|
22
11
|
}
|
|
@@ -11,10 +11,16 @@
|
|
|
11
11
|
"type": "string",
|
|
12
12
|
"description": "Path to the TypeORM data source file used for migrations."
|
|
13
13
|
},
|
|
14
|
+
"moduleSystem": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"enum": ["auto", "commonjs", "esm"],
|
|
17
|
+
"default": "auto",
|
|
18
|
+
"description": "Override module-system detection used to select the TypeORM CLI runner."
|
|
19
|
+
},
|
|
14
20
|
"count": {
|
|
15
21
|
"type": "integer",
|
|
16
22
|
"minimum": 1,
|
|
17
|
-
"description": "Number of
|
|
23
|
+
"description": "Number of times to execute TypeORM `migration:revert`."
|
|
18
24
|
},
|
|
19
25
|
"args": {
|
|
20
26
|
"type": "array",
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import {
|
|
3
|
-
export interface RunExecutorOptions extends BaseExecutorOptions {
|
|
4
|
-
transaction?: 'all' | 'none' | 'each';
|
|
5
|
-
fake?: boolean;
|
|
6
|
-
args?: string[];
|
|
7
|
-
}
|
|
2
|
+
import type { RunExecutorOptions } from './schema.js';
|
|
8
3
|
export default function runMigrations(options: RunExecutorOptions, context: ExecutorContext): Promise<{
|
|
9
4
|
success: boolean;
|
|
10
5
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/run/executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/run/executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,wBAA8B,aAAa,CACzC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,eAAe;;GAmBzB"}
|
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ensureArgs, ensureProjectRoot, relativeToWorkspace, splitCommand, } from '../shared.js';
|
|
3
|
-
import { spawn } from '../../utils/spawn.js';
|
|
1
|
+
import { runDataSourceTypeormCommand } from '../../utils/cli.js';
|
|
4
2
|
export default async function runMigrations(options, context) {
|
|
5
|
-
const
|
|
6
|
-
const pmc = getPackageManagerCommand();
|
|
7
|
-
const execCommand = pmc.exec ?? pmc.dlx ?? 'npx';
|
|
8
|
-
const [command, baseArgs] = splitCommand(execCommand);
|
|
9
|
-
const args = [
|
|
10
|
-
...baseArgs,
|
|
11
|
-
'typeorm-ts-node-commonjs',
|
|
12
|
-
'migration:run',
|
|
13
|
-
'-d',
|
|
14
|
-
relativeToWorkspace(context.root, paths.dataSource),
|
|
15
|
-
];
|
|
3
|
+
const afterDataSourceArgs = [];
|
|
16
4
|
if (options.transaction) {
|
|
17
|
-
|
|
5
|
+
afterDataSourceArgs.push('--transaction', options.transaction);
|
|
18
6
|
}
|
|
19
7
|
if (options.fake) {
|
|
20
|
-
|
|
8
|
+
afterDataSourceArgs.push('--fake');
|
|
21
9
|
}
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
const exitCode = await runDataSourceTypeormCommand('migration:run', options, context, {
|
|
11
|
+
afterDataSourceArgs,
|
|
12
|
+
});
|
|
24
13
|
return { success: exitCode === 0 };
|
|
25
14
|
}
|
|
@@ -11,6 +11,12 @@
|
|
|
11
11
|
"type": "string",
|
|
12
12
|
"description": "Path to the TypeORM data source file used for migrations."
|
|
13
13
|
},
|
|
14
|
+
"moduleSystem": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"enum": ["auto", "commonjs", "esm"],
|
|
17
|
+
"default": "auto",
|
|
18
|
+
"description": "Override module-system detection used to select the TypeORM CLI runner."
|
|
19
|
+
},
|
|
14
20
|
"transaction": {
|
|
15
21
|
"type": "string",
|
|
16
22
|
"enum": ["all", "each", "none"],
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import type { SchemaDropExecutorOptions } from './schema.js';
|
|
3
|
+
export default function dropSchema(options: SchemaDropExecutorOptions, context: ExecutorContext): Promise<{
|
|
4
|
+
success: boolean;
|
|
5
|
+
}>;
|
|
6
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/schema-drop/executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAE7D,wBAA8B,UAAU,CACtC,OAAO,EAAE,yBAAyB,EAClC,OAAO,EAAE,eAAe;;GASzB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"title": "TypeORM Schema Drop Executor",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"projectRoot": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"description": "Project root when it cannot be inferred from the Nx project configuration."
|
|
9
|
+
},
|
|
10
|
+
"dataSource": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "Path to the TypeORM data source file used for schema drop."
|
|
13
|
+
},
|
|
14
|
+
"moduleSystem": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"enum": ["auto", "commonjs", "esm"],
|
|
17
|
+
"default": "auto",
|
|
18
|
+
"description": "Override module-system detection used to select the TypeORM CLI runner."
|
|
19
|
+
},
|
|
20
|
+
"args": {
|
|
21
|
+
"type": "array",
|
|
22
|
+
"items": {
|
|
23
|
+
"type": "string"
|
|
24
|
+
},
|
|
25
|
+
"description": "Additional CLI arguments passed through to the TypeORM command."
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import type { SchemaLogExecutorOptions } from './schema.js';
|
|
3
|
+
export default function logSchema(options: SchemaLogExecutorOptions, context: ExecutorContext): Promise<{
|
|
4
|
+
success: boolean;
|
|
5
|
+
}>;
|
|
6
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/schema-log/executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D,wBAA8B,SAAS,CACrC,OAAO,EAAE,wBAAwB,EACjC,OAAO,EAAE,eAAe;;GASzB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"title": "TypeORM Schema Log Executor",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"projectRoot": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"description": "Project root when it cannot be inferred from the Nx project configuration."
|
|
9
|
+
},
|
|
10
|
+
"dataSource": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "Path to the TypeORM data source file used for schema logging."
|
|
13
|
+
},
|
|
14
|
+
"moduleSystem": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"enum": ["auto", "commonjs", "esm"],
|
|
17
|
+
"default": "auto",
|
|
18
|
+
"description": "Override module-system detection used to select the TypeORM CLI runner."
|
|
19
|
+
},
|
|
20
|
+
"args": {
|
|
21
|
+
"type": "array",
|
|
22
|
+
"items": {
|
|
23
|
+
"type": "string"
|
|
24
|
+
},
|
|
25
|
+
"description": "Additional CLI arguments passed through to the TypeORM command."
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import type { SchemaSyncExecutorOptions } from './schema.js';
|
|
3
|
+
export default function syncSchema(options: SchemaSyncExecutorOptions, context: ExecutorContext): Promise<{
|
|
4
|
+
success: boolean;
|
|
5
|
+
}>;
|
|
6
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/schema-sync/executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAE7D,wBAA8B,UAAU,CACtC,OAAO,EAAE,yBAAyB,EAClC,OAAO,EAAE,eAAe;;GASzB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"title": "TypeORM Schema Sync Executor",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"projectRoot": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"description": "Project root when it cannot be inferred from the Nx project configuration."
|
|
9
|
+
},
|
|
10
|
+
"dataSource": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "Path to the TypeORM data source file used for schema sync."
|
|
13
|
+
},
|
|
14
|
+
"moduleSystem": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"enum": ["auto", "commonjs", "esm"],
|
|
17
|
+
"default": "auto",
|
|
18
|
+
"description": "Override module-system detection used to select the TypeORM CLI runner."
|
|
19
|
+
},
|
|
20
|
+
"args": {
|
|
21
|
+
"type": "array",
|
|
22
|
+
"items": {
|
|
23
|
+
"type": "string"
|
|
24
|
+
},
|
|
25
|
+
"description": "Additional CLI arguments passed through to the TypeORM command."
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import {
|
|
3
|
-
export interface SeedExecutorOptions extends Pick<BaseExecutorOptions, 'projectRoot'> {
|
|
4
|
-
file: string;
|
|
5
|
-
export?: string;
|
|
6
|
-
tsconfig?: string;
|
|
7
|
-
args?: unknown[];
|
|
8
|
-
}
|
|
2
|
+
import type { SeedExecutorOptions } from './schema.js';
|
|
9
3
|
export default function seedDatabase(options: SeedExecutorOptions, context: ExecutorContext): Promise<{
|
|
10
4
|
success: boolean;
|
|
11
5
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/seed/executor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/seed/executor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,wBAA8B,YAAY,CACxC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,eAAe;;GAsCzB"}
|
|
@@ -2,7 +2,7 @@ import { existsSync } from 'node:fs';
|
|
|
2
2
|
import { isAbsolute, resolve } from 'node:path';
|
|
3
3
|
import { pathToFileURL } from 'node:url';
|
|
4
4
|
import { logger } from '@nx/devkit';
|
|
5
|
-
import { resolveProjectRoot } from '
|
|
5
|
+
import { resolveProjectRoot } from '../../utils/shared.js';
|
|
6
6
|
export default async function seedDatabase(options, context) {
|
|
7
7
|
if (!options.file) {
|
|
8
8
|
throw new Error('Provide a seed file using the file option.');
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import type { SubscriberCreateExecutorOptions } from './schema.js';
|
|
3
|
+
export default function createSubscriber(options: SubscriberCreateExecutorOptions, context: ExecutorContext): Promise<{
|
|
4
|
+
success: boolean;
|
|
5
|
+
}>;
|
|
6
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/subscriber-create/executor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAEnE,wBAA8B,gBAAgB,CAC5C,OAAO,EAAE,+BAA+B,EACxC,OAAO,EAAE,eAAe;;GAiBzB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isAbsolute, join } from 'node:path';
|
|
2
|
+
import { runTypeormCommand } from '../../utils/cli.js';
|
|
3
|
+
import { resolveProjectRoot } from '../../utils/shared.js';
|
|
4
|
+
export default async function createSubscriber(options, context) {
|
|
5
|
+
const path = options.path?.trim();
|
|
6
|
+
if (!path) {
|
|
7
|
+
throw new Error('Provide a subscriber path via the path option.');
|
|
8
|
+
}
|
|
9
|
+
const { projectRoot } = resolveProjectRoot(options.projectRoot, context);
|
|
10
|
+
const targetPath = isAbsolute(path) ? path : join(projectRoot, path);
|
|
11
|
+
const exitCode = await runTypeormCommand('subscriber:create', options, context, [targetPath]);
|
|
12
|
+
return { success: exitCode === 0 };
|
|
13
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"title": "TypeORM Subscriber Create Executor",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"path": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"description": "Path of the subscriber file."
|
|
9
|
+
},
|
|
10
|
+
"projectRoot": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "Project root when it cannot be inferred from the Nx project configuration."
|
|
13
|
+
},
|
|
14
|
+
"args": {
|
|
15
|
+
"type": "array",
|
|
16
|
+
"items": {
|
|
17
|
+
"type": "string"
|
|
18
|
+
},
|
|
19
|
+
"description": "Additional CLI arguments passed through to the TypeORM command."
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"required": ["path"]
|
|
23
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import type { VersionExecutorOptions } from './schema.js';
|
|
3
|
+
export default function typeormVersion(options: VersionExecutorOptions, context: ExecutorContext): Promise<{
|
|
4
|
+
success: boolean;
|
|
5
|
+
}>;
|
|
6
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/version/executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1D,wBAA8B,cAAc,CAC1C,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE,eAAe;;GAIzB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"title": "TypeORM Version Executor",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"args": {
|
|
7
|
+
"type": "array",
|
|
8
|
+
"items": {
|
|
9
|
+
"type": "string"
|
|
10
|
+
},
|
|
11
|
+
"description": "Additional CLI arguments passed through to the TypeORM command."
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1 +1,55 @@
|
|
|
1
|
-
|
|
1
|
+
# Choose one configuration mode:
|
|
2
|
+
# 1) DATABASE_URL
|
|
3
|
+
# 2) TYPEORM_* discrete variables
|
|
4
|
+
# Mixed mode is rejected.
|
|
5
|
+
|
|
6
|
+
# Mode 1: DATABASE_URL
|
|
7
|
+
<% if (database === 'postgres') { %>DATABASE_URL=postgresql://postgres:postgres@localhost:5432/<%= appDatabase %>
|
|
8
|
+
<% } %><% if (database === 'mysql' || database === 'mariadb') { %>DATABASE_URL=<%= database %>://root:root@localhost:3306/<%= appDatabase %>
|
|
9
|
+
<% } %><% if (database === 'mssql') { %>DATABASE_URL=sqlserver://sa:StrongPassword!123@localhost:1433;database=<%= appDatabase %>
|
|
10
|
+
<% } %><% if (database === 'sqlite' || database === 'better-sqlite3') { %>DATABASE_URL=./tmp/<%= appDatabase %>.sqlite
|
|
11
|
+
<% } %>
|
|
12
|
+
|
|
13
|
+
# Mode 2: TYPEORM_* variables
|
|
14
|
+
<% if (database === 'postgres') { %>TYPEORM_HOST=localhost
|
|
15
|
+
TYPEORM_PORT=5432
|
|
16
|
+
TYPEORM_USERNAME=postgres
|
|
17
|
+
TYPEORM_PASSWORD=postgres
|
|
18
|
+
TYPEORM_DATABASE=<%= appDatabase %>
|
|
19
|
+
TYPEORM_SCHEMA=public
|
|
20
|
+
TYPEORM_SSL=false
|
|
21
|
+
# TYPEORM_SSL can also be a JSON object:
|
|
22
|
+
# TYPEORM_SSL={"rejectUnauthorized":false}
|
|
23
|
+
TYPEORM_APPLICATION_NAME=<%= appDatabase %>-service
|
|
24
|
+
TYPEORM_CONNECT_TIMEOUT_MS=5000
|
|
25
|
+
<% } %><% if (database === 'mysql' || database === 'mariadb') { %>TYPEORM_HOST=localhost
|
|
26
|
+
TYPEORM_PORT=3306
|
|
27
|
+
TYPEORM_USERNAME=root
|
|
28
|
+
TYPEORM_PASSWORD=root
|
|
29
|
+
TYPEORM_DATABASE=<%= appDatabase %>
|
|
30
|
+
TYPEORM_SSL=false
|
|
31
|
+
TYPEORM_SOCKET_PATH=
|
|
32
|
+
TYPEORM_CHARSET=utf8mb4
|
|
33
|
+
TYPEORM_TIMEZONE=Z
|
|
34
|
+
TYPEORM_CONNECT_TIMEOUT=10000
|
|
35
|
+
<% } %><% if (database === 'mssql') { %>TYPEORM_HOST=localhost
|
|
36
|
+
TYPEORM_PORT=1433
|
|
37
|
+
TYPEORM_USERNAME=sa
|
|
38
|
+
TYPEORM_PASSWORD=StrongPassword!123
|
|
39
|
+
TYPEORM_DATABASE=<%= appDatabase %>
|
|
40
|
+
TYPEORM_DOMAIN=
|
|
41
|
+
TYPEORM_CONNECTION_TIMEOUT=15000
|
|
42
|
+
TYPEORM_REQUEST_TIMEOUT=15000
|
|
43
|
+
TYPEORM_ENCRYPT=false
|
|
44
|
+
TYPEORM_TRUST_SERVER_CERTIFICATE=true
|
|
45
|
+
TYPEORM_INSTANCE_NAME=
|
|
46
|
+
<% } %><% if (database === 'sqlite') { %>TYPEORM_DATABASE=./tmp/<%= appDatabase %>.sqlite
|
|
47
|
+
TYPEORM_BUSY_TIMEOUT=5000
|
|
48
|
+
TYPEORM_ENABLE_WAL=true
|
|
49
|
+
<% } %><% if (database === 'better-sqlite3') { %>TYPEORM_DATABASE=./tmp/<%= appDatabase %>.sqlite
|
|
50
|
+
TYPEORM_ENABLE_WAL=true
|
|
51
|
+
TYPEORM_TIMEOUT=5000
|
|
52
|
+
TYPEORM_READONLY=false
|
|
53
|
+
TYPEORM_FILE_MUST_EXIST=false
|
|
54
|
+
TYPEORM_STATEMENT_CACHE_SIZE=100
|
|
55
|
+
<% } %>
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export function makeRuntimeDataSource(): DataSource {
|
|
4
|
-
const url = process.env.DATABASE_URL;
|
|
5
|
-
if (!url) {
|
|
6
|
-
throw new Error('Missing DATABASE_URL');
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
return new DataSource({
|
|
10
|
-
type: '<%= database %>',
|
|
11
|
-
url,
|
|
12
|
-
synchronize: false,
|
|
13
|
-
logging: false,
|
|
14
|
-
});
|
|
15
|
-
}
|
|
1
|
+
export { makeRuntimeDataSource } from './data-source';
|