@webpieces/dev-config 0.2.23 → 0.2.25

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/generators.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "$schema": "http://json-schema.org/schema",
3
3
  "generators": {
4
4
  "init": {
5
- "factory": "./generators/init/generator",
6
- "schema": "./generators/init/schema.json",
5
+ "factory": "./src/generators/init/generator",
6
+ "schema": "./src/generators/init/schema.json",
7
7
  "description": "Initialize @webpieces/dev-config in an Nx workspace"
8
8
  }
9
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/dev-config",
3
- "version": "0.2.23",
3
+ "version": "0.2.25",
4
4
  "description": "Development configuration, scripts, and patterns for WebPieces projects",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -34,7 +34,7 @@
34
34
  "plugins/**/*",
35
35
  "plugin/**/*",
36
36
  "plugin.js",
37
- "generators/**/*",
37
+ "src/**/*",
38
38
  "generators.json",
39
39
  "architecture/**/*",
40
40
  "executors.json",
package/plugin/README.md CHANGED
@@ -31,8 +31,15 @@ This automatically:
31
31
  - Adds `madge` as a devDependency (required for circular dependency checking)
32
32
  - Creates the `architecture/` directory
33
33
  - Adds convenient npm scripts to `package.json`
34
+ - Creates `eslint.webpieces.config.mjs` with @webpieces ESLint rules
35
+ - Creates `eslint.config.mjs` (if you don't have one) that imports the webpieces rules
36
+ - If you already have `eslint.config.mjs`, shows you how to import the webpieces rules (one line)
34
37
  - Makes all targets immediately available
35
38
 
39
+ **For new projects: Zero configuration needed!** All architecture validation, circular dependency checking, and ESLint rules are active.
40
+
41
+ **For existing projects with ESLint:** Just add one import line shown during installation to enable the @webpieces ESLint rules.
42
+
36
43
  ## Usage
37
44
 
38
45
  ### Convenient npm Scripts
@@ -0,0 +1,20 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export interface InitGeneratorSchema {
3
+ skipFormat?: boolean;
4
+ }
5
+ /**
6
+ * Init generator for @webpieces/dev-config
7
+ *
8
+ * Automatically runs when users execute: nx add @webpieces/dev-config
9
+ *
10
+ * Responsibilities:
11
+ * - Registers the plugin in nx.json
12
+ * - Creates architecture/ directory if needed
13
+ * - Adds madge as a devDependency (required for circular dep checking)
14
+ * - Adds convenient npm scripts to package.json
15
+ * - Always creates eslint.webpieces.config.mjs with @webpieces rules
16
+ * - Creates eslint.config.mjs (if not exists) that imports eslint.webpieces.config.mjs
17
+ * - If eslint.config.mjs exists, shows user how to import eslint.webpieces.config.mjs
18
+ * - Provides helpful output about available targets
19
+ */
20
+ export default function initGenerator(tree: Tree, options: InitGeneratorSchema): Promise<() => Promise<void>>;
@@ -0,0 +1,220 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = initGenerator;
4
+ const devkit_1 = require("@nx/devkit");
5
+ /**
6
+ * Init generator for @webpieces/dev-config
7
+ *
8
+ * Automatically runs when users execute: nx add @webpieces/dev-config
9
+ *
10
+ * Responsibilities:
11
+ * - Registers the plugin in nx.json
12
+ * - Creates architecture/ directory if needed
13
+ * - Adds madge as a devDependency (required for circular dep checking)
14
+ * - Adds convenient npm scripts to package.json
15
+ * - Always creates eslint.webpieces.config.mjs with @webpieces rules
16
+ * - Creates eslint.config.mjs (if not exists) that imports eslint.webpieces.config.mjs
17
+ * - If eslint.config.mjs exists, shows user how to import eslint.webpieces.config.mjs
18
+ * - Provides helpful output about available targets
19
+ */
20
+ async function initGenerator(tree, options) {
21
+ registerPlugin(tree);
22
+ const installTask = addMadgeDependency(tree);
23
+ createArchitectureDirectory(tree);
24
+ addNpmScripts(tree);
25
+ createEslintConfig(tree);
26
+ if (!options.skipFormat) {
27
+ await (0, devkit_1.formatFiles)(tree);
28
+ }
29
+ return createSuccessCallback(installTask);
30
+ }
31
+ function registerPlugin(tree) {
32
+ const nxJson = (0, devkit_1.readNxJson)(tree);
33
+ if (!nxJson) {
34
+ throw new Error('Could not read nx.json. Are you in an Nx workspace?');
35
+ }
36
+ if (!nxJson.plugins) {
37
+ nxJson.plugins = [];
38
+ }
39
+ const pluginName = '@webpieces/dev-config';
40
+ const alreadyRegistered = nxJson.plugins.some((p) => typeof p === 'string' ? p === pluginName : p.plugin === pluginName);
41
+ if (!alreadyRegistered) {
42
+ nxJson.plugins.push(pluginName);
43
+ (0, devkit_1.updateNxJson)(tree, nxJson);
44
+ console.log(`✅ Registered ${pluginName} plugin in nx.json`);
45
+ }
46
+ else {
47
+ console.log(`ℹ️ ${pluginName} plugin is already registered`);
48
+ }
49
+ }
50
+ function addMadgeDependency(tree) {
51
+ return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { 'madge': '^8.0.0' });
52
+ }
53
+ function createArchitectureDirectory(tree) {
54
+ if (!tree.exists('architecture')) {
55
+ tree.write('architecture/.gitkeep', '');
56
+ console.log('✅ Created architecture/ directory');
57
+ }
58
+ }
59
+ function addNpmScripts(tree) {
60
+ (0, devkit_1.updateJson)(tree, 'package.json', (pkgJson) => {
61
+ pkgJson.scripts = pkgJson.scripts ?? {};
62
+ // Add architecture validation scripts
63
+ pkgJson.scripts['arch:generate'] = 'nx run .:arch:generate';
64
+ pkgJson.scripts['arch:visualize'] = 'nx run .:arch:visualize';
65
+ pkgJson.scripts['arch:validate'] = 'nx run .:arch:validate-no-cycles && nx run .:arch:validate-no-skiplevel-deps';
66
+ pkgJson.scripts['arch:validate-all'] = 'nx run .:arch:validate-no-cycles && nx run .:arch:validate-no-skiplevel-deps && nx run .:arch:validate-architecture-unchanged';
67
+ // Add circular dependency checking scripts
68
+ pkgJson.scripts['arch:check-circular'] = 'nx run-many --target=check-circular-deps --all';
69
+ pkgJson.scripts['arch:check-circular-affected'] = 'nx affected --target=check-circular-deps';
70
+ // Complete validation including circular deps
71
+ pkgJson.scripts['arch:validate-complete'] = 'npm run arch:validate-all && npm run arch:check-circular';
72
+ return pkgJson;
73
+ });
74
+ console.log('✅ Added npm scripts for architecture validation and circular dependency checking');
75
+ }
76
+ function createEslintConfig(tree) {
77
+ const webpiecesConfigPath = 'eslint.webpieces.config.mjs';
78
+ const mainConfigPath = 'eslint.config.mjs';
79
+ // Always create eslint.webpieces.config.mjs with our rules
80
+ createWebpiecesEslintConfig(tree, webpiecesConfigPath);
81
+ // Check if main eslint.config.mjs exists
82
+ if (tree.exists(mainConfigPath)) {
83
+ // Existing config - show them how to import
84
+ console.log('');
85
+ console.log('📋 Existing eslint.config.mjs detected');
86
+ console.log('');
87
+ console.log('To use @webpieces/dev-config ESLint rules, add this import to your eslint.config.mjs:');
88
+ console.log('');
89
+ console.log(' import webpiecesConfig from \'./eslint.webpieces.config.mjs\';');
90
+ console.log('');
91
+ console.log('Then spread it into your config array:');
92
+ console.log('');
93
+ console.log(' export default [');
94
+ console.log(' ...webpiecesConfig, // Add this line');
95
+ console.log(' // ... your existing config');
96
+ console.log(' ];');
97
+ console.log('');
98
+ }
99
+ else {
100
+ // No existing config - create one that imports webpieces config
101
+ const mainConfig = `// ESLint configuration
102
+ // Imports @webpieces/dev-config rules
103
+
104
+ import webpiecesConfig from './eslint.webpieces.config.mjs';
105
+
106
+ // Export the webpieces configuration
107
+ // You can add your own rules after spreading webpiecesConfig
108
+ export default [
109
+ ...webpiecesConfig,
110
+ // Add your custom ESLint configuration here
111
+ ];
112
+ `;
113
+ tree.write(mainConfigPath, mainConfig);
114
+ console.log('✅ Created eslint.config.mjs with @webpieces/dev-config rules');
115
+ }
116
+ }
117
+ function createWebpiecesEslintConfig(tree, configPath) {
118
+ const webpiecesConfig = `// @webpieces/dev-config ESLint rules
119
+ // This file contains the ESLint configuration provided by @webpieces/dev-config
120
+ // You can modify or remove rules as needed for your project
121
+
122
+ import webpiecesPlugin from '@webpieces/dev-config/eslint-plugin';
123
+ import tseslint from '@typescript-eslint/eslint-plugin';
124
+ import tsparser from '@typescript-eslint/parser';
125
+
126
+ export default [
127
+ {
128
+ ignores: ['**/dist', '**/node_modules', '**/coverage', '**/.nx'],
129
+ },
130
+ {
131
+ files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
132
+ plugins: {
133
+ '@webpieces': webpiecesPlugin,
134
+ '@typescript-eslint': tseslint,
135
+ },
136
+ languageOptions: {
137
+ parser: tsparser,
138
+ ecmaVersion: 2021,
139
+ sourceType: 'module',
140
+ },
141
+ rules: {
142
+ // WebPieces custom rules
143
+ '@webpieces/catch-error-pattern': 'error',
144
+ '@webpieces/no-unmanaged-exceptions': 'error',
145
+ '@webpieces/max-method-lines': ['error', { max: 70 }],
146
+ '@webpieces/max-file-lines': ['error', { max: 700 }],
147
+ '@webpieces/enforce-architecture': 'error',
148
+
149
+ // TypeScript rules
150
+ '@typescript-eslint/no-explicit-any': 'off',
151
+ '@typescript-eslint/explicit-function-return-type': 'off',
152
+ '@typescript-eslint/no-unused-vars': 'off',
153
+ '@typescript-eslint/no-empty-interface': 'off',
154
+ '@typescript-eslint/no-empty-function': 'off',
155
+
156
+ // General code quality
157
+ 'no-console': 'off',
158
+ 'no-debugger': 'off',
159
+ 'no-var': 'error',
160
+ 'prefer-const': 'off',
161
+ },
162
+ },
163
+ {
164
+ // Test files - relaxed rules
165
+ files: ['**/*.spec.ts', '**/*.test.ts'],
166
+ rules: {
167
+ '@typescript-eslint/no-explicit-any': 'off',
168
+ '@typescript-eslint/no-non-null-assertion': 'off',
169
+ '@webpieces/max-method-lines': 'off',
170
+ },
171
+ },
172
+ ];
173
+ `;
174
+ tree.write(configPath, webpiecesConfig);
175
+ console.log('✅ Created eslint.webpieces.config.mjs with @webpieces/dev-config rules');
176
+ }
177
+ function createSuccessCallback(installTask) {
178
+ return async () => {
179
+ await installTask();
180
+ console.log('✅ Added madge to devDependencies');
181
+ console.log('');
182
+ console.log('✅ @webpieces/dev-config plugin initialized!');
183
+ console.log('');
184
+ printAvailableTargets();
185
+ };
186
+ }
187
+ function printAvailableTargets() {
188
+ console.log('📝 Available npm scripts (convenient shortcuts):');
189
+ console.log('');
190
+ console.log(' Architecture graph:');
191
+ console.log(' npm run arch:generate # Generate dependency graph');
192
+ console.log(' npm run arch:visualize # Visualize dependency graph');
193
+ console.log('');
194
+ console.log(' Validation:');
195
+ console.log(' npm run arch:validate # Quick validation (no-cycles + no-skiplevel-deps)');
196
+ console.log(' npm run arch:validate-all # Full arch validation (+ unchanged check)');
197
+ console.log(' npm run arch:check-circular # Check all projects for circular deps');
198
+ console.log(' npm run arch:check-circular-affected # Check affected projects only');
199
+ console.log(' npm run arch:validate-complete # Complete validation (arch + circular)');
200
+ console.log('');
201
+ console.log('📝 Available Nx targets:');
202
+ console.log('');
203
+ console.log(' Workspace-level architecture validation:');
204
+ console.log(' nx run .:arch:generate # Generate dependency graph');
205
+ console.log(' nx run .:arch:visualize # Visualize dependency graph');
206
+ console.log(' nx run .:arch:validate-no-cycles # Check for circular dependencies');
207
+ console.log(' nx run .:arch:validate-no-skiplevel-deps # Check for redundant dependencies');
208
+ console.log(' nx run .:arch:validate-architecture-unchanged # Validate against blessed graph');
209
+ console.log('');
210
+ console.log(' Per-project circular dependency checking:');
211
+ console.log(' nx run <project>:check-circular-deps # Check project for circular deps');
212
+ console.log(' nx affected --target=check-circular-deps # Check all affected projects');
213
+ console.log(' nx run-many --target=check-circular-deps --all # Check all projects');
214
+ console.log('');
215
+ console.log('💡 Quick start:');
216
+ console.log(' npm run arch:generate # Generate the graph first');
217
+ console.log(' npm run arch:validate-complete # Run complete validation');
218
+ console.log('');
219
+ }
220
+ //# sourceMappingURL=generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/dev-config/src/generators/init/generator.ts"],"names":[],"mappings":";;AAqBA,gCAYC;AAjCD,uCAAmH;AAMnH;;;;;;;;;;;;;;GAcG;AACY,KAAK,UAAU,aAAa,CAAC,IAAU,EAAE,OAA4B;IAChF,cAAc,CAAC,IAAI,CAAC,CAAC;IACrB,MAAM,WAAW,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC7C,2B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C,CAAC;IAC1D,OAAO,CAAC,GAAG,CAAC,gFAAgF,CAAC,CAAC;IAC9F,OAAO,CAAC,GAAG,CAAC,iFAAiF,CAAC,CAAC;IAC/F,OAAO,CAAC,GAAG,CAAC,sFAAsF,CAAC,CAAC;IACpG,OAAO,CAAC,GAAG,CAAC,uFAAuF,CAAC,CAAC;IACrG,OAAO,CAAC,GAAG,CAAC,qFAAqF,CAAC,CAAC;IACnG,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;IAC3D,OAAO,CAAC,GAAG,CAAC,sFAAsF,CAAC,CAAC;IACpG,OAAO,CAAC,GAAG,CAAC,kFAAkF,CAAC,CAAC;IAChG,OAAO,CAAC,GAAG,CAAC,yEAAyE,CAAC,CAAC;IACvF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC/B,OAAO,CAAC,GAAG,CAAC,+DAA+D,CAAC,CAAC;IAC7E,OAAO,CAAC,GAAG,CAAC,8DAA8D,CAAC,CAAC;IAC5E,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACpB,CAAC","sourcesContent":["import { formatFiles, readNxJson, Tree, updateNxJson, updateJson, addDependenciesToPackageJson } from '@nx/devkit';\n\nexport interface InitGeneratorSchema {\n skipFormat?: boolean;\n}\n\n/**\n * Init generator for @webpieces/dev-config\n *\n * Automatically runs when users execute: nx add @webpieces/dev-config\n *\n * Responsibilities:\n * - Registers the plugin in nx.json\n * - Creates architecture/ directory if needed\n * - Adds madge as a devDependency (required for circular dep checking)\n * - Adds convenient npm scripts to package.json\n * - Always creates eslint.webpieces.config.mjs with @webpieces rules\n * - Creates eslint.config.mjs (if not exists) that imports eslint.webpieces.config.mjs\n * - If eslint.config.mjs exists, shows user how to import eslint.webpieces.config.mjs\n * - Provides helpful output about available targets\n */\nexport default async function initGenerator(tree: Tree, options: InitGeneratorSchema) {\n registerPlugin(tree);\n const installTask = addMadgeDependency(tree);\n createArchitectureDirectory(tree);\n addNpmScripts(tree);\n createEslintConfig(tree);\n\n if (!options.skipFormat) {\n await formatFiles(tree);\n }\n\n return createSuccessCallback(installTask);\n}\n\nfunction registerPlugin(tree: Tree): void {\n const nxJson = readNxJson(tree);\n if (!nxJson) {\n throw new Error('Could not read nx.json. Are you in an Nx workspace?');\n }\n\n if (!nxJson.plugins) {\n nxJson.plugins = [];\n }\n\n const pluginName = '@webpieces/dev-config';\n const alreadyRegistered = nxJson.plugins.some(\n (p) => typeof p === 'string' ? p === pluginName : p.plugin === pluginName\n );\n\n if (!alreadyRegistered) {\n nxJson.plugins.push(pluginName);\n updateNxJson(tree, nxJson);\n console.log(`✅ Registered ${pluginName} plugin in nx.json`);\n } else {\n console.log(`ℹ️ ${pluginName} plugin is already registered`);\n }\n}\n\nfunction addMadgeDependency(tree: Tree) {\n return addDependenciesToPackageJson(tree, {}, { 'madge': '^8.0.0' });\n}\n\nfunction createArchitectureDirectory(tree: Tree): void {\n if (!tree.exists('architecture')) {\n tree.write('architecture/.gitkeep', '');\n console.log('✅ Created architecture/ directory');\n }\n}\n\nfunction addNpmScripts(tree: Tree): void {\n updateJson(tree, 'package.json', (pkgJson) => {\n pkgJson.scripts = pkgJson.scripts ?? {};\n\n // Add architecture validation scripts\n pkgJson.scripts['arch:generate'] = 'nx run .:arch:generate';\n pkgJson.scripts['arch:visualize'] = 'nx run .:arch:visualize';\n pkgJson.scripts['arch:validate'] = 'nx run .:arch:validate-no-cycles && nx run .:arch:validate-no-skiplevel-deps';\n pkgJson.scripts['arch:validate-all'] = 'nx run .:arch:validate-no-cycles && nx run .:arch:validate-no-skiplevel-deps && nx run .:arch:validate-architecture-unchanged';\n\n // Add circular dependency checking scripts\n pkgJson.scripts['arch:check-circular'] = 'nx run-many --target=check-circular-deps --all';\n pkgJson.scripts['arch:check-circular-affected'] = 'nx affected --target=check-circular-deps';\n\n // Complete validation including circular deps\n pkgJson.scripts['arch:validate-complete'] = 'npm run arch:validate-all && npm run arch:check-circular';\n\n return pkgJson;\n });\n\n console.log('✅ Added npm scripts for architecture validation and circular dependency checking');\n}\n\nfunction createEslintConfig(tree: Tree): void {\n const webpiecesConfigPath = 'eslint.webpieces.config.mjs';\n const mainConfigPath = 'eslint.config.mjs';\n\n // Always create eslint.webpieces.config.mjs with our rules\n createWebpiecesEslintConfig(tree, webpiecesConfigPath);\n\n // Check if main eslint.config.mjs exists\n if (tree.exists(mainConfigPath)) {\n // Existing config - show them how to import\n console.log('');\n console.log('📋 Existing eslint.config.mjs detected');\n console.log('');\n console.log('To use @webpieces/dev-config ESLint rules, add this import to your eslint.config.mjs:');\n console.log('');\n console.log(' import webpiecesConfig from \\'./eslint.webpieces.config.mjs\\';');\n console.log('');\n console.log('Then spread it into your config array:');\n console.log('');\n console.log(' export default [');\n console.log(' ...webpiecesConfig, // Add this line');\n console.log(' // ... your existing config');\n console.log(' ];');\n console.log('');\n } else {\n // No existing config - create one that imports webpieces config\n const mainConfig = `// ESLint configuration\n// Imports @webpieces/dev-config rules\n\nimport webpiecesConfig from './eslint.webpieces.config.mjs';\n\n// Export the webpieces configuration\n// You can add your own rules after spreading webpiecesConfig\nexport default [\n ...webpiecesConfig,\n // Add your custom ESLint configuration here\n];\n`;\n\n tree.write(mainConfigPath, mainConfig);\n console.log('✅ Created eslint.config.mjs with @webpieces/dev-config rules');\n }\n}\n\nfunction createWebpiecesEslintConfig(tree: Tree, configPath: string): void {\n const webpiecesConfig = `// @webpieces/dev-config ESLint rules\n// This file contains the ESLint configuration provided by @webpieces/dev-config\n// You can modify or remove rules as needed for your project\n\nimport webpiecesPlugin from '@webpieces/dev-config/eslint-plugin';\nimport tseslint from '@typescript-eslint/eslint-plugin';\nimport tsparser from '@typescript-eslint/parser';\n\nexport default [\n {\n ignores: ['**/dist', '**/node_modules', '**/coverage', '**/.nx'],\n },\n {\n files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],\n plugins: {\n '@webpieces': webpiecesPlugin,\n '@typescript-eslint': tseslint,\n },\n languageOptions: {\n parser: tsparser,\n ecmaVersion: 2021,\n sourceType: 'module',\n },\n rules: {\n // WebPieces custom rules\n '@webpieces/catch-error-pattern': 'error',\n '@webpieces/no-unmanaged-exceptions': 'error',\n '@webpieces/max-method-lines': ['error', { max: 70 }],\n '@webpieces/max-file-lines': ['error', { max: 700 }],\n '@webpieces/enforce-architecture': 'error',\n\n // TypeScript rules\n '@typescript-eslint/no-explicit-any': 'off',\n '@typescript-eslint/explicit-function-return-type': 'off',\n '@typescript-eslint/no-unused-vars': 'off',\n '@typescript-eslint/no-empty-interface': 'off',\n '@typescript-eslint/no-empty-function': 'off',\n\n // General code quality\n 'no-console': 'off',\n 'no-debugger': 'off',\n 'no-var': 'error',\n 'prefer-const': 'off',\n },\n },\n {\n // Test files - relaxed rules\n files: ['**/*.spec.ts', '**/*.test.ts'],\n rules: {\n '@typescript-eslint/no-explicit-any': 'off',\n '@typescript-eslint/no-non-null-assertion': 'off',\n '@webpieces/max-method-lines': 'off',\n },\n },\n];\n`;\n\n tree.write(configPath, webpiecesConfig);\n console.log('✅ Created eslint.webpieces.config.mjs with @webpieces/dev-config rules');\n}\n\nfunction createSuccessCallback(installTask: ReturnType<typeof addDependenciesToPackageJson>) {\n return async () => {\n await installTask();\n console.log('✅ Added madge to devDependencies');\n console.log('');\n console.log('✅ @webpieces/dev-config plugin initialized!');\n console.log('');\n printAvailableTargets();\n };\n}\n\nfunction printAvailableTargets(): void {\n console.log('📝 Available npm scripts (convenient shortcuts):');\n console.log('');\n console.log(' Architecture graph:');\n console.log(' npm run arch:generate # Generate dependency graph');\n console.log(' npm run arch:visualize # Visualize dependency graph');\n console.log('');\n console.log(' Validation:');\n console.log(' npm run arch:validate # Quick validation (no-cycles + no-skiplevel-deps)');\n console.log(' npm run arch:validate-all # Full arch validation (+ unchanged check)');\n console.log(' npm run arch:check-circular # Check all projects for circular deps');\n console.log(' npm run arch:check-circular-affected # Check affected projects only');\n console.log(' npm run arch:validate-complete # Complete validation (arch + circular)');\n console.log('');\n console.log('📝 Available Nx targets:');\n console.log('');\n console.log(' Workspace-level architecture validation:');\n console.log(' nx run .:arch:generate # Generate dependency graph');\n console.log(' nx run .:arch:visualize # Visualize dependency graph');\n console.log(' nx run .:arch:validate-no-cycles # Check for circular dependencies');\n console.log(' nx run .:arch:validate-no-skiplevel-deps # Check for redundant dependencies');\n console.log(' nx run .:arch:validate-architecture-unchanged # Validate against blessed graph');\n console.log('');\n console.log(' Per-project circular dependency checking:');\n console.log(' nx run <project>:check-circular-deps # Check project for circular deps');\n console.log(' nx affected --target=check-circular-deps # Check all affected projects');\n console.log(' nx run-many --target=check-circular-deps --all # Check all projects');\n console.log('');\n console.log('💡 Quick start:');\n console.log(' npm run arch:generate # Generate the graph first');\n console.log(' npm run arch:validate-complete # Run complete validation');\n console.log('');\n}\n"]}
package/src/index.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @webpieces/dev-config
3
+ *
4
+ * Development configuration, scripts, and patterns for WebPieces projects.
5
+ *
6
+ * This package provides:
7
+ * - Executable scripts (via bin commands: wp-start, wp-stop, etc.)
8
+ * - Shareable ESLint configuration
9
+ * - Jest preset
10
+ * - Base TypeScript configuration
11
+ * - Claude Code pattern documentation
12
+ *
13
+ * @packageDocumentation
14
+ */
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
+ export declare const version = "0.0.0-dev";
25
+ export declare const packageName = "@webpieces/dev-config";
26
+ /**
27
+ * Check if running in webpieces-ts workspace
28
+ */
29
+ export declare function isWebpiecesWorkspace(): boolean;
30
+ /**
31
+ * Get project root directory
32
+ */
33
+ export declare function getProjectRoot(): string;
package/src/index.js ADDED
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /**
3
+ * @webpieces/dev-config
4
+ *
5
+ * Development configuration, scripts, and patterns for WebPieces projects.
6
+ *
7
+ * This package provides:
8
+ * - Executable scripts (via bin commands: wp-start, wp-stop, etc.)
9
+ * - Shareable ESLint configuration
10
+ * - Jest preset
11
+ * - Base TypeScript configuration
12
+ * - Claude Code pattern documentation
13
+ *
14
+ * @packageDocumentation
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.packageName = exports.version = void 0;
18
+ exports.isWebpiecesWorkspace = isWebpiecesWorkspace;
19
+ 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
+ */
29
+ exports.version = '0.0.0-dev';
30
+ exports.packageName = '@webpieces/dev-config';
31
+ /**
32
+ * Check if running in webpieces-ts workspace
33
+ */
34
+ function isWebpiecesWorkspace() {
35
+ return process.cwd().includes('webpieces-ts');
36
+ }
37
+ /**
38
+ * Get project root directory
39
+ */
40
+ function getProjectRoot() {
41
+ // This is a simple helper, actual path detection is in bash scripts
42
+ return process.cwd();
43
+ }
44
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/tooling/dev-config/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAkBH,oDAEC;AAKD,wCAGC;AA1BD;;;;;;;;GAQG;AAEU,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","sourcesContent":["/**\n * @webpieces/dev-config\n *\n * Development configuration, scripts, and patterns for WebPieces projects.\n *\n * This package provides:\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\n/**\n * This is primarily a configuration and scripts package.\n * The actual exports are defined in package.json:\n *\n * - bin: Executable scripts (wp-start, wp-stop, etc.)\n * - exports: Configuration files (eslint, jest, tsconfig)\n *\n * See README.md for usage instructions.\n */\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"]}
@@ -1,130 +0,0 @@
1
- import { formatFiles, readNxJson, Tree, updateNxJson, updateJson, addDependenciesToPackageJson } from '@nx/devkit';
2
- import type { InitGeneratorSchema } from './schema';
3
-
4
- /**
5
- * Init generator for @webpieces/dev-config
6
- *
7
- * Automatically runs when users execute: nx add @webpieces/dev-config
8
- *
9
- * Responsibilities:
10
- * - Registers the plugin in nx.json
11
- * - Creates architecture/ directory if needed
12
- * - Adds madge as a devDependency (required for circular dep checking)
13
- * - Adds convenient npm scripts to package.json
14
- * - Provides helpful output about available targets
15
- */
16
- export default async function initGenerator(tree: Tree, options: InitGeneratorSchema) {
17
- registerPlugin(tree);
18
- const installTask = addMadgeDependency(tree);
19
- createArchitectureDirectory(tree);
20
- addNpmScripts(tree);
21
-
22
- if (!options.skipFormat) {
23
- await formatFiles(tree);
24
- }
25
-
26
- return createSuccessCallback(installTask);
27
- }
28
-
29
- function registerPlugin(tree: Tree): void {
30
- const nxJson = readNxJson(tree);
31
- if (!nxJson) {
32
- throw new Error('Could not read nx.json. Are you in an Nx workspace?');
33
- }
34
-
35
- if (!nxJson.plugins) {
36
- nxJson.plugins = [];
37
- }
38
-
39
- const pluginName = '@webpieces/dev-config';
40
- const alreadyRegistered = nxJson.plugins.some(
41
- (p) => typeof p === 'string' ? p === pluginName : p.plugin === pluginName
42
- );
43
-
44
- if (!alreadyRegistered) {
45
- nxJson.plugins.push(pluginName);
46
- updateNxJson(tree, nxJson);
47
- console.log(`✅ Registered ${pluginName} plugin in nx.json`);
48
- } else {
49
- console.log(`ℹ️ ${pluginName} plugin is already registered`);
50
- }
51
- }
52
-
53
- function addMadgeDependency(tree: Tree) {
54
- return addDependenciesToPackageJson(tree, {}, { 'madge': '^8.0.0' });
55
- }
56
-
57
- function createArchitectureDirectory(tree: Tree): void {
58
- if (!tree.exists('architecture')) {
59
- tree.write('architecture/.gitkeep', '');
60
- console.log('✅ Created architecture/ directory');
61
- }
62
- }
63
-
64
- function addNpmScripts(tree: Tree): void {
65
- updateJson(tree, 'package.json', (pkgJson) => {
66
- pkgJson.scripts = pkgJson.scripts ?? {};
67
-
68
- // Add architecture validation scripts
69
- pkgJson.scripts['arch:generate'] = 'nx run .:arch:generate';
70
- pkgJson.scripts['arch:visualize'] = 'nx run .:arch:visualize';
71
- pkgJson.scripts['arch:validate'] = 'nx run .:arch:validate-no-cycles && nx run .:arch:validate-no-skiplevel-deps';
72
- pkgJson.scripts['arch:validate-all'] = 'nx run .:arch:validate-no-cycles && nx run .:arch:validate-no-skiplevel-deps && nx run .:arch:validate-architecture-unchanged';
73
-
74
- // Add circular dependency checking scripts
75
- pkgJson.scripts['arch:check-circular'] = 'nx run-many --target=check-circular-deps --all';
76
- pkgJson.scripts['arch:check-circular-affected'] = 'nx affected --target=check-circular-deps';
77
-
78
- // Complete validation including circular deps
79
- pkgJson.scripts['arch:validate-complete'] = 'npm run arch:validate-all && npm run arch:check-circular';
80
-
81
- return pkgJson;
82
- });
83
-
84
- console.log('✅ Added npm scripts for architecture validation and circular dependency checking');
85
- }
86
-
87
- function createSuccessCallback(installTask: ReturnType<typeof addDependenciesToPackageJson>) {
88
- return async () => {
89
- await installTask();
90
- console.log('✅ Added madge to devDependencies');
91
- console.log('');
92
- console.log('✅ @webpieces/dev-config plugin initialized!');
93
- console.log('');
94
- printAvailableTargets();
95
- };
96
- }
97
-
98
- function printAvailableTargets(): void {
99
- console.log('📝 Available npm scripts (convenient shortcuts):');
100
- console.log('');
101
- console.log(' Architecture graph:');
102
- console.log(' npm run arch:generate # Generate dependency graph');
103
- console.log(' npm run arch:visualize # Visualize dependency graph');
104
- console.log('');
105
- console.log(' Validation:');
106
- console.log(' npm run arch:validate # Quick validation (no-cycles + no-skiplevel-deps)');
107
- console.log(' npm run arch:validate-all # Full arch validation (+ unchanged check)');
108
- console.log(' npm run arch:check-circular # Check all projects for circular deps');
109
- console.log(' npm run arch:check-circular-affected # Check affected projects only');
110
- console.log(' npm run arch:validate-complete # Complete validation (arch + circular)');
111
- console.log('');
112
- console.log('📝 Available Nx targets:');
113
- console.log('');
114
- console.log(' Workspace-level architecture validation:');
115
- console.log(' nx run .:arch:generate # Generate dependency graph');
116
- console.log(' nx run .:arch:visualize # Visualize dependency graph');
117
- console.log(' nx run .:arch:validate-no-cycles # Check for circular dependencies');
118
- console.log(' nx run .:arch:validate-no-skiplevel-deps # Check for redundant dependencies');
119
- console.log(' nx run .:arch:validate-architecture-unchanged # Validate against blessed graph');
120
- console.log('');
121
- console.log(' Per-project circular dependency checking:');
122
- console.log(' nx run <project>:check-circular-deps # Check project for circular deps');
123
- console.log(' nx affected --target=check-circular-deps # Check all affected projects');
124
- console.log(' nx run-many --target=check-circular-deps --all # Check all projects');
125
- console.log('');
126
- console.log('💡 Quick start:');
127
- console.log(' npm run arch:generate # Generate the graph first');
128
- console.log(' npm run arch:validate-complete # Run complete validation');
129
- console.log('');
130
- }
File without changes