@percy/cli-build 1.0.0-beta.9 → 1.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 +32 -31
- package/package.json +26 -28
- package/dist/commands/build/finalize.js +0 -60
- package/dist/commands/build/wait.js +0 -155
- package/dist/index.js +0 -8
- package/oclif.manifest.json +0 -1
package/README.md
CHANGED
|
@@ -7,44 +7,45 @@ Commands for interacting with Percy builds
|
|
|
7
7
|
* [`percy build:finalize`](#percy-buildfinalize)
|
|
8
8
|
* [`percy build:wait`](#percy-buildwait)
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
### `percy build:finalize`
|
|
11
11
|
|
|
12
|
-
Finalize parallel Percy builds
|
|
12
|
+
Finalize parallel Percy builds
|
|
13
13
|
|
|
14
14
|
```
|
|
15
|
-
|
|
16
|
-
$ percy build:finalize
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
--silent
|
|
22
|
-
|
|
23
|
-
EXAMPLE
|
|
24
|
-
$ percy build:finalize
|
|
15
|
+
Usage:
|
|
16
|
+
$ percy build:finalize [options]
|
|
17
|
+
|
|
18
|
+
Global options:
|
|
19
|
+
-v, --verbose Log everything
|
|
20
|
+
-q, --quiet Log errors only
|
|
21
|
+
-s, --silent Log nothing
|
|
22
|
+
-h, --help Display command help
|
|
25
23
|
```
|
|
26
24
|
|
|
27
|
-
|
|
25
|
+
### `percy build:wait`
|
|
28
26
|
|
|
29
|
-
Wait for a build to be finished
|
|
27
|
+
Wait for a build to be finished
|
|
30
28
|
|
|
31
29
|
```
|
|
32
|
-
|
|
33
|
-
$ percy build:wait
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
-b, --build
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
--
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
30
|
+
Usage:
|
|
31
|
+
$ percy build:wait [options]
|
|
32
|
+
|
|
33
|
+
Options:
|
|
34
|
+
-b, --build <id> Build ID
|
|
35
|
+
-p, --project <slug> Build project slug, requires '--commit'
|
|
36
|
+
-c, --commit <sha> Build commit sha, requires '--project'
|
|
37
|
+
-t, --timeout <ms> Timeout before exiting without updates, defaults to 10 minutes
|
|
38
|
+
-i, --interval <ms> Interval at which to poll for updates, defaults to 1 second
|
|
39
|
+
-f, --fail-on-changes Exit with an error when diffs are found
|
|
40
|
+
|
|
41
|
+
Global options:
|
|
42
|
+
-v, --verbose Log everything
|
|
43
|
+
-q, --quiet Log errors only
|
|
44
|
+
-s, --silent Log nothing
|
|
45
|
+
-h, --help Display command help
|
|
46
|
+
|
|
47
|
+
Examples:
|
|
48
|
+
$ percy build:wait --build 2222222
|
|
49
|
+
$ percy build:wait --project org/project --commit HEAD
|
|
49
50
|
```
|
|
50
51
|
<!-- commandsstop -->
|
package/package.json
CHANGED
|
@@ -1,40 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/cli-build",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
],
|
|
10
|
-
"scripts": {
|
|
11
|
-
"build": "babel --root-mode upward src --out-dir dist",
|
|
12
|
-
"lint": "eslint --ignore-path ../../.gitignore .",
|
|
13
|
-
"postbuild": "oclif-dev manifest",
|
|
14
|
-
"readme": "oclif-dev readme",
|
|
15
|
-
"test": "cross-env NODE_ENV=test mocha",
|
|
16
|
-
"test:coverage": "nyc yarn test"
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/percy/cli",
|
|
8
|
+
"directory": "packages/cli-build"
|
|
17
9
|
},
|
|
18
10
|
"publishConfig": {
|
|
19
11
|
"access": "public"
|
|
20
12
|
},
|
|
21
|
-
"
|
|
22
|
-
"
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=14"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"./dist"
|
|
18
|
+
],
|
|
19
|
+
"main": "./dist/index.js",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"exports": "./dist/index.js",
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "node ../../scripts/build",
|
|
24
|
+
"lint": "eslint --ignore-path ../../.gitignore .",
|
|
25
|
+
"readme": "percy-cli-readme",
|
|
26
|
+
"test": "node ../../scripts/test",
|
|
27
|
+
"test:coverage": "yarn test --coverage"
|
|
23
28
|
},
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"build": {
|
|
29
|
-
"description": "interact with Percy builds"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
29
|
+
"@percy/cli": {
|
|
30
|
+
"commands": [
|
|
31
|
+
"./dist/build.js"
|
|
32
|
+
]
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"@percy/cli-command": "
|
|
35
|
-
"@percy/client": "^1.0.0-beta.9",
|
|
36
|
-
"@percy/env": "^1.0.0-beta.9",
|
|
37
|
-
"@percy/logger": "^1.0.0-beta.9"
|
|
35
|
+
"@percy/cli-command": "1.0.0"
|
|
38
36
|
},
|
|
39
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "6df509421a60144e4f9f5d59dc57a5675372a0b2"
|
|
40
38
|
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Finalize = void 0;
|
|
7
|
-
|
|
8
|
-
var _cliCommand = _interopRequireWildcard(require("@percy/cli-command"));
|
|
9
|
-
|
|
10
|
-
var _client = _interopRequireDefault(require("@percy/client"));
|
|
11
|
-
|
|
12
|
-
var _logger = _interopRequireDefault(require("@percy/logger"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
17
|
-
|
|
18
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
|
|
20
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
-
|
|
22
|
-
class Finalize extends _cliCommand.default {
|
|
23
|
-
async run() {
|
|
24
|
-
if (!this.isPercyEnabled()) {
|
|
25
|
-
_logger.default.info('Percy is disabled');
|
|
26
|
-
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
let client = new _client.default();
|
|
31
|
-
|
|
32
|
-
if (client.env.parallel.total !== -1) {
|
|
33
|
-
_logger.default.error('This command should only be used with PERCY_PARALLEL_TOTAL=-1');
|
|
34
|
-
|
|
35
|
-
_logger.default.error(`Current value is "${client.env.parallel.total}"`);
|
|
36
|
-
|
|
37
|
-
return this.exit(1);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
_logger.default.info('Finalizing parallel build...');
|
|
41
|
-
|
|
42
|
-
await client.createBuild();
|
|
43
|
-
let build = client.build;
|
|
44
|
-
await client.finalizeBuild({
|
|
45
|
-
all: true
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
_logger.default.info(`Finalized build #${build.number}: ${build.url}`);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
exports.Finalize = Finalize;
|
|
54
|
-
|
|
55
|
-
_defineProperty(Finalize, "description", 'Finalize parallel Percy builds where PERCY_PARALLEL_TOTAL=-1');
|
|
56
|
-
|
|
57
|
-
_defineProperty(Finalize, "flags", { ..._cliCommand.flags.logging
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
_defineProperty(Finalize, "examples", ['$ percy build:finalize']);
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Wait = void 0;
|
|
7
|
-
|
|
8
|
-
var _readline = _interopRequireDefault(require("readline"));
|
|
9
|
-
|
|
10
|
-
var _cliCommand = _interopRequireWildcard(require("@percy/cli-command"));
|
|
11
|
-
|
|
12
|
-
var _client = _interopRequireDefault(require("@percy/client"));
|
|
13
|
-
|
|
14
|
-
var _logger = _interopRequireDefault(require("@percy/logger"));
|
|
15
|
-
|
|
16
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
17
|
-
|
|
18
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
|
-
|
|
24
|
-
class Wait extends _cliCommand.default {
|
|
25
|
-
async run() {
|
|
26
|
-
if (!this.isPercyEnabled()) {
|
|
27
|
-
_logger.default.info('Percy is disabled');
|
|
28
|
-
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
let client = new _client.default();
|
|
33
|
-
let result = await client.waitForBuild({
|
|
34
|
-
progress: this.progress,
|
|
35
|
-
...this.flags
|
|
36
|
-
});
|
|
37
|
-
return this.finish(result);
|
|
38
|
-
} // Log build progress
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
progress({
|
|
42
|
-
attributes: {
|
|
43
|
-
state,
|
|
44
|
-
'total-snapshots': count,
|
|
45
|
-
'total-comparisons': total,
|
|
46
|
-
'total-comparisons-finished': finished
|
|
47
|
-
}
|
|
48
|
-
}) {
|
|
49
|
-
// update the same line each time
|
|
50
|
-
_readline.default.cursorTo(process.stdout, 0); // still recieving snapshots
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (state === 'pending') {
|
|
54
|
-
process.stdout.write(_logger.default.formatter('Recieving snapshots...')); // need to clear the line before finishing
|
|
55
|
-
} else if (finished === total || state === 'finished') {
|
|
56
|
-
_readline.default.clearLine(process.stdout);
|
|
57
|
-
} // processing snapshots
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (state === 'processing') {
|
|
61
|
-
process.stdout.write(_logger.default.formatter(`Processing ${count} snapshots - ` + (finished === total ? 'finishing up...' : `${finished} of ${total} comparisons finished...`)));
|
|
62
|
-
}
|
|
63
|
-
} // Log build status
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
finish({
|
|
67
|
-
attributes: {
|
|
68
|
-
state,
|
|
69
|
-
'web-url': url,
|
|
70
|
-
'build-number': number,
|
|
71
|
-
'total-comparisons-diff': diffs,
|
|
72
|
-
'failure-reason': failReason,
|
|
73
|
-
'failure-details': failDetails
|
|
74
|
-
}
|
|
75
|
-
}) {
|
|
76
|
-
if (state === 'finished') {
|
|
77
|
-
_logger.default.info(`Build #${number} finished! ${url}`);
|
|
78
|
-
|
|
79
|
-
_logger.default.info(`Found ${diffs} changes`);
|
|
80
|
-
|
|
81
|
-
if (this.flags['fail-on-changes'] && diffs > 0) {
|
|
82
|
-
return this.exit(1);
|
|
83
|
-
}
|
|
84
|
-
} else if (state === 'failed') {
|
|
85
|
-
_logger.default.error(`Build #${number} failed! ${url}`);
|
|
86
|
-
|
|
87
|
-
_logger.default.error(this.failure(failReason, failDetails));
|
|
88
|
-
|
|
89
|
-
return this.exit(1);
|
|
90
|
-
} else {
|
|
91
|
-
_logger.default.error(`Build #${number} is ${state}. ${url}`);
|
|
92
|
-
|
|
93
|
-
return this.exit(1);
|
|
94
|
-
}
|
|
95
|
-
} // Create failure messages
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
failure(type, details) {
|
|
99
|
-
switch (type) {
|
|
100
|
-
case 'render_timeout':
|
|
101
|
-
return 'Some snapshots in this build took too long to render even ' + 'after multiple retries.';
|
|
102
|
-
|
|
103
|
-
case 'no_snapshots':
|
|
104
|
-
return 'No snapshots were uploaded to this build.';
|
|
105
|
-
|
|
106
|
-
case 'missing_finalize':
|
|
107
|
-
return 'Failed to correctly finalize.';
|
|
108
|
-
|
|
109
|
-
case 'missing_resources':
|
|
110
|
-
// eslint-disable-next-line camelcase
|
|
111
|
-
return (details === null || details === void 0 ? void 0 : details.missing_parallel_builds) ? `Only ${details.parallel_builds_received} of ` + `${details.parallel_builds_expected} parallelized build processes finished.` : 'Some build or snapshot resources failed to correctly upload.';
|
|
112
|
-
|
|
113
|
-
default:
|
|
114
|
-
return `Error: ${type}`;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
exports.Wait = Wait;
|
|
121
|
-
|
|
122
|
-
_defineProperty(Wait, "description", 'Wait for a build to be finished. Requires a full access PERCY_TOKEN');
|
|
123
|
-
|
|
124
|
-
_defineProperty(Wait, "flags", { ..._cliCommand.flags.logging,
|
|
125
|
-
build: _cliCommand.flags.string({
|
|
126
|
-
char: 'b',
|
|
127
|
-
description: 'build id',
|
|
128
|
-
exclusive: ['project', 'commit']
|
|
129
|
-
}),
|
|
130
|
-
project: _cliCommand.flags.string({
|
|
131
|
-
char: 'p',
|
|
132
|
-
description: "build's project slug, required with --commit",
|
|
133
|
-
inclusive: ['commit']
|
|
134
|
-
}),
|
|
135
|
-
commit: _cliCommand.flags.string({
|
|
136
|
-
char: 'c',
|
|
137
|
-
description: "build's commit sha for a project",
|
|
138
|
-
inclusive: ['project']
|
|
139
|
-
}),
|
|
140
|
-
timeout: _cliCommand.flags.integer({
|
|
141
|
-
char: 't',
|
|
142
|
-
description: ['timeout, in milliseconds, to exit when there are no updates, ', 'defaults to 10 minutes'].join('')
|
|
143
|
-
}),
|
|
144
|
-
interval: _cliCommand.flags.integer({
|
|
145
|
-
char: 'i',
|
|
146
|
-
description: ['interval, in milliseconds, at which to poll for updates, ', 'defaults to 1000'].join('')
|
|
147
|
-
}),
|
|
148
|
-
'fail-on-changes': _cliCommand.flags.boolean({
|
|
149
|
-
char: 'f',
|
|
150
|
-
default: false,
|
|
151
|
-
description: 'exits with an error when diffs are found in snapshots'
|
|
152
|
-
})
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
_defineProperty(Wait, "examples", ['$ percy build:wait --build 123', '$ percy build:wait --project test --commit HEAD']);
|
package/dist/index.js
DELETED
package/oclif.manifest.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":"1.0.0-beta.9","commands":{"build:finalize":{"id":"build:finalize","description":"Finalize parallel Percy builds where PERCY_PARALLEL_TOTAL=-1","pluginName":"@percy/cli-build","pluginType":"core","aliases":[],"examples":["$ percy build:finalize"],"flags":{"verbose":{"name":"verbose","type":"boolean","char":"v","description":"log everything","allowNo":false},"quiet":{"name":"quiet","type":"boolean","char":"q","description":"log errors only","allowNo":false},"silent":{"name":"silent","type":"boolean","description":"log nothing","allowNo":false}},"args":[]},"build:wait":{"id":"build:wait","description":"Wait for a build to be finished. Requires a full access PERCY_TOKEN","pluginName":"@percy/cli-build","pluginType":"core","aliases":[],"examples":["$ percy build:wait --build 123","$ percy build:wait --project test --commit HEAD"],"flags":{"verbose":{"name":"verbose","type":"boolean","char":"v","description":"log everything","allowNo":false},"quiet":{"name":"quiet","type":"boolean","char":"q","description":"log errors only","allowNo":false},"silent":{"name":"silent","type":"boolean","description":"log nothing","allowNo":false},"build":{"name":"build","type":"option","char":"b","description":"build id"},"project":{"name":"project","type":"option","char":"p","description":"build's project slug, required with --commit"},"commit":{"name":"commit","type":"option","char":"c","description":"build's commit sha for a project"},"timeout":{"name":"timeout","type":"option","char":"t","description":"timeout, in milliseconds, to exit when there are no updates, defaults to 10 minutes"},"interval":{"name":"interval","type":"option","char":"i","description":"interval, in milliseconds, at which to poll for updates, defaults to 1000"},"fail-on-changes":{"name":"fail-on-changes","type":"boolean","char":"f","description":"exits with an error when diffs are found in snapshots","allowNo":false}},"args":[]}}}
|