@decohere/workspace 0.0.1-dev.126 → 0.0.1-dev.5
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 +1 -1
- package/package.json +3 -13
- package/src/const.ts +19 -0
- package/src/errors.ts +1 -0
- package/src/factories/config.factory.ts +21 -0
- package/src/factories/find-workspace-root.ts +32 -0
- package/src/factories/project.factory.ts +75 -0
- package/src/factories/workspace.factory.ts +44 -0
- package/{types/src/index.d.ts → src/index.ts} +7 -1
- package/src/models/has-package-json.mixin.ts +30 -0
- package/src/models/has-tsconfig.mixin.ts +48 -0
- package/src/models/package-aliases.ts +130 -0
- package/src/models/package-json.model.ts +231 -0
- package/src/models/project-file-event.ts +9 -0
- package/src/models/project.model.ts +340 -0
- package/src/models/source-extensions.ts +59 -0
- package/src/models/tsconfig.model.ts +81 -0
- package/src/models/workspace-config.type.ts +57 -0
- package/src/models/workspace.model.ts +178 -0
- package/tests/find-workspace-root.spec.ts +30 -0
- package/tests/package-aliases.spec.ts +160 -0
- package/tests/package-json.model.spec.ts +78 -0
- package/tests/project.factory.spec.ts +100 -0
- package/tests/source-extensions.spec.ts +33 -0
- package/tests/workspace.factory.spec.ts +147 -0
- package/LICENSE +0 -15
- package/commonjs/src/const.js +0 -69
- package/commonjs/src/errors.js +0 -12
- package/commonjs/src/factories/config.factory.js +0 -90
- package/commonjs/src/factories/find-workspace-root.js +0 -37
- package/commonjs/src/factories/project.factory.js +0 -73
- package/commonjs/src/factories/workspace.factory.js +0 -50
- package/commonjs/src/index.js +0 -74
- package/commonjs/src/models/has-package-json.mixin.js +0 -50
- package/commonjs/src/models/has-tsconfig.mixin.js +0 -75
- package/commonjs/src/models/package-aliases.js +0 -112
- package/commonjs/src/models/package-json.model.js +0 -202
- package/commonjs/src/models/project-file-event.js +0 -4
- package/commonjs/src/models/project.model.js +0 -316
- package/commonjs/src/models/source-extensions.js +0 -81
- package/commonjs/src/models/tsconfig.model.js +0 -97
- package/commonjs/src/models/workspace-config.type.js +0 -7
- package/commonjs/src/models/workspace.model.js +0 -153
- package/es6/src/const.js +0 -36
- package/es6/src/errors.js +0 -2
- package/es6/src/factories/config.factory.js +0 -34
- package/es6/src/factories/find-workspace-root.js +0 -26
- package/es6/src/factories/project.factory.js +0 -58
- package/es6/src/factories/workspace.factory.js +0 -35
- package/es6/src/index.js +0 -14
- package/es6/src/models/has-package-json.mixin.js +0 -35
- package/es6/src/models/has-tsconfig.mixin.js +0 -60
- package/es6/src/models/package-aliases.js +0 -97
- package/es6/src/models/package-json.model.js +0 -192
- package/es6/src/models/project-file-event.js +0 -1
- package/es6/src/models/project.model.js +0 -301
- package/es6/src/models/source-extensions.js +0 -66
- package/es6/src/models/tsconfig.model.js +0 -74
- package/es6/src/models/workspace-config.type.js +0 -4
- package/es6/src/models/workspace.model.js +0 -143
- package/types/src/const.d.ts +0 -8
- package/types/src/errors.d.ts +0 -2
- package/types/src/factories/config.factory.d.ts +0 -6
- package/types/src/factories/find-workspace-root.d.ts +0 -6
- package/types/src/factories/project.factory.d.ts +0 -8
- package/types/src/factories/workspace.factory.d.ts +0 -9
- package/types/src/models/has-package-json.mixin.d.ts +0 -9
- package/types/src/models/has-tsconfig.mixin.d.ts +0 -11
- package/types/src/models/package-aliases.d.ts +0 -28
- package/types/src/models/package-json.model.d.ts +0 -40
- package/types/src/models/project-file-event.d.ts +0 -9
- package/types/src/models/project.model.d.ts +0 -64
- package/types/src/models/source-extensions.d.ts +0 -22
- package/types/src/models/tsconfig.model.d.ts +0 -11
- package/types/src/models/workspace-config.type.d.ts +0 -52
- package/types/src/models/workspace.model.d.ts +0 -40
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "HasTsConfig", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return HasTsConfig;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _nodefs = /*#__PURE__*/ _interop_require_default(require("node:fs"));
|
|
12
|
-
const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
|
|
13
|
-
const _caching = require("@decohere/core/caching");
|
|
14
|
-
const _io = require("@decohere/core/io");
|
|
15
|
-
const _const = require("../const.js");
|
|
16
|
-
const _tsconfigmodel = require("./tsconfig.model.js");
|
|
17
|
-
function _interop_require_default(obj) {
|
|
18
|
-
return obj && obj.__esModule ? obj : {
|
|
19
|
-
default: obj
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
23
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
25
|
-
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;
|
|
26
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
27
|
-
}
|
|
28
|
-
function _ts_metadata(k, v) {
|
|
29
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
30
|
-
}
|
|
31
|
-
class HasTsConfig {
|
|
32
|
-
async getTsConfig() {
|
|
33
|
-
for (const configPath of this.tsConfigPaths){
|
|
34
|
-
if (await _io.io.fileExists(configPath)) return _tsconfigmodel.Tsconfig.parse(configPath);
|
|
35
|
-
}
|
|
36
|
-
return _tsconfigmodel.Tsconfig.default();
|
|
37
|
-
}
|
|
38
|
-
getTsConfigSync() {
|
|
39
|
-
const configPath = this.findTsConfigPath();
|
|
40
|
-
if (configPath != null) return _tsconfigmodel.Tsconfig.parseSync(configPath);
|
|
41
|
-
return _tsconfigmodel.Tsconfig.default();
|
|
42
|
-
}
|
|
43
|
-
/** First existing `tsconfig.json` on this object, if any. */ findTsConfigPath() {
|
|
44
|
-
return this.tsConfigPaths.find((configPath)=>HasTsConfig.fileExistsSync(configPath));
|
|
45
|
-
}
|
|
46
|
-
get tsConfigPaths() {
|
|
47
|
-
const paths = [
|
|
48
|
-
_nodepath.default.join(this.tsConfigDirectory, _const.TS_CONFIG)
|
|
49
|
-
];
|
|
50
|
-
const fallback = this.fallbackTsConfigDirectory;
|
|
51
|
-
if (fallback != null) {
|
|
52
|
-
paths.push(_nodepath.default.join(fallback, _const.TS_CONFIG));
|
|
53
|
-
}
|
|
54
|
-
return paths;
|
|
55
|
-
}
|
|
56
|
-
static fileExistsSync(filePath) {
|
|
57
|
-
try {
|
|
58
|
-
return _nodefs.default.statSync(filePath).isFile();
|
|
59
|
-
} catch {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
_ts_decorate([
|
|
65
|
-
(0, _caching.memoize)(),
|
|
66
|
-
_ts_metadata("design:type", Function),
|
|
67
|
-
_ts_metadata("design:paramtypes", []),
|
|
68
|
-
_ts_metadata("design:returntype", Promise)
|
|
69
|
-
], HasTsConfig.prototype, "getTsConfig", null);
|
|
70
|
-
_ts_decorate([
|
|
71
|
-
(0, _caching.memoize)(),
|
|
72
|
-
_ts_metadata("design:type", Function),
|
|
73
|
-
_ts_metadata("design:paramtypes", []),
|
|
74
|
-
_ts_metadata("design:returntype", void 0)
|
|
75
|
-
], HasTsConfig.prototype, "getTsConfigSync", null);
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "packageAliases", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return packageAliases;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _nodefs = require("node:fs");
|
|
12
|
-
const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
|
|
13
|
-
const _sourceextensions = require("./source-extensions.js");
|
|
14
|
-
function _interop_require_default(obj) {
|
|
15
|
-
return obj && obj.__esModule ? obj : {
|
|
16
|
-
default: obj
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Convention aliases from workspace packages, then tsconfig `paths` for the same keys.
|
|
21
|
-
* Prefer `Workspace.getPackageAliases` when a workspace is available.
|
|
22
|
-
*/ function build(projects, options) {
|
|
23
|
-
const baseUrl = _nodepath.default.resolve(options.baseUrl);
|
|
24
|
-
const paths = {
|
|
25
|
-
...conventionAliasPaths(projects, baseUrl),
|
|
26
|
-
...options.tsconfigPaths
|
|
27
|
-
};
|
|
28
|
-
return {
|
|
29
|
-
baseUrl,
|
|
30
|
-
paths
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
/** Bare import specifier that is not relative, absolute, or a node/file URL. */ function isBareSpecifier(specifier) {
|
|
34
|
-
return specifier.length > 0 && !specifier.startsWith(".") && !specifier.startsWith("/") && !specifier.startsWith("node:") && !specifier.startsWith("file:") && !specifier.startsWith("data:") && !specifier.startsWith("#");
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Resolve a bare specifier through package aliases (SWC-style `paths`
|
|
38
|
-
* relative to `baseUrl`) to an absolute `.ts` path. Longest key wins.
|
|
39
|
-
*/ function resolvePath(specifier, paths, baseUrl) {
|
|
40
|
-
if (!isBareSpecifier(specifier)) return null;
|
|
41
|
-
const resolvedBase = _nodepath.default.resolve(baseUrl);
|
|
42
|
-
const keys = Object.keys(paths).sort((a, b)=>b.length - a.length);
|
|
43
|
-
for (const key of keys){
|
|
44
|
-
const target = paths[key]?.[0];
|
|
45
|
-
if (target == null) continue;
|
|
46
|
-
if (key.endsWith("/*")) {
|
|
47
|
-
const prefix = key.slice(0, -1);
|
|
48
|
-
if (!specifier.startsWith(prefix)) continue;
|
|
49
|
-
const mappedRoot = target.endsWith("/*") ? target.slice(0, -2) : target;
|
|
50
|
-
const subpath = specifier.slice(prefix.length);
|
|
51
|
-
return subpathSource(_nodepath.default.resolve(resolvedBase, mappedRoot, subpath));
|
|
52
|
-
}
|
|
53
|
-
if (specifier === key) {
|
|
54
|
-
return toTsSourcePath(_nodepath.default.resolve(resolvedBase, target.replace(/\*$/, "")));
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
function conventionAliasPaths(projects, baseUrl) {
|
|
60
|
-
const aliases = {};
|
|
61
|
-
for (const project of projects){
|
|
62
|
-
const name = project.name;
|
|
63
|
-
if (name.length === 0) continue;
|
|
64
|
-
const entry = _nodepath.default.resolve(project.getSourceEntryPath());
|
|
65
|
-
// A package with no root entry (only subpaths, like core) gets no bare alias, and its
|
|
66
|
-
// subpaths resolve under `src/`.
|
|
67
|
-
const hasEntry = (0, _nodefs.existsSync)(entry);
|
|
68
|
-
if (hasEntry) aliases[name] = [
|
|
69
|
-
toPosixRelative(baseUrl, entry)
|
|
70
|
-
];
|
|
71
|
-
const subpathRoot = hasEntry ? _nodepath.default.dirname(entry) : _nodepath.default.resolve(project.rootDir, project.projectDirectory, "src");
|
|
72
|
-
if ((0, _nodefs.existsSync)(subpathRoot)) {
|
|
73
|
-
aliases[`${name}/*`] = [
|
|
74
|
-
`${toPosixRelative(baseUrl, subpathRoot)}/*`
|
|
75
|
-
];
|
|
76
|
-
}
|
|
77
|
-
// Subpaths the package exports, mapped to their sources: these can name any file,
|
|
78
|
-
// not just `<sub>.ts` or `<sub>/index.ts` under the entry's directory.
|
|
79
|
-
for (const [subpath, source] of Object.entries(project.getSourceExports())){
|
|
80
|
-
aliases[`${name}/${subpath.slice(2)}`] = [
|
|
81
|
-
toPosixRelative(baseUrl, source)
|
|
82
|
-
];
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return aliases;
|
|
86
|
-
}
|
|
87
|
-
function toPosixRelative(from, to) {
|
|
88
|
-
const relative = _nodepath.default.relative(from, to);
|
|
89
|
-
if (relative === "") return ".";
|
|
90
|
-
return relative.split(_nodepath.default.sep).join("/");
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* The source file a wildcard subpath names: `<sub>` with a source extension (`.ts`, `.tsx`, or
|
|
94
|
-
* `.mts`/`.cts` for `.mjs`/`.cjs`), else the `index` source of the directory it names (as
|
|
95
|
-
* `@pkg/models` is `src/models/index.ts`), else `<sub>.ts` for the caller to report missing.
|
|
96
|
-
*/ function subpathSource(candidate) {
|
|
97
|
-
const files = _sourceextensions.sourceExtensions.candidates(candidate);
|
|
98
|
-
const directory = candidate.replace(/\.([mc]?[jt]sx?)$/, "");
|
|
99
|
-
const indexes = _sourceextensions.sourceExtensions.candidates(_nodepath.default.join(directory, "index"));
|
|
100
|
-
return [
|
|
101
|
-
...files,
|
|
102
|
-
...indexes
|
|
103
|
-
].find((file)=>(0, _nodefs.existsSync)(file)) ?? toTsSourcePath(candidate);
|
|
104
|
-
}
|
|
105
|
-
/** A target as a source path: itself when it is one, else its first source candidate. */ function toTsSourcePath(candidate) {
|
|
106
|
-
return _sourceextensions.sourceExtensions.candidates(candidate)[0] ?? `${candidate}.ts`;
|
|
107
|
-
}
|
|
108
|
-
const packageAliases = {
|
|
109
|
-
build,
|
|
110
|
-
isBareSpecifier,
|
|
111
|
-
resolvePath
|
|
112
|
-
};
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "PackageJson", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return PackageJson;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
class PackageJson {
|
|
12
|
-
static PACKAGE_JSON_KEY_ORDER = [
|
|
13
|
-
"$schema",
|
|
14
|
-
"name",
|
|
15
|
-
"displayName",
|
|
16
|
-
"version",
|
|
17
|
-
"description",
|
|
18
|
-
"keywords",
|
|
19
|
-
"homepage",
|
|
20
|
-
"bugs",
|
|
21
|
-
"repository",
|
|
22
|
-
"license",
|
|
23
|
-
"author",
|
|
24
|
-
"contributors",
|
|
25
|
-
"funding",
|
|
26
|
-
"type",
|
|
27
|
-
"main",
|
|
28
|
-
"module",
|
|
29
|
-
"types",
|
|
30
|
-
"exports",
|
|
31
|
-
"files",
|
|
32
|
-
"bin",
|
|
33
|
-
"man",
|
|
34
|
-
"directories",
|
|
35
|
-
"scripts",
|
|
36
|
-
"dependencies",
|
|
37
|
-
"devDependencies",
|
|
38
|
-
"peerDependencies",
|
|
39
|
-
"peerDependenciesMeta",
|
|
40
|
-
"optionalDependencies",
|
|
41
|
-
"bundledDependencies",
|
|
42
|
-
"engines",
|
|
43
|
-
"os",
|
|
44
|
-
"cpu",
|
|
45
|
-
"private",
|
|
46
|
-
"publishConfig",
|
|
47
|
-
"workspaces",
|
|
48
|
-
"packageManager",
|
|
49
|
-
"forge"
|
|
50
|
-
];
|
|
51
|
-
constructor(data){
|
|
52
|
-
Object.assign(this, data);
|
|
53
|
-
this.dependencies = this.dependencies ?? {};
|
|
54
|
-
this.devDependencies = this.devDependencies ?? {};
|
|
55
|
-
}
|
|
56
|
-
sort() {
|
|
57
|
-
const sorted = this.toSortedPackageJsonRecord();
|
|
58
|
-
Object.assign(this, sorted);
|
|
59
|
-
return this;
|
|
60
|
-
}
|
|
61
|
-
withVersion(version) {
|
|
62
|
-
return new PackageJson({
|
|
63
|
-
...this,
|
|
64
|
-
version
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
withDependencies(dependencies) {
|
|
68
|
-
return new PackageJson({
|
|
69
|
-
...this,
|
|
70
|
-
dependencies
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
withDevDependencies(devDependencies) {
|
|
74
|
-
return new PackageJson({
|
|
75
|
-
...this,
|
|
76
|
-
devDependencies
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
withPeerDependencies(peerDependencies) {
|
|
80
|
-
return new PackageJson({
|
|
81
|
-
...this,
|
|
82
|
-
peerDependencies
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
toJSON() {
|
|
86
|
-
return `${JSON.stringify(this.toSortedPackageJsonRecord(), null, 2)}\n`;
|
|
87
|
-
}
|
|
88
|
-
getRepositoryOwner() {
|
|
89
|
-
return this.parseRepository()?.owner;
|
|
90
|
-
}
|
|
91
|
-
getRepositoryName() {
|
|
92
|
-
return this.parseRepository()?.name;
|
|
93
|
-
}
|
|
94
|
-
getRepositoryFullName() {
|
|
95
|
-
const parsed = this.parseRepository();
|
|
96
|
-
if (parsed == null) {
|
|
97
|
-
return undefined;
|
|
98
|
-
}
|
|
99
|
-
return `${parsed.owner}/${parsed.name}`;
|
|
100
|
-
}
|
|
101
|
-
sortDependencyMap(input) {
|
|
102
|
-
return Object.fromEntries(Object.entries(input).sort(([left], [right])=>left.localeCompare(right, "en")));
|
|
103
|
-
}
|
|
104
|
-
sortPackageJsonKeys(source) {
|
|
105
|
-
const sorted = Object.create(null);
|
|
106
|
-
for (const key of PackageJson.PACKAGE_JSON_KEY_ORDER){
|
|
107
|
-
if (key in source) {
|
|
108
|
-
sorted[key] = source[key];
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
const remainingKeys = Object.keys(source).filter((key)=>!PackageJson.PACKAGE_JSON_KEY_ORDER.includes(key)).sort();
|
|
112
|
-
for (const key of remainingKeys){
|
|
113
|
-
sorted[key] = source[key];
|
|
114
|
-
}
|
|
115
|
-
return sorted;
|
|
116
|
-
}
|
|
117
|
-
toSortedPackageJsonRecord() {
|
|
118
|
-
const clone = {
|
|
119
|
-
...this
|
|
120
|
-
};
|
|
121
|
-
if (clone.dependencies) {
|
|
122
|
-
clone.dependencies = this.sortDependencyMap(clone.dependencies);
|
|
123
|
-
}
|
|
124
|
-
if (clone.devDependencies) {
|
|
125
|
-
clone.devDependencies = this.sortDependencyMap(clone.devDependencies);
|
|
126
|
-
}
|
|
127
|
-
return this.sortPackageJsonKeys(clone);
|
|
128
|
-
}
|
|
129
|
-
repositoryReferenceToString(repository) {
|
|
130
|
-
if (typeof repository === "string") {
|
|
131
|
-
return repository;
|
|
132
|
-
}
|
|
133
|
-
if (repository == null) {
|
|
134
|
-
return "";
|
|
135
|
-
}
|
|
136
|
-
return String(repository.url ?? "");
|
|
137
|
-
}
|
|
138
|
-
parseRepository() {
|
|
139
|
-
const repositoryValue = this.repositoryReferenceToString(this.repository);
|
|
140
|
-
if (repositoryValue === "") {
|
|
141
|
-
return undefined;
|
|
142
|
-
}
|
|
143
|
-
const trimmed = repositoryValue.trim();
|
|
144
|
-
if (!trimmed.includes("://") && !trimmed.startsWith("git@")) {
|
|
145
|
-
const shorthand = /^(?:[a-z0-9-]+:)?([^/\s]+)\/([^\s]+)$/i.exec(trimmed);
|
|
146
|
-
if (shorthand) {
|
|
147
|
-
return {
|
|
148
|
-
owner: shorthand[1].toLowerCase(),
|
|
149
|
-
name: this.sanitizeRepositoryName(shorthand[2])
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
const ssh = /^git@[^:]+:([^/\s]+)\/([^\s]+)$/i.exec(trimmed);
|
|
154
|
-
if (ssh) {
|
|
155
|
-
return {
|
|
156
|
-
owner: ssh[1].toLowerCase(),
|
|
157
|
-
name: this.sanitizeRepositoryName(ssh[2])
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
const urlRepository = this.parseRepositoryFromUrl(trimmed);
|
|
161
|
-
if (urlRepository != null) {
|
|
162
|
-
return urlRepository;
|
|
163
|
-
}
|
|
164
|
-
return undefined;
|
|
165
|
-
}
|
|
166
|
-
parseRepositoryFromUrl(repository) {
|
|
167
|
-
const normalized = repository.replace(/^git\+/, "");
|
|
168
|
-
let url;
|
|
169
|
-
try {
|
|
170
|
-
url = new URL(normalized);
|
|
171
|
-
} catch {
|
|
172
|
-
return undefined;
|
|
173
|
-
}
|
|
174
|
-
const segments = url.pathname.split("/").filter(Boolean);
|
|
175
|
-
if (segments.length < 2) {
|
|
176
|
-
return undefined;
|
|
177
|
-
}
|
|
178
|
-
const owner = segments[0]?.toLowerCase();
|
|
179
|
-
const name = this.sanitizeRepositoryName(segments[1] ?? "");
|
|
180
|
-
if (owner == null || owner === "" || name === "") {
|
|
181
|
-
return undefined;
|
|
182
|
-
}
|
|
183
|
-
return {
|
|
184
|
-
owner,
|
|
185
|
-
name
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
sanitizeRepositoryName(name) {
|
|
189
|
-
return name.replace(/\.git$/i, "").toLowerCase();
|
|
190
|
-
}
|
|
191
|
-
name;
|
|
192
|
-
version;
|
|
193
|
-
repository;
|
|
194
|
-
main;
|
|
195
|
-
/** `exports` as written in package.json: a path, or a map of subpaths (values may be condition maps). */ exports;
|
|
196
|
-
peerDependencies;
|
|
197
|
-
optionalDependencies;
|
|
198
|
-
scripts;
|
|
199
|
-
dependencies = {};
|
|
200
|
-
devDependencies = {};
|
|
201
|
-
private;
|
|
202
|
-
}
|