@bemoje/monorepo 1.1.1 → 1.2.0
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/lib/MonoRepo.cjs +142 -0
- package/lib/MonoRepo.d.cts +10 -0
- package/lib/MonoRepo.d.ts +10 -0
- package/lib/MonoRepo.js +134 -0
- package/lib/code/AbstractCode.cjs +77 -0
- package/lib/code/AbstractCode.d.cts +30 -0
- package/lib/code/AbstractCode.d.ts +30 -0
- package/lib/code/AbstractCode.js +74 -0
- package/lib/code/CodeBlock.cjs +51 -0
- package/lib/code/CodeBlock.d.cts +22 -0
- package/lib/code/CodeBlock.d.ts +22 -0
- package/lib/code/CodeBlock.js +48 -0
- package/lib/code/TsCode.cjs +90 -0
- package/lib/code/TsCode.d.cts +10 -0
- package/lib/code/TsCode.d.ts +10 -0
- package/lib/code/TsCode.js +87 -0
- package/lib/code/imports/ImportKeywords.cjs +42 -0
- package/lib/code/imports/ImportKeywords.d.cts +10 -0
- package/lib/code/imports/ImportKeywords.d.ts +10 -0
- package/lib/code/imports/ImportKeywords.js +39 -0
- package/lib/code/imports/ImportSpecifiers.cjs +98 -0
- package/lib/code/imports/ImportSpecifiers.d.cts +10 -0
- package/lib/code/imports/ImportSpecifiers.d.ts +10 -0
- package/lib/code/imports/ImportSpecifiers.js +95 -0
- package/lib/code/imports/ImportStatement.cjs +89 -0
- package/lib/code/imports/ImportStatement.d.cts +10 -0
- package/lib/code/imports/ImportStatement.d.ts +10 -0
- package/lib/code/imports/ImportStatement.js +86 -0
- package/lib/code/imports/ModuleSpecifier.cjs +77 -0
- package/lib/code/imports/ModuleSpecifier.d.cts +10 -0
- package/lib/code/imports/ModuleSpecifier.d.ts +10 -0
- package/lib/code/imports/ModuleSpecifier.js +74 -0
- package/lib/common/AbstractBase.cjs +77 -0
- package/lib/common/AbstractBase.d.cts +3 -0
- package/lib/common/AbstractBase.d.ts +3 -0
- package/lib/common/AbstractBase.js +74 -0
- package/lib/file/File.cjs +118 -0
- package/lib/file/File.d.cts +10 -0
- package/lib/file/File.d.ts +10 -0
- package/lib/file/File.js +91 -0
- package/lib/file/TestFile.cjs +42 -0
- package/lib/file/TestFile.d.cts +10 -0
- package/lib/file/TestFile.d.ts +10 -0
- package/lib/file/TestFile.js +39 -0
- package/lib/file/TsFile.cjs +46 -0
- package/lib/file/TsFile.d.cts +10 -0
- package/lib/file/TsFile.d.ts +10 -0
- package/lib/file/TsFile.js +43 -0
- package/lib/index.cjs +215 -0
- package/lib/index.d.cts +26 -0
- package/lib/index.d.ts +26 -0
- package/lib/index.js +30 -0
- package/lib/methods/findWorkspacePackageName.cjs +17 -0
- package/lib/methods/findWorkspacePackageName.d.cts +6 -0
- package/lib/methods/findWorkspacePackageName.d.ts +6 -0
- package/lib/methods/findWorkspacePackageName.js +14 -0
- package/lib/methods/getAllImports.cjs +18 -0
- package/lib/methods/getAllImports.d.cts +17 -0
- package/lib/methods/getAllImports.d.ts +17 -0
- package/lib/methods/getAllImports.js +16 -0
- package/lib/methods/getAllWorkspacePackageJsonPaths.cjs +20 -0
- package/lib/methods/getAllWorkspacePackageJsonPaths.d.cts +6 -0
- package/lib/methods/getAllWorkspacePackageJsonPaths.d.ts +6 -0
- package/lib/methods/getAllWorkspacePackageJsonPaths.js +13 -0
- package/lib/methods/getAllWorkspacePackageJsons.cjs +20 -0
- package/lib/methods/getAllWorkspacePackageJsons.d.cts +6 -0
- package/lib/methods/getAllWorkspacePackageJsons.d.ts +6 -0
- package/lib/methods/getAllWorkspacePackageJsons.js +13 -0
- package/lib/methods/getAllWorkspacePackageNames.cjs +15 -0
- package/lib/methods/getAllWorkspacePackageNames.d.cts +6 -0
- package/lib/methods/getAllWorkspacePackageNames.d.ts +6 -0
- package/lib/methods/getAllWorkspacePackageNames.js +12 -0
- package/lib/methods/getAllWorkspacePaths.cjs +23 -0
- package/lib/methods/getAllWorkspacePaths.d.cts +6 -0
- package/lib/methods/getAllWorkspacePaths.d.ts +6 -0
- package/lib/methods/getAllWorkspacePaths.js +16 -0
- package/lib/methods/getImportsRecursively.cjs +176 -0
- package/lib/methods/getImportsRecursively.d.cts +37 -0
- package/lib/methods/getImportsRecursively.d.ts +37 -0
- package/lib/methods/getImportsRecursively.js +168 -0
- package/lib/methods/getRepoPackageJson.cjs +17 -0
- package/lib/methods/getRepoPackageJson.d.cts +6 -0
- package/lib/methods/getRepoPackageJson.d.ts +6 -0
- package/lib/methods/getRepoPackageJson.js +10 -0
- package/lib/methods/getRepoPackageJsonPath.cjs +17 -0
- package/lib/methods/getRepoPackageJsonPath.d.cts +6 -0
- package/lib/methods/getRepoPackageJsonPath.d.ts +6 -0
- package/lib/methods/getRepoPackageJsonPath.js +10 -0
- package/lib/repo/Workspace.cjs +383 -0
- package/lib/repo/Workspace.d.cts +10 -0
- package/lib/repo/Workspace.d.ts +10 -0
- package/lib/repo/Workspace.js +376 -0
- package/lib/util/SemanticExtnamePrefix.cjs +12 -0
- package/lib/util/SemanticExtnamePrefix.d.cts +14 -0
- package/lib/util/SemanticExtnamePrefix.d.ts +14 -0
- package/lib/util/SemanticExtnamePrefix.js +12 -0
- package/lib/util/SemanticExtnamePrefixDescriptions.cjs +12 -0
- package/lib/util/SemanticExtnamePrefixDescriptions.d.cts +15 -0
- package/lib/util/SemanticExtnamePrefixDescriptions.d.ts +15 -0
- package/lib/util/SemanticExtnamePrefixDescriptions.js +12 -0
- package/lib/util/SemanticExtnamePrefixes.cjs +9 -0
- package/lib/util/SemanticExtnamePrefixes.d.cts +97 -0
- package/lib/util/SemanticExtnamePrefixes.d.ts +97 -0
- package/lib/util/SemanticExtnamePrefixes.js +6 -0
- package/lib/util/getRepoRootDirpath.cjs +30 -0
- package/lib/util/getRepoRootDirpath.d.cts +6 -0
- package/lib/util/getRepoRootDirpath.d.ts +6 -0
- package/lib/util/getRepoRootDirpath.js +21 -0
- package/lib/util/getWorkspaceDirpaths.cjs +27 -0
- package/lib/util/getWorkspaceDirpaths.d.cts +6 -0
- package/lib/util/getWorkspaceDirpaths.d.ts +6 -0
- package/lib/util/getWorkspaceDirpaths.js +19 -0
- package/lib/util/hasExtnamePrefix.cjs +18 -0
- package/lib/util/hasExtnamePrefix.d.cts +38 -0
- package/lib/util/hasExtnamePrefix.d.ts +38 -0
- package/lib/util/hasExtnamePrefix.js +11 -0
- package/lib/util/resolveModuleImportPath.cjs +34 -0
- package/lib/util/resolveModuleImportPath.d.cts +8 -0
- package/lib/util/resolveModuleImportPath.d.ts +8 -0
- package/lib/util/resolveModuleImportPath.js +26 -0
- package/lib/util/semverVersionBump.cjs +28 -0
- package/lib/util/semverVersionBump.d.cts +22 -0
- package/lib/util/semverVersionBump.d.ts +22 -0
- package/lib/util/semverVersionBump.js +26 -0
- package/package.json +464 -32
- package/index.d.ts +0 -636
- package/index.mjs +0 -2321
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var getRepoRootDirpath = require('../util/getRepoRootDirpath');
|
|
4
|
+
var upath = require('upath');
|
|
5
|
+
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var upath__default = /*#__PURE__*/_interopDefault(upath);
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
12
|
+
function getRepoPackageJsonPath() {
|
|
13
|
+
return upath__default.default.joinSafe(getRepoRootDirpath.getRepoRootDirpath(), "package.json");
|
|
14
|
+
}
|
|
15
|
+
__name(getRepoPackageJsonPath, "getRepoPackageJsonPath");
|
|
16
|
+
|
|
17
|
+
exports.getRepoPackageJsonPath = getRepoPackageJsonPath;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { __name } from '../chunk-SHUYVCID.js';
|
|
2
|
+
import { getRepoRootDirpath } from '../util/getRepoRootDirpath';
|
|
3
|
+
import upath from 'upath';
|
|
4
|
+
|
|
5
|
+
function getRepoPackageJsonPath() {
|
|
6
|
+
return upath.joinSafe(getRepoRootDirpath(), "package.json");
|
|
7
|
+
}
|
|
8
|
+
__name(getRepoPackageJsonPath, "getRepoPackageJsonPath");
|
|
9
|
+
|
|
10
|
+
export { getRepoPackageJsonPath };
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var AbstractBase = require('../common/AbstractBase');
|
|
4
|
+
var composition = require('@mono/composition');
|
|
5
|
+
var SemanticExtnamePrefix = require('../util/SemanticExtnamePrefix');
|
|
6
|
+
var TestFile = require('../file/TestFile');
|
|
7
|
+
var TsFile = require('../file/TsFile');
|
|
8
|
+
var array = require('es-toolkit/array');
|
|
9
|
+
var child_process = require('child_process');
|
|
10
|
+
var hasExtnamePrefix = require('../util/hasExtnamePrefix');
|
|
11
|
+
var path$1 = require('@mono/path');
|
|
12
|
+
var decorators = require('@mono/decorators');
|
|
13
|
+
var path = require('upath');
|
|
14
|
+
var util = require('util');
|
|
15
|
+
var esm = require('fs-extra/esm');
|
|
16
|
+
var resolveModuleImportPath = require('../util/resolveModuleImportPath');
|
|
17
|
+
var esToolkit = require('es-toolkit');
|
|
18
|
+
var fs = require('@mono/fs');
|
|
19
|
+
|
|
20
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
+
|
|
22
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
23
|
+
|
|
24
|
+
var __defProp = Object.defineProperty;
|
|
25
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
26
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
27
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
28
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
29
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
30
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31
|
+
}
|
|
32
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
33
|
+
function _ts_metadata(k, v) {
|
|
34
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
35
|
+
}
|
|
36
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
37
|
+
class Workspace extends AbstractBase.AbstractBase {
|
|
38
|
+
static {
|
|
39
|
+
__name(this, "Workspace");
|
|
40
|
+
}
|
|
41
|
+
static inspector = composition.Inspector.compose(Workspace, {
|
|
42
|
+
keys: [
|
|
43
|
+
"name",
|
|
44
|
+
"tsFiles",
|
|
45
|
+
"testFiles"
|
|
46
|
+
]
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* The workspace's origin directory name, eg. 'libs', 'apps', etc.
|
|
50
|
+
*/
|
|
51
|
+
origin;
|
|
52
|
+
/**
|
|
53
|
+
* The workspace's root directory path.
|
|
54
|
+
*/
|
|
55
|
+
path;
|
|
56
|
+
constructor(parent, dirpath) {
|
|
57
|
+
super(parent);
|
|
58
|
+
this.path = path__default.default.normalize(dirpath);
|
|
59
|
+
this.origin = path__default.default.basename(path__default.default.dirname(this.path));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The workspace's package.json filepath.
|
|
63
|
+
*/
|
|
64
|
+
get packageJsonPath() {
|
|
65
|
+
return path__default.default.join(this.path, "package.json");
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The workspace's package.json file as an object.
|
|
69
|
+
*/
|
|
70
|
+
get packageJson() {
|
|
71
|
+
return esm.readJsonSync(this.packageJsonPath);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The workspace's name from the package.json file.
|
|
75
|
+
*/
|
|
76
|
+
get name() {
|
|
77
|
+
if (!this.packageJson.name) {
|
|
78
|
+
throw new Error(`Workspace package.json missing 'name' field: ${this.packageJsonPath}`);
|
|
79
|
+
}
|
|
80
|
+
return this.packageJson.name;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Reads the workspace's package.json file and returns the 'dependencies' field as a sorted array of strings.
|
|
84
|
+
*/
|
|
85
|
+
get installedDependencies() {
|
|
86
|
+
const deps = this.packageJson.dependencies ?? {};
|
|
87
|
+
return Object.keys(deps).sort();
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Reads the workspace's package.json file and returns the 'devDependencies' field as a sorted array of strings.
|
|
91
|
+
*/
|
|
92
|
+
get installedDevDependencies() {
|
|
93
|
+
const deps = this.packageJson.devDependencies ?? {};
|
|
94
|
+
return Object.keys(deps).sort();
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get all unique file-level dependencies of the workspace, including transitive dependencies through other local workspaces.
|
|
98
|
+
*
|
|
99
|
+
* This method recursively traverses the dependency graph of the workspace, collecting all unique dependencies. It distinguishes between internal dependencies (other local workspaces) and external dependencies (npm packages).
|
|
100
|
+
*
|
|
101
|
+
* @returns An object containing two arrays: `internal` for internal workspace dependencies and `external` for npm package dependencies.
|
|
102
|
+
*/
|
|
103
|
+
get importedDependenciesRecursive() {
|
|
104
|
+
const repo = this.parent;
|
|
105
|
+
const wsNames = new Set(repo.workspaces.map((w) => {
|
|
106
|
+
return w.name;
|
|
107
|
+
}));
|
|
108
|
+
const allDeps = recurse(this.tsFiles.filter((f) => {
|
|
109
|
+
return f.isSourceFile;
|
|
110
|
+
}));
|
|
111
|
+
const internal = [
|
|
112
|
+
...allDeps
|
|
113
|
+
].filter((d) => {
|
|
114
|
+
return wsNames.has(d);
|
|
115
|
+
}).sort();
|
|
116
|
+
const external = [
|
|
117
|
+
...allDeps
|
|
118
|
+
].filter((d) => {
|
|
119
|
+
return !wsNames.has(d);
|
|
120
|
+
}).sort();
|
|
121
|
+
function recurse(files, allDeps2 = /* @__PURE__ */ new Set(), visited = /* @__PURE__ */ new Set(), depth = 0) {
|
|
122
|
+
for (const file of files) {
|
|
123
|
+
if (visited.has(file.path)) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
visited.add(file.path);
|
|
127
|
+
for (const dep of file.dependencies) {
|
|
128
|
+
allDeps2.add(dep);
|
|
129
|
+
const depWs = repo.workspaces.find((w) => {
|
|
130
|
+
return w.name === dep;
|
|
131
|
+
});
|
|
132
|
+
if (depWs) {
|
|
133
|
+
recurse(depWs.tsFiles.filter((f) => {
|
|
134
|
+
return f.isSourceFile;
|
|
135
|
+
}), allDeps2, visited, depth + 1).forEach((d) => {
|
|
136
|
+
return allDeps2.add(d);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return allDeps2;
|
|
142
|
+
}
|
|
143
|
+
__name(recurse, "recurse");
|
|
144
|
+
return {
|
|
145
|
+
internal,
|
|
146
|
+
external
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Get the source files in the workspace's 'src' directory.
|
|
151
|
+
* Test files are not included.
|
|
152
|
+
*/
|
|
153
|
+
get tsFiles() {
|
|
154
|
+
return fs.walkDirectory(this.path, {
|
|
155
|
+
stats: true,
|
|
156
|
+
only: "files",
|
|
157
|
+
filter: /* @__PURE__ */ __name((_dirpath, basename) => {
|
|
158
|
+
if (basename === "node_modules") {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
if (basename === "coverage") {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
if (basename.startsWith(".")) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
return true;
|
|
168
|
+
}, "filter")
|
|
169
|
+
}).filter(([fspath]) => {
|
|
170
|
+
return path$1.hasParentDirname(fspath, "src") && !hasExtnamePrefix.hasExtnamePrefix(fspath);
|
|
171
|
+
}).map(([fspath]) => {
|
|
172
|
+
return new TsFile.TsFile(this, fspath);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Get the test files in the workspace's 'src' directory.
|
|
177
|
+
*/
|
|
178
|
+
get testFiles() {
|
|
179
|
+
return fs.walkDirectory(this.path, {
|
|
180
|
+
stats: true,
|
|
181
|
+
only: "files",
|
|
182
|
+
filter: /* @__PURE__ */ __name((_dirpath, basename) => {
|
|
183
|
+
if (basename === "node_modules") {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
if (basename === "coverage") {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
if (basename.startsWith(".")) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
return true;
|
|
193
|
+
}, "filter")
|
|
194
|
+
}).filter(([fspath]) => {
|
|
195
|
+
return path$1.hasParentDirname(fspath, "src") && !hasExtnamePrefix.hasExtnamePrefix(fspath, SemanticExtnamePrefix.SemanticExtnamePrefix.test);
|
|
196
|
+
}).map(([fspath]) => {
|
|
197
|
+
return new TestFile.TestFile(this, fspath);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
get files() {
|
|
201
|
+
return [
|
|
202
|
+
...this.tsFiles,
|
|
203
|
+
...this.testFiles
|
|
204
|
+
];
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Get imported non-relative dependencies for each source file in the workspace, grouped by file.
|
|
208
|
+
*/
|
|
209
|
+
get importedDependenciesByFile() {
|
|
210
|
+
return new Map(this.tsFiles.map((file) => {
|
|
211
|
+
return [
|
|
212
|
+
path__default.default.relative(process.cwd(), file.path),
|
|
213
|
+
file.dependencies
|
|
214
|
+
];
|
|
215
|
+
}));
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Get imported non-relative dependencies for each test file in the workspace, grouped by file.
|
|
219
|
+
*/
|
|
220
|
+
get importedTestDependenciesByFile() {
|
|
221
|
+
return new Map(this.testFiles.map((file) => {
|
|
222
|
+
return [
|
|
223
|
+
path__default.default.relative(process.cwd(), file.path),
|
|
224
|
+
file.dependencies
|
|
225
|
+
];
|
|
226
|
+
}));
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Get imported non-relative dependencies for each source file in the workspace in a flat array.
|
|
230
|
+
*/
|
|
231
|
+
get importedDependencies() {
|
|
232
|
+
return esToolkit.uniq(Array.from(this.importedDependenciesByFile.values()).flat());
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Get imported non-relative dependencies for each test file in the workspace in a flat array.
|
|
236
|
+
*/
|
|
237
|
+
get importedTestDependencies() {
|
|
238
|
+
return esToolkit.uniq(Array.from(this.importedTestDependenciesByFile.values()).flat());
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Get dependencies that are imported but not listed in the workspace's package.json under 'dependencies'.
|
|
242
|
+
*/
|
|
243
|
+
get missingDependencies() {
|
|
244
|
+
return array.difference(this.importedDependencies, this.installedDependencies).filter((dep) => {
|
|
245
|
+
return !this.parent.packageJson.dependencies?.[dep];
|
|
246
|
+
}).filter((dep) => {
|
|
247
|
+
return !this.parent.tsconfigBasePaths?.[dep];
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Get dependencies that are imported but not listed in the workspace's package.json under 'devDependencies'.
|
|
252
|
+
*/
|
|
253
|
+
get missingDevDependencies() {
|
|
254
|
+
return array.difference(this.importedTestDependencies, array.union(this.installedDependencies, this.installedDevDependencies)).filter((dep) => {
|
|
255
|
+
return !this.parent.packageJson.devDependencies?.[dep];
|
|
256
|
+
}).filter((dep) => {
|
|
257
|
+
return !this.parent.packageJson.dependencies?.[dep];
|
|
258
|
+
}).filter((dep) => {
|
|
259
|
+
return !this.parent.tsconfigBasePaths?.[dep];
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Get dependencies that are listed in the workspace's package.json but not imported in any source file (excl. test files).
|
|
264
|
+
*/
|
|
265
|
+
get unusedDependencies() {
|
|
266
|
+
return array.difference(this.installedDependencies, this.importedDependencies);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
*
|
|
270
|
+
*/
|
|
271
|
+
get incorrectlyImportedRepoWorkspaces() {
|
|
272
|
+
const results = [];
|
|
273
|
+
for (const file of this.files) {
|
|
274
|
+
for (const imp of file.tsCode.imports) {
|
|
275
|
+
if (imp.module.from === this.name) {
|
|
276
|
+
const resolvedFileName = resolveModuleImportPath.resolveModuleImportPath(file.path, imp.module.from)?.resolvedFileName;
|
|
277
|
+
if (resolvedFileName) {
|
|
278
|
+
results.push({
|
|
279
|
+
filepath: file.path,
|
|
280
|
+
replaceValue: imp.module.from,
|
|
281
|
+
withValue: resolvedFileName.endsWith("index.ts") ? `./${imp.specifiers?.importedNamesArray[0]}` : `./${path__default.default.relative(path__default.default.dirname(file.path), resolvedFileName)}`
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return results;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Returns an object with found dependency problems for the workspace or undefined if no problems were found.
|
|
291
|
+
* @see WorkspaceDependencyProblems
|
|
292
|
+
*/
|
|
293
|
+
get dependencyProblems() {
|
|
294
|
+
const result = {
|
|
295
|
+
origin: this.origin,
|
|
296
|
+
workspace: this.name,
|
|
297
|
+
unused: this.unusedDependencies,
|
|
298
|
+
missing: this.missingDependencies,
|
|
299
|
+
missingDev: this.missingDevDependencies,
|
|
300
|
+
imports: this.incorrectlyImportedRepoWorkspaces
|
|
301
|
+
};
|
|
302
|
+
if (!result.unused.length && !result.missing.length && !result.missingDev.length) {
|
|
303
|
+
return void 0;
|
|
304
|
+
}
|
|
305
|
+
for (const [key, value] of Object.entries(result)) {
|
|
306
|
+
if (!value.length) {
|
|
307
|
+
delete result[key];
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return result;
|
|
311
|
+
}
|
|
312
|
+
async depcheck() {
|
|
313
|
+
try {
|
|
314
|
+
const rootPkg = this.parent.packageJson;
|
|
315
|
+
const dependencies = rootPkg.dependencies || {};
|
|
316
|
+
const devDependencies = rootPkg.devDependencies || {};
|
|
317
|
+
const ignores = Object.keys({
|
|
318
|
+
...devDependencies,
|
|
319
|
+
...dependencies
|
|
320
|
+
}).concat("@mono/*");
|
|
321
|
+
const ignoresFlag = `--ignores "${ignores.join(",")}"`;
|
|
322
|
+
const cmd = `yarn depcheck ${this.path} ${ignoresFlag} --json`;
|
|
323
|
+
const execPromise = util.promisify(child_process.exec);
|
|
324
|
+
const res = await execPromise(cmd);
|
|
325
|
+
return JSON.parse(res.stdout.toString());
|
|
326
|
+
} catch (error) {
|
|
327
|
+
const res = error;
|
|
328
|
+
if (res.stdout) {
|
|
329
|
+
return JSON.parse(res.stdout.toString());
|
|
330
|
+
}
|
|
331
|
+
console.error(error);
|
|
332
|
+
return {
|
|
333
|
+
dependencies: [],
|
|
334
|
+
devDependencies: [],
|
|
335
|
+
using: {},
|
|
336
|
+
missing: {},
|
|
337
|
+
invalidFiles: {},
|
|
338
|
+
invalidDirs: {}
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Returns the workspace's cwd-relative path.
|
|
344
|
+
*/
|
|
345
|
+
toString() {
|
|
346
|
+
return path__default.default.relative(process.cwd(), this.path);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
_ts_decorate([
|
|
350
|
+
decorators.lazyProp(1e3),
|
|
351
|
+
_ts_metadata("design:type", typeof PackageJson === "undefined" ? Object : PackageJson),
|
|
352
|
+
_ts_metadata("design:paramtypes", [])
|
|
353
|
+
], Workspace.prototype, "packageJson", null);
|
|
354
|
+
_ts_decorate([
|
|
355
|
+
decorators.lazyProp(5e3),
|
|
356
|
+
_ts_metadata("design:type", Array),
|
|
357
|
+
_ts_metadata("design:paramtypes", [])
|
|
358
|
+
], Workspace.prototype, "tsFiles", null);
|
|
359
|
+
_ts_decorate([
|
|
360
|
+
decorators.lazyProp(5e3),
|
|
361
|
+
_ts_metadata("design:type", Array),
|
|
362
|
+
_ts_metadata("design:paramtypes", [])
|
|
363
|
+
], Workspace.prototype, "testFiles", null);
|
|
364
|
+
_ts_decorate([
|
|
365
|
+
decorators.lazyProp(1e3),
|
|
366
|
+
_ts_metadata("design:type", typeof Map === "undefined" ? Object : Map),
|
|
367
|
+
_ts_metadata("design:paramtypes", [])
|
|
368
|
+
], Workspace.prototype, "importedDependenciesByFile", null);
|
|
369
|
+
_ts_decorate([
|
|
370
|
+
decorators.lazyProp(1e3),
|
|
371
|
+
_ts_metadata("design:type", typeof Map === "undefined" ? Object : Map),
|
|
372
|
+
_ts_metadata("design:paramtypes", [])
|
|
373
|
+
], Workspace.prototype, "importedTestDependenciesByFile", null);
|
|
374
|
+
Workspace = _ts_decorate([
|
|
375
|
+
composition.Parenting.compose,
|
|
376
|
+
_ts_metadata("design:type", Function),
|
|
377
|
+
_ts_metadata("design:paramtypes", [
|
|
378
|
+
typeof P === "undefined" ? Object : P,
|
|
379
|
+
String
|
|
380
|
+
])
|
|
381
|
+
], Workspace);
|
|
382
|
+
|
|
383
|
+
exports.Workspace = Workspace;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import '../AbstractBase-J4h6nW8k.cjs';
|
|
2
|
+
export { c as IncorrectlyImportedRepoWorkspace, W as Workspace, g as WorkspaceDependencyProblems } from '../MonoRepo-BgdabVzT.cjs';
|
|
3
|
+
import 'depcheck';
|
|
4
|
+
import 'util';
|
|
5
|
+
import 'mnemonist';
|
|
6
|
+
import '../is-never.d-CgQ1j0-8.cjs';
|
|
7
|
+
import 'typescript';
|
|
8
|
+
import '../code/AbstractCode.cjs';
|
|
9
|
+
import '../code/CodeBlock.cjs';
|
|
10
|
+
import 'fs';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import '../AbstractBase-J4h6nW8k.js';
|
|
2
|
+
export { c as IncorrectlyImportedRepoWorkspace, W as Workspace, g as WorkspaceDependencyProblems } from '../MonoRepo-BFFUDAYn.js';
|
|
3
|
+
import 'depcheck';
|
|
4
|
+
import 'util';
|
|
5
|
+
import 'mnemonist';
|
|
6
|
+
import '../is-never.d-CgQ1j0-8.js';
|
|
7
|
+
import 'typescript';
|
|
8
|
+
import '../code/AbstractCode.js';
|
|
9
|
+
import '../code/CodeBlock.js';
|
|
10
|
+
import 'fs';
|