@bemoje/monorepo 1.1.1 → 1.2.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.
Files changed (127) hide show
  1. package/lib/MonoRepo.cjs +7370 -0
  2. package/lib/MonoRepo.d.cts +10 -0
  3. package/lib/MonoRepo.d.ts +10 -0
  4. package/lib/MonoRepo.js +7361 -0
  5. package/lib/code/AbstractCode.cjs +5568 -0
  6. package/lib/code/AbstractCode.d.cts +30 -0
  7. package/lib/code/AbstractCode.d.ts +30 -0
  8. package/lib/code/AbstractCode.js +5562 -0
  9. package/lib/code/CodeBlock.cjs +5614 -0
  10. package/lib/code/CodeBlock.d.cts +22 -0
  11. package/lib/code/CodeBlock.d.ts +22 -0
  12. package/lib/code/CodeBlock.js +5608 -0
  13. package/lib/code/TsCode.cjs +7370 -0
  14. package/lib/code/TsCode.d.cts +10 -0
  15. package/lib/code/TsCode.d.ts +10 -0
  16. package/lib/code/TsCode.js +7361 -0
  17. package/lib/code/imports/ImportKeywords.cjs +5652 -0
  18. package/lib/code/imports/ImportKeywords.d.cts +10 -0
  19. package/lib/code/imports/ImportKeywords.d.ts +10 -0
  20. package/lib/code/imports/ImportKeywords.js +5646 -0
  21. package/lib/code/imports/ImportSpecifiers.cjs +5708 -0
  22. package/lib/code/imports/ImportSpecifiers.d.cts +10 -0
  23. package/lib/code/imports/ImportSpecifiers.d.ts +10 -0
  24. package/lib/code/imports/ImportSpecifiers.js +5702 -0
  25. package/lib/code/imports/ImportStatement.cjs +7372 -0
  26. package/lib/code/imports/ImportStatement.d.cts +10 -0
  27. package/lib/code/imports/ImportStatement.d.ts +10 -0
  28. package/lib/code/imports/ImportStatement.js +7363 -0
  29. package/lib/code/imports/ModuleSpecifier.cjs +7372 -0
  30. package/lib/code/imports/ModuleSpecifier.d.cts +10 -0
  31. package/lib/code/imports/ModuleSpecifier.d.ts +10 -0
  32. package/lib/code/imports/ModuleSpecifier.js +7363 -0
  33. package/lib/common/AbstractBase.cjs +638 -0
  34. package/lib/common/AbstractBase.d.cts +3 -0
  35. package/lib/common/AbstractBase.d.ts +3 -0
  36. package/lib/common/AbstractBase.js +634 -0
  37. package/lib/file/File.cjs +5496 -0
  38. package/lib/file/File.d.cts +10 -0
  39. package/lib/file/File.d.ts +10 -0
  40. package/lib/file/File.js +5490 -0
  41. package/lib/file/TestFile.cjs +7368 -0
  42. package/lib/file/TestFile.d.cts +10 -0
  43. package/lib/file/TestFile.d.ts +10 -0
  44. package/lib/file/TestFile.js +7359 -0
  45. package/lib/file/TsFile.cjs +7368 -0
  46. package/lib/file/TsFile.d.cts +10 -0
  47. package/lib/file/TsFile.d.ts +10 -0
  48. package/lib/file/TsFile.js +7359 -0
  49. package/lib/index.cjs +7698 -0
  50. package/lib/index.d.cts +26 -0
  51. package/lib/index.d.ts +26 -0
  52. package/lib/index.js +7672 -0
  53. package/lib/methods/findWorkspacePackageName.cjs +86 -0
  54. package/lib/methods/findWorkspacePackageName.d.cts +6 -0
  55. package/lib/methods/findWorkspacePackageName.d.ts +6 -0
  56. package/lib/methods/findWorkspacePackageName.js +78 -0
  57. package/lib/methods/getAllImports.cjs +20 -0
  58. package/lib/methods/getAllImports.d.cts +17 -0
  59. package/lib/methods/getAllImports.d.ts +17 -0
  60. package/lib/methods/getAllImports.js +18 -0
  61. package/lib/methods/getAllWorkspacePackageJsonPaths.cjs +57 -0
  62. package/lib/methods/getAllWorkspacePackageJsonPaths.d.cts +6 -0
  63. package/lib/methods/getAllWorkspacePackageJsonPaths.d.ts +6 -0
  64. package/lib/methods/getAllWorkspacePackageJsonPaths.js +49 -0
  65. package/lib/methods/getAllWorkspacePackageJsons.cjs +66 -0
  66. package/lib/methods/getAllWorkspacePackageJsons.d.cts +6 -0
  67. package/lib/methods/getAllWorkspacePackageJsons.d.ts +6 -0
  68. package/lib/methods/getAllWorkspacePackageJsons.js +58 -0
  69. package/lib/methods/getAllWorkspacePackageNames.cjs +75 -0
  70. package/lib/methods/getAllWorkspacePackageNames.d.cts +6 -0
  71. package/lib/methods/getAllWorkspacePackageNames.d.ts +6 -0
  72. package/lib/methods/getAllWorkspacePackageNames.js +67 -0
  73. package/lib/methods/getAllWorkspacePaths.cjs +50 -0
  74. package/lib/methods/getAllWorkspacePaths.d.cts +6 -0
  75. package/lib/methods/getAllWorkspacePaths.d.ts +6 -0
  76. package/lib/methods/getAllWorkspacePaths.js +42 -0
  77. package/lib/methods/getImportsRecursively.cjs +7577 -0
  78. package/lib/methods/getImportsRecursively.d.cts +37 -0
  79. package/lib/methods/getImportsRecursively.d.ts +37 -0
  80. package/lib/methods/getImportsRecursively.js +7566 -0
  81. package/lib/methods/getRepoPackageJson.cjs +40 -0
  82. package/lib/methods/getRepoPackageJson.d.cts +6 -0
  83. package/lib/methods/getRepoPackageJson.d.ts +6 -0
  84. package/lib/methods/getRepoPackageJson.js +32 -0
  85. package/lib/methods/getRepoPackageJsonPath.cjs +34 -0
  86. package/lib/methods/getRepoPackageJsonPath.d.cts +6 -0
  87. package/lib/methods/getRepoPackageJsonPath.d.ts +6 -0
  88. package/lib/methods/getRepoPackageJsonPath.js +26 -0
  89. package/lib/repo/Workspace.cjs +7370 -0
  90. package/lib/repo/Workspace.d.cts +10 -0
  91. package/lib/repo/Workspace.d.ts +10 -0
  92. package/lib/repo/Workspace.js +7361 -0
  93. package/lib/util/SemanticExtnamePrefix.cjs +13 -0
  94. package/lib/util/SemanticExtnamePrefix.d.cts +14 -0
  95. package/lib/util/SemanticExtnamePrefix.d.ts +14 -0
  96. package/lib/util/SemanticExtnamePrefix.js +11 -0
  97. package/lib/util/SemanticExtnamePrefixDescriptions.cjs +13 -0
  98. package/lib/util/SemanticExtnamePrefixDescriptions.d.cts +15 -0
  99. package/lib/util/SemanticExtnamePrefixDescriptions.d.ts +15 -0
  100. package/lib/util/SemanticExtnamePrefixDescriptions.js +11 -0
  101. package/lib/util/SemanticExtnamePrefixes.cjs +18 -0
  102. package/lib/util/SemanticExtnamePrefixes.d.cts +97 -0
  103. package/lib/util/SemanticExtnamePrefixes.d.ts +97 -0
  104. package/lib/util/SemanticExtnamePrefixes.js +14 -0
  105. package/lib/util/getRepoRootDirpath.cjs +30 -0
  106. package/lib/util/getRepoRootDirpath.d.cts +6 -0
  107. package/lib/util/getRepoRootDirpath.d.ts +6 -0
  108. package/lib/util/getRepoRootDirpath.js +22 -0
  109. package/lib/util/getWorkspaceDirpaths.cjs +42 -0
  110. package/lib/util/getWorkspaceDirpaths.d.cts +6 -0
  111. package/lib/util/getWorkspaceDirpaths.d.ts +6 -0
  112. package/lib/util/getWorkspaceDirpaths.js +34 -0
  113. package/lib/util/hasExtnamePrefix.cjs +27 -0
  114. package/lib/util/hasExtnamePrefix.d.cts +38 -0
  115. package/lib/util/hasExtnamePrefix.d.ts +38 -0
  116. package/lib/util/hasExtnamePrefix.js +25 -0
  117. package/lib/util/resolveModuleImportPath.cjs +51 -0
  118. package/lib/util/resolveModuleImportPath.d.cts +8 -0
  119. package/lib/util/resolveModuleImportPath.d.ts +8 -0
  120. package/lib/util/resolveModuleImportPath.js +42 -0
  121. package/lib/util/semverVersionBump.cjs +30 -0
  122. package/lib/util/semverVersionBump.d.cts +22 -0
  123. package/lib/util/semverVersionBump.d.ts +22 -0
  124. package/lib/util/semverVersionBump.js +28 -0
  125. package/package.json +464 -31
  126. package/index.d.ts +0 -636
  127. package/index.mjs +0 -2321
