@decohere/core 0.0.1-dev.118 → 0.0.1-dev.119
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/commonjs/src/caching/cache-manager.js +3 -3
- package/commonjs/src/caching/index.js +1 -1
- package/commonjs/src/caching/map-cache.js +39 -0
- package/commonjs/src/io/io.js +0 -3
- package/es6/src/caching/cache-manager.js +3 -3
- package/es6/src/caching/index.js +1 -1
- package/es6/src/caching/map-cache.js +35 -0
- package/es6/src/caching/memoize.decorator.js +1 -1
- package/es6/src/io/io.js +0 -3
- package/package.json +6 -40
- package/types/src/caching/index.d.ts +1 -1
- package/types/src/caching/map-cache.d.ts +23 -0
- package/types/src/caching/memoize.decorator.d.ts +1 -1
- package/types/src/io/io.d.ts +0 -3
- package/commonjs/src/caching/node-cache-memoize.adapter.js +0 -49
- package/commonjs/src/cli/action.js +0 -65
- package/commonjs/src/cli/command.js +0 -127
- package/commonjs/src/cli/index.js +0 -61
- package/commonjs/src/cli/module.type.js +0 -18
- package/commonjs/src/cli/options.js +0 -115
- package/commonjs/src/diagnostics/index.js +0 -22
- package/commonjs/src/diagnostics/trace.js +0 -86
- package/commonjs/src/interop/docker/docker.js +0 -54
- package/commonjs/src/interop/errors/interop.error.js +0 -12
- package/commonjs/src/interop/git/git.js +0 -134
- package/commonjs/src/interop/git/git.types.js +0 -4
- package/commonjs/src/interop/index.js +0 -97
- package/commonjs/src/interop/node/index.js +0 -18
- package/commonjs/src/interop/node/node.js +0 -45
- package/commonjs/src/interop/npm/npm.js +0 -231
- package/commonjs/src/interop/npm/npm.types.js +0 -16
- package/commonjs/src/interop/pnpm/pnpm.js +0 -34
- package/commonjs/src/interop/pnpm/pnpm.types.js +0 -4
- package/commonjs/src/interop/shell/shell.argv.js +0 -45
- package/commonjs/src/interop/shell/shell.js +0 -105
- package/commonjs/src/interop/shell/shell.types.js +0 -4
- package/commonjs/src/interop/types/detect-package-manager.js +0 -71
- package/commonjs/src/interop/types/package-manager.js +0 -4
- package/commonjs/src/interop/yarn/yarn.js +0 -34
- package/commonjs/src/interop/yarn/yarn.types.js +0 -4
- package/commonjs/src/io/find-directories.js +0 -21
- package/commonjs/src/io/find-file.js +0 -45
- package/commonjs/src/io/watch.js +0 -261
- package/commonjs/src/semver/index.js +0 -18
- package/commonjs/src/semver/semver.js +0 -92
- package/commonjs/src/testing/flush-promises.js +0 -16
- package/commonjs/src/testing/glob-with-memfs.js +0 -22
- package/commonjs/src/testing/index.js +0 -22
- package/commonjs/src/testing/memfs.js +0 -52
- package/commonjs/src/testing/mock-logger.js +0 -36
- package/commonjs/src/testing/spy-on-constructor.js +0 -27
- package/es6/src/caching/node-cache-memoize.adapter.js +0 -37
- package/es6/src/cli/action.js +0 -47
- package/es6/src/cli/command.js +0 -106
- package/es6/src/cli/index.js +0 -4
- package/es6/src/cli/module.type.js +0 -11
- package/es6/src/cli/options.js +0 -76
- package/es6/src/diagnostics/index.js +0 -1
- package/es6/src/diagnostics/trace.js +0 -68
- package/es6/src/interop/docker/docker.js +0 -44
- package/es6/src/interop/errors/interop.error.js +0 -2
- package/es6/src/interop/git/git.js +0 -124
- package/es6/src/interop/git/git.types.js +0 -1
- package/es6/src/interop/index.js +0 -21
- package/es6/src/interop/node/index.js +0 -1
- package/es6/src/interop/node/node.js +0 -35
- package/es6/src/interop/npm/npm.js +0 -180
- package/es6/src/interop/npm/npm.types.js +0 -6
- package/es6/src/interop/pnpm/pnpm.js +0 -24
- package/es6/src/interop/pnpm/pnpm.types.js +0 -1
- package/es6/src/interop/shell/shell.argv.js +0 -35
- package/es6/src/interop/shell/shell.js +0 -95
- package/es6/src/interop/shell/shell.types.js +0 -1
- package/es6/src/interop/types/detect-package-manager.js +0 -50
- package/es6/src/interop/types/package-manager.js +0 -1
- package/es6/src/interop/yarn/yarn.js +0 -24
- package/es6/src/interop/yarn/yarn.types.js +0 -1
- package/es6/src/io/find-directories.js +0 -11
- package/es6/src/io/find-file.js +0 -27
- package/es6/src/io/watch.js +0 -238
- package/es6/src/semver/index.js +0 -1
- package/es6/src/semver/semver.js +0 -71
- package/es6/src/testing/flush-promises.js +0 -6
- package/es6/src/testing/glob-with-memfs.js +0 -20
- package/es6/src/testing/index.js +0 -5
- package/es6/src/testing/memfs.js +0 -25
- package/es6/src/testing/mock-logger.js +0 -26
- package/es6/src/testing/spy-on-constructor.js +0 -31
- package/types/src/caching/node-cache-memoize.adapter.d.ts +0 -22
- package/types/src/cli/action.d.ts +0 -36
- package/types/src/cli/command.d.ts +0 -34
- package/types/src/cli/index.d.ts +0 -7
- package/types/src/cli/module.type.d.ts +0 -36
- package/types/src/cli/options.d.ts +0 -28
- package/types/src/diagnostics/index.d.ts +0 -1
- package/types/src/diagnostics/trace.d.ts +0 -10
- package/types/src/interop/docker/docker.d.ts +0 -19
- package/types/src/interop/errors/interop.error.d.ts +0 -2
- package/types/src/interop/git/git.d.ts +0 -16
- package/types/src/interop/git/git.types.d.ts +0 -14
- package/types/src/interop/index.d.ts +0 -14
- package/types/src/interop/node/index.d.ts +0 -1
- package/types/src/interop/node/node.d.ts +0 -5
- package/types/src/interop/npm/npm.d.ts +0 -29
- package/types/src/interop/npm/npm.types.d.ts +0 -24
- package/types/src/interop/pnpm/pnpm.d.ts +0 -9
- package/types/src/interop/pnpm/pnpm.types.d.ts +0 -3
- package/types/src/interop/shell/shell.argv.d.ts +0 -5
- package/types/src/interop/shell/shell.d.ts +0 -6
- package/types/src/interop/shell/shell.types.d.ts +0 -9
- package/types/src/interop/types/detect-package-manager.d.ts +0 -4
- package/types/src/interop/types/package-manager.d.ts +0 -10
- package/types/src/interop/yarn/yarn.d.ts +0 -9
- package/types/src/interop/yarn/yarn.types.d.ts +0 -3
- package/types/src/io/find-directories.d.ts +0 -2
- package/types/src/io/find-file.d.ts +0 -9
- package/types/src/io/watch.d.ts +0 -16
- package/types/src/semver/index.d.ts +0 -1
- package/types/src/semver/semver.d.ts +0 -18
- package/types/src/testing/flush-promises.d.ts +0 -1
- package/types/src/testing/glob-with-memfs.d.ts +0 -3
- package/types/src/testing/index.d.ts +0 -5
- package/types/src/testing/memfs.d.ts +0 -5
- package/types/src/testing/mock-logger.d.ts +0 -13
- package/types/src/testing/spy-on-constructor.d.ts +0 -21
|
@@ -16,7 +16,7 @@ _export(exports, {
|
|
|
16
16
|
return Caching;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
const
|
|
19
|
+
const _mapcache = require("./map-cache.js");
|
|
20
20
|
const Caches = {
|
|
21
21
|
default: "DEFAULT",
|
|
22
22
|
memoize: "MEMOIZE_CACHE"
|
|
@@ -40,8 +40,8 @@ const Caches = {
|
|
|
40
40
|
*/ getCache(name, memoize = false) {
|
|
41
41
|
const cacheName = name ?? this.defaultCacheName;
|
|
42
42
|
if (!this.caches.has(cacheName)) {
|
|
43
|
-
const cache =
|
|
44
|
-
|
|
43
|
+
const cache = new _mapcache.MapCache({
|
|
44
|
+
memoize
|
|
45
45
|
});
|
|
46
46
|
this.caches.set(cacheName, cache);
|
|
47
47
|
}
|
|
@@ -7,7 +7,7 @@ _export_star(require("./cache.js"), exports);
|
|
|
7
7
|
_export_star(require("./cache-manager.js"), exports);
|
|
8
8
|
_export_star(require("./invalidate-cache.decorator.js"), exports);
|
|
9
9
|
_export_star(require("./memoize.decorator.js"), exports);
|
|
10
|
-
_export_star(require("./
|
|
10
|
+
_export_star(require("./map-cache.js"), exports);
|
|
11
11
|
function _export_star(from, to) {
|
|
12
12
|
Object.keys(from).forEach(function(k) {
|
|
13
13
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "MapCache", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return MapCache;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
class MapCache {
|
|
12
|
+
#entries = new Map();
|
|
13
|
+
#memoize;
|
|
14
|
+
constructor(options = {}){
|
|
15
|
+
this.#memoize = options.memoize ?? false;
|
|
16
|
+
}
|
|
17
|
+
get isMemoize() {
|
|
18
|
+
return this.#memoize;
|
|
19
|
+
}
|
|
20
|
+
get(key) {
|
|
21
|
+
const value = this.#entries.get(key);
|
|
22
|
+
if (this.#memoize || value === null || typeof value !== "object") {
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
return structuredClone(value);
|
|
26
|
+
}
|
|
27
|
+
set(key, value) {
|
|
28
|
+
this.#entries.set(key, value);
|
|
29
|
+
}
|
|
30
|
+
has(key) {
|
|
31
|
+
return this.#entries.has(key);
|
|
32
|
+
}
|
|
33
|
+
del(key) {
|
|
34
|
+
this.#entries.delete(key);
|
|
35
|
+
}
|
|
36
|
+
flushAll() {
|
|
37
|
+
this.#entries.clear();
|
|
38
|
+
}
|
|
39
|
+
}
|
package/commonjs/src/io/io.js
CHANGED
|
@@ -6,12 +6,9 @@ _export_star(require("./copy-file.js"), exports);
|
|
|
6
6
|
_export_star(require("./delete-file.js"), exports);
|
|
7
7
|
_export_star(require("./directory-exists.js"), exports);
|
|
8
8
|
_export_star(require("./file-exists.js"), exports);
|
|
9
|
-
_export_star(require("./find-directories.js"), exports);
|
|
10
|
-
_export_star(require("./find-file.js"), exports);
|
|
11
9
|
_export_star(require("./read-file.js"), exports);
|
|
12
10
|
_export_star(require("./remove-dir.js"), exports);
|
|
13
11
|
_export_star(require("./url-to-path.js"), exports);
|
|
14
|
-
_export_star(require("./watch.js"), exports);
|
|
15
12
|
_export_star(require("./write-file.js"), exports);
|
|
16
13
|
function _export_star(from, to) {
|
|
17
14
|
Object.keys(from).forEach(function(k) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MapCache } from "./map-cache.js";
|
|
2
2
|
export const Caches = {
|
|
3
3
|
default: "DEFAULT",
|
|
4
4
|
memoize: "MEMOIZE_CACHE"
|
|
@@ -22,8 +22,8 @@ export const Caches = {
|
|
|
22
22
|
*/ getCache(name, memoize = false) {
|
|
23
23
|
const cacheName = name ?? this.defaultCacheName;
|
|
24
24
|
if (!this.caches.has(cacheName)) {
|
|
25
|
-
const cache =
|
|
26
|
-
|
|
25
|
+
const cache = new MapCache({
|
|
26
|
+
memoize
|
|
27
27
|
});
|
|
28
28
|
this.caches.set(cacheName, cache);
|
|
29
29
|
}
|
package/es6/src/caching/index.js
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The built-in cache: a plain `Map`, no expiry.
|
|
3
|
+
*
|
|
4
|
+
* By default `get` returns a `structuredClone` of an object, so a caller that changes what it
|
|
5
|
+
* got back can't change the cached value. With `memoize` it returns the stored reference.
|
|
6
|
+
* Scalars, `null` and `undefined` are returned as they are.
|
|
7
|
+
*/ export class MapCache {
|
|
8
|
+
#entries = new Map();
|
|
9
|
+
#memoize;
|
|
10
|
+
constructor(options = {}){
|
|
11
|
+
this.#memoize = options.memoize ?? false;
|
|
12
|
+
}
|
|
13
|
+
get isMemoize() {
|
|
14
|
+
return this.#memoize;
|
|
15
|
+
}
|
|
16
|
+
get(key) {
|
|
17
|
+
const value = this.#entries.get(key);
|
|
18
|
+
if (this.#memoize || value === null || typeof value !== "object") {
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
return structuredClone(value);
|
|
22
|
+
}
|
|
23
|
+
set(key, value) {
|
|
24
|
+
this.#entries.set(key, value);
|
|
25
|
+
}
|
|
26
|
+
has(key) {
|
|
27
|
+
return this.#entries.has(key);
|
|
28
|
+
}
|
|
29
|
+
del(key) {
|
|
30
|
+
this.#entries.delete(key);
|
|
31
|
+
}
|
|
32
|
+
flushAll() {
|
|
33
|
+
this.#entries.clear();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -2,7 +2,7 @@ import { CacheDecorator } from "./cache.decorator.js";
|
|
|
2
2
|
import { Caches, Caching } from "./cache-manager.js";
|
|
3
3
|
/**
|
|
4
4
|
* Memoize decorator class that extends CacheDecorator with memoization support
|
|
5
|
-
* Automatically uses a memoization-capable cache (
|
|
5
|
+
* Automatically uses a memoization-capable cache (a MapCache that hands out references)
|
|
6
6
|
*/ export class MemoizeDecorator extends CacheDecorator {
|
|
7
7
|
decorator(target, propertyKey, descriptor) {
|
|
8
8
|
const cache = this.options?.cache ?? Caching.getCache(this.options?.name ?? Caches.memoize, true);
|
package/es6/src/io/io.js
CHANGED
|
@@ -2,10 +2,7 @@ export * from "./copy-file.js";
|
|
|
2
2
|
export * from "./delete-file.js";
|
|
3
3
|
export * from "./directory-exists.js";
|
|
4
4
|
export * from "./file-exists.js";
|
|
5
|
-
export * from "./find-directories.js";
|
|
6
|
-
export * from "./find-file.js";
|
|
7
5
|
export * from "./read-file.js";
|
|
8
6
|
export * from "./remove-dir.js";
|
|
9
7
|
export * from "./url-to-path.js";
|
|
10
|
-
export * from "./watch.js";
|
|
11
8
|
export * from "./write-file.js";
|
package/package.json
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decohere/core",
|
|
3
|
-
"version": "0.0.1-dev.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.1-dev.119",
|
|
4
|
+
"description": "The runtime base every Decohere package builds on: reflection, composition, configuration types, extensibility, collections, objects, caching on a Map, and basic file IO. No side effects on import.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
7
7
|
"utilities",
|
|
8
|
-
"collections",
|
|
9
|
-
"caching",
|
|
10
|
-
"io",
|
|
11
|
-
"cli",
|
|
12
8
|
"reflection",
|
|
9
|
+
"composition",
|
|
10
|
+
"caching",
|
|
13
11
|
"decohere"
|
|
14
12
|
],
|
|
15
13
|
"license": "ISC",
|
|
@@ -37,11 +35,6 @@
|
|
|
37
35
|
"import": "./es6/src/extensibility/index.js",
|
|
38
36
|
"require": "./commonjs/src/extensibility/index.js"
|
|
39
37
|
},
|
|
40
|
-
"./interop": {
|
|
41
|
-
"types": "./types/src/interop/index.d.ts",
|
|
42
|
-
"import": "./es6/src/interop/index.js",
|
|
43
|
-
"require": "./commonjs/src/interop/index.js"
|
|
44
|
-
},
|
|
45
38
|
"./io": {
|
|
46
39
|
"types": "./types/src/io/index.d.ts",
|
|
47
40
|
"import": "./es6/src/io/index.js",
|
|
@@ -62,45 +55,18 @@
|
|
|
62
55
|
"import": "./es6/src/system/index.js",
|
|
63
56
|
"require": "./commonjs/src/system/index.js"
|
|
64
57
|
},
|
|
65
|
-
"./semver": {
|
|
66
|
-
"types": "./types/src/semver/index.d.ts",
|
|
67
|
-
"import": "./es6/src/semver/index.js",
|
|
68
|
-
"require": "./commonjs/src/semver/index.js"
|
|
69
|
-
},
|
|
70
|
-
"./testing": {
|
|
71
|
-
"types": "./types/src/testing/index.d.ts",
|
|
72
|
-
"import": "./es6/src/testing/index.js",
|
|
73
|
-
"require": "./commonjs/src/testing/index.js"
|
|
74
|
-
},
|
|
75
58
|
"./composition": {
|
|
76
59
|
"types": "./types/src/composition/index.d.ts",
|
|
77
60
|
"import": "./es6/src/composition/index.js",
|
|
78
61
|
"require": "./commonjs/src/composition/index.js"
|
|
79
|
-
},
|
|
80
|
-
"./cli": {
|
|
81
|
-
"types": "./types/src/cli/index.d.ts",
|
|
82
|
-
"import": "./es6/src/cli/index.js",
|
|
83
|
-
"require": "./commonjs/src/cli/index.js"
|
|
84
|
-
},
|
|
85
|
-
"./diagnostics": {
|
|
86
|
-
"types": "./types/src/diagnostics/index.d.ts",
|
|
87
|
-
"import": "./es6/src/diagnostics/index.js",
|
|
88
|
-
"require": "./commonjs/src/diagnostics/index.js"
|
|
89
62
|
}
|
|
90
63
|
},
|
|
91
64
|
"scripts": {
|
|
92
65
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
93
66
|
},
|
|
94
67
|
"dependencies": {
|
|
95
|
-
"@
|
|
96
|
-
"@decohere/scribe": "0.0.1-dev.118",
|
|
97
|
-
"commander": "^13.1.0",
|
|
98
|
-
"glob": "^13.0.1",
|
|
99
|
-
"picomatch": "^4.0.4",
|
|
68
|
+
"@decohere/scribe": "0.0.1-dev.119",
|
|
100
69
|
"reflect-metadata": "^0.2.2"
|
|
101
70
|
},
|
|
102
|
-
"devDependencies": {
|
|
103
|
-
"memfs": "^4.17.0",
|
|
104
|
-
"vitest": "^3.2.6"
|
|
105
|
-
}
|
|
71
|
+
"devDependencies": {}
|
|
106
72
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ICache } from "./cache.js";
|
|
2
|
+
type MapCacheOptions = {
|
|
3
|
+
/** Hand out the stored reference instead of a copy (what `@memoize` needs). */
|
|
4
|
+
memoize?: boolean;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* The built-in cache: a plain `Map`, no expiry.
|
|
8
|
+
*
|
|
9
|
+
* By default `get` returns a `structuredClone` of an object, so a caller that changes what it
|
|
10
|
+
* got back can't change the cached value. With `memoize` it returns the stored reference.
|
|
11
|
+
* Scalars, `null` and `undefined` are returned as they are.
|
|
12
|
+
*/
|
|
13
|
+
export declare class MapCache implements ICache {
|
|
14
|
+
#private;
|
|
15
|
+
constructor(options?: MapCacheOptions);
|
|
16
|
+
get isMemoize(): boolean;
|
|
17
|
+
get(key: string): unknown;
|
|
18
|
+
set(key: string, value: unknown): void;
|
|
19
|
+
has(key: string): boolean;
|
|
20
|
+
del(key: string): void;
|
|
21
|
+
flushAll(): void;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CacheDecorator } from "./cache.decorator.js";
|
|
2
2
|
/**
|
|
3
3
|
* Memoize decorator class that extends CacheDecorator with memoization support
|
|
4
|
-
* Automatically uses a memoization-capable cache (
|
|
4
|
+
* Automatically uses a memoization-capable cache (a MapCache that hands out references)
|
|
5
5
|
*/
|
|
6
6
|
export declare class MemoizeDecorator extends CacheDecorator {
|
|
7
7
|
decorator(target: object, propertyKey: string, descriptor: PropertyDescriptor): void;
|
package/types/src/io/io.d.ts
CHANGED
|
@@ -2,10 +2,7 @@ export * from "./copy-file.js";
|
|
|
2
2
|
export * from "./delete-file.js";
|
|
3
3
|
export * from "./directory-exists.js";
|
|
4
4
|
export * from "./file-exists.js";
|
|
5
|
-
export * from "./find-directories.js";
|
|
6
|
-
export * from "./find-file.js";
|
|
7
5
|
export * from "./read-file.js";
|
|
8
6
|
export * from "./remove-dir.js";
|
|
9
7
|
export * from "./url-to-path.js";
|
|
10
|
-
export * from "./watch.js";
|
|
11
8
|
export * from "./write-file.js";
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "NodeCacheAdapter", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return NodeCacheAdapter;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _nodecache = /*#__PURE__*/ _interop_require_default(require("@cacheable/node-cache"));
|
|
12
|
-
function _interop_require_default(obj) {
|
|
13
|
-
return obj && obj.__esModule ? obj : {
|
|
14
|
-
default: obj
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
class NodeCacheAdapter {
|
|
18
|
-
static create(options = {
|
|
19
|
-
enableMemoization: false
|
|
20
|
-
}) {
|
|
21
|
-
const nodeCache = new _nodecache.default({
|
|
22
|
-
useClones: !options.enableMemoization
|
|
23
|
-
});
|
|
24
|
-
return new NodeCacheAdapter(nodeCache);
|
|
25
|
-
}
|
|
26
|
-
supportsMemoization = true;
|
|
27
|
-
cache;
|
|
28
|
-
constructor(inst = new _nodecache.default()){
|
|
29
|
-
this.cache = inst;
|
|
30
|
-
}
|
|
31
|
-
get isMemoize() {
|
|
32
|
-
return !this.cache.options.useClones;
|
|
33
|
-
}
|
|
34
|
-
get(key) {
|
|
35
|
-
return this.cache.get(key);
|
|
36
|
-
}
|
|
37
|
-
set(key, value) {
|
|
38
|
-
this.cache.set(key, value);
|
|
39
|
-
}
|
|
40
|
-
has(key) {
|
|
41
|
-
return this.cache.has(key);
|
|
42
|
-
}
|
|
43
|
-
del(key) {
|
|
44
|
-
this.cache.del(key);
|
|
45
|
-
}
|
|
46
|
-
flushAll() {
|
|
47
|
-
this.cache.flushAll();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
get ActionMap () {
|
|
13
|
-
return ActionMap;
|
|
14
|
-
},
|
|
15
|
-
get ActionResponse () {
|
|
16
|
-
return ActionResponse;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const ActionMap = Symbol("ActionMap");
|
|
20
|
-
class ActionResponse {
|
|
21
|
-
static Success(name, data) {
|
|
22
|
-
return new ActionResponse({
|
|
23
|
-
name,
|
|
24
|
-
data,
|
|
25
|
-
succeeded: true
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
static Skipped(name) {
|
|
29
|
-
return new ActionResponse({
|
|
30
|
-
name,
|
|
31
|
-
skipped: true
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
static Blocking(name) {
|
|
35
|
-
return new ActionResponse({
|
|
36
|
-
name,
|
|
37
|
-
succeeded: true,
|
|
38
|
-
blocking: true
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
static Error(name, messageOrData, data) {
|
|
42
|
-
if (Array.isArray(messageOrData)) {
|
|
43
|
-
const message = messageOrData.filter((r)=>!r.succeeded).map((r)=>r.error ?? "Unknown error").join("\n");
|
|
44
|
-
return new ActionResponse({
|
|
45
|
-
name,
|
|
46
|
-
message,
|
|
47
|
-
data: messageOrData
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
return new ActionResponse({
|
|
51
|
-
name,
|
|
52
|
-
message: messageOrData,
|
|
53
|
-
data
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
constructor(data){
|
|
57
|
-
Object.assign(this, data);
|
|
58
|
-
}
|
|
59
|
-
name;
|
|
60
|
-
succeeded = false;
|
|
61
|
-
skipped = false;
|
|
62
|
-
blocking = false;
|
|
63
|
-
message;
|
|
64
|
-
data;
|
|
65
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
get CommandError () {
|
|
13
|
-
return CommandError;
|
|
14
|
-
},
|
|
15
|
-
get CommandResponse () {
|
|
16
|
-
return CommandResponse;
|
|
17
|
-
},
|
|
18
|
-
get DecohereCommand () {
|
|
19
|
-
return DecohereCommand;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const _commander = require("commander");
|
|
23
|
-
const CommandResponse = {
|
|
24
|
-
success (_ctx, responses) {
|
|
25
|
-
return responses;
|
|
26
|
-
},
|
|
27
|
-
help () {
|
|
28
|
-
return {};
|
|
29
|
-
},
|
|
30
|
-
fromAction (name, response) {
|
|
31
|
-
return {
|
|
32
|
-
[name]: response
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
class CommandError extends Error {
|
|
37
|
-
}
|
|
38
|
-
class DecohereCommand extends _commander.Command {
|
|
39
|
-
get actions() {
|
|
40
|
-
return [];
|
|
41
|
-
}
|
|
42
|
-
constructor(name, handler){
|
|
43
|
-
super();
|
|
44
|
-
if (typeof name === "string" || typeof name === "function") {
|
|
45
|
-
this.name(this.parseCommandName(name));
|
|
46
|
-
} else {
|
|
47
|
-
this.name(this.parseCommandName(this.constructor));
|
|
48
|
-
if (name) {
|
|
49
|
-
this.registerSubcommand(name, handler);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (handler && !this.commands.length) {
|
|
53
|
-
this.action(handler);
|
|
54
|
-
}
|
|
55
|
-
this.exitOverride();
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Whether the command, with these options, runs until it is stopped (`flux serve`,
|
|
59
|
-
* `forge build --watch`). The CLI then listens for SIGINT and SIGTERM from the moment it
|
|
60
|
-
* starts, so a stop during start-up still shuts down cleanly; other commands keep Node's
|
|
61
|
-
* default, where Ctrl+C ends them at once.
|
|
62
|
-
*/ runsUntilStopped(_options) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
async run(actions, options) {
|
|
66
|
-
const responses = await this.runActions(actions, options);
|
|
67
|
-
this.throwOnErrors(responses);
|
|
68
|
-
return CommandResponse.success(options, responses);
|
|
69
|
-
}
|
|
70
|
-
registerSubcommand(commands, onAction) {
|
|
71
|
-
if (typeof commands === "function") {
|
|
72
|
-
const instance = new commands(commands, onAction);
|
|
73
|
-
this.addCommand(instance);
|
|
74
|
-
if (onAction && !instance.commands.length) {
|
|
75
|
-
instance.action(onAction);
|
|
76
|
-
}
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
for (const [key, command] of Object.entries(commands)){
|
|
80
|
-
const instance = command instanceof DecohereCommand ? command : new command(key, onAction);
|
|
81
|
-
this.addCommand(instance);
|
|
82
|
-
if (onAction && !instance.commands.length) {
|
|
83
|
-
instance.action(onAction);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
async runActions(actions, options) {
|
|
88
|
-
const selectedActions = this.getSelectedActions(actions);
|
|
89
|
-
const responses = {};
|
|
90
|
-
for (const [actionKey, action] of selectedActions){
|
|
91
|
-
responses[actionKey] = await action.run(options);
|
|
92
|
-
}
|
|
93
|
-
return responses;
|
|
94
|
-
}
|
|
95
|
-
getSelectedActions(actions) {
|
|
96
|
-
if (!this.actions.length) {
|
|
97
|
-
return [];
|
|
98
|
-
}
|
|
99
|
-
const actionEntries = Object.entries(actions);
|
|
100
|
-
return this.actions.map((ActionClass)=>{
|
|
101
|
-
const selectedAction = actionEntries.find(([, action])=>action instanceof ActionClass);
|
|
102
|
-
if (!selectedAction) {
|
|
103
|
-
throw new CommandError(`${this.name()} command missing action instance for ${ActionClass.name}`);
|
|
104
|
-
}
|
|
105
|
-
return selectedAction;
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
throwOnErrors(responses) {
|
|
109
|
-
const failures = Object.entries(responses).filter(([, response])=>{
|
|
110
|
-
if (!response) {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
return !response.succeeded && !response.skipped;
|
|
114
|
-
});
|
|
115
|
-
if (!failures.length) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
throw new CommandError(`${this.name()} command failed. ${failures.map(([actionName, response])=>`${actionName}: ${response?.message ?? "Unknown error"}`).join("\n")}`);
|
|
119
|
-
}
|
|
120
|
-
parseCommandName(stringLike) {
|
|
121
|
-
const command = typeof stringLike === "string" ? stringLike : stringLike.name?.toLowerCase().replace("command", "") ?? "";
|
|
122
|
-
if (command === "") {
|
|
123
|
-
throw new CommandError(`Could not parse command name from ${stringLike.toString()}`);
|
|
124
|
-
}
|
|
125
|
-
return command;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
get ActionMap () {
|
|
13
|
-
return _action.ActionMap;
|
|
14
|
-
},
|
|
15
|
-
get ActionResponse () {
|
|
16
|
-
return _action.ActionResponse;
|
|
17
|
-
},
|
|
18
|
-
get CommandError () {
|
|
19
|
-
return _command.CommandError;
|
|
20
|
-
},
|
|
21
|
-
get CommandResponse () {
|
|
22
|
-
return _command.CommandResponse;
|
|
23
|
-
},
|
|
24
|
-
get ConfigFileOption () {
|
|
25
|
-
return _options.ConfigFileOption;
|
|
26
|
-
},
|
|
27
|
-
get ConfigurationOption () {
|
|
28
|
-
return _options.ConfigurationOption;
|
|
29
|
-
},
|
|
30
|
-
get DecohereCommand () {
|
|
31
|
-
return _command.DecohereCommand;
|
|
32
|
-
},
|
|
33
|
-
get DryRunOption () {
|
|
34
|
-
return _options.DryRunOption;
|
|
35
|
-
},
|
|
36
|
-
get EnvFileIfExistsOption () {
|
|
37
|
-
return _options.EnvFileIfExistsOption;
|
|
38
|
-
},
|
|
39
|
-
get EnvFileOption () {
|
|
40
|
-
return _options.EnvFileOption;
|
|
41
|
-
},
|
|
42
|
-
get LogLevelOption () {
|
|
43
|
-
return _options.LogLevelOption;
|
|
44
|
-
},
|
|
45
|
-
get ModuleManifest () {
|
|
46
|
-
return _moduletype.ModuleManifest;
|
|
47
|
-
},
|
|
48
|
-
get NoBuildOptions () {
|
|
49
|
-
return _options.NoBuildOptions;
|
|
50
|
-
},
|
|
51
|
-
get NoCleanOptions () {
|
|
52
|
-
return _options.NoCleanOptions;
|
|
53
|
-
},
|
|
54
|
-
get ProjectOption () {
|
|
55
|
-
return _options.ProjectOption;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
const _action = require("./action.js");
|
|
59
|
-
const _command = require("./command.js");
|
|
60
|
-
const _moduletype = require("./module.type.js");
|
|
61
|
-
const _options = require("./options.js");
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "ModuleManifest", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return ModuleManifest;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
class ModuleManifest {
|
|
12
|
-
/** Sub-command classes this module contributes. */ commands = {};
|
|
13
|
-
/** Action classes this module contributes. */ actions = {};
|
|
14
|
-
/** Register infrastructure services into the DI container. */ registerServices(_builder) {}
|
|
15
|
-
/** Lazily create a workspace instance. Return null if this module does not use a workspace. */ createWorkspace(_options) {
|
|
16
|
-
return Promise.resolve(null);
|
|
17
|
-
}
|
|
18
|
-
}
|