ump 3.5.2 → 3.5.7
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 -0
- package/lib/1password.js +27 -0
- package/lib/commands.js +20 -7
- package/lib/config.js +5 -0
- package/package.json +14 -13
- package/ump.js +6 -1
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ For programmatic use (i.e. requiring it as a module in a node.js script), instal
|
|
|
21
21
|
* `-m`, `--message`: Message to be used for the commit and tag when `-r` or `-p` is set. Default: Release %s
|
|
22
22
|
* `-r`, `--release`: If set, runs `git add` and `git commit` for the bumped files and pushes a tagged release.
|
|
23
23
|
* `-p`, `--publish`: If set, automatically runs with the `--release` flag and then publishes the release to npm.
|
|
24
|
+
* `-o`, `--otp`: One-time password for 2FA authentication when publishing to npm.
|
|
24
25
|
* `-a`, `--autostash`: Default: `true`. Whether to use the `--autostash` flag when running `git pull`
|
|
25
26
|
* `-x`, `--skip-pull`: If set, skips executing the initial git pull command during a release/publish task. USE WITH CAUTION.
|
|
26
27
|
* `-t`, `--tag-prefix`: Optional prefix for the version in git tag. (e.g. With `--message "Release %s" --tag-prefix version`, The tag might look like "version 1.2.3" and its commit message "Release version 1.2.3")
|
package/lib/1password.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import sdk from '@1password/sdk';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const has1PasswordVars = () => {
|
|
5
|
+
return process.env.OP_NPM_VAULT_ID && process.env.OP_NPM_ITEM_ID && process.env.OP_SERVICE_ACCOUNT_TOKEN;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// Creates an authenticated client.
|
|
9
|
+
export const getTotp = async() => {
|
|
10
|
+
const vaultId = process.env.OP_NPM_VAULT_ID;
|
|
11
|
+
const itemId = process.env.OP_NPM_ITEM_ID;
|
|
12
|
+
|
|
13
|
+
const client = await sdk.createClient({
|
|
14
|
+
auth: process.env.OP_SERVICE_ACCOUNT_TOKEN,
|
|
15
|
+
// Set the following to your own integration name and version.
|
|
16
|
+
integrationName: 'ump',
|
|
17
|
+
integrationVersion: 'v1.0.0',
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const item = await client.items.get(vaultId, itemId);
|
|
21
|
+
|
|
22
|
+
let field = item.fields.find((element) => {
|
|
23
|
+
return element.fieldType === sdk.ItemFieldType.Totp;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return field.details.content?.code;
|
|
27
|
+
};
|
package/lib/commands.js
CHANGED
|
@@ -7,6 +7,7 @@ import childProcess from 'child_process';
|
|
|
7
7
|
import {utils, peach} from './utils.js';
|
|
8
8
|
import {config} from './config.js';
|
|
9
9
|
import {log} from './log.js';
|
|
10
|
+
import {has1PasswordVars, getTotp} from './1password.js';
|
|
10
11
|
|
|
11
12
|
const exec = promisify(childProcess.exec);
|
|
12
13
|
|
|
@@ -19,7 +20,7 @@ const getFlags = (obj) => {
|
|
|
19
20
|
|
|
20
21
|
return ` --${key} ${val}`;
|
|
21
22
|
})
|
|
22
|
-
.filter(
|
|
23
|
+
.filter(Boolean)
|
|
23
24
|
.join('');
|
|
24
25
|
};
|
|
25
26
|
|
|
@@ -163,18 +164,30 @@ const commands = {
|
|
|
163
164
|
throw new Error('Skipping execution');
|
|
164
165
|
}
|
|
165
166
|
|
|
166
|
-
if (lines.length) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
167
|
+
// if (lines.length) {
|
|
168
|
+
// console.log(lines);
|
|
169
|
+
// utils.error(`Git working directory not clean:\n\t${lines.join('\n\t')}`);
|
|
170
|
+
// }
|
|
170
171
|
|
|
171
172
|
try {
|
|
172
|
-
const ret = await peach(releaseSteps, (command) => {
|
|
173
|
+
const ret = await peach(releaseSteps.slice(-1), (command) => {
|
|
173
174
|
return exec(command)
|
|
174
175
|
.then(() => {
|
|
175
176
|
log.color(`Executed ${command}`, 'cyan');
|
|
176
177
|
})
|
|
177
|
-
.catch(
|
|
178
|
+
.catch(async(err) => {
|
|
179
|
+
console.log('npm publish?', command.includes('npm publish'));
|
|
180
|
+
console.log('npm error code EOTP?', err.message.includes('npm error code EOTP'));
|
|
181
|
+
console.log('has1PasswordVars?', has1PasswordVars());
|
|
182
|
+
|
|
183
|
+
if (command.includes('npm publish') && err.message.includes('npm error code EOTP') && has1PasswordVars()) {
|
|
184
|
+
const flags = getFlags(opts.publishFlags);
|
|
185
|
+
const oneTimePassword = await getTotp();
|
|
186
|
+
|
|
187
|
+
return exec(`npm publish${flags} --otp=${oneTimePassword}`);
|
|
188
|
+
}
|
|
189
|
+
utils.error(err);
|
|
190
|
+
});
|
|
178
191
|
});
|
|
179
192
|
|
|
180
193
|
return ret;
|
package/lib/config.js
CHANGED
|
@@ -86,6 +86,11 @@ Object.assign(config, {
|
|
|
86
86
|
description: 'If set, automatically runs with the `--release` flag and then publishes the release to npm.',
|
|
87
87
|
type: 'boolean',
|
|
88
88
|
},
|
|
89
|
+
o: {
|
|
90
|
+
alias: 'otp',
|
|
91
|
+
description: 'One-time password for 2FA authentication when publishing to npm.',
|
|
92
|
+
type: 'string',
|
|
93
|
+
},
|
|
89
94
|
a: {
|
|
90
95
|
alias: 'autostash',
|
|
91
96
|
description: 'Whether to use the --autostash flag when running `git pull`',
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ump",
|
|
3
3
|
"title": "ump",
|
|
4
|
-
"version": "3.5.
|
|
4
|
+
"version": "3.5.7",
|
|
5
5
|
"description": "Bump without the B",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "npm run test:clean && npm run test:pre && npm run test:run",
|
|
8
8
|
"test:clean": "rm -rf ./test/testarea",
|
|
9
9
|
"test:pre": "npm run lint && mkdir -p \"./test/testarea\"",
|
|
10
|
-
"test:run": "
|
|
10
|
+
"test:run": "mocha --delay --reporter spec",
|
|
11
11
|
"lint": "eslint *.js bin lib test"
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "git@github.com
|
|
15
|
+
"url": "git+ssh://git@github.com/kswedberg/ump.git"
|
|
16
16
|
},
|
|
17
17
|
"type": "module",
|
|
18
18
|
"main": "ump.js",
|
|
@@ -28,23 +28,24 @@
|
|
|
28
28
|
"node": ">=14"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@inquirer/
|
|
33
|
-
"
|
|
34
|
-
"
|
|
31
|
+
"@1password/sdk": "^0.3.1",
|
|
32
|
+
"@inquirer/confirm": "^6.0.3",
|
|
33
|
+
"@inquirer/select": "^5.0.3",
|
|
34
|
+
"chalk": "^5.6.2",
|
|
35
|
+
"fs-extra": "^11.3.2",
|
|
35
36
|
"git-config": "^0.0.7",
|
|
36
|
-
"glob": "^
|
|
37
|
+
"glob": "^13.0.0",
|
|
37
38
|
"rc": "^1.2.8",
|
|
38
|
-
"semver": "^7.7.
|
|
39
|
+
"semver": "^7.7.3",
|
|
39
40
|
"update-notifier": "^7.3.1",
|
|
40
41
|
"yargs": "^18.0.0"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@types/mocha": "^10.0.10",
|
|
44
|
-
"chai": "^6.
|
|
45
|
-
"eslint": "^9.
|
|
46
|
-
"eslint-config-kswedberg": "^7.2.
|
|
47
|
-
"mocha": "^11.7.
|
|
45
|
+
"chai": "^6.2.1",
|
|
46
|
+
"eslint": "^9.39.2",
|
|
47
|
+
"eslint-config-kswedberg": "^7.2.2",
|
|
48
|
+
"mocha": "^11.7.5"
|
|
48
49
|
},
|
|
49
50
|
"license": "MIT"
|
|
50
51
|
}
|
package/ump.js
CHANGED
|
@@ -39,9 +39,14 @@ const ump = async function(options) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
|
|
42
|
+
opts.publishFlags = {};
|
|
43
|
+
|
|
44
|
+
if (opts.otp) {
|
|
45
|
+
opts.publishFlags.otp = opts.otp;
|
|
46
|
+
}
|
|
47
|
+
|
|
42
48
|
// opts.inquire is set to true automatically for CLI usage
|
|
43
49
|
if (opts.publish && opts.inquire && config.pkgName.startsWith('@')) {
|
|
44
|
-
opts.publishFlags = {};
|
|
45
50
|
if (opts.access) {
|
|
46
51
|
config.publishPrompt.default = opts.access;
|
|
47
52
|
}
|