package/index.d.ts DELETED
@@ -1,636 +0,0 @@
1
- import { SetFieldType, TsConfigJson, Arrayable } from 'type-fest';
2
- import { InspectOptions, inspect } from 'node:util';
3
- import { MultiSet, DefaultMap } from 'mnemonist';
4
- import * as typescript from 'typescript';
5
- import { CompilerOptions } from 'typescript';
6
- import { Results } from 'depcheck';
7
- import { Stats } from 'node:fs';
8
-
9
- /**
10
- * Interface for a View that wraps a target object.
11
- * View methods are redirected to the wrapped object which acts as
12
- * a surrogate 'this'.
13
- *
14
- * To create a method that redirects to 'target', @see {@link defineProxifiedPrototypeProperty}
15
- */
16
- interface IView<T extends object> {
17
- readonly target: T;
18
- }
19
-
20
- declare const TARGET_SYMBOL: unique symbol;
21
- /**
22
- * Base class providing view functionality over a target object using the Composition pattern.
23
- */
24
- declare class View<Target extends object> implements IView<Target> {
25
- private [TARGET_SYMBOL];
26
- constructor(target: Target);
27
- get [Symbol.toStringTag](): string;
28
- get target(): Target;
29
- }
30
-
31
- interface InspectorOptions {
32
- inspect?: InspectOptions;
33
- ignoreValues?: IgnoreValuesOptions;
34
- keys?: (string | symbol)[];
35
- autoAddBooleanKeys?: boolean;
36
- ignoreKeys?: (string | symbol)[];
37
- filters?: InspectFilter[];
38
- }
39
- interface IgnoreValuesOptions {
40
- noEmptyArray?: boolean;
41
- noEmptyObject?: boolean;
42
- noNull?: boolean;
43
- noUndefined?: boolean;
44
- noFalse?: boolean;
45
- }
46
- type InspectFilter = <T extends InspectorTarget>(this: T, value: unknown, key: string | symbol, depth: number, object: T) => boolean;
47
- type ClassInspectorMixin = typeof Function.prototype & {
48
- inspector: InspectorOptions;
49
- };
50
-
51
- /**
52
- * Interface that target objects must implement to be inspectable.
53
- * Provides standard inspection methods for debugging and serialization.
54
- */
55
- interface InspectorTarget {
56
- [inspect.custom](depth: number, options: InspectOptions): string;
57
- get inspector(): Inspector;
58
- toJSON(): Partial<this>;
59
- }
60
- /**
61
- * Inspector provides customizable object inspection and serialization using the Composition pattern.
62
- * Composes target classes with inspection capabilities, allowing selective property display and custom formatting.
63
- */
64
- declare class Inspector extends View<InspectorTarget> {
65
- /**
66
- * Composes a class with Inspector capabilities by adding inspection methods to its prototype.
67
- * This follows the Composition pattern to extend classes without inheritance.
68
- */
69
- static compose(cls: ClassInspectorMixin, options?: InspectorOptions): InspectorOptions;
70
- /**
71
- * Compile the target object and return the output as an object.
72
- */
73
- toObject(depth?: number): Partial<InspectorTarget>;
74
- /**
75
- * Inspect the target object.
76
- */
77
- inspect(depth?: number, options?: InspectOptions): string;
78
- /**
79
- * Compiles the output object and inspect options.
80
- * Merges prototype chain options and applies filters to determine which properties to include.
81
- */
82
- protected compile(depth?: number): {
83
- output: Partial<InspectorTarget>;
84
- inspectOptions: InspectOptions;
85
- };
86
- /**
87
- * Walks the prototype chain and merges Inspector options from all classes.
88
- * Subclass options override superclass options following inheritance semantics.
89
- */
90
- protected mergePrototypeOptions(): Required<InspectorOptions>;
91
- /**
92
- * Returns a deep clone of the default Inspector options.
93
- */
94
- protected getDefaults(): Required<InspectorOptions>;
95
- }
96
-
97
- type FunctionPrototype = typeof Function.prototype;
98
-
99
- interface PackageJson {
100
- name?: string;
101
- packageManager?: string;
102
- resolutions?: {
103
- [key: string]: string;
104
- };
105
- workspaces?: string[];
106
- version?: string;
107
- private?: boolean;
108
- description?: string;
109
- type?: string;
110
- main?: string;
111
- module?: string;
112
- typings?: string;
113
- types?: string;
114
- scripts?: {
115
- [key: string]: string;
116
- };
117
- repository?: {
118
- type: string;
119
- url: string;
120
- };
121
- keywords?: string[];
122
- author?: string;
123
- license?: string;
124
- bugs?: {
125
- url: string;
126
- };
127
- homepage?: string;
128
- dependencies?: {
129
- [key: string]: string;
130
- };
131
- devDependencies?: {
132
- [key: string]: string;
133
- };
134
- peerDependencies?: {
135
- [key: string]: string;
136
- };
137
- browserslist?: string[] | {
138
- [key: string]: string;
139
- };
140
- engines?: {
141
- node: string;
142
- npm?: string;
143
- yarn?: string;
144
- };
145
- funding?: {
146
- type: string;
147
- url: string;
148
- };
149
- preferGlobal?: boolean;
150
- bin?: string | {
151
- [key: string]: string;
152
- };
153
- }
154
-
155
- /**
156
- * Class that handles the parent-child relationships between objects on their behalf.
157
- *
158
- * In order to avoid circular references, all children keep a weak reference to their parent. However,
159
- * it is not guaranteed. Two objects could in principle mutually be both each other's parent and child
160
- * at the same time which would allow circular references to exist.
161
- */
162
- declare class Parenting<TP extends object | null = object | null> extends View<ParentingTarget<TP>> {
163
- /**
164
- * Class decorator to register and correctly initialize a class as a 'parentingTarget'.
165
- */
166
- static compose(cls: ParentingTargetConstructor): void;
167
- /**
168
- * Store a weak refences to the target object's parent.
169
- */
170
- onInstance(parent: TP | null): void;
171
- /**
172
- * Retrieve the parent object of 'target' object.
173
- */
174
- getParent(): TP;
175
- /**
176
- * Recursively get parent until no parent is found or a circular reference is detected.
177
- */
178
- iterateAncestors<T extends object | null = object | null>(): Generator<ParentingTarget<T>>;
179
- /**
180
- * The depth of the object in the parent-child hierarchy.
181
- */
182
- get depth(): number;
183
- /**
184
- * The class constructor of the target object.
185
- */
186
- get parentingTargetConstructor(): ParentingTargetConstructor;
187
- /**
188
- * A WeakMap for parent references.
189
- */
190
- private static readonly parentWeakRefMap;
191
- }
192
-
193
- interface ParentingTarget<P extends object | null = object | null> {
194
- get parenting(): Parenting<P>;
195
- }
196
- type ParentingTargetConstructor<P extends object | null = object | null> = {
197
- parenting?: ParentRelationTypes<P>;
198
- } & typeof Function.prototype;
199
-
200
- /**
201
- * Manages parent-child relationships between constructor types, tracking hierarchical connections and providing debugging capabilities.
202
- */
203
- declare class ParentRelationTypes<P extends object | null = object | null> extends View<ParentingTargetConstructor<P>> {
204
- registerParent(parentType: FunctionPrototype): void;
205
- get hasParent(): boolean;
206
- get getParentTypes(): MultiSet<FunctionPrototype>;
207
- get hasChildren(): boolean;
208
- get getChildTypes(): MultiSet<FunctionPrototype>;
209
- get isRoot(): boolean;
210
- get isLeaf(): boolean;
211
- get isIsolated(): boolean;
212
- static getAllChildTypesStats(): Record<string, Record<string, number>>;
213
- static getAllParentTypesStats(): Record<string, Record<string, number>>;
214
- static getAllStats(): any[];
215
- static printAllStats(): void;
216
- static childTypesStats: DefaultMap<Function, MultiSet<Function>>;
217
- static parentTypesStats: DefaultMap<Function, MultiSet<Function>>;
218
- }
219
-
220
- declare module './AbstractBase' {
221
- interface AbstractBase extends InspectorTarget {
222
- }
223
- interface AbstractBase<P extends object | null> extends ParentingTarget<P> {
224
- }
225
- }
226
- /**
227
- * Abstract base class that provides common functionality for monorepo management including parenting and inspection capabilities.
228
- */
229
- declare abstract class AbstractBase<P extends object | null = object | null> implements ParentingTarget<P> {
230
- static inspector: InspectorOptions;
231
- constructor(parent: P);
232
- findParentDeep<T extends AbstractBase>(predicate: (parent: T) => boolean): T | undefined;
233
- get parent(): P;
234
- getParentDeep<T extends AbstractBase>(instanceOf: new (...args: any[]) => T): T;
235
- }
236
-
237
- /**
238
- * Abstract base class for representing code structures in the monorepo with inspection and preview capabilities.
239
- */
240
- declare abstract class AbstractCode<P extends AbstractBase = AbstractBase> extends AbstractBase<P> {
241
- static readonly inspector: InspectorOptions;
242
- static readonly codePreviewOptions: {
243
- maxLines: number;
244
- maxLineLength: number;
245
- };
246
- constructor(parent: P);
247
- get path(): string;
248
- get code(): string;
249
- get isMultiLine(): boolean;
250
- get lines(): string[];
251
- get codePreview(): string | string[];
252
- codeIndexRangeOf(code: string): {
253
- index: number;
254
- lastIndex: number;
255
- };
256
- getCodeRange(range: {
257
- index: number;
258
- lastIndex: number;
259
- }): string;
260
- }
261
-
262
- /**
263
- * Represents a block of code within a larger code structure, defined by an index range.
264
- */
265
- declare class CodeBlock<P extends AbstractCode = AbstractCode> extends AbstractCode<P> {
266
- static readonly inspector: InspectorOptions;
267
- readonly indexRange: {
268
- index: number;
269
- lastIndex: number;
270
- };
271
- constructor(parent: P, indexRange: {
272
- index: number;
273
- lastIndex: number;
274
- });
275
- toString(): string;
276
- }
277
-
278
- /**
279
- * Represents the imported keywords/specifiers in an import statement.
280
- */
281
- declare class ImportKeywords<P extends ImportStatement = ImportStatement> extends CodeBlock<P> {
282
- static readonly inspector: InspectorOptions;
283
- get keywords(): string[];
284
- has(kw: string): boolean;
285
- get isType(): boolean;
286
- }
287
-
288
- declare class ImportSpecifiers<P extends ImportStatement = ImportStatement> extends CodeBlock<P> {
289
- static readonly inspector: InspectorOptions;
290
- get codeWithoutTypeKeyword(): string;
291
- get type(): 'default' | 'named' | 'mixed' | 'namespace';
292
- get isDefaultImport(): boolean;
293
- get isNamedImport(): boolean;
294
- get isMixedImport(): boolean;
295
- get isNamespaceImport(): boolean;
296
- get namedImportsArray(): string[];
297
- /**
298
- * Splits the import specifier into an array of specifiers as if to split into individual import statements.
299
- * @example `{A,B} => {A},{B}`
300
- */
301
- splitSpecifiers(): string[];
302
- /**
303
- * Returns the keys added to the global namespace by this import specifier.
304
- */
305
- get importedNamesArray(): string[];
306
- get defaultImport(): string | undefined;
307
- get namespaceImport(): string | undefined;
308
- get hasNamedImport(): boolean;
309
- get hasDefaultImport(): boolean;
310
- }
311
-
312
- declare class ModuleSpecifier<P extends ImportStatement = ImportStatement> extends CodeBlock<P> {
313
- static readonly inspector: InspectorOptions;
314
- /**
315
- * Alias for the `code` property.
316
- */
317
- get from(): string;
318
- get dependency(): string | undefined;
319
- get isBuiltin(): boolean;
320
- get isScoped(): boolean;
321
- get isRepoScoped(): boolean;
322
- /**
323
- * Returns whether import is an other, but local workspace in the monorepo.
324
- */
325
- get isOtherRepoWorkspace(): boolean;
326
- get isRelative(): boolean;
327
- get isFromRepoRoot(): boolean;
328
- get isExternal(): boolean;
329
- get isDependency(): boolean;
330
- }
331
-
332
- /**
333
- * Represents an import statement in TypeScript code with parsing and manipulation capabilities.
334
- */
335
- declare class ImportStatement<P extends TsCode = TsCode> extends CodeBlock<P> {
336
- static readonly inspector: InspectorOptions;
337
- toOneLine(): string;
338
- get keywords(): ImportKeywords<this>;
339
- get specifiers(): ImportSpecifiers<this> | undefined;
340
- get module(): ModuleSpecifier<this>;
341
- split(): string[];
342
- get filepath(): string;
343
- }
344
-
345
- declare class File<P extends Workspace = Workspace> extends AbstractBase<P> {
346
- static readonly inspector: InspectorOptions;
347
- readonly path: string;
348
- constructor(parent: P, filepath: string);
349
- get stats(): Stats;
350
- get isTs(): boolean;
351
- get isDotTs(): boolean;
352
- get isDotTsx(): boolean;
353
- get isExample(): boolean;
354
- get isDeclaration(): boolean;
355
- get isTest(): boolean;
356
- get isIndexFile(): boolean;
357
- get isSourceFile(): boolean;
358
- /**
359
- * Read the file contents.
360
- */
361
- protected readFile(): string;
362
- }
363
-
364
- /**
365
- * Represents a TypeScript file in the monorepo with code analysis and dependency tracking capabilities.
366
- */
367
- declare class TsFile<P extends Workspace = Workspace> extends File<P> {
368
- static readonly inspector: InspectorOptions;
369
- get tsCode(): TsCode;
370
- get dependencies(): string[];
371
- }
372
-
373
- /**
374
- * Represents TypeScript code with import parsing and manipulation capabilities.
375
- */
376
- declare class TsCode<P extends TsFile = TsFile> extends AbstractCode<P> {
377
- #private;
378
- static readonly inspector: InspectorOptions;
379
- get code(): string;
380
- constructor(parent: P, code: string);
381
- toString(): string;
382
- requires(format?: 'lines' | 'modules'): string[];
383
- get imports(): ImportStatement[];
384
- get exportedClassNames(): string[];
385
- get dependencies(): string[];
386
- private get requireRegex();
387
- }
388
-
389
- /**
390
- * Represents a test file in the monorepo with TypeScript code analysis capabilities.
391
- */
392
- declare class TestFile<P extends Workspace = Workspace> extends TsFile<P> {
393
- static readonly inspector: InspectorOptions;
394
- get tsCode(): TsCode;
395
- get dependencies(): string[];
396
- }
397
-
398
- declare class Workspace<P extends MonoRepo = MonoRepo> extends AbstractBase<P> {
399
- static readonly inspector: InspectorOptions;
400
- /**
401
- * The workspace's origin directory name, eg. 'libs', 'apps', etc.
402
- */
403
- readonly origin: string;
404
- /**
405
- * The workspace's root directory path.
406
- */
407
- readonly path: string;
408
- constructor(parent: P, dirpath: string);
409
- /**
410
- * The workspace's package.json filepath.
411
- */
412
- get packageJsonPath(): string;
413
- /**
414
- * The workspace's package.json file as an object.
415
- */
416
- get packageJson(): PackageJson;
417
- /**
418
- * The workspace's name from the package.json file.
419
- */
420
- get name(): string;
421
- /**
422
- * Reads the workspace's package.json file and returns the 'dependencies' field as a sorted array of strings.
423
- */
424
- get installedDependencies(): string[];
425
- /**
426
- * Reads the workspace's package.json file and returns the 'devDependencies' field as a sorted array of strings.
427
- */
428
- get installedDevDependencies(): string[];
429
- /**
430
- * Get all unique file-level dependencies of the workspace, including transitive dependencies through other local workspaces.
431
- *
432
- * 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).
433
- *
434
- * @returns An object containing two arrays: `internal` for internal workspace dependencies and `external` for npm package dependencies.
435
- */
436
- get importedDependenciesRecursive(): {
437
- internal: string[];
438
- external: string[];
439
- };
440
- /**
441
- * Get the source files in the workspace's 'src' directory.
442
- * Test files are not included.
443
- */
444
- get tsFiles(): TsFile[];
445
- /**
446
- * Get the test files in the workspace's 'src' directory.
447
- */
448
- get testFiles(): TsFile[];
449
- get files(): (TsFile | TestFile)[];
450
- /**
451
- * Get imported non-relative dependencies for each source file in the workspace, grouped by file.
452
- */
453
- get importedDependenciesByFile(): Map<string, string[]>;
454
- /**
455
- * Get imported non-relative dependencies for each test file in the workspace, grouped by file.
456
- */
457
- get importedTestDependenciesByFile(): Map<string, string[]>;
458
- /**
459
- * Get imported non-relative dependencies for each source file in the workspace in a flat array.
460
- */
461
- get importedDependencies(): string[];
462
- /**
463
- * Get imported non-relative dependencies for each test file in the workspace in a flat array.
464
- */
465
- get importedTestDependencies(): string[];
466
- /**
467
- * Get dependencies that are imported but not listed in the workspace's package.json under 'dependencies'.
468
- */
469
- get missingDependencies(): string[];
470
- /**
471
- * Get dependencies that are imported but not listed in the workspace's package.json under 'devDependencies'.
472
- */
473
- get missingDevDependencies(): string[];
474
- /**
475
- * Get dependencies that are listed in the workspace's package.json but not imported in any source file (excl. test files).
476
- */
477
- get unusedDependencies(): string[];
478
- /**
479
- *
480
- */
481
- get incorrectlyImportedRepoWorkspaces(): IncorrectlyImportedRepoWorkspace[];
482
- /**
483
- * Returns an object with found dependency problems for the workspace or undefined if no problems were found.
484
- * @see WorkspaceDependencyProblems
485
- */
486
- get dependencyProblems(): WorkspaceDependencyProblems | undefined;
487
- depcheck(): Promise<Results>;
488
- /**
489
- * Returns the workspace's cwd-relative path.
490
- */
491
- toString(): string;
492
- }
493
- interface WorkspaceDependencyProblems {
494
- origin: string;
495
- workspace: string;
496
- unused?: string[];
497
- missing?: string[];
498
- missingDev?: string[];
499
- imports?: IncorrectlyImportedRepoWorkspace[];
500
- }
501
- interface IncorrectlyImportedRepoWorkspace {
502
- filepath: string;
503
- replaceValue: string;
504
- withValue: string;
505
- }
506
-
507
- /**
508
- * Represents a monorepo with workspace management, TypeScript configuration, and dependency analysis capabilities.
509
- */
510
- declare class MonoRepo<P extends null = null> extends AbstractBase<P> {
511
- static readonly inspector: InspectorOptions;
512
- static instances: Map<string, MonoRepo<null>>;
513
- readonly path: string;
514
- constructor();
515
- get monoRepo(): MonoRepo;
516
- get packageJsonPath(): string;
517
- get tsconfigBaseJsonPath(): string;
518
- get tsconfigBase(): SetFieldType<TsConfigJson, "compilerOptions", TsConfigJson["compilerOptions"] & {
519
- paths: CompilerOptions["paths"];
520
- }>;
521
- get tsconfigBasePathsJsonPath(): string;
522
- get tsconfigBasePaths(): Record<string, string[]>;
523
- get packageJson(): PackageJson;
524
- get name(): string;
525
- get workspacesRootPaths(): string[];
526
- get workspacePaths(): string[];
527
- get workspaces(): Workspace[];
528
- }
529
-
530
- /**
531
- * Finds the full package name for a workspace given a partial name.
532
- */
533
- declare function findWorkspacePackageName(name: string): Promise<string | undefined>;
534
-
535
- /**
536
- * Retrieves all import statements from TypeScript source files across all workspaces in the monorepo.
537
- */
538
- declare function getAllImports(repo: MonoRepo): ImportStatement<TsCode<TsFile<Workspace<MonoRepo<null>>>>>[];
539
-
540
- /**
541
- * Gets all workspace package.json file paths.
542
- */
543
- declare function getAllWorkspacePackageJsonPaths(): Promise<string[]>;
544
-
545
- /**
546
- * Gets all workspace package.json contents.
547
- */
548
- declare function getAllWorkspacePackageJsons(): Promise<any[]>;
549
-
550
- /**
551
- * Gets all workspace package names.
552
- */
553
- declare function getAllWorkspacePackageNames(): Promise<string[]>;
554
-
555
- /**
556
- * Returns an array of all workspace directory paths.
557
- */
558
- declare function getAllWorkspacePaths(): Promise<string[]>;
559
-
560
- /**
561
- * Reads the repository's root package.json file.
562
- */
563
- declare function getRepoPackageJson(): Promise<any>;
564
-
565
- /**
566
- * Gets the absolute path to the repository's package.json file.
567
- */
568
- declare function getRepoPackageJsonPath(): string;
569
-
570
- /**
571
- * Constants for semantic filename prefixes used to categorize files by their purpose.
572
- */
573
- type SemanticExtnamePrefix = (typeof SemanticExtnamePrefix)[keyof typeof SemanticExtnamePrefix];
574
- declare const SemanticExtnamePrefix: {
575
- readonly d: "d";
576
- readonly test: "test";
577
- readonly examples: "examples";
578
- readonly benchmark: "benchmark";
579
- readonly temp: "temp";
580
- readonly wip: "wip";
581
- };
582
-
583
- /**
584
- * A record mapping semantic extname prefixes to their descriptions.
585
- *
586
- * - `d`: Declaration files
587
- * - `test`: Vitest test suite files
588
- * - `examples`: Files containing working and tested example usage code (included in git, but ignored by most repo tools)
589
- * - `benchmark`: Benchmark files (included in git, but ignored by most repo tools)
590
- * - `temp`: Temporary files (ignored by git, build, tests, etc.)
591
- * - `wip`: Work in progress files (ignored by git, build, tests, etc.)
592
- */
593
- declare const SemanticExtnamePrefixDescriptions: Record<SemanticExtnamePrefix, string>;
594
-
595
- /**
596
- * Get the root directory path of the monorepo by finding the package.json with workspaces configuration.
597
- */
598
- declare const getRepoRootDirpath: () => string;
599
-
600
- /**
601
- * Get all workspace directory paths by reading the workspace patterns from the root package.json.
602
- */
603
- declare function getWorkspaceDirpaths(): string[];
604
-
605
- /**
606
- * Checks if a file path has any of the specified semantic extension prefixes (e.g., .test.ts).
607
- */
608
- declare function hasExtnamePrefix(tsFilepath: string, prefixes?: Arrayable<SemanticExtnamePrefix>): boolean;
609
-
610
- /**
611
- * Returns the resolved import path (relative from repo root)
612
- */
613
- declare function resolveModuleImportPath(filepath: string, importFrom: string): typescript.ResolvedModuleFull | undefined;
614
-
615
- /**
616
- * Bumps the semantic versioning (SemVer) of a given version string or array based on the specified level.
617
- * The function supports 'major', 'minor', and 'patch' levels.
618
- *
619
- * @remarks
620
- * This function will mutate the original version if it's an array.
621
- *
622
- * @param version - The current version. It can be a string (e.g., '1.0.0') or an array of strings or numbers (e.g., ['1', '0', '0'] or [1, 0, 0]).
623
- * @param level - The level of the version bump. It can be 'major', 'minor', or 'patch'.
624
- *
625
- * @returns The bumped version as a string.
626
- *
627
- * @example
628
- * ```ts
629
- * semverVersionBump('1.0.0', 'major'); // '2.0.0'
630
- * semverVersionBump([1, 0, 4], 'minor'); // '1.1.0'
631
- * semverVersionBump(['1', '0', '0'], 'patch'); // '1.0.1'
632
- * ```
633
- */
634
- declare function semverVersionBump(version: string | string[] | number[], level: 'major' | 'minor' | 'patch'): string;
635
-
636
- export { AbstractBase, AbstractCode, CodeBlock, File, ImportKeywords, ImportSpecifiers, ImportStatement, type IncorrectlyImportedRepoWorkspace, ModuleSpecifier, MonoRepo, SemanticExtnamePrefix, SemanticExtnamePrefixDescriptions, TestFile, TsCode, TsFile, Workspace, type WorkspaceDependencyProblems, findWorkspacePackageName, getAllImports, getAllWorkspacePackageJsonPaths, getAllWorkspacePackageJsons, getAllWorkspacePackageNames, getAllWorkspacePaths, getRepoPackageJson, getRepoPackageJsonPath, getRepoRootDirpath, getWorkspaceDirpaths, hasExtnamePrefix, resolveModuleImportPath, semverVersionBump };