@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,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.patchCustomRules = patchCustomRules;
4
+ exports.patchEslintConfig = patchEslintConfig;
5
+ const tslib_1 = require("tslib");
6
+ const tsquery_1 = require("@phenomnomnominal/tsquery");
7
+ const ts = tslib_1.__importStar(require("typescript"));
8
+ const patch_file_1 = require("../utils/patch-file");
9
+ const CUSTOM_RULES_EXPORT_NAME = 'customRules';
10
+ const ESLINT_CONFIG_FILE_NAME = 'eslint.config.mjs';
11
+ const ESLINT_CONFIG_IMPORT_SELECTOR = `ImportDeclaration:has(StringLiteral[text=/${ESLINT_CONFIG_FILE_NAME.replaceAll('.', '\\.')}$/])`;
12
+ const EXPORT_DEFAULT_ARRAY_SELECTOR = 'ExportAssignment > ArrayLiteralExpression';
13
+ function patchCustomRules(input) {
14
+ const sourceFile = ts.createSourceFile(input.path, input.content, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS);
15
+ const edits = [
16
+ createCustomRulesImportEdit(sourceFile, input.content),
17
+ createCustomRulesSpreadEdit(sourceFile, input.content),
18
+ ];
19
+ return edits
20
+ .filter((edit) => Boolean(edit))
21
+ .sort((left, right) => right.position - left.position)
22
+ .reduce((updatedContent, edit) => `${updatedContent.slice(0, edit.position)}${edit.text}${updatedContent.slice(edit.position)}`, input.content);
23
+ }
24
+ function createCustomRulesImportEdit(sourceFile, content) {
25
+ const importDeclaration = (0, tsquery_1.match)(sourceFile, ESLINT_CONFIG_IMPORT_SELECTOR).find(ts.isImportDeclaration);
26
+ const importClause = importDeclaration?.importClause;
27
+ if (!importDeclaration || !importClause) {
28
+ return undefined;
29
+ }
30
+ const namedBindings = importClause.namedBindings;
31
+ if (namedBindings && ts.isNamedImports(namedBindings)) {
32
+ if (namedBindings.elements.some((element) => element.name.text === CUSTOM_RULES_EXPORT_NAME)) {
33
+ return undefined;
34
+ }
35
+ const closingBracePosition = namedBindings.getEnd() - 1;
36
+ const insertionPosition = findLastNonWhitespacePositionBefore(content, closingBracePosition);
37
+ const namedImportsContent = content
38
+ .slice(namedBindings.getStart(sourceFile) + 1, closingBracePosition)
39
+ .trim();
40
+ if (!namedImportsContent) {
41
+ return {
42
+ position: closingBracePosition,
43
+ text: ` ${CUSTOM_RULES_EXPORT_NAME} `,
44
+ };
45
+ }
46
+ const separator = namedImportsContent.endsWith(',') ? ' ' : ', ';
47
+ return {
48
+ position: insertionPosition + 1,
49
+ text: `${separator}${CUSTOM_RULES_EXPORT_NAME}`,
50
+ };
51
+ }
52
+ if (!importClause.name) {
53
+ return undefined;
54
+ }
55
+ return {
56
+ position: importClause.name.getEnd(),
57
+ text: `, { ${CUSTOM_RULES_EXPORT_NAME} }`,
58
+ };
59
+ }
60
+ function createCustomRulesSpreadEdit(sourceFile, content) {
61
+ const exportArray = (0, tsquery_1.match)(sourceFile, EXPORT_DEFAULT_ARRAY_SELECTOR).find((node) => ts.isArrayLiteralExpression(node) &&
62
+ ts.isExportAssignment(node.parent) &&
63
+ !node.parent.isExportEquals);
64
+ if (!exportArray) {
65
+ return undefined;
66
+ }
67
+ if (exportArray.elements.some((element) => ts.isSpreadElement(element) &&
68
+ ts.isIdentifier(element.expression) &&
69
+ element.expression.text === CUSTOM_RULES_EXPORT_NAME)) {
70
+ return undefined;
71
+ }
72
+ const closingBracketPosition = exportArray.getEnd() - 1;
73
+ const openingBracketPosition = exportArray.getStart(sourceFile);
74
+ const openingLine = sourceFile.getLineAndCharacterOfPosition(openingBracketPosition).line;
75
+ const closingLine = sourceFile.getLineAndCharacterOfPosition(closingBracketPosition).line;
76
+ if (openingLine === closingLine) {
77
+ return {
78
+ position: closingBracketPosition,
79
+ text: exportArray.elements.length
80
+ ? `, ...${CUSTOM_RULES_EXPORT_NAME}`
81
+ : `...${CUSTOM_RULES_EXPORT_NAME}`,
82
+ };
83
+ }
84
+ const firstElement = exportArray.elements.at(0);
85
+ const elementIndent = firstElement
86
+ ? getLineIndent(content, firstElement.getStart(sourceFile))
87
+ : `${getLineIndent(content, closingBracketPosition)} `;
88
+ const closingLineStart = content.lastIndexOf('\n', closingBracketPosition - 1) + 1;
89
+ return {
90
+ position: closingLineStart,
91
+ text: `${elementIndent}...${CUSTOM_RULES_EXPORT_NAME},\n`,
92
+ };
93
+ }
94
+ function getLineIndent(content, position) {
95
+ const lineStart = content.lastIndexOf('\n', position - 1) + 1;
96
+ const indentation = /^\s*/.exec(content.slice(lineStart, position));
97
+ return indentation?.[0] ?? '';
98
+ }
99
+ function findLastNonWhitespacePositionBefore(content, position) {
100
+ for (let index = position - 1; index >= 0; index -= 1) {
101
+ if (!/\s/.test(content[index])) {
102
+ return index;
103
+ }
104
+ }
105
+ return position;
106
+ }
107
+ function patchEslintConfig(tree, context) {
108
+ const patches = [(0, patch_file_1.createFilePatch)(patchCustomRules)];
109
+ (0, patch_file_1.patchFile)(tree, `${context.projectRoot}/eslint.config.mjs`, patches);
110
+ }
@@ -0,0 +1,4 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { LibraryContext } from '../utils/context';
3
+ export declare function runGenericPatch(tree: Tree, context: LibraryContext): void;
4
+ //# sourceMappingURL=generic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../../../src/generators/feature-libs/patches/generic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIlD,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,QAGlE"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runGenericPatch = runGenericPatch;
4
+ const eslint_config_mjs_patch_1 = require("./eslint-config-mjs.patch");
5
+ const package_json_patch_1 = require("./package-json.patch");
6
+ function runGenericPatch(tree, context) {
7
+ (0, eslint_config_mjs_patch_1.patchEslintConfig)(tree, context);
8
+ (0, package_json_patch_1.patchPackageJson)(tree, context);
9
+ }
@@ -0,0 +1,8 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { LibraryContext } from '../utils/context';
3
+ export declare function patchAddExports({ tree, path }: {
4
+ tree: Tree;
5
+ path: string;
6
+ }): void;
7
+ export declare function patchPackageJson(tree: Tree, context: LibraryContext): void;
8
+ //# sourceMappingURL=package-json.patch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-json.patch.d.ts","sourceRoot":"","sources":["../../../../src/generators/feature-libs/patches/package-json.patch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,wBAAgB,eAAe,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,QAa3E;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,QAInE"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.patchAddExports = patchAddExports;
4
+ exports.patchPackageJson = patchPackageJson;
5
+ const devkit_1 = require("@nx/devkit");
6
+ const patch_file_1 = require("../utils/patch-file");
7
+ function patchAddExports({ tree, path }) {
8
+ (0, devkit_1.updateJson)(tree, path, (pkgJson) => {
9
+ pkgJson.exports = {
10
+ '.': {
11
+ types: './src/index.ts',
12
+ import: './src/index.ts',
13
+ default: './src/index.ts',
14
+ },
15
+ };
16
+ pkgJson.devDependencies = {};
17
+ return pkgJson;
18
+ });
19
+ }
20
+ function patchPackageJson(tree, context) {
21
+ const patches = [(0, patch_file_1.createFilePatch)(patchAddExports)];
22
+ (0, patch_file_1.patchFile)(tree, `${context.projectRoot}/package.json`, patches);
23
+ }
@@ -0,0 +1,8 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { LibraryContext } from '../utils/context';
3
+ export declare function patchVueInclude({ tree, path }: {
4
+ tree: Tree;
5
+ path: string;
6
+ }): void;
7
+ export declare function patchTsConfigSpec(tree: Tree, context: LibraryContext): void;
8
+ //# sourceMappingURL=tsconfig-spec-json.patch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsconfig-spec-json.patch.d.ts","sourceRoot":"","sources":["../../../../src/generators/feature-libs/patches/tsconfig-spec-json.patch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,wBAAgB,eAAe,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,QAU3E;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,QAIpE"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.patchVueInclude = patchVueInclude;
4
+ exports.patchTsConfigSpec = patchTsConfigSpec;
5
+ const devkit_1 = require("@nx/devkit");
6
+ const patch_file_1 = require("../utils/patch-file");
7
+ function patchVueInclude({ tree, path }) {
8
+ (0, devkit_1.updateJson)(tree, path, (tsConfig) => {
9
+ const include = Array.isArray(tsConfig.include) ? tsConfig.include : [];
10
+ if (!include.includes('src/**/*.vue')) {
11
+ tsConfig.include = [...include, 'src/**/*.vue'];
12
+ }
13
+ return tsConfig;
14
+ });
15
+ }
16
+ function patchTsConfigSpec(tree, context) {
17
+ const patches = [(0, patch_file_1.createFilePatch)(patchVueInclude)];
18
+ (0, patch_file_1.patchFile)(tree, `${context.projectRoot}/tsconfig.spec.json`, patches);
19
+ }
@@ -0,0 +1,22 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { LibraryContext } from '../utils/context';
3
+ export declare function patchTestSetupViteConfig(input: {
4
+ content: string;
5
+ }): string;
6
+ export declare function patchCacheDirViteConfig(input: {
7
+ content: string;
8
+ }, context: {
9
+ projectPath: string;
10
+ }): string;
11
+ export declare function patchNameViteConfig(input: {
12
+ content: string;
13
+ }, context: {
14
+ projectName: string;
15
+ }): string;
16
+ export declare function patchTailwindVitePluginViteConfig(input: {
17
+ content: string;
18
+ }): string;
19
+ export declare function patchViteConfig(tree: Tree, context: LibraryContext, options: {
20
+ hasComponents: boolean;
21
+ }): void;
22
+ //# sourceMappingURL=vite-config-mts.patch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-config-mts.patch.d.ts","sourceRoot":"","sources":["../../../../src/generators/feature-libs/patches/vite-config-mts.patch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,UAOlE;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,EAC1B,OAAO,EAAE;IACP,WAAW,EAAE,MAAM,CAAC;CACrB,UAMF;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,EAC1B,OAAO,EAAE;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,UAMjC;AAED,wBAAgB,iCAAiC,CAAC,KAAK,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,UA6B3E;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE;IAAE,aAAa,EAAE,OAAO,CAAA;CAAE,QAiBpC"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.patchTestSetupViteConfig = patchTestSetupViteConfig;
4
+ exports.patchCacheDirViteConfig = patchCacheDirViteConfig;
5
+ exports.patchNameViteConfig = patchNameViteConfig;
6
+ exports.patchTailwindVitePluginViteConfig = patchTailwindVitePluginViteConfig;
7
+ exports.patchViteConfig = patchViteConfig;
8
+ const patch_file_1 = require("../utils/patch-file");
9
+ function patchTestSetupViteConfig(input) {
10
+ const output = input.content.replace(/(\s+environment:\s+["']jsdom["'],\n)/, '$1 setupFiles: ["test-setup.ts"],\n');
11
+ return output;
12
+ }
13
+ function patchCacheDirViteConfig(input, context) {
14
+ return input.content.replace(/^\s*cacheDir:\s*['"][^'"]+['"],$/m, ` cacheDir: '../../../node_modules/.vite/${context.projectPath}',`);
15
+ }
16
+ function patchNameViteConfig(input, context) {
17
+ return input.content.replace(/^\s*name:\s*['"][^'"]+['"],$/m, ` name: '${context.projectName}',`);
18
+ }
19
+ function patchTailwindVitePluginViteConfig(input) {
20
+ let updatedViteConfigContent = input.content;
21
+ if (!updatedViteConfigContent.includes("import tailwindcss from '@tailwindcss/vite';")) {
22
+ updatedViteConfigContent = updatedViteConfigContent.replace(/^(?:import .*\n)+/, (imports) => `${imports}import tailwindcss from '@tailwindcss/vite';\n`);
23
+ }
24
+ updatedViteConfigContent = updatedViteConfigContent.replace(/^\s*plugins:\s*\[(.*)\],$/m, (fullMatch, pluginList) => {
25
+ if (!pluginList.includes('vue()') ||
26
+ pluginList.includes('tailwindcss()')) {
27
+ return fullMatch;
28
+ }
29
+ return fullMatch.replace('vue()', 'vue(), tailwindcss()');
30
+ });
31
+ return updatedViteConfigContent;
32
+ }
33
+ function patchViteConfig(tree, context, options) {
34
+ const patches = [
35
+ (0, patch_file_1.createFilePatch)(patchTestSetupViteConfig),
36
+ (0, patch_file_1.createFilePatch)(patchCacheDirViteConfig, {
37
+ projectPath: context.projectRoot,
38
+ }),
39
+ (0, patch_file_1.createFilePatch)(patchNameViteConfig, {
40
+ projectName: context.projectName,
41
+ }),
42
+ ];
43
+ if (options.hasComponents) {
44
+ patches.push((0, patch_file_1.createFilePatch)(patchTailwindVitePluginViteConfig));
45
+ }
46
+ (0, patch_file_1.patchFile)(tree, `${context.projectRoot}/vite.config.mts`, patches);
47
+ }
@@ -0,0 +1,18 @@
1
+ export interface FeatureLibsGeneratorSchema {
2
+ /**
3
+ * Path where the libraries should be created
4
+ */
5
+ libsPath: string;
6
+ /**
7
+ * Optional workspace prefix. When omitted, the generator will derive it from
8
+ * `package.json` using {@link getWorkspacePrefix}.
9
+ */
10
+ workspacePrefix?: string;
11
+ ressourceNameSingular: string;
12
+ ressourceNamePlural: string;
13
+ libTypes: ('feature' | 'data-access' | 'ui' | 'types' | 'util')[];
14
+ /**
15
+ * Whether to create a project.json file for the generated library.
16
+ */
17
+ useProjectJson?: boolean;
18
+ }
@@ -0,0 +1,62 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "NxWorkspaceToolsFeatureLibsGenerator",
4
+ "title": "Generate feature libraries",
5
+ "description": "Generate a feature libraries scaffold for the workspace.",
6
+ "type": "object",
7
+ "properties": {
8
+ "libsPath": {
9
+ "type": "string",
10
+ "description": "The path where the libraries should be created.",
11
+ "$default": {
12
+ "$source": "argv",
13
+ "index": 0
14
+ },
15
+ "x-prompt": "Where should the library be placed (e.g., libs/my-ressources)?"
16
+ },
17
+ "workspacePrefix": {
18
+ "type": "string",
19
+ "description": "The workspace prefix used by libraries",
20
+ "$default": {
21
+ "$source": "argv",
22
+ "index": 1
23
+ },
24
+ "x-prompt": "What is the libraries workspace prefix (e.g., @my-org)?"
25
+ },
26
+ "ressourceNameSingular": {
27
+ "type": "string",
28
+ "description": "The singular resource name to use in generated files.",
29
+ "$default": {
30
+ "$source": "argv",
31
+ "index": 2
32
+ },
33
+ "x-prompt": "What singular resource name would you like to use?"
34
+ },
35
+ "ressourceNamePlural": {
36
+ "type": "string",
37
+ "description": "The plural resource name to use in generated files.",
38
+ "$default": {
39
+ "$source": "argv",
40
+ "index": 3
41
+ },
42
+ "x-prompt": "What plural resource name would you like to use?"
43
+ },
44
+ "libTypes": {
45
+ "type": "array",
46
+ "description": "The lib types to generate.",
47
+ "items": {
48
+ "type": "string",
49
+ "enum": ["feature", "data-access", "ui", "types", "util"]
50
+ },
51
+ "default": ["feature", "data-access", "ui", "types", "util"],
52
+ "x-prompt": "Which library types would you like to generate?"
53
+ },
54
+ "useProjectJson": {
55
+ "type": "boolean",
56
+ "description": "Create a project.json file for each generated library.",
57
+ "default": false,
58
+ "x-prompt": "Should a project.json be created?"
59
+ }
60
+ },
61
+ "required": ["libsPath", "ressourceNameSingular", "ressourceNamePlural"]
62
+ }
@@ -0,0 +1,4 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { LibraryContext } from './context';
3
+ export declare function addInternalDepsToPackageJson(tree: Tree, { projectRoot, projectName, packageName, libTypes, workspacePrefix, }: LibraryContext): void;
4
+ //# sourceMappingURL=add-internal-deps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-internal-deps.d.ts","sourceRoot":"","sources":["../../../../src/generators/feature-libs/utils/add-internal-deps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,IAAI,EACV,EACE,WAAW,EACX,WAAW,EACX,WAAW,EACX,QAAQ,EACR,eAAe,GAChB,EAAE,cAAc,QAmDlB"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addInternalDepsToPackageJson = addInternalDepsToPackageJson;
4
+ const devkit_1 = require("@nx/devkit");
5
+ function addInternalDepsToPackageJson(tree, { projectRoot, projectName, packageName, libTypes, workspacePrefix, }) {
6
+ const packageJsonPath = `${projectRoot}/package.json`;
7
+ (0, devkit_1.updateJson)(tree, packageJsonPath, (pkgJson) => {
8
+ pkgJson.devDependencies = {};
9
+ const selectedLibraryTypes = new Set(libTypes);
10
+ if (selectedLibraryTypes.has('feature') &&
11
+ packageName !== `${workspacePrefix}/${projectName}`) {
12
+ pkgJson.devDependencies[`${workspacePrefix}/${projectName}`] =
13
+ 'workspace:*';
14
+ }
15
+ if (selectedLibraryTypes.has('data-access') &&
16
+ packageName !== `${workspacePrefix}/${projectName}-data-access`) {
17
+ pkgJson.devDependencies[`${workspacePrefix}/${projectName}-data-access`] =
18
+ 'workspace:*';
19
+ }
20
+ if (selectedLibraryTypes.has('ui') &&
21
+ packageName !== `${workspacePrefix}/${projectName}-ui`) {
22
+ pkgJson.devDependencies[`${workspacePrefix}/${projectName}-ui`] =
23
+ 'workspace:*';
24
+ }
25
+ if (selectedLibraryTypes.has('types') &&
26
+ packageName !== `${workspacePrefix}/${projectName}-types`) {
27
+ pkgJson.devDependencies[`${workspacePrefix}/${projectName}-types`] =
28
+ 'workspace:*';
29
+ }
30
+ if (selectedLibraryTypes.has('util') &&
31
+ packageName !== `${workspacePrefix}/${projectName}-util`) {
32
+ pkgJson.devDependencies[`${workspacePrefix}/${projectName}-util`] =
33
+ 'workspace:*';
34
+ }
35
+ return pkgJson;
36
+ });
37
+ }
@@ -0,0 +1,13 @@
1
+ import { FeatureLibsGeneratorSchema } from '../schema';
2
+ export type LibraryType = FeatureLibsGeneratorSchema['libTypes'][number];
3
+ export interface LibraryContext {
4
+ workspacePrefix: string;
5
+ libTypes: FeatureLibsGeneratorSchema['libTypes'];
6
+ projectRoot: string;
7
+ projectName: string;
8
+ packageName: string;
9
+ useProjectJson: boolean;
10
+ }
11
+ export declare function getWorkspacePrefix(): string;
12
+ export declare function createLibraryContext(options: FeatureLibsGeneratorSchema, libraryType: LibraryType): LibraryContext;
13
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/generators/feature-libs/utils/context.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAEvD,MAAM,MAAM,WAAW,GAAG,0BAA0B,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzE,MAAM,WAAW,cAAc;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,0BAA0B,CAAC,UAAU,CAAC,CAAC;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,OAAO,CAAC;CACzB;AAID,wBAAgB,kBAAkB,IAAI,MAAM,CAiB3C;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,0BAA0B,EACnC,WAAW,EAAE,WAAW,GACvB,cAAc,CAuDhB"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWorkspacePrefix = getWorkspacePrefix;
4
+ exports.createLibraryContext = createLibraryContext;
5
+ const tslib_1 = require("tslib");
6
+ const fs = tslib_1.__importStar(require("fs"));
7
+ const path = tslib_1.__importStar(require("path"));
8
+ // Detect the prefix from the root package.json. This allows the generator to
9
+ // automatically adapt to different monorepo names without hard‑coding.
10
+ function getWorkspacePrefix() {
11
+ // Resolve the workspace root package.json relative to this file.
12
+ const pkgPath = path.resolve(__dirname, '../../../../../../package.json');
13
+ try {
14
+ const raw = fs.readFileSync(pkgPath, 'utf8');
15
+ const { name } = JSON.parse(raw);
16
+ // The package name is expected to be in the form "@prefix/something".
17
+ if (typeof name === 'string' && name.startsWith('@')) {
18
+ return name.split('/')[0];
19
+ }
20
+ }
21
+ catch {
22
+ /* fall back */
23
+ }
24
+ // No fallback: if the package.json cannot be read or parsed, let the caller
25
+ // handle the failure. Returning an empty string would silently break the
26
+ // generator.
27
+ throw new Error('Unable to determine workspace prefix');
28
+ }
29
+ function createLibraryContext(options, libraryType) {
30
+ const workspacePrefix = options.workspacePrefix ?? getWorkspacePrefix();
31
+ let context;
32
+ switch (libraryType) {
33
+ case 'feature':
34
+ context = {
35
+ projectRoot: `${options.libsPath}/feature`,
36
+ projectName: options.ressourceNamePlural,
37
+ packageName: `${workspacePrefix}/${options.ressourceNamePlural}`,
38
+ };
39
+ break;
40
+ case 'data-access':
41
+ context = {
42
+ projectRoot: `${options.libsPath}/data-access`,
43
+ projectName: `${options.ressourceNamePlural}-data-access`,
44
+ packageName: `${workspacePrefix}/${options.ressourceNamePlural}-data-access`,
45
+ };
46
+ break;
47
+ case 'ui':
48
+ context = {
49
+ projectRoot: `${options.libsPath}/ui`,
50
+ projectName: `${options.ressourceNamePlural}-ui`,
51
+ packageName: `${workspacePrefix}/${options.ressourceNamePlural}-ui`,
52
+ };
53
+ break;
54
+ case 'types':
55
+ context = {
56
+ projectRoot: `${options.libsPath}/types`,
57
+ projectName: `${options.ressourceNamePlural}-types`,
58
+ packageName: `${workspacePrefix}/${options.ressourceNamePlural}-types`,
59
+ };
60
+ break;
61
+ case 'util':
62
+ context = {
63
+ projectRoot: `${options.libsPath}/util`,
64
+ projectName: `${options.ressourceNamePlural}-util`,
65
+ packageName: `${workspacePrefix}/${options.ressourceNamePlural}-util`,
66
+ };
67
+ break;
68
+ default:
69
+ // This should never happen because libraryType is constrained by
70
+ // FeatureLibsGeneratorSchema['libTypes'][number]. Adding a default keeps
71
+ // TypeScript happy and provides a clear error if an unexpected value
72
+ // slips through.
73
+ throw new Error(`Unsupported library type: ${libraryType}`);
74
+ }
75
+ return {
76
+ ...context,
77
+ workspacePrefix,
78
+ libTypes: options.libTypes,
79
+ useProjectJson: options.useProjectJson ?? false,
80
+ };
81
+ }
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare function installStorybook(tree: Tree, project: string): Promise<void>;
3
+ //# sourceMappingURL=install-storybook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-storybook.d.ts","sourceRoot":"","sources":["../../../../src/generators/feature-libs/utils/install-storybook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAiB,MAAM,YAAY,CAAC;AAEjD,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,iBAYjE"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.installStorybook = installStorybook;
4
+ const devkit_1 = require("@nx/devkit");
5
+ async function installStorybook(tree, project) {
6
+ const nxVueVersion = require('@nx/vue/package.json').version;
7
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/storybook', nxVueVersion);
8
+ await configurationGenerator(tree, {
9
+ addPlugin: true,
10
+ project,
11
+ });
12
+ }
@@ -0,0 +1,8 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { FeatureLibsGeneratorSchema } from '../schema';
3
+ export declare function generateFeatureLib(tree: Tree, options: FeatureLibsGeneratorSchema): Promise<void>;
4
+ export declare function generateDataAccessLib(tree: Tree, options: FeatureLibsGeneratorSchema): Promise<void>;
5
+ export declare function generateTypesLib(tree: Tree, options: FeatureLibsGeneratorSchema): Promise<void>;
6
+ export declare function generateUiLib(tree: Tree, options: FeatureLibsGeneratorSchema): Promise<void>;
7
+ export declare function generateUtilLib(tree: Tree, options: FeatureLibsGeneratorSchema): Promise<void>;
8
+ //# sourceMappingURL=library-generators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"library-generators.d.ts","sourceRoot":"","sources":["../../../../src/generators/feature-libs/utils/library-generators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAiB,MAAM,YAAY,CAAC;AASjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAoBvD,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,0BAA0B,iBAgCpC;AAED,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,0BAA0B,iBAwBpC;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,0BAA0B,iBAsBpC;AAED,wBAAsB,aAAa,CACjC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,0BAA0B,iBA2BpC;AAED,wBAAsB,eAAe,CACnC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,0BAA0B,iBAyBpC"}