@percy/cli-build 1.0.0-beta.71 → 1.0.0-beta.72
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 +30 -29
- package/dist/build.js +22 -0
- package/dist/finalize.js +47 -0
- package/dist/index.js +37 -12
- package/dist/wait.js +150 -0
- package/package.json +18 -26
- package/dist/commands/build/finalize.js +0 -77
- package/dist/commands/build/wait.js +0 -139
- package/oclif.manifest.json +0 -1
package/README.md
CHANGED
|
@@ -7,43 +7,44 @@ 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
|
-
|
|
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:
|
|
47
48
|
$ percy build:wait --build 2222222
|
|
48
49
|
$ percy build:wait --project org/project --commit HEAD
|
|
49
50
|
```
|
package/dist/build.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.build = void 0;
|
|
7
|
+
|
|
8
|
+
var _cliCommand = _interopRequireDefault(require("@percy/cli-command"));
|
|
9
|
+
|
|
10
|
+
var _finalize = _interopRequireDefault(require("./finalize"));
|
|
11
|
+
|
|
12
|
+
var _wait = _interopRequireDefault(require("./wait"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
const build = (0, _cliCommand.default)('build', {
|
|
17
|
+
description: 'Finalize and wait on Percy builds',
|
|
18
|
+
commands: [_finalize.default, _wait.default]
|
|
19
|
+
});
|
|
20
|
+
exports.build = build;
|
|
21
|
+
var _default = build;
|
|
22
|
+
exports.default = _default;
|
package/dist/finalize.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.finalize = exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _cliCommand = _interopRequireDefault(require("@percy/cli-command"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
const finalize = (0, _cliCommand.default)('finalize', {
|
|
13
|
+
description: 'Finalize parallel Percy builds',
|
|
14
|
+
percy: true
|
|
15
|
+
}, async ({
|
|
16
|
+
env,
|
|
17
|
+
percy,
|
|
18
|
+
log,
|
|
19
|
+
exit
|
|
20
|
+
}) => {
|
|
21
|
+
if (!percy) exit(0, 'Percy is disabled'); // automatically set parallel total to -1
|
|
22
|
+
|
|
23
|
+
env.PERCY_PARALLEL_TOTAL || (env.PERCY_PARALLEL_TOTAL = '-1'); // ensure that this command is not used for other parallel totals
|
|
24
|
+
|
|
25
|
+
if (env.PERCY_PARALLEL_TOTAL !== '-1') {
|
|
26
|
+
log.error('This command should only be used with PERCY_PARALLEL_TOTAL=-1');
|
|
27
|
+
log.error(`Current value is "${env.PERCY_PARALLEL_TOTAL}"`);
|
|
28
|
+
exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
log.info('Finalizing parallel build...'); // rely on the parallel nonce to cause the API to return the current running build for the nonce
|
|
32
|
+
|
|
33
|
+
let {
|
|
34
|
+
data: build
|
|
35
|
+
} = await percy.client.createBuild();
|
|
36
|
+
await percy.client.finalizeBuild(build.id, {
|
|
37
|
+
all: true
|
|
38
|
+
});
|
|
39
|
+
let {
|
|
40
|
+
'build-number': number,
|
|
41
|
+
'web-url': url
|
|
42
|
+
} = build.attributes;
|
|
43
|
+
log.info(`Finalized build #${number}: ${url}`);
|
|
44
|
+
});
|
|
45
|
+
exports.finalize = finalize;
|
|
46
|
+
var _default = finalize;
|
|
47
|
+
exports.default = _default;
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "build", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _build.build;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "default", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _build.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "finalize", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _finalize.finalize;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "wait", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _wait.wait;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
var _build = _interopRequireWildcard(require("./build"));
|
|
32
|
+
|
|
33
|
+
var _finalize = require("./finalize");
|
|
34
|
+
|
|
35
|
+
var _wait = require("./wait");
|
|
36
|
+
|
|
37
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
38
|
+
|
|
39
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
package/dist/wait.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.wait = exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _cliCommand = _interopRequireDefault(require("@percy/cli-command"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
const wait = (0, _cliCommand.default)('wait', {
|
|
13
|
+
description: 'Wait for a build to be finished',
|
|
14
|
+
flags: [{
|
|
15
|
+
name: 'build',
|
|
16
|
+
description: 'Build ID',
|
|
17
|
+
exclusive: ['project', 'commit'],
|
|
18
|
+
type: 'id',
|
|
19
|
+
short: 'b'
|
|
20
|
+
}, {
|
|
21
|
+
name: 'project',
|
|
22
|
+
description: 'Build project slug, requires \'--commit\'',
|
|
23
|
+
requires: ['commit'],
|
|
24
|
+
type: 'slug',
|
|
25
|
+
short: 'p'
|
|
26
|
+
}, {
|
|
27
|
+
name: 'commit',
|
|
28
|
+
description: 'Build commit sha, requires \'--project\'',
|
|
29
|
+
requires: ['project'],
|
|
30
|
+
type: 'sha',
|
|
31
|
+
short: 'c'
|
|
32
|
+
}, {
|
|
33
|
+
name: 'timeout',
|
|
34
|
+
description: 'Timeout before exiting without updates, defaults to 10 minutes',
|
|
35
|
+
type: 'ms',
|
|
36
|
+
parse: Number,
|
|
37
|
+
short: 't'
|
|
38
|
+
}, {
|
|
39
|
+
name: 'interval',
|
|
40
|
+
description: 'Interval at which to poll for updates, defaults to 1 second',
|
|
41
|
+
type: 'ms',
|
|
42
|
+
parse: Number,
|
|
43
|
+
short: 'i'
|
|
44
|
+
}, {
|
|
45
|
+
name: 'fail-on-changes',
|
|
46
|
+
description: 'Exit with an error when diffs are found',
|
|
47
|
+
short: 'f'
|
|
48
|
+
}],
|
|
49
|
+
examples: ['$0 --build 2222222', '$0 --project org/project --commit HEAD'],
|
|
50
|
+
percy: true
|
|
51
|
+
}, async function* ({
|
|
52
|
+
flags,
|
|
53
|
+
percy,
|
|
54
|
+
log,
|
|
55
|
+
exit
|
|
56
|
+
}) {
|
|
57
|
+
if (!percy) exit(0, 'Percy is disabled'); // do not wait directly on the promise as to not block the event loop
|
|
58
|
+
|
|
59
|
+
let waiting = percy.client.waitForBuild(flags, build => {
|
|
60
|
+
logProgress(build, log);
|
|
61
|
+
if (isFailing(build, flags)) exit(1);
|
|
62
|
+
}); // wait between event loops to allow process termination
|
|
63
|
+
|
|
64
|
+
let handleDone = () => waiting.done = true;
|
|
65
|
+
|
|
66
|
+
waiting.then(handleDone, handleDone);
|
|
67
|
+
|
|
68
|
+
while (!waiting.done) {
|
|
69
|
+
yield new Promise(r => setImmediate(r));
|
|
70
|
+
} // bubble errors
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
yield waiting;
|
|
74
|
+
}); // Log build progress
|
|
75
|
+
|
|
76
|
+
exports.wait = wait;
|
|
77
|
+
|
|
78
|
+
function logProgress({
|
|
79
|
+
attributes: {
|
|
80
|
+
state,
|
|
81
|
+
'web-url': url,
|
|
82
|
+
'build-number': number,
|
|
83
|
+
'failure-reason': failReason,
|
|
84
|
+
'failure-details': failDetails,
|
|
85
|
+
'total-snapshots': count,
|
|
86
|
+
'total-comparisons': total,
|
|
87
|
+
'total-comparisons-diff': diffs,
|
|
88
|
+
'total-comparisons-finished': finished
|
|
89
|
+
}
|
|
90
|
+
}, log) {
|
|
91
|
+
switch (state) {
|
|
92
|
+
case 'pending':
|
|
93
|
+
return log.progress('Recieving snapshots...');
|
|
94
|
+
|
|
95
|
+
case 'processing':
|
|
96
|
+
return log.progress(`Processing ${count} snapshots - ` + (finished === total ? 'finishing up...' : `${finished} of ${total} comparisons finished...`));
|
|
97
|
+
|
|
98
|
+
case 'finished':
|
|
99
|
+
log.info(`Build #${number} finished! ${url}`);
|
|
100
|
+
return log.info(`Found ${diffs} changes`);
|
|
101
|
+
|
|
102
|
+
case 'failed':
|
|
103
|
+
log.error(`Build #${number} failed! ${url}`);
|
|
104
|
+
return log.error(failureMessage(failReason, failDetails));
|
|
105
|
+
|
|
106
|
+
default:
|
|
107
|
+
return log.error(`Build #${number} is ${state}. ${url}`);
|
|
108
|
+
}
|
|
109
|
+
} // Create failure messages
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
function failureMessage(type, {
|
|
113
|
+
missing_parallel_builds: missingParallel,
|
|
114
|
+
parallel_builds_received: parallelCount,
|
|
115
|
+
parallel_builds_expected: parallelTotal
|
|
116
|
+
} = {}) {
|
|
117
|
+
switch (type) {
|
|
118
|
+
case 'render_timeout':
|
|
119
|
+
return 'Some snapshots in this build took too long ' + 'to render even after multiple retries.';
|
|
120
|
+
|
|
121
|
+
case 'no_snapshots':
|
|
122
|
+
return 'No snapshots were uploaded to this build.';
|
|
123
|
+
|
|
124
|
+
case 'missing_finalize':
|
|
125
|
+
return 'Failed to correctly finalize.';
|
|
126
|
+
|
|
127
|
+
case 'missing_resources':
|
|
128
|
+
return missingParallel ? `Only ${parallelCount} of ${parallelTotal} parallel builds were received.` : 'Some build or snapshot resources failed to correctly upload.';
|
|
129
|
+
|
|
130
|
+
default:
|
|
131
|
+
return `Error: ${type}`;
|
|
132
|
+
}
|
|
133
|
+
} // Return true or false if a build is considered failing or not
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
function isFailing({
|
|
137
|
+
attributes: {
|
|
138
|
+
state,
|
|
139
|
+
'total-comparisons-diff': diffs
|
|
140
|
+
}
|
|
141
|
+
}, {
|
|
142
|
+
failOnChanges
|
|
143
|
+
}) {
|
|
144
|
+
// not pending and not processing
|
|
145
|
+
return state !== 'pending' && state !== 'processing' && ( // not finished or finished with diffs
|
|
146
|
+
state !== 'finished' || failOnChanges && !!diffs);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
var _default = wait;
|
|
150
|
+
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/cli-build",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.72",
|
|
4
4
|
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/percy/cli",
|
|
8
|
+
"directory": "packages/cli-build"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
5
13
|
"main": "dist/index.js",
|
|
6
14
|
"files": [
|
|
7
|
-
"dist"
|
|
8
|
-
"oclif.manifest.json"
|
|
15
|
+
"dist"
|
|
9
16
|
],
|
|
10
17
|
"engines": {
|
|
11
18
|
"node": ">=12"
|
|
@@ -13,33 +20,18 @@
|
|
|
13
20
|
"scripts": {
|
|
14
21
|
"build": "node ../../scripts/build",
|
|
15
22
|
"lint": "eslint --ignore-path ../../.gitignore .",
|
|
16
|
-
"
|
|
17
|
-
"readme": "oclif-dev readme",
|
|
23
|
+
"readme": "percy-cli-readme",
|
|
18
24
|
"test": "node ../../scripts/test",
|
|
19
25
|
"test:coverage": "yarn test --coverage"
|
|
20
26
|
},
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"bin": "percy",
|
|
26
|
-
"commands": "./dist/commands",
|
|
27
|
-
"topics": {
|
|
28
|
-
"build": {
|
|
29
|
-
"description": "interact with Percy builds"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
27
|
+
"@percy/cli": {
|
|
28
|
+
"commands": [
|
|
29
|
+
"./dist/build.js"
|
|
30
|
+
]
|
|
32
31
|
},
|
|
33
32
|
"dependencies": {
|
|
34
|
-
"@percy/cli-command": "1.0.0-beta.
|
|
35
|
-
"@percy/
|
|
36
|
-
"@percy/env": "1.0.0-beta.71",
|
|
37
|
-
"@percy/logger": "1.0.0-beta.71"
|
|
38
|
-
},
|
|
39
|
-
"repository": {
|
|
40
|
-
"type": "git",
|
|
41
|
-
"url": "https://github.com/percy/cli",
|
|
42
|
-
"directory": "packages/cli-build"
|
|
33
|
+
"@percy/cli-command": "1.0.0-beta.72",
|
|
34
|
+
"@percy/logger": "1.0.0-beta.72"
|
|
43
35
|
},
|
|
44
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "6219287e18a0cacb609d0c2696a5785abc9009b9"
|
|
45
37
|
}
|
|
@@ -1,77 +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
|
-
var _package = _interopRequireDefault(require("../../../package.json"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
-
|
|
20
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
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 Finalize extends _cliCommand.default {
|
|
25
|
-
constructor(...args) {
|
|
26
|
-
super(...args);
|
|
27
|
-
|
|
28
|
-
_defineProperty(this, "log", (0, _logger.default)('cli:build:finalize'));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async run() {
|
|
32
|
-
if (!this.isPercyEnabled()) {
|
|
33
|
-
this.log.info('Percy is disabled');
|
|
34
|
-
return;
|
|
35
|
-
} // automatically set parallel total to -1
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (!process.env.PERCY_PARALLEL_TOTAL) {
|
|
39
|
-
process.env.PERCY_PARALLEL_TOTAL = '-1';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
let client = new _client.default({
|
|
43
|
-
clientInfo: `${_package.default.name}/${_package.default.version}`,
|
|
44
|
-
environmentInfo: `node/${process.version}`
|
|
45
|
-
}); // ensure that this command is not used for other parallel totals
|
|
46
|
-
|
|
47
|
-
if (client.env.parallel.total !== -1) {
|
|
48
|
-
this.log.error('This command should only be used with PERCY_PARALLEL_TOTAL=-1');
|
|
49
|
-
this.log.error(`Current value is "${client.env.parallel.total}"`);
|
|
50
|
-
return this.exit(1);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
this.log.info('Finalizing parallel build...'); // rely on the parallel nonce to cause the API to return the current running build for the nonce
|
|
54
|
-
|
|
55
|
-
let {
|
|
56
|
-
data: build
|
|
57
|
-
} = await client.createBuild();
|
|
58
|
-
let {
|
|
59
|
-
'build-number': number,
|
|
60
|
-
'web-url': url
|
|
61
|
-
} = build.attributes;
|
|
62
|
-
await client.finalizeBuild(build.id, {
|
|
63
|
-
all: true
|
|
64
|
-
});
|
|
65
|
-
this.log.info(`Finalized build #${number}: ${url}`);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
exports.Finalize = Finalize;
|
|
71
|
-
|
|
72
|
-
_defineProperty(Finalize, "description", 'Finalize parallel Percy builds where PERCY_PARALLEL_TOTAL=-1');
|
|
73
|
-
|
|
74
|
-
_defineProperty(Finalize, "flags", { ..._cliCommand.flags.logging
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
_defineProperty(Finalize, "examples", ['$ percy build:finalize']);
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Wait = 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
|
-
var _package = _interopRequireDefault(require("../../../package.json"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
-
|
|
20
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
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
|
-
constructor(...args) {
|
|
26
|
-
super(...args);
|
|
27
|
-
|
|
28
|
-
_defineProperty(this, "log", (0, _logger.default)('cli:build:wait'));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async run() {
|
|
32
|
-
if (!this.isPercyEnabled()) {
|
|
33
|
-
return this.log.info('Percy is disabled');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
await new _client.default({
|
|
37
|
-
clientInfo: `${_package.default.name}/${_package.default.version}`,
|
|
38
|
-
environmentInfo: `node/${process.version}`
|
|
39
|
-
}).waitForBuild(this.flags, data => {
|
|
40
|
-
this.status(data);
|
|
41
|
-
});
|
|
42
|
-
} // Log build status and maybe exit when failed
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
status({
|
|
46
|
-
attributes: {
|
|
47
|
-
state,
|
|
48
|
-
'web-url': url,
|
|
49
|
-
'build-number': number,
|
|
50
|
-
'failure-reason': failReason,
|
|
51
|
-
'failure-details': failDetails,
|
|
52
|
-
'total-snapshots': count,
|
|
53
|
-
'total-comparisons': total,
|
|
54
|
-
'total-comparisons-diff': diffs,
|
|
55
|
-
'total-comparisons-finished': finished
|
|
56
|
-
}
|
|
57
|
-
}) {
|
|
58
|
-
switch (state) {
|
|
59
|
-
case 'pending':
|
|
60
|
-
return this.log.progress('Recieving snapshots...');
|
|
61
|
-
|
|
62
|
-
case 'processing':
|
|
63
|
-
return this.log.progress(`Processing ${count} snapshots - ` + (finished === total ? 'finishing up...' : `${finished} of ${total} comparisons finished...`));
|
|
64
|
-
|
|
65
|
-
case 'finished':
|
|
66
|
-
this.log.info(`Build #${number} finished! ${url}`);
|
|
67
|
-
this.log.info(`Found ${diffs} changes`);
|
|
68
|
-
return this.flags['fail-on-changes'] && diffs > 0 && this.exit(1);
|
|
69
|
-
|
|
70
|
-
case 'failed':
|
|
71
|
-
this.log.error(`Build #${number} failed! ${url}`);
|
|
72
|
-
this.log.error(this.failure(failReason, failDetails));
|
|
73
|
-
return this.exit(1);
|
|
74
|
-
|
|
75
|
-
default:
|
|
76
|
-
this.log.error(`Build #${number} is ${state}. ${url}`);
|
|
77
|
-
return this.exit(1);
|
|
78
|
-
}
|
|
79
|
-
} // Create failure messages
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
failure(type, details) {
|
|
83
|
-
switch (type) {
|
|
84
|
-
case 'render_timeout':
|
|
85
|
-
return 'Some snapshots in this build took too long to render even ' + 'after multiple retries.';
|
|
86
|
-
|
|
87
|
-
case 'no_snapshots':
|
|
88
|
-
return 'No snapshots were uploaded to this build.';
|
|
89
|
-
|
|
90
|
-
case 'missing_finalize':
|
|
91
|
-
return 'Failed to correctly finalize.';
|
|
92
|
-
|
|
93
|
-
case 'missing_resources':
|
|
94
|
-
// eslint-disable-next-line camelcase
|
|
95
|
-
return details !== null && details !== 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.';
|
|
96
|
-
|
|
97
|
-
default:
|
|
98
|
-
return `Error: ${type}`;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
exports.Wait = Wait;
|
|
105
|
-
|
|
106
|
-
_defineProperty(Wait, "description", 'Wait for a build to be finished. Requires a full access PERCY_TOKEN');
|
|
107
|
-
|
|
108
|
-
_defineProperty(Wait, "flags", { ..._cliCommand.flags.logging,
|
|
109
|
-
build: _cliCommand.flags.string({
|
|
110
|
-
char: 'b',
|
|
111
|
-
description: 'build id',
|
|
112
|
-
exclusive: ['project', 'commit']
|
|
113
|
-
}),
|
|
114
|
-
project: _cliCommand.flags.string({
|
|
115
|
-
char: 'p',
|
|
116
|
-
description: "build's project slug, required with --commit",
|
|
117
|
-
inclusive: ['commit']
|
|
118
|
-
}),
|
|
119
|
-
commit: _cliCommand.flags.string({
|
|
120
|
-
char: 'c',
|
|
121
|
-
description: "build's commit sha for a project",
|
|
122
|
-
inclusive: ['project']
|
|
123
|
-
}),
|
|
124
|
-
timeout: _cliCommand.flags.integer({
|
|
125
|
-
char: 't',
|
|
126
|
-
description: ['timeout, in milliseconds, to exit when there are no updates, ', 'defaults to 10 minutes'].join('')
|
|
127
|
-
}),
|
|
128
|
-
interval: _cliCommand.flags.integer({
|
|
129
|
-
char: 'i',
|
|
130
|
-
description: ['interval, in milliseconds, at which to poll for updates, ', 'defaults to 1000'].join('')
|
|
131
|
-
}),
|
|
132
|
-
'fail-on-changes': _cliCommand.flags.boolean({
|
|
133
|
-
char: 'f',
|
|
134
|
-
default: false,
|
|
135
|
-
description: 'exits with an error when diffs are found in snapshots'
|
|
136
|
-
})
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
_defineProperty(Wait, "examples", ['$ percy build:wait --build 2222222', '$ percy build:wait --project org/project --commit HEAD']);
|
package/oclif.manifest.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":"1.0.0-beta.71","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 2222222","$ percy build:wait --project org/project --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":[]}}}
|