@webpieces/dev-config 0.2.24 → 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 +2 -2
- package/package.json +2 -2
- package/src/generators/init/generator.d.ts +20 -0
- package/{generators/init/generator.ts → src/generators/init/generator.js} +24 -44
- package/src/generators/init/generator.js.map +1 -0
- package/src/index.d.ts +33 -0
- package/src/index.js +44 -0
- package/src/index.js.map +1 -0
- /package/{generators → src/generators}/init/schema.json +0 -0
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.
|
|
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
|
-
"
|
|
37
|
+
"src/**/*",
|
|
38
38
|
"generators.json",
|
|
39
39
|
"architecture/**/*",
|
|
40
40
|
"executors.json",
|
|
@@ -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>>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = initGenerator;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
5
|
/**
|
|
5
6
|
* Init generator for @webpieces/dev-config
|
|
6
7
|
*
|
|
@@ -16,85 +17,67 @@ import type { InitGeneratorSchema } from './schema';
|
|
|
16
17
|
* - If eslint.config.mjs exists, shows user how to import eslint.webpieces.config.mjs
|
|
17
18
|
* - Provides helpful output about available targets
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
+
async function initGenerator(tree, options) {
|
|
20
21
|
registerPlugin(tree);
|
|
21
22
|
const installTask = addMadgeDependency(tree);
|
|
22
23
|
createArchitectureDirectory(tree);
|
|
23
24
|
addNpmScripts(tree);
|
|
24
25
|
createEslintConfig(tree);
|
|
25
|
-
|
|
26
26
|
if (!options.skipFormat) {
|
|
27
|
-
await formatFiles(tree);
|
|
27
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
28
28
|
}
|
|
29
|
-
|
|
30
29
|
return createSuccessCallback(installTask);
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const nxJson = readNxJson(tree);
|
|
31
|
+
function registerPlugin(tree) {
|
|
32
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
35
33
|
if (!nxJson) {
|
|
36
34
|
throw new Error('Could not read nx.json. Are you in an Nx workspace?');
|
|
37
35
|
}
|
|
38
|
-
|
|
39
36
|
if (!nxJson.plugins) {
|
|
40
37
|
nxJson.plugins = [];
|
|
41
38
|
}
|
|
42
|
-
|
|
43
39
|
const pluginName = '@webpieces/dev-config';
|
|
44
|
-
const alreadyRegistered = nxJson.plugins.some(
|
|
45
|
-
(p) => typeof p === 'string' ? p === pluginName : p.plugin === pluginName
|
|
46
|
-
);
|
|
47
|
-
|
|
40
|
+
const alreadyRegistered = nxJson.plugins.some((p) => typeof p === 'string' ? p === pluginName : p.plugin === pluginName);
|
|
48
41
|
if (!alreadyRegistered) {
|
|
49
42
|
nxJson.plugins.push(pluginName);
|
|
50
|
-
updateNxJson(tree, nxJson);
|
|
43
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
51
44
|
console.log(`✅ Registered ${pluginName} plugin in nx.json`);
|
|
52
|
-
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
53
47
|
console.log(`ℹ️ ${pluginName} plugin is already registered`);
|
|
54
48
|
}
|
|
55
49
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return addDependenciesToPackageJson(tree, {}, { 'madge': '^8.0.0' });
|
|
50
|
+
function addMadgeDependency(tree) {
|
|
51
|
+
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { 'madge': '^8.0.0' });
|
|
59
52
|
}
|
|
60
|
-
|
|
61
|
-
function createArchitectureDirectory(tree: Tree): void {
|
|
53
|
+
function createArchitectureDirectory(tree) {
|
|
62
54
|
if (!tree.exists('architecture')) {
|
|
63
55
|
tree.write('architecture/.gitkeep', '');
|
|
64
56
|
console.log('✅ Created architecture/ directory');
|
|
65
57
|
}
|
|
66
58
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
updateJson(tree, 'package.json', (pkgJson) => {
|
|
59
|
+
function addNpmScripts(tree) {
|
|
60
|
+
(0, devkit_1.updateJson)(tree, 'package.json', (pkgJson) => {
|
|
70
61
|
pkgJson.scripts = pkgJson.scripts ?? {};
|
|
71
|
-
|
|
72
62
|
// Add architecture validation scripts
|
|
73
63
|
pkgJson.scripts['arch:generate'] = 'nx run .:arch:generate';
|
|
74
64
|
pkgJson.scripts['arch:visualize'] = 'nx run .:arch:visualize';
|
|
75
65
|
pkgJson.scripts['arch:validate'] = 'nx run .:arch:validate-no-cycles && nx run .:arch:validate-no-skiplevel-deps';
|
|
76
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';
|
|
77
|
-
|
|
78
67
|
// Add circular dependency checking scripts
|
|
79
68
|
pkgJson.scripts['arch:check-circular'] = 'nx run-many --target=check-circular-deps --all';
|
|
80
69
|
pkgJson.scripts['arch:check-circular-affected'] = 'nx affected --target=check-circular-deps';
|
|
81
|
-
|
|
82
70
|
// Complete validation including circular deps
|
|
83
71
|
pkgJson.scripts['arch:validate-complete'] = 'npm run arch:validate-all && npm run arch:check-circular';
|
|
84
|
-
|
|
85
72
|
return pkgJson;
|
|
86
73
|
});
|
|
87
|
-
|
|
88
74
|
console.log('✅ Added npm scripts for architecture validation and circular dependency checking');
|
|
89
75
|
}
|
|
90
|
-
|
|
91
|
-
function createEslintConfig(tree: Tree): void {
|
|
76
|
+
function createEslintConfig(tree) {
|
|
92
77
|
const webpiecesConfigPath = 'eslint.webpieces.config.mjs';
|
|
93
78
|
const mainConfigPath = 'eslint.config.mjs';
|
|
94
|
-
|
|
95
79
|
// Always create eslint.webpieces.config.mjs with our rules
|
|
96
80
|
createWebpiecesEslintConfig(tree, webpiecesConfigPath);
|
|
97
|
-
|
|
98
81
|
// Check if main eslint.config.mjs exists
|
|
99
82
|
if (tree.exists(mainConfigPath)) {
|
|
100
83
|
// Existing config - show them how to import
|
|
@@ -112,7 +95,8 @@ function createEslintConfig(tree: Tree): void {
|
|
|
112
95
|
console.log(' // ... your existing config');
|
|
113
96
|
console.log(' ];');
|
|
114
97
|
console.log('');
|
|
115
|
-
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
116
100
|
// No existing config - create one that imports webpieces config
|
|
117
101
|
const mainConfig = `// ESLint configuration
|
|
118
102
|
// Imports @webpieces/dev-config rules
|
|
@@ -126,13 +110,11 @@ export default [
|
|
|
126
110
|
// Add your custom ESLint configuration here
|
|
127
111
|
];
|
|
128
112
|
`;
|
|
129
|
-
|
|
130
113
|
tree.write(mainConfigPath, mainConfig);
|
|
131
114
|
console.log('✅ Created eslint.config.mjs with @webpieces/dev-config rules');
|
|
132
115
|
}
|
|
133
116
|
}
|
|
134
|
-
|
|
135
|
-
function createWebpiecesEslintConfig(tree: Tree, configPath: string): void {
|
|
117
|
+
function createWebpiecesEslintConfig(tree, configPath) {
|
|
136
118
|
const webpiecesConfig = `// @webpieces/dev-config ESLint rules
|
|
137
119
|
// This file contains the ESLint configuration provided by @webpieces/dev-config
|
|
138
120
|
// You can modify or remove rules as needed for your project
|
|
@@ -189,12 +171,10 @@ export default [
|
|
|
189
171
|
},
|
|
190
172
|
];
|
|
191
173
|
`;
|
|
192
|
-
|
|
193
174
|
tree.write(configPath, webpiecesConfig);
|
|
194
175
|
console.log('✅ Created eslint.webpieces.config.mjs with @webpieces/dev-config rules');
|
|
195
176
|
}
|
|
196
|
-
|
|
197
|
-
function createSuccessCallback(installTask: ReturnType<typeof addDependenciesToPackageJson>) {
|
|
177
|
+
function createSuccessCallback(installTask) {
|
|
198
178
|
return async () => {
|
|
199
179
|
await installTask();
|
|
200
180
|
console.log('✅ Added madge to devDependencies');
|
|
@@ -204,8 +184,7 @@ function createSuccessCallback(installTask: ReturnType<typeof addDependenciesToP
|
|
|
204
184
|
printAvailableTargets();
|
|
205
185
|
};
|
|
206
186
|
}
|
|
207
|
-
|
|
208
|
-
function printAvailableTargets(): void {
|
|
187
|
+
function printAvailableTargets() {
|
|
209
188
|
console.log('📝 Available npm scripts (convenient shortcuts):');
|
|
210
189
|
console.log('');
|
|
211
190
|
console.log(' Architecture graph:');
|
|
@@ -238,3 +217,4 @@ function printAvailableTargets(): void {
|
|
|
238
217
|
console.log(' npm run arch:validate-complete # Run complete validation');
|
|
239
218
|
console.log('');
|
|
240
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,2BAA2B,CAAC,IAAI,CAAC,CAAC;IAClC,aAAa,CAAC,IAAI,CAAC,CAAC;IACpB,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAEzB,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QACtB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,qBAAqB,CAAC,WAAW,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,cAAc,CAAC,IAAU;IAC9B,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,IAAI,CAAC,CAAC;IAChC,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IAC3E,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAClB,MAAM,CAAC,OA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AC,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
|
package/src/index.js.map
ADDED
|
@@ -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"]}
|
|
File without changes
|