@bemoje/monorepo 1.0.0 → 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/README.md +99 -0
- 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 -2330
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/lib/MonoRepo.cjs
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var AbstractBase = require('./common/AbstractBase');
|
|
4
|
+
var composition = require('@mono/composition');
|
|
5
|
+
var Workspace = require('./repo/Workspace');
|
|
6
|
+
var fs = require('fs');
|
|
7
|
+
var getRepoRootDirpath = require('./util/getRepoRootDirpath');
|
|
8
|
+
var decorators = require('@mono/decorators');
|
|
9
|
+
var path = require('upath');
|
|
10
|
+
var esm = require('fs-extra/esm');
|
|
11
|
+
|
|
12
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
|
|
14
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
15
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
16
|
+
|
|
17
|
+
var __defProp = Object.defineProperty;
|
|
18
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
19
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
20
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
21
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
22
|
+
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;
|
|
23
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
24
|
+
}
|
|
25
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
26
|
+
function _ts_metadata(k, v) {
|
|
27
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
28
|
+
}
|
|
29
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
30
|
+
class MonoRepo extends AbstractBase.AbstractBase {
|
|
31
|
+
static {
|
|
32
|
+
__name(this, "MonoRepo");
|
|
33
|
+
}
|
|
34
|
+
static inspector = composition.Inspector.compose(MonoRepo, {
|
|
35
|
+
keys: [
|
|
36
|
+
"name",
|
|
37
|
+
"workspaces"
|
|
38
|
+
]
|
|
39
|
+
});
|
|
40
|
+
static instances = /* @__PURE__ */ new Map();
|
|
41
|
+
path;
|
|
42
|
+
constructor() {
|
|
43
|
+
const oPath = getRepoRootDirpath.getRepoRootDirpath();
|
|
44
|
+
if (MonoRepo.instances.has(oPath)) {
|
|
45
|
+
return MonoRepo.instances.get(oPath);
|
|
46
|
+
}
|
|
47
|
+
super(null);
|
|
48
|
+
this.path = oPath;
|
|
49
|
+
MonoRepo.instances.set(this.path, this);
|
|
50
|
+
}
|
|
51
|
+
get monoRepo() {
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
get packageJsonPath() {
|
|
55
|
+
return path__default.default.join(this.path, "package.json");
|
|
56
|
+
}
|
|
57
|
+
get tsconfigBaseJsonPath() {
|
|
58
|
+
return path__default.default.join(this.path, "tsconfig.json");
|
|
59
|
+
}
|
|
60
|
+
get tsconfigBase() {
|
|
61
|
+
const o = esm.readJsonSync(this.tsconfigBaseJsonPath);
|
|
62
|
+
if (!o.compilerOptions) {
|
|
63
|
+
o.compilerOptions = {};
|
|
64
|
+
}
|
|
65
|
+
o.compilerOptions.paths = o.compilerOptions.paths || this.tsconfigBasePaths;
|
|
66
|
+
return o;
|
|
67
|
+
}
|
|
68
|
+
get tsconfigBasePathsJsonPath() {
|
|
69
|
+
return path__default.default.join(this.path, "tsconfig.paths.json");
|
|
70
|
+
}
|
|
71
|
+
get tsconfigBasePaths() {
|
|
72
|
+
if (!fs__default.default.existsSync(this.tsconfigBasePathsJsonPath)) {
|
|
73
|
+
return {};
|
|
74
|
+
}
|
|
75
|
+
return esm.readJsonSync(this.tsconfigBasePathsJsonPath).compilerOptions?.paths ?? {};
|
|
76
|
+
}
|
|
77
|
+
get packageJson() {
|
|
78
|
+
return esm.readJsonSync(this.packageJsonPath);
|
|
79
|
+
}
|
|
80
|
+
get name() {
|
|
81
|
+
if (!this.packageJson.name) {
|
|
82
|
+
throw new Error(`MonoRepo package.json missing 'name' field: ${this.packageJsonPath}`);
|
|
83
|
+
}
|
|
84
|
+
return this.packageJson.name;
|
|
85
|
+
}
|
|
86
|
+
get workspacesRootPaths() {
|
|
87
|
+
if (!this.packageJson.workspaces) {
|
|
88
|
+
throw new Error(`MonoRepo package.json missing 'workspaces' field: ${this.packageJsonPath}`);
|
|
89
|
+
}
|
|
90
|
+
return this.packageJson.workspaces.map((workspacePath) => {
|
|
91
|
+
return path__default.default.join(this.path, workspacePath.replace(/\*$/, ""));
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
get workspacePaths() {
|
|
95
|
+
return this.workspacesRootPaths.flatMap((workspacePath) => {
|
|
96
|
+
return fs__default.default.readdirSync(workspacePath, {
|
|
97
|
+
withFileTypes: true
|
|
98
|
+
}).filter((dirent) => {
|
|
99
|
+
return dirent.isDirectory();
|
|
100
|
+
}).map((dirent) => {
|
|
101
|
+
return path__default.default.join(workspacePath, dirent.name);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
get workspaces() {
|
|
106
|
+
return this.workspacePaths.map((dirpath) => {
|
|
107
|
+
return new Workspace.Workspace(this, dirpath);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
_ts_decorate([
|
|
112
|
+
decorators.lazyProp(5e3),
|
|
113
|
+
_ts_metadata("design:type", void 0),
|
|
114
|
+
_ts_metadata("design:paramtypes", [])
|
|
115
|
+
], MonoRepo.prototype, "tsconfigBase", null);
|
|
116
|
+
_ts_decorate([
|
|
117
|
+
decorators.lazyProp(5e3),
|
|
118
|
+
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record),
|
|
119
|
+
_ts_metadata("design:paramtypes", [])
|
|
120
|
+
], MonoRepo.prototype, "tsconfigBasePaths", null);
|
|
121
|
+
_ts_decorate([
|
|
122
|
+
decorators.lazyProp(5e3),
|
|
123
|
+
_ts_metadata("design:type", typeof PackageJson === "undefined" ? Object : PackageJson),
|
|
124
|
+
_ts_metadata("design:paramtypes", [])
|
|
125
|
+
], MonoRepo.prototype, "packageJson", null);
|
|
126
|
+
_ts_decorate([
|
|
127
|
+
decorators.lazyProp(5e3),
|
|
128
|
+
_ts_metadata("design:type", void 0),
|
|
129
|
+
_ts_metadata("design:paramtypes", [])
|
|
130
|
+
], MonoRepo.prototype, "workspacePaths", null);
|
|
131
|
+
_ts_decorate([
|
|
132
|
+
decorators.lazyProp,
|
|
133
|
+
_ts_metadata("design:type", Array),
|
|
134
|
+
_ts_metadata("design:paramtypes", [])
|
|
135
|
+
], MonoRepo.prototype, "workspaces", null);
|
|
136
|
+
MonoRepo = _ts_decorate([
|
|
137
|
+
composition.Parenting.compose,
|
|
138
|
+
_ts_metadata("design:type", Function),
|
|
139
|
+
_ts_metadata("design:paramtypes", [])
|
|
140
|
+
], MonoRepo);
|
|
141
|
+
|
|
142
|
+
exports.MonoRepo = MonoRepo;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { d as MonoRepo } from './MonoRepo-BgdabVzT.cjs';
|
|
2
|
+
import './AbstractBase-J4h6nW8k.cjs';
|
|
3
|
+
import 'typescript';
|
|
4
|
+
import './is-never.d-CgQ1j0-8.cjs';
|
|
5
|
+
import 'depcheck';
|
|
6
|
+
import './code/AbstractCode.cjs';
|
|
7
|
+
import 'util';
|
|
8
|
+
import 'mnemonist';
|
|
9
|
+
import './code/CodeBlock.cjs';
|
|
10
|
+
import 'fs';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { d as MonoRepo } from './MonoRepo-BFFUDAYn.js';
|
|
2
|
+
import './AbstractBase-J4h6nW8k.js';
|
|
3
|
+
import 'typescript';
|
|
4
|
+
import './is-never.d-CgQ1j0-8.js';
|
|
5
|
+
import 'depcheck';
|
|
6
|
+
import './code/AbstractCode.js';
|
|
7
|
+
import 'util';
|
|
8
|
+
import 'mnemonist';
|
|
9
|
+
import './code/CodeBlock.js';
|
|
10
|
+
import 'fs';
|
package/lib/MonoRepo.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { __name } from './chunk-SHUYVCID.js';
|
|
2
|
+
import { AbstractBase } from './common/AbstractBase';
|
|
3
|
+
import { Inspector, Parenting } from '@mono/composition';
|
|
4
|
+
import { Workspace } from './repo/Workspace';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import { getRepoRootDirpath } from './util/getRepoRootDirpath';
|
|
7
|
+
import { lazyProp } from '@mono/decorators';
|
|
8
|
+
import path from 'upath';
|
|
9
|
+
import { readJsonSync } from 'fs-extra/esm';
|
|
10
|
+
|
|
11
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
12
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
13
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
14
|
+
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;
|
|
15
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
16
|
+
}
|
|
17
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
18
|
+
function _ts_metadata(k, v) {
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
20
|
+
}
|
|
21
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
22
|
+
class MonoRepo extends AbstractBase {
|
|
23
|
+
static {
|
|
24
|
+
__name(this, "MonoRepo");
|
|
25
|
+
}
|
|
26
|
+
static inspector = Inspector.compose(MonoRepo, {
|
|
27
|
+
keys: [
|
|
28
|
+
"name",
|
|
29
|
+
"workspaces"
|
|
30
|
+
]
|
|
31
|
+
});
|
|
32
|
+
static instances = /* @__PURE__ */ new Map();
|
|
33
|
+
path;
|
|
34
|
+
constructor() {
|
|
35
|
+
const oPath = getRepoRootDirpath();
|
|
36
|
+
if (MonoRepo.instances.has(oPath)) {
|
|
37
|
+
return MonoRepo.instances.get(oPath);
|
|
38
|
+
}
|
|
39
|
+
super(null);
|
|
40
|
+
this.path = oPath;
|
|
41
|
+
MonoRepo.instances.set(this.path, this);
|
|
42
|
+
}
|
|
43
|
+
get monoRepo() {
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
get packageJsonPath() {
|
|
47
|
+
return path.join(this.path, "package.json");
|
|
48
|
+
}
|
|
49
|
+
get tsconfigBaseJsonPath() {
|
|
50
|
+
return path.join(this.path, "tsconfig.json");
|
|
51
|
+
}
|
|
52
|
+
get tsconfigBase() {
|
|
53
|
+
const o = readJsonSync(this.tsconfigBaseJsonPath);
|
|
54
|
+
if (!o.compilerOptions) {
|
|
55
|
+
o.compilerOptions = {};
|
|
56
|
+
}
|
|
57
|
+
o.compilerOptions.paths = o.compilerOptions.paths || this.tsconfigBasePaths;
|
|
58
|
+
return o;
|
|
59
|
+
}
|
|
60
|
+
get tsconfigBasePathsJsonPath() {
|
|
61
|
+
return path.join(this.path, "tsconfig.paths.json");
|
|
62
|
+
}
|
|
63
|
+
get tsconfigBasePaths() {
|
|
64
|
+
if (!fs.existsSync(this.tsconfigBasePathsJsonPath)) {
|
|
65
|
+
return {};
|
|
66
|
+
}
|
|
67
|
+
return readJsonSync(this.tsconfigBasePathsJsonPath).compilerOptions?.paths ?? {};
|
|
68
|
+
}
|
|
69
|
+
get packageJson() {
|
|
70
|
+
return readJsonSync(this.packageJsonPath);
|
|
71
|
+
}
|
|
72
|
+
get name() {
|
|
73
|
+
if (!this.packageJson.name) {
|
|
74
|
+
throw new Error(`MonoRepo package.json missing 'name' field: ${this.packageJsonPath}`);
|
|
75
|
+
}
|
|
76
|
+
return this.packageJson.name;
|
|
77
|
+
}
|
|
78
|
+
get workspacesRootPaths() {
|
|
79
|
+
if (!this.packageJson.workspaces) {
|
|
80
|
+
throw new Error(`MonoRepo package.json missing 'workspaces' field: ${this.packageJsonPath}`);
|
|
81
|
+
}
|
|
82
|
+
return this.packageJson.workspaces.map((workspacePath) => {
|
|
83
|
+
return path.join(this.path, workspacePath.replace(/\*$/, ""));
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
get workspacePaths() {
|
|
87
|
+
return this.workspacesRootPaths.flatMap((workspacePath) => {
|
|
88
|
+
return fs.readdirSync(workspacePath, {
|
|
89
|
+
withFileTypes: true
|
|
90
|
+
}).filter((dirent) => {
|
|
91
|
+
return dirent.isDirectory();
|
|
92
|
+
}).map((dirent) => {
|
|
93
|
+
return path.join(workspacePath, dirent.name);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
get workspaces() {
|
|
98
|
+
return this.workspacePaths.map((dirpath) => {
|
|
99
|
+
return new Workspace(this, dirpath);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
_ts_decorate([
|
|
104
|
+
lazyProp(5e3),
|
|
105
|
+
_ts_metadata("design:type", void 0),
|
|
106
|
+
_ts_metadata("design:paramtypes", [])
|
|
107
|
+
], MonoRepo.prototype, "tsconfigBase", null);
|
|
108
|
+
_ts_decorate([
|
|
109
|
+
lazyProp(5e3),
|
|
110
|
+
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record),
|
|
111
|
+
_ts_metadata("design:paramtypes", [])
|
|
112
|
+
], MonoRepo.prototype, "tsconfigBasePaths", null);
|
|
113
|
+
_ts_decorate([
|
|
114
|
+
lazyProp(5e3),
|
|
115
|
+
_ts_metadata("design:type", typeof PackageJson === "undefined" ? Object : PackageJson),
|
|
116
|
+
_ts_metadata("design:paramtypes", [])
|
|
117
|
+
], MonoRepo.prototype, "packageJson", null);
|
|
118
|
+
_ts_decorate([
|
|
119
|
+
lazyProp(5e3),
|
|
120
|
+
_ts_metadata("design:type", void 0),
|
|
121
|
+
_ts_metadata("design:paramtypes", [])
|
|
122
|
+
], MonoRepo.prototype, "workspacePaths", null);
|
|
123
|
+
_ts_decorate([
|
|
124
|
+
lazyProp,
|
|
125
|
+
_ts_metadata("design:type", Array),
|
|
126
|
+
_ts_metadata("design:paramtypes", [])
|
|
127
|
+
], MonoRepo.prototype, "workspaces", null);
|
|
128
|
+
MonoRepo = _ts_decorate([
|
|
129
|
+
Parenting.compose,
|
|
130
|
+
_ts_metadata("design:type", Function),
|
|
131
|
+
_ts_metadata("design:paramtypes", [])
|
|
132
|
+
], MonoRepo);
|
|
133
|
+
|
|
134
|
+
export { MonoRepo };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var AbstractBase = require('../common/AbstractBase');
|
|
4
|
+
var File = require('../file/File');
|
|
5
|
+
var composition = require('@mono/composition');
|
|
6
|
+
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
10
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
12
|
+
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;
|
|
13
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
|
+
}
|
|
15
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
16
|
+
function _ts_metadata(k, v) {
|
|
17
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
18
|
+
}
|
|
19
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
20
|
+
class AbstractCode extends AbstractBase.AbstractBase {
|
|
21
|
+
static {
|
|
22
|
+
__name(this, "AbstractCode");
|
|
23
|
+
}
|
|
24
|
+
static inspector = composition.Inspector.compose(AbstractCode, {
|
|
25
|
+
keys: []
|
|
26
|
+
});
|
|
27
|
+
static codePreviewOptions = {
|
|
28
|
+
maxLines: 10,
|
|
29
|
+
maxLineLength: 90
|
|
30
|
+
};
|
|
31
|
+
constructor(parent) {
|
|
32
|
+
super(parent);
|
|
33
|
+
}
|
|
34
|
+
get path() {
|
|
35
|
+
return this.getParentDeep(File.File).path;
|
|
36
|
+
}
|
|
37
|
+
get code() {
|
|
38
|
+
return this.toString();
|
|
39
|
+
}
|
|
40
|
+
get isMultiLine() {
|
|
41
|
+
return this.code.includes("\n");
|
|
42
|
+
}
|
|
43
|
+
get lines() {
|
|
44
|
+
return this.code.split(/\r*\n/);
|
|
45
|
+
}
|
|
46
|
+
get codePreview() {
|
|
47
|
+
const maxLines = AbstractCode.codePreviewOptions.maxLines;
|
|
48
|
+
const maxLineLength = AbstractCode.codePreviewOptions.maxLineLength;
|
|
49
|
+
const applyMaxLineLength = /* @__PURE__ */ __name((line) => {
|
|
50
|
+
return line.length > maxLineLength ? `${line.substring(0, maxLineLength - 3)}...` : line;
|
|
51
|
+
}, "applyMaxLineLength");
|
|
52
|
+
return this.isMultiLine ? this.lines.slice(0, maxLines).map(applyMaxLineLength) : applyMaxLineLength(this.code);
|
|
53
|
+
}
|
|
54
|
+
codeIndexRangeOf(code) {
|
|
55
|
+
const index = this.code.indexOf(code);
|
|
56
|
+
if (index === -1) {
|
|
57
|
+
throw new Error(`Code not found: ${code}`);
|
|
58
|
+
}
|
|
59
|
+
const lastIndex = index + code.length;
|
|
60
|
+
return {
|
|
61
|
+
index,
|
|
62
|
+
lastIndex
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
getCodeRange(range) {
|
|
66
|
+
return this.code.substring(range.index, range.lastIndex);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
AbstractCode = _ts_decorate([
|
|
70
|
+
composition.Parenting.compose,
|
|
71
|
+
_ts_metadata("design:type", Function),
|
|
72
|
+
_ts_metadata("design:paramtypes", [
|
|
73
|
+
typeof P === "undefined" ? Object : P
|
|
74
|
+
])
|
|
75
|
+
], AbstractCode);
|
|
76
|
+
|
|
77
|
+
exports.AbstractCode = AbstractCode;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { A as AbstractBase, I as InspectorOptions } from '../AbstractBase-J4h6nW8k.cjs';
|
|
2
|
+
import 'util';
|
|
3
|
+
import 'mnemonist';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Abstract base class for representing code structures in the monorepo with inspection and preview capabilities.
|
|
7
|
+
*/
|
|
8
|
+
declare abstract class AbstractCode<P extends AbstractBase = AbstractBase> extends AbstractBase<P> {
|
|
9
|
+
static readonly inspector: InspectorOptions;
|
|
10
|
+
static readonly codePreviewOptions: {
|
|
11
|
+
maxLines: number;
|
|
12
|
+
maxLineLength: number;
|
|
13
|
+
};
|
|
14
|
+
constructor(parent: P);
|
|
15
|
+
get path(): string;
|
|
16
|
+
get code(): string;
|
|
17
|
+
get isMultiLine(): boolean;
|
|
18
|
+
get lines(): string[];
|
|
19
|
+
get codePreview(): string | string[];
|
|
20
|
+
codeIndexRangeOf(code: string): {
|
|
21
|
+
index: number;
|
|
22
|
+
lastIndex: number;
|
|
23
|
+
};
|
|
24
|
+
getCodeRange(range: {
|
|
25
|
+
index: number;
|
|
26
|
+
lastIndex: number;
|
|
27
|
+
}): string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { AbstractCode };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { A as AbstractBase, I as InspectorOptions } from '../AbstractBase-J4h6nW8k.js';
|
|
2
|
+
import 'util';
|
|
3
|
+
import 'mnemonist';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Abstract base class for representing code structures in the monorepo with inspection and preview capabilities.
|
|
7
|
+
*/
|
|
8
|
+
declare abstract class AbstractCode<P extends AbstractBase = AbstractBase> extends AbstractBase<P> {
|
|
9
|
+
static readonly inspector: InspectorOptions;
|
|
10
|
+
static readonly codePreviewOptions: {
|
|
11
|
+
maxLines: number;
|
|
12
|
+
maxLineLength: number;
|
|
13
|
+
};
|
|
14
|
+
constructor(parent: P);
|
|
15
|
+
get path(): string;
|
|
16
|
+
get code(): string;
|
|
17
|
+
get isMultiLine(): boolean;
|
|
18
|
+
get lines(): string[];
|
|
19
|
+
get codePreview(): string | string[];
|
|
20
|
+
codeIndexRangeOf(code: string): {
|
|
21
|
+
index: number;
|
|
22
|
+
lastIndex: number;
|
|
23
|
+
};
|
|
24
|
+
getCodeRange(range: {
|
|
25
|
+
index: number;
|
|
26
|
+
lastIndex: number;
|
|
27
|
+
}): string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { AbstractCode };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { __name } from '../chunk-SHUYVCID.js';
|
|
2
|
+
import { AbstractBase } from '../common/AbstractBase';
|
|
3
|
+
import { File } from '../file/File';
|
|
4
|
+
import { Inspector, Parenting } from '@mono/composition';
|
|
5
|
+
|
|
6
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
7
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
9
|
+
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;
|
|
10
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11
|
+
}
|
|
12
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
13
|
+
function _ts_metadata(k, v) {
|
|
14
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
15
|
+
}
|
|
16
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
17
|
+
class AbstractCode extends AbstractBase {
|
|
18
|
+
static {
|
|
19
|
+
__name(this, "AbstractCode");
|
|
20
|
+
}
|
|
21
|
+
static inspector = Inspector.compose(AbstractCode, {
|
|
22
|
+
keys: []
|
|
23
|
+
});
|
|
24
|
+
static codePreviewOptions = {
|
|
25
|
+
maxLines: 10,
|
|
26
|
+
maxLineLength: 90
|
|
27
|
+
};
|
|
28
|
+
constructor(parent) {
|
|
29
|
+
super(parent);
|
|
30
|
+
}
|
|
31
|
+
get path() {
|
|
32
|
+
return this.getParentDeep(File).path;
|
|
33
|
+
}
|
|
34
|
+
get code() {
|
|
35
|
+
return this.toString();
|
|
36
|
+
}
|
|
37
|
+
get isMultiLine() {
|
|
38
|
+
return this.code.includes("\n");
|
|
39
|
+
}
|
|
40
|
+
get lines() {
|
|
41
|
+
return this.code.split(/\r*\n/);
|
|
42
|
+
}
|
|
43
|
+
get codePreview() {
|
|
44
|
+
const maxLines = AbstractCode.codePreviewOptions.maxLines;
|
|
45
|
+
const maxLineLength = AbstractCode.codePreviewOptions.maxLineLength;
|
|
46
|
+
const applyMaxLineLength = /* @__PURE__ */ __name((line) => {
|
|
47
|
+
return line.length > maxLineLength ? `${line.substring(0, maxLineLength - 3)}...` : line;
|
|
48
|
+
}, "applyMaxLineLength");
|
|
49
|
+
return this.isMultiLine ? this.lines.slice(0, maxLines).map(applyMaxLineLength) : applyMaxLineLength(this.code);
|
|
50
|
+
}
|
|
51
|
+
codeIndexRangeOf(code) {
|
|
52
|
+
const index = this.code.indexOf(code);
|
|
53
|
+
if (index === -1) {
|
|
54
|
+
throw new Error(`Code not found: ${code}`);
|
|
55
|
+
}
|
|
56
|
+
const lastIndex = index + code.length;
|
|
57
|
+
return {
|
|
58
|
+
index,
|
|
59
|
+
lastIndex
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
getCodeRange(range) {
|
|
63
|
+
return this.code.substring(range.index, range.lastIndex);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
AbstractCode = _ts_decorate([
|
|
67
|
+
Parenting.compose,
|
|
68
|
+
_ts_metadata("design:type", Function),
|
|
69
|
+
_ts_metadata("design:paramtypes", [
|
|
70
|
+
typeof P === "undefined" ? Object : P
|
|
71
|
+
])
|
|
72
|
+
], AbstractCode);
|
|
73
|
+
|
|
74
|
+
export { AbstractCode };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var AbstractCode = require('./AbstractCode');
|
|
4
|
+
var composition = require('@mono/composition');
|
|
5
|
+
var decorators = require('@mono/decorators');
|
|
6
|
+
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
10
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
12
|
+
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;
|
|
13
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
|
+
}
|
|
15
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
16
|
+
function _ts_metadata(k, v) {
|
|
17
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
18
|
+
}
|
|
19
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
20
|
+
class CodeBlock extends AbstractCode.AbstractCode {
|
|
21
|
+
static {
|
|
22
|
+
__name(this, "CodeBlock");
|
|
23
|
+
}
|
|
24
|
+
static inspector = composition.Inspector.compose(CodeBlock, {
|
|
25
|
+
keys: []
|
|
26
|
+
});
|
|
27
|
+
indexRange;
|
|
28
|
+
constructor(parent, indexRange) {
|
|
29
|
+
super(parent);
|
|
30
|
+
this.indexRange = indexRange;
|
|
31
|
+
}
|
|
32
|
+
toString() {
|
|
33
|
+
return this.parenting.getParent().getCodeRange(this.indexRange);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
_ts_decorate([
|
|
37
|
+
decorators.lazyProp(2500),
|
|
38
|
+
_ts_metadata("design:type", Function),
|
|
39
|
+
_ts_metadata("design:paramtypes", []),
|
|
40
|
+
_ts_metadata("design:returntype", String)
|
|
41
|
+
], CodeBlock.prototype, "toString", null);
|
|
42
|
+
CodeBlock = _ts_decorate([
|
|
43
|
+
composition.Parenting.compose,
|
|
44
|
+
_ts_metadata("design:type", Function),
|
|
45
|
+
_ts_metadata("design:paramtypes", [
|
|
46
|
+
typeof P === "undefined" ? Object : P,
|
|
47
|
+
Object
|
|
48
|
+
])
|
|
49
|
+
], CodeBlock);
|
|
50
|
+
|
|
51
|
+
exports.CodeBlock = CodeBlock;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { I as InspectorOptions } from '../AbstractBase-J4h6nW8k.cjs';
|
|
2
|
+
import { AbstractCode } from './AbstractCode.cjs';
|
|
3
|
+
import 'util';
|
|
4
|
+
import 'mnemonist';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents a block of code within a larger code structure, defined by an index range.
|
|
8
|
+
*/
|
|
9
|
+
declare class CodeBlock<P extends AbstractCode = AbstractCode> extends AbstractCode<P> {
|
|
10
|
+
static readonly inspector: InspectorOptions;
|
|
11
|
+
readonly indexRange: {
|
|
12
|
+
index: number;
|
|
13
|
+
lastIndex: number;
|
|
14
|
+
};
|
|
15
|
+
constructor(parent: P, indexRange: {
|
|
16
|
+
index: number;
|
|
17
|
+
lastIndex: number;
|
|
18
|
+
});
|
|
19
|
+
toString(): string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { CodeBlock };
|