@eweap/nx-workspace-tools 0.0.2-2 → 0.0.2-5
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/dist/executors/internal-deps/internal-deps.d.ts +28 -0
- package/dist/executors/internal-deps/internal-deps.d.ts.map +1 -0
- package/dist/executors/internal-deps/internal-deps.js +221 -0
- package/dist/executors/internal-deps/schema.d.ts +3 -0
- package/dist/executors/internal-deps/schema.json +15 -0
- package/dist/generators/feature-libs/__snapshots__/ui/.storybook/styles.css +4 -0
- package/dist/generators/feature-libs/__snapshots__/ui/tsconfig.storybook.json +25 -0
- package/dist/generators/feature-libs/feature-libs.d.ts +6 -0
- package/dist/generators/feature-libs/feature-libs.d.ts.map +1 -0
- package/dist/generators/feature-libs/feature-libs.js +31 -0
- package/dist/generators/feature-libs/files/data-access/eslint.config.mjs.template +23 -0
- package/dist/generators/feature-libs/files/data-access/src/index.ts.template +1 -0
- package/dist/generators/feature-libs/files/data-access/tsconfig.spec.json.template +7 -0
- package/dist/generators/feature-libs/files/feature/eslint.config.mjs.template +23 -0
- package/dist/generators/feature-libs/files/feature/src/index.ts.template +4 -0
- package/dist/generators/feature-libs/files/feature/test-setup.ts.template +1 -0
- package/dist/generators/feature-libs/files/feature/tsconfig.spec.json.template +7 -0
- package/dist/generators/feature-libs/files/src/index.ts.template +1 -0
- package/dist/generators/feature-libs/files/types/eslint.config.mjs.template +23 -0
- package/dist/generators/feature-libs/files/types/src/__ressourceNameSingular__.ts.template +1 -0
- package/dist/generators/feature-libs/files/types/src/index.ts.template +1 -0
- package/dist/generators/feature-libs/files/ui/.storybook/main.ts.template +26 -0
- package/dist/generators/feature-libs/files/ui/.storybook/preview.ts.template +13 -0
- package/dist/generators/feature-libs/files/ui/.storybook/styles.css.template +4 -0
- package/dist/generators/feature-libs/files/ui/eslint.config.mjs.template +23 -0
- package/dist/generators/feature-libs/files/ui/src/components/index.ts.template +1 -0
- package/dist/generators/feature-libs/files/ui/src/index.ts.template +1 -0
- package/dist/generators/feature-libs/files/ui/tsconfig.spec.json.template +7 -0
- package/dist/generators/feature-libs/files/ui/tsconfig.storybook.json.template +25 -0
- package/dist/generators/feature-libs/files/util/eslint.config.mjs.template +23 -0
- package/dist/generators/feature-libs/files/util/src/index.ts.template +1 -0
- package/dist/generators/feature-libs/files/util/tsconfig.spec.json.template +7 -0
- package/dist/generators/feature-libs/patches/__snapshots__/eslint-config-mjs.patch.spec.ts.snap +27 -0
- package/dist/generators/feature-libs/patches/__snapshots__/package-json.patch.spec.ts.snap +61 -0
- package/dist/generators/feature-libs/patches/__snapshots__/tsconfig-spec-json.patch.spec.ts.snap +39 -0
- package/dist/generators/feature-libs/patches/__snapshots__/vite-config-mts.patch.spec.ts.snap +58 -0
- package/dist/generators/feature-libs/patches/eslint-config-mjs.patch.d.ts +9 -0
- package/dist/generators/feature-libs/patches/eslint-config-mjs.patch.d.ts.map +1 -0
- package/dist/generators/feature-libs/patches/eslint-config-mjs.patch.js +110 -0
- package/dist/generators/feature-libs/patches/generic.d.ts +4 -0
- package/dist/generators/feature-libs/patches/generic.d.ts.map +1 -0
- package/dist/generators/feature-libs/patches/generic.js +9 -0
- package/dist/generators/feature-libs/patches/package-json.patch.d.ts +8 -0
- package/dist/generators/feature-libs/patches/package-json.patch.d.ts.map +1 -0
- package/dist/generators/feature-libs/patches/package-json.patch.js +23 -0
- package/dist/generators/feature-libs/patches/tsconfig-spec-json.patch.d.ts +8 -0
- package/dist/generators/feature-libs/patches/tsconfig-spec-json.patch.d.ts.map +1 -0
- package/dist/generators/feature-libs/patches/tsconfig-spec-json.patch.js +19 -0
- package/dist/generators/feature-libs/patches/vite-config-mts.patch.d.ts +22 -0
- package/dist/generators/feature-libs/patches/vite-config-mts.patch.d.ts.map +1 -0
- package/dist/generators/feature-libs/patches/vite-config-mts.patch.js +47 -0
- package/dist/generators/feature-libs/schema.d.ts +18 -0
- package/dist/generators/feature-libs/schema.json +62 -0
- package/dist/generators/feature-libs/utils/context.d.ts +13 -0
- package/dist/generators/feature-libs/utils/context.d.ts.map +1 -0
- package/dist/generators/feature-libs/utils/context.js +81 -0
- package/dist/generators/feature-libs/utils/file-helpers.d.ts +4 -0
- package/dist/generators/feature-libs/utils/file-helpers.d.ts.map +1 -0
- package/dist/generators/feature-libs/utils/file-helpers.js +49 -0
- package/dist/generators/feature-libs/utils/install-storybook.d.ts +3 -0
- package/dist/generators/feature-libs/utils/install-storybook.d.ts.map +1 -0
- package/dist/generators/feature-libs/utils/install-storybook.js +12 -0
- package/dist/generators/feature-libs/utils/library-generators.d.ts +8 -0
- package/dist/generators/feature-libs/utils/library-generators.d.ts.map +1 -0
- package/dist/generators/feature-libs/utils/library-generators.js +135 -0
- package/dist/generators/feature-libs/utils/patch-file.d.ts +14 -0
- package/dist/generators/feature-libs/utils/patch-file.d.ts.map +1 -0
- package/dist/generators/feature-libs/utils/patch-file.js +28 -0
- package/dist/generators/feature-libs/utils/string-helpers.d.ts +2 -0
- package/dist/generators/feature-libs/utils/string-helpers.d.ts.map +1 -0
- package/dist/generators/feature-libs/utils/string-helpers.js +7 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/package.json +4 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PromiseExecutor } from '@nx/devkit';
|
|
2
|
+
import type { InternalDepsExecutorSchema } from './schema';
|
|
3
|
+
declare const dependencySections: readonly ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
|
|
4
|
+
type DependencySection = (typeof dependencySections)[number];
|
|
5
|
+
type PackageJson = {
|
|
6
|
+
[key in DependencySection]?: Record<string, string>;
|
|
7
|
+
} & Record<string, unknown>;
|
|
8
|
+
type DependencyEntry = {
|
|
9
|
+
name: string;
|
|
10
|
+
section: DependencySection;
|
|
11
|
+
};
|
|
12
|
+
type DependencyGroup = {
|
|
13
|
+
packageJsonPath: string;
|
|
14
|
+
entries: DependencyEntry[];
|
|
15
|
+
};
|
|
16
|
+
type PackageJsonDependencyGroup = DependencyGroup & {
|
|
17
|
+
absolutePath: string;
|
|
18
|
+
packageJson: PackageJson;
|
|
19
|
+
};
|
|
20
|
+
export declare function getWorkspaceDependencies(packageJson: PackageJson): DependencyEntry[];
|
|
21
|
+
export declare function analyzeProjectDependencies(workspaceRoot: string, projectRoot: string): {
|
|
22
|
+
allGroups: DependencyGroup[];
|
|
23
|
+
unusedGroups: PackageJsonDependencyGroup[];
|
|
24
|
+
};
|
|
25
|
+
export declare function removeUnusedWorkspaceDependencies(groups: PackageJsonDependencyGroup[]): number;
|
|
26
|
+
declare const runExecutor: PromiseExecutor<InternalDepsExecutorSchema>;
|
|
27
|
+
export default runExecutor;
|
|
28
|
+
//# sourceMappingURL=internal-deps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-deps.d.ts","sourceRoot":"","sources":["../../../src/executors/internal-deps/internal-deps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAQlD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAG3D,QAAA,MAAM,kBAAkB,0FAKd,CAAC;AAoBX,KAAK,iBAAiB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,KAAK,WAAW,GAAG;KAChB,GAAG,IAAI,iBAAiB,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CACpD,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5B,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,iBAAiB,CAAC;CAC5B,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B,CAAC;AAEF,KAAK,0BAA0B,GAAG,eAAe,GAAG;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC;AA8CF,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,WAAW,GACvB,eAAe,EAAE,CAcnB;AAgID,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,GAClB;IACD,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,YAAY,EAAE,0BAA0B,EAAE,CAAC;CAC5C,CAsCA;AAED,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,0BAA0B,EAAE,GACnC,MAAM,CA0BR;AAED,QAAA,MAAM,WAAW,EAAE,eAAe,CAAC,0BAA0B,CAoC5D,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWorkspaceDependencies = getWorkspaceDependencies;
|
|
4
|
+
exports.analyzeProjectDependencies = analyzeProjectDependencies;
|
|
5
|
+
exports.removeUnusedWorkspaceDependencies = removeUnusedWorkspaceDependencies;
|
|
6
|
+
const node_child_process_1 = require("node:child_process");
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_path_1 = require("node:path");
|
|
9
|
+
const workspaceDependencyPrefix = 'workspace:';
|
|
10
|
+
const dependencySections = [
|
|
11
|
+
'dependencies',
|
|
12
|
+
'devDependencies',
|
|
13
|
+
'peerDependencies',
|
|
14
|
+
'optionalDependencies',
|
|
15
|
+
];
|
|
16
|
+
const ignoredDirs = new Set([
|
|
17
|
+
'.git',
|
|
18
|
+
'.nx',
|
|
19
|
+
'.turbo',
|
|
20
|
+
'coverage',
|
|
21
|
+
'dist',
|
|
22
|
+
'e2e-output',
|
|
23
|
+
'node_modules',
|
|
24
|
+
'out-tsc',
|
|
25
|
+
'tmp',
|
|
26
|
+
]);
|
|
27
|
+
const ignoredFiles = [
|
|
28
|
+
'package.json',
|
|
29
|
+
'package-lock.json',
|
|
30
|
+
'pnpm-lock.yaml',
|
|
31
|
+
'yarn.lock',
|
|
32
|
+
'bun.lockb',
|
|
33
|
+
];
|
|
34
|
+
function isWorkspaceDependencyVersion(version) {
|
|
35
|
+
return version.startsWith(workspaceDependencyPrefix);
|
|
36
|
+
}
|
|
37
|
+
function runCommand(command, args, cwd, options = {}) {
|
|
38
|
+
const result = (0, node_child_process_1.spawnSync)(command, args, {
|
|
39
|
+
cwd,
|
|
40
|
+
encoding: 'utf8',
|
|
41
|
+
...options,
|
|
42
|
+
});
|
|
43
|
+
if (result.error) {
|
|
44
|
+
throw result.error;
|
|
45
|
+
}
|
|
46
|
+
if (result.status !== 0) {
|
|
47
|
+
const stderr = result.stderr?.trim();
|
|
48
|
+
throw new Error(stderr ||
|
|
49
|
+
`${command} ${args.join(' ')} failed with code ${result.status}`);
|
|
50
|
+
}
|
|
51
|
+
return result.stdout?.trim() ?? '';
|
|
52
|
+
}
|
|
53
|
+
function isIgnoredUsageEntry(entryName) {
|
|
54
|
+
return (ignoredDirs.has(entryName) ||
|
|
55
|
+
ignoredFiles.includes(entryName) ||
|
|
56
|
+
entryName.endsWith('.map') ||
|
|
57
|
+
entryName.endsWith('.snap'));
|
|
58
|
+
}
|
|
59
|
+
function parsePackageJson(packageJsonPath) {
|
|
60
|
+
return JSON.parse((0, node_fs_1.readFileSync)(packageJsonPath, 'utf8'));
|
|
61
|
+
}
|
|
62
|
+
function getWorkspaceDependencies(packageJson) {
|
|
63
|
+
const entries = [];
|
|
64
|
+
for (const section of dependencySections) {
|
|
65
|
+
const dependencies = packageJson[section] ?? {};
|
|
66
|
+
for (const [name, version] of Object.entries(dependencies)) {
|
|
67
|
+
if (isWorkspaceDependencyVersion(version)) {
|
|
68
|
+
entries.push({ name, section });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return entries;
|
|
73
|
+
}
|
|
74
|
+
function listWorkspaceDependencies(workspaceRoot, packageJsonPath) {
|
|
75
|
+
const absolutePath = (0, node_path_1.resolve)(workspaceRoot, packageJsonPath);
|
|
76
|
+
const packageJson = parsePackageJson(absolutePath);
|
|
77
|
+
const entries = getWorkspaceDependencies(packageJson);
|
|
78
|
+
if (entries.length === 0) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
return { absolutePath, entries, packageJson, packageJsonPath };
|
|
82
|
+
}
|
|
83
|
+
function findUsages(workspaceRoot, packageJsonPath, dependencyName) {
|
|
84
|
+
const projectDir = (0, node_path_1.resolve)(workspaceRoot, (0, node_path_1.dirname)(packageJsonPath));
|
|
85
|
+
return walkForDependencyUsages(workspaceRoot, projectDir, dependencyName);
|
|
86
|
+
}
|
|
87
|
+
function walkForDependencyUsages(workspaceRoot, dir, dependencyName) {
|
|
88
|
+
const results = [];
|
|
89
|
+
for (const entry of (0, node_fs_1.readdirSync)(dir, { withFileTypes: true })) {
|
|
90
|
+
if (isIgnoredUsageEntry(entry.name)) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const fullPath = (0, node_path_1.join)(dir, entry.name);
|
|
94
|
+
if (entry.isDirectory()) {
|
|
95
|
+
results.push(...walkForDependencyUsages(workspaceRoot, fullPath, dependencyName));
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (!entry.isFile()) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
const fileContents = (0, node_fs_1.readFileSync)(fullPath, 'utf8');
|
|
103
|
+
if (fileContents.includes(dependencyName)) {
|
|
104
|
+
results.push((0, node_path_1.relative)(workspaceRoot, fullPath));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return results;
|
|
112
|
+
}
|
|
113
|
+
function logDependencyGroups(title, groups) {
|
|
114
|
+
console.log('');
|
|
115
|
+
console.log(title);
|
|
116
|
+
if (groups.length === 0) {
|
|
117
|
+
console.log(' none');
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
for (const group of groups) {
|
|
121
|
+
console.log(` ${group.packageJsonPath}`);
|
|
122
|
+
for (const entry of group.entries) {
|
|
123
|
+
console.log(` - ${entry.section} -> ${entry.name}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function syncWorkspaceAfterFix(workspaceRoot) {
|
|
128
|
+
console.log('');
|
|
129
|
+
console.log('Running pnpm install...');
|
|
130
|
+
runCommand('pnpm', ['install'], workspaceRoot, { stdio: 'inherit' });
|
|
131
|
+
console.log('');
|
|
132
|
+
console.log('Running pnpm nx sync...');
|
|
133
|
+
runCommand('pnpm', ['nx', 'sync'], workspaceRoot, { stdio: 'inherit' });
|
|
134
|
+
}
|
|
135
|
+
function getProjectPackageJsonPath(workspaceRoot, projectRoot) {
|
|
136
|
+
const packageJsonPath = (0, node_path_1.resolve)(workspaceRoot, projectRoot, 'package.json');
|
|
137
|
+
if (!(0, node_fs_1.existsSync)(packageJsonPath)) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
return (0, node_path_1.relative)(workspaceRoot, packageJsonPath);
|
|
141
|
+
}
|
|
142
|
+
function resolveProjectRoot(context) {
|
|
143
|
+
const projectName = context.projectName;
|
|
144
|
+
if (!projectName) {
|
|
145
|
+
throw new Error('Executor must run with a target project.');
|
|
146
|
+
}
|
|
147
|
+
const configuredProjectRoot = context.projectsConfigurations?.projects?.[projectName]?.root;
|
|
148
|
+
const graphProjectRoot = context.projectGraph?.nodes?.[projectName]?.data.root;
|
|
149
|
+
const projectRoot = configuredProjectRoot ?? graphProjectRoot;
|
|
150
|
+
if (!projectRoot) {
|
|
151
|
+
throw new Error(`Unable to resolve root for project ${projectName}.`);
|
|
152
|
+
}
|
|
153
|
+
return projectRoot;
|
|
154
|
+
}
|
|
155
|
+
function analyzeProjectDependencies(workspaceRoot, projectRoot) {
|
|
156
|
+
const allGroups = [];
|
|
157
|
+
const unusedGroups = [];
|
|
158
|
+
const packageJsonPath = getProjectPackageJsonPath(workspaceRoot, projectRoot);
|
|
159
|
+
if (!packageJsonPath) {
|
|
160
|
+
return { allGroups, unusedGroups };
|
|
161
|
+
}
|
|
162
|
+
const dependencyGroup = listWorkspaceDependencies(workspaceRoot, packageJsonPath);
|
|
163
|
+
if (!dependencyGroup) {
|
|
164
|
+
return { allGroups, unusedGroups };
|
|
165
|
+
}
|
|
166
|
+
allGroups.push({
|
|
167
|
+
packageJsonPath,
|
|
168
|
+
entries: dependencyGroup.entries,
|
|
169
|
+
});
|
|
170
|
+
const unusedEntries = dependencyGroup.entries.filter((entry) => findUsages(workspaceRoot, packageJsonPath, entry.name).length === 0);
|
|
171
|
+
if (unusedEntries.length > 0) {
|
|
172
|
+
unusedGroups.push({
|
|
173
|
+
absolutePath: dependencyGroup.absolutePath,
|
|
174
|
+
entries: unusedEntries,
|
|
175
|
+
packageJson: dependencyGroup.packageJson,
|
|
176
|
+
packageJsonPath,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return { allGroups, unusedGroups };
|
|
180
|
+
}
|
|
181
|
+
function removeUnusedWorkspaceDependencies(groups) {
|
|
182
|
+
let removedDependenciesCount = 0;
|
|
183
|
+
for (const group of groups) {
|
|
184
|
+
for (const entry of group.entries) {
|
|
185
|
+
const dependencies = group.packageJson[entry.section];
|
|
186
|
+
if (!dependencies) {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
delete dependencies[entry.name];
|
|
190
|
+
removedDependenciesCount += 1;
|
|
191
|
+
if (Object.keys(dependencies).length === 0) {
|
|
192
|
+
delete group.packageJson[entry.section];
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
(0, node_fs_1.writeFileSync)(group.absolutePath, `${JSON.stringify(group.packageJson, null, 2)}\n`);
|
|
196
|
+
}
|
|
197
|
+
return removedDependenciesCount;
|
|
198
|
+
}
|
|
199
|
+
const runExecutor = async (options, context) => {
|
|
200
|
+
const workspaceRoot = context.root;
|
|
201
|
+
const projectRoot = resolveProjectRoot(context);
|
|
202
|
+
const { allGroups, unusedGroups } = analyzeProjectDependencies(workspaceRoot, projectRoot);
|
|
203
|
+
logDependencyGroups('All project internal dependencies', allGroups);
|
|
204
|
+
logDependencyGroups('Unused project internal dependencies', unusedGroups);
|
|
205
|
+
if (!options.write) {
|
|
206
|
+
console.log('');
|
|
207
|
+
console.log('Dry run only. Pass write: true to remove unused dependencies.');
|
|
208
|
+
return { success: true };
|
|
209
|
+
}
|
|
210
|
+
if (unusedGroups.length === 0) {
|
|
211
|
+
console.log('');
|
|
212
|
+
console.log('Nothing to remove.');
|
|
213
|
+
return { success: true };
|
|
214
|
+
}
|
|
215
|
+
const removedDependenciesCount = removeUnusedWorkspaceDependencies(unusedGroups);
|
|
216
|
+
console.log('');
|
|
217
|
+
console.log(`Removed ${removedDependenciesCount} unused dependencies.`);
|
|
218
|
+
syncWorkspaceAfterFix(workspaceRoot);
|
|
219
|
+
return { success: true };
|
|
220
|
+
};
|
|
221
|
+
exports.default = runExecutor;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"version": 2,
|
|
4
|
+
"title": "Internal dependencies executor",
|
|
5
|
+
"description": "Scan internal dependencies in the project.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"write": {
|
|
9
|
+
"type": "boolean",
|
|
10
|
+
"description": "Remove unused internal dependencies and nx-sync the project.",
|
|
11
|
+
"default": false
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"required": []
|
|
15
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "out-tsc/storybook",
|
|
5
|
+
"module": "esnext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"jsx": "preserve",
|
|
8
|
+
"types": ["vite/client"]
|
|
9
|
+
},
|
|
10
|
+
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"],
|
|
11
|
+
"include": [
|
|
12
|
+
"src/**/*.stories.ts",
|
|
13
|
+
"src/**/*.stories.js",
|
|
14
|
+
"src/**/*.stories.jsx",
|
|
15
|
+
"src/**/*.stories.tsx",
|
|
16
|
+
"src/**/*.stories.mdx",
|
|
17
|
+
".storybook/*.js",
|
|
18
|
+
".storybook/**/*.ts"
|
|
19
|
+
],
|
|
20
|
+
"references": [
|
|
21
|
+
{
|
|
22
|
+
"path": "./tsconfig.lib.json"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { FeatureLibsGeneratorSchema } from './schema';
|
|
3
|
+
export { generateDataAccessLib, generateFeatureLib, generateTypesLib, generateUiLib, generateUtilLib, } from './utils/library-generators';
|
|
4
|
+
export { createLibraryContext } from './utils/context';
|
|
5
|
+
export default function featureLibsGenerator(tree: Tree, options: FeatureLibsGeneratorSchema): Promise<void>;
|
|
6
|
+
//# sourceMappingURL=feature-libs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature-libs.d.ts","sourceRoot":"","sources":["../../../src/generators/feature-libs/feature-libs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAStD,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,eAAe,GAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,wBAA8B,oBAAoB,CAChD,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,0BAA0B,iBAuBpC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createLibraryContext = exports.generateUtilLib = exports.generateUiLib = exports.generateTypesLib = exports.generateFeatureLib = exports.generateDataAccessLib = void 0;
|
|
4
|
+
exports.default = featureLibsGenerator;
|
|
5
|
+
const library_generators_1 = require("./utils/library-generators");
|
|
6
|
+
var library_generators_2 = require("./utils/library-generators");
|
|
7
|
+
Object.defineProperty(exports, "generateDataAccessLib", { enumerable: true, get: function () { return library_generators_2.generateDataAccessLib; } });
|
|
8
|
+
Object.defineProperty(exports, "generateFeatureLib", { enumerable: true, get: function () { return library_generators_2.generateFeatureLib; } });
|
|
9
|
+
Object.defineProperty(exports, "generateTypesLib", { enumerable: true, get: function () { return library_generators_2.generateTypesLib; } });
|
|
10
|
+
Object.defineProperty(exports, "generateUiLib", { enumerable: true, get: function () { return library_generators_2.generateUiLib; } });
|
|
11
|
+
Object.defineProperty(exports, "generateUtilLib", { enumerable: true, get: function () { return library_generators_2.generateUtilLib; } });
|
|
12
|
+
var context_1 = require("./utils/context");
|
|
13
|
+
Object.defineProperty(exports, "createLibraryContext", { enumerable: true, get: function () { return context_1.createLibraryContext; } });
|
|
14
|
+
async function featureLibsGenerator(tree, options) {
|
|
15
|
+
const selectedLibraryTypes = new Set(options.libTypes);
|
|
16
|
+
if (selectedLibraryTypes.has('feature')) {
|
|
17
|
+
await (0, library_generators_1.generateFeatureLib)(tree, options);
|
|
18
|
+
}
|
|
19
|
+
if (selectedLibraryTypes.has('data-access')) {
|
|
20
|
+
await (0, library_generators_1.generateDataAccessLib)(tree, options);
|
|
21
|
+
}
|
|
22
|
+
if (selectedLibraryTypes.has('ui')) {
|
|
23
|
+
await (0, library_generators_1.generateUiLib)(tree, options);
|
|
24
|
+
}
|
|
25
|
+
if (selectedLibraryTypes.has('types')) {
|
|
26
|
+
await (0, library_generators_1.generateTypesLib)(tree, options);
|
|
27
|
+
}
|
|
28
|
+
if (selectedLibraryTypes.has('util')) {
|
|
29
|
+
await (0, library_generators_1.generateUtilLib)(tree, options);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import vue from 'eslint-plugin-vue';
|
|
2
|
+
|
|
3
|
+
import baseConfig, { customRules } from '../../../eslint.config.mjs';
|
|
4
|
+
|
|
5
|
+
export default [
|
|
6
|
+
...baseConfig,
|
|
7
|
+
...vue.configs['flat/recommended'],
|
|
8
|
+
{
|
|
9
|
+
files: ['**/*.vue'],
|
|
10
|
+
languageOptions: {
|
|
11
|
+
parserOptions: {
|
|
12
|
+
parser: await import('@typescript-eslint/parser'),
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.vue'],
|
|
18
|
+
rules: {
|
|
19
|
+
'vue/multi-word-component-names': 'off',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
...customRules,
|
|
23
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import vue from 'eslint-plugin-vue';
|
|
2
|
+
|
|
3
|
+
import baseConfig, { customRules } from '../../../eslint.config.mjs';
|
|
4
|
+
|
|
5
|
+
export default [
|
|
6
|
+
...baseConfig,
|
|
7
|
+
...vue.configs['flat/recommended'],
|
|
8
|
+
{
|
|
9
|
+
files: ['**/*.vue'],
|
|
10
|
+
languageOptions: {
|
|
11
|
+
parserOptions: {
|
|
12
|
+
parser: await import('@typescript-eslint/parser'),
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.vue'],
|
|
18
|
+
rules: {
|
|
19
|
+
'vue/multi-word-component-names': 'off',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
...customRules,
|
|
23
|
+
];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<% if(libTypes.includes('data-access')) { %>export * from "<%= workspacePrefix %>/<%= ressourceNamePlural %>-data-access";<% } %>
|
|
2
|
+
<% if(libTypes.includes('types')) { %>export * from "<%= workspacePrefix %>/<%= ressourceNamePlural %>-types";<% } %>
|
|
3
|
+
<% if(libTypes.includes('ui')) { %>export * from "<%= workspacePrefix %>/<%= ressourceNamePlural %>-ui";<% } %>
|
|
4
|
+
<% if(libTypes.includes('util')) { %>export * from "<%= workspacePrefix %>/<%= ressourceNamePlural %>-util";<% } %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const variable = "<%= name %>";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import vue from 'eslint-plugin-vue';
|
|
2
|
+
|
|
3
|
+
import baseConfig, { customRules } from '../../../eslint.config.mjs';
|
|
4
|
+
|
|
5
|
+
export default [
|
|
6
|
+
...baseConfig,
|
|
7
|
+
...vue.configs['flat/recommended'],
|
|
8
|
+
{
|
|
9
|
+
files: ['**/*.vue'],
|
|
10
|
+
languageOptions: {
|
|
11
|
+
parserOptions: {
|
|
12
|
+
parser: await import('@typescript-eslint/parser'),
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.vue'],
|
|
18
|
+
rules: {
|
|
19
|
+
'vue/multi-word-component-names': 'off',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
...customRules,
|
|
23
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./<%= ressourceNameSingular %>";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { StorybookConfig } from '@storybook/vue3-vite';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
const config: StorybookConfig = {
|
|
6
|
+
stories: ['../src/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'],
|
|
7
|
+
addons: [],
|
|
8
|
+
framework: {
|
|
9
|
+
name: getAbsolutePath('@storybook/vue3-vite'),
|
|
10
|
+
options: {
|
|
11
|
+
builder: {
|
|
12
|
+
viteConfigPath: 'vite.config.mts',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function getAbsolutePath(value: string): any {
|
|
19
|
+
return dirname(fileURLToPath(import.meta.resolve(`${value}/package.json`)));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default config;
|
|
23
|
+
|
|
24
|
+
// To customize your Vite configuration you can use the viteFinal field.
|
|
25
|
+
// Check https://storybook.js.org/docs/react/builders/vite#configuration
|
|
26
|
+
// and https://nx.dev/recipes/storybook/custom-builder-configs
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Preview } from '@storybook/vue3';
|
|
2
|
+
import { vueRouter } from 'storybook-vue3-router';
|
|
3
|
+
|
|
4
|
+
import './styles.css';
|
|
5
|
+
|
|
6
|
+
const preview: Preview = {
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: 'centered',
|
|
9
|
+
},
|
|
10
|
+
decorators: [vueRouter()],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default preview;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import vue from 'eslint-plugin-vue';
|
|
2
|
+
|
|
3
|
+
import baseConfig, { customRules } from '../../../eslint.config.mjs';
|
|
4
|
+
|
|
5
|
+
export default [
|
|
6
|
+
...baseConfig,
|
|
7
|
+
...vue.configs['flat/recommended'],
|
|
8
|
+
{
|
|
9
|
+
files: ['**/*.vue'],
|
|
10
|
+
languageOptions: {
|
|
11
|
+
parserOptions: {
|
|
12
|
+
parser: await import('@typescript-eslint/parser'),
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.vue'],
|
|
18
|
+
rules: {
|
|
19
|
+
'vue/multi-word-component-names': 'off',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
...customRules,
|
|
23
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// export { default as Button } from "./lib/button/Button.vue";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./components";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "out-tsc/storybook",
|
|
5
|
+
"module": "esnext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"jsx": "preserve",
|
|
8
|
+
"types": ["vite/client"]
|
|
9
|
+
},
|
|
10
|
+
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"],
|
|
11
|
+
"include": [
|
|
12
|
+
"src/**/*.stories.ts",
|
|
13
|
+
"src/**/*.stories.js",
|
|
14
|
+
"src/**/*.stories.jsx",
|
|
15
|
+
"src/**/*.stories.tsx",
|
|
16
|
+
"src/**/*.stories.mdx",
|
|
17
|
+
".storybook/*.js",
|
|
18
|
+
".storybook/**/*.ts"
|
|
19
|
+
],
|
|
20
|
+
"references": [
|
|
21
|
+
{
|
|
22
|
+
"path": "./tsconfig.lib.json"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import vue from 'eslint-plugin-vue';
|
|
2
|
+
|
|
3
|
+
import baseConfig, { customRules } from '../../../eslint.config.mjs';
|
|
4
|
+
|
|
5
|
+
export default [
|
|
6
|
+
...baseConfig,
|
|
7
|
+
...vue.configs['flat/recommended'],
|
|
8
|
+
{
|
|
9
|
+
files: ['**/*.vue'],
|
|
10
|
+
languageOptions: {
|
|
11
|
+
parserOptions: {
|
|
12
|
+
parser: await import('@typescript-eslint/parser'),
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.vue'],
|
|
18
|
+
rules: {
|
|
19
|
+
'vue/multi-word-component-names': 'off',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
...customRules,
|
|
23
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/dist/generators/feature-libs/patches/__snapshots__/eslint-config-mjs.patch.spec.ts.snap
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`patchEslintConfig > should patch the eslint config file 1`] = `
|
|
4
|
+
"import vue from 'eslint-plugin-vue';
|
|
5
|
+
import baseConfig, { customRules } from '../../eslint.config.mjs';
|
|
6
|
+
|
|
7
|
+
export default [
|
|
8
|
+
...baseConfig,
|
|
9
|
+
...vue.configs['flat/recommended'],
|
|
10
|
+
{
|
|
11
|
+
files: ['**/*.vue'],
|
|
12
|
+
languageOptions: {
|
|
13
|
+
parserOptions: {
|
|
14
|
+
parser: await import('@typescript-eslint/parser'),
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.vue'],
|
|
20
|
+
rules: {
|
|
21
|
+
'vue/multi-word-component-names': 'off',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
...customRules,
|
|
25
|
+
];
|
|
26
|
+
"
|
|
27
|
+
`;
|