@decohere/devkit 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/README.md +14 -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/diagnostics/index.js +22 -0
- package/commonjs/src/diagnostics/trace.js +79 -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/find-directories.js +21 -0
- package/commonjs/src/io/find-file.js +45 -0
- package/commonjs/src/io/index.js +20 -0
- package/commonjs/src/io/watch.js +261 -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/diagnostics/index.js +1 -0
- package/es6/src/diagnostics/trace.js +61 -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/find-directories.js +11 -0
- package/es6/src/io/find-file.js +27 -0
- package/es6/src/io/index.js +3 -0
- package/es6/src/io/watch.js +238 -0
- package/package.json +49 -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/diagnostics/index.d.ts +1 -0
- package/types/src/diagnostics/trace.d.ts +10 -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/find-directories.d.ts +2 -0
- package/types/src/io/find-file.d.ts +9 -0
- package/types/src/io/index.d.ts +3 -0
- package/types/src/io/watch.d.ts +16 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "Git", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return Git;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _interoperror = require("../errors/interop.error.js");
|
|
12
|
+
const _shell = require("../shell/shell.js");
|
|
13
|
+
const Commands = {
|
|
14
|
+
stage: "stage",
|
|
15
|
+
tag: "tag",
|
|
16
|
+
add: "add",
|
|
17
|
+
commit: "commit",
|
|
18
|
+
push: "push",
|
|
19
|
+
listFiles: "ls-files"
|
|
20
|
+
};
|
|
21
|
+
const defaultOptions = {
|
|
22
|
+
cwd: "./"
|
|
23
|
+
};
|
|
24
|
+
class Git extends _shell.Shell {
|
|
25
|
+
program = "git";
|
|
26
|
+
async getModifiedFiles(options = defaultOptions) {
|
|
27
|
+
const args = [
|
|
28
|
+
Commands.listFiles,
|
|
29
|
+
"--modified"
|
|
30
|
+
];
|
|
31
|
+
const { cwd } = options;
|
|
32
|
+
const result = await this.run({
|
|
33
|
+
cwd
|
|
34
|
+
}, ...args);
|
|
35
|
+
return result.data;
|
|
36
|
+
}
|
|
37
|
+
async getBranchName(options = defaultOptions) {
|
|
38
|
+
const { cwd } = options;
|
|
39
|
+
const args = [
|
|
40
|
+
"rev-parse",
|
|
41
|
+
"--symbolic-full-name",
|
|
42
|
+
"--abbrev-ref",
|
|
43
|
+
"HEAD"
|
|
44
|
+
];
|
|
45
|
+
const result = await this.run({
|
|
46
|
+
cwd
|
|
47
|
+
}, ...args);
|
|
48
|
+
return result.data[0];
|
|
49
|
+
}
|
|
50
|
+
async tag(tag, options = defaultOptions) {
|
|
51
|
+
const args = [
|
|
52
|
+
Commands.tag,
|
|
53
|
+
tag
|
|
54
|
+
];
|
|
55
|
+
const { cwd } = options;
|
|
56
|
+
const result = await this.run({
|
|
57
|
+
cwd
|
|
58
|
+
}, ...args);
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
async pushTag(tag, options = defaultOptions) {
|
|
62
|
+
const { cwd, remote = "origin" } = options;
|
|
63
|
+
const result = await this.run({
|
|
64
|
+
cwd
|
|
65
|
+
}, Commands.push, remote, tag);
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
async commit(message, options) {
|
|
69
|
+
const optionsAndDefaults = {
|
|
70
|
+
...defaultOptions,
|
|
71
|
+
...options
|
|
72
|
+
};
|
|
73
|
+
const { cwd, files = [], all } = optionsAndDefaults;
|
|
74
|
+
const args = [
|
|
75
|
+
Commands.commit
|
|
76
|
+
];
|
|
77
|
+
if (files.length > 0 && all) {
|
|
78
|
+
throw new _interoperror.InteropError("Cannot commit all and files at the same time");
|
|
79
|
+
}
|
|
80
|
+
if (files.length > 0) {
|
|
81
|
+
await this.stage({
|
|
82
|
+
files
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (options.all) {
|
|
86
|
+
args.push("-a");
|
|
87
|
+
}
|
|
88
|
+
args.push("-m", message);
|
|
89
|
+
const result = await this.run({
|
|
90
|
+
cwd
|
|
91
|
+
}, ...args);
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
async push(branch, options) {
|
|
95
|
+
const optionsAndDefaults = {
|
|
96
|
+
...defaultOptions,
|
|
97
|
+
...options
|
|
98
|
+
};
|
|
99
|
+
const { cwd, setUpstream } = optionsAndDefaults;
|
|
100
|
+
const args = [
|
|
101
|
+
Commands.push
|
|
102
|
+
];
|
|
103
|
+
args.push("--set-upstream", setUpstream ?? "origin");
|
|
104
|
+
args.push(branch);
|
|
105
|
+
const result = await this.run({
|
|
106
|
+
cwd
|
|
107
|
+
}, ...args);
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
async pull(branch, options = defaultOptions) {
|
|
111
|
+
const { cwd } = options;
|
|
112
|
+
return this.run({
|
|
113
|
+
cwd
|
|
114
|
+
}, "pull", "--rebase", "origin", branch);
|
|
115
|
+
}
|
|
116
|
+
async stage(options) {
|
|
117
|
+
const optionsAndDefaults = {
|
|
118
|
+
...defaultOptions,
|
|
119
|
+
...options
|
|
120
|
+
};
|
|
121
|
+
const { cwd, files = [], all } = optionsAndDefaults;
|
|
122
|
+
if (all) {
|
|
123
|
+
await this.run({
|
|
124
|
+
cwd
|
|
125
|
+
}, Commands.stage, "-a");
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
for (const file of files){
|
|
129
|
+
await this.run({
|
|
130
|
+
cwd
|
|
131
|
+
}, Commands.stage, file);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// << Git >>
|
|
2
|
+
// << Docker >>
|
|
3
|
+
"use strict";
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
function _export(target, all) {
|
|
8
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
_export(exports, {
|
|
14
|
+
get git () {
|
|
15
|
+
return _gittypes;
|
|
16
|
+
},
|
|
17
|
+
get npm () {
|
|
18
|
+
return _npmtypes;
|
|
19
|
+
},
|
|
20
|
+
get pnpm () {
|
|
21
|
+
return _pnpmtypes;
|
|
22
|
+
},
|
|
23
|
+
get shell () {
|
|
24
|
+
return _shelltypes;
|
|
25
|
+
},
|
|
26
|
+
get yarn () {
|
|
27
|
+
return _yarntypes;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
_export_star(require("./docker/docker.js"), exports);
|
|
31
|
+
_export_star(require("./git/git.js"), exports);
|
|
32
|
+
const _gittypes = /*#__PURE__*/ _interop_require_wildcard(require("./git/git.types.js"));
|
|
33
|
+
_export_star(require("./node/node.js"), exports);
|
|
34
|
+
_export_star(require("./npm/npm.js"), exports);
|
|
35
|
+
const _npmtypes = /*#__PURE__*/ _interop_require_wildcard(require("./npm/npm.types.js"));
|
|
36
|
+
_export_star(require("./pnpm/pnpm.js"), exports);
|
|
37
|
+
const _pnpmtypes = /*#__PURE__*/ _interop_require_wildcard(require("./pnpm/pnpm.types.js"));
|
|
38
|
+
_export_star(require("./shell/shell.js"), exports);
|
|
39
|
+
const _shelltypes = /*#__PURE__*/ _interop_require_wildcard(require("./shell/shell.types.js"));
|
|
40
|
+
_export_star(require("./types/detect-package-manager.js"), exports);
|
|
41
|
+
_export_star(require("./types/package-manager.js"), exports);
|
|
42
|
+
_export_star(require("./yarn/yarn.js"), exports);
|
|
43
|
+
const _yarntypes = /*#__PURE__*/ _interop_require_wildcard(require("./yarn/yarn.types.js"));
|
|
44
|
+
function _export_star(from, to) {
|
|
45
|
+
Object.keys(from).forEach(function(k) {
|
|
46
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
47
|
+
Object.defineProperty(to, k, {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function() {
|
|
50
|
+
return from[k];
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return from;
|
|
56
|
+
}
|
|
57
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
58
|
+
if (typeof WeakMap !== "function") return null;
|
|
59
|
+
var cacheBabelInterop = new WeakMap();
|
|
60
|
+
var cacheNodeInterop = new WeakMap();
|
|
61
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
62
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
63
|
+
})(nodeInterop);
|
|
64
|
+
}
|
|
65
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
66
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
67
|
+
return obj;
|
|
68
|
+
}
|
|
69
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
70
|
+
return {
|
|
71
|
+
default: obj
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
75
|
+
if (cache && cache.has(obj)) {
|
|
76
|
+
return cache.get(obj);
|
|
77
|
+
}
|
|
78
|
+
var newObj = {
|
|
79
|
+
__proto__: null
|
|
80
|
+
};
|
|
81
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
82
|
+
for(var key in obj){
|
|
83
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
84
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
85
|
+
if (desc && (desc.get || desc.set)) {
|
|
86
|
+
Object.defineProperty(newObj, key, desc);
|
|
87
|
+
} else {
|
|
88
|
+
newObj[key] = obj[key];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
newObj.default = obj;
|
|
93
|
+
if (cache) {
|
|
94
|
+
cache.set(obj, newObj);
|
|
95
|
+
}
|
|
96
|
+
return newObj;
|
|
97
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./node.js"), exports);
|
|
6
|
+
function _export_star(from, to) {
|
|
7
|
+
Object.keys(from).forEach(function(k) {
|
|
8
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
9
|
+
Object.defineProperty(to, k, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return from[k];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return from;
|
|
18
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "Node", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return Node;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _nodechild_process = require("node:child_process");
|
|
12
|
+
const _shell = require("../shell/shell.js");
|
|
13
|
+
class Node extends _shell.Shell {
|
|
14
|
+
program = "node";
|
|
15
|
+
async runScript(script, ...args) {
|
|
16
|
+
const spawnOpt = {
|
|
17
|
+
cwd: ".",
|
|
18
|
+
stdio: "inherit",
|
|
19
|
+
env: {
|
|
20
|
+
...process.env
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return new Promise((resolve, reject)=>{
|
|
24
|
+
const proc = (0, _nodechild_process.spawn)("node", [
|
|
25
|
+
script,
|
|
26
|
+
...args
|
|
27
|
+
], spawnOpt);
|
|
28
|
+
proc.on("exit", (code)=>{
|
|
29
|
+
if (code !== 0) {
|
|
30
|
+
reject();
|
|
31
|
+
}
|
|
32
|
+
resolve(null);
|
|
33
|
+
});
|
|
34
|
+
proc.on("close", (code)=>{
|
|
35
|
+
resolve(null);
|
|
36
|
+
if (code === 0) {
|
|
37
|
+
resolve({
|
|
38
|
+
message: `${script} completed`
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
reject(`Running '${script}' failed with code ${code}`);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "Npm", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return Npm;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _interoperror = require("../errors/interop.error.js");
|
|
12
|
+
const _shell = require("../shell/shell.js");
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
14
|
+
if (typeof WeakMap !== "function") return null;
|
|
15
|
+
var cacheBabelInterop = new WeakMap();
|
|
16
|
+
var cacheNodeInterop = new WeakMap();
|
|
17
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
18
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
19
|
+
})(nodeInterop);
|
|
20
|
+
}
|
|
21
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
22
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
23
|
+
return obj;
|
|
24
|
+
}
|
|
25
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
26
|
+
return {
|
|
27
|
+
default: obj
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
31
|
+
if (cache && cache.has(obj)) {
|
|
32
|
+
return cache.get(obj);
|
|
33
|
+
}
|
|
34
|
+
var newObj = {
|
|
35
|
+
__proto__: null
|
|
36
|
+
};
|
|
37
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
38
|
+
for(var key in obj){
|
|
39
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
40
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
41
|
+
if (desc && (desc.get || desc.set)) {
|
|
42
|
+
Object.defineProperty(newObj, key, desc);
|
|
43
|
+
} else {
|
|
44
|
+
newObj[key] = obj[key];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
newObj.default = obj;
|
|
49
|
+
if (cache) {
|
|
50
|
+
cache.set(obj, newObj);
|
|
51
|
+
}
|
|
52
|
+
return newObj;
|
|
53
|
+
}
|
|
54
|
+
const Commands = {
|
|
55
|
+
publish: "publish",
|
|
56
|
+
version: "version",
|
|
57
|
+
link: "link",
|
|
58
|
+
install: "install"
|
|
59
|
+
};
|
|
60
|
+
class Npm extends _shell.Shell {
|
|
61
|
+
name = "npm";
|
|
62
|
+
program = "npm";
|
|
63
|
+
async publish(directory, options = {
|
|
64
|
+
channel: "beta"
|
|
65
|
+
}) {
|
|
66
|
+
const { cwd, dryRun, skipIfPublished, channel, authToken, otp, provenance } = options;
|
|
67
|
+
if (directory == null) {
|
|
68
|
+
throw new _interoperror.InteropError("Directory is required");
|
|
69
|
+
}
|
|
70
|
+
if (skipIfPublished && !dryRun) {
|
|
71
|
+
const alreadyPublished = await this.isPublished(directory, {
|
|
72
|
+
cwd
|
|
73
|
+
});
|
|
74
|
+
if (alreadyPublished) {
|
|
75
|
+
return {
|
|
76
|
+
message: `Skipping publish — version already exists on registry`,
|
|
77
|
+
data: []
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const args = [
|
|
82
|
+
Commands.publish,
|
|
83
|
+
directory
|
|
84
|
+
];
|
|
85
|
+
let tmpUserConfigPath;
|
|
86
|
+
args.push("--tag", channel ?? "beta");
|
|
87
|
+
if (provenance) {
|
|
88
|
+
args.push("--provenance");
|
|
89
|
+
}
|
|
90
|
+
// Explicit --token (local bootstrap). OIDC publish must not inherit cwd .npmrc / NODE_AUTH_TOKEN.
|
|
91
|
+
if (authToken?.trim()) {
|
|
92
|
+
tmpUserConfigPath = await this.createTempUserConfig(authToken.trim());
|
|
93
|
+
args.push("--userconfig", tmpUserConfigPath);
|
|
94
|
+
}
|
|
95
|
+
if (dryRun) {
|
|
96
|
+
args.push("--dry-run");
|
|
97
|
+
}
|
|
98
|
+
const env = {
|
|
99
|
+
...process.env
|
|
100
|
+
};
|
|
101
|
+
if (!authToken?.trim()) {
|
|
102
|
+
delete env.NODE_AUTH_TOKEN;
|
|
103
|
+
delete env.NPM_TOKEN;
|
|
104
|
+
env.NPM_CONFIG_USERCONFIG = "/dev/null";
|
|
105
|
+
}
|
|
106
|
+
if (otp) {
|
|
107
|
+
env.NPM_CONFIG_OTP = otp;
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
return await this.run({
|
|
111
|
+
cwd,
|
|
112
|
+
env
|
|
113
|
+
}, ...args);
|
|
114
|
+
} catch (error) {
|
|
115
|
+
if (skipIfPublished && !dryRun && isAlreadyPublishedError(error)) {
|
|
116
|
+
return {
|
|
117
|
+
message: `Skipping publish — version already exists on registry`,
|
|
118
|
+
data: []
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
throw error;
|
|
122
|
+
} finally{
|
|
123
|
+
if (tmpUserConfigPath) {
|
|
124
|
+
await this.removeTempUserConfig(tmpUserConfigPath);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* @description Runs in the directory of the package
|
|
130
|
+
* @param options
|
|
131
|
+
* @returns
|
|
132
|
+
*/ async version(versionType, options) {
|
|
133
|
+
const { cwd, noTag, preid } = options;
|
|
134
|
+
const args = [
|
|
135
|
+
Commands.version,
|
|
136
|
+
versionType
|
|
137
|
+
];
|
|
138
|
+
if (noTag) {
|
|
139
|
+
args.push("--no-git-tag-version");
|
|
140
|
+
}
|
|
141
|
+
if (preid) {
|
|
142
|
+
args.push("--preid", preid);
|
|
143
|
+
}
|
|
144
|
+
return this.run({
|
|
145
|
+
cwd
|
|
146
|
+
}, ...args);
|
|
147
|
+
}
|
|
148
|
+
async link(directory, options = {
|
|
149
|
+
cwd: "./"
|
|
150
|
+
}) {
|
|
151
|
+
const { cwd } = options;
|
|
152
|
+
const args = [
|
|
153
|
+
Commands.link,
|
|
154
|
+
directory
|
|
155
|
+
];
|
|
156
|
+
return this.run({
|
|
157
|
+
cwd
|
|
158
|
+
}, ...args);
|
|
159
|
+
}
|
|
160
|
+
async install(options = {
|
|
161
|
+
cwd: "./"
|
|
162
|
+
}) {
|
|
163
|
+
const { cwd } = options;
|
|
164
|
+
return this.run({
|
|
165
|
+
cwd
|
|
166
|
+
}, Commands.install);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Install only `dependencies` as real folders: `--omit=dev` skips devDependencies and
|
|
170
|
+
* `--no-bin-links` skips the `.bin` symlinks, so the result holds no symlinks at all.
|
|
171
|
+
*/ async installProduction(options = {
|
|
172
|
+
cwd: "./"
|
|
173
|
+
}) {
|
|
174
|
+
const { cwd } = options;
|
|
175
|
+
return this.run({
|
|
176
|
+
cwd
|
|
177
|
+
}, Commands.install, "--omit=dev", "--no-bin-links", "--no-audit", "--no-fund", "--loglevel=error");
|
|
178
|
+
}
|
|
179
|
+
async syncLockFile(options = {
|
|
180
|
+
cwd: "./"
|
|
181
|
+
}) {
|
|
182
|
+
const { cwd } = options;
|
|
183
|
+
return this.run({
|
|
184
|
+
cwd
|
|
185
|
+
}, Commands.install, "--package-lock-only", "--ignore-scripts");
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* True when package@version exists on the registry.
|
|
189
|
+
* Uses ambient npm config (cwd `.npmrc`); do not pass tokens on argv.
|
|
190
|
+
*/ async isPublished(directory, options) {
|
|
191
|
+
const { readFileSync } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("node:fs")));
|
|
192
|
+
const { join } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("node:path")));
|
|
193
|
+
try {
|
|
194
|
+
const pkgJson = JSON.parse(readFileSync(join(directory, "package.json"), "utf8"));
|
|
195
|
+
const spec = `${pkgJson.name}@${pkgJson.version}`;
|
|
196
|
+
await this.run(options, "view", spec, "version");
|
|
197
|
+
return true;
|
|
198
|
+
} catch {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
async createTempUserConfig(authToken) {
|
|
203
|
+
const { mkdtemp, writeFile } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("node:fs/promises")));
|
|
204
|
+
const { tmpdir } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("node:os")));
|
|
205
|
+
const { join } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("node:path")));
|
|
206
|
+
const tempDir = await mkdtemp(join(tmpdir(), "decohere-npmrc-"));
|
|
207
|
+
const npmrcPath = join(tempDir, ".npmrc");
|
|
208
|
+
const npmrc = [
|
|
209
|
+
"registry=https://registry.npmjs.org/",
|
|
210
|
+
"always-auth=true",
|
|
211
|
+
`//registry.npmjs.org/:_authToken=${authToken}`
|
|
212
|
+
].join("\n");
|
|
213
|
+
await writeFile(npmrcPath, `${npmrc}\n`, {
|
|
214
|
+
mode: 0o600
|
|
215
|
+
});
|
|
216
|
+
return npmrcPath;
|
|
217
|
+
}
|
|
218
|
+
async removeTempUserConfig(npmrcPath) {
|
|
219
|
+
const { rm } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("node:fs/promises")));
|
|
220
|
+
const { dirname } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("node:path")));
|
|
221
|
+
const dir = dirname(npmrcPath);
|
|
222
|
+
await rm(dir, {
|
|
223
|
+
recursive: true,
|
|
224
|
+
force: true
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function isAlreadyPublishedError(error) {
|
|
229
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
230
|
+
return /cannot publish over the previously published versions/i.test(message);
|
|
231
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "VersionTypes", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return VersionTypes;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const VersionTypes = {
|
|
12
|
+
major: "major",
|
|
13
|
+
minor: "minor",
|
|
14
|
+
patch: "patch",
|
|
15
|
+
prerelease: "prerelease"
|
|
16
|
+
};
|
|
@@ -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
|
+
};
|