@eweap/nx-workspace-tools 0.0.2-10

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.
Files changed (73) hide show
  1. package/README.md +11 -0
  2. package/dist/executors/internal-deps/internal-deps.d.ts +28 -0
  3. package/dist/executors/internal-deps/internal-deps.d.ts.map +1 -0
  4. package/dist/executors/internal-deps/internal-deps.js +221 -0
  5. package/dist/executors/internal-deps/schema.d.ts +3 -0
  6. package/dist/executors/internal-deps/schema.json +15 -0
  7. package/dist/generators/feature-libs/__snapshots__/ui/.storybook/styles.css +4 -0
  8. package/dist/generators/feature-libs/feature-libs.d.ts +6 -0
  9. package/dist/generators/feature-libs/feature-libs.d.ts.map +1 -0
  10. package/dist/generators/feature-libs/feature-libs.js +31 -0
  11. package/dist/generators/feature-libs/files/data-access/eslint.config.mjs.template +23 -0
  12. package/dist/generators/feature-libs/files/data-access/src/index.ts.template +1 -0
  13. package/dist/generators/feature-libs/files/data-access/tsconfig.spec.json.template +7 -0
  14. package/dist/generators/feature-libs/files/feature/eslint.config.mjs.template +23 -0
  15. package/dist/generators/feature-libs/files/feature/src/index.ts.template +4 -0
  16. package/dist/generators/feature-libs/files/feature/test-setup.ts.template +1 -0
  17. package/dist/generators/feature-libs/files/feature/tsconfig.spec.json.template +7 -0
  18. package/dist/generators/feature-libs/files/src/index.ts.template +1 -0
  19. package/dist/generators/feature-libs/files/types/eslint.config.mjs.template +23 -0
  20. package/dist/generators/feature-libs/files/types/src/__ressourceNameSingular__.ts.template +1 -0
  21. package/dist/generators/feature-libs/files/types/src/index.ts.template +1 -0
  22. package/dist/generators/feature-libs/files/ui/.storybook/main.ts.template +26 -0
  23. package/dist/generators/feature-libs/files/ui/.storybook/preview.ts.template +13 -0
  24. package/dist/generators/feature-libs/files/ui/.storybook/styles.css.template +4 -0
  25. package/dist/generators/feature-libs/files/ui/eslint.config.mjs.template +23 -0
  26. package/dist/generators/feature-libs/files/ui/src/components/index.ts.template +1 -0
  27. package/dist/generators/feature-libs/files/ui/src/index.ts.template +1 -0
  28. package/dist/generators/feature-libs/files/ui/tsconfig.spec.json.template +7 -0
  29. package/dist/generators/feature-libs/files/ui/tsconfig.storybook.json.template +25 -0
  30. package/dist/generators/feature-libs/files/util/eslint.config.mjs.template +23 -0
  31. package/dist/generators/feature-libs/files/util/src/index.ts.template +1 -0
  32. package/dist/generators/feature-libs/files/util/tsconfig.spec.json.template +7 -0
  33. package/dist/generators/feature-libs/patches/eslint-config-mjs.patch.d.ts +9 -0
  34. package/dist/generators/feature-libs/patches/eslint-config-mjs.patch.d.ts.map +1 -0
  35. package/dist/generators/feature-libs/patches/eslint-config-mjs.patch.js +110 -0
  36. package/dist/generators/feature-libs/patches/generic.d.ts +4 -0
  37. package/dist/generators/feature-libs/patches/generic.d.ts.map +1 -0
  38. package/dist/generators/feature-libs/patches/generic.js +9 -0
  39. package/dist/generators/feature-libs/patches/package-json.patch.d.ts +8 -0
  40. package/dist/generators/feature-libs/patches/package-json.patch.d.ts.map +1 -0
  41. package/dist/generators/feature-libs/patches/package-json.patch.js +23 -0
  42. package/dist/generators/feature-libs/patches/tsconfig-spec-json.patch.d.ts +8 -0
  43. package/dist/generators/feature-libs/patches/tsconfig-spec-json.patch.d.ts.map +1 -0
  44. package/dist/generators/feature-libs/patches/tsconfig-spec-json.patch.js +19 -0
  45. package/dist/generators/feature-libs/patches/vite-config-mts.patch.d.ts +22 -0
  46. package/dist/generators/feature-libs/patches/vite-config-mts.patch.d.ts.map +1 -0
  47. package/dist/generators/feature-libs/patches/vite-config-mts.patch.js +47 -0
  48. package/dist/generators/feature-libs/schema.d.ts +18 -0
  49. package/dist/generators/feature-libs/schema.json +62 -0
  50. package/dist/generators/feature-libs/utils/add-internal-deps.d.ts +4 -0
  51. package/dist/generators/feature-libs/utils/add-internal-deps.d.ts.map +1 -0
  52. package/dist/generators/feature-libs/utils/add-internal-deps.js +37 -0
  53. package/dist/generators/feature-libs/utils/context.d.ts +13 -0
  54. package/dist/generators/feature-libs/utils/context.d.ts.map +1 -0
  55. package/dist/generators/feature-libs/utils/context.js +81 -0
  56. package/dist/generators/feature-libs/utils/install-storybook.d.ts +3 -0
  57. package/dist/generators/feature-libs/utils/install-storybook.d.ts.map +1 -0
  58. package/dist/generators/feature-libs/utils/install-storybook.js +12 -0
  59. package/dist/generators/feature-libs/utils/library-generators.d.ts +8 -0
  60. package/dist/generators/feature-libs/utils/library-generators.d.ts.map +1 -0
  61. package/dist/generators/feature-libs/utils/library-generators.js +135 -0
  62. package/dist/generators/feature-libs/utils/patch-file.d.ts +14 -0
  63. package/dist/generators/feature-libs/utils/patch-file.d.ts.map +1 -0
  64. package/dist/generators/feature-libs/utils/patch-file.js +28 -0
  65. package/dist/generators/feature-libs/utils/string-helpers.d.ts +2 -0
  66. package/dist/generators/feature-libs/utils/string-helpers.d.ts.map +1 -0
  67. package/dist/generators/feature-libs/utils/string-helpers.js +7 -0
  68. package/dist/index.d.ts +4 -0
  69. package/dist/index.d.ts.map +1 -0
  70. package/dist/index.js +37 -0
  71. package/executors.json +9 -0
  72. package/generators.json +9 -0
  73. package/package.json +73 -0
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateFeatureLib = generateFeatureLib;
4
+ exports.generateDataAccessLib = generateDataAccessLib;
5
+ exports.generateTypesLib = generateTypesLib;
6
+ exports.generateUiLib = generateUiLib;
7
+ exports.generateUtilLib = generateUtilLib;
8
+ const tslib_1 = require("tslib");
9
+ const devkit_1 = require("@nx/devkit");
10
+ const js_1 = require("@nx/js");
11
+ const vue_1 = require("@nx/vue");
12
+ const lodash_es_1 = require("lodash-es");
13
+ const path = tslib_1.__importStar(require("path"));
14
+ const generic_1 = require("../patches/generic");
15
+ const tsconfig_spec_json_patch_1 = require("../patches/tsconfig-spec-json.patch");
16
+ const vite_config_mts_patch_1 = require("../patches/vite-config-mts.patch");
17
+ const add_internal_deps_1 = require("./add-internal-deps");
18
+ const context_1 = require("./context");
19
+ const install_storybook_1 = require("./install-storybook");
20
+ const string_helpers_1 = require("./string-helpers");
21
+ function applyLibFileTemplates(tree, templateFolder, projectRoot, context) {
22
+ (0, devkit_1.generateFiles)(tree, path.join(__dirname, '..', 'files', templateFolder), projectRoot, context);
23
+ }
24
+ async function generateFeatureLib(tree, options) {
25
+ const context = (0, context_1.createLibraryContext)(options, 'feature');
26
+ await (0, vue_1.libraryGenerator)(tree, {
27
+ directory: context.projectRoot,
28
+ linter: 'eslint',
29
+ name: context.projectName,
30
+ unitTestRunner: 'vitest',
31
+ importPath: context.packageName,
32
+ tags: 'type:feature',
33
+ addPlugin: true,
34
+ useProjectJson: context.useProjectJson,
35
+ });
36
+ await (0, install_storybook_1.installStorybook)(tree, context.projectName);
37
+ // Apply patches
38
+ (0, generic_1.runGenericPatch)(tree, context);
39
+ (0, vite_config_mts_patch_1.patchViteConfig)(tree, context, { hasComponents: true });
40
+ (0, tsconfig_spec_json_patch_1.patchTsConfigSpec)(tree, context);
41
+ // Install internal deps
42
+ (0, add_internal_deps_1.addInternalDepsToPackageJson)(tree, context);
43
+ // Apply file templates
44
+ applyLibFileTemplates(tree, 'feature', context.projectRoot, {
45
+ ...options,
46
+ camelCase: lodash_es_1.camelCase,
47
+ workspacePrefix: context.workspacePrefix,
48
+ libTypes: context.libTypes,
49
+ });
50
+ }
51
+ async function generateDataAccessLib(tree, options) {
52
+ const context = (0, context_1.createLibraryContext)(options, 'data-access');
53
+ await (0, js_1.libraryGenerator)(tree, {
54
+ directory: context.projectRoot,
55
+ linter: 'eslint',
56
+ name: context.projectName,
57
+ unitTestRunner: 'vitest',
58
+ importPath: context.packageName,
59
+ tags: 'type:data-access',
60
+ addPlugin: true,
61
+ useProjectJson: context.useProjectJson,
62
+ });
63
+ // Apply patches
64
+ (0, generic_1.runGenericPatch)(tree, context);
65
+ (0, vite_config_mts_patch_1.patchViteConfig)(tree, context, { hasComponents: false });
66
+ // Apply file templates
67
+ applyLibFileTemplates(tree, 'data-access', context.projectRoot, {
68
+ ...options,
69
+ uppercase: string_helpers_1.toUpperSnakeCase,
70
+ });
71
+ }
72
+ async function generateTypesLib(tree, options) {
73
+ const context = (0, context_1.createLibraryContext)(options, 'types');
74
+ await (0, js_1.libraryGenerator)(tree, {
75
+ directory: context.projectRoot,
76
+ linter: 'eslint',
77
+ name: context.projectName,
78
+ unitTestRunner: 'vitest',
79
+ importPath: context.packageName,
80
+ tags: 'type:types',
81
+ addPlugin: true,
82
+ useProjectJson: context.useProjectJson,
83
+ });
84
+ // Apply patches
85
+ (0, generic_1.runGenericPatch)(tree, context);
86
+ // Apply file templates
87
+ applyLibFileTemplates(tree, 'types', context.projectRoot, {
88
+ ...options,
89
+ });
90
+ }
91
+ async function generateUiLib(tree, options) {
92
+ const context = (0, context_1.createLibraryContext)(options, 'ui');
93
+ await (0, vue_1.libraryGenerator)(tree, {
94
+ directory: context.projectRoot,
95
+ linter: 'eslint',
96
+ name: context.projectName,
97
+ unitTestRunner: 'vitest',
98
+ importPath: context.packageName,
99
+ tags: 'type:ui',
100
+ addPlugin: true,
101
+ useProjectJson: context.useProjectJson,
102
+ });
103
+ await (0, install_storybook_1.installStorybook)(tree, context.projectName);
104
+ // Apply patches
105
+ (0, generic_1.runGenericPatch)(tree, context);
106
+ (0, vite_config_mts_patch_1.patchViteConfig)(tree, context, { hasComponents: true });
107
+ (0, tsconfig_spec_json_patch_1.patchTsConfigSpec)(tree, context);
108
+ // Apply file templates
109
+ applyLibFileTemplates(tree, 'ui', context.projectRoot, {
110
+ ...options,
111
+ camelCase: lodash_es_1.camelCase,
112
+ });
113
+ }
114
+ async function generateUtilLib(tree, options) {
115
+ const context = (0, context_1.createLibraryContext)(options, 'util');
116
+ await (0, js_1.libraryGenerator)(tree, {
117
+ directory: context.projectRoot,
118
+ linter: 'eslint',
119
+ name: context.projectName,
120
+ unitTestRunner: 'vitest',
121
+ importPath: context.packageName,
122
+ tags: 'type:util',
123
+ addPlugin: true,
124
+ useProjectJson: context.useProjectJson,
125
+ });
126
+ // Apply patches
127
+ (0, generic_1.runGenericPatch)(tree, context);
128
+ (0, vite_config_mts_patch_1.patchViteConfig)(tree, context, { hasComponents: false });
129
+ // Apply file templates
130
+ applyLibFileTemplates(tree, 'util', context.projectRoot, {
131
+ ...options,
132
+ camelCase: lodash_es_1.camelCase,
133
+ uppercase: string_helpers_1.toUpperSnakeCase,
134
+ });
135
+ }
@@ -0,0 +1,14 @@
1
+ import { Tree } from '@nx/devkit';
2
+ type FilePatchInput = {
3
+ tree: Tree;
4
+ path: string;
5
+ content: string;
6
+ };
7
+ export interface FilePatch<TArgs extends readonly unknown[] = readonly unknown[]> {
8
+ patchFn(input: FilePatchInput, ...args: TArgs): string | void;
9
+ patchArgs: TArgs;
10
+ }
11
+ export declare function createFilePatch<TArgs extends readonly unknown[]>(patchFn: (input: FilePatchInput, ...args: TArgs) => string | void, ...args: TArgs): FilePatch<TArgs>;
12
+ export declare function patchFile<const TPatches extends readonly FilePatch[]>(tree: Tree, path: string, filePatches: TPatches): void;
13
+ export {};
14
+ //# sourceMappingURL=patch-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patch-file.d.ts","sourceRoot":"","sources":["../../../../src/generators/feature-libs/utils/patch-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,SAAS,CACxB,KAAK,SAAS,SAAS,OAAO,EAAE,GAAG,SAAS,OAAO,EAAE;IAErD,OAAO,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC;IAC9D,SAAS,EAAE,KAAK,CAAC;CAClB;AAED,wBAAgB,eAAe,CAAC,KAAK,SAAS,SAAS,OAAO,EAAE,EAC9D,OAAO,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,KAAK,KAAK,MAAM,GAAG,IAAI,EACjE,GAAG,IAAI,EAAE,KAAK,GACb,SAAS,CAAC,KAAK,CAAC,CAElB;AAED,wBAAgB,SAAS,CAAC,KAAK,CAAC,QAAQ,SAAS,SAAS,SAAS,EAAE,EACnE,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,QAAQ,QA6BtB"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createFilePatch = createFilePatch;
4
+ exports.patchFile = patchFile;
5
+ function createFilePatch(patchFn, ...args) {
6
+ return { patchFn, patchArgs: args };
7
+ }
8
+ function patchFile(tree, path, filePatches) {
9
+ const fileContent = tree.read(path, 'utf-8');
10
+ if (!fileContent) {
11
+ return;
12
+ }
13
+ let newFileContent = fileContent;
14
+ filePatches.forEach((filePatch) => {
15
+ const newContent = filePatch.patchFn({
16
+ tree,
17
+ path,
18
+ content: newFileContent,
19
+ }, ...filePatch.patchArgs);
20
+ // Some patches mutate the tree directly instead of returning new content.
21
+ if (newContent) {
22
+ newFileContent = newContent;
23
+ }
24
+ });
25
+ if (newFileContent !== fileContent) {
26
+ tree.write(path, newFileContent);
27
+ }
28
+ }
@@ -0,0 +1,2 @@
1
+ export declare function toUpperSnakeCase(value: string): string;
2
+ //# sourceMappingURL=string-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-helpers.d.ts","sourceRoot":"","sources":["../../../../src/generators/feature-libs/utils/string-helpers.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,UAE7C"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toUpperSnakeCase = toUpperSnakeCase;
4
+ const lodash_es_1 = require("lodash-es");
5
+ function toUpperSnakeCase(value) {
6
+ return (0, lodash_es_1.snakeCase)(value).toUpperCase();
7
+ }
@@ -0,0 +1,4 @@
1
+ import type { CreateNodes } from '@nx/devkit';
2
+ export declare const createNodes: CreateNodes;
3
+ export declare const createNodesV2: CreateNodes;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,YAAY,CAAC;AAqCnE,eAAO,MAAM,WAAW,EAAE,WASzB,CAAC;AAEF,eAAO,MAAM,aAAa,aAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createNodesV2 = exports.createNodes = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const node_path_1 = require("node:path");
6
+ const internalDepsTargetName = 'internal-deps';
7
+ function getInternalDepsTarget() {
8
+ return {
9
+ executor: '@eweap/nx-workspace-tools:internal-deps',
10
+ options: {
11
+ write: false,
12
+ },
13
+ };
14
+ }
15
+ function createInternalDepsTarget(projectRoot) {
16
+ return {
17
+ projects: {
18
+ [projectRoot]: {
19
+ targets: {
20
+ [internalDepsTargetName]: getInternalDepsTarget(),
21
+ },
22
+ },
23
+ },
24
+ };
25
+ }
26
+ async function createNodesForConfigFile(configFilePath) {
27
+ const projectRoot = (0, node_path_1.dirname)(configFilePath);
28
+ if (projectRoot === '.' || projectRoot.length === 0) {
29
+ return {};
30
+ }
31
+ return createInternalDepsTarget(projectRoot);
32
+ }
33
+ exports.createNodes = [
34
+ '**/{project,package}.json',
35
+ async (configFilePaths, options, context) => (0, devkit_1.createNodesFromFiles)(createNodesForConfigFile, configFilePaths, options, context),
36
+ ];
37
+ exports.createNodesV2 = exports.createNodes;
package/executors.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "executors": {
3
+ "internal-deps": {
4
+ "implementation": "./dist/executors/internal-deps/internal-deps",
5
+ "schema": "./dist/executors/internal-deps/schema.json",
6
+ "description": "Scan internal internal dependencies in the project."
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "generators": {
3
+ "feature-libs": {
4
+ "factory": "./dist/generators/feature-libs/feature-libs",
5
+ "schema": "./dist/generators/feature-libs/schema.json",
6
+ "description": "Generate a feature libraries scaffold."
7
+ }
8
+ }
9
+ }
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@eweap/nx-workspace-tools",
3
+ "version": "0.0.2-10",
4
+ "type": "commonjs",
5
+ "repository": {
6
+ "url": "https://github.com/eweap/nx-plugins"
7
+ },
8
+ "main": "./dist/index.js",
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ "./package.json": "./package.json",
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js",
16
+ "default": "./dist/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "!**/*.tsbuildinfo",
22
+ "executors.json",
23
+ "generators.json"
24
+ ],
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "dependencies": {
29
+ "@nx/devkit": "*",
30
+ "@nx/js": "*",
31
+ "@nx/vue": "*",
32
+ "@phenomnomnominal/tsquery": "*",
33
+ "lodash-es": "*",
34
+ "tslib": "*",
35
+ "typescript": "*",
36
+ "nx": "23.1.1"
37
+ },
38
+ "nx": {
39
+ "name": "nx-workspace-tools",
40
+ "targets": {
41
+ "build": {
42
+ "executor": "@nx/js:tsc",
43
+ "outputs": [
44
+ "{options.outputPath}"
45
+ ],
46
+ "options": {
47
+ "outputPath": "packages/nx-workspace-tools/dist",
48
+ "main": "packages/nx-workspace-tools/src/index.ts",
49
+ "tsConfig": "packages/nx-workspace-tools/tsconfig.lib.json",
50
+ "rootDir": "packages/nx-workspace-tools/src",
51
+ "generatePackageJson": false,
52
+ "assets": [
53
+ {
54
+ "input": "./packages/nx-workspace-tools/src",
55
+ "glob": "**/!(*.ts)",
56
+ "ignore": [
57
+ "**/__snapshots__/**"
58
+ ],
59
+ "output": "."
60
+ },
61
+ {
62
+ "input": "./packages/nx-workspace-tools/src",
63
+ "glob": "**/*.d.ts",
64
+ "output": "."
65
+ }
66
+ ]
67
+ }
68
+ }
69
+ }
70
+ },
71
+ "executors": "./executors.json",
72
+ "generators": "./generators.json"
73
+ }