@eweap/nx-workspace-tools 0.0.2-10 → 0.0.2-12
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/README.md +6 -0
- package/dist/executors/internal-deps/internal-deps.d.ts.map +1 -1
- package/dist/executors/internal-deps/internal-deps.js +4 -9
- package/dist/generators/feature-libs/files/feature/src/index.ts.template +4 -4
- package/dist/generators/feature-libs/files/types/src/index.ts.template +1 -1
- package/dist/generators/feature-libs/schema.d.ts +2 -2
- package/dist/generators/feature-libs/schema.json +4 -4
- package/dist/generators/feature-libs/utils/context.js +10 -10
- package/package.json +12 -9
- /package/dist/generators/feature-libs/files/types/src/{__ressourceNameSingular__.ts.template → __resourceNameSingular__.ts.template} +0 -0
package/README.md
CHANGED
|
@@ -9,3 +9,9 @@ Run `nx build nx-workspace-tools` to build the library.
|
|
|
9
9
|
## Running unit tests
|
|
10
10
|
|
|
11
11
|
Run `nx test nx-workspace-tools` to execute the unit tests via [Vitest](https://vitest.dev/).
|
|
12
|
+
|
|
13
|
+
## Internal dependencies
|
|
14
|
+
|
|
15
|
+
The `internal-deps` executor reports unused `workspace:` dependencies and fails
|
|
16
|
+
the Nx task when any are found. With `write: true`, it removes the reported
|
|
17
|
+
dependencies and succeeds when the correction completes successfully.
|
|
@@ -1 +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,C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ACrB,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC;AA8CF,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,WAAW,GACvB,eAAe,EAAE,CAcnB;AA4HD,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"}
|
|
@@ -98,14 +98,9 @@ function walkForDependencyUsages(workspaceRoot, dir, dependencyName) {
|
|
|
98
98
|
if (!entry.isFile()) {
|
|
99
99
|
continue;
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
results.push((0, node_path_1.relative)(workspaceRoot, fullPath));
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
catch {
|
|
108
|
-
continue;
|
|
101
|
+
const fileContents = (0, node_fs_1.readFileSync)(fullPath, 'utf8');
|
|
102
|
+
if (fileContents.includes(dependencyName)) {
|
|
103
|
+
results.push((0, node_path_1.relative)(workspaceRoot, fullPath));
|
|
109
104
|
}
|
|
110
105
|
}
|
|
111
106
|
return results;
|
|
@@ -205,7 +200,7 @@ const runExecutor = async (options, context) => {
|
|
|
205
200
|
if (!options.write) {
|
|
206
201
|
console.log('');
|
|
207
202
|
console.log('Dry run only. Pass write: true to remove unused dependencies.');
|
|
208
|
-
return { success:
|
|
203
|
+
return { success: unusedGroups.length === 0 };
|
|
209
204
|
}
|
|
210
205
|
if (unusedGroups.length === 0) {
|
|
211
206
|
console.log('');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<% if(libTypes.includes('data-access')) { %>export * from "<%= workspacePrefix %>/<%=
|
|
2
|
-
<% if(libTypes.includes('types')) { %>export * from "<%= workspacePrefix %>/<%=
|
|
3
|
-
<% if(libTypes.includes('ui')) { %>export * from "<%= workspacePrefix %>/<%=
|
|
4
|
-
<% if(libTypes.includes('util')) { %>export * from "<%= workspacePrefix %>/<%=
|
|
1
|
+
<% if(libTypes.includes('data-access')) { %>export * from "<%= workspacePrefix %>/<%= resourceNamePlural %>-data-access";<% } %>
|
|
2
|
+
<% if(libTypes.includes('types')) { %>export * from "<%= workspacePrefix %>/<%= resourceNamePlural %>-types";<% } %>
|
|
3
|
+
<% if(libTypes.includes('ui')) { %>export * from "<%= workspacePrefix %>/<%= resourceNamePlural %>-ui";<% } %>
|
|
4
|
+
<% if(libTypes.includes('util')) { %>export * from "<%= workspacePrefix %>/<%= resourceNamePlural %>-util";<% } %>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./<%=
|
|
1
|
+
export * from "./<%= resourceNameSingular %>";
|
|
@@ -8,8 +8,8 @@ export interface FeatureLibsGeneratorSchema {
|
|
|
8
8
|
* `package.json` using {@link getWorkspacePrefix}.
|
|
9
9
|
*/
|
|
10
10
|
workspacePrefix?: string;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
resourceNameSingular: string;
|
|
12
|
+
resourceNamePlural: string;
|
|
13
13
|
libTypes: ('feature' | 'data-access' | 'ui' | 'types' | 'util')[];
|
|
14
14
|
/**
|
|
15
15
|
* Whether to create a project.json file for the generated library.
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"$source": "argv",
|
|
13
13
|
"index": 0
|
|
14
14
|
},
|
|
15
|
-
"x-prompt": "Where should the library be placed (e.g., libs/my-
|
|
15
|
+
"x-prompt": "Where should the library be placed (e.g., libs/my-resources)?"
|
|
16
16
|
},
|
|
17
17
|
"workspacePrefix": {
|
|
18
18
|
"type": "string",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"x-prompt": "What is the libraries workspace prefix (e.g., @my-org)?"
|
|
25
25
|
},
|
|
26
|
-
"
|
|
26
|
+
"resourceNameSingular": {
|
|
27
27
|
"type": "string",
|
|
28
28
|
"description": "The singular resource name to use in generated files.",
|
|
29
29
|
"$default": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"x-prompt": "What singular resource name would you like to use?"
|
|
34
34
|
},
|
|
35
|
-
"
|
|
35
|
+
"resourceNamePlural": {
|
|
36
36
|
"type": "string",
|
|
37
37
|
"description": "The plural resource name to use in generated files.",
|
|
38
38
|
"$default": {
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"x-prompt": "Should a project.json be created?"
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
|
-
"required": ["libsPath", "
|
|
61
|
+
"required": ["libsPath", "resourceNameSingular", "resourceNamePlural"]
|
|
62
62
|
}
|
|
@@ -33,36 +33,36 @@ function createLibraryContext(options, libraryType) {
|
|
|
33
33
|
case 'feature':
|
|
34
34
|
context = {
|
|
35
35
|
projectRoot: `${options.libsPath}/feature`,
|
|
36
|
-
projectName: options.
|
|
37
|
-
packageName: `${workspacePrefix}/${options.
|
|
36
|
+
projectName: options.resourceNamePlural,
|
|
37
|
+
packageName: `${workspacePrefix}/${options.resourceNamePlural}`,
|
|
38
38
|
};
|
|
39
39
|
break;
|
|
40
40
|
case 'data-access':
|
|
41
41
|
context = {
|
|
42
42
|
projectRoot: `${options.libsPath}/data-access`,
|
|
43
|
-
projectName: `${options.
|
|
44
|
-
packageName: `${workspacePrefix}/${options.
|
|
43
|
+
projectName: `${options.resourceNamePlural}-data-access`,
|
|
44
|
+
packageName: `${workspacePrefix}/${options.resourceNamePlural}-data-access`,
|
|
45
45
|
};
|
|
46
46
|
break;
|
|
47
47
|
case 'ui':
|
|
48
48
|
context = {
|
|
49
49
|
projectRoot: `${options.libsPath}/ui`,
|
|
50
|
-
projectName: `${options.
|
|
51
|
-
packageName: `${workspacePrefix}/${options.
|
|
50
|
+
projectName: `${options.resourceNamePlural}-ui`,
|
|
51
|
+
packageName: `${workspacePrefix}/${options.resourceNamePlural}-ui`,
|
|
52
52
|
};
|
|
53
53
|
break;
|
|
54
54
|
case 'types':
|
|
55
55
|
context = {
|
|
56
56
|
projectRoot: `${options.libsPath}/types`,
|
|
57
|
-
projectName: `${options.
|
|
58
|
-
packageName: `${workspacePrefix}/${options.
|
|
57
|
+
projectName: `${options.resourceNamePlural}-types`,
|
|
58
|
+
packageName: `${workspacePrefix}/${options.resourceNamePlural}-types`,
|
|
59
59
|
};
|
|
60
60
|
break;
|
|
61
61
|
case 'util':
|
|
62
62
|
context = {
|
|
63
63
|
projectRoot: `${options.libsPath}/util`,
|
|
64
|
-
projectName: `${options.
|
|
65
|
-
packageName: `${workspacePrefix}/${options.
|
|
64
|
+
projectName: `${options.resourceNamePlural}-util`,
|
|
65
|
+
packageName: `${workspacePrefix}/${options.resourceNamePlural}-util`,
|
|
66
66
|
};
|
|
67
67
|
break;
|
|
68
68
|
default:
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eweap/nx-workspace-tools",
|
|
3
|
-
"version": "0.0.2-
|
|
3
|
+
"version": "0.0.2-12",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/eweap/nx-plugins"
|
|
7
7
|
},
|
|
8
|
+
"homepage": "https://eweap.github.io/nx-plugins",
|
|
8
9
|
"main": "./dist/index.js",
|
|
9
10
|
"module": "./dist/index.js",
|
|
10
11
|
"types": "./dist/index.d.ts",
|
|
@@ -26,14 +27,16 @@
|
|
|
26
27
|
"access": "public"
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
"nx": "23.
|
|
30
|
+
"@phenomnomnominal/tsquery": "^6.2.0",
|
|
31
|
+
"lodash-es": "^4.17.21",
|
|
32
|
+
"tslib": "^2.3.0",
|
|
33
|
+
"typescript": "~6.0.3"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@nx/devkit": "^23.0.0",
|
|
37
|
+
"@nx/js": "^23.0.0",
|
|
38
|
+
"@nx/vue": "^23.0.0",
|
|
39
|
+
"nx": "^23.0.0"
|
|
37
40
|
},
|
|
38
41
|
"nx": {
|
|
39
42
|
"name": "nx-workspace-tools",
|