@webpieces/dev-config 0.2.27 → 0.2.29
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/package.json +2 -2
- package/plugin/index.d.ts +4 -0
- package/plugin/index.js +8 -0
- package/plugin/index.js.map +1 -0
- package/plugin.js +260 -0
- package/src/index.d.ts +10 -9
- package/src/index.js +10 -9
- package/src/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/dev-config",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.29",
|
|
4
4
|
"description": "Development configuration, scripts, and patterns for WebPieces projects",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"bin": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"executors": "./executors.json",
|
|
15
15
|
"generators": "./generators.json",
|
|
16
16
|
"exports": {
|
|
17
|
-
".": "./index.js",
|
|
17
|
+
".": "./src/index.js",
|
|
18
18
|
"./package.json": "./package.json",
|
|
19
19
|
"./eslint": "./config/eslint/base.mjs",
|
|
20
20
|
"./eslint-plugin": "./eslint-plugin/index.js",
|
package/plugin/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
/**
|
|
5
|
+
* Re-export plugin from parent directory for clean imports
|
|
6
|
+
*/
|
|
7
|
+
tslib_1.__exportStar(require("../plugin"), exports);
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/tooling/dev-config/plugin/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,oDAA0B","sourcesContent":["/**\n * Re-export plugin from parent directory for clean imports\n */\nexport * from '../plugin';\n"]}
|
package/plugin.js
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Unified Nx Inference Plugin for @webpieces/dev-config
|
|
4
|
+
*
|
|
5
|
+
* This plugin automatically creates targets for:
|
|
6
|
+
* 1. Workspace-level architecture validation (generate, visualize, validate-*)
|
|
7
|
+
* 2. Per-project circular dependency checking
|
|
8
|
+
*
|
|
9
|
+
* Install with: nx add @webpieces/dev-config
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* Add to nx.json plugins array:
|
|
13
|
+
* {
|
|
14
|
+
* "plugins": ["@webpieces/dev-config"]
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* Then all targets appear automatically without manual project.json configuration.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.createNodesV2 = void 0;
|
|
21
|
+
const path_1 = require("path");
|
|
22
|
+
const fs_1 = require("fs");
|
|
23
|
+
const DEFAULT_OPTIONS = {
|
|
24
|
+
circularDeps: {
|
|
25
|
+
enabled: true,
|
|
26
|
+
targetName: 'check-circular-deps',
|
|
27
|
+
excludePatterns: [],
|
|
28
|
+
},
|
|
29
|
+
workspace: {
|
|
30
|
+
enabled: true,
|
|
31
|
+
targetPrefix: 'arch:',
|
|
32
|
+
graphPath: 'architecture/dependencies.json',
|
|
33
|
+
validations: {
|
|
34
|
+
noCycles: true,
|
|
35
|
+
noSkipLevelDeps: true,
|
|
36
|
+
architectureUnchanged: true,
|
|
37
|
+
},
|
|
38
|
+
features: {
|
|
39
|
+
generate: true,
|
|
40
|
+
visualize: true,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
function normalizeOptions(options) {
|
|
45
|
+
const circularDeps = {
|
|
46
|
+
...DEFAULT_OPTIONS.circularDeps,
|
|
47
|
+
...options?.circularDeps,
|
|
48
|
+
};
|
|
49
|
+
const workspace = {
|
|
50
|
+
...DEFAULT_OPTIONS.workspace,
|
|
51
|
+
...options?.workspace,
|
|
52
|
+
validations: {
|
|
53
|
+
...DEFAULT_OPTIONS.workspace.validations,
|
|
54
|
+
...options?.workspace?.validations,
|
|
55
|
+
},
|
|
56
|
+
features: {
|
|
57
|
+
...DEFAULT_OPTIONS.workspace.features,
|
|
58
|
+
...options?.workspace?.features,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
circularDeps,
|
|
63
|
+
workspace,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Nx V2 Inference Plugin
|
|
68
|
+
* Matches project.json files and creates architecture + circular-deps targets
|
|
69
|
+
*/
|
|
70
|
+
exports.createNodesV2 = [
|
|
71
|
+
// Pattern to match: look for project.json files
|
|
72
|
+
'**/project.json',
|
|
73
|
+
// Inference function
|
|
74
|
+
async (projectFiles, options, context) => {
|
|
75
|
+
const opts = normalizeOptions(options);
|
|
76
|
+
const results = [];
|
|
77
|
+
// Phase 1: Add workspace-level architecture targets to root
|
|
78
|
+
if (opts.workspace.enabled) {
|
|
79
|
+
const rootProject = projectFiles.find((f) => (0, path_1.dirname)(f) === '.');
|
|
80
|
+
if (rootProject) {
|
|
81
|
+
const workspaceTargets = createWorkspaceTargets(opts);
|
|
82
|
+
if (Object.keys(workspaceTargets).length > 0) {
|
|
83
|
+
const result = {
|
|
84
|
+
projects: {
|
|
85
|
+
'.': {
|
|
86
|
+
targets: workspaceTargets,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
results.push([rootProject, result]);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Phase 2: Add per-project circular-deps targets
|
|
95
|
+
if (opts.circularDeps.enabled) {
|
|
96
|
+
for (const projectFile of projectFiles) {
|
|
97
|
+
const projectRoot = (0, path_1.dirname)(projectFile);
|
|
98
|
+
// Skip workspace root (already handled)
|
|
99
|
+
if (projectRoot === '.')
|
|
100
|
+
continue;
|
|
101
|
+
// Check exclude patterns
|
|
102
|
+
if (isExcluded(projectRoot, opts.circularDeps.excludePatterns)) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
// Only create target if project has a src/ directory
|
|
106
|
+
const srcDir = (0, path_1.join)(context.workspaceRoot, projectRoot, 'src');
|
|
107
|
+
if ((0, fs_1.existsSync)(srcDir)) {
|
|
108
|
+
const targetName = opts.circularDeps.targetName;
|
|
109
|
+
const checkCircularDepsTarget = createCircularDepsTarget(projectRoot, targetName);
|
|
110
|
+
const result = {
|
|
111
|
+
projects: {
|
|
112
|
+
[projectRoot]: {
|
|
113
|
+
targets: {
|
|
114
|
+
[targetName]: checkCircularDepsTarget,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
results.push([projectFile, result]);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return results;
|
|
124
|
+
},
|
|
125
|
+
];
|
|
126
|
+
/**
|
|
127
|
+
* Create workspace-level architecture validation targets
|
|
128
|
+
*/
|
|
129
|
+
function createWorkspaceTargets(opts) {
|
|
130
|
+
const targets = {};
|
|
131
|
+
const prefix = opts.workspace.targetPrefix;
|
|
132
|
+
const graphPath = opts.workspace.graphPath;
|
|
133
|
+
// Add help target (always available)
|
|
134
|
+
targets[`${prefix}help`] = createHelpTarget();
|
|
135
|
+
if (opts.workspace.features.generate) {
|
|
136
|
+
targets[`${prefix}generate`] = createGenerateTarget(graphPath);
|
|
137
|
+
}
|
|
138
|
+
if (opts.workspace.features.visualize) {
|
|
139
|
+
targets[`${prefix}visualize`] = createVisualizeTarget(prefix, graphPath);
|
|
140
|
+
}
|
|
141
|
+
if (opts.workspace.validations.noCycles) {
|
|
142
|
+
targets[`${prefix}validate-no-cycles`] = createValidateNoCyclesTarget();
|
|
143
|
+
}
|
|
144
|
+
if (opts.workspace.validations.architectureUnchanged) {
|
|
145
|
+
targets[`${prefix}validate-architecture-unchanged`] = createValidateUnchangedTarget(graphPath);
|
|
146
|
+
}
|
|
147
|
+
if (opts.workspace.validations.noSkipLevelDeps) {
|
|
148
|
+
targets[`${prefix}validate-no-skiplevel-deps`] = createValidateNoSkipLevelTarget();
|
|
149
|
+
}
|
|
150
|
+
return targets;
|
|
151
|
+
}
|
|
152
|
+
function createGenerateTarget(graphPath) {
|
|
153
|
+
return {
|
|
154
|
+
executor: '@webpieces/dev-config:generate',
|
|
155
|
+
cache: true,
|
|
156
|
+
inputs: ['default'],
|
|
157
|
+
outputs: ['{workspaceRoot}/architecture/dependencies.json'],
|
|
158
|
+
options: { graphPath },
|
|
159
|
+
metadata: {
|
|
160
|
+
technologies: ['nx'],
|
|
161
|
+
description: 'Generate the architecture dependency graph from project.json files',
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function createVisualizeTarget(prefix, graphPath) {
|
|
166
|
+
return {
|
|
167
|
+
executor: '@webpieces/dev-config:visualize',
|
|
168
|
+
dependsOn: [`${prefix}generate`],
|
|
169
|
+
options: { graphPath },
|
|
170
|
+
metadata: {
|
|
171
|
+
technologies: ['nx'],
|
|
172
|
+
description: 'Generate visual representations of the architecture graph',
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function createValidateNoCyclesTarget() {
|
|
177
|
+
return {
|
|
178
|
+
executor: '@webpieces/dev-config:validate-no-cycles',
|
|
179
|
+
cache: true,
|
|
180
|
+
inputs: ['default'],
|
|
181
|
+
metadata: {
|
|
182
|
+
technologies: ['nx'],
|
|
183
|
+
description: 'Validate the architecture has no circular dependencies',
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function createValidateUnchangedTarget(graphPath) {
|
|
188
|
+
return {
|
|
189
|
+
executor: '@webpieces/dev-config:validate-architecture-unchanged',
|
|
190
|
+
cache: true,
|
|
191
|
+
inputs: ['default', '{workspaceRoot}/architecture/dependencies.json'],
|
|
192
|
+
options: { graphPath },
|
|
193
|
+
metadata: {
|
|
194
|
+
technologies: ['nx'],
|
|
195
|
+
description: 'Validate the architecture matches the saved blessed graph',
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
function createValidateNoSkipLevelTarget() {
|
|
200
|
+
return {
|
|
201
|
+
executor: '@webpieces/dev-config:validate-no-skiplevel-deps',
|
|
202
|
+
cache: true,
|
|
203
|
+
inputs: ['default'],
|
|
204
|
+
metadata: {
|
|
205
|
+
technologies: ['nx'],
|
|
206
|
+
description: 'Validate no project has redundant transitive dependencies',
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function createHelpTarget() {
|
|
211
|
+
return {
|
|
212
|
+
executor: '@webpieces/dev-config:help',
|
|
213
|
+
cache: true,
|
|
214
|
+
metadata: {
|
|
215
|
+
technologies: ['nx'],
|
|
216
|
+
description: 'Display help for @webpieces/dev-config commands and targets',
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Create per-project circular dependency checking target
|
|
222
|
+
*/
|
|
223
|
+
function createCircularDepsTarget(projectRoot, targetName) {
|
|
224
|
+
return {
|
|
225
|
+
executor: 'nx:run-commands',
|
|
226
|
+
cache: true,
|
|
227
|
+
inputs: ['default'],
|
|
228
|
+
outputs: [],
|
|
229
|
+
options: {
|
|
230
|
+
command: 'npx madge --circular --extensions ts,tsx src',
|
|
231
|
+
cwd: projectRoot,
|
|
232
|
+
},
|
|
233
|
+
metadata: {
|
|
234
|
+
technologies: ['madge'],
|
|
235
|
+
description: 'Check for circular dependencies using madge',
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Check if a project should be excluded based on patterns
|
|
241
|
+
*/
|
|
242
|
+
function isExcluded(projectRoot, excludePatterns) {
|
|
243
|
+
if (excludePatterns.length === 0) {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
// Simple glob matching (could be enhanced with minimatch if needed)
|
|
247
|
+
return excludePatterns.some((pattern) => {
|
|
248
|
+
// Convert glob pattern to regex
|
|
249
|
+
const regexPattern = pattern
|
|
250
|
+
.replace(/\*\*/g, '.*') // ** matches any path
|
|
251
|
+
.replace(/\*/g, '[^/]*'); // * matches any string except /
|
|
252
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
253
|
+
return regex.test(projectRoot);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Export plugin as default for Nx
|
|
258
|
+
*/
|
|
259
|
+
exports.default = { createNodesV2: exports.createNodesV2 };
|
|
260
|
+
//# sourceMappingURL=plugin.js.map
|
package/src/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Development configuration, scripts, and patterns for WebPieces projects.
|
|
5
5
|
*
|
|
6
6
|
* This package provides:
|
|
7
|
+
* - Nx inference plugin for architecture validation and circular dependency checking
|
|
7
8
|
* - Executable scripts (via bin commands: wp-start, wp-stop, etc.)
|
|
8
9
|
* - Shareable ESLint configuration
|
|
9
10
|
* - Jest preset
|
|
@@ -12,15 +13,6 @@
|
|
|
12
13
|
*
|
|
13
14
|
* @packageDocumentation
|
|
14
15
|
*/
|
|
15
|
-
/**
|
|
16
|
-
* This is primarily a configuration and scripts package.
|
|
17
|
-
* The actual exports are defined in package.json:
|
|
18
|
-
*
|
|
19
|
-
* - bin: Executable scripts (wp-start, wp-stop, etc.)
|
|
20
|
-
* - exports: Configuration files (eslint, jest, tsconfig)
|
|
21
|
-
*
|
|
22
|
-
* See README.md for usage instructions.
|
|
23
|
-
*/
|
|
24
16
|
export declare const version = "0.0.0-dev";
|
|
25
17
|
export declare const packageName = "@webpieces/dev-config";
|
|
26
18
|
/**
|
|
@@ -31,3 +23,12 @@ export declare function isWebpiecesWorkspace(): boolean;
|
|
|
31
23
|
* Get project root directory
|
|
32
24
|
*/
|
|
33
25
|
export declare function getProjectRoot(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Default export for Nx plugin system
|
|
28
|
+
* This is what Nx loads when the package is registered as a plugin in nx.json
|
|
29
|
+
*/
|
|
30
|
+
declare const _default: {
|
|
31
|
+
name: string;
|
|
32
|
+
createNodesV2: import("@nx/devkit").CreateNodesV2<import("../plugin").ArchitecturePluginOptions>;
|
|
33
|
+
};
|
|
34
|
+
export default _default;
|
package/src/index.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Development configuration, scripts, and patterns for WebPieces projects.
|
|
6
6
|
*
|
|
7
7
|
* This package provides:
|
|
8
|
+
* - Nx inference plugin for architecture validation and circular dependency checking
|
|
8
9
|
* - Executable scripts (via bin commands: wp-start, wp-stop, etc.)
|
|
9
10
|
* - Shareable ESLint configuration
|
|
10
11
|
* - Jest preset
|
|
@@ -17,15 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
18
|
exports.packageName = exports.version = void 0;
|
|
18
19
|
exports.isWebpiecesWorkspace = isWebpiecesWorkspace;
|
|
19
20
|
exports.getProjectRoot = getProjectRoot;
|
|
20
|
-
|
|
21
|
-
* This is primarily a configuration and scripts package.
|
|
22
|
-
* The actual exports are defined in package.json:
|
|
23
|
-
*
|
|
24
|
-
* - bin: Executable scripts (wp-start, wp-stop, etc.)
|
|
25
|
-
* - exports: Configuration files (eslint, jest, tsconfig)
|
|
26
|
-
*
|
|
27
|
-
* See README.md for usage instructions.
|
|
28
|
-
*/
|
|
21
|
+
const plugin_1 = require("../plugin");
|
|
29
22
|
exports.version = '0.0.0-dev';
|
|
30
23
|
exports.packageName = '@webpieces/dev-config';
|
|
31
24
|
/**
|
|
@@ -41,4 +34,12 @@ function getProjectRoot() {
|
|
|
41
34
|
// This is a simple helper, actual path detection is in bash scripts
|
|
42
35
|
return process.cwd();
|
|
43
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Default export for Nx plugin system
|
|
39
|
+
* This is what Nx loads when the package is registered as a plugin in nx.json
|
|
40
|
+
*/
|
|
41
|
+
exports.default = {
|
|
42
|
+
name: '@webpieces/dev-config',
|
|
43
|
+
createNodesV2: plugin_1.createNodesV2,
|
|
44
|
+
};
|
|
44
45
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/tooling/dev-config/src/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/tooling/dev-config/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAUH,oDAEC;AAKD,wCAGC;AAlBD,sCAA0C;AAE7B,QAAA,OAAO,GAAG,WAAW,CAAC;AACtB,QAAA,WAAW,GAAG,uBAAuB,CAAC;AAEnD;;GAEG;AACH,SAAgB,oBAAoB;IAChC,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;AAClD,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc;IAC1B,oEAAoE;IACpE,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC;AACzB,CAAC;AAED;;;GAGG;AACH,kBAAe;IACX,IAAI,EAAE,uBAAuB;IAC7B,aAAa,EAAb,sBAAa;CAChB,CAAC","sourcesContent":["/**\n * @webpieces/dev-config\n *\n * Development configuration, scripts, and patterns for WebPieces projects.\n *\n * This package provides:\n * - Nx inference plugin for architecture validation and circular dependency checking\n * - Executable scripts (via bin commands: wp-start, wp-stop, etc.)\n * - Shareable ESLint configuration\n * - Jest preset\n * - Base TypeScript configuration\n * - Claude Code pattern documentation\n *\n * @packageDocumentation\n */\n\nimport { createNodesV2 } from '../plugin';\n\nexport const version = '0.0.0-dev';\nexport const packageName = '@webpieces/dev-config';\n\n/**\n * Check if running in webpieces-ts workspace\n */\nexport function isWebpiecesWorkspace(): boolean {\n return process.cwd().includes('webpieces-ts');\n}\n\n/**\n * Get project root directory\n */\nexport function getProjectRoot(): string {\n // This is a simple helper, actual path detection is in bash scripts\n return process.cwd();\n}\n\n/**\n * Default export for Nx plugin system\n * This is what Nx loads when the package is registered as a plugin in nx.json\n */\nexport default {\n name: '@webpieces/dev-config',\n createNodesV2,\n};\n"]}
|