ump 3.5.3 → 4.0.0
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 -2
- package/lib/config.js +5 -0
- package/lib/log.js +6 -6
- package/lib/utils.js +3 -3
- package/package.json +11 -11
- 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
|
|
|
@@ -174,7 +175,24 @@ const commands = {
|
|
|
174
175
|
.then(() => {
|
|
175
176
|
log.color(`Executed ${command}`, 'cyan');
|
|
176
177
|
})
|
|
177
|
-
.catch(
|
|
178
|
+
.catch(async(err) => {
|
|
179
|
+
if (command.includes('npm publish') && err.message.includes('npm error code EOTP')) {
|
|
180
|
+
if (has1PasswordVars()) {
|
|
181
|
+
const flags = getFlags(opts.publishFlags);
|
|
182
|
+
const oneTimePassword = await getTotp();
|
|
183
|
+
|
|
184
|
+
log.color('npm publish command failed with EOTP error', 'red');
|
|
185
|
+
log.color('Trying again with one-time password', 'cyan');
|
|
186
|
+
|
|
187
|
+
return exec(`npm publish${flags} --otp=${oneTimePassword}`);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
log.color('One-time password is not set', 'red');
|
|
191
|
+
log.color('Try using the --otp option to provide a one-time password', 'cyan');
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
utils.error(err);
|
|
195
|
+
});
|
|
178
196
|
});
|
|
179
197
|
|
|
180
198
|
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/lib/log.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {styleText} from 'node:util';
|
|
2
2
|
|
|
3
3
|
const log = {
|
|
4
4
|
color: function(str, color) {
|
|
5
|
-
const txt = color ?
|
|
5
|
+
const txt = color ? styleText(color, str) : str;
|
|
6
6
|
|
|
7
7
|
console.log(txt);
|
|
8
8
|
},
|
|
@@ -10,9 +10,9 @@ const log = {
|
|
|
10
10
|
const files = opts.files.join(', ');
|
|
11
11
|
|
|
12
12
|
console.log('');
|
|
13
|
-
console.log(
|
|
14
|
-
console.log(
|
|
15
|
-
console.log(
|
|
13
|
+
console.log(styleText('bold', 'SET FILES:\t'), styleText('yellow', files));
|
|
14
|
+
console.log(styleText('bold', 'OLD VERSION:\t'), styleText('yellow', opts.version));
|
|
15
|
+
console.log(styleText('bold', 'NEW VERSION:\t'), styleText('yellow', opts.newVersion));
|
|
16
16
|
},
|
|
17
17
|
tasks: function(tasks) {
|
|
18
18
|
console.log('\nAbout to execute the following:');
|
|
@@ -21,7 +21,7 @@ const log = {
|
|
|
21
21
|
});
|
|
22
22
|
},
|
|
23
23
|
keyValue: function(key, value) {
|
|
24
|
-
console.log(
|
|
24
|
+
console.log(styleText('dim', key), value);
|
|
25
25
|
},
|
|
26
26
|
};
|
|
27
27
|
|
package/lib/utils.js
CHANGED
|
@@ -4,7 +4,7 @@ import path from 'path';
|
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
import util from 'util';
|
|
6
6
|
import {globSync} from 'glob';
|
|
7
|
-
import
|
|
7
|
+
import {styleText} from 'node:util';
|
|
8
8
|
import rc from 'rc';
|
|
9
9
|
import semver from 'semver';
|
|
10
10
|
import {config} from './config.js';
|
|
@@ -118,10 +118,10 @@ const utils = {
|
|
|
118
118
|
|
|
119
119
|
// Special case for no releaseType (user just types "ump")
|
|
120
120
|
if (isErr === 'noRelease') {
|
|
121
|
-
console.log(
|
|
121
|
+
console.log(styleText(['yellow', 'bold'], '\nCURRENT VERSION:'));
|
|
122
122
|
} else if (isErr) {
|
|
123
123
|
// All other errors
|
|
124
|
-
console.log(
|
|
124
|
+
console.log(styleText('red', `\n${config.messages[isErr]}` || config.messages[def]));
|
|
125
125
|
|
|
126
126
|
['releaseType', 'sourceFile', 'version'].forEach((item) => {
|
|
127
127
|
log.keyValue(item, opts[item]);
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ump",
|
|
3
3
|
"title": "ump",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0",
|
|
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",
|
|
@@ -25,25 +25,25 @@
|
|
|
25
25
|
"url": "https://karlswedberg.com/"
|
|
26
26
|
},
|
|
27
27
|
"engines": {
|
|
28
|
-
"node": ">=
|
|
28
|
+
"node": ">=20.12.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@inquirer/
|
|
33
|
-
"
|
|
31
|
+
"@1password/sdk": "^0.3.1",
|
|
32
|
+
"@inquirer/confirm": "^6.0.4",
|
|
33
|
+
"@inquirer/select": "^5.0.4",
|
|
34
34
|
"fs-extra": "^11.3.2",
|
|
35
35
|
"git-config": "^0.0.7",
|
|
36
|
-
"glob": "^13.0.
|
|
36
|
+
"glob": "^13.0.1",
|
|
37
37
|
"rc": "^1.2.8",
|
|
38
|
-
"semver": "^7.7.
|
|
38
|
+
"semver": "^7.7.4",
|
|
39
39
|
"update-notifier": "^7.3.1",
|
|
40
40
|
"yargs": "^18.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/mocha": "^10.0.10",
|
|
44
44
|
"chai": "^6.2.1",
|
|
45
|
-
"eslint": "^9.39.
|
|
46
|
-
"eslint-config-kswedberg": "^7.2.
|
|
45
|
+
"eslint": "^9.39.2",
|
|
46
|
+
"eslint-config-kswedberg": "^7.2.3",
|
|
47
47
|
"mocha": "^11.7.5"
|
|
48
48
|
},
|
|
49
49
|
"license": "MIT"
|
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
|
}
|