@bemoje/monorepo 0.0.1 → 1.1.1
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 +99 -0
- package/index.d.ts +2 -2
- package/index.mjs +186 -195
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# @mono/monorepo
|
|
2
|
+
|
|
3
|
+
Monorepo workspace management, package discovery, and TypeScript code processing utilities.
|
|
4
|
+
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
[](https://nodejs.org/api/esm.html)
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
### Managing the Repository & Workspaces
|
|
11
|
+
|
|
12
|
+
The `MonoRepo` class allows structured, automated tasks against packages and workspaces in a typical monorepo
|
|
13
|
+
environment (e.g. yarn, npm, pnpm workspaces).
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { MonoRepo } from '@mono/monorepo'
|
|
17
|
+
|
|
18
|
+
const repo = new MonoRepo()
|
|
19
|
+
|
|
20
|
+
// Access all registered packages/workspaces
|
|
21
|
+
const workspaces = repo.workspaces
|
|
22
|
+
console.log(`Found ${workspaces.length} workspaces`)
|
|
23
|
+
|
|
24
|
+
// Get specific workspaces by name or type
|
|
25
|
+
const packageJson = repo.getWorkspace('my-package')?.packageJson
|
|
26
|
+
|
|
27
|
+
// Bump version for all packages (semver)
|
|
28
|
+
repo.bumpVersions('patch')
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Script & File Operations
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { TsFile, findWorkspacePackageName } from '@mono/monorepo'
|
|
35
|
+
|
|
36
|
+
const tsFile = new TsFile('path/to/my-file.ts')
|
|
37
|
+
|
|
38
|
+
// Read structural code representations (imports, blocks, components)
|
|
39
|
+
const imports = tsFile.imports
|
|
40
|
+
|
|
41
|
+
// Use utility functions independently of classes
|
|
42
|
+
const packageName = findWorkspacePackageName('libs/my-feature')
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## API Reference
|
|
46
|
+
|
|
47
|
+
### Core Repository
|
|
48
|
+
|
|
49
|
+
| Export | Description |
|
|
50
|
+
| -------------- | ---------------------------------------------------------- |
|
|
51
|
+
| `MonoRepo` | Central class governing the structure of an open monorepo |
|
|
52
|
+
| `Workspace` | Model structure for an individual project/package |
|
|
53
|
+
| `AbstractBase` | Foundational primitive used for components mapping classes |
|
|
54
|
+
|
|
55
|
+
### Code & Imports Parsing
|
|
56
|
+
|
|
57
|
+
| Export | Description |
|
|
58
|
+
| ------------------ | ---------------------------------------------------------- |
|
|
59
|
+
| `AbstractCode` | Model providing baseline AST context matching |
|
|
60
|
+
| `TsCode` | Encapsulates structural elements found in Typescript code |
|
|
61
|
+
| `CodeBlock` | Abstraction representing code blocks and nested structures |
|
|
62
|
+
| `ImportStatement` | Comprehensive model for evaluating module imports |
|
|
63
|
+
| `ImportKeywords` | Parsed model mapping distinct words injected |
|
|
64
|
+
| `ImportSpecifiers` | Parsed model resolving named exports inside imports |
|
|
65
|
+
| `ModuleSpecifier` | Model resolving targeted module representations |
|
|
66
|
+
|
|
67
|
+
### File Operations
|
|
68
|
+
|
|
69
|
+
| Export | Description |
|
|
70
|
+
| ---------- | ---------------------------------------------------------- |
|
|
71
|
+
| `File` | Generic cross-platform file wrapper providing baseline IO |
|
|
72
|
+
| `TsFile` | File abstraction built specifically for `.ts` processing |
|
|
73
|
+
| `TestFile` | Standard test-execution tracking class wrapping code types |
|
|
74
|
+
|
|
75
|
+
### Discovery Methods
|
|
76
|
+
|
|
77
|
+
| Export | Description |
|
|
78
|
+
| --------------------------------- | --------------------------------------------------------- |
|
|
79
|
+
| `getRepoRootDirpath` | Find the repository's root execution configuration index |
|
|
80
|
+
| `getRepoPackageJsonPath` | Absolute path to root `package.json` |
|
|
81
|
+
| `getRepoPackageJson` | Full structurally parsed data for root `package.json` |
|
|
82
|
+
| `getWorkspaceDirpaths` | Retrieve array of directories containing active packages |
|
|
83
|
+
| `getAllWorkspacePaths` | Return specific mapped configurations of standard domains |
|
|
84
|
+
| `getAllWorkspacePackageJsonPaths` | Array returning strictly active `package.json` paths |
|
|
85
|
+
| `getAllWorkspacePackageJsons` | Extract parsing configuration objects for children pkgs |
|
|
86
|
+
| `getAllWorkspacePackageNames` | Map name attributes found from all workspace directories |
|
|
87
|
+
| `findWorkspacePackageName` | Discover closest named active project bound to child path |
|
|
88
|
+
|
|
89
|
+
### Utilities
|
|
90
|
+
|
|
91
|
+
| Export | Description |
|
|
92
|
+
| ----------------------------------- | ---------------------------------------------------------- |
|
|
93
|
+
| `getAllImports` | Collect import arrays across scopes / boundaries |
|
|
94
|
+
| `resolveModuleImportPath` | Convert abstract module statements into absolute locations |
|
|
95
|
+
| `semverVersionBump` | Upgrade semantics targeting specific boundaries semver |
|
|
96
|
+
| `hasExtnamePrefix` | Matching abstraction targeting specific semantic models |
|
|
97
|
+
| `SemanticExtnamePrefix` | Types identifying standard TS suffix standards (`.test`) |
|
|
98
|
+
| `SemanticExtnamePrefixes` | Array evaluation tracking suffixes expected across modules |
|
|
99
|
+
| `SemanticExtnamePrefixDescriptions` | Readable text models matching semantic prefix usages |
|
package/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SetFieldType, TsConfigJson, Arrayable } from 'type-fest';
|
|
2
|
-
import { InspectOptions, inspect } from 'util';
|
|
2
|
+
import { InspectOptions, inspect } from 'node:util';
|
|
3
3
|
import { MultiSet, DefaultMap } from 'mnemonist';
|
|
4
4
|
import * as typescript from 'typescript';
|
|
5
5
|
import { CompilerOptions } from 'typescript';
|
|
6
6
|
import { Results } from 'depcheck';
|
|
7
|
-
import { Stats } from 'fs';
|
|
7
|
+
import { Stats } from 'node:fs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Interface for a View that wraps a target object.
|
package/index.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import { ms } from 'enhanced-ms';
|
|
|
10
10
|
import path2 from 'upath';
|
|
11
11
|
import { builtinModules } from 'module';
|
|
12
12
|
import strip from 'strip-comments';
|
|
13
|
+
import { uniq } from 'es-toolkit';
|
|
13
14
|
import { difference, union } from 'es-toolkit/array';
|
|
14
15
|
import { exec } from 'child_process';
|
|
15
16
|
import fs3, { readJsonSync } from 'fs-extra/esm';
|
|
@@ -137,134 +138,6 @@ function hasProperty(object, key) {
|
|
|
137
138
|
}
|
|
138
139
|
__name(hasProperty, "hasProperty");
|
|
139
140
|
|
|
140
|
-
// ../map/src/mapGetOrDefault.ts
|
|
141
|
-
function mapGetOrDefault(map, key, factory) {
|
|
142
|
-
let value = map.get(key);
|
|
143
|
-
if (value !== void 0 || map.has(key)) {
|
|
144
|
-
return value;
|
|
145
|
-
}
|
|
146
|
-
value = factory(key, map);
|
|
147
|
-
map.set(key, value);
|
|
148
|
-
return value;
|
|
149
|
-
}
|
|
150
|
-
__name(mapGetOrDefault, "mapGetOrDefault");
|
|
151
|
-
|
|
152
|
-
// ../map/src/TimeoutWeakMap.ts
|
|
153
|
-
var TimeoutWeakMap = class {
|
|
154
|
-
static {
|
|
155
|
-
__name(this, "TimeoutWeakMap");
|
|
156
|
-
}
|
|
157
|
-
timeoutMs;
|
|
158
|
-
wmap = /* @__PURE__ */ new WeakMap();
|
|
159
|
-
/**
|
|
160
|
-
* @param timeoutMs Default timeout in milliseconds for entries
|
|
161
|
-
*/
|
|
162
|
-
constructor(timeoutMs) {
|
|
163
|
-
this.timeoutMs = timeoutMs;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Retrieves the value for the given key and refreshes its timeout.
|
|
167
|
-
*
|
|
168
|
-
* @param key The key to retrieve
|
|
169
|
-
* @returns The value if found, undefined otherwise
|
|
170
|
-
*/
|
|
171
|
-
get(key) {
|
|
172
|
-
const vt = this.wmap.get(key);
|
|
173
|
-
if (!vt) {
|
|
174
|
-
return void 0;
|
|
175
|
-
}
|
|
176
|
-
const [value, timeout] = vt;
|
|
177
|
-
timeout.refresh();
|
|
178
|
-
return value;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Sets a key-value pair with an optional custom timeout.
|
|
182
|
-
*
|
|
183
|
-
* @param key The key to set
|
|
184
|
-
* @param value The value to associate with the key
|
|
185
|
-
* @param timeoutMs Optional timeout override for this entry
|
|
186
|
-
* @returns This instance for chaining
|
|
187
|
-
*/
|
|
188
|
-
set(key, value, timeoutMs) {
|
|
189
|
-
this.wmap.set(key, [
|
|
190
|
-
value,
|
|
191
|
-
setTimeout(() => {
|
|
192
|
-
this.delete(key);
|
|
193
|
-
}, timeoutMs ?? this.timeoutMs).unref()
|
|
194
|
-
]);
|
|
195
|
-
return this;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Removes a key-value pair and clears its timeout.
|
|
199
|
-
*
|
|
200
|
-
* @param key The key to delete
|
|
201
|
-
* @returns True if the key existed and was deleted, false otherwise
|
|
202
|
-
*/
|
|
203
|
-
delete(key) {
|
|
204
|
-
const vt = this.wmap.get(key);
|
|
205
|
-
if (!vt) {
|
|
206
|
-
return false;
|
|
207
|
-
}
|
|
208
|
-
const timeout = vt[1];
|
|
209
|
-
clearTimeout(timeout);
|
|
210
|
-
return this.wmap.delete(key);
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Checks if a key exists in the map.
|
|
214
|
-
* Does not refresh the timeout.
|
|
215
|
-
*
|
|
216
|
-
* @param key The key to check
|
|
217
|
-
* @returns True if the key exists, false otherwise
|
|
218
|
-
*/
|
|
219
|
-
has(key) {
|
|
220
|
-
return this.wmap.has(key);
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Loads multiple key-value pairs into the map.
|
|
224
|
-
*
|
|
225
|
-
* @param entries Iterable of key-value pairs to load
|
|
226
|
-
* @param timeoutMs Optional timeout override for all entries
|
|
227
|
-
* @returns This instance for chaining
|
|
228
|
-
*/
|
|
229
|
-
load(entries, timeoutMs) {
|
|
230
|
-
for (const [key, value] of entries) {
|
|
231
|
-
this.set(key, value, timeoutMs);
|
|
232
|
-
}
|
|
233
|
-
return this;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Updates an existing value or creates a new one using an update function.
|
|
237
|
-
*
|
|
238
|
-
* @param key The key to update
|
|
239
|
-
* @param update Function that receives the current value and returns the new value
|
|
240
|
-
* @returns This instance for chaining
|
|
241
|
-
*/
|
|
242
|
-
update(key, update) {
|
|
243
|
-
return this.set(key, update(this.get(key), key, this));
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Gets a value or creates it using a factory function if it doesn't exist.
|
|
247
|
-
* Refreshes timeout if the value exists.
|
|
248
|
-
*
|
|
249
|
-
* @param key The key to get or create
|
|
250
|
-
* @param factory Function to create the value if it doesn't exist
|
|
251
|
-
* @param timeoutMs Optional timeout override for new entries
|
|
252
|
-
* @returns The existing or newly created value
|
|
253
|
-
*/
|
|
254
|
-
getOrDefault(key, factory, timeoutMs) {
|
|
255
|
-
const vt = this.wmap.get(key);
|
|
256
|
-
if (vt) {
|
|
257
|
-
const [value, timeout] = vt;
|
|
258
|
-
timeout.refresh();
|
|
259
|
-
return value;
|
|
260
|
-
} else {
|
|
261
|
-
const value = factory(key, this);
|
|
262
|
-
this.set(key, value, timeoutMs);
|
|
263
|
-
return value;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
|
|
268
141
|
// ../composition/src/inspector/defaults/ignoreValuesFilterDefaults.ts
|
|
269
142
|
var ignoreValuesFilterDefaults = {
|
|
270
143
|
noFalse: /* @__PURE__ */ __name((value) => {
|
|
@@ -375,7 +248,7 @@ var Inspector = class _Inspector extends View {
|
|
|
375
248
|
const { output, inspectOptions } = this.compile(depth);
|
|
376
249
|
Object.assign(inspectOptions, options);
|
|
377
250
|
const result = inspect(output, options);
|
|
378
|
-
return result.
|
|
251
|
+
return result.replaceAll(/Object \[\w+] {/gm, (match) => {
|
|
379
252
|
match = match.substring(8, match.length - 3);
|
|
380
253
|
return `[${inspectOptions.colors ? colors2.magenta(match) : match}] {`;
|
|
381
254
|
});
|
|
@@ -795,8 +668,8 @@ var SemanticExtnamePrefix = {
|
|
|
795
668
|
wip: "wip"
|
|
796
669
|
};
|
|
797
670
|
|
|
798
|
-
// ../fn/src/
|
|
799
|
-
function
|
|
671
|
+
// ../fn/src/setNameAndLength.ts
|
|
672
|
+
function setNameAndLength(source, target, lengthDelta = 0) {
|
|
800
673
|
return Object.defineProperties(target, {
|
|
801
674
|
name: {
|
|
802
675
|
configurable: true,
|
|
@@ -804,15 +677,15 @@ function preserveNameAndLength(source, target, adjustLengthBy = 0) {
|
|
|
804
677
|
},
|
|
805
678
|
length: {
|
|
806
679
|
configurable: true,
|
|
807
|
-
value: source.length +
|
|
680
|
+
value: source.length + lengthDelta
|
|
808
681
|
}
|
|
809
682
|
});
|
|
810
683
|
}
|
|
811
|
-
__name(
|
|
684
|
+
__name(setNameAndLength, "setNameAndLength");
|
|
812
685
|
|
|
813
686
|
// ../fn/src/bindArg.ts
|
|
814
687
|
function bindArg(fn, boundArgIndex, boundArgValue) {
|
|
815
|
-
return
|
|
688
|
+
return setNameAndLength(fn, (...args) => {
|
|
816
689
|
return fn(...args.slice(0, boundArgIndex), boundArgValue, ...args.slice(boundArgIndex));
|
|
817
690
|
}, -1);
|
|
818
691
|
}
|
|
@@ -873,6 +746,134 @@ function assertDescriptorValueIsFunction(key, descriptor) {
|
|
|
873
746
|
}
|
|
874
747
|
}
|
|
875
748
|
__name(assertDescriptorValueIsFunction, "assertDescriptorValueIsFunction");
|
|
749
|
+
|
|
750
|
+
// ../map/src/mapGetOrDefault.ts
|
|
751
|
+
function mapGetOrDefault(map, key, factory) {
|
|
752
|
+
let value = map.get(key);
|
|
753
|
+
if (value !== void 0 || map.has(key)) {
|
|
754
|
+
return value;
|
|
755
|
+
}
|
|
756
|
+
value = factory(key, map);
|
|
757
|
+
map.set(key, value);
|
|
758
|
+
return value;
|
|
759
|
+
}
|
|
760
|
+
__name(mapGetOrDefault, "mapGetOrDefault");
|
|
761
|
+
|
|
762
|
+
// ../map/src/TimeoutWeakMap.ts
|
|
763
|
+
var TimeoutWeakMap = class {
|
|
764
|
+
static {
|
|
765
|
+
__name(this, "TimeoutWeakMap");
|
|
766
|
+
}
|
|
767
|
+
timeoutMs;
|
|
768
|
+
wmap = /* @__PURE__ */ new WeakMap();
|
|
769
|
+
/**
|
|
770
|
+
* @param timeoutMs Default timeout in milliseconds for entries
|
|
771
|
+
*/
|
|
772
|
+
constructor(timeoutMs) {
|
|
773
|
+
this.timeoutMs = timeoutMs;
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* Retrieves the value for the given key and refreshes its timeout.
|
|
777
|
+
*
|
|
778
|
+
* @param key The key to retrieve
|
|
779
|
+
* @returns The value if found, undefined otherwise
|
|
780
|
+
*/
|
|
781
|
+
get(key) {
|
|
782
|
+
const vt = this.wmap.get(key);
|
|
783
|
+
if (!vt) {
|
|
784
|
+
return void 0;
|
|
785
|
+
}
|
|
786
|
+
const [value, timeout] = vt;
|
|
787
|
+
timeout.refresh();
|
|
788
|
+
return value;
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* Sets a key-value pair with an optional custom timeout.
|
|
792
|
+
*
|
|
793
|
+
* @param key The key to set
|
|
794
|
+
* @param value The value to associate with the key
|
|
795
|
+
* @param timeoutMs Optional timeout override for this entry
|
|
796
|
+
* @returns This instance for chaining
|
|
797
|
+
*/
|
|
798
|
+
set(key, value, timeoutMs) {
|
|
799
|
+
this.wmap.set(key, [
|
|
800
|
+
value,
|
|
801
|
+
setTimeout(() => {
|
|
802
|
+
this.delete(key);
|
|
803
|
+
}, timeoutMs ?? this.timeoutMs).unref()
|
|
804
|
+
]);
|
|
805
|
+
return this;
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Removes a key-value pair and clears its timeout.
|
|
809
|
+
*
|
|
810
|
+
* @param key The key to delete
|
|
811
|
+
* @returns True if the key existed and was deleted, false otherwise
|
|
812
|
+
*/
|
|
813
|
+
delete(key) {
|
|
814
|
+
const vt = this.wmap.get(key);
|
|
815
|
+
if (!vt) {
|
|
816
|
+
return false;
|
|
817
|
+
}
|
|
818
|
+
const timeout = vt[1];
|
|
819
|
+
clearTimeout(timeout);
|
|
820
|
+
return this.wmap.delete(key);
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Checks if a key exists in the map.
|
|
824
|
+
* Does not refresh the timeout.
|
|
825
|
+
*
|
|
826
|
+
* @param key The key to check
|
|
827
|
+
* @returns True if the key exists, false otherwise
|
|
828
|
+
*/
|
|
829
|
+
has(key) {
|
|
830
|
+
return this.wmap.has(key);
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Loads multiple key-value pairs into the map.
|
|
834
|
+
*
|
|
835
|
+
* @param entries Iterable of key-value pairs to load
|
|
836
|
+
* @param timeoutMs Optional timeout override for all entries
|
|
837
|
+
* @returns This instance for chaining
|
|
838
|
+
*/
|
|
839
|
+
load(entries, timeoutMs) {
|
|
840
|
+
for (const [key, value] of entries) {
|
|
841
|
+
this.set(key, value, timeoutMs);
|
|
842
|
+
}
|
|
843
|
+
return this;
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Updates an existing value or creates a new one using an update function.
|
|
847
|
+
*
|
|
848
|
+
* @param key The key to update
|
|
849
|
+
* @param update Function that receives the current value and returns the new value
|
|
850
|
+
* @returns This instance for chaining
|
|
851
|
+
*/
|
|
852
|
+
update(key, update) {
|
|
853
|
+
return this.set(key, update(this.get(key), key, this));
|
|
854
|
+
}
|
|
855
|
+
/**
|
|
856
|
+
* Gets a value or creates it using a factory function if it doesn't exist.
|
|
857
|
+
* Refreshes timeout if the value exists.
|
|
858
|
+
*
|
|
859
|
+
* @param key The key to get or create
|
|
860
|
+
* @param factory Function to create the value if it doesn't exist
|
|
861
|
+
* @param timeoutMs Optional timeout override for new entries
|
|
862
|
+
* @returns The existing or newly created value
|
|
863
|
+
*/
|
|
864
|
+
getOrDefault(key, factory, timeoutMs) {
|
|
865
|
+
const vt = this.wmap.get(key);
|
|
866
|
+
if (vt) {
|
|
867
|
+
const [value, timeout] = vt;
|
|
868
|
+
timeout.refresh();
|
|
869
|
+
return value;
|
|
870
|
+
} else {
|
|
871
|
+
const value = factory(key, this);
|
|
872
|
+
this.set(key, value, timeoutMs);
|
|
873
|
+
return value;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
};
|
|
876
877
|
function memoizeSync(arg = {}) {
|
|
877
878
|
const opts = typeof arg === "object" ? arg : {
|
|
878
879
|
maxAge: typeof arg === "number" ? arg : ms(arg)
|
|
@@ -1178,7 +1179,7 @@ var ImportSpecifiers = class _ImportSpecifiers extends CodeBlock {
|
|
|
1178
1179
|
autoAddBooleanKeys: false
|
|
1179
1180
|
});
|
|
1180
1181
|
get codeWithoutTypeKeyword() {
|
|
1181
|
-
return this.code.
|
|
1182
|
+
return this.code.replaceAll(/\s*\btype\b\s*/g, " ");
|
|
1182
1183
|
}
|
|
1183
1184
|
get type() {
|
|
1184
1185
|
if (this.isMixedImport) {
|
|
@@ -1193,19 +1194,19 @@ var ImportSpecifiers = class _ImportSpecifiers extends CodeBlock {
|
|
|
1193
1194
|
return "default";
|
|
1194
1195
|
}
|
|
1195
1196
|
get isDefaultImport() {
|
|
1196
|
-
return /[
|
|
1197
|
+
return /[$A-Z_a-z][\w$]*/.test(this.codeWithoutTypeKeyword) && !this.isNamespaceImport;
|
|
1197
1198
|
}
|
|
1198
1199
|
get isNamedImport() {
|
|
1199
|
-
return
|
|
1200
|
+
return /{[^}]+}/.test(this.codeWithoutTypeKeyword);
|
|
1200
1201
|
}
|
|
1201
1202
|
get isMixedImport() {
|
|
1202
|
-
return /([
|
|
1203
|
+
return /([$A-Z_a-z][\w$]*),\s*{[^}]+}/.test(this.codeWithoutTypeKeyword);
|
|
1203
1204
|
}
|
|
1204
1205
|
get isNamespaceImport() {
|
|
1205
|
-
return /\*\s+as\s+([
|
|
1206
|
+
return /\*\s+as\s+([$A-Z_a-z][\w$]*)/.test(this.codeWithoutTypeKeyword);
|
|
1206
1207
|
}
|
|
1207
1208
|
get namedImportsArray() {
|
|
1208
|
-
return this.code.replace("\n", " ").match(
|
|
1209
|
+
return this.code.replace("\n", " ").match(/{([^}]+)}/)?.[1].split(",").map((specifier) => {
|
|
1209
1210
|
return specifier.trim();
|
|
1210
1211
|
}).filter((s) => {
|
|
1211
1212
|
return !!s;
|
|
@@ -1228,15 +1229,15 @@ var ImportSpecifiers = class _ImportSpecifiers extends CodeBlock {
|
|
|
1228
1229
|
get importedNamesArray() {
|
|
1229
1230
|
return this.codeWithoutTypeKeyword.replace(/[\w*]+ as \w+/, (m) => {
|
|
1230
1231
|
return m.split(" as ")[1];
|
|
1231
|
-
}).
|
|
1232
|
+
}).replaceAll(/[{}]/g, " ").split(",").map((s) => {
|
|
1232
1233
|
return s.trim();
|
|
1233
1234
|
}).filter(Boolean);
|
|
1234
1235
|
}
|
|
1235
1236
|
get defaultImport() {
|
|
1236
|
-
return this.codeWithoutTypeKeyword.match(/^([
|
|
1237
|
+
return this.codeWithoutTypeKeyword.match(/^([$A-Z_a-z][\w$]*)\s*(,|)/)?.[1] || void 0;
|
|
1237
1238
|
}
|
|
1238
1239
|
get namespaceImport() {
|
|
1239
|
-
return this.codeWithoutTypeKeyword.match(/^\*\s+as\s+([
|
|
1240
|
+
return this.codeWithoutTypeKeyword.match(/^\*\s+as\s+([$A-Z_a-z][\w$]*)/)?.[1] || void 0;
|
|
1240
1241
|
}
|
|
1241
1242
|
get hasNamedImport() {
|
|
1242
1243
|
return !!this.namedImportsArray.length;
|
|
@@ -1378,7 +1379,7 @@ var ImportStatement = class _ImportStatement extends CodeBlock {
|
|
|
1378
1379
|
}
|
|
1379
1380
|
});
|
|
1380
1381
|
toOneLine() {
|
|
1381
|
-
return this.code.
|
|
1382
|
+
return this.code.replaceAll(/\r?\n/g, " ").replaceAll(/\s{2,}/g, " ").replace(/,\s+}/, " }");
|
|
1382
1383
|
}
|
|
1383
1384
|
get keywords() {
|
|
1384
1385
|
const match = this.code.match(/^import\s+(?:type\s+)?/);
|
|
@@ -1386,15 +1387,15 @@ var ImportStatement = class _ImportStatement extends CodeBlock {
|
|
|
1386
1387
|
return new ImportKeywords(this, this.codeIndexRangeOf(code));
|
|
1387
1388
|
}
|
|
1388
1389
|
get specifiers() {
|
|
1389
|
-
const match = this.code.match(/import\s+([^'
|
|
1390
|
+
const match = this.code.match(/import\s+([^"']+)\s+from\s+/);
|
|
1390
1391
|
const code = match ? match[1].trim() : "";
|
|
1391
1392
|
if (!code) {
|
|
1392
|
-
return
|
|
1393
|
+
return;
|
|
1393
1394
|
}
|
|
1394
1395
|
return new ImportSpecifiers(this, this.codeIndexRangeOf(code));
|
|
1395
1396
|
}
|
|
1396
1397
|
get module() {
|
|
1397
|
-
const match = this.code.match(/(?:from|import)\s+['
|
|
1398
|
+
const match = this.code.match(/(?:from|import)\s+["']([^"']+)["']/);
|
|
1398
1399
|
const code = match[1].trim();
|
|
1399
1400
|
return new ModuleSpecifier(this, this.codeIndexRangeOf(code));
|
|
1400
1401
|
}
|
|
@@ -1428,12 +1429,6 @@ ImportStatement = _ts_decorate9([
|
|
|
1428
1429
|
Parenting.compose
|
|
1429
1430
|
], ImportStatement);
|
|
1430
1431
|
|
|
1431
|
-
// ../array/src/lib/arrRemoveDuplicates.ts
|
|
1432
|
-
function arrRemoveDuplicates(array) {
|
|
1433
|
-
return Array.from(new Set(array));
|
|
1434
|
-
}
|
|
1435
|
-
__name(arrRemoveDuplicates, "arrRemoveDuplicates");
|
|
1436
|
-
|
|
1437
1432
|
// ../regex/src/rexec.ts
|
|
1438
1433
|
function rexec(regex, string) {
|
|
1439
1434
|
regex = new RegExp(regex.source, regex.flags);
|
|
@@ -1464,13 +1459,13 @@ function findLineColumn(content, index) {
|
|
|
1464
1459
|
}
|
|
1465
1460
|
__name(findLineColumn, "findLineColumn");
|
|
1466
1461
|
function importStatementToOneLiner(code) {
|
|
1467
|
-
return strip(code).
|
|
1462
|
+
return strip(code).replaceAll(/\r*\n/g, " ").replaceAll(/\s+/g, " ").replace(/,\s*}/, " }").replaceAll(/\s*,\s*/g, ", ").replaceAll(/\s+/g, " ").trim();
|
|
1468
1463
|
}
|
|
1469
1464
|
__name(importStatementToOneLiner, "importStatementToOneLiner");
|
|
1470
1465
|
|
|
1471
1466
|
// ../tscode/src/tsCrlfToLf.ts
|
|
1472
1467
|
function tsCrlfToLf(code) {
|
|
1473
|
-
return code.
|
|
1468
|
+
return code.replaceAll(/\r+\n/g, "\n");
|
|
1474
1469
|
}
|
|
1475
1470
|
__name(tsCrlfToLf, "tsCrlfToLf");
|
|
1476
1471
|
|
|
@@ -1480,14 +1475,13 @@ function tsExtractImports(code) {
|
|
|
1480
1475
|
code = replaceImportStatementsInsideLiteralStrings(code);
|
|
1481
1476
|
code = replaceImportStatementsInsideBlockComments(code);
|
|
1482
1477
|
const isFirstLine = /^import /;
|
|
1483
|
-
const isFirstLineInMulti =
|
|
1484
|
-
const isLastLineInMulti =
|
|
1478
|
+
const isFirstLineInMulti = /{\s*$/;
|
|
1479
|
+
const isLastLineInMulti = /^} from ["']/;
|
|
1485
1480
|
const result = [];
|
|
1486
1481
|
let isMulti = false;
|
|
1487
1482
|
let impLines = [];
|
|
1488
1483
|
const lines = code.split(/\r?\n/);
|
|
1489
|
-
for (
|
|
1490
|
-
const line = lines[l];
|
|
1484
|
+
for (const [l, line] of lines.entries()) {
|
|
1491
1485
|
if (isFirstLine.test(line)) {
|
|
1492
1486
|
if (isFirstLineInMulti.test(line)) {
|
|
1493
1487
|
impLines.push(line);
|
|
@@ -1522,19 +1516,17 @@ function tsExtractImports(code) {
|
|
|
1522
1516
|
}
|
|
1523
1517
|
__name(tsExtractImports, "tsExtractImports");
|
|
1524
1518
|
function replaceImportStatementsInsideLiteralStrings(code) {
|
|
1525
|
-
return code.
|
|
1526
|
-
return match.
|
|
1519
|
+
return code.replaceAll(/(["'`])(.*?)\1/gs, (match) => {
|
|
1520
|
+
return match.replaceAll(/\nimport /gs, "\nIMPORT ");
|
|
1527
1521
|
});
|
|
1528
1522
|
}
|
|
1529
1523
|
__name(replaceImportStatementsInsideLiteralStrings, "replaceImportStatementsInsideLiteralStrings");
|
|
1530
1524
|
function replaceImportStatementsInsideBlockComments(code) {
|
|
1531
|
-
return code.
|
|
1532
|
-
return match.
|
|
1525
|
+
return code.replaceAll(/\/\*(.*?)\*\//gs, (match) => {
|
|
1526
|
+
return match.replaceAll(/\nimport /gs, "\nIMPORT ");
|
|
1533
1527
|
});
|
|
1534
1528
|
}
|
|
1535
1529
|
__name(replaceImportStatementsInsideBlockComments, "replaceImportStatementsInsideBlockComments");
|
|
1536
|
-
|
|
1537
|
-
// src/code/TsCode.ts
|
|
1538
1530
|
function _ts_decorate10(decorators, target, key, desc) {
|
|
1539
1531
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1540
1532
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1572,7 +1564,7 @@ var TsCode = class _TsCode extends AbstractCode {
|
|
|
1572
1564
|
return this.requireRegex.test(line);
|
|
1573
1565
|
});
|
|
1574
1566
|
}
|
|
1575
|
-
return
|
|
1567
|
+
return uniq(Array.from(this.code.matchAll(this.requireRegex)).map((o) => {
|
|
1576
1568
|
return o[1];
|
|
1577
1569
|
}));
|
|
1578
1570
|
}
|
|
@@ -1595,7 +1587,7 @@ var TsCode = class _TsCode extends AbstractCode {
|
|
|
1595
1587
|
}).filter(Boolean).sort();
|
|
1596
1588
|
}
|
|
1597
1589
|
get requireRegex() {
|
|
1598
|
-
return /require\(['
|
|
1590
|
+
return /require\(["'](.+)["']\)/g;
|
|
1599
1591
|
}
|
|
1600
1592
|
};
|
|
1601
1593
|
_ts_decorate10([
|
|
@@ -1702,13 +1694,9 @@ function walkDirectory(dirpath, options) {
|
|
|
1702
1694
|
stats
|
|
1703
1695
|
];
|
|
1704
1696
|
});
|
|
1705
|
-
|
|
1706
|
-
return
|
|
1707
|
-
}
|
|
1708
|
-
return entries.map(([fspath]) => {
|
|
1709
|
-
return fspath;
|
|
1710
|
-
});
|
|
1711
|
-
}
|
|
1697
|
+
return options.stats ? entries : entries.map(([fspath]) => {
|
|
1698
|
+
return fspath;
|
|
1699
|
+
});
|
|
1712
1700
|
}
|
|
1713
1701
|
__name(walkDirectory, "walkDirectory");
|
|
1714
1702
|
function convertToWalkdirOptions(options) {
|
|
@@ -1816,25 +1804,21 @@ var Workspace = class _Workspace extends AbstractBase {
|
|
|
1816
1804
|
*/
|
|
1817
1805
|
get importedDependenciesRecursive() {
|
|
1818
1806
|
const repo = this.parent;
|
|
1819
|
-
const wsNames = repo.workspaces.map((w) => {
|
|
1807
|
+
const wsNames = new Set(repo.workspaces.map((w) => {
|
|
1820
1808
|
return w.name;
|
|
1821
|
-
});
|
|
1809
|
+
}));
|
|
1822
1810
|
const allDeps = recurse(this.tsFiles.filter((f) => {
|
|
1823
1811
|
return f.isSourceFile;
|
|
1824
1812
|
}));
|
|
1825
1813
|
const internal = [
|
|
1826
1814
|
...allDeps
|
|
1827
1815
|
].filter((d) => {
|
|
1828
|
-
return wsNames.
|
|
1829
|
-
return name === d;
|
|
1830
|
-
});
|
|
1816
|
+
return wsNames.has(d);
|
|
1831
1817
|
}).sort();
|
|
1832
1818
|
const external = [
|
|
1833
1819
|
...allDeps
|
|
1834
1820
|
].filter((d) => {
|
|
1835
|
-
return !wsNames.
|
|
1836
|
-
return name === d;
|
|
1837
|
-
});
|
|
1821
|
+
return !wsNames.has(d);
|
|
1838
1822
|
}).sort();
|
|
1839
1823
|
function recurse(files, allDeps2 = /* @__PURE__ */ new Set(), visited = /* @__PURE__ */ new Set(), depth = 0) {
|
|
1840
1824
|
for (const file of files) {
|
|
@@ -1947,13 +1931,13 @@ var Workspace = class _Workspace extends AbstractBase {
|
|
|
1947
1931
|
* Get imported non-relative dependencies for each source file in the workspace in a flat array.
|
|
1948
1932
|
*/
|
|
1949
1933
|
get importedDependencies() {
|
|
1950
|
-
return
|
|
1934
|
+
return uniq(Array.from(this.importedDependenciesByFile.values()).flat());
|
|
1951
1935
|
}
|
|
1952
1936
|
/**
|
|
1953
1937
|
* Get imported non-relative dependencies for each test file in the workspace in a flat array.
|
|
1954
1938
|
*/
|
|
1955
1939
|
get importedTestDependencies() {
|
|
1956
|
-
return
|
|
1940
|
+
return uniq(Array.from(this.importedTestDependenciesByFile.values()).flat());
|
|
1957
1941
|
}
|
|
1958
1942
|
/**
|
|
1959
1943
|
* Get dependencies that are imported but not listed in the workspace's package.json under 'dependencies'.
|
|
@@ -2173,7 +2157,7 @@ var MonoRepo = class _MonoRepo extends AbstractBase {
|
|
|
2173
2157
|
});
|
|
2174
2158
|
}
|
|
2175
2159
|
get workspacePaths() {
|
|
2176
|
-
return this.workspacesRootPaths.
|
|
2160
|
+
return this.workspacesRootPaths.flatMap((workspacePath) => {
|
|
2177
2161
|
return fs.readdirSync(workspacePath, {
|
|
2178
2162
|
withFileTypes: true
|
|
2179
2163
|
}).filter((dirent) => {
|
|
@@ -2181,7 +2165,7 @@ var MonoRepo = class _MonoRepo extends AbstractBase {
|
|
|
2181
2165
|
}).map((dirent) => {
|
|
2182
2166
|
return path2.join(workspacePath, dirent.name);
|
|
2183
2167
|
});
|
|
2184
|
-
})
|
|
2168
|
+
});
|
|
2185
2169
|
}
|
|
2186
2170
|
get workspaces() {
|
|
2187
2171
|
return this.workspacePaths.map((dirpath) => {
|
|
@@ -2313,15 +2297,22 @@ __name(getWorkspaceDirpaths, "getWorkspaceDirpaths");
|
|
|
2313
2297
|
// src/util/semverVersionBump.ts
|
|
2314
2298
|
function semverVersionBump(version, level) {
|
|
2315
2299
|
const arr = (typeof version === "string" ? version.split(".") : version).map(Number);
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2300
|
+
switch (level) {
|
|
2301
|
+
case "major": {
|
|
2302
|
+
arr[0] += 1;
|
|
2303
|
+
arr[1] = 0;
|
|
2304
|
+
arr[2] = 0;
|
|
2305
|
+
break;
|
|
2306
|
+
}
|
|
2307
|
+
case "minor": {
|
|
2308
|
+
arr[1] += 1;
|
|
2309
|
+
arr[2] = 0;
|
|
2310
|
+
break;
|
|
2311
|
+
}
|
|
2312
|
+
case "patch": {
|
|
2313
|
+
arr[2] += 1;
|
|
2314
|
+
break;
|
|
2315
|
+
}
|
|
2325
2316
|
}
|
|
2326
2317
|
return arr.join(".");
|
|
2327
2318
|
}
|