@percy/cli-build 1.0.0-beta.76 → 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/package.json +10 -9
- package/dist/build.js +0 -22
- package/dist/finalize.js +0 -47
- package/dist/index.js +0 -39
- package/dist/wait.js +0 -150
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/cli-build",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,13 +10,15 @@
|
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
|
-
"main": "dist/index.js",
|
|
14
|
-
"files": [
|
|
15
|
-
"dist"
|
|
16
|
-
],
|
|
17
13
|
"engines": {
|
|
18
|
-
"node": ">=
|
|
14
|
+
"node": ">=14"
|
|
19
15
|
},
|
|
16
|
+
"files": [
|
|
17
|
+
"./dist"
|
|
18
|
+
],
|
|
19
|
+
"main": "./dist/index.js",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"exports": "./dist/index.js",
|
|
20
22
|
"scripts": {
|
|
21
23
|
"build": "node ../../scripts/build",
|
|
22
24
|
"lint": "eslint --ignore-path ../../.gitignore .",
|
|
@@ -30,8 +32,7 @@
|
|
|
30
32
|
]
|
|
31
33
|
},
|
|
32
34
|
"dependencies": {
|
|
33
|
-
"@percy/cli-command": "1.0.0
|
|
34
|
-
"@percy/logger": "1.0.0-beta.76"
|
|
35
|
+
"@percy/cli-command": "1.0.0"
|
|
35
36
|
},
|
|
36
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "6df509421a60144e4f9f5d59dc57a5675372a0b2"
|
|
37
38
|
}
|
package/dist/build.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
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
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
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;
|