@automattic/vip 2.21.0 → 2.23.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/CHANGELOG.md +23 -0
- package/assets/dev-env.lando.template.yml.ejs +1 -1
- package/automattic-vip-2.23.0.tgz +0 -0
- package/dist/bin/vip-app-list.js +0 -12
- package/dist/bin/vip-app.js +6 -13
- package/dist/bin/vip-cache-purge-url.js +4 -19
- package/dist/bin/vip-cache.js +0 -2
- package/dist/bin/vip-config-envvar-delete.js +4 -19
- package/dist/bin/vip-config-envvar-get-all.js +6 -19
- package/dist/bin/vip-config-envvar-get.js +4 -15
- package/dist/bin/vip-config-envvar-list.js +8 -20
- package/dist/bin/vip-config-envvar-set.js +4 -23
- package/dist/bin/vip-config-envvar.js +0 -2
- package/dist/bin/vip-config-software-get.js +0 -17
- package/dist/bin/vip-config-software-update.js +6 -22
- package/dist/bin/vip-config-software.js +0 -2
- package/dist/bin/vip-config.js +0 -2
- package/dist/bin/vip-dev-env-create.js +0 -18
- package/dist/bin/vip-dev-env-destroy.js +0 -9
- package/dist/bin/vip-dev-env-exec.js +0 -12
- package/dist/bin/vip-dev-env-import-media.js +0 -7
- package/dist/bin/vip-dev-env-import-sql.js +2 -17
- package/dist/bin/vip-dev-env-import.js +0 -3
- package/dist/bin/vip-dev-env-info.js +0 -10
- package/dist/bin/vip-dev-env-list.js +0 -7
- package/dist/bin/vip-dev-env-start.js +4 -14
- package/dist/bin/vip-dev-env-stop.js +0 -9
- package/dist/bin/vip-dev-env-update.js +0 -11
- package/dist/bin/vip-dev-env.js +0 -2
- package/dist/bin/vip-import-media-abort.js +0 -18
- package/dist/bin/vip-import-media-status.js +0 -12
- package/dist/bin/vip-import-media.js +6 -23
- package/dist/bin/vip-import-sql-status.js +0 -12
- package/dist/bin/vip-import-sql.js +40 -103
- package/dist/bin/vip-import-validate-files.js +21 -42
- package/dist/bin/vip-import-validate-sql.js +0 -8
- package/dist/bin/vip-import.js +0 -3
- package/dist/bin/vip-logs.js +20 -50
- package/dist/bin/vip-search-replace.js +8 -14
- package/dist/bin/vip-sync.js +2 -25
- package/dist/bin/vip-validate-preflight.js +427 -0
- package/dist/bin/vip-validate.js +19 -0
- package/dist/bin/vip-whoami.js +2 -14
- package/dist/bin/vip-wp.js +39 -89
- package/dist/bin/vip.js +5 -35
- package/dist/lib/analytics/clients/pendo.js +9 -18
- package/dist/lib/analytics/clients/stub.js +1 -3
- package/dist/lib/analytics/clients/tracks.js +11 -20
- package/dist/lib/analytics/index.js +4 -11
- package/dist/lib/api/app.js +1 -11
- package/dist/lib/api/cache-purge.js +4 -7
- package/dist/lib/api/feature-flags.js +1 -4
- package/dist/lib/api/http.js +9 -15
- package/dist/lib/api/user.js +1 -7
- package/dist/lib/api.js +17 -19
- package/dist/lib/app-logs/app-logs.js +2 -9
- package/dist/lib/app.js +2 -5
- package/dist/lib/cli/apiConfig.js +4 -19
- package/dist/lib/cli/command.js +43 -133
- package/dist/lib/cli/config.js +1 -5
- package/dist/lib/cli/envAlias.js +14 -15
- package/dist/lib/cli/exit.js +4 -6
- package/dist/lib/cli/format.js +8 -50
- package/dist/lib/cli/progress.js +13 -42
- package/dist/lib/cli/prompt.js +1 -5
- package/dist/lib/cli/repo.js +7 -20
- package/dist/lib/client-file-uploader.js +44 -97
- package/dist/lib/config/software.js +2 -52
- package/dist/lib/constants/dev-environment.js +1 -2
- package/dist/lib/constants/file-size.js +1 -1
- package/dist/lib/constants/vipgo.js +1 -1
- package/dist/lib/dev-environment/dev-environment-cli.js +68 -155
- package/dist/lib/dev-environment/dev-environment-core.js +73 -194
- package/dist/lib/dev-environment/dev-environment-lando.js +16 -71
- package/dist/lib/env.js +1 -4
- package/dist/lib/envvar/api-delete.js +1 -4
- package/dist/lib/envvar/api-get-all.js +1 -4
- package/dist/lib/envvar/api-get.js +1 -2
- package/dist/lib/envvar/api-list.js +3 -4
- package/dist/lib/envvar/api-set.js +1 -4
- package/dist/lib/envvar/api.js +5 -16
- package/dist/lib/envvar/input.js +1 -8
- package/dist/lib/envvar/logging.js +2 -6
- package/dist/lib/envvar/read-file.js +1 -3
- package/dist/lib/http/proxy-agent.js +17 -22
- package/dist/lib/keychain/browser.js +1 -4
- package/dist/lib/keychain/insecure.js +1 -10
- package/dist/lib/keychain/secure.js +1 -8
- package/dist/lib/keychain.js +4 -8
- package/dist/lib/logout.js +0 -6
- package/dist/lib/media-import/media-file-import.js +3 -7
- package/dist/lib/media-import/progress.js +6 -17
- package/dist/lib/media-import/status.js +14 -65
- package/dist/lib/read-file.js +1 -6
- package/dist/lib/rollbar.js +1 -7
- package/dist/lib/search-and-replace.js +9 -41
- package/dist/lib/site-import/db-file-import.js +3 -9
- package/dist/lib/site-import/status.js +17 -74
- package/dist/lib/token.js +1 -33
- package/dist/lib/tracker.js +4 -20
- package/dist/lib/user-error.js +0 -2
- package/dist/lib/validations/is-multi-site-sql-dump.js +4 -12
- package/dist/lib/validations/is-multi-site.js +5 -21
- package/dist/lib/validations/is-multisite-domain-mapped.js +5 -31
- package/dist/lib/validations/line-by-line.js +4 -16
- package/dist/lib/validations/site-type.js +10 -19
- package/dist/lib/validations/sql.js +11 -76
- package/dist/lib/validations/utils.js +1 -6
- package/dist/lib/vip-import-validate-files.js +82 -109
- package/npm-shrinkwrap.json +2407 -1800
- package/package.json +18 -15
package/dist/lib/cli/exit.js
CHANGED
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.withError = withError;
|
|
7
|
-
|
|
8
7
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
|
-
|
|
10
8
|
var _env = _interopRequireDefault(require("../env"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
*
|
|
16
12
|
* @format
|
|
@@ -23,11 +19,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
23
19
|
/**
|
|
24
20
|
* Internal dependencies
|
|
25
21
|
*/
|
|
22
|
+
|
|
26
23
|
function withError(message) {
|
|
27
|
-
console.log(`${_chalk.default.red('Error: ')} ${message.toString().replace(/^Error:\s*/, '')}`);
|
|
24
|
+
console.log(`${_chalk.default.red('Error: ')} ${message.toString().replace(/^Error:\s*/, '')}`);
|
|
25
|
+
|
|
26
|
+
// Debug ouput is printed below error output both for information
|
|
28
27
|
// hierarchy and to make it more likely that the user copies it to their
|
|
29
28
|
// clipboard when dragging across output.
|
|
30
|
-
|
|
31
29
|
console.log(`${_chalk.default.yellow('Debug: ')} VIP-CLI v${_env.default.app.version}, Node ${_env.default.node.version}, ${_env.default.os.name} ${_env.default.os.version}`);
|
|
32
30
|
process.exit(1);
|
|
33
31
|
}
|
package/dist/lib/cli/format.js
CHANGED
|
@@ -3,83 +3,67 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.RunningSprite = exports.RUNNING_SPRITE_GLYPHS = void 0;
|
|
7
|
+
exports.capitalize = capitalize;
|
|
6
8
|
exports.formatData = formatData;
|
|
7
9
|
exports.formatEnvironment = formatEnvironment;
|
|
8
|
-
exports.
|
|
10
|
+
exports.formatSearchReplaceValues = void 0;
|
|
11
|
+
exports.getGlyphForStatus = getGlyphForStatus;
|
|
9
12
|
exports.keyValue = keyValue;
|
|
10
13
|
exports.requoteArgs = requoteArgs;
|
|
11
|
-
exports.
|
|
12
|
-
exports.getGlyphForStatus = getGlyphForStatus;
|
|
13
|
-
exports.formatSearchReplaceValues = exports.RunningSprite = exports.RUNNING_SPRITE_GLYPHS = void 0;
|
|
14
|
-
|
|
14
|
+
exports.table = table;
|
|
15
15
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
16
|
-
|
|
17
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
|
|
19
17
|
/** @format */
|
|
20
|
-
|
|
21
18
|
/**
|
|
22
19
|
* External dependencies
|
|
23
20
|
*/
|
|
21
|
+
|
|
24
22
|
function formatData(data, format, opts) {
|
|
25
23
|
if (!data || !data.length) {
|
|
26
24
|
return '';
|
|
27
25
|
}
|
|
28
|
-
|
|
29
26
|
switch (format) {
|
|
30
27
|
case 'ids':
|
|
31
28
|
return ids(data, opts);
|
|
32
|
-
|
|
33
29
|
case 'json':
|
|
34
30
|
return JSON.stringify(data, null, '\t');
|
|
35
|
-
|
|
36
31
|
case 'csv':
|
|
37
32
|
return csv(data, opts);
|
|
38
|
-
|
|
39
33
|
case 'keyValue':
|
|
40
34
|
return keyValue(data, opts);
|
|
41
|
-
|
|
42
35
|
case 'table':
|
|
43
36
|
default:
|
|
44
37
|
return table(data, opts);
|
|
45
38
|
}
|
|
46
39
|
}
|
|
47
|
-
|
|
48
40
|
function formatEnvironment(environment) {
|
|
49
41
|
if ('production' === environment.toLowerCase()) {
|
|
50
42
|
return _chalk.default.red(environment.toUpperCase());
|
|
51
43
|
}
|
|
52
|
-
|
|
53
44
|
return _chalk.default.blueBright(environment.toLowerCase());
|
|
54
45
|
}
|
|
55
|
-
|
|
56
46
|
function ids(data) {
|
|
57
47
|
const fields = Object.keys(data[0]).map(key => key.toLowerCase());
|
|
58
|
-
|
|
59
48
|
if (0 > fields.indexOf('id')) {
|
|
60
49
|
return 'No ID field found';
|
|
61
50
|
}
|
|
62
|
-
|
|
63
51
|
const id = [];
|
|
64
52
|
data.forEach(datum => id.push(datum.id));
|
|
65
53
|
return id.join(' ');
|
|
66
54
|
}
|
|
67
|
-
|
|
68
55
|
function csv(data) {
|
|
69
56
|
const {
|
|
70
57
|
Parser
|
|
71
58
|
} = require('json2csv');
|
|
72
|
-
|
|
73
59
|
const fields = Object.keys(data[0]);
|
|
74
60
|
const parser = new Parser({
|
|
75
61
|
fields: formatFields(fields)
|
|
76
62
|
});
|
|
77
63
|
return parser.parse(data);
|
|
78
64
|
}
|
|
79
|
-
|
|
80
65
|
function table(data) {
|
|
81
66
|
const Table = require('cli-table');
|
|
82
|
-
|
|
83
67
|
const fields = Object.keys(data[0]);
|
|
84
68
|
const dataTable = new Table({
|
|
85
69
|
head: formatFields(fields),
|
|
@@ -94,110 +78,85 @@ function table(data) {
|
|
|
94
78
|
});
|
|
95
79
|
return dataTable.toString();
|
|
96
80
|
}
|
|
97
|
-
|
|
98
81
|
function formatFields(fields) {
|
|
99
82
|
return fields.map(field => {
|
|
100
83
|
return field.split(/(?=[A-Z])/).join(' ').toLowerCase();
|
|
101
84
|
});
|
|
102
85
|
}
|
|
103
|
-
|
|
104
86
|
function keyValue(values) {
|
|
105
87
|
const lines = [];
|
|
106
88
|
const pairs = values.length > 0;
|
|
107
89
|
pairs ? lines.push('===================================') : '';
|
|
108
|
-
|
|
109
90
|
for (const {
|
|
110
91
|
key,
|
|
111
92
|
value
|
|
112
93
|
} of values) {
|
|
113
94
|
let formattedValue = value;
|
|
114
|
-
|
|
115
95
|
switch (key.toLowerCase()) {
|
|
116
96
|
case 'environment':
|
|
117
97
|
formattedValue = formatEnvironment(value);
|
|
118
98
|
break;
|
|
119
99
|
}
|
|
120
|
-
|
|
121
100
|
lines.push(`+ ${key}: ${formattedValue}`);
|
|
122
101
|
}
|
|
123
|
-
|
|
124
102
|
lines.push('===================================');
|
|
125
103
|
return lines.join('\n');
|
|
126
104
|
}
|
|
127
|
-
|
|
128
105
|
function requoteArgs(args) {
|
|
129
106
|
return args.map(arg => {
|
|
130
107
|
if (arg.includes('--') && arg.includes('=') && arg.includes(' ')) {
|
|
131
108
|
return arg.replace(/^--(.*)=(.*)$/, '--$1="$2"');
|
|
132
109
|
}
|
|
133
|
-
|
|
134
110
|
if (arg.includes(' ')) {
|
|
135
111
|
return `"${arg}"`;
|
|
136
112
|
}
|
|
137
|
-
|
|
138
113
|
return arg;
|
|
139
114
|
});
|
|
140
115
|
}
|
|
141
|
-
|
|
142
116
|
function capitalize(str) {
|
|
143
117
|
if (typeof str !== 'string' || !str.length) {
|
|
144
118
|
return '';
|
|
145
119
|
}
|
|
146
|
-
|
|
147
120
|
return str[0].toUpperCase() + str.slice(1);
|
|
148
121
|
}
|
|
149
|
-
|
|
150
122
|
const RUNNING_SPRITE_GLYPHS = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
151
123
|
exports.RUNNING_SPRITE_GLYPHS = RUNNING_SPRITE_GLYPHS;
|
|
152
|
-
|
|
153
124
|
class RunningSprite {
|
|
154
125
|
constructor() {
|
|
155
126
|
this.count = 0;
|
|
156
127
|
}
|
|
157
|
-
|
|
158
128
|
next() {
|
|
159
129
|
if (++this.count >= RUNNING_SPRITE_GLYPHS.length) {
|
|
160
130
|
this.count = 0;
|
|
161
131
|
}
|
|
162
132
|
}
|
|
163
|
-
|
|
164
133
|
toString() {
|
|
165
134
|
const glyph = RUNNING_SPRITE_GLYPHS[this.count];
|
|
166
135
|
this.next(); // TODO: throttle
|
|
167
|
-
|
|
168
136
|
return glyph;
|
|
169
137
|
}
|
|
170
|
-
|
|
171
138
|
}
|
|
172
|
-
|
|
173
139
|
exports.RunningSprite = RunningSprite;
|
|
174
|
-
|
|
175
140
|
function getGlyphForStatus(status, runningSprite) {
|
|
176
141
|
switch (status) {
|
|
177
142
|
default:
|
|
178
143
|
return '';
|
|
179
|
-
|
|
180
144
|
case 'pending':
|
|
181
145
|
return '○';
|
|
182
|
-
|
|
183
146
|
case 'running':
|
|
184
147
|
return _chalk.default.blueBright(runningSprite);
|
|
185
|
-
|
|
186
148
|
case 'success':
|
|
187
149
|
return _chalk.default.green('✓');
|
|
188
|
-
|
|
189
150
|
case 'failed':
|
|
190
151
|
return _chalk.default.red('✕');
|
|
191
|
-
|
|
192
152
|
case 'unknown':
|
|
193
153
|
return _chalk.default.yellow('✕');
|
|
194
|
-
|
|
195
154
|
case 'skipped':
|
|
196
155
|
return _chalk.default.green('-');
|
|
197
156
|
}
|
|
198
|
-
}
|
|
199
|
-
|
|
157
|
+
}
|
|
200
158
|
|
|
159
|
+
// Format Search and Replace values to output
|
|
201
160
|
const formatSearchReplaceValues = (values, message) => {
|
|
202
161
|
// Convert single pair S-R values to arrays
|
|
203
162
|
const searchReplaceValues = typeof values === 'string' ? [values] : values;
|
|
@@ -209,5 +168,4 @@ const formatSearchReplaceValues = (values, message) => {
|
|
|
209
168
|
});
|
|
210
169
|
return formattedOutput;
|
|
211
170
|
};
|
|
212
|
-
|
|
213
171
|
exports.formatSearchReplaceValues = formatSearchReplaceValues;
|
package/dist/lib/cli/progress.js
CHANGED
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ProgressTracker = void 0;
|
|
7
|
-
|
|
8
7
|
var _singleLineLog = require("single-line-log");
|
|
9
|
-
|
|
10
8
|
var _format = require("./format");
|
|
11
|
-
|
|
12
9
|
/** @format */
|
|
13
10
|
|
|
14
11
|
/**
|
|
@@ -18,15 +15,18 @@ var _format = require("./format");
|
|
|
18
15
|
/**
|
|
19
16
|
* Internal dependencies
|
|
20
17
|
*/
|
|
21
|
-
const PRINT_INTERVAL = process.env.DEBUG ? 5000 : 200; // How often the report is printed. Mainly affects the "spinner" animation.
|
|
22
18
|
|
|
19
|
+
const PRINT_INTERVAL = process.env.DEBUG ? 5000 : 200; // How often the report is printed. Mainly affects the "spinner" animation.
|
|
23
20
|
const COMPLETED_STEP_SLUGS = ['success', 'skipped'];
|
|
24
|
-
|
|
25
21
|
class ProgressTracker {
|
|
26
22
|
// Track the state of each step
|
|
23
|
+
|
|
27
24
|
// Spinnerz go brrrr
|
|
25
|
+
|
|
28
26
|
// This gets printed before the step status
|
|
27
|
+
|
|
29
28
|
// This gets printed after the step status
|
|
29
|
+
|
|
30
30
|
constructor(steps) {
|
|
31
31
|
this.runningSprite = new _format.RunningSprite();
|
|
32
32
|
this.hasFailure = false;
|
|
@@ -35,11 +35,9 @@ class ProgressTracker {
|
|
|
35
35
|
this.prefix = '';
|
|
36
36
|
this.suffix = '';
|
|
37
37
|
}
|
|
38
|
-
|
|
39
38
|
getSteps() {
|
|
40
39
|
return new Map([...this.stepsFromCaller, ...this.stepsFromServer]);
|
|
41
40
|
}
|
|
42
|
-
|
|
43
41
|
mapSteps(steps) {
|
|
44
42
|
return steps.reduce((map, {
|
|
45
43
|
id,
|
|
@@ -54,19 +52,16 @@ class ProgressTracker {
|
|
|
54
52
|
return map;
|
|
55
53
|
}, new Map());
|
|
56
54
|
}
|
|
57
|
-
|
|
58
55
|
setUploadPercentage(percentage) {
|
|
59
56
|
const uploadStep = this.stepsFromCaller.get('upload');
|
|
60
|
-
|
|
61
57
|
if (!uploadStep) {
|
|
62
58
|
return;
|
|
63
59
|
}
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
this.stepsFromCaller.set('upload', {
|
|
61
|
+
...uploadStep,
|
|
66
62
|
percentage
|
|
67
63
|
});
|
|
68
64
|
}
|
|
69
|
-
|
|
70
65
|
setStepsFromServer(steps) {
|
|
71
66
|
const formattedSteps = steps.map(({
|
|
72
67
|
name,
|
|
@@ -76,106 +71,86 @@ class ProgressTracker {
|
|
|
76
71
|
name,
|
|
77
72
|
status
|
|
78
73
|
}));
|
|
79
|
-
|
|
80
74
|
if (!steps.some(({
|
|
81
75
|
status
|
|
82
76
|
}) => status === 'running')) {
|
|
83
77
|
const firstPendingStepIndex = steps.findIndex(({
|
|
84
78
|
status
|
|
85
79
|
}) => status === 'pending');
|
|
86
|
-
|
|
87
80
|
if (firstPendingStepIndex !== -1) {
|
|
88
81
|
// "Promote" the first "pending" to "running"
|
|
89
82
|
formattedSteps[firstPendingStepIndex].status = 'running';
|
|
90
83
|
}
|
|
91
84
|
}
|
|
92
|
-
|
|
93
85
|
this.stepsFromServer = this.mapSteps(formattedSteps);
|
|
94
86
|
}
|
|
95
|
-
|
|
96
87
|
getNextStep() {
|
|
97
88
|
if (this.allStepsSucceeded()) {
|
|
98
89
|
return undefined;
|
|
99
90
|
}
|
|
100
|
-
|
|
101
91
|
const steps = [...this.getSteps().values()];
|
|
102
92
|
return steps.find(({
|
|
103
93
|
status
|
|
104
94
|
}) => status === 'pending');
|
|
105
95
|
}
|
|
106
|
-
|
|
107
96
|
stepRunning(stepId) {
|
|
108
97
|
this.setStatusForStepId(stepId, 'running');
|
|
109
98
|
}
|
|
110
|
-
|
|
111
99
|
stepFailed(stepId) {
|
|
112
100
|
this.setStatusForStepId(stepId, 'failed');
|
|
113
101
|
}
|
|
114
|
-
|
|
115
102
|
stepSkipped(stepId) {
|
|
116
103
|
this.setStatusForStepId(stepId, 'skipped');
|
|
117
104
|
}
|
|
118
|
-
|
|
119
105
|
stepSuccess(stepId) {
|
|
120
|
-
this.setStatusForStepId(stepId, 'success');
|
|
121
|
-
|
|
106
|
+
this.setStatusForStepId(stepId, 'success');
|
|
107
|
+
// The stepSuccess helper automatically sets the next step to "running"
|
|
122
108
|
const nextStep = this.getNextStep();
|
|
123
|
-
|
|
124
109
|
if (nextStep) {
|
|
125
110
|
this.stepRunning(nextStep.id);
|
|
126
111
|
return;
|
|
127
112
|
}
|
|
128
113
|
}
|
|
129
|
-
|
|
130
114
|
allStepsSucceeded() {
|
|
131
115
|
return ![...this.getSteps().values()].some(({
|
|
132
116
|
status
|
|
133
117
|
}) => status !== 'success');
|
|
134
118
|
}
|
|
135
|
-
|
|
136
119
|
setStatusForStepId(stepId, status) {
|
|
137
120
|
const step = this.stepsFromCaller.get(stepId);
|
|
138
|
-
|
|
139
121
|
if (!step) {
|
|
140
122
|
// Only allowed to update existing steps with this method
|
|
141
123
|
throw new Error(`Step name ${stepId} is not valid.`);
|
|
142
124
|
}
|
|
143
|
-
|
|
144
125
|
if (COMPLETED_STEP_SLUGS.includes(step.status)) {
|
|
145
126
|
throw new Error(`Step name ${stepId} is already completed.`);
|
|
146
127
|
}
|
|
147
|
-
|
|
148
128
|
if (status === 'failed') {
|
|
149
129
|
this.hasFailure = true;
|
|
150
130
|
}
|
|
151
|
-
|
|
152
|
-
|
|
131
|
+
this.stepsFromCaller.set(stepId, {
|
|
132
|
+
...step,
|
|
153
133
|
status
|
|
154
134
|
});
|
|
155
135
|
}
|
|
156
|
-
|
|
157
136
|
startPrinting(prePrintCallback = () => {}) {
|
|
158
137
|
this.printInterval = setInterval(() => {
|
|
159
138
|
prePrintCallback();
|
|
160
139
|
this.print();
|
|
161
140
|
}, PRINT_INTERVAL);
|
|
162
141
|
}
|
|
163
|
-
|
|
164
142
|
stopPrinting() {
|
|
165
143
|
if (this.printInterval) {
|
|
166
144
|
clearInterval(this.printInterval);
|
|
167
145
|
}
|
|
168
146
|
}
|
|
169
|
-
|
|
170
147
|
print({
|
|
171
148
|
clearAfter = false
|
|
172
149
|
} = {}) {
|
|
173
150
|
if (!this.hasPrinted) {
|
|
174
151
|
this.hasPrinted = true;
|
|
175
|
-
|
|
176
152
|
_singleLineLog.stdout.clear();
|
|
177
153
|
}
|
|
178
|
-
|
|
179
154
|
const stepValues = [...this.getSteps().values()];
|
|
180
155
|
const logs = stepValues.reduce((accumulator, {
|
|
181
156
|
name,
|
|
@@ -185,24 +160,20 @@ class ProgressTracker {
|
|
|
185
160
|
}) => {
|
|
186
161
|
const statusIcon = (0, _format.getGlyphForStatus)(status, this.runningSprite);
|
|
187
162
|
let suffix = '';
|
|
188
|
-
|
|
189
163
|
if (id === 'upload') {
|
|
190
164
|
if (status === 'running' && percentage) {
|
|
191
165
|
suffix = percentage;
|
|
192
166
|
}
|
|
193
167
|
}
|
|
194
|
-
|
|
195
168
|
return `${accumulator}${statusIcon} ${name} ${suffix}\n`;
|
|
196
|
-
}, '');
|
|
169
|
+
}, '');
|
|
197
170
|
|
|
171
|
+
// Output the logs
|
|
198
172
|
(0, _singleLineLog.stdout)(`${this.prefix || ''}${logs}${this.suffix || ''}`);
|
|
199
|
-
|
|
200
173
|
if (clearAfter) {
|
|
201
174
|
// Break out of the "Single log line" buffer
|
|
202
175
|
_singleLineLog.stdout.clear();
|
|
203
176
|
}
|
|
204
177
|
}
|
|
205
|
-
|
|
206
178
|
}
|
|
207
|
-
|
|
208
179
|
exports.ProgressTracker = ProgressTracker;
|
package/dist/lib/cli/prompt.js
CHANGED
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.confirm = confirm;
|
|
7
|
-
|
|
8
7
|
var _enquirer = require("enquirer");
|
|
9
|
-
|
|
10
8
|
var _format = require("./format");
|
|
11
9
|
|
|
12
10
|
/**
|
|
@@ -16,13 +14,12 @@ var _format = require("./format");
|
|
|
16
14
|
/**
|
|
17
15
|
* Internal dependencies
|
|
18
16
|
*/
|
|
19
|
-
|
|
20
17
|
/* eslint-disable no-duplicate-imports */
|
|
21
18
|
|
|
22
19
|
/* eslint-enable no-duplicate-imports */
|
|
20
|
+
|
|
23
21
|
async function confirm(values, message, skipPrompt = false) {
|
|
24
22
|
console.log((0, _format.keyValue)(values));
|
|
25
|
-
|
|
26
23
|
if (!skipPrompt) {
|
|
27
24
|
const answer = await (0, _enquirer.prompt)({
|
|
28
25
|
type: 'confirm',
|
|
@@ -32,6 +29,5 @@ async function confirm(values, message, skipPrompt = false) {
|
|
|
32
29
|
});
|
|
33
30
|
return answer.confirm;
|
|
34
31
|
}
|
|
35
|
-
|
|
36
32
|
return true;
|
|
37
33
|
}
|
package/dist/lib/cli/repo.js
CHANGED
|
@@ -4,72 +4,59 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = getRepoFromGitConfig;
|
|
7
|
-
|
|
8
7
|
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
-
|
|
10
8
|
var _path = _interopRequireDefault(require("path"));
|
|
11
|
-
|
|
12
9
|
var _ini = _interopRequireDefault(require("ini"));
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
11
|
|
|
16
12
|
/**
|
|
17
13
|
* External dependencies
|
|
18
14
|
*/
|
|
15
|
+
|
|
19
16
|
async function getRepoFromGitConfig() {
|
|
20
17
|
const file = await find();
|
|
21
|
-
|
|
22
18
|
if (!file.length) {
|
|
23
19
|
return '';
|
|
24
20
|
}
|
|
21
|
+
const config = _ini.default.parse(_fs.default.readFileSync(file, 'utf-8'));
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
// Find the first 'wpcomvip' remote
|
|
29
24
|
for (const key in config) {
|
|
30
25
|
if ('remote' !== key.substring(0, 6)) {
|
|
31
26
|
continue;
|
|
32
27
|
}
|
|
33
|
-
|
|
34
28
|
if (!config[key].url) {
|
|
35
29
|
continue;
|
|
36
30
|
}
|
|
37
|
-
|
|
38
31
|
if (0 > config[key].url.indexOf('wpcomvip/')) {
|
|
39
32
|
continue;
|
|
40
33
|
}
|
|
41
|
-
|
|
42
34
|
let repo = config[key].url;
|
|
43
35
|
repo = repo.replace(/.git$/, '');
|
|
44
36
|
repo = repo.replace('https://github.com/', '');
|
|
45
37
|
repo = repo.replace('git@github.com:', '');
|
|
46
38
|
return repo;
|
|
47
39
|
}
|
|
48
|
-
|
|
49
40
|
return;
|
|
50
41
|
}
|
|
51
|
-
|
|
52
42
|
async function find(dir) {
|
|
53
43
|
dir = dir || process.cwd();
|
|
54
44
|
const test = dir + '/.git/config';
|
|
55
|
-
|
|
56
45
|
if (await exists(test)) {
|
|
57
46
|
return test;
|
|
58
|
-
}
|
|
59
|
-
|
|
47
|
+
}
|
|
60
48
|
|
|
49
|
+
// Bail if we went all the way and didn't find it
|
|
61
50
|
const directory = _path.default.parse(dir);
|
|
62
|
-
|
|
63
51
|
if (directory.dir === directory.root) {
|
|
64
52
|
return '';
|
|
65
|
-
}
|
|
66
|
-
|
|
53
|
+
}
|
|
67
54
|
|
|
55
|
+
// cd ..
|
|
68
56
|
const up = dir.split(_path.default.sep);
|
|
69
57
|
up.pop();
|
|
70
58
|
return find(up.join(_path.default.sep));
|
|
71
59
|
}
|
|
72
|
-
|
|
73
60
|
async function exists(file) {
|
|
74
61
|
return new Promise(resolve => {
|
|
75
62
|
_fs.default.access(file, _fs.default.constants.F_OK, err => resolve(!err));
|