@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
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import '../../AbstractBase-J4h6nW8k.cjs';
|
|
2
|
+
import '../CodeBlock.cjs';
|
|
3
|
+
export { b as ImportStatement } from '../../MonoRepo-BgdabVzT.cjs';
|
|
4
|
+
import 'util';
|
|
5
|
+
import 'mnemonist';
|
|
6
|
+
import '../AbstractCode.cjs';
|
|
7
|
+
import '../../is-never.d-CgQ1j0-8.cjs';
|
|
8
|
+
import 'typescript';
|
|
9
|
+
import 'depcheck';
|
|
10
|
+
import 'fs';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import '../../AbstractBase-J4h6nW8k.js';
|
|
2
|
+
import '../CodeBlock.js';
|
|
3
|
+
export { b as ImportStatement } from '../../MonoRepo-BFFUDAYn.js';
|
|
4
|
+
import 'util';
|
|
5
|
+
import 'mnemonist';
|
|
6
|
+
import '../AbstractCode.js';
|
|
7
|
+
import '../../is-never.d-CgQ1j0-8.js';
|
|
8
|
+
import 'typescript';
|
|
9
|
+
import 'depcheck';
|
|
10
|
+
import 'fs';
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { __name } from '../../chunk-SHUYVCID.js';
|
|
2
|
+
import { CodeBlock } from '../CodeBlock';
|
|
3
|
+
import { ImportKeywords } from './ImportKeywords';
|
|
4
|
+
import { ImportSpecifiers } from './ImportSpecifiers';
|
|
5
|
+
import { Inspector, Parenting } from '@mono/composition';
|
|
6
|
+
import { ModuleSpecifier } from './ModuleSpecifier';
|
|
7
|
+
import { TsFile } from '../../file/TsFile';
|
|
8
|
+
import { lazyProp } from '@mono/decorators';
|
|
9
|
+
|
|
10
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
11
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
13
|
+
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;
|
|
14
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
15
|
+
}
|
|
16
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
17
|
+
function _ts_metadata(k, v) {
|
|
18
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
19
|
+
}
|
|
20
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
21
|
+
class ImportStatement extends CodeBlock {
|
|
22
|
+
static {
|
|
23
|
+
__name(this, "ImportStatement");
|
|
24
|
+
}
|
|
25
|
+
static inspector = Inspector.compose(ImportStatement, {
|
|
26
|
+
keys: [
|
|
27
|
+
"keywords",
|
|
28
|
+
"specifiers",
|
|
29
|
+
"module"
|
|
30
|
+
],
|
|
31
|
+
inspect: {
|
|
32
|
+
compact: true
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
toOneLine() {
|
|
36
|
+
return this.code.replaceAll(/\r?\n/g, " ").replaceAll(/\s{2,}/g, " ").replace(/,\s+}/, " }");
|
|
37
|
+
}
|
|
38
|
+
get keywords() {
|
|
39
|
+
const match = this.code.match(/^import\s+(?:type\s+)?/);
|
|
40
|
+
const code = match[0].trim();
|
|
41
|
+
return new ImportKeywords(this, this.codeIndexRangeOf(code));
|
|
42
|
+
}
|
|
43
|
+
get specifiers() {
|
|
44
|
+
const match = this.code.match(/import\s+([^"']+)\s+from\s+/);
|
|
45
|
+
const code = match ? match[1].trim() : "";
|
|
46
|
+
if (!code) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
return new ImportSpecifiers(this, this.codeIndexRangeOf(code));
|
|
50
|
+
}
|
|
51
|
+
get module() {
|
|
52
|
+
const match = this.code.match(/(?:from|import)\s+["']([^"']+)["']/);
|
|
53
|
+
const code = match[1].trim();
|
|
54
|
+
return new ModuleSpecifier(this, this.codeIndexRangeOf(code));
|
|
55
|
+
}
|
|
56
|
+
split() {
|
|
57
|
+
return this.specifiers?.splitSpecifiers().map((specifier) => {
|
|
58
|
+
return `import ${specifier} from '${this.module.from}'`;
|
|
59
|
+
}) ?? [
|
|
60
|
+
this.code
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
get filepath() {
|
|
64
|
+
return this.getParentDeep(TsFile).path;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
_ts_decorate([
|
|
68
|
+
lazyProp,
|
|
69
|
+
_ts_metadata("design:type", void 0),
|
|
70
|
+
_ts_metadata("design:paramtypes", [])
|
|
71
|
+
], ImportStatement.prototype, "keywords", null);
|
|
72
|
+
_ts_decorate([
|
|
73
|
+
lazyProp,
|
|
74
|
+
_ts_metadata("design:type", void 0),
|
|
75
|
+
_ts_metadata("design:paramtypes", [])
|
|
76
|
+
], ImportStatement.prototype, "specifiers", null);
|
|
77
|
+
_ts_decorate([
|
|
78
|
+
lazyProp,
|
|
79
|
+
_ts_metadata("design:type", void 0),
|
|
80
|
+
_ts_metadata("design:paramtypes", [])
|
|
81
|
+
], ImportStatement.prototype, "module", null);
|
|
82
|
+
ImportStatement = _ts_decorate([
|
|
83
|
+
Parenting.compose
|
|
84
|
+
], ImportStatement);
|
|
85
|
+
|
|
86
|
+
export { ImportStatement };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var CodeBlock = require('../CodeBlock');
|
|
4
|
+
var composition = require('@mono/composition');
|
|
5
|
+
var MonoRepo = require('../../MonoRepo');
|
|
6
|
+
var Workspace = require('../../repo/Workspace');
|
|
7
|
+
var module$1 = require('module');
|
|
8
|
+
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
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
|
+
class ModuleSpecifier extends CodeBlock.CodeBlock {
|
|
19
|
+
static {
|
|
20
|
+
__name(this, "ModuleSpecifier");
|
|
21
|
+
}
|
|
22
|
+
static inspector = composition.Inspector.compose(ModuleSpecifier, {
|
|
23
|
+
keys: [
|
|
24
|
+
"from"
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Alias for the `code` property.
|
|
29
|
+
*/
|
|
30
|
+
get from() {
|
|
31
|
+
return this.code;
|
|
32
|
+
}
|
|
33
|
+
get dependency() {
|
|
34
|
+
if (!this.isDependency) {
|
|
35
|
+
return void 0;
|
|
36
|
+
}
|
|
37
|
+
return this.code.split("/").slice(0, this.isScoped ? 2 : 1).join("/");
|
|
38
|
+
}
|
|
39
|
+
get isBuiltin() {
|
|
40
|
+
return module$1.builtinModules.includes(this.code.replace(/^node:/i, ""));
|
|
41
|
+
}
|
|
42
|
+
get isScoped() {
|
|
43
|
+
return this.code.startsWith("@");
|
|
44
|
+
}
|
|
45
|
+
get isRepoScoped() {
|
|
46
|
+
return this.code.startsWith(`@${this.getParentDeep(MonoRepo.MonoRepo).name}/`);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns whether import is an other, but local workspace in the monorepo.
|
|
50
|
+
*/
|
|
51
|
+
get isOtherRepoWorkspace() {
|
|
52
|
+
return this.getParentDeep(MonoRepo.MonoRepo).workspaces.map((ws) => {
|
|
53
|
+
return ws.name;
|
|
54
|
+
}).filter((name) => {
|
|
55
|
+
return name !== this.getParentDeep(Workspace.Workspace).name;
|
|
56
|
+
}).some((name) => {
|
|
57
|
+
return this.code.includes(name);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
get isRelative() {
|
|
61
|
+
return this.code.startsWith(".");
|
|
62
|
+
}
|
|
63
|
+
get isFromRepoRoot() {
|
|
64
|
+
return this.code.startsWith("/");
|
|
65
|
+
}
|
|
66
|
+
get isExternal() {
|
|
67
|
+
return !this.isBuiltin && !this.isRepoScoped && !this.isRelative;
|
|
68
|
+
}
|
|
69
|
+
get isDependency() {
|
|
70
|
+
return this.isExternal || this.isRepoScoped;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
ModuleSpecifier = _ts_decorate([
|
|
74
|
+
composition.Parenting.compose
|
|
75
|
+
], ModuleSpecifier);
|
|
76
|
+
|
|
77
|
+
exports.ModuleSpecifier = ModuleSpecifier;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import '../../AbstractBase-J4h6nW8k.cjs';
|
|
2
|
+
import '../CodeBlock.cjs';
|
|
3
|
+
export { M as ModuleSpecifier } from '../../MonoRepo-BgdabVzT.cjs';
|
|
4
|
+
import 'util';
|
|
5
|
+
import 'mnemonist';
|
|
6
|
+
import '../AbstractCode.cjs';
|
|
7
|
+
import '../../is-never.d-CgQ1j0-8.cjs';
|
|
8
|
+
import 'typescript';
|
|
9
|
+
import 'depcheck';
|
|
10
|
+
import 'fs';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import '../../AbstractBase-J4h6nW8k.js';
|
|
2
|
+
import '../CodeBlock.js';
|
|
3
|
+
export { M as ModuleSpecifier } from '../../MonoRepo-BFFUDAYn.js';
|
|
4
|
+
import 'util';
|
|
5
|
+
import 'mnemonist';
|
|
6
|
+
import '../AbstractCode.js';
|
|
7
|
+
import '../../is-never.d-CgQ1j0-8.js';
|
|
8
|
+
import 'typescript';
|
|
9
|
+
import 'depcheck';
|
|
10
|
+
import 'fs';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { __name } from '../../chunk-SHUYVCID.js';
|
|
2
|
+
import { CodeBlock } from '../CodeBlock';
|
|
3
|
+
import { Inspector, Parenting } from '@mono/composition';
|
|
4
|
+
import { MonoRepo } from '../../MonoRepo';
|
|
5
|
+
import { Workspace } from '../../repo/Workspace';
|
|
6
|
+
import { builtinModules } from 'module';
|
|
7
|
+
|
|
8
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
9
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
11
|
+
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;
|
|
12
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
13
|
+
}
|
|
14
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
15
|
+
class ModuleSpecifier extends CodeBlock {
|
|
16
|
+
static {
|
|
17
|
+
__name(this, "ModuleSpecifier");
|
|
18
|
+
}
|
|
19
|
+
static inspector = Inspector.compose(ModuleSpecifier, {
|
|
20
|
+
keys: [
|
|
21
|
+
"from"
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Alias for the `code` property.
|
|
26
|
+
*/
|
|
27
|
+
get from() {
|
|
28
|
+
return this.code;
|
|
29
|
+
}
|
|
30
|
+
get dependency() {
|
|
31
|
+
if (!this.isDependency) {
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
return this.code.split("/").slice(0, this.isScoped ? 2 : 1).join("/");
|
|
35
|
+
}
|
|
36
|
+
get isBuiltin() {
|
|
37
|
+
return builtinModules.includes(this.code.replace(/^node:/i, ""));
|
|
38
|
+
}
|
|
39
|
+
get isScoped() {
|
|
40
|
+
return this.code.startsWith("@");
|
|
41
|
+
}
|
|
42
|
+
get isRepoScoped() {
|
|
43
|
+
return this.code.startsWith(`@${this.getParentDeep(MonoRepo).name}/`);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns whether import is an other, but local workspace in the monorepo.
|
|
47
|
+
*/
|
|
48
|
+
get isOtherRepoWorkspace() {
|
|
49
|
+
return this.getParentDeep(MonoRepo).workspaces.map((ws) => {
|
|
50
|
+
return ws.name;
|
|
51
|
+
}).filter((name) => {
|
|
52
|
+
return name !== this.getParentDeep(Workspace).name;
|
|
53
|
+
}).some((name) => {
|
|
54
|
+
return this.code.includes(name);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
get isRelative() {
|
|
58
|
+
return this.code.startsWith(".");
|
|
59
|
+
}
|
|
60
|
+
get isFromRepoRoot() {
|
|
61
|
+
return this.code.startsWith("/");
|
|
62
|
+
}
|
|
63
|
+
get isExternal() {
|
|
64
|
+
return !this.isBuiltin && !this.isRepoScoped && !this.isRelative;
|
|
65
|
+
}
|
|
66
|
+
get isDependency() {
|
|
67
|
+
return this.isExternal || this.isRepoScoped;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
ModuleSpecifier = _ts_decorate([
|
|
71
|
+
Parenting.compose
|
|
72
|
+
], ModuleSpecifier);
|
|
73
|
+
|
|
74
|
+
export { ModuleSpecifier };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var composition = require('@mono/composition');
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
8
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10
|
+
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;
|
|
11
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12
|
+
}
|
|
13
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
14
|
+
function _ts_metadata(k, v) {
|
|
15
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
16
|
+
}
|
|
17
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
18
|
+
class AbstractBase {
|
|
19
|
+
static {
|
|
20
|
+
__name(this, "AbstractBase");
|
|
21
|
+
}
|
|
22
|
+
static inspector = composition.Inspector.compose(AbstractBase, {
|
|
23
|
+
keys: [],
|
|
24
|
+
autoAddBooleanKeys: true,
|
|
25
|
+
ignoreKeys: [],
|
|
26
|
+
ignoreValues: {
|
|
27
|
+
noEmptyArray: true,
|
|
28
|
+
noEmptyObject: true,
|
|
29
|
+
noNull: true,
|
|
30
|
+
noUndefined: true,
|
|
31
|
+
noFalse: true
|
|
32
|
+
},
|
|
33
|
+
inspect: {
|
|
34
|
+
customInspect: true,
|
|
35
|
+
maxStringLength: 500,
|
|
36
|
+
maxArrayLength: 5,
|
|
37
|
+
breakLength: 80,
|
|
38
|
+
colors: true,
|
|
39
|
+
depth: null,
|
|
40
|
+
compact: false,
|
|
41
|
+
numericSeparator: true
|
|
42
|
+
},
|
|
43
|
+
filters: []
|
|
44
|
+
});
|
|
45
|
+
constructor(parent) {
|
|
46
|
+
this.parenting.onInstance(parent);
|
|
47
|
+
}
|
|
48
|
+
findParentDeep(predicate) {
|
|
49
|
+
for (const parent of this.parenting.iterateAncestors()) {
|
|
50
|
+
if (predicate(parent)) {
|
|
51
|
+
return parent;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
get parent() {
|
|
57
|
+
return this.parenting.getParent();
|
|
58
|
+
}
|
|
59
|
+
getParentDeep(instanceOf) {
|
|
60
|
+
const parent = this.findParentDeep((p) => {
|
|
61
|
+
return p instanceof instanceOf;
|
|
62
|
+
});
|
|
63
|
+
if (!parent) {
|
|
64
|
+
throw new Error(`Parent of type ${instanceOf.name} not found.`);
|
|
65
|
+
}
|
|
66
|
+
return parent;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
AbstractBase = _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
|
+
], AbstractBase);
|
|
76
|
+
|
|
77
|
+
exports.AbstractBase = AbstractBase;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { __name } from '../chunk-SHUYVCID.js';
|
|
2
|
+
import { Inspector, Parenting } from '@mono/composition';
|
|
3
|
+
|
|
4
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
5
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7
|
+
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;
|
|
8
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
9
|
+
}
|
|
10
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
11
|
+
function _ts_metadata(k, v) {
|
|
12
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
13
|
+
}
|
|
14
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
15
|
+
class AbstractBase {
|
|
16
|
+
static {
|
|
17
|
+
__name(this, "AbstractBase");
|
|
18
|
+
}
|
|
19
|
+
static inspector = Inspector.compose(AbstractBase, {
|
|
20
|
+
keys: [],
|
|
21
|
+
autoAddBooleanKeys: true,
|
|
22
|
+
ignoreKeys: [],
|
|
23
|
+
ignoreValues: {
|
|
24
|
+
noEmptyArray: true,
|
|
25
|
+
noEmptyObject: true,
|
|
26
|
+
noNull: true,
|
|
27
|
+
noUndefined: true,
|
|
28
|
+
noFalse: true
|
|
29
|
+
},
|
|
30
|
+
inspect: {
|
|
31
|
+
customInspect: true,
|
|
32
|
+
maxStringLength: 500,
|
|
33
|
+
maxArrayLength: 5,
|
|
34
|
+
breakLength: 80,
|
|
35
|
+
colors: true,
|
|
36
|
+
depth: null,
|
|
37
|
+
compact: false,
|
|
38
|
+
numericSeparator: true
|
|
39
|
+
},
|
|
40
|
+
filters: []
|
|
41
|
+
});
|
|
42
|
+
constructor(parent) {
|
|
43
|
+
this.parenting.onInstance(parent);
|
|
44
|
+
}
|
|
45
|
+
findParentDeep(predicate) {
|
|
46
|
+
for (const parent of this.parenting.iterateAncestors()) {
|
|
47
|
+
if (predicate(parent)) {
|
|
48
|
+
return parent;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return void 0;
|
|
52
|
+
}
|
|
53
|
+
get parent() {
|
|
54
|
+
return this.parenting.getParent();
|
|
55
|
+
}
|
|
56
|
+
getParentDeep(instanceOf) {
|
|
57
|
+
const parent = this.findParentDeep((p) => {
|
|
58
|
+
return p instanceof instanceOf;
|
|
59
|
+
});
|
|
60
|
+
if (!parent) {
|
|
61
|
+
throw new Error(`Parent of type ${instanceOf.name} not found.`);
|
|
62
|
+
}
|
|
63
|
+
return parent;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
AbstractBase = _ts_decorate([
|
|
67
|
+
Parenting.compose,
|
|
68
|
+
_ts_metadata("design:type", Function),
|
|
69
|
+
_ts_metadata("design:paramtypes", [
|
|
70
|
+
typeof P === "undefined" ? Object : P
|
|
71
|
+
])
|
|
72
|
+
], AbstractBase);
|
|
73
|
+
|
|
74
|
+
export { AbstractBase };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('@mono/path');
|
|
4
|
+
var AbstractBase = require('../common/AbstractBase');
|
|
5
|
+
var composition = require('@mono/composition');
|
|
6
|
+
var SemanticExtnamePrefix = require('../util/SemanticExtnamePrefix');
|
|
7
|
+
var fs = require('fs');
|
|
8
|
+
var hasExtnamePrefix = require('../util/hasExtnamePrefix');
|
|
9
|
+
var decorators = require('@mono/decorators');
|
|
10
|
+
var upath = require('upath');
|
|
11
|
+
|
|
12
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
|
|
14
|
+
function _interopNamespace(e) {
|
|
15
|
+
if (e && e.__esModule) return e;
|
|
16
|
+
var n = Object.create(null);
|
|
17
|
+
if (e) {
|
|
18
|
+
Object.keys(e).forEach(function (k) {
|
|
19
|
+
if (k !== 'default') {
|
|
20
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
21
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return e[k]; }
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
n.default = e;
|
|
29
|
+
return Object.freeze(n);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
33
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
34
|
+
var upath__default = /*#__PURE__*/_interopDefault(upath);
|
|
35
|
+
|
|
36
|
+
var __defProp = Object.defineProperty;
|
|
37
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
38
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
39
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
40
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
41
|
+
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;
|
|
42
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
43
|
+
}
|
|
44
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
45
|
+
function _ts_metadata(k, v) {
|
|
46
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
47
|
+
}
|
|
48
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
49
|
+
class File extends AbstractBase.AbstractBase {
|
|
50
|
+
static {
|
|
51
|
+
__name(this, "File");
|
|
52
|
+
}
|
|
53
|
+
static inspector = composition.Inspector.compose(File, {
|
|
54
|
+
keys: [
|
|
55
|
+
"relative"
|
|
56
|
+
]
|
|
57
|
+
});
|
|
58
|
+
path;
|
|
59
|
+
constructor(parent, filepath) {
|
|
60
|
+
super(parent);
|
|
61
|
+
this.path = upath__default.default.normalize(filepath);
|
|
62
|
+
}
|
|
63
|
+
get stats() {
|
|
64
|
+
return fs__default.default.statSync(this.path);
|
|
65
|
+
}
|
|
66
|
+
get isTs() {
|
|
67
|
+
return path__namespace.hasExtname(this.path, [
|
|
68
|
+
"ts",
|
|
69
|
+
"mts",
|
|
70
|
+
"tsx"
|
|
71
|
+
]);
|
|
72
|
+
}
|
|
73
|
+
get isDotTs() {
|
|
74
|
+
return path__namespace.hasExtname(this.path, "ts");
|
|
75
|
+
}
|
|
76
|
+
get isDotTsx() {
|
|
77
|
+
return path__namespace.hasExtname(this.path, "tsx");
|
|
78
|
+
}
|
|
79
|
+
get isExample() {
|
|
80
|
+
return hasExtnamePrefix.hasExtnamePrefix(this.path, SemanticExtnamePrefix.SemanticExtnamePrefix.examples);
|
|
81
|
+
}
|
|
82
|
+
get isDeclaration() {
|
|
83
|
+
return hasExtnamePrefix.hasExtnamePrefix(this.path, SemanticExtnamePrefix.SemanticExtnamePrefix.d);
|
|
84
|
+
}
|
|
85
|
+
get isTest() {
|
|
86
|
+
return hasExtnamePrefix.hasExtnamePrefix(this.path, SemanticExtnamePrefix.SemanticExtnamePrefix.test);
|
|
87
|
+
}
|
|
88
|
+
get isIndexFile() {
|
|
89
|
+
return upath__default.default.parse(this.path).name === "index";
|
|
90
|
+
}
|
|
91
|
+
get isSourceFile() {
|
|
92
|
+
return path__namespace.hasParentDirname(this.path, "src") && !hasExtnamePrefix.hasExtnamePrefix(this.path);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Read the file contents.
|
|
96
|
+
*/
|
|
97
|
+
readFile() {
|
|
98
|
+
if (!fs__default.default.existsSync(this.path)) {
|
|
99
|
+
throw new Error(`File not found: ${this.path}`);
|
|
100
|
+
}
|
|
101
|
+
return fs__default.default.readFileSync(this.path, "utf8");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
_ts_decorate([
|
|
105
|
+
decorators.lazyProp(1e3),
|
|
106
|
+
_ts_metadata("design:type", typeof Stats === "undefined" ? Object : Stats),
|
|
107
|
+
_ts_metadata("design:paramtypes", [])
|
|
108
|
+
], File.prototype, "stats", null);
|
|
109
|
+
File = _ts_decorate([
|
|
110
|
+
composition.Parenting.compose,
|
|
111
|
+
_ts_metadata("design:type", Function),
|
|
112
|
+
_ts_metadata("design:paramtypes", [
|
|
113
|
+
typeof P === "undefined" ? Object : P,
|
|
114
|
+
String
|
|
115
|
+
])
|
|
116
|
+
], File);
|
|
117
|
+
|
|
118
|
+
exports.File = File;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import '../AbstractBase-J4h6nW8k.cjs';
|
|
2
|
+
import 'fs';
|
|
3
|
+
export { F as File } from '../MonoRepo-BgdabVzT.cjs';
|
|
4
|
+
import 'util';
|
|
5
|
+
import 'mnemonist';
|
|
6
|
+
import '../is-never.d-CgQ1j0-8.cjs';
|
|
7
|
+
import 'typescript';
|
|
8
|
+
import 'depcheck';
|
|
9
|
+
import '../code/AbstractCode.cjs';
|
|
10
|
+
import '../code/CodeBlock.cjs';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import '../AbstractBase-J4h6nW8k.js';
|
|
2
|
+
import 'fs';
|
|
3
|
+
export { F as File } from '../MonoRepo-BFFUDAYn.js';
|
|
4
|
+
import 'util';
|
|
5
|
+
import 'mnemonist';
|
|
6
|
+
import '../is-never.d-CgQ1j0-8.js';
|
|
7
|
+
import 'typescript';
|
|
8
|
+
import 'depcheck';
|
|
9
|
+
import '../code/AbstractCode.js';
|
|
10
|
+
import '../code/CodeBlock.js';
|
package/lib/file/File.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { __name } from '../chunk-SHUYVCID.js';
|
|
2
|
+
import * as path from '@mono/path';
|
|
3
|
+
import { AbstractBase } from '../common/AbstractBase';
|
|
4
|
+
import { Inspector, Parenting } from '@mono/composition';
|
|
5
|
+
import { SemanticExtnamePrefix } from '../util/SemanticExtnamePrefix';
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import { hasExtnamePrefix } from '../util/hasExtnamePrefix';
|
|
8
|
+
import { lazyProp } from '@mono/decorators';
|
|
9
|
+
import upath from 'upath';
|
|
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 File extends AbstractBase {
|
|
23
|
+
static {
|
|
24
|
+
__name(this, "File");
|
|
25
|
+
}
|
|
26
|
+
static inspector = Inspector.compose(File, {
|
|
27
|
+
keys: [
|
|
28
|
+
"relative"
|
|
29
|
+
]
|
|
30
|
+
});
|
|
31
|
+
path;
|
|
32
|
+
constructor(parent, filepath) {
|
|
33
|
+
super(parent);
|
|
34
|
+
this.path = upath.normalize(filepath);
|
|
35
|
+
}
|
|
36
|
+
get stats() {
|
|
37
|
+
return fs.statSync(this.path);
|
|
38
|
+
}
|
|
39
|
+
get isTs() {
|
|
40
|
+
return path.hasExtname(this.path, [
|
|
41
|
+
"ts",
|
|
42
|
+
"mts",
|
|
43
|
+
"tsx"
|
|
44
|
+
]);
|
|
45
|
+
}
|
|
46
|
+
get isDotTs() {
|
|
47
|
+
return path.hasExtname(this.path, "ts");
|
|
48
|
+
}
|
|
49
|
+
get isDotTsx() {
|
|
50
|
+
return path.hasExtname(this.path, "tsx");
|
|
51
|
+
}
|
|
52
|
+
get isExample() {
|
|
53
|
+
return hasExtnamePrefix(this.path, SemanticExtnamePrefix.examples);
|
|
54
|
+
}
|
|
55
|
+
get isDeclaration() {
|
|
56
|
+
return hasExtnamePrefix(this.path, SemanticExtnamePrefix.d);
|
|
57
|
+
}
|
|
58
|
+
get isTest() {
|
|
59
|
+
return hasExtnamePrefix(this.path, SemanticExtnamePrefix.test);
|
|
60
|
+
}
|
|
61
|
+
get isIndexFile() {
|
|
62
|
+
return upath.parse(this.path).name === "index";
|
|
63
|
+
}
|
|
64
|
+
get isSourceFile() {
|
|
65
|
+
return path.hasParentDirname(this.path, "src") && !hasExtnamePrefix(this.path);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Read the file contents.
|
|
69
|
+
*/
|
|
70
|
+
readFile() {
|
|
71
|
+
if (!fs.existsSync(this.path)) {
|
|
72
|
+
throw new Error(`File not found: ${this.path}`);
|
|
73
|
+
}
|
|
74
|
+
return fs.readFileSync(this.path, "utf8");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
_ts_decorate([
|
|
78
|
+
lazyProp(1e3),
|
|
79
|
+
_ts_metadata("design:type", typeof Stats === "undefined" ? Object : Stats),
|
|
80
|
+
_ts_metadata("design:paramtypes", [])
|
|
81
|
+
], File.prototype, "stats", null);
|
|
82
|
+
File = _ts_decorate([
|
|
83
|
+
Parenting.compose,
|
|
84
|
+
_ts_metadata("design:type", Function),
|
|
85
|
+
_ts_metadata("design:paramtypes", [
|
|
86
|
+
typeof P === "undefined" ? Object : P,
|
|
87
|
+
String
|
|
88
|
+
])
|
|
89
|
+
], File);
|
|
90
|
+
|
|
91
|
+
export { File };
|