@webpieces/dev-config 0.2.26 → 0.2.27

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.
@@ -0,0 +1,6 @@
1
+ import type { ExecutorContext } from '@nx/devkit';
2
+ export interface HelpExecutorOptions {
3
+ }
4
+ export default function helpExecutor(options: HelpExecutorOptions, context: ExecutorContext): Promise<{
5
+ success: true;
6
+ }>;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = helpExecutor;
4
+ async function helpExecutor(options, context) {
5
+ // ANSI color codes
6
+ const GREEN = '\x1b[32m\x1b[1m';
7
+ const BOLD = '\x1b[1m';
8
+ const RESET = '\x1b[0m';
9
+ console.log('');
10
+ console.log(`${GREEN}💡 @webpieces/dev-config - Available Commands${RESET}`);
11
+ console.log('');
12
+ console.log(`${BOLD}📝 Available npm scripts (convenient shortcuts):${RESET}`);
13
+ console.log('');
14
+ console.log(' Architecture graph:');
15
+ console.log(' npm run arch:generate # Generate dependency graph');
16
+ console.log(' npm run arch:visualize # Visualize dependency graph');
17
+ console.log('');
18
+ console.log(' Validation:');
19
+ console.log(' npm run arch:validate # Quick validation (no-cycles + no-skiplevel-deps)');
20
+ console.log(' npm run arch:validate-all # Full arch validation (+ unchanged check)');
21
+ console.log(' npm run arch:check-circular # Check all projects for circular deps');
22
+ console.log(' npm run arch:check-circular-affected # Check affected projects only');
23
+ console.log(' npm run arch:validate-complete # Complete validation (arch + circular)');
24
+ console.log('');
25
+ console.log(`${BOLD}📝 Available Nx targets:${RESET}`);
26
+ console.log('');
27
+ console.log(' Workspace-level architecture validation:');
28
+ console.log(' nx run .:arch:generate # Generate dependency graph');
29
+ console.log(' nx run .:arch:visualize # Visualize dependency graph');
30
+ console.log(' nx run .:arch:validate-no-cycles # Check for circular dependencies');
31
+ console.log(' nx run .:arch:validate-no-skiplevel-deps # Check for redundant dependencies');
32
+ console.log(' nx run .:arch:validate-architecture-unchanged # Validate against blessed graph');
33
+ console.log('');
34
+ console.log(' Per-project circular dependency checking:');
35
+ console.log(' nx run <project>:check-circular-deps # Check project for circular deps');
36
+ console.log(' nx affected --target=check-circular-deps # Check all affected projects');
37
+ console.log(' nx run-many --target=check-circular-deps --all # Check all projects');
38
+ console.log('');
39
+ console.log(`${GREEN}💡 Quick start:${RESET}`);
40
+ console.log(` ${BOLD}npm run arch:generate${RESET} # Generate the graph first`);
41
+ console.log(` ${BOLD}npm run arch:validate-complete${RESET} # Run complete validation`);
42
+ console.log('');
43
+ return { success: true };
44
+ }
45
+ //# sourceMappingURL=executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../packages/tooling/dev-config/executors/help/executor.ts"],"names":[],"mappings":";;AAIA,+BA6CC;AA7Cc,KAAK,UAAU,YAAY,CACtC,OAA4B,EAC5B,OAAwB;IAExB,mBAAmB;IACnB,MAAM,KAAK,GAAG,iBAAiB,CAAC;IAChC,MAAM,IAAI,GAAG,SAAS,CAAC;IACvB,MAAM,KAAK,GAAG,SAAS,CAAC;IAExB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,gDAAgD,KAAK,EAAE,CAAC,CAAC;IAC7E,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,mDAAmD,KAAK,EAAE,CAAC,CAAC;IAC/E,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,wEAAwE,CAAC,CAAC;IACtF,OAAO,CAAC,GAAG,CAAC,yEAAyE,CAAC,CAAC;IACvF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CA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iCAAiC,KAAK,6BAA6B,CAAC,CAAC;IAC3F,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAEhB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["import type { ExecutorContext } from '@nx/devkit';\n\nexport interface HelpExecutorOptions {}\n\nexport default async function helpExecutor(\n options: HelpExecutorOptions,\n context: ExecutorContext\n): Promise<{ success: true }> {\n // ANSI color codes\n const GREEN = '\\x1b[32m\\x1b[1m';\n const BOLD = '\\x1b[1m';\n const RESET = '\\x1b[0m';\n\n console.log('');\n console.log(`${GREEN}💡 @webpieces/dev-config - Available Commands${RESET}`);\n console.log('');\n console.log(`${BOLD}📝 Available npm scripts (convenient shortcuts):${RESET}`);\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(`${BOLD}📝 Available Nx targets:${RESET}`);\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(`${GREEN}💡 Quick start:${RESET}`);\n console.log(` ${BOLD}npm run arch:generate${RESET} # Generate the graph first`);\n console.log(` ${BOLD}npm run arch:validate-complete${RESET} # Run complete validation`);\n console.log('');\n\n return { success: true };\n}\n"]}
@@ -0,0 +1,50 @@
1
+ import type { ExecutorContext } from '@nx/devkit';
2
+
3
+ export interface HelpExecutorOptions {}
4
+
5
+ export default async function helpExecutor(
6
+ options: HelpExecutorOptions,
7
+ context: ExecutorContext
8
+ ): Promise<{ success: true }> {
9
+ // ANSI color codes
10
+ const GREEN = '\x1b[32m\x1b[1m';
11
+ const BOLD = '\x1b[1m';
12
+ const RESET = '\x1b[0m';
13
+
14
+ console.log('');
15
+ console.log(`${GREEN}💡 @webpieces/dev-config - Available Commands${RESET}`);
16
+ console.log('');
17
+ console.log(`${BOLD}📝 Available npm scripts (convenient shortcuts):${RESET}`);
18
+ console.log('');
19
+ console.log(' Architecture graph:');
20
+ console.log(' npm run arch:generate # Generate dependency graph');
21
+ console.log(' npm run arch:visualize # Visualize dependency graph');
22
+ console.log('');
23
+ console.log(' Validation:');
24
+ console.log(' npm run arch:validate # Quick validation (no-cycles + no-skiplevel-deps)');
25
+ console.log(' npm run arch:validate-all # Full arch validation (+ unchanged check)');
26
+ console.log(' npm run arch:check-circular # Check all projects for circular deps');
27
+ console.log(' npm run arch:check-circular-affected # Check affected projects only');
28
+ console.log(' npm run arch:validate-complete # Complete validation (arch + circular)');
29
+ console.log('');
30
+ console.log(`${BOLD}📝 Available Nx targets:${RESET}`);
31
+ console.log('');
32
+ console.log(' Workspace-level architecture validation:');
33
+ console.log(' nx run .:arch:generate # Generate dependency graph');
34
+ console.log(' nx run .:arch:visualize # Visualize dependency graph');
35
+ console.log(' nx run .:arch:validate-no-cycles # Check for circular dependencies');
36
+ console.log(' nx run .:arch:validate-no-skiplevel-deps # Check for redundant dependencies');
37
+ console.log(' nx run .:arch:validate-architecture-unchanged # Validate against blessed graph');
38
+ console.log('');
39
+ console.log(' Per-project circular dependency checking:');
40
+ console.log(' nx run <project>:check-circular-deps # Check project for circular deps');
41
+ console.log(' nx affected --target=check-circular-deps # Check all affected projects');
42
+ console.log(' nx run-many --target=check-circular-deps --all # Check all projects');
43
+ console.log('');
44
+ console.log(`${GREEN}💡 Quick start:${RESET}`);
45
+ console.log(` ${BOLD}npm run arch:generate${RESET} # Generate the graph first`);
46
+ console.log(` ${BOLD}npm run arch:validate-complete${RESET} # Run complete validation`);
47
+ console.log('');
48
+
49
+ return { success: true };
50
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "title": "Help Executor",
4
+ "description": "Display help for @webpieces/dev-config commands and targets",
5
+ "type": "object",
6
+ "properties": {}
7
+ }
@@ -0,0 +1,6 @@
1
+ import type { ExecutorContext } from '@nx/devkit';
2
+ export interface ValidateEslintSyncOptions {
3
+ }
4
+ export default function validateEslintSyncExecutor(options: ValidateEslintSyncOptions, context: ExecutorContext): Promise<{
5
+ success: boolean;
6
+ }>;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = validateEslintSyncExecutor;
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
6
+ const crypto_1 = require("crypto");
7
+ function calculateHash(content) {
8
+ return (0, crypto_1.createHash)('sha256').update(content).digest('hex');
9
+ }
10
+ function normalizeContent(content) {
11
+ // Normalize line endings and trim whitespace
12
+ return content.replace(/\r\n/g, '\n').trim();
13
+ }
14
+ async function validateEslintSyncExecutor(options, context) {
15
+ const workspaceRoot = context.root;
16
+ const templatePath = (0, path_1.join)(workspaceRoot, 'packages/tooling/dev-config/templates/eslint.webpieces.config.mjs');
17
+ const workspacePath = (0, path_1.join)(workspaceRoot, 'eslint.webpieces.config.mjs');
18
+ // eslint-disable-next-line @webpieces/no-unmanaged-exceptions
19
+ try {
20
+ const templateContent = (0, fs_1.readFileSync)(templatePath, 'utf-8');
21
+ const workspaceContent = (0, fs_1.readFileSync)(workspacePath, 'utf-8');
22
+ const templateRules = extractRulesSection(templateContent);
23
+ const workspaceRules = extractRulesSection(workspaceContent);
24
+ const templateHash = calculateHash(normalizeContent(templateRules));
25
+ const workspaceHash = calculateHash(normalizeContent(workspaceRules));
26
+ if (templateHash !== workspaceHash) {
27
+ printValidationError(templatePath, workspacePath);
28
+ return { success: false };
29
+ }
30
+ console.log('✅ ESLint configuration sync validated - rules match!');
31
+ return { success: true };
32
+ }
33
+ catch (err) {
34
+ // Error occurred during validation - log and fail
35
+ // eslint-disable-next-line @webpieces/catch-error-pattern
36
+ console.error('❌ Error validating ESLint sync:', err);
37
+ return { success: false };
38
+ }
39
+ }
40
+ function printValidationError(templatePath, workspacePath) {
41
+ console.error('');
42
+ console.error('❌ ESLint configuration sync validation FAILED');
43
+ console.error('');
44
+ console.error('The @webpieces ESLint rules must be identical in both files:');
45
+ console.error(` 1. ${templatePath}`);
46
+ console.error(` 2. ${workspacePath}`);
47
+ console.error('');
48
+ console.error('These files must have identical rules sections so that:');
49
+ console.error(' - External clients get the same rules we use internally');
50
+ console.error(' - We "eat our own dog food" - same rules for everyone');
51
+ console.error('');
52
+ console.error('To fix:');
53
+ console.error(' 1. Modify the rules in ONE file (recommend: templates/eslint.webpieces.config.mjs)');
54
+ console.error(' 2. Copy the rules section to the other file');
55
+ console.error(' 3. Keep import statements different (template uses npm, workspace uses loadWorkspaceRules)');
56
+ console.error('');
57
+ console.error('Customization for webpieces workspace goes in: eslint.config.mjs');
58
+ console.error('');
59
+ }
60
+ function extractRulesSection(content) {
61
+ // Extract everything between "export default [" and the final "];"
62
+ // This includes the rules configuration
63
+ const match = content.match(/export default \[([\s\S]*)\];/);
64
+ if (!match) {
65
+ throw new Error('Could not extract rules section - export default not found');
66
+ }
67
+ return match[1].trim();
68
+ }
69
+ //# sourceMappingURL=executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../packages/tooling/dev-config/executors/validate-eslint-sync/executor.ts"],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,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,mBAAmB,CAAC,OAAe;IACxC,mEAAmE;IACnE,wCAAwC;IACxC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAC7D,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC3B,CAAC","sourcesContent":["import type { ExecutorContext } from '@nx/devkit';\nimport { readFileSync } from 'fs';\nimport { join } from 'path';\nimport { createHash } from 'crypto';\n\nexport interface ValidateEslintSyncOptions {}\n\nfunction calculateHash(content: string): string {\n return createHash('sha256').update(content).digest('hex');\n}\n\nfunction normalizeContent(content: string): string {\n // Normalize line endings and trim whitespace\n return content.replace(/\\r\\n/g, '\\n').trim();\n}\n\nexport default async function validateEslintSyncExecutor(\n options: ValidateEslintSyncOptions,\n context: ExecutorContext\n): Promise<{ success: boolean }> {\n const workspaceRoot = context.root;\n\n const templatePath = join(workspaceRoot, 'packages/tooling/dev-config/templates/eslint.webpieces.config.mjs');\n const workspacePath = join(workspaceRoot, 'eslint.webpieces.config.mjs');\n\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const templateContent = readFileSync(templatePath, 'utf-8');\n const workspaceContent = readFileSync(workspacePath, 'utf-8');\n\n const templateRules = extractRulesSection(templateContent);\n const workspaceRules = extractRulesSection(workspaceContent);\n\n const templateHash = calculateHash(normalizeContent(templateRules));\n const workspaceHash = calculateHash(normalizeContent(workspaceRules));\n\n if (templateHash !== workspaceHash) {\n printValidationError(templatePath, workspacePath);\n return { success: false };\n }\n\n console.log('✅ ESLint configuration sync validated - rules match!');\n return { success: true };\n\n } catch (err: any) {\n // Error occurred during validation - log and fail\n // eslint-disable-next-line @webpieces/catch-error-pattern\n console.error('❌ Error validating ESLint sync:', err);\n return { success: false };\n }\n}\n\nfunction printValidationError(templatePath: string, workspacePath: string): void {\n console.error('');\n console.error('❌ ESLint configuration sync validation FAILED');\n console.error('');\n console.error('The @webpieces ESLint rules must be identical in both files:');\n console.error(` 1. ${templatePath}`);\n console.error(` 2. ${workspacePath}`);\n console.error('');\n console.error('These files must have identical rules sections so that:');\n console.error(' - External clients get the same rules we use internally');\n console.error(' - We \"eat our own dog food\" - same rules for everyone');\n console.error('');\n console.error('To fix:');\n console.error(' 1. Modify the rules in ONE file (recommend: templates/eslint.webpieces.config.mjs)');\n console.error(' 2. Copy the rules section to the other file');\n console.error(' 3. Keep import statements different (template uses npm, workspace uses loadWorkspaceRules)');\n console.error('');\n console.error('Customization for webpieces workspace goes in: eslint.config.mjs');\n console.error('');\n}\n\nfunction extractRulesSection(content: string): string {\n // Extract everything between \"export default [\" and the final \"];\"\n // This includes the rules configuration\n const match = content.match(/export default \\[([\\s\\S]*)\\];/);\n if (!match) {\n throw new Error('Could not extract rules section - export default not found');\n }\n\n return match[1].trim();\n}\n"]}
@@ -0,0 +1,83 @@
1
+ import type { ExecutorContext } from '@nx/devkit';
2
+ import { readFileSync } from 'fs';
3
+ import { join } from 'path';
4
+ import { createHash } from 'crypto';
5
+
6
+ export interface ValidateEslintSyncOptions {}
7
+
8
+ function calculateHash(content: string): string {
9
+ return createHash('sha256').update(content).digest('hex');
10
+ }
11
+
12
+ function normalizeContent(content: string): string {
13
+ // Normalize line endings and trim whitespace
14
+ return content.replace(/\r\n/g, '\n').trim();
15
+ }
16
+
17
+ export default async function validateEslintSyncExecutor(
18
+ options: ValidateEslintSyncOptions,
19
+ context: ExecutorContext
20
+ ): Promise<{ success: boolean }> {
21
+ const workspaceRoot = context.root;
22
+
23
+ const templatePath = join(workspaceRoot, 'packages/tooling/dev-config/templates/eslint.webpieces.config.mjs');
24
+ const workspacePath = join(workspaceRoot, 'eslint.webpieces.config.mjs');
25
+
26
+ // eslint-disable-next-line @webpieces/no-unmanaged-exceptions
27
+ try {
28
+ const templateContent = readFileSync(templatePath, 'utf-8');
29
+ const workspaceContent = readFileSync(workspacePath, 'utf-8');
30
+
31
+ const templateRules = extractRulesSection(templateContent);
32
+ const workspaceRules = extractRulesSection(workspaceContent);
33
+
34
+ const templateHash = calculateHash(normalizeContent(templateRules));
35
+ const workspaceHash = calculateHash(normalizeContent(workspaceRules));
36
+
37
+ if (templateHash !== workspaceHash) {
38
+ printValidationError(templatePath, workspacePath);
39
+ return { success: false };
40
+ }
41
+
42
+ console.log('✅ ESLint configuration sync validated - rules match!');
43
+ return { success: true };
44
+
45
+ } catch (err: any) {
46
+ // Error occurred during validation - log and fail
47
+ // eslint-disable-next-line @webpieces/catch-error-pattern
48
+ console.error('❌ Error validating ESLint sync:', err);
49
+ return { success: false };
50
+ }
51
+ }
52
+
53
+ function printValidationError(templatePath: string, workspacePath: string): void {
54
+ console.error('');
55
+ console.error('❌ ESLint configuration sync validation FAILED');
56
+ console.error('');
57
+ console.error('The @webpieces ESLint rules must be identical in both files:');
58
+ console.error(` 1. ${templatePath}`);
59
+ console.error(` 2. ${workspacePath}`);
60
+ console.error('');
61
+ console.error('These files must have identical rules sections so that:');
62
+ console.error(' - External clients get the same rules we use internally');
63
+ console.error(' - We "eat our own dog food" - same rules for everyone');
64
+ console.error('');
65
+ console.error('To fix:');
66
+ console.error(' 1. Modify the rules in ONE file (recommend: templates/eslint.webpieces.config.mjs)');
67
+ console.error(' 2. Copy the rules section to the other file');
68
+ console.error(' 3. Keep import statements different (template uses npm, workspace uses loadWorkspaceRules)');
69
+ console.error('');
70
+ console.error('Customization for webpieces workspace goes in: eslint.config.mjs');
71
+ console.error('');
72
+ }
73
+
74
+ function extractRulesSection(content: string): string {
75
+ // Extract everything between "export default [" and the final "];"
76
+ // This includes the rules configuration
77
+ const match = content.match(/export default \[([\s\S]*)\];/);
78
+ if (!match) {
79
+ throw new Error('Could not extract rules section - export default not found');
80
+ }
81
+
82
+ return match[1].trim();
83
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "title": "Validate ESLint Sync Executor",
4
+ "description": "Validates that workspace and template eslint.webpieces.config.mjs files have identical rules",
5
+ "type": "object",
6
+ "properties": {}
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/dev-config",
3
- "version": "0.2.26",
3
+ "version": "0.2.27",
4
4
  "description": "Development configuration, scripts, and patterns for WebPieces projects",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -35,6 +35,7 @@
35
35
  "plugin/**/*",
36
36
  "plugin.js",
37
37
  "templates/**/*",
38
+ "executors/**/*",
38
39
  "src/**/*",
39
40
  "generators.json",
40
41
  "architecture/**/*",