@percy/cli-exec 1.31.14-beta.0 → 1.31.14-beta.2
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/dist/exec.js +8 -1
- package/dist/index.js +2 -1
- package/dist/replay.js +46 -0
- package/package.json +6 -5
package/dist/exec.js
CHANGED
|
@@ -3,11 +3,12 @@ import logger from '@percy/logger';
|
|
|
3
3
|
import start from './start.js';
|
|
4
4
|
import stop from './stop.js';
|
|
5
5
|
import ping from './ping.js';
|
|
6
|
+
import replay from './replay.js';
|
|
6
7
|
import { waitForTimeout } from '@percy/client/utils';
|
|
7
8
|
export const exec = command('exec', {
|
|
8
9
|
description: 'Start and stop Percy around a supplied command',
|
|
9
10
|
usage: '[options] -- <command>',
|
|
10
|
-
commands: [start, stop, ping],
|
|
11
|
+
commands: [start, stop, ping, replay],
|
|
11
12
|
flags: [{
|
|
12
13
|
name: 'parallel',
|
|
13
14
|
description: 'Marks the build as one of many parallel builds',
|
|
@@ -22,6 +23,12 @@ export const exec = command('exec', {
|
|
|
22
23
|
var _process$env2;
|
|
23
24
|
return !!((_process$env2 = process.env).PERCY_PARTIAL_BUILD || (_process$env2.PERCY_PARTIAL_BUILD = '1'));
|
|
24
25
|
}
|
|
26
|
+
}, {
|
|
27
|
+
name: 'archive-dir',
|
|
28
|
+
description: 'Save snapshot data to an archive directory for deferred upload',
|
|
29
|
+
percyrc: 'percy.archiveDir',
|
|
30
|
+
type: 'string',
|
|
31
|
+
group: 'Percy'
|
|
25
32
|
}, {
|
|
26
33
|
name: 'testing',
|
|
27
34
|
percyrc: 'testing',
|
package/dist/index.js
CHANGED
package/dist/replay.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import command from '@percy/cli-command';
|
|
3
|
+
export const replay = command('replay', {
|
|
4
|
+
description: 'Upload archived snapshots to Percy',
|
|
5
|
+
args: [{
|
|
6
|
+
name: 'archive-dir',
|
|
7
|
+
description: 'Directory containing archived snapshots',
|
|
8
|
+
required: true,
|
|
9
|
+
attribute: val => {
|
|
10
|
+
if (!fs.existsSync(val)) throw new Error(`Not found: ${val}`);
|
|
11
|
+
if (!fs.lstatSync(val).isDirectory()) throw new Error(`Not a directory: ${val}`);
|
|
12
|
+
return 'archiveDir';
|
|
13
|
+
}
|
|
14
|
+
}],
|
|
15
|
+
examples: ['$0 ./percy-archive'],
|
|
16
|
+
percy: {
|
|
17
|
+
deferUploads: true,
|
|
18
|
+
skipDiscovery: true
|
|
19
|
+
}
|
|
20
|
+
}, async function* ({
|
|
21
|
+
percy,
|
|
22
|
+
args,
|
|
23
|
+
log,
|
|
24
|
+
exit
|
|
25
|
+
}) {
|
|
26
|
+
if (!percy) exit(0, 'Percy is disabled');
|
|
27
|
+
let {
|
|
28
|
+
readArchivedSnapshots
|
|
29
|
+
} = await import('@percy/core/archive');
|
|
30
|
+
let snapshots = readArchivedSnapshots(args.archiveDir, log);
|
|
31
|
+
if (!snapshots.length) {
|
|
32
|
+
throw new Error('No valid snapshots found in archive');
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
yield* percy.yield.start();
|
|
36
|
+
for (let snapshot of snapshots) {
|
|
37
|
+
yield* percy.yield.replaySnapshot(snapshot);
|
|
38
|
+
}
|
|
39
|
+
yield* percy.yield.stop();
|
|
40
|
+
} catch (error) {
|
|
41
|
+
log.error(error);
|
|
42
|
+
await percy.stop(true);
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
export default replay;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/cli-exec",
|
|
3
|
-
"version": "1.31.14-beta.
|
|
3
|
+
"version": "1.31.14-beta.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,14 +29,15 @@
|
|
|
29
29
|
},
|
|
30
30
|
"@percy/cli": {
|
|
31
31
|
"commands": [
|
|
32
|
-
"./dist/exec.js"
|
|
32
|
+
"./dist/exec.js",
|
|
33
|
+
"./dist/replay.js"
|
|
33
34
|
]
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@percy/cli-command": "1.31.14-beta.
|
|
37
|
-
"@percy/logger": "1.31.14-beta.
|
|
37
|
+
"@percy/cli-command": "1.31.14-beta.2",
|
|
38
|
+
"@percy/logger": "1.31.14-beta.2",
|
|
38
39
|
"cross-spawn": "^7.0.3",
|
|
39
40
|
"which": "^2.0.2"
|
|
40
41
|
},
|
|
41
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "e4fce73023453b77cdef50aac1a9bd5eb70cd01a"
|
|
42
43
|
}
|