@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
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ // src/util/SemanticExtnamePrefix.ts
4
+ var SemanticExtnamePrefix = {
5
+ d: "d",
6
+ test: "test",
7
+ examples: "examples",
8
+ benchmark: "benchmark",
9
+ temp: "temp",
10
+ wip: "wip"
11
+ };
12
+
13
+ exports.SemanticExtnamePrefix = SemanticExtnamePrefix;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Constants for semantic filename prefixes used to categorize files by their purpose.
3
+ */
4
+ type SemanticExtnamePrefix = (typeof SemanticExtnamePrefix)[keyof typeof SemanticExtnamePrefix];
5
+ declare const SemanticExtnamePrefix: {
6
+ readonly d: "d";
7
+ readonly test: "test";
8
+ readonly examples: "examples";
9
+ readonly benchmark: "benchmark";
10
+ readonly temp: "temp";
11
+ readonly wip: "wip";
12
+ };
13
+
14
+ export { SemanticExtnamePrefix };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Constants for semantic filename prefixes used to categorize files by their purpose.
3
+ */
4
+ type SemanticExtnamePrefix = (typeof SemanticExtnamePrefix)[keyof typeof SemanticExtnamePrefix];
5
+ declare const SemanticExtnamePrefix: {
6
+ readonly d: "d";
7
+ readonly test: "test";
8
+ readonly examples: "examples";
9
+ readonly benchmark: "benchmark";
10
+ readonly temp: "temp";
11
+ readonly wip: "wip";
12
+ };
13
+
14
+ export { SemanticExtnamePrefix };
@@ -0,0 +1,11 @@
1
+ // src/util/SemanticExtnamePrefix.ts
2
+ var SemanticExtnamePrefix = {
3
+ d: "d",
4
+ test: "test",
5
+ examples: "examples",
6
+ benchmark: "benchmark",
7
+ temp: "temp",
8
+ wip: "wip"
9
+ };
10
+
11
+ export { SemanticExtnamePrefix };
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ // src/util/SemanticExtnamePrefixDescriptions.ts
4
+ var SemanticExtnamePrefixDescriptions = {
5
+ d: "declarations",
6
+ test: "vitest test suite",
7
+ examples: "contains working and tested example usage code. Included in git, but ignored by most repo tools",
8
+ benchmark: "benchmark files, included in git, but ignored by most repo tools.",
9
+ temp: "temporary files, ignored by git, build, tests, etc.",
10
+ wip: "work in progress, ignored by git, build, tests, etc."
11
+ };
12
+
13
+ exports.SemanticExtnamePrefixDescriptions = SemanticExtnamePrefixDescriptions;
@@ -0,0 +1,15 @@
1
+ import { SemanticExtnamePrefix } from './SemanticExtnamePrefix.cjs';
2
+
3
+ /**
4
+ * A record mapping semantic extname prefixes to their descriptions.
5
+ *
6
+ * - `d`: Declaration files
7
+ * - `test`: Vitest test suite files
8
+ * - `examples`: Files containing working and tested example usage code (included in git, but ignored by most repo tools)
9
+ * - `benchmark`: Benchmark files (included in git, but ignored by most repo tools)
10
+ * - `temp`: Temporary files (ignored by git, build, tests, etc.)
11
+ * - `wip`: Work in progress files (ignored by git, build, tests, etc.)
12
+ */
13
+ declare const SemanticExtnamePrefixDescriptions: Record<SemanticExtnamePrefix, string>;
14
+
15
+ export { SemanticExtnamePrefixDescriptions };
@@ -0,0 +1,15 @@
1
+ import { SemanticExtnamePrefix } from './SemanticExtnamePrefix.js';
2
+
3
+ /**
4
+ * A record mapping semantic extname prefixes to their descriptions.
5
+ *
6
+ * - `d`: Declaration files
7
+ * - `test`: Vitest test suite files
8
+ * - `examples`: Files containing working and tested example usage code (included in git, but ignored by most repo tools)
9
+ * - `benchmark`: Benchmark files (included in git, but ignored by most repo tools)
10
+ * - `temp`: Temporary files (ignored by git, build, tests, etc.)
11
+ * - `wip`: Work in progress files (ignored by git, build, tests, etc.)
12
+ */
13
+ declare const SemanticExtnamePrefixDescriptions: Record<SemanticExtnamePrefix, string>;
14
+
15
+ export { SemanticExtnamePrefixDescriptions };
@@ -0,0 +1,11 @@
1
+ // src/util/SemanticExtnamePrefixDescriptions.ts
2
+ var SemanticExtnamePrefixDescriptions = {
3
+ d: "declarations",
4
+ test: "vitest test suite",
5
+ examples: "contains working and tested example usage code. Included in git, but ignored by most repo tools",
6
+ benchmark: "benchmark files, included in git, but ignored by most repo tools.",
7
+ temp: "temporary files, ignored by git, build, tests, etc.",
8
+ wip: "work in progress, ignored by git, build, tests, etc."
9
+ };
10
+
11
+ export { SemanticExtnamePrefixDescriptions };
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ // src/util/SemanticExtnamePrefix.ts
4
+ var SemanticExtnamePrefix = {
5
+ d: "d",
6
+ test: "test",
7
+ examples: "examples",
8
+ benchmark: "benchmark",
9
+ temp: "temp",
10
+ wip: "wip"
11
+ };
12
+
13
+ // src/util/SemanticExtnamePrefixes.ts
14
+ var SemanticExtnamePrefixes_default = Object.values(SemanticExtnamePrefix);
15
+
16
+ module.exports = SemanticExtnamePrefixes_default;
17
+
18
+ module.exports = exports.default;
@@ -0,0 +1,97 @@
1
+ import { SemanticExtnamePrefix } from './SemanticExtnamePrefix.cjs';
2
+ import { I as IsNever } from '../is-never.d-CgQ1j0-8.cjs';
3
+
4
+ /**
5
+ Convert a union type to an intersection type using [distributive conditional types](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
6
+
7
+ Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
8
+
9
+ @example
10
+ ```
11
+ import type {UnionToIntersection} from 'type-fest';
12
+
13
+ type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
14
+
15
+ type Intersection = UnionToIntersection<Union>;
16
+ //=> {the(): void} & {great(arg: string): void} & {escape: boolean}
17
+ ```
18
+
19
+ @category Type
20
+ */
21
+ type UnionToIntersection<Union> = (
22
+ // `extends unknown` is always going to be the case and is used to convert the
23
+ // `Union` into a [distributive conditional
24
+ // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
25
+ Union extends unknown
26
+ // The union type is used as the only argument to a function since the union
27
+ // of function arguments is an intersection.
28
+ ? (distributedUnion: Union) => void
29
+ // This won't happen.
30
+ : never
31
+ // Infer the `Intersection` type since TypeScript represents the positional
32
+ // arguments of unions of functions as an intersection of the union.
33
+ ) extends ((mergedIntersection: infer Intersection) => void)
34
+ // The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
35
+ ? Intersection & Union
36
+ : never;
37
+
38
+ /**
39
+ Returns the last element of a union type.
40
+
41
+ @example
42
+ ```
43
+ type Last = LastOfUnion<1 | 2 | 3>;
44
+ //=> 3
45
+ ```
46
+ */
47
+ type LastOfUnion<T> =
48
+ UnionToIntersection<T extends any ? () => T : never> extends () => (infer R)
49
+ ? R
50
+ : never;
51
+
52
+ /**
53
+ Convert a union type into an unordered tuple type of its elements.
54
+
55
+ "Unordered" means the elements of the tuple are not guaranteed to be in the same order as in the union type. The arrangement can appear random and may change at any time.
56
+
57
+ This can be useful when you have objects with a finite set of keys and want a type defining only the allowed keys, but do not want to repeat yourself.
58
+
59
+ @example
60
+ ```
61
+ import type {UnionToTuple} from 'type-fest';
62
+
63
+ type Numbers = 1 | 2 | 3;
64
+ type NumbersTuple = UnionToTuple<Numbers>;
65
+ //=> [1, 2, 3]
66
+ ```
67
+
68
+ @example
69
+ ```
70
+ import type {UnionToTuple} from 'type-fest';
71
+
72
+ const pets = {
73
+ dog: '🐶',
74
+ cat: '🐱',
75
+ snake: '🐍',
76
+ };
77
+
78
+ type Pet = keyof typeof pets;
79
+ //=> 'dog' | 'cat' | 'snake'
80
+
81
+ const petList = Object.keys(pets) as UnionToTuple<Pet>;
82
+ //=> ['dog', 'cat', 'snake']
83
+ ```
84
+
85
+ @category Array
86
+ */
87
+ type UnionToTuple<T, L = LastOfUnion<T>> =
88
+ IsNever<T> extends false
89
+ ? [...UnionToTuple<Exclude<T, L>>, L]
90
+ : [];
91
+
92
+ /**
93
+ * Array of all semantic extension prefixes used to categorize files by their purpose.
94
+ */
95
+ declare const _default: UnionToTuple<SemanticExtnamePrefix>;
96
+
97
+ export = _default;
@@ -0,0 +1,97 @@
1
+ import { SemanticExtnamePrefix } from './SemanticExtnamePrefix.js';
2
+ import { I as IsNever } from '../is-never.d-CgQ1j0-8.js';
3
+
4
+ /**
5
+ Convert a union type to an intersection type using [distributive conditional types](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
6
+
7
+ Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
8
+
9
+ @example
10
+ ```
11
+ import type {UnionToIntersection} from 'type-fest';
12
+
13
+ type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
14
+
15
+ type Intersection = UnionToIntersection<Union>;
16
+ //=> {the(): void} & {great(arg: string): void} & {escape: boolean}
17
+ ```
18
+
19
+ @category Type
20
+ */
21
+ type UnionToIntersection<Union> = (
22
+ // `extends unknown` is always going to be the case and is used to convert the
23
+ // `Union` into a [distributive conditional
24
+ // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
25
+ Union extends unknown
26
+ // The union type is used as the only argument to a function since the union
27
+ // of function arguments is an intersection.
28
+ ? (distributedUnion: Union) => void
29
+ // This won't happen.
30
+ : never
31
+ // Infer the `Intersection` type since TypeScript represents the positional
32
+ // arguments of unions of functions as an intersection of the union.
33
+ ) extends ((mergedIntersection: infer Intersection) => void)
34
+ // The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
35
+ ? Intersection & Union
36
+ : never;
37
+
38
+ /**
39
+ Returns the last element of a union type.
40
+
41
+ @example
42
+ ```
43
+ type Last = LastOfUnion<1 | 2 | 3>;
44
+ //=> 3
45
+ ```
46
+ */
47
+ type LastOfUnion<T> =
48
+ UnionToIntersection<T extends any ? () => T : never> extends () => (infer R)
49
+ ? R
50
+ : never;
51
+
52
+ /**
53
+ Convert a union type into an unordered tuple type of its elements.
54
+
55
+ "Unordered" means the elements of the tuple are not guaranteed to be in the same order as in the union type. The arrangement can appear random and may change at any time.
56
+
57
+ This can be useful when you have objects with a finite set of keys and want a type defining only the allowed keys, but do not want to repeat yourself.
58
+
59
+ @example
60
+ ```
61
+ import type {UnionToTuple} from 'type-fest';
62
+
63
+ type Numbers = 1 | 2 | 3;
64
+ type NumbersTuple = UnionToTuple<Numbers>;
65
+ //=> [1, 2, 3]
66
+ ```
67
+
68
+ @example
69
+ ```
70
+ import type {UnionToTuple} from 'type-fest';
71
+
72
+ const pets = {
73
+ dog: '🐶',
74
+ cat: '🐱',
75
+ snake: '🐍',
76
+ };
77
+
78
+ type Pet = keyof typeof pets;
79
+ //=> 'dog' | 'cat' | 'snake'
80
+
81
+ const petList = Object.keys(pets) as UnionToTuple<Pet>;
82
+ //=> ['dog', 'cat', 'snake']
83
+ ```
84
+
85
+ @category Array
86
+ */
87
+ type UnionToTuple<T, L = LastOfUnion<T>> =
88
+ IsNever<T> extends false
89
+ ? [...UnionToTuple<Exclude<T, L>>, L]
90
+ : [];
91
+
92
+ /**
93
+ * Array of all semantic extension prefixes used to categorize files by their purpose.
94
+ */
95
+ declare const _default: UnionToTuple<SemanticExtnamePrefix>;
96
+
97
+ export { _default as default };
@@ -0,0 +1,14 @@
1
+ // src/util/SemanticExtnamePrefix.ts
2
+ var SemanticExtnamePrefix = {
3
+ d: "d",
4
+ test: "test",
5
+ examples: "examples",
6
+ benchmark: "benchmark",
7
+ temp: "temp",
8
+ wip: "wip"
9
+ };
10
+
11
+ // src/util/SemanticExtnamePrefixes.ts
12
+ var SemanticExtnamePrefixes_default = Object.values(SemanticExtnamePrefix);
13
+
14
+ export { SemanticExtnamePrefixes_default as default };
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ var fs = require('fs-extra');
4
+ var onetime = require('onetime');
5
+ var path = require('upath');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
10
+ var onetime__default = /*#__PURE__*/_interopDefault(onetime);
11
+ var path__default = /*#__PURE__*/_interopDefault(path);
12
+
13
+ var __defProp = Object.defineProperty;
14
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
+ var getRepoRootDirpath = onetime__default.default(/* @__PURE__ */ __name(function getRepoRootDirpath2() {
16
+ return (/* @__PURE__ */ __name(function recurse(dirpath = process.cwd()) {
17
+ dirpath = path__default.default.normalizeSafe(dirpath);
18
+ const pkgpath = path__default.default.joinSafe(dirpath, "package.json");
19
+ if (fs__default.default.existsSync(pkgpath) && fs__default.default.readJsonSync(pkgpath)?.workspaces) {
20
+ return dirpath;
21
+ }
22
+ const parent = path__default.default.dirname(dirpath);
23
+ if (parent !== dirpath) {
24
+ return recurse(parent);
25
+ }
26
+ throw new Error(`Could not find repo root from process.cwd(): ${process.cwd()}`);
27
+ }, "recurse"))();
28
+ }, "getRepoRootDirpath"));
29
+
30
+ exports.getRepoRootDirpath = getRepoRootDirpath;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Get the root directory path of the monorepo by finding the package.json with workspaces configuration.
3
+ */
4
+ declare const getRepoRootDirpath: () => string;
5
+
6
+ export { getRepoRootDirpath };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Get the root directory path of the monorepo by finding the package.json with workspaces configuration.
3
+ */
4
+ declare const getRepoRootDirpath: () => string;
5
+
6
+ export { getRepoRootDirpath };
@@ -0,0 +1,22 @@
1
+ import fs from 'fs-extra';
2
+ import onetime from 'onetime';
3
+ import path from 'upath';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var getRepoRootDirpath = onetime(/* @__PURE__ */ __name(function getRepoRootDirpath2() {
8
+ return (/* @__PURE__ */ __name(function recurse(dirpath = process.cwd()) {
9
+ dirpath = path.normalizeSafe(dirpath);
10
+ const pkgpath = path.joinSafe(dirpath, "package.json");
11
+ if (fs.existsSync(pkgpath) && fs.readJsonSync(pkgpath)?.workspaces) {
12
+ return dirpath;
13
+ }
14
+ const parent = path.dirname(dirpath);
15
+ if (parent !== dirpath) {
16
+ return recurse(parent);
17
+ }
18
+ throw new Error(`Could not find repo root from process.cwd(): ${process.cwd()}`);
19
+ }, "recurse"))();
20
+ }, "getRepoRootDirpath"));
21
+
22
+ export { getRepoRootDirpath };
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ var fs = require('fs-extra');
4
+ var onetime = require('onetime');
5
+ var path = require('upath');
6
+ var glob = require('glob');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
+
10
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
11
+ var onetime__default = /*#__PURE__*/_interopDefault(onetime);
12
+ var path__default = /*#__PURE__*/_interopDefault(path);
13
+
14
+ var __defProp = Object.defineProperty;
15
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
16
+ var getRepoRootDirpath = onetime__default.default(/* @__PURE__ */ __name(function getRepoRootDirpath2() {
17
+ return (/* @__PURE__ */ __name(function recurse(dirpath = process.cwd()) {
18
+ dirpath = path__default.default.normalizeSafe(dirpath);
19
+ const pkgpath = path__default.default.joinSafe(dirpath, "package.json");
20
+ if (fs__default.default.existsSync(pkgpath) && fs__default.default.readJsonSync(pkgpath)?.workspaces) {
21
+ return dirpath;
22
+ }
23
+ const parent = path__default.default.dirname(dirpath);
24
+ if (parent !== dirpath) {
25
+ return recurse(parent);
26
+ }
27
+ throw new Error(`Could not find repo root from process.cwd(): ${process.cwd()}`);
28
+ }, "recurse"))();
29
+ }, "getRepoRootDirpath"));
30
+ function getWorkspaceDirpaths() {
31
+ const rootDirpath = getRepoRootDirpath();
32
+ const pkg = fs__default.default.readJsonSync(path__default.default.joinSafe(rootDirpath, "package.json"));
33
+ if (!pkg.workspaces) {
34
+ throw new Error(`No workspaces found in package.json at ${rootDirpath}`);
35
+ }
36
+ return pkg.workspaces.flatMap((workspace) => {
37
+ return glob.globSync(workspace);
38
+ }).map(path__default.default.normalizeSafe);
39
+ }
40
+ __name(getWorkspaceDirpaths, "getWorkspaceDirpaths");
41
+
42
+ exports.getWorkspaceDirpaths = getWorkspaceDirpaths;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Get all workspace directory paths by reading the workspace patterns from the root package.json.
3
+ */
4
+ declare function getWorkspaceDirpaths(): string[];
5
+
6
+ export { getWorkspaceDirpaths };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Get all workspace directory paths by reading the workspace patterns from the root package.json.
3
+ */
4
+ declare function getWorkspaceDirpaths(): string[];
5
+
6
+ export { getWorkspaceDirpaths };
@@ -0,0 +1,34 @@
1
+ import fs from 'fs-extra';
2
+ import onetime from 'onetime';
3
+ import path from 'upath';
4
+ import { globSync } from 'glob';
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var getRepoRootDirpath = onetime(/* @__PURE__ */ __name(function getRepoRootDirpath2() {
9
+ return (/* @__PURE__ */ __name(function recurse(dirpath = process.cwd()) {
10
+ dirpath = path.normalizeSafe(dirpath);
11
+ const pkgpath = path.joinSafe(dirpath, "package.json");
12
+ if (fs.existsSync(pkgpath) && fs.readJsonSync(pkgpath)?.workspaces) {
13
+ return dirpath;
14
+ }
15
+ const parent = path.dirname(dirpath);
16
+ if (parent !== dirpath) {
17
+ return recurse(parent);
18
+ }
19
+ throw new Error(`Could not find repo root from process.cwd(): ${process.cwd()}`);
20
+ }, "recurse"))();
21
+ }, "getRepoRootDirpath"));
22
+ function getWorkspaceDirpaths() {
23
+ const rootDirpath = getRepoRootDirpath();
24
+ const pkg = fs.readJsonSync(path.joinSafe(rootDirpath, "package.json"));
25
+ if (!pkg.workspaces) {
26
+ throw new Error(`No workspaces found in package.json at ${rootDirpath}`);
27
+ }
28
+ return pkg.workspaces.flatMap((workspace) => {
29
+ return globSync(workspace);
30
+ }).map(path.normalizeSafe);
31
+ }
32
+ __name(getWorkspaceDirpaths, "getWorkspaceDirpaths");
33
+
34
+ export { getWorkspaceDirpaths };
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+
6
+ // src/util/SemanticExtnamePrefix.ts
7
+ var SemanticExtnamePrefix = {
8
+ d: "d",
9
+ test: "test",
10
+ examples: "examples",
11
+ benchmark: "benchmark",
12
+ temp: "temp",
13
+ wip: "wip"
14
+ };
15
+
16
+ // src/util/SemanticExtnamePrefixes.ts
17
+ var SemanticExtnamePrefixes_default = Object.values(SemanticExtnamePrefix);
18
+
19
+ // src/util/hasExtnamePrefix.ts
20
+ function hasExtnamePrefix(tsFilepath, prefixes = SemanticExtnamePrefixes_default) {
21
+ return new RegExp(`[.](${[
22
+ prefixes
23
+ ].flat(2).join("|")})[.][^/\\\\]+$`).test(tsFilepath);
24
+ }
25
+ __name(hasExtnamePrefix, "hasExtnamePrefix");
26
+
27
+ exports.hasExtnamePrefix = hasExtnamePrefix;
@@ -0,0 +1,38 @@
1
+ import { SemanticExtnamePrefix } from './SemanticExtnamePrefix.cjs';
2
+
3
+ /**
4
+ Create a type that represents either the value or an array of the value.
5
+
6
+ @see {@link Promisable}
7
+
8
+ @example
9
+ ```
10
+ import type {Arrayable} from 'type-fest';
11
+
12
+ function bundle(input: string, output: Arrayable<string>) {
13
+ const outputList = Array.isArray(output) ? output : [output];
14
+
15
+ // …
16
+
17
+ for (const output of outputList) {
18
+ console.log(`write ${input} to: ${output}`);
19
+ }
20
+ }
21
+
22
+ bundle('src/index.js', 'dist/index.js');
23
+ bundle('src/index.js', ['dist/index.cjs', 'dist/index.mjs']);
24
+ ```
25
+
26
+ @category Array
27
+ */
28
+ type Arrayable<T> =
29
+ T
30
+ // TODO: Use `readonly T[]` when this issue is resolved: https://github.com/microsoft/TypeScript/issues/17002
31
+ | T[];
32
+
33
+ /**
34
+ * Checks if a file path has any of the specified semantic extension prefixes (e.g., .test.ts).
35
+ */
36
+ declare function hasExtnamePrefix(tsFilepath: string, prefixes?: Arrayable<SemanticExtnamePrefix>): boolean;
37
+
38
+ export { hasExtnamePrefix };
@@ -0,0 +1,38 @@
1
+ import { SemanticExtnamePrefix } from './SemanticExtnamePrefix.js';
2
+
3
+ /**
4
+ Create a type that represents either the value or an array of the value.
5
+
6
+ @see {@link Promisable}
7
+
8
+ @example
9
+ ```
10
+ import type {Arrayable} from 'type-fest';
11
+
12
+ function bundle(input: string, output: Arrayable<string>) {
13
+ const outputList = Array.isArray(output) ? output : [output];
14
+
15
+ // …
16
+
17
+ for (const output of outputList) {
18
+ console.log(`write ${input} to: ${output}`);
19
+ }
20
+ }
21
+
22
+ bundle('src/index.js', 'dist/index.js');
23
+ bundle('src/index.js', ['dist/index.cjs', 'dist/index.mjs']);
24
+ ```
25
+
26
+ @category Array
27
+ */
28
+ type Arrayable<T> =
29
+ T
30
+ // TODO: Use `readonly T[]` when this issue is resolved: https://github.com/microsoft/TypeScript/issues/17002
31
+ | T[];
32
+
33
+ /**
34
+ * Checks if a file path has any of the specified semantic extension prefixes (e.g., .test.ts).
35
+ */
36
+ declare function hasExtnamePrefix(tsFilepath: string, prefixes?: Arrayable<SemanticExtnamePrefix>): boolean;
37
+
38
+ export { hasExtnamePrefix };
@@ -0,0 +1,25 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/util/SemanticExtnamePrefix.ts
5
+ var SemanticExtnamePrefix = {
6
+ d: "d",
7
+ test: "test",
8
+ examples: "examples",
9
+ benchmark: "benchmark",
10
+ temp: "temp",
11
+ wip: "wip"
12
+ };
13
+
14
+ // src/util/SemanticExtnamePrefixes.ts
15
+ var SemanticExtnamePrefixes_default = Object.values(SemanticExtnamePrefix);
16
+
17
+ // src/util/hasExtnamePrefix.ts
18
+ function hasExtnamePrefix(tsFilepath, prefixes = SemanticExtnamePrefixes_default) {
19
+ return new RegExp(`[.](${[
20
+ prefixes
21
+ ].flat(2).join("|")})[.][^/\\\\]+$`).test(tsFilepath);
22
+ }
23
+ __name(hasExtnamePrefix, "hasExtnamePrefix");
24
+
25
+ export { hasExtnamePrefix };