@decohere/core 0.0.1-dev.116
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 +98 -0
- package/commonjs/src/caching/cache.decorator.js +69 -0
- package/commonjs/src/caching/cache.js +6 -0
- package/commonjs/src/caching/index.js +23 -0
- package/commonjs/src/caching/invalidate-cache.decorator.js +92 -0
- package/commonjs/src/caching/memoize.decorator.js +36 -0
- package/commonjs/src/caching/node-cache-memoize.adapter.js +49 -0
- package/commonjs/src/cli/action.js +65 -0
- package/commonjs/src/cli/command.js +127 -0
- package/commonjs/src/cli/index.js +61 -0
- package/commonjs/src/cli/module.type.js +18 -0
- package/commonjs/src/cli/options.js +115 -0
- package/commonjs/src/collections/collections.js +21 -0
- package/commonjs/src/collections/find-duplicates.js +35 -0
- package/commonjs/src/collections/index.js +52 -0
- package/commonjs/src/collections/merge-arrays.js +34 -0
- package/commonjs/src/collections/sum.js +63 -0
- package/commonjs/src/collections/unique-objects.js +39 -0
- package/commonjs/src/composition/index.js +4 -0
- package/commonjs/src/configuration/configuration.types.js +11 -0
- package/commonjs/src/configuration/index.js +18 -0
- package/commonjs/src/diagnostics/index.js +22 -0
- package/commonjs/src/diagnostics/trace.js +86 -0
- package/commonjs/src/extensibility/decorator-factory-base.js +22 -0
- package/commonjs/src/extensibility/decorator-factory.js +31 -0
- package/commonjs/src/extensibility/extension.js +37 -0
- package/commonjs/src/extensibility/index.js +23 -0
- package/commonjs/src/extensibility/mixwith.js +36 -0
- package/commonjs/src/extensibility/pipeline.js +56 -0
- package/commonjs/src/extensibility/step.js +18 -0
- package/commonjs/src/interop/docker/docker.js +54 -0
- package/commonjs/src/interop/errors/interop.error.js +12 -0
- package/commonjs/src/interop/git/git.js +134 -0
- package/commonjs/src/interop/git/git.types.js +4 -0
- package/commonjs/src/interop/index.js +97 -0
- package/commonjs/src/interop/node/index.js +18 -0
- package/commonjs/src/interop/node/node.js +45 -0
- package/commonjs/src/interop/npm/npm.js +231 -0
- package/commonjs/src/interop/npm/npm.types.js +16 -0
- package/commonjs/src/interop/pnpm/pnpm.js +34 -0
- package/commonjs/src/interop/pnpm/pnpm.types.js +4 -0
- package/commonjs/src/interop/shell/shell.argv.js +45 -0
- package/commonjs/src/interop/shell/shell.js +105 -0
- package/commonjs/src/interop/shell/shell.types.js +4 -0
- package/commonjs/src/interop/types/detect-package-manager.js +71 -0
- package/commonjs/src/interop/types/package-manager.js +4 -0
- package/commonjs/src/interop/yarn/yarn.js +34 -0
- package/commonjs/src/interop/yarn/yarn.types.js +4 -0
- package/commonjs/src/io/copy-file.js +25 -0
- package/commonjs/src/io/delete-file.js +21 -0
- package/commonjs/src/io/directory-exists.js +24 -0
- package/commonjs/src/io/file-exists.js +19 -0
- package/commonjs/src/io/find-directories.js +21 -0
- package/commonjs/src/io/find-file.js +45 -0
- package/commonjs/src/io/index.js +66 -0
- package/commonjs/src/io/io.js +28 -0
- package/commonjs/src/io/read-file.js +39 -0
- package/commonjs/src/io/remove-dir.js +22 -0
- package/commonjs/src/io/types/directory.type.js +4 -0
- package/commonjs/src/io/types/file.js +28 -0
- package/commonjs/src/io/types/index.js +19 -0
- package/commonjs/src/io/url-to-path.js +33 -0
- package/commonjs/src/io/watch.js +261 -0
- package/commonjs/src/io/write-file.js +30 -0
- package/commonjs/src/objects/deep-merge.js +67 -0
- package/commonjs/src/objects/index.js +11 -0
- package/commonjs/src/reflection/index.js +20 -0
- package/commonjs/src/reflection/types/index.js +18 -0
- package/commonjs/src/reflection/types/reflection.types.js +26 -0
- package/commonjs/src/reflection/utilities.js +118 -0
- package/commonjs/src/semver/index.js +18 -0
- package/commonjs/src/semver/semver.js +92 -0
- package/commonjs/src/system/camel-case.js +13 -0
- package/commonjs/src/system/debounce.js +19 -0
- package/commonjs/src/system/decorator.js +46 -0
- package/commonjs/src/system/environment.js +23 -0
- package/commonjs/src/system/function.types.js +18 -0
- package/commonjs/src/system/index.js +24 -0
- package/commonjs/src/system/retry.decorator.js +40 -0
- package/commonjs/src/system/sleep.js +13 -0
- package/commonjs/src/system/type.utils.js +4 -0
- package/commonjs/src/testing/flush-promises.js +16 -0
- package/commonjs/src/testing/glob-with-memfs.js +22 -0
- package/commonjs/src/testing/index.js +22 -0
- package/commonjs/src/testing/memfs.js +52 -0
- package/commonjs/src/testing/mock-logger.js +36 -0
- package/commonjs/src/testing/spy-on-constructor.js +27 -0
- package/es6/src/caching/cache-manager.js +82 -0
- package/es6/src/caching/cache.decorator.js +51 -0
- package/es6/src/caching/cache.js +3 -0
- package/es6/src/caching/index.js +6 -0
- package/es6/src/caching/invalidate-cache.decorator.js +71 -0
- package/es6/src/caching/memoize.decorator.js +27 -0
- package/es6/src/caching/node-cache-memoize.adapter.js +37 -0
- package/es6/src/cli/action.js +47 -0
- package/es6/src/cli/command.js +106 -0
- package/es6/src/cli/index.js +4 -0
- package/es6/src/cli/module.type.js +11 -0
- package/es6/src/cli/options.js +76 -0
- package/es6/src/collections/collections.js +4 -0
- package/es6/src/collections/find-duplicates.js +17 -0
- package/es6/src/collections/index.js +1 -0
- package/es6/src/collections/merge-arrays.js +16 -0
- package/es6/src/collections/sum.js +45 -0
- package/es6/src/collections/unique-objects.js +21 -0
- package/es6/src/composition/index.js +1 -0
- package/es6/src/configuration/configuration.types.js +1 -0
- package/es6/src/configuration/index.js +1 -0
- package/es6/src/diagnostics/index.js +1 -0
- package/es6/src/diagnostics/trace.js +68 -0
- package/es6/src/extensibility/decorator-factory-base.js +39 -0
- package/es6/src/extensibility/decorator-factory.js +21 -0
- package/es6/src/extensibility/extension.js +27 -0
- package/es6/src/extensibility/index.js +6 -0
- package/es6/src/extensibility/mixwith.js +26 -0
- package/es6/src/extensibility/pipeline.js +46 -0
- package/es6/src/extensibility/step.js +16 -0
- package/es6/src/interop/docker/docker.js +44 -0
- package/es6/src/interop/errors/interop.error.js +2 -0
- package/es6/src/interop/git/git.js +124 -0
- package/es6/src/interop/git/git.types.js +1 -0
- package/es6/src/interop/index.js +21 -0
- package/es6/src/interop/node/index.js +1 -0
- package/es6/src/interop/node/node.js +35 -0
- package/es6/src/interop/npm/npm.js +180 -0
- package/es6/src/interop/npm/npm.types.js +6 -0
- package/es6/src/interop/pnpm/pnpm.js +24 -0
- package/es6/src/interop/pnpm/pnpm.types.js +1 -0
- package/es6/src/interop/shell/shell.argv.js +35 -0
- package/es6/src/interop/shell/shell.js +95 -0
- package/es6/src/interop/shell/shell.types.js +1 -0
- package/es6/src/interop/types/detect-package-manager.js +50 -0
- package/es6/src/interop/types/package-manager.js +1 -0
- package/es6/src/interop/yarn/yarn.js +24 -0
- package/es6/src/interop/yarn/yarn.types.js +1 -0
- package/es6/src/io/copy-file.js +10 -0
- package/es6/src/io/delete-file.js +6 -0
- package/es6/src/io/directory-exists.js +9 -0
- package/es6/src/io/file-exists.js +9 -0
- package/es6/src/io/find-directories.js +11 -0
- package/es6/src/io/find-file.js +27 -0
- package/es6/src/io/index.js +2 -0
- package/es6/src/io/io.js +11 -0
- package/es6/src/io/read-file.js +13 -0
- package/es6/src/io/remove-dir.js +7 -0
- package/es6/src/io/types/directory.type.js +1 -0
- package/es6/src/io/types/file.js +18 -0
- package/es6/src/io/types/index.js +2 -0
- package/es6/src/io/url-to-path.js +15 -0
- package/es6/src/io/watch.js +238 -0
- package/es6/src/io/write-file.js +15 -0
- package/es6/src/objects/deep-merge.js +57 -0
- package/es6/src/objects/index.js +1 -0
- package/es6/src/reflection/index.js +3 -0
- package/es6/src/reflection/types/index.js +1 -0
- package/es6/src/reflection/types/reflection.types.js +8 -0
- package/es6/src/reflection/utilities.js +74 -0
- package/es6/src/semver/index.js +1 -0
- package/es6/src/semver/semver.js +71 -0
- package/es6/src/system/camel-case.js +3 -0
- package/es6/src/system/debounce.js +9 -0
- package/es6/src/system/decorator.js +30 -0
- package/es6/src/system/environment.js +5 -0
- package/es6/src/system/function.types.js +26 -0
- package/es6/src/system/index.js +7 -0
- package/es6/src/system/retry.decorator.js +30 -0
- package/es6/src/system/sleep.js +3 -0
- package/es6/src/system/type.utils.js +1 -0
- package/es6/src/testing/flush-promises.js +6 -0
- package/es6/src/testing/glob-with-memfs.js +20 -0
- package/es6/src/testing/index.js +5 -0
- package/es6/src/testing/memfs.js +25 -0
- package/es6/src/testing/mock-logger.js +26 -0
- package/es6/src/testing/spy-on-constructor.js +31 -0
- package/package.json +106 -0
- package/types/src/caching/cache-manager.d.ts +59 -0
- package/types/src/caching/cache.d.ts +11 -0
- package/types/src/caching/cache.decorator.d.ts +18 -0
- package/types/src/caching/index.d.ts +6 -0
- package/types/src/caching/invalidate-cache.decorator.d.ts +17 -0
- package/types/src/caching/memoize.decorator.d.ts +16 -0
- package/types/src/caching/node-cache-memoize.adapter.d.ts +22 -0
- package/types/src/cli/action.d.ts +36 -0
- package/types/src/cli/command.d.ts +34 -0
- package/types/src/cli/index.d.ts +7 -0
- package/types/src/cli/module.type.d.ts +36 -0
- package/types/src/cli/options.d.ts +28 -0
- package/types/src/collections/collections.d.ts +4 -0
- package/types/src/collections/find-duplicates.d.ts +2 -0
- package/types/src/collections/index.d.ts +1 -0
- package/types/src/collections/merge-arrays.d.ts +2 -0
- package/types/src/collections/sum.d.ts +4 -0
- package/types/src/collections/unique-objects.d.ts +2 -0
- package/types/src/composition/index.d.ts +37 -0
- package/types/src/configuration/configuration.types.d.ts +10 -0
- package/types/src/configuration/index.d.ts +1 -0
- package/types/src/diagnostics/index.d.ts +1 -0
- package/types/src/diagnostics/trace.d.ts +10 -0
- package/types/src/extensibility/decorator-factory-base.d.ts +39 -0
- package/types/src/extensibility/decorator-factory.d.ts +19 -0
- package/types/src/extensibility/extension.d.ts +9 -0
- package/types/src/extensibility/index.d.ts +6 -0
- package/types/src/extensibility/mixwith.d.ts +6 -0
- package/types/src/extensibility/pipeline.d.ts +12 -0
- package/types/src/extensibility/step.d.ts +16 -0
- package/types/src/interop/docker/docker.d.ts +19 -0
- package/types/src/interop/errors/interop.error.d.ts +2 -0
- package/types/src/interop/git/git.d.ts +16 -0
- package/types/src/interop/git/git.types.d.ts +14 -0
- package/types/src/interop/index.d.ts +14 -0
- package/types/src/interop/node/index.d.ts +1 -0
- package/types/src/interop/node/node.d.ts +5 -0
- package/types/src/interop/npm/npm.d.ts +29 -0
- package/types/src/interop/npm/npm.types.d.ts +24 -0
- package/types/src/interop/pnpm/pnpm.d.ts +9 -0
- package/types/src/interop/pnpm/pnpm.types.d.ts +3 -0
- package/types/src/interop/shell/shell.argv.d.ts +5 -0
- package/types/src/interop/shell/shell.d.ts +6 -0
- package/types/src/interop/shell/shell.types.d.ts +9 -0
- package/types/src/interop/types/detect-package-manager.d.ts +4 -0
- package/types/src/interop/types/package-manager.d.ts +10 -0
- package/types/src/interop/yarn/yarn.d.ts +9 -0
- package/types/src/interop/yarn/yarn.types.d.ts +3 -0
- package/types/src/io/copy-file.d.ts +4 -0
- package/types/src/io/delete-file.d.ts +1 -0
- package/types/src/io/directory-exists.d.ts +1 -0
- package/types/src/io/file-exists.d.ts +1 -0
- package/types/src/io/find-directories.d.ts +2 -0
- package/types/src/io/find-file.d.ts +9 -0
- package/types/src/io/index.d.ts +2 -0
- package/types/src/io/io.d.ts +11 -0
- package/types/src/io/read-file.d.ts +4 -0
- package/types/src/io/remove-dir.d.ts +5 -0
- package/types/src/io/types/directory.type.d.ts +4 -0
- package/types/src/io/types/file.d.ts +20 -0
- package/types/src/io/types/index.d.ts +2 -0
- package/types/src/io/url-to-path.d.ts +2 -0
- package/types/src/io/watch.d.ts +16 -0
- package/types/src/io/write-file.d.ts +5 -0
- package/types/src/objects/deep-merge.d.ts +41 -0
- package/types/src/objects/index.d.ts +1 -0
- package/types/src/reflection/index.d.ts +3 -0
- package/types/src/reflection/types/index.d.ts +1 -0
- package/types/src/reflection/types/reflection.types.d.ts +21 -0
- package/types/src/reflection/utilities.d.ts +27 -0
- package/types/src/semver/index.d.ts +1 -0
- package/types/src/semver/semver.d.ts +18 -0
- package/types/src/system/camel-case.d.ts +1 -0
- package/types/src/system/debounce.d.ts +1 -0
- package/types/src/system/decorator.d.ts +15 -0
- package/types/src/system/environment.d.ts +6 -0
- package/types/src/system/function.types.d.ts +55 -0
- package/types/src/system/index.d.ts +7 -0
- package/types/src/system/retry.decorator.d.ts +6 -0
- package/types/src/system/sleep.d.ts +1 -0
- package/types/src/system/type.utils.d.ts +1 -0
- package/types/src/testing/flush-promises.d.ts +1 -0
- package/types/src/testing/glob-with-memfs.d.ts +3 -0
- package/types/src/testing/index.d.ts +5 -0
- package/types/src/testing/memfs.d.ts +5 -0
- package/types/src/testing/mock-logger.d.ts +13 -0
- package/types/src/testing/spy-on-constructor.d.ts +21 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "Pnpm", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return Pnpm;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _shell = require("../shell/shell.js");
|
|
12
|
+
const Commands = {
|
|
13
|
+
install: "install"
|
|
14
|
+
};
|
|
15
|
+
class Pnpm extends _shell.Shell {
|
|
16
|
+
name = "pnpm";
|
|
17
|
+
program = "pnpm";
|
|
18
|
+
async install(options = {
|
|
19
|
+
cwd: "./"
|
|
20
|
+
}) {
|
|
21
|
+
const { cwd } = options;
|
|
22
|
+
return this.run({
|
|
23
|
+
cwd
|
|
24
|
+
}, Commands.install);
|
|
25
|
+
}
|
|
26
|
+
async syncLockFile(options = {
|
|
27
|
+
cwd: "./"
|
|
28
|
+
}) {
|
|
29
|
+
const { cwd } = options;
|
|
30
|
+
return this.run({
|
|
31
|
+
cwd
|
|
32
|
+
}, Commands.install, "--lockfile-only", "--ignore-scripts");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "shellArgv", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return shellArgv;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function fields(args) {
|
|
12
|
+
const positional = [];
|
|
13
|
+
const flags = {};
|
|
14
|
+
for(let i = 0; i < args.length; i++){
|
|
15
|
+
const arg = args[i];
|
|
16
|
+
if (arg === "--") {
|
|
17
|
+
positional.push(...args.slice(i + 1));
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
if (arg.startsWith("--")) {
|
|
21
|
+
const body = arg.slice(2);
|
|
22
|
+
const eq = body.indexOf("=");
|
|
23
|
+
if (eq !== -1) {
|
|
24
|
+
flags[body.slice(0, eq)] = body.slice(eq + 1);
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const next = args[i + 1];
|
|
28
|
+
if (next != null && !next.startsWith("-")) {
|
|
29
|
+
flags[body] = next;
|
|
30
|
+
i += 1;
|
|
31
|
+
} else {
|
|
32
|
+
flags[body] = true;
|
|
33
|
+
}
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
positional.push(arg);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
_: positional,
|
|
40
|
+
...flags
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const shellArgv = {
|
|
44
|
+
fields
|
|
45
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "Shell", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return Shell;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _nodechild_process = require("node:child_process");
|
|
12
|
+
const _scribe = require("@decohere/scribe");
|
|
13
|
+
const _interoperror = require("../errors/interop.error.js");
|
|
14
|
+
const _shellargv = require("./shell.argv.js");
|
|
15
|
+
class Shell {
|
|
16
|
+
async run(options, ...args) {
|
|
17
|
+
const logger = _scribe.scribe.logger(Shell.name);
|
|
18
|
+
const argv = args ?? [];
|
|
19
|
+
const argvFields = _shellargv.shellArgv.fields(argv);
|
|
20
|
+
const positionals = Array.isArray(argvFields._) ? argvFields._ : [];
|
|
21
|
+
const commandName = [
|
|
22
|
+
this.program,
|
|
23
|
+
...positionals
|
|
24
|
+
].join(" ").trim();
|
|
25
|
+
logger.info("Running", {
|
|
26
|
+
program: this.program,
|
|
27
|
+
args: argvFields
|
|
28
|
+
});
|
|
29
|
+
return new Promise((resolve, reject)=>{
|
|
30
|
+
let settled = false;
|
|
31
|
+
const resolveOnce = (response)=>{
|
|
32
|
+
if (settled) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
settled = true;
|
|
36
|
+
resolve(response);
|
|
37
|
+
};
|
|
38
|
+
const rejectOnce = (error)=>{
|
|
39
|
+
if (settled) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
settled = true;
|
|
43
|
+
reject(error);
|
|
44
|
+
};
|
|
45
|
+
const { cwd, env } = options;
|
|
46
|
+
const spawnOpt = {
|
|
47
|
+
cwd: cwd ?? ".",
|
|
48
|
+
stdio: [
|
|
49
|
+
"inherit",
|
|
50
|
+
"pipe",
|
|
51
|
+
"pipe"
|
|
52
|
+
],
|
|
53
|
+
env: env ?? {
|
|
54
|
+
...process.env
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const proc = (0, _nodechild_process.spawn)(this.program, argv, spawnOpt);
|
|
58
|
+
const responseData = [];
|
|
59
|
+
const errorData = [];
|
|
60
|
+
proc.on("close", (code, signal)=>{
|
|
61
|
+
if (code === 0) {
|
|
62
|
+
resolveOnce({
|
|
63
|
+
message: `${commandName} completed`,
|
|
64
|
+
data: responseData
|
|
65
|
+
});
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const stderr = errorData.join("\n").trim();
|
|
69
|
+
const stdout = responseData.join("\n").trim();
|
|
70
|
+
const exitCodeText = code == null ? "unknown" : String(code);
|
|
71
|
+
const signalText = signal ? ` signal ${signal}` : "";
|
|
72
|
+
const base = `Running '${commandName}' failed with code ${exitCodeText}${signalText}`;
|
|
73
|
+
const details = [
|
|
74
|
+
stderr ? `stderr:\n${stderr}` : "",
|
|
75
|
+
!stderr && stdout ? `stdout:\n${stdout}` : ""
|
|
76
|
+
].filter(Boolean).join("\n");
|
|
77
|
+
rejectOnce(new _interoperror.InteropError(details ? `${base}\n${details}` : base));
|
|
78
|
+
});
|
|
79
|
+
proc.on("error", (err)=>{
|
|
80
|
+
rejectOnce(err);
|
|
81
|
+
});
|
|
82
|
+
proc.stdout.on("error", (err)=>{
|
|
83
|
+
rejectOnce(err);
|
|
84
|
+
});
|
|
85
|
+
proc.stdout.on("data", (data)=>{
|
|
86
|
+
const lines = this.parseStream(data);
|
|
87
|
+
console.log(data.toString());
|
|
88
|
+
responseData.push(...lines);
|
|
89
|
+
});
|
|
90
|
+
proc.stderr?.on("error", (err)=>{
|
|
91
|
+
rejectOnce(err);
|
|
92
|
+
});
|
|
93
|
+
proc.stderr?.on("data", (data)=>{
|
|
94
|
+
const lines = this.parseStream(data);
|
|
95
|
+
console.error(data.toString());
|
|
96
|
+
errorData.push(...lines);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
parseStream(data) {
|
|
101
|
+
const dataStr = data.toString();
|
|
102
|
+
const lines = dataStr.split("\n").filter((l)=>l !== "");
|
|
103
|
+
return lines;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
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 detectPackageManager () {
|
|
13
|
+
return detectPackageManager;
|
|
14
|
+
},
|
|
15
|
+
get packageManagerFromString () {
|
|
16
|
+
return packageManagerFromString;
|
|
17
|
+
},
|
|
18
|
+
get promptForPackageManager () {
|
|
19
|
+
return promptForPackageManager;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const _nodefs = require("node:fs");
|
|
23
|
+
const _nodepath = require("node:path");
|
|
24
|
+
const _promises = require("node:readline/promises");
|
|
25
|
+
const _npm = require("../npm/npm.js");
|
|
26
|
+
const _pnpm = require("../pnpm/pnpm.js");
|
|
27
|
+
const _yarn = require("../yarn/yarn.js");
|
|
28
|
+
const LOCKFILES = [
|
|
29
|
+
[
|
|
30
|
+
"pnpm-lock.yaml",
|
|
31
|
+
()=>new _pnpm.Pnpm()
|
|
32
|
+
],
|
|
33
|
+
[
|
|
34
|
+
"yarn.lock",
|
|
35
|
+
()=>new _yarn.Yarn()
|
|
36
|
+
],
|
|
37
|
+
[
|
|
38
|
+
"package-lock.json",
|
|
39
|
+
()=>new _npm.Npm()
|
|
40
|
+
]
|
|
41
|
+
];
|
|
42
|
+
function fromLockfile(cwd) {
|
|
43
|
+
for (const [file, factory] of LOCKFILES){
|
|
44
|
+
if ((0, _nodefs.existsSync)((0, _nodepath.join)(cwd, file))) return factory();
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
function fromUserAgent() {
|
|
49
|
+
const agent = process.env.npm_config_user_agent ?? "";
|
|
50
|
+
if (agent.startsWith("pnpm")) return new _pnpm.Pnpm();
|
|
51
|
+
if (agent.startsWith("yarn")) return new _yarn.Yarn();
|
|
52
|
+
if (agent.startsWith("npm")) return new _npm.Npm();
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
function detectPackageManager(cwd) {
|
|
56
|
+
return fromLockfile(cwd) ?? fromUserAgent();
|
|
57
|
+
}
|
|
58
|
+
function packageManagerFromString(name) {
|
|
59
|
+
if (name === "yarn") return new _yarn.Yarn();
|
|
60
|
+
if (name === "npm") return new _npm.Npm();
|
|
61
|
+
return new _pnpm.Pnpm();
|
|
62
|
+
}
|
|
63
|
+
async function promptForPackageManager() {
|
|
64
|
+
const rl = (0, _promises.createInterface)({
|
|
65
|
+
input: process.stdin,
|
|
66
|
+
output: process.stdout
|
|
67
|
+
});
|
|
68
|
+
const answer = await rl.question("Package manager? [pnpm/yarn/npm] (default: pnpm): ");
|
|
69
|
+
rl.close();
|
|
70
|
+
return packageManagerFromString(answer.trim().toLowerCase());
|
|
71
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "Yarn", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return Yarn;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _shell = require("../shell/shell.js");
|
|
12
|
+
const Commands = {
|
|
13
|
+
install: "install"
|
|
14
|
+
};
|
|
15
|
+
class Yarn extends _shell.Shell {
|
|
16
|
+
name = "yarn";
|
|
17
|
+
program = "yarn";
|
|
18
|
+
async install(options = {
|
|
19
|
+
cwd: "./"
|
|
20
|
+
}) {
|
|
21
|
+
const { cwd } = options;
|
|
22
|
+
return this.run({
|
|
23
|
+
cwd
|
|
24
|
+
}, Commands.install);
|
|
25
|
+
}
|
|
26
|
+
async syncLockFile(options = {
|
|
27
|
+
cwd: "./"
|
|
28
|
+
}) {
|
|
29
|
+
const { cwd } = options;
|
|
30
|
+
return this.run({
|
|
31
|
+
cwd
|
|
32
|
+
}, Commands.install, "--mode", "update-lockfile", "--ignore-scripts");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "copyFile", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return copyFile;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _promises = /*#__PURE__*/ _interop_require_default(require("node:fs/promises"));
|
|
12
|
+
const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
async function copyFile(src, dest, options = {}) {
|
|
19
|
+
if (options.mkdir) {
|
|
20
|
+
await _promises.default.mkdir(_nodepath.default.dirname(dest), {
|
|
21
|
+
recursive: true
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
await _promises.default.copyFile(src, dest);
|
|
25
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "deleteFile", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return deleteFile;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _promises = /*#__PURE__*/ _interop_require_default(require("node:fs/promises"));
|
|
12
|
+
function _interop_require_default(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
async function deleteFile(filePath) {
|
|
18
|
+
return _promises.default.rm(filePath, {
|
|
19
|
+
force: true
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "directoryExists", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return directoryExists;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _promises = /*#__PURE__*/ _interop_require_default(require("node:fs/promises"));
|
|
12
|
+
function _interop_require_default(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
async function directoryExists(path) {
|
|
18
|
+
try {
|
|
19
|
+
await _promises.default.access(path);
|
|
20
|
+
return true;
|
|
21
|
+
} catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "fileExists", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return fileExists;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _promises = require("node:fs/promises");
|
|
12
|
+
async function fileExists(path) {
|
|
13
|
+
try {
|
|
14
|
+
const stats = await (0, _promises.stat)(path);
|
|
15
|
+
return stats.isFile();
|
|
16
|
+
} catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "findDirectories", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return findDirectories;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _glob = require("glob");
|
|
12
|
+
async function findDirectories(...pattern) {
|
|
13
|
+
const paths = await (0, _glob.glob)(pattern, {
|
|
14
|
+
withFileTypes: true
|
|
15
|
+
});
|
|
16
|
+
const dirs = paths.filter((p)=>p.isDirectory()).map((p)=>({
|
|
17
|
+
name: p.name,
|
|
18
|
+
parentPath: p.parentPath
|
|
19
|
+
}));
|
|
20
|
+
return dirs;
|
|
21
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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 findFile () {
|
|
13
|
+
return findFile;
|
|
14
|
+
},
|
|
15
|
+
get findFiles () {
|
|
16
|
+
return findFiles;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _glob = require("glob");
|
|
20
|
+
const _file = require("./types/file.js");
|
|
21
|
+
async function findFile(pattern) {
|
|
22
|
+
const files = await (0, _glob.glob)(pattern, {
|
|
23
|
+
includeChildMatches: false
|
|
24
|
+
});
|
|
25
|
+
if (files.length === 0) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const file = {
|
|
29
|
+
relativePath: files.at(0)
|
|
30
|
+
};
|
|
31
|
+
return file;
|
|
32
|
+
}
|
|
33
|
+
async function findFiles(patterns, options) {
|
|
34
|
+
const paths = await (0, _glob.glob)(patterns, {
|
|
35
|
+
...options,
|
|
36
|
+
withFileTypes: true
|
|
37
|
+
});
|
|
38
|
+
const files = paths.filter((p)=>p.isFile()).map((p)=>{
|
|
39
|
+
return new _file.FileEx({
|
|
40
|
+
relativePath: p.relative(),
|
|
41
|
+
fullPath: p.fullpath()
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
return files;
|
|
45
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "io", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _io;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _io = /*#__PURE__*/ _interop_require_wildcard(require("./io.js"));
|
|
12
|
+
_export_star(require("./types/index.js"), exports);
|
|
13
|
+
function _export_star(from, to) {
|
|
14
|
+
Object.keys(from).forEach(function(k) {
|
|
15
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
16
|
+
Object.defineProperty(to, k, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function() {
|
|
19
|
+
return from[k];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return from;
|
|
25
|
+
}
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
27
|
+
if (typeof WeakMap !== "function") return null;
|
|
28
|
+
var cacheBabelInterop = new WeakMap();
|
|
29
|
+
var cacheNodeInterop = new WeakMap();
|
|
30
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
31
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
32
|
+
})(nodeInterop);
|
|
33
|
+
}
|
|
34
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
35
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
36
|
+
return obj;
|
|
37
|
+
}
|
|
38
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
39
|
+
return {
|
|
40
|
+
default: obj
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
44
|
+
if (cache && cache.has(obj)) {
|
|
45
|
+
return cache.get(obj);
|
|
46
|
+
}
|
|
47
|
+
var newObj = {
|
|
48
|
+
__proto__: null
|
|
49
|
+
};
|
|
50
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
51
|
+
for(var key in obj){
|
|
52
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
53
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
54
|
+
if (desc && (desc.get || desc.set)) {
|
|
55
|
+
Object.defineProperty(newObj, key, desc);
|
|
56
|
+
} else {
|
|
57
|
+
newObj[key] = obj[key];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
newObj.default = obj;
|
|
62
|
+
if (cache) {
|
|
63
|
+
cache.set(obj, newObj);
|
|
64
|
+
}
|
|
65
|
+
return newObj;
|
|
66
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./copy-file.js"), exports);
|
|
6
|
+
_export_star(require("./delete-file.js"), exports);
|
|
7
|
+
_export_star(require("./directory-exists.js"), exports);
|
|
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
|
+
_export_star(require("./read-file.js"), exports);
|
|
12
|
+
_export_star(require("./remove-dir.js"), exports);
|
|
13
|
+
_export_star(require("./url-to-path.js"), exports);
|
|
14
|
+
_export_star(require("./watch.js"), exports);
|
|
15
|
+
_export_star(require("./write-file.js"), exports);
|
|
16
|
+
function _export_star(from, to) {
|
|
17
|
+
Object.keys(from).forEach(function(k) {
|
|
18
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
19
|
+
Object.defineProperty(to, k, {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function() {
|
|
22
|
+
return from[k];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return from;
|
|
28
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 readFile () {
|
|
13
|
+
return readFile;
|
|
14
|
+
},
|
|
15
|
+
get readFiles () {
|
|
16
|
+
return readFiles;
|
|
17
|
+
},
|
|
18
|
+
get readJsonFile () {
|
|
19
|
+
return readJsonFile;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const _promises = /*#__PURE__*/ _interop_require_default(require("node:fs/promises"));
|
|
23
|
+
function _interop_require_default(obj) {
|
|
24
|
+
return obj && obj.__esModule ? obj : {
|
|
25
|
+
default: obj
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
async function readFiles(filePaths, encoding = "utf8") {
|
|
29
|
+
const data = await Promise.all(filePaths.map((file)=>readFile(file.fullPath, encoding)));
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
async function readFile(filePath, encoding = "utf8") {
|
|
33
|
+
const data = await _promises.default.readFile(filePath, encoding);
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
async function readJsonFile(filePath, encoding = "utf8") {
|
|
37
|
+
const data = await readFile(filePath, encoding);
|
|
38
|
+
return JSON.parse(data);
|
|
39
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "removeDir", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return removeDir;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _promises = /*#__PURE__*/ _interop_require_default(require("node:fs/promises"));
|
|
12
|
+
function _interop_require_default(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
async function removeDir(path, options = {
|
|
18
|
+
recursive: false,
|
|
19
|
+
force: false
|
|
20
|
+
}) {
|
|
21
|
+
await _promises.default.rm(path, options);
|
|
22
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "FileEx", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return FileEx;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _readfile = require("../read-file.js");
|
|
12
|
+
class FileEx {
|
|
13
|
+
constructor(data){
|
|
14
|
+
this.fullPath = data.fullPath;
|
|
15
|
+
this.relativePath = data.relativePath ?? data.fullPath;
|
|
16
|
+
this.#content = data.content;
|
|
17
|
+
}
|
|
18
|
+
#content;
|
|
19
|
+
fullPath;
|
|
20
|
+
relativePath;
|
|
21
|
+
toString() {
|
|
22
|
+
return this.relativePath;
|
|
23
|
+
}
|
|
24
|
+
async getContent() {
|
|
25
|
+
if (this.#content != null) return this.#content;
|
|
26
|
+
return (0, _readfile.readFile)(this.fullPath);
|
|
27
|
+
}
|
|
28
|
+
}
|