@tactical-ddd/nx 0.0.2-alpha.0 → 0.0.2-alpha.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.
- package/README.md +137 -1
- package/generators/domain/domain.d.ts +5 -0
- package/generators/domain/domain.d.ts.map +1 -0
- package/generators/domain/domain.js +211 -0
- package/generators/domain/domain.js.map +1 -0
- package/generators/domain/files/contracts/src/index.ts +1 -0
- package/generators/domain/files/contracts/src/lib/interfaces/__name__-facade.interface.ts +7 -0
- package/generators/domain/files/core/src/index.ts +1 -0
- package/generators/domain/files/core/src/lib/application/__name__.facade.ts +7 -0
- package/generators/domain/files/core/src/lib/domain/.gitkeep +0 -0
- package/generators/domain/files/core/src/lib/infrastructure/.gitkeep +0 -0
- package/generators/domain/schema.d.js +6 -0
- package/generators/domain/schema.d.js.map +1 -0
- package/generators/domain/schema.d.ts +12 -0
- package/generators/domain/schema.json +73 -0
- package/generators/init/init.d.ts +5 -0
- package/generators/init/init.d.ts.map +1 -0
- package/generators/init/init.js +193 -0
- package/generators/init/init.js.map +1 -0
- package/generators/init/module-boundaries.d.ts +14 -0
- package/generators/init/module-boundaries.d.ts.map +1 -0
- package/generators/init/module-boundaries.js +140 -0
- package/generators/init/module-boundaries.js.map +1 -0
- package/generators/init/schema.d.js +6 -0
- package/generators/init/schema.d.js.map +1 -0
- package/generators/init/schema.d.ts +10 -0
- package/generators/init/schema.json +55 -0
- package/generators/shared-kernel/schema.d.ts +1 -1
- package/generators/shared-kernel/schema.json +1 -1
- package/generators/shared-kernel/shared-kernel.d.ts +2 -2
- package/generators/shared-kernel/shared-kernel.d.ts.map +1 -1
- package/generators/shared-kernel/shared-kernel.js +29 -15
- package/generators/shared-kernel/shared-kernel.js.map +1 -1
- package/generators.json +10 -0
- package/index.d.ts +5 -0
- package/index.d.ts.map +1 -1
- package/index.js +5 -0
- package/index.js.map +1 -1
- package/package.json +19 -1
- package/types.d.ts +3 -1
- package/types.d.ts.map +1 -1
- package/types.js +2 -0
- package/types.js.map +1 -1
- package/utils/eslint-module-boundaries.d.ts +30 -0
- package/utils/eslint-module-boundaries.d.ts.map +1 -0
- package/utils/eslint-module-boundaries.js +206 -0
- package/utils/eslint-module-boundaries.js.map +1 -0
- package/utils/library-exist.d.ts +12 -0
- package/utils/library-exist.d.ts.map +1 -0
- package/utils/library-exist.js +15 -0
- package/utils/library-exist.js.map +1 -0
- package/utils/logger.d.ts +13 -0
- package/utils/logger.d.ts.map +1 -0
- package/utils/logger.js +48 -0
- package/utils/logger.js.map +1 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get default () {
|
|
13
|
+
return _default;
|
|
14
|
+
},
|
|
15
|
+
get initGenerator () {
|
|
16
|
+
return initGenerator;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _extends = require("@swc/helpers/_/_extends");
|
|
20
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
21
|
+
const _devkit = require("@nx/devkit");
|
|
22
|
+
const _moduleboundaries = require("./module-boundaries");
|
|
23
|
+
const _eslintmoduleboundaries = require("../../utils/eslint-module-boundaries");
|
|
24
|
+
const _sharedkernel = /*#__PURE__*/ _interop_require_default._(require("../shared-kernel/shared-kernel"));
|
|
25
|
+
/**
|
|
26
|
+
* Collection name this plugin publishes its generators under. Used as the key
|
|
27
|
+
* in `nx.json`'s `generators` map so defaults apply to every generator we ship.
|
|
28
|
+
*/ const COLLECTION = '@tactical-ddd/nx';
|
|
29
|
+
/**
|
|
30
|
+
* Generators that accept (and should inherit) the workspace-wide `prefix`.
|
|
31
|
+
* Extend this list as new generators are added — for now only `shared-kernel`
|
|
32
|
+
* consumes the prefix.
|
|
33
|
+
*/ const PREFIXED_GENERATORS = [
|
|
34
|
+
'shared-kernel',
|
|
35
|
+
'domain'
|
|
36
|
+
];
|
|
37
|
+
/**
|
|
38
|
+
* Built-in Nx library generators that should inherit the workspace-wide
|
|
39
|
+
* build/lint/test defaults so hand-rolled libraries match the conventions.
|
|
40
|
+
* `@nx/js:library` always applies; `@nx/react:library` is layered on only for
|
|
41
|
+
* the `react` preset (see {@link setGeneratorDefaults}).
|
|
42
|
+
*/ const BASE_LIBRARY_GENERATORS = [
|
|
43
|
+
'@nx/js:library'
|
|
44
|
+
];
|
|
45
|
+
const REACT_LIBRARY_GENERATORS = [
|
|
46
|
+
'@nx/react:library'
|
|
47
|
+
];
|
|
48
|
+
/** The Tactical DDD React runtime bindings package. */ const TACTICAL_DDD_REACT = '@tactical-ddd/react';
|
|
49
|
+
/**
|
|
50
|
+
* React runtime versions added to the *user's* workspace under the `react`
|
|
51
|
+
* preset. Kept in step with the React version `@nx/react`'s own generators
|
|
52
|
+
* install so the two never disagree.
|
|
53
|
+
*/ const REACT_VERSION = '^19.0.0';
|
|
54
|
+
const REACT_DOM_VERSION = '^19.0.0';
|
|
55
|
+
/**
|
|
56
|
+
* Version specifier to install `@tactical-ddd/react` at. The React bindings are
|
|
57
|
+
* released in lockstep with this plugin, so we mirror the running plugin's own
|
|
58
|
+
* version. This also makes the e2e suite resolve the locally-published build:
|
|
59
|
+
* both packages are published to the local registry under the same e2e version.
|
|
60
|
+
*/ function tacticalDddReactVersion() {
|
|
61
|
+
try {
|
|
62
|
+
// Resolves from the workspace the generator runs in, where the plugin is
|
|
63
|
+
// installed (real usage and e2e).
|
|
64
|
+
return require('@tactical-ddd/nx/package.json').version;
|
|
65
|
+
} catch (unused) {
|
|
66
|
+
// Source / unit-test fallback: this package's own manifest.
|
|
67
|
+
return require('../../../package.json').version;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async function initGenerator(tree, options) {
|
|
71
|
+
setGeneratorDefaults(tree, options);
|
|
72
|
+
// Make sure every Nx plugin the configured/invoked generators rely on is
|
|
73
|
+
// present; the returned task installs whatever was missing once the generator
|
|
74
|
+
// finishes writing to the tree.
|
|
75
|
+
const installDependencies = ensureGeneratorDependencies(tree, options);
|
|
76
|
+
// Generate the shared kernel first: in a fresh workspace the root ESLint
|
|
77
|
+
// config does not exist until the first library is generated, so this is what
|
|
78
|
+
// establishes the config that `applyDepConstraints` then tunes.
|
|
79
|
+
const installKernel = await (0, _sharedkernel.default)(tree, {
|
|
80
|
+
directory: options.sharedDirectory,
|
|
81
|
+
prefix: options.prefix,
|
|
82
|
+
linter: options.linter,
|
|
83
|
+
unitTestRunner: options.unitTestRunner,
|
|
84
|
+
bundler: options.bundler
|
|
85
|
+
});
|
|
86
|
+
// Populate the root ESLint config with the Tactical DDD dependency graph so
|
|
87
|
+
// the architecture is enforced at lint time. Skipped (with a warning) when
|
|
88
|
+
// the workspace has no ESLint config — e.g. `linter: none`.
|
|
89
|
+
(0, _eslintmoduleboundaries.applyDepConstraints)(tree, _moduleboundaries.DEP_CONSTRAINTS);
|
|
90
|
+
await (0, _devkit.formatFiles)(tree);
|
|
91
|
+
// Run both the plugin-dependency install and the shared kernel's own install
|
|
92
|
+
// callbacks (the latter installs the packages backing the inferred ESLint/Jest
|
|
93
|
+
// plugins the generated libraries registered).
|
|
94
|
+
return (0, _devkit.runTasksInSerial)(installDependencies, installKernel);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Ensures the Nx plugin packages the configured/invoked generators depend on are
|
|
98
|
+
* declared in the workspace `package.json`, installing any that are missing.
|
|
99
|
+
*
|
|
100
|
+
* `addDependenciesToPackageJson` is itself the presence check: it only adds (or
|
|
101
|
+
* bumps) entries that are absent or older, leaving existing versions untouched,
|
|
102
|
+
* and returns a task that runs the package manager install for whatever changed.
|
|
103
|
+
* All versions are pinned to `NX_VERSION` — the Nx version this plugin runs
|
|
104
|
+
* against — so the added plugins stay in lockstep with the workspace's Nx core.
|
|
105
|
+
*
|
|
106
|
+
* Dependencies are scoped to the chosen options: the ESLint tooling is only
|
|
107
|
+
* required when `linter: 'eslint'`, and the test-runner plugin follows
|
|
108
|
+
* `unitTestRunner`. The `react` preset additionally pulls in the `@nx/react`
|
|
109
|
+
* generator plugin (dev-time) plus the React runtime — `react`, `react-dom`
|
|
110
|
+
* and the `@tactical-ddd/react` bindings — as production dependencies.
|
|
111
|
+
*/ function ensureGeneratorDependencies(tree, options) {
|
|
112
|
+
const dependencies = {};
|
|
113
|
+
const devDependencies = {
|
|
114
|
+
// Powers the shared-kernel generator (`@nx/js:library`) and the
|
|
115
|
+
// `@nx/js:library` defaults written above.
|
|
116
|
+
'@nx/js': _devkit.NX_VERSION
|
|
117
|
+
};
|
|
118
|
+
if (options.linter === 'eslint') {
|
|
119
|
+
// `@nx/eslint` provides the flat-config AST utilities and lint target;
|
|
120
|
+
// `@nx/eslint-plugin` provides the `@nx/enforce-module-boundaries` rule.
|
|
121
|
+
devDependencies['@nx/eslint'] = _devkit.NX_VERSION;
|
|
122
|
+
devDependencies['@nx/eslint-plugin'] = _devkit.NX_VERSION;
|
|
123
|
+
}
|
|
124
|
+
if (options.unitTestRunner === 'jest') {
|
|
125
|
+
devDependencies['@nx/jest'] = _devkit.NX_VERSION;
|
|
126
|
+
} else if (options.unitTestRunner === 'vitest') {
|
|
127
|
+
devDependencies['@nx/vite'] = _devkit.NX_VERSION;
|
|
128
|
+
}
|
|
129
|
+
if (options.preset === 'react') {
|
|
130
|
+
// Dev-time: powers the `@nx/react:library` defaults and React generators.
|
|
131
|
+
devDependencies['@nx/react'] = _devkit.NX_VERSION;
|
|
132
|
+
// Run-time: the React framework and our React bindings ship in the app.
|
|
133
|
+
dependencies['react'] = REACT_VERSION;
|
|
134
|
+
dependencies['react-dom'] = REACT_DOM_VERSION;
|
|
135
|
+
dependencies[TACTICAL_DDD_REACT] = tacticalDddReactVersion();
|
|
136
|
+
}
|
|
137
|
+
return (0, _devkit.addDependenciesToPackageJson)(tree, dependencies, devDependencies);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Persists workspace-wide generator defaults into `nx.json` so choices like the
|
|
141
|
+
* organization `prefix`, linter and test runner are configured once during
|
|
142
|
+
* `init` and then transparently injected by Nx into every subsequent generator
|
|
143
|
+
* invocation (e.g. `nx g @tactical-ddd/nx:shared-kernel`, or even the built-in
|
|
144
|
+
* `nx g @nx/js:library`) without the user re-typing them.
|
|
145
|
+
*
|
|
146
|
+
* Two groups of defaults are written:
|
|
147
|
+
*
|
|
148
|
+
* "generators": {
|
|
149
|
+
* // 1. Our own collection — inherit the prefix and linting/testing choices.
|
|
150
|
+
* "@tactical-ddd/nx": {
|
|
151
|
+
* "shared-kernel": { "prefix": "@my-org", "linter": "eslint", "unitTestRunner": "jest" }
|
|
152
|
+
* },
|
|
153
|
+
* // 2. The built-in library generators — so hand-rolled libs match conventions.
|
|
154
|
+
* "@nx/js:library": { "bundler": "none", "linter": "eslint", "unitTestRunner": "jest" },
|
|
155
|
+
* // `@nx/react:library` is added only under the `react` preset.
|
|
156
|
+
* "@nx/react:library": { "bundler": "none", "linter": "eslint", "unitTestRunner": "jest" }
|
|
157
|
+
* }
|
|
158
|
+
*/ function setGeneratorDefaults(tree, options) {
|
|
159
|
+
var _readNxJson, _nxJson, _generators, _generators1, _COLLECTION, _, _options_bundler;
|
|
160
|
+
const nxJson = (_readNxJson = (0, _devkit.readNxJson)(tree)) != null ? _readNxJson : {};
|
|
161
|
+
const generators = (_generators = (_nxJson = nxJson).generators) != null ? _generators : _nxJson.generators = {};
|
|
162
|
+
// 1. Our own collection's generators inherit the prefix + linting/testing.
|
|
163
|
+
const collectionDefaults = (_ = (_generators1 = generators)[_COLLECTION = COLLECTION]) != null ? _ : _generators1[_COLLECTION] = {};
|
|
164
|
+
for (const generator of PREFIXED_GENERATORS){
|
|
165
|
+
collectionDefaults[generator] = _extends._({}, collectionDefaults[generator], {
|
|
166
|
+
prefix: options.prefix,
|
|
167
|
+
linter: options.linter,
|
|
168
|
+
unitTestRunner: options.unitTestRunner,
|
|
169
|
+
preset: options.preset
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
// 2. The built-in library generators get the same workspace-wide build/lint/
|
|
173
|
+
// test defaults, so a plain `nx g @nx/js:library` (or `@nx/react:library`)
|
|
174
|
+
// produces a library that already matches the Tactical DDD conventions.
|
|
175
|
+
// `@nx/react:library` defaults are written only under the `react` preset, so
|
|
176
|
+
// we don't advertise React tooling a non-React workspace never installed.
|
|
177
|
+
const libraryDefaults = {
|
|
178
|
+
bundler: (_options_bundler = options.bundler) != null ? _options_bundler : 'none',
|
|
179
|
+
linter: options.linter,
|
|
180
|
+
unitTestRunner: options.unitTestRunner
|
|
181
|
+
};
|
|
182
|
+
const libraryGenerators = options.preset === 'react' ? [
|
|
183
|
+
...BASE_LIBRARY_GENERATORS,
|
|
184
|
+
...REACT_LIBRARY_GENERATORS
|
|
185
|
+
] : BASE_LIBRARY_GENERATORS;
|
|
186
|
+
for (const generator of libraryGenerators){
|
|
187
|
+
generators[generator] = _extends._({}, generators[generator], libraryDefaults);
|
|
188
|
+
}
|
|
189
|
+
(0, _devkit.updateNxJson)(tree, nxJson);
|
|
190
|
+
}
|
|
191
|
+
const _default = initGenerator;
|
|
192
|
+
|
|
193
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx/src/generators/init/init.ts"],"sourcesContent":["import {\n addDependenciesToPackageJson,\n formatFiles,\n NX_VERSION,\n readNxJson,\n runTasksInSerial,\n updateNxJson,\n type GeneratorCallback,\n type NxJsonConfiguration,\n type Tree,\n} from '@nx/devkit';\n\nimport type { InitGeneratorSchema } from './schema';\nimport { DEP_CONSTRAINTS } from './module-boundaries';\nimport { applyDepConstraints } from '../../utils/eslint-module-boundaries';\nimport sharedKernelGenerator from '../shared-kernel/shared-kernel';\n\n/**\n * Collection name this plugin publishes its generators under. Used as the key\n * in `nx.json`'s `generators` map so defaults apply to every generator we ship.\n */\nconst COLLECTION = '@tactical-ddd/nx';\n\n/**\n * Generators that accept (and should inherit) the workspace-wide `prefix`.\n * Extend this list as new generators are added — for now only `shared-kernel`\n * consumes the prefix.\n */\nconst PREFIXED_GENERATORS = ['shared-kernel', 'domain'] as const;\n\n/**\n * Built-in Nx library generators that should inherit the workspace-wide\n * build/lint/test defaults so hand-rolled libraries match the conventions.\n * `@nx/js:library` always applies; `@nx/react:library` is layered on only for\n * the `react` preset (see {@link setGeneratorDefaults}).\n */\nconst BASE_LIBRARY_GENERATORS = ['@nx/js:library'] as const;\nconst REACT_LIBRARY_GENERATORS = ['@nx/react:library'] as const;\n\n/** The Tactical DDD React runtime bindings package. */\nconst TACTICAL_DDD_REACT = '@tactical-ddd/react';\n\n/**\n * React runtime versions added to the *user's* workspace under the `react`\n * preset. Kept in step with the React version `@nx/react`'s own generators\n * install so the two never disagree.\n */\nconst REACT_VERSION = '^19.0.0';\nconst REACT_DOM_VERSION = '^19.0.0';\n\n/**\n * Version specifier to install `@tactical-ddd/react` at. The React bindings are\n * released in lockstep with this plugin, so we mirror the running plugin's own\n * version. This also makes the e2e suite resolve the locally-published build:\n * both packages are published to the local registry under the same e2e version.\n */\nfunction tacticalDddReactVersion(): string {\n try {\n // Resolves from the workspace the generator runs in, where the plugin is\n // installed (real usage and e2e).\n return require('@tactical-ddd/nx/package.json').version as string;\n } catch {\n // Source / unit-test fallback: this package's own manifest.\n return require('../../../package.json').version as string;\n }\n}\n\nexport async function initGenerator(\n tree: Tree,\n options: InitGeneratorSchema,\n): Promise<GeneratorCallback> {\n setGeneratorDefaults(tree, options);\n\n // Make sure every Nx plugin the configured/invoked generators rely on is\n // present; the returned task installs whatever was missing once the generator\n // finishes writing to the tree.\n const installDependencies = ensureGeneratorDependencies(tree, options);\n\n // Generate the shared kernel first: in a fresh workspace the root ESLint\n // config does not exist until the first library is generated, so this is what\n // establishes the config that `applyDepConstraints` then tunes.\n const installKernel = await sharedKernelGenerator(tree, {\n directory: options.sharedDirectory,\n prefix: options.prefix,\n linter: options.linter,\n unitTestRunner: options.unitTestRunner,\n bundler: options.bundler,\n });\n\n // Populate the root ESLint config with the Tactical DDD dependency graph so\n // the architecture is enforced at lint time. Skipped (with a warning) when\n // the workspace has no ESLint config — e.g. `linter: none`.\n applyDepConstraints(tree, DEP_CONSTRAINTS);\n\n await formatFiles(tree);\n\n // Run both the plugin-dependency install and the shared kernel's own install\n // callbacks (the latter installs the packages backing the inferred ESLint/Jest\n // plugins the generated libraries registered).\n return runTasksInSerial(installDependencies, installKernel);\n}\n\n/**\n * Ensures the Nx plugin packages the configured/invoked generators depend on are\n * declared in the workspace `package.json`, installing any that are missing.\n *\n * `addDependenciesToPackageJson` is itself the presence check: it only adds (or\n * bumps) entries that are absent or older, leaving existing versions untouched,\n * and returns a task that runs the package manager install for whatever changed.\n * All versions are pinned to `NX_VERSION` — the Nx version this plugin runs\n * against — so the added plugins stay in lockstep with the workspace's Nx core.\n *\n * Dependencies are scoped to the chosen options: the ESLint tooling is only\n * required when `linter: 'eslint'`, and the test-runner plugin follows\n * `unitTestRunner`. The `react` preset additionally pulls in the `@nx/react`\n * generator plugin (dev-time) plus the React runtime — `react`, `react-dom`\n * and the `@tactical-ddd/react` bindings — as production dependencies.\n */\nfunction ensureGeneratorDependencies(\n tree: Tree,\n options: InitGeneratorSchema,\n): GeneratorCallback {\n const dependencies: Record<string, string> = {};\n const devDependencies: Record<string, string> = {\n // Powers the shared-kernel generator (`@nx/js:library`) and the\n // `@nx/js:library` defaults written above.\n '@nx/js': NX_VERSION,\n };\n\n if (options.linter === 'eslint') {\n // `@nx/eslint` provides the flat-config AST utilities and lint target;\n // `@nx/eslint-plugin` provides the `@nx/enforce-module-boundaries` rule.\n devDependencies['@nx/eslint'] = NX_VERSION;\n devDependencies['@nx/eslint-plugin'] = NX_VERSION;\n }\n\n if (options.unitTestRunner === 'jest') {\n devDependencies['@nx/jest'] = NX_VERSION;\n } else if (options.unitTestRunner === 'vitest') {\n devDependencies['@nx/vite'] = NX_VERSION;\n }\n\n if (options.preset === 'react') {\n // Dev-time: powers the `@nx/react:library` defaults and React generators.\n devDependencies['@nx/react'] = NX_VERSION;\n // Run-time: the React framework and our React bindings ship in the app.\n dependencies['react'] = REACT_VERSION;\n dependencies['react-dom'] = REACT_DOM_VERSION;\n dependencies[TACTICAL_DDD_REACT] = tacticalDddReactVersion();\n }\n\n return addDependenciesToPackageJson(tree, dependencies, devDependencies);\n}\n\n/**\n * Persists workspace-wide generator defaults into `nx.json` so choices like the\n * organization `prefix`, linter and test runner are configured once during\n * `init` and then transparently injected by Nx into every subsequent generator\n * invocation (e.g. `nx g @tactical-ddd/nx:shared-kernel`, or even the built-in\n * `nx g @nx/js:library`) without the user re-typing them.\n *\n * Two groups of defaults are written:\n *\n * \"generators\": {\n * // 1. Our own collection — inherit the prefix and linting/testing choices.\n * \"@tactical-ddd/nx\": {\n * \"shared-kernel\": { \"prefix\": \"@my-org\", \"linter\": \"eslint\", \"unitTestRunner\": \"jest\" }\n * },\n * // 2. The built-in library generators — so hand-rolled libs match conventions.\n * \"@nx/js:library\": { \"bundler\": \"none\", \"linter\": \"eslint\", \"unitTestRunner\": \"jest\" },\n * // `@nx/react:library` is added only under the `react` preset.\n * \"@nx/react:library\": { \"bundler\": \"none\", \"linter\": \"eslint\", \"unitTestRunner\": \"jest\" }\n * }\n */\nfunction setGeneratorDefaults(tree: Tree, options: InitGeneratorSchema) {\n const nxJson = readNxJson(tree) ?? ({} as NxJsonConfiguration);\n\n const generators = (nxJson.generators ??= {}) as Record<\n string,\n Record<string, unknown>\n >;\n\n // 1. Our own collection's generators inherit the prefix + linting/testing.\n const collectionDefaults = (generators[COLLECTION] ??= {}) as Record<\n string,\n Record<string, unknown>\n >;\n\n for (const generator of PREFIXED_GENERATORS) {\n collectionDefaults[generator] = {\n ...collectionDefaults[generator],\n prefix: options.prefix,\n linter: options.linter,\n unitTestRunner: options.unitTestRunner,\n preset: options.preset,\n };\n }\n\n // 2. The built-in library generators get the same workspace-wide build/lint/\n // test defaults, so a plain `nx g @nx/js:library` (or `@nx/react:library`)\n // produces a library that already matches the Tactical DDD conventions.\n // `@nx/react:library` defaults are written only under the `react` preset, so\n // we don't advertise React tooling a non-React workspace never installed.\n const libraryDefaults: Record<string, unknown> = {\n bundler: options.bundler ?? 'none',\n linter: options.linter,\n unitTestRunner: options.unitTestRunner,\n };\n\n const libraryGenerators =\n options.preset === 'react'\n ? [...BASE_LIBRARY_GENERATORS, ...REACT_LIBRARY_GENERATORS]\n : BASE_LIBRARY_GENERATORS;\n\n for (const generator of libraryGenerators) {\n generators[generator] = {\n ...generators[generator],\n ...libraryDefaults,\n };\n }\n\n updateNxJson(tree, nxJson);\n}\n\nexport default initGenerator;\n"],"names":["initGenerator","COLLECTION","PREFIXED_GENERATORS","BASE_LIBRARY_GENERATORS","REACT_LIBRARY_GENERATORS","TACTICAL_DDD_REACT","REACT_VERSION","REACT_DOM_VERSION","tacticalDddReactVersion","require","version","tree","options","setGeneratorDefaults","installDependencies","ensureGeneratorDependencies","installKernel","sharedKernelGenerator","directory","sharedDirectory","prefix","linter","unitTestRunner","bundler","applyDepConstraints","DEP_CONSTRAINTS","formatFiles","runTasksInSerial","dependencies","devDependencies","NX_VERSION","preset","addDependenciesToPackageJson","readNxJson","nxJson","generators","collectionDefaults","generator","libraryDefaults","libraryGenerators","updateNxJson"],"mappings":"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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `depConstraints` for `@nx/enforce-module-boundaries`, encoding the dependency
|
|
3
|
+
* graph of the Tactical DDD architecture.
|
|
4
|
+
*
|
|
5
|
+
* The rule enforces two things at once:
|
|
6
|
+
* 1. The allowed dependency directions described below (a library may only
|
|
7
|
+
* depend on libraries whose tags are listed in `onlyDependOnLibsWithTags`).
|
|
8
|
+
* 2. The absence of circular dependencies between projects — this is built
|
|
9
|
+
* into `@nx/enforce-module-boundaries` and needs no extra option.
|
|
10
|
+
*/
|
|
11
|
+
import type { DepConstraint } from '../../utils/eslint-module-boundaries';
|
|
12
|
+
export type { DepConstraint };
|
|
13
|
+
export declare const DEP_CONSTRAINTS: DepConstraint[];
|
|
14
|
+
//# sourceMappingURL=module-boundaries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-boundaries.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/generators/init/module-boundaries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAE1E,YAAY,EAAE,aAAa,EAAE,CAAC;AAE9B,eAAO,MAAM,eAAe,EAAE,aAAa,EAkH1C,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `depConstraints` for `@nx/enforce-module-boundaries`, encoding the dependency
|
|
3
|
+
* graph of the Tactical DDD architecture.
|
|
4
|
+
*
|
|
5
|
+
* The rule enforces two things at once:
|
|
6
|
+
* 1. The allowed dependency directions described below (a library may only
|
|
7
|
+
* depend on libraries whose tags are listed in `onlyDependOnLibsWithTags`).
|
|
8
|
+
* 2. The absence of circular dependencies between projects — this is built
|
|
9
|
+
* into `@nx/enforce-module-boundaries` and needs no extra option.
|
|
10
|
+
*/ "use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", {
|
|
12
|
+
value: true
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "DEP_CONSTRAINTS", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function() {
|
|
17
|
+
return DEP_CONSTRAINTS;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const _types = require("../../types");
|
|
21
|
+
const DEP_CONSTRAINTS = [
|
|
22
|
+
// ==========================================
|
|
23
|
+
// 1. SCOPE RULES
|
|
24
|
+
// ==========================================
|
|
25
|
+
// Shared knows about nothing but itself.
|
|
26
|
+
{
|
|
27
|
+
sourceTag: _types.LibraryScope.Shared,
|
|
28
|
+
onlyDependOnLibsWithTags: [
|
|
29
|
+
_types.LibraryScope.Shared
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
// A domain may use shared libraries and other libraries of its own scope.
|
|
33
|
+
{
|
|
34
|
+
sourceTag: _types.LibraryScope.Domain,
|
|
35
|
+
onlyDependOnLibsWithTags: [
|
|
36
|
+
_types.LibraryScope.Domain,
|
|
37
|
+
_types.LibraryScope.Shared
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
// ==========================================
|
|
41
|
+
// 2. CROSS-DOMAIN IMPORT PROTECTION
|
|
42
|
+
// ==========================================
|
|
43
|
+
// Per-domain isolation cannot be expressed by a single static constraint:
|
|
44
|
+
// `@nx/enforce-module-boundaries` glob-matches the target tags too, so a
|
|
45
|
+
// `domain:*` → `domain:*` rule would let `domain:auth` import `domain:payments`.
|
|
46
|
+
// The actual silo is enforced by a per-domain constraint
|
|
47
|
+
// (`domain:<name>` → [`domain:<name>`, `scope:shared`, `type:contracts`]) that
|
|
48
|
+
// the `domain` generator injects for each domain it creates — confining a
|
|
49
|
+
// domain to itself, the shared kernel, and the *public contracts* of other
|
|
50
|
+
// domains (the published-language pattern), never their implementation. This
|
|
51
|
+
// baseline entry only scopes any domain library to domains + shared
|
|
52
|
+
// (mirroring the `scope:domain` rule above); the injected per-domain
|
|
53
|
+
// constraints add the real restriction (Nx requires *every* matching
|
|
54
|
+
// constraint to permit a dependency).
|
|
55
|
+
{
|
|
56
|
+
sourceTag: _types.LibraryScope.CrossDomain,
|
|
57
|
+
onlyDependOnLibsWithTags: [
|
|
58
|
+
_types.LibraryScope.CrossDomain,
|
|
59
|
+
_types.LibraryScope.Shared
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
// ==========================================
|
|
63
|
+
// 3. TYPE RULES (ARCHITECTURE LAYERS)
|
|
64
|
+
// ==========================================
|
|
65
|
+
// Contracts: the foundation. May import nothing.
|
|
66
|
+
{
|
|
67
|
+
sourceTag: _types.LibraryType.Contracts,
|
|
68
|
+
onlyDependOnLibsWithTags: [
|
|
69
|
+
_types.LibraryType.Contracts
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
// Utils: pure functions. Know only contracts and other utils.
|
|
73
|
+
{
|
|
74
|
+
sourceTag: _types.LibraryType.Utils,
|
|
75
|
+
onlyDependOnLibsWithTags: [
|
|
76
|
+
_types.LibraryType.Contracts,
|
|
77
|
+
_types.LibraryType.Utils
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
// Infrastructure: I/O, API clients. Know types and helpers.
|
|
81
|
+
{
|
|
82
|
+
sourceTag: _types.LibraryType.Infrastructure,
|
|
83
|
+
onlyDependOnLibsWithTags: [
|
|
84
|
+
_types.LibraryType.Contracts,
|
|
85
|
+
_types.LibraryType.Utils,
|
|
86
|
+
_types.LibraryType.Infrastructure
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
// Core: business logic. May use everything below it plus its own domain core.
|
|
90
|
+
{
|
|
91
|
+
sourceTag: _types.LibraryType.Core,
|
|
92
|
+
onlyDependOnLibsWithTags: [
|
|
93
|
+
_types.LibraryType.Contracts,
|
|
94
|
+
_types.LibraryType.Utils,
|
|
95
|
+
_types.LibraryType.Infrastructure,
|
|
96
|
+
_types.LibraryType.Core
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
// ------------------------------------------
|
|
100
|
+
// UI (presentational components)
|
|
101
|
+
// ------------------------------------------
|
|
102
|
+
// Dumb components (buttons, cards, forms). Know only props interfaces
|
|
103
|
+
// (contracts) and formatting helpers (utils). Importing core (entities) or
|
|
104
|
+
// infrastructure is strictly forbidden.
|
|
105
|
+
{
|
|
106
|
+
sourceTag: _types.LibraryType.Ui,
|
|
107
|
+
onlyDependOnLibsWithTags: [
|
|
108
|
+
_types.LibraryType.Contracts,
|
|
109
|
+
_types.LibraryType.Utils,
|
|
110
|
+
_types.LibraryType.Ui
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
// Testing: mocks and fixtures. May import the core for mocking.
|
|
114
|
+
{
|
|
115
|
+
sourceTag: _types.LibraryType.Testing,
|
|
116
|
+
onlyDependOnLibsWithTags: [
|
|
117
|
+
_types.LibraryType.Contracts,
|
|
118
|
+
_types.LibraryType.Utils,
|
|
119
|
+
_types.LibraryType.Infrastructure,
|
|
120
|
+
_types.LibraryType.Core,
|
|
121
|
+
_types.LibraryType.Ui,
|
|
122
|
+
_types.LibraryType.Testing
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
// Features: UI and state. The topmost layer, may import everything.
|
|
126
|
+
{
|
|
127
|
+
sourceTag: _types.LibraryType.Features,
|
|
128
|
+
onlyDependOnLibsWithTags: [
|
|
129
|
+
_types.LibraryType.Contracts,
|
|
130
|
+
_types.LibraryType.Utils,
|
|
131
|
+
_types.LibraryType.Infrastructure,
|
|
132
|
+
_types.LibraryType.Core,
|
|
133
|
+
_types.LibraryType.Ui,
|
|
134
|
+
_types.LibraryType.Testing,
|
|
135
|
+
_types.LibraryType.Features
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
];
|
|
139
|
+
|
|
140
|
+
//# sourceMappingURL=module-boundaries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx/src/generators/init/module-boundaries.ts"],"sourcesContent":["/**\n * `depConstraints` for `@nx/enforce-module-boundaries`, encoding the dependency\n * graph of the Tactical DDD architecture.\n *\n * The rule enforces two things at once:\n * 1. The allowed dependency directions described below (a library may only\n * depend on libraries whose tags are listed in `onlyDependOnLibsWithTags`).\n * 2. The absence of circular dependencies between projects — this is built\n * into `@nx/enforce-module-boundaries` and needs no extra option.\n */\n\nimport { LibraryScope, LibraryType } from '../../types';\nimport type { DepConstraint } from '../../utils/eslint-module-boundaries';\n\nexport type { DepConstraint };\n\nexport const DEP_CONSTRAINTS: DepConstraint[] = [\n // ==========================================\n // 1. SCOPE RULES\n // ==========================================\n\n // Shared knows about nothing but itself.\n {\n sourceTag: LibraryScope.Shared,\n onlyDependOnLibsWithTags: [LibraryScope.Shared],\n },\n // A domain may use shared libraries and other libraries of its own scope.\n {\n sourceTag: LibraryScope.Domain,\n onlyDependOnLibsWithTags: [LibraryScope.Domain, LibraryScope.Shared],\n },\n\n // ==========================================\n // 2. CROSS-DOMAIN IMPORT PROTECTION\n // ==========================================\n // Per-domain isolation cannot be expressed by a single static constraint:\n // `@nx/enforce-module-boundaries` glob-matches the target tags too, so a\n // `domain:*` → `domain:*` rule would let `domain:auth` import `domain:payments`.\n // The actual silo is enforced by a per-domain constraint\n // (`domain:<name>` → [`domain:<name>`, `scope:shared`, `type:contracts`]) that\n // the `domain` generator injects for each domain it creates — confining a\n // domain to itself, the shared kernel, and the *public contracts* of other\n // domains (the published-language pattern), never their implementation. This\n // baseline entry only scopes any domain library to domains + shared\n // (mirroring the `scope:domain` rule above); the injected per-domain\n // constraints add the real restriction (Nx requires *every* matching\n // constraint to permit a dependency).\n {\n sourceTag: LibraryScope.CrossDomain,\n onlyDependOnLibsWithTags: [LibraryScope.CrossDomain, LibraryScope.Shared],\n },\n\n // ==========================================\n // 3. TYPE RULES (ARCHITECTURE LAYERS)\n // ==========================================\n\n // Contracts: the foundation. May import nothing.\n {\n sourceTag: LibraryType.Contracts,\n onlyDependOnLibsWithTags: [LibraryType.Contracts],\n },\n\n // Utils: pure functions. Know only contracts and other utils.\n {\n sourceTag: LibraryType.Utils,\n onlyDependOnLibsWithTags: [LibraryType.Contracts, LibraryType.Utils],\n },\n\n // Infrastructure: I/O, API clients. Know types and helpers.\n {\n sourceTag: LibraryType.Infrastructure,\n onlyDependOnLibsWithTags: [\n LibraryType.Contracts,\n LibraryType.Utils,\n LibraryType.Infrastructure,\n ],\n },\n\n // Core: business logic. May use everything below it plus its own domain core.\n {\n sourceTag: LibraryType.Core,\n onlyDependOnLibsWithTags: [\n LibraryType.Contracts,\n LibraryType.Utils,\n LibraryType.Infrastructure,\n LibraryType.Core,\n ],\n },\n\n // ------------------------------------------\n // UI (presentational components)\n // ------------------------------------------\n // Dumb components (buttons, cards, forms). Know only props interfaces\n // (contracts) and formatting helpers (utils). Importing core (entities) or\n // infrastructure is strictly forbidden.\n {\n sourceTag: LibraryType.Ui,\n onlyDependOnLibsWithTags: [\n LibraryType.Contracts,\n LibraryType.Utils,\n LibraryType.Ui,\n ],\n },\n\n // Testing: mocks and fixtures. May import the core for mocking.\n {\n sourceTag: LibraryType.Testing,\n onlyDependOnLibsWithTags: [\n LibraryType.Contracts,\n LibraryType.Utils,\n LibraryType.Infrastructure,\n LibraryType.Core,\n LibraryType.Ui,\n LibraryType.Testing,\n ],\n },\n\n // Features: UI and state. The topmost layer, may import everything.\n {\n sourceTag: LibraryType.Features,\n onlyDependOnLibsWithTags: [\n LibraryType.Contracts,\n LibraryType.Utils,\n LibraryType.Infrastructure,\n LibraryType.Core,\n LibraryType.Ui,\n LibraryType.Testing,\n LibraryType.Features,\n ],\n },\n];\n"],"names":["DEP_CONSTRAINTS","sourceTag","LibraryScope","Shared","onlyDependOnLibsWithTags","Domain","CrossDomain","LibraryType","Contracts","Utils","Infrastructure","Core","Ui","Testing","Features"],"mappings":"AAAA;;;;;;;;;CASC;;;;+BAOYA;;;eAAAA;;;uBAL6B;AAKnC,MAAMA,kBAAmC;IAC9C,6CAA6C;IAC7C,iBAAiB;IACjB,6CAA6C;IAE7C,yCAAyC;IACzC;QACEC,WAAWC,mBAAY,CAACC,MAAM;QAC9BC,0BAA0B;YAACF,mBAAY,CAACC,MAAM;SAAC;IACjD;IACA,0EAA0E;IAC1E;QACEF,WAAWC,mBAAY,CAACG,MAAM;QAC9BD,0BAA0B;YAACF,mBAAY,CAACG,MAAM;YAAEH,mBAAY,CAACC,MAAM;SAAC;IACtE;IAEA,6CAA6C;IAC7C,oCAAoC;IACpC,6CAA6C;IAC7C,0EAA0E;IAC1E,yEAAyE;IACzE,iFAAiF;IACjF,yDAAyD;IACzD,+EAA+E;IAC/E,0EAA0E;IAC1E,2EAA2E;IAC3E,6EAA6E;IAC7E,oEAAoE;IACpE,qEAAqE;IACrE,qEAAqE;IACrE,sCAAsC;IACtC;QACEF,WAAWC,mBAAY,CAACI,WAAW;QACnCF,0BAA0B;YAACF,mBAAY,CAACI,WAAW;YAAEJ,mBAAY,CAACC,MAAM;SAAC;IAC3E;IAEA,6CAA6C;IAC7C,sCAAsC;IACtC,6CAA6C;IAE7C,iDAAiD;IACjD;QACEF,WAAWM,kBAAW,CAACC,SAAS;QAChCJ,0BAA0B;YAACG,kBAAW,CAACC,SAAS;SAAC;IACnD;IAEA,8DAA8D;IAC9D;QACEP,WAAWM,kBAAW,CAACE,KAAK;QAC5BL,0BAA0B;YAACG,kBAAW,CAACC,SAAS;YAAED,kBAAW,CAACE,KAAK;SAAC;IACtE;IAEA,4DAA4D;IAC5D;QACER,WAAWM,kBAAW,CAACG,cAAc;QACrCN,0BAA0B;YACxBG,kBAAW,CAACC,SAAS;YACrBD,kBAAW,CAACE,KAAK;YACjBF,kBAAW,CAACG,cAAc;SAC3B;IACH;IAEA,8EAA8E;IAC9E;QACET,WAAWM,kBAAW,CAACI,IAAI;QAC3BP,0BAA0B;YACxBG,kBAAW,CAACC,SAAS;YACrBD,kBAAW,CAACE,KAAK;YACjBF,kBAAW,CAACG,cAAc;YAC1BH,kBAAW,CAACI,IAAI;SACjB;IACH;IAEA,6CAA6C;IAC7C,iCAAiC;IACjC,6CAA6C;IAC7C,sEAAsE;IACtE,2EAA2E;IAC3E,wCAAwC;IACxC;QACEV,WAAWM,kBAAW,CAACK,EAAE;QACzBR,0BAA0B;YACxBG,kBAAW,CAACC,SAAS;YACrBD,kBAAW,CAACE,KAAK;YACjBF,kBAAW,CAACK,EAAE;SACf;IACH;IAEA,gEAAgE;IAChE;QACEX,WAAWM,kBAAW,CAACM,OAAO;QAC9BT,0BAA0B;YACxBG,kBAAW,CAACC,SAAS;YACrBD,kBAAW,CAACE,KAAK;YACjBF,kBAAW,CAACG,cAAc;YAC1BH,kBAAW,CAACI,IAAI;YAChBJ,kBAAW,CAACK,EAAE;YACdL,kBAAW,CAACM,OAAO;SACpB;IACH;IAEA,oEAAoE;IACpE;QACEZ,WAAWM,kBAAW,CAACO,QAAQ;QAC/BV,0BAA0B;YACxBG,kBAAW,CAACC,SAAS;YACrBD,kBAAW,CAACE,KAAK;YACjBF,kBAAW,CAACG,cAAc;YAC1BH,kBAAW,CAACI,IAAI;YAChBJ,kBAAW,CAACK,EAAE;YACdL,kBAAW,CAACM,OAAO;YACnBN,kBAAW,CAACO,QAAQ;SACrB;IACH;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx/src/generators/init/schema.d.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Bundler } from '@nx/devkit';
|
|
2
|
+
|
|
3
|
+
export interface InitGeneratorSchema {
|
|
4
|
+
sharedDirectory: string;
|
|
5
|
+
prefix: string;
|
|
6
|
+
linter?: 'eslint' | 'none';
|
|
7
|
+
unitTestRunner?: 'jest' | 'vitest' | 'none';
|
|
8
|
+
bundler?: Bundler;
|
|
9
|
+
preset?: 'none' | 'react';
|
|
10
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "InitGenerator",
|
|
4
|
+
"title": "Tactical DDD: Init Generator",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"sharedDirectory": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Root folder for the shared kernel (it is recommended to keep libs/shared)",
|
|
10
|
+
"default": "libs/shared",
|
|
11
|
+
"x-prompt": "Which directory should the Shared Kernel be generated into?"
|
|
12
|
+
},
|
|
13
|
+
"prefix": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "Organization prefix for the generated libraries, e.g. '@my-org'",
|
|
16
|
+
"x-prompt": "Which organization prefix should be used (e.g. @my-org)?"
|
|
17
|
+
},
|
|
18
|
+
"linter": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"enum": ["eslint", "none"],
|
|
21
|
+
"description": "Which linter to use?",
|
|
22
|
+
"x-prompt": "Which linter should be configured?"
|
|
23
|
+
},
|
|
24
|
+
"unitTestRunner": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"enum": ["jest", "vitest", "none"],
|
|
27
|
+
"description": "Which test runner to use?",
|
|
28
|
+
"x-prompt": "Which unit test runner should be used?"
|
|
29
|
+
},
|
|
30
|
+
"bundler": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"enum": ["none", "swc", "tsc", "rollup", "vite", "esbuild"],
|
|
33
|
+
"default": "none",
|
|
34
|
+
"description": "Which bundler to use?"
|
|
35
|
+
},
|
|
36
|
+
"preset": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"enum": ["none", "react"],
|
|
39
|
+
"default": "none",
|
|
40
|
+
"description": "Framework preset. 'react' also installs @tactical-ddd/react, the React runtime and React generator defaults.",
|
|
41
|
+
"x-prompt": {
|
|
42
|
+
"message": "Which framework preset should be configured?",
|
|
43
|
+
"type": "list",
|
|
44
|
+
"items": [
|
|
45
|
+
{ "value": "none", "label": "None (framework-agnostic)" },
|
|
46
|
+
{
|
|
47
|
+
"value": "react",
|
|
48
|
+
"label": "React (@tactical-ddd/react + React tooling)"
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"required": ["prefix", "linter", "unitTestRunner"]
|
|
55
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Tree } from '@nx/devkit';
|
|
1
|
+
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
2
2
|
import type { SharedKernelGeneratorSchema } from './schema';
|
|
3
|
-
export declare function sharedKernelGenerator(tree: Tree, options: SharedKernelGeneratorSchema): Promise<
|
|
3
|
+
export declare function sharedKernelGenerator(tree: Tree, options: SharedKernelGeneratorSchema): Promise<GeneratorCallback>;
|
|
4
4
|
export default sharedKernelGenerator;
|
|
5
5
|
//# sourceMappingURL=shared-kernel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-kernel.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/generators/shared-kernel/shared-kernel.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"shared-kernel.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/generators/shared-kernel/shared-kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,iBAAiB,EACtB,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAIpB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAM5D,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,iBAAiB,CAAC,CAuG5B;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -21,23 +21,34 @@ const _js = require("@nx/js");
|
|
|
21
21
|
const _path = require("path");
|
|
22
22
|
const _types = require("../../types");
|
|
23
23
|
const _resolvemoduleformat = require("../../utils/resolve-module-format");
|
|
24
|
+
const _libraryexist = require("../../utils/library-exist");
|
|
25
|
+
const _logger = require("../../utils/logger");
|
|
24
26
|
async function sharedKernelGenerator(tree, options) {
|
|
25
27
|
const sharedDirectory = options.directory;
|
|
26
28
|
const contractsRoot = `${sharedDirectory}/contracts`;
|
|
27
29
|
const utilsRoot = `${sharedDirectory}/utils`;
|
|
28
30
|
const infrastructureRoot = `${sharedDirectory}/infrastructure`;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
// Install callbacks returned by the delegated `@nx/js:library` generator.
|
|
32
|
+
// They must be returned to Nx so the packages backing the inferred plugins
|
|
33
|
+
// registered via `addPlugin` — `@nx/eslint`, `@nx/jest` — actually get
|
|
34
|
+
// installed; otherwise nx.json references plugins Nx cannot load on the next
|
|
35
|
+
// command. Every library also passes `addPlugin: true`: the `@nx/js` public
|
|
36
|
+
// wrapper defaults it to `false`, which makes the delegated generators emit
|
|
37
|
+
// deprecated executor targets instead of inferred tasks (Project Crystal).
|
|
38
|
+
const tasks = [];
|
|
39
|
+
if (!(0, _libraryexist.libraryExists)(tree, contractsRoot)) {
|
|
40
|
+
(0, _logger.info)(`Creating contracts library at ${contractsRoot}...`);
|
|
41
|
+
tasks.push(await (0, _js.libraryGenerator)(tree, {
|
|
32
42
|
name: options.prefix ? `${options.prefix}/shared-contracts` : 'shared-contracts',
|
|
33
43
|
directory: contractsRoot,
|
|
34
44
|
useProjectJson: false,
|
|
45
|
+
addPlugin: true,
|
|
35
46
|
unitTestRunner: 'none',
|
|
36
47
|
bundler: options.bundler,
|
|
37
48
|
linter: options.linter,
|
|
38
49
|
tags: `${_types.LibraryScope.Shared},${_types.LibraryType.Contracts}`,
|
|
39
50
|
minimal: true
|
|
40
|
-
});
|
|
51
|
+
}));
|
|
41
52
|
const type = (0, _resolvemoduleformat.resolveLibraryModuleFormat)(tree, contractsRoot);
|
|
42
53
|
tree.delete(`${contractsRoot}/src/lib/shared-contracts.ts`);
|
|
43
54
|
(0, _devkit.generateFiles)(tree, (0, _path.resolve)(__dirname, 'files/contracts'), contractsRoot, {
|
|
@@ -46,45 +57,48 @@ async function sharedKernelGenerator(tree, options) {
|
|
|
46
57
|
overwriteStrategy: _devkit.OverwriteStrategy.Overwrite
|
|
47
58
|
});
|
|
48
59
|
} else {
|
|
49
|
-
|
|
60
|
+
(0, _logger.info)(`Contracts library already exists at ${contractsRoot}`);
|
|
50
61
|
}
|
|
51
|
-
if (!
|
|
52
|
-
|
|
53
|
-
await (0, _js.libraryGenerator)(tree, {
|
|
62
|
+
if (!(0, _libraryexist.libraryExists)(tree, utilsRoot)) {
|
|
63
|
+
(0, _logger.info)(`Creating utils library at ${utilsRoot}...`);
|
|
64
|
+
tasks.push(await (0, _js.libraryGenerator)(tree, {
|
|
54
65
|
name: options.prefix ? `${options.prefix}/shared-utils` : 'shared-utils',
|
|
55
66
|
directory: utilsRoot,
|
|
56
67
|
useProjectJson: false,
|
|
68
|
+
addPlugin: true,
|
|
57
69
|
unitTestRunner: options.unitTestRunner,
|
|
58
70
|
bundler: options.bundler,
|
|
59
71
|
linter: options.linter,
|
|
60
72
|
tags: `${_types.LibraryScope.Shared},${_types.LibraryType.Utils}`,
|
|
61
73
|
minimal: true
|
|
62
|
-
});
|
|
74
|
+
}));
|
|
63
75
|
tree.delete(`${utilsRoot}/src/lib/shared-utils.ts`);
|
|
64
76
|
tree.delete(`${utilsRoot}/src/lib/shared-utils.spec.ts`);
|
|
65
77
|
tree.write(`${utilsRoot}/src/index.ts`, '');
|
|
66
78
|
} else {
|
|
67
|
-
|
|
79
|
+
(0, _logger.info)(`Utils library already exists at ${utilsRoot}`);
|
|
68
80
|
}
|
|
69
|
-
if (!
|
|
70
|
-
|
|
71
|
-
await (0, _js.libraryGenerator)(tree, {
|
|
81
|
+
if (!(0, _libraryexist.libraryExists)(tree, infrastructureRoot)) {
|
|
82
|
+
(0, _logger.info)(`Creating infrastructure library at ${infrastructureRoot}...`);
|
|
83
|
+
tasks.push(await (0, _js.libraryGenerator)(tree, {
|
|
72
84
|
name: options.prefix ? `${options.prefix}/shared-infrastructure` : 'shared-infrastructure',
|
|
73
85
|
directory: infrastructureRoot,
|
|
74
86
|
useProjectJson: false,
|
|
87
|
+
addPlugin: true,
|
|
75
88
|
unitTestRunner: options.unitTestRunner,
|
|
76
89
|
bundler: options.bundler,
|
|
77
90
|
linter: options.linter,
|
|
78
91
|
tags: `${_types.LibraryScope.Shared},${_types.LibraryType.Infrastructure}`,
|
|
79
92
|
minimal: true
|
|
80
|
-
});
|
|
93
|
+
}));
|
|
81
94
|
tree.delete(`${infrastructureRoot}/src/lib/shared-infrastructure.ts`);
|
|
82
95
|
tree.delete(`${infrastructureRoot}/src/lib/shared-infrastructure.spec.ts`);
|
|
83
96
|
tree.write(`${infrastructureRoot}/src/index.ts`, '');
|
|
84
97
|
} else {
|
|
85
|
-
|
|
98
|
+
(0, _logger.info)(`Infrastructure library already exists at ${infrastructureRoot}`);
|
|
86
99
|
}
|
|
87
100
|
await (0, _devkit.formatFiles)(tree);
|
|
101
|
+
return (0, _devkit.runTasksInSerial)(...tasks);
|
|
88
102
|
}
|
|
89
103
|
const _default = sharedKernelGenerator;
|
|
90
104
|
|