ump 2.1.7 → 3.1.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/.eslintrc.cjs +6 -0
- package/README.md +1 -1
- package/bin/ump.js +6 -6
- package/lib/commands.js +15 -13
- package/lib/config.js +11 -6
- package/lib/log.js +3 -6
- package/lib/notifier.js +7 -2
- package/lib/utils.js +79 -57
- package/package.json +17 -16
- package/test/test.js +31 -24
- package/ump.js +14 -18
- package/.eslintrc.js +0 -6
package/.eslintrc.cjs
ADDED
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ For programmatic use (i.e. requiring it as a module in a node.js script), instal
|
|
|
29
29
|
The only required option is `files`, which takes an array of files. All other options are the same as the command-line long-hand options: `message, release, publish, debug` (not `help`).
|
|
30
30
|
|
|
31
31
|
```js
|
|
32
|
-
|
|
32
|
+
import ump from 'ump';
|
|
33
33
|
|
|
34
34
|
ump({
|
|
35
35
|
files: [
|
package/bin/ump.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const yargs = require('yargs/yargs')(process.argv.slice(2));
|
|
8
|
-
const options = require('../lib/config').cliOptions;
|
|
3
|
+
import('../lib/notifier.js');
|
|
4
|
+
import yarg from 'yargs';
|
|
5
|
+
import ump from '../ump.js';
|
|
6
|
+
import {config} from '../lib/config.js';
|
|
9
7
|
|
|
8
|
+
const options = config.cliOptions;
|
|
9
|
+
const yargs = yarg(process.argv.slice(2));
|
|
10
10
|
const argv = yargs
|
|
11
11
|
.usage('Usage: $0 <releaseType> [files]... [options]')
|
|
12
12
|
.usage(`
|
package/lib/commands.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import Promises from 'bluebird';
|
|
5
|
+
import fs from 'fs-extra';
|
|
6
|
+
import {promisify} from 'util';
|
|
7
|
+
import childProcess from 'child_process';
|
|
8
|
+
import {utils} from './utils.js';
|
|
9
|
+
import {config} from './config.js';
|
|
10
|
+
import {log} from './log.js';
|
|
11
|
+
|
|
8
12
|
const exec = promisify(childProcess.exec);
|
|
9
|
-
const utils = require('./utils');
|
|
10
|
-
const config = require('./config');
|
|
11
|
-
const log = require('./log');
|
|
12
13
|
|
|
13
14
|
const getFlags = (obj) => {
|
|
14
15
|
return Object.entries(obj || {})
|
|
@@ -65,12 +66,13 @@ const commands = {
|
|
|
65
66
|
return console.log(`Skipping version updates to ${files.join(', ')}`);
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
return files.
|
|
69
|
-
const data = utils.readJSON(file);
|
|
69
|
+
return Promise.all(files.map(async(file) => {
|
|
70
|
+
const data = await utils.readJSON(file);
|
|
70
71
|
|
|
71
72
|
data.version = newVersion;
|
|
72
73
|
utils.writeJSON(file, data);
|
|
73
|
-
});
|
|
74
|
+
}));
|
|
75
|
+
|
|
74
76
|
},
|
|
75
77
|
};
|
|
76
78
|
},
|
|
@@ -126,7 +128,7 @@ const commands = {
|
|
|
126
128
|
let lines = [];
|
|
127
129
|
|
|
128
130
|
try {
|
|
129
|
-
await
|
|
131
|
+
await utils.checkGitConfig(path.resolve('./', '.git'));
|
|
130
132
|
} catch (err) {
|
|
131
133
|
utils.error(err);
|
|
132
134
|
}
|
|
@@ -174,4 +176,4 @@ const commands = {
|
|
|
174
176
|
},
|
|
175
177
|
};
|
|
176
178
|
|
|
177
|
-
|
|
179
|
+
export {commands};
|
package/lib/config.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
|
|
2
4
|
let pkg = {};
|
|
3
5
|
|
|
4
6
|
try {
|
|
5
|
-
pkg =
|
|
7
|
+
pkg = fs.readJsonSync(path.join(process.cwd(), 'package.json'));
|
|
6
8
|
} catch (err) {
|
|
7
9
|
pkg = {name: ''};
|
|
8
10
|
}
|
|
9
|
-
|
|
11
|
+
|
|
12
|
+
const config = {
|
|
10
13
|
defaults: {
|
|
11
14
|
sourceFile: 'package.json',
|
|
12
15
|
message: 'Release %s',
|
|
@@ -25,6 +28,7 @@ let config = {
|
|
|
25
28
|
noRepo: 'You cannot "release" this version. You are not in a git repository.',
|
|
26
29
|
noSource: 'The specified source file does not exist.',
|
|
27
30
|
},
|
|
31
|
+
|
|
28
32
|
releaseTypes: [
|
|
29
33
|
'major',
|
|
30
34
|
'minor',
|
|
@@ -33,14 +37,15 @@ let config = {
|
|
|
33
37
|
'preminor',
|
|
34
38
|
'prepatch',
|
|
35
39
|
],
|
|
36
|
-
confirm: [
|
|
37
40
|
|
|
41
|
+
confirm: [
|
|
38
42
|
{
|
|
39
43
|
message: 'Are you sure you want to continue?',
|
|
40
44
|
name: 'run',
|
|
41
45
|
type: 'confirm',
|
|
42
46
|
},
|
|
43
47
|
],
|
|
48
|
+
|
|
44
49
|
publishPrompts: [
|
|
45
50
|
{
|
|
46
51
|
name: 'access',
|
|
@@ -57,7 +62,7 @@ let config = {
|
|
|
57
62
|
],
|
|
58
63
|
};
|
|
59
64
|
|
|
60
|
-
|
|
65
|
+
Object.assign(config, {
|
|
61
66
|
cliOptions: {
|
|
62
67
|
// releaseType: {
|
|
63
68
|
// position: 0,
|
|
@@ -94,4 +99,4 @@ config = Object.assign(config, {
|
|
|
94
99
|
},
|
|
95
100
|
});
|
|
96
101
|
|
|
97
|
-
|
|
102
|
+
export {config};
|
package/lib/log.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import chalk from 'chalk';
|
|
2
2
|
|
|
3
3
|
const log = {
|
|
4
4
|
color: function(str, color) {
|
|
5
|
-
|
|
5
|
+
const txt = color ? chalk[color](str) : str;
|
|
6
6
|
|
|
7
|
-
if (color) {
|
|
8
|
-
txt = chalk[color](txt);
|
|
9
|
-
}
|
|
10
7
|
console.log(txt);
|
|
11
8
|
},
|
|
12
9
|
bump: function(opts) {
|
|
@@ -28,4 +25,4 @@ const log = {
|
|
|
28
25
|
},
|
|
29
26
|
};
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
export {log};
|
package/lib/notifier.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import {utils} from './utils.js';
|
|
4
|
+
import updateNotifier from 'update-notifier';
|
|
1
5
|
|
|
2
|
-
|
|
3
|
-
const
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
const dirname = utils.getDirName(import.meta.url);
|
|
8
|
+
const pkg = fs.readJsonSync(path.resolve(dirname, '..', 'package.json'));
|
|
4
9
|
|
|
5
10
|
updateNotifier({
|
|
6
11
|
packageName: pkg.name,
|
package/lib/utils.js
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import childProcess from 'child_process';
|
|
5
|
+
import Promises from 'bluebird';
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import util from 'util';
|
|
8
|
+
import glob from 'glob';
|
|
9
|
+
import chalk from 'chalk';
|
|
10
|
+
import rc from 'rc';
|
|
11
|
+
import semver from 'semver';
|
|
12
|
+
import {config} from './config.js';
|
|
13
|
+
import {log} from './log.js';
|
|
14
|
+
|
|
15
|
+
const readFile = util.promisify(fs.readFile);
|
|
16
|
+
const writeFile = util.promisify(fs.writeFile);
|
|
17
|
+
const stat = util.promisify(fs.stat);
|
|
13
18
|
|
|
14
19
|
const utils = {
|
|
15
|
-
|
|
20
|
+
getDirName(url) {
|
|
21
|
+
const moduleURL = new URL(url);
|
|
22
|
+
|
|
23
|
+
return moduleURL.pathname.replace(/\/[^/]+$/, '');
|
|
24
|
+
},
|
|
25
|
+
escapeQuotes(str) {
|
|
16
26
|
if (typeof str === 'string') {
|
|
17
27
|
return str.replace(/(["$`\\])/g, '\\$1');
|
|
18
28
|
}
|
|
@@ -20,8 +30,26 @@ const utils = {
|
|
|
20
30
|
return str;
|
|
21
31
|
|
|
22
32
|
},
|
|
33
|
+
async checkGitConfig(gitPath) {
|
|
34
|
+
const gitDirOrFile = await stat(gitPath);
|
|
35
|
+
|
|
36
|
+
if (gitDirOrFile.isDirectory()) {
|
|
37
|
+
await readFile(`${gitPath}/config`);
|
|
38
|
+
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// If we're in a submodule, the .git path will be a file that contains a 'gitdir: …' entry
|
|
43
|
+
const contents = await readFile(gitPath, 'utf8');
|
|
44
|
+
const content = contents.split(/\n/)[0];
|
|
45
|
+
const gitdir = content.replace(/^\s*gitdir:\s*(.+)$/, '$1');
|
|
23
46
|
|
|
24
|
-
|
|
47
|
+
const gitConfig = path.resolve(`${gitdir}/config`);
|
|
48
|
+
|
|
49
|
+
await readFile(gitConfig);
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
getFiles(items) {
|
|
25
53
|
const files = items ? [].concat(items) : ['package.json'];
|
|
26
54
|
const list = [];
|
|
27
55
|
|
|
@@ -41,14 +69,22 @@ const utils = {
|
|
|
41
69
|
return unique;
|
|
42
70
|
},
|
|
43
71
|
|
|
44
|
-
readJSON
|
|
72
|
+
async readJSON(file) {
|
|
73
|
+
const filePath = path.resolve(process.cwd(), file);
|
|
74
|
+
|
|
45
75
|
try {
|
|
46
|
-
|
|
76
|
+
const str = await readFile(filePath, 'utf8');
|
|
77
|
+
const json = JSON.parse(str);
|
|
78
|
+
|
|
79
|
+
return json;
|
|
47
80
|
} catch (err) {
|
|
48
|
-
|
|
81
|
+
console.log(err);
|
|
82
|
+
|
|
83
|
+
return {error: true};
|
|
49
84
|
}
|
|
50
85
|
},
|
|
51
|
-
|
|
86
|
+
|
|
87
|
+
writeJSON(file, input) {
|
|
52
88
|
let json = input;
|
|
53
89
|
|
|
54
90
|
if (typeof json === 'object') {
|
|
@@ -58,7 +94,7 @@ const utils = {
|
|
|
58
94
|
fs.writeFileSync(file, json);
|
|
59
95
|
},
|
|
60
96
|
|
|
61
|
-
getBumpError
|
|
97
|
+
getBumpError(opts) {
|
|
62
98
|
let err = null;
|
|
63
99
|
|
|
64
100
|
if (typeof opts.releaseType === 'undefined') {
|
|
@@ -78,11 +114,9 @@ const utils = {
|
|
|
78
114
|
return err;
|
|
79
115
|
},
|
|
80
116
|
|
|
81
|
-
bumpError
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
let label = 'version';
|
|
85
|
-
let value = opts.version;
|
|
117
|
+
bumpError(opts) {
|
|
118
|
+
const isErr = utils.getBumpError(opts);
|
|
119
|
+
const def = '_default';
|
|
86
120
|
|
|
87
121
|
// Special case for no releaseType (user just types "ump")
|
|
88
122
|
if (isErr === 'noRelease') {
|
|
@@ -99,15 +133,15 @@ const utils = {
|
|
|
99
133
|
return isErr;
|
|
100
134
|
},
|
|
101
135
|
|
|
102
|
-
error
|
|
136
|
+
error(err) {
|
|
103
137
|
throw err;
|
|
104
138
|
},
|
|
105
139
|
|
|
106
|
-
debug
|
|
107
|
-
|
|
108
|
-
|
|
140
|
+
debug(obj) {
|
|
141
|
+
const debugOutput = JSON.stringify(obj, null, 2);
|
|
142
|
+
const file = '.ump.debug.json';
|
|
109
143
|
|
|
110
|
-
return
|
|
144
|
+
return writeFile(file, debugOutput)
|
|
111
145
|
.then(() => {
|
|
112
146
|
log.color(`\n**DEBUG ONLY! Writing the following to ${file}:**`, 'cyan');
|
|
113
147
|
console.log(debugOutput);
|
|
@@ -117,7 +151,7 @@ const utils = {
|
|
|
117
151
|
extend: function extend(...args) {
|
|
118
152
|
let arg, prop;
|
|
119
153
|
let al = args.length;
|
|
120
|
-
|
|
154
|
+
const firstArg = al === 1 ? {} : args.shift();
|
|
121
155
|
|
|
122
156
|
while (--al > -1) {
|
|
123
157
|
arg = args[al];
|
|
@@ -134,11 +168,11 @@ const utils = {
|
|
|
134
168
|
return firstArg;
|
|
135
169
|
},
|
|
136
170
|
|
|
137
|
-
repoDirty: function
|
|
138
|
-
|
|
171
|
+
repoDirty: function(stdout, files) {
|
|
172
|
+
const lines = stdout
|
|
173
|
+
.trim().split('\n')
|
|
139
174
|
.filter((line) => {
|
|
140
|
-
|
|
141
|
-
|
|
175
|
+
const file = line.replace(/.{1,2}\s+/, '');
|
|
142
176
|
|
|
143
177
|
return line.trim() && !file.match(/^\?\? /) && files.indexOf(file) === -1;
|
|
144
178
|
})
|
|
@@ -149,17 +183,17 @@ const utils = {
|
|
|
149
183
|
return lines;
|
|
150
184
|
},
|
|
151
185
|
|
|
152
|
-
resetVersion: function
|
|
186
|
+
resetVersion: function(opts) {
|
|
153
187
|
log.color('Did not execute commands. Resetting version.', 'red');
|
|
154
|
-
opts.files.
|
|
155
|
-
|
|
188
|
+
Promise.all(opts.files.map(async(file) => {
|
|
189
|
+
const json = await utils.readJSON(file);
|
|
156
190
|
|
|
157
191
|
json.version = opts.version;
|
|
158
192
|
utils.writeJSON(file, json);
|
|
159
|
-
});
|
|
193
|
+
}));
|
|
160
194
|
},
|
|
161
195
|
|
|
162
|
-
getNewVersion: function
|
|
196
|
+
getNewVersion: function(opts) {
|
|
163
197
|
// semver release type
|
|
164
198
|
if (config.releaseTypes.indexOf(opts.releaseType) !== -1) {
|
|
165
199
|
return semver.inc(opts.version, opts.releaseType);
|
|
@@ -169,10 +203,10 @@ const utils = {
|
|
|
169
203
|
return opts.releaseType;
|
|
170
204
|
},
|
|
171
205
|
|
|
172
|
-
buildOptions: function
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
206
|
+
buildOptions: async function(options) {
|
|
207
|
+
const appName = options.appName || 'ump';
|
|
208
|
+
const rcOptions = rc(appName);
|
|
209
|
+
const opts = utils.extend(config.defaults, rcOptions, options);
|
|
176
210
|
|
|
177
211
|
opts.files = utils.getFiles(opts.files);
|
|
178
212
|
opts.extraFiles = utils.getFiles(opts.extras || []);
|
|
@@ -183,7 +217,9 @@ const utils = {
|
|
|
183
217
|
opts.release = true;
|
|
184
218
|
}
|
|
185
219
|
|
|
186
|
-
|
|
220
|
+
const src = await utils.readJSON(opts.sourceFile);
|
|
221
|
+
|
|
222
|
+
opts.version = src.version;
|
|
187
223
|
|
|
188
224
|
if (utils.bumpError(opts)) {
|
|
189
225
|
return Object.assign(opts, {error: true});
|
|
@@ -193,20 +229,6 @@ const utils = {
|
|
|
193
229
|
|
|
194
230
|
return opts;
|
|
195
231
|
},
|
|
196
|
-
|
|
197
|
-
// Taken from https://github.com/inikulin/publish-please/blob/master/src/publish.js
|
|
198
|
-
checkNodeNpm: function checkNodeNpm() {
|
|
199
|
-
return exec('npm version --json')
|
|
200
|
-
.then((versions) => {
|
|
201
|
-
const npmVersion = JSON.parse(versions).npm;
|
|
202
|
-
const isNode6 = semver.gte(process.version, '6.0.0');
|
|
203
|
-
const isSafeNpmVersion = semver.satisfies(npmVersion, '>=2.15.8 <3.0.0 || >=3.10.1');
|
|
204
|
-
|
|
205
|
-
if (isNode6 && !isSafeNpmVersion) {
|
|
206
|
-
throw new Error(`npm@${npmVersion} has known issues publishing when running Node.js 6. Please upgrade npm or downgrade Node and publish again. See: https://github.com/npm/npm/issues/5082`);
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
},
|
|
210
232
|
};
|
|
211
233
|
|
|
212
|
-
|
|
234
|
+
export {utils};
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ump",
|
|
3
3
|
"title": "ump",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.1.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
10
|
"test:run": "node_modules/.bin/mocha --delay --reporter spec",
|
|
11
|
-
"lint": "eslint --config .eslintrc.
|
|
11
|
+
"lint": "eslint --config .eslintrc.cjs *.js bin lib test",
|
|
12
12
|
"snyk-protect": "snyk protect",
|
|
13
13
|
"prepare": "npm run snyk-protect"
|
|
14
14
|
},
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"type": "git",
|
|
17
17
|
"url": "git@github.com:kswedberg/ump.git"
|
|
18
18
|
},
|
|
19
|
+
"type": "module",
|
|
19
20
|
"main": "ump.js",
|
|
20
21
|
"bin": {
|
|
21
22
|
"ump": "bin/ump.js"
|
|
@@ -26,26 +27,26 @@
|
|
|
26
27
|
"url": "https://karlswedberg.com/"
|
|
27
28
|
},
|
|
28
29
|
"engines": {
|
|
29
|
-
"node": ">=
|
|
30
|
+
"node": ">=14"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
|
-
"bluebird": "^3.7.
|
|
33
|
-
"chalk": "^
|
|
33
|
+
"bluebird": "^3.7.2",
|
|
34
|
+
"chalk": "^5.0.0",
|
|
34
35
|
"fs-extra": "^10.0.0",
|
|
35
|
-
"git-config": "0.0.7",
|
|
36
|
-
"glob": "^7.
|
|
37
|
-
"inquirer": "^
|
|
36
|
+
"git-config": "^0.0.7",
|
|
37
|
+
"glob": "^7.2.0",
|
|
38
|
+
"inquirer": "^8.2.0",
|
|
38
39
|
"rc": "^1.2.8",
|
|
39
|
-
"semver": "^
|
|
40
|
-
"snyk": "^1.
|
|
41
|
-
"update-notifier": "^
|
|
42
|
-
"yargs": "^
|
|
40
|
+
"semver": "^7.3.5",
|
|
41
|
+
"snyk": "^1.812.0",
|
|
42
|
+
"update-notifier": "^6.0.2",
|
|
43
|
+
"yargs": "^17.3.1"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
|
-
"chai": "^4.
|
|
46
|
-
"eslint": "^
|
|
47
|
-
"eslint-config-kswedberg": "^
|
|
48
|
-
"mocha": "^
|
|
46
|
+
"chai": "^4.3.4",
|
|
47
|
+
"eslint": "^8.5.0",
|
|
48
|
+
"eslint-config-kswedberg": "^5.1.1",
|
|
49
|
+
"mocha": "^9.1.3"
|
|
49
50
|
},
|
|
50
51
|
"license": "MIT",
|
|
51
52
|
"snyk": true
|
package/test/test.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import Promises from 'bluebird';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import ump from '../ump.js';
|
|
5
|
+
import {utils} from '../lib/utils.js';
|
|
6
|
+
import {commands} from '../lib/commands.js';
|
|
7
|
+
|
|
8
|
+
import {expect} from 'chai';
|
|
9
|
+
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
const dirname = utils.getDirName(import.meta.url);
|
|
6
12
|
|
|
7
13
|
const settings = {
|
|
8
14
|
inquire: false,
|
|
@@ -24,13 +30,10 @@ const pkg = {
|
|
|
24
30
|
version: '1.0.0',
|
|
25
31
|
};
|
|
26
32
|
|
|
27
|
-
|
|
33
|
+
let opts = {};
|
|
28
34
|
|
|
29
35
|
const tests = {
|
|
30
|
-
utils
|
|
31
|
-
|
|
32
|
-
const opts = utils.buildOptions(settings);
|
|
33
|
-
|
|
36
|
+
utils() {
|
|
34
37
|
it('should build options object', () => {
|
|
35
38
|
expect(opts.sourceFile).to.equal(settings.files[0]);
|
|
36
39
|
expect(opts.newVersion).to.equal('1.0.1');
|
|
@@ -49,9 +52,8 @@ const tests = {
|
|
|
49
52
|
expect(opts.extraFiles.length).to.equal(2);
|
|
50
53
|
});
|
|
51
54
|
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const commands = require('../lib/commands');
|
|
55
|
+
|
|
56
|
+
commands() {
|
|
55
57
|
const extras = commands.extras(opts);
|
|
56
58
|
|
|
57
59
|
it('should have correct log info', () => {
|
|
@@ -76,7 +78,6 @@ const tests = {
|
|
|
76
78
|
},
|
|
77
79
|
};
|
|
78
80
|
|
|
79
|
-
|
|
80
81
|
const files = [
|
|
81
82
|
{
|
|
82
83
|
file: 'package.json',
|
|
@@ -111,16 +112,22 @@ const files = [
|
|
|
111
112
|
},
|
|
112
113
|
];
|
|
113
114
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
.
|
|
118
|
-
describe('ump', () => {
|
|
119
|
-
Object.keys(tests).forEach((test) => {
|
|
120
|
-
describe(test, tests[test]);
|
|
115
|
+
const runTests = async() => {
|
|
116
|
+
try {
|
|
117
|
+
await Promises.each(files, (file) => {
|
|
118
|
+
return fs.writeFile(path.join(dirname, 'testarea/', file.file), file.content);
|
|
121
119
|
});
|
|
122
|
-
});
|
|
123
120
|
|
|
121
|
+
opts = await utils.buildOptions(settings);
|
|
122
|
+
describe('ump', () => {
|
|
123
|
+
Object.entries(tests).forEach(([name, test]) => {
|
|
124
|
+
describe(name, test);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
} catch (err) {
|
|
128
|
+
console.error(err);
|
|
129
|
+
}
|
|
124
130
|
run();
|
|
125
|
-
}
|
|
126
|
-
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
runTests();
|
package/ump.js
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const config = require('./lib/config');
|
|
3
|
+
import Promises from 'bluebird';
|
|
4
|
+
import inquirer from 'inquirer';
|
|
5
|
+
|
|
6
|
+
import {utils} from './lib/utils.js';
|
|
7
|
+
import {commands} from './lib/commands.js';
|
|
8
|
+
import {log} from './lib/log.js';
|
|
9
|
+
import {config} from './lib/config.js';
|
|
10
|
+
|
|
12
11
|
const sequence = [];
|
|
13
12
|
|
|
14
13
|
const runCommands = function(sequence, options) {
|
|
15
|
-
return
|
|
14
|
+
return Promises.each(sequence, (command) => {
|
|
15
|
+
return command.cmd(options);
|
|
16
|
+
})
|
|
16
17
|
.then(() => {
|
|
17
|
-
|
|
18
|
-
return command.cmd(options);
|
|
19
|
-
})
|
|
20
|
-
.then(() => {
|
|
21
|
-
log.color('*** DONE! ***', 'green');
|
|
22
|
-
});
|
|
18
|
+
log.color('*** DONE! ***', 'green');
|
|
23
19
|
})
|
|
24
20
|
.catch((err) => {
|
|
25
21
|
console.error(err);
|
|
@@ -28,7 +24,7 @@ const runCommands = function(sequence, options) {
|
|
|
28
24
|
};
|
|
29
25
|
|
|
30
26
|
const ump = async function(options) {
|
|
31
|
-
const opts = utils.buildOptions(options);
|
|
27
|
+
const opts = await utils.buildOptions(options);
|
|
32
28
|
|
|
33
29
|
if (opts.error) {
|
|
34
30
|
return;
|
|
@@ -70,4 +66,4 @@ const ump = async function(options) {
|
|
|
70
66
|
runCommands(sequence, opts);
|
|
71
67
|
};
|
|
72
68
|
|
|
73
|
-
|
|
69
|
+
export default ump;
|