@percy/cli-exec 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 +81 -60
- package/dist/common.js +16 -0
- package/dist/exec.js +133 -0
- package/dist/index.js +41 -16
- package/dist/{commands/exec/ping.js → ping.js} +33 -41
- package/dist/{hooks/init.js → start.js} +31 -9
- package/dist/stop.js +56 -0
- package/package.json +18 -29
- package/dist/commands/exec/index.js +0 -125
- package/dist/commands/exec/start.js +0 -61
- package/dist/commands/exec/stop.js +0 -71
- package/dist/flags.js +0 -17
- package/oclif.manifest.json +0 -1
package/README.md
CHANGED
|
@@ -5,89 +5,110 @@ Percy CLI commands for running a local snapshot server using [`@percy/core`](./p
|
|
|
5
5
|
## Commands
|
|
6
6
|
<!-- commands -->
|
|
7
7
|
* [`percy exec`](#percy-exec)
|
|
8
|
-
* [`percy exec:ping`](#percy-execping)
|
|
9
8
|
* [`percy exec:start`](#percy-execstart)
|
|
10
9
|
* [`percy exec:stop`](#percy-execstop)
|
|
10
|
+
* [`percy exec:ping`](#percy-execping)
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
### `percy exec`
|
|
13
13
|
|
|
14
14
|
Start and stop Percy around a supplied command
|
|
15
15
|
|
|
16
16
|
```
|
|
17
|
-
|
|
18
|
-
$ percy exec
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
--
|
|
29
|
-
--
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
--
|
|
33
|
-
|
|
34
|
-
|
|
17
|
+
Usage:
|
|
18
|
+
$ percy exec [options] -- <command>
|
|
19
|
+
|
|
20
|
+
Subcommands:
|
|
21
|
+
exec:start [options] Starts a local Percy snapshot server
|
|
22
|
+
exec:stop [options] Stops a local running Percy snapshot server
|
|
23
|
+
exec:ping [options] Pings a local running Percy snapshot server
|
|
24
|
+
help [command] Display command help
|
|
25
|
+
|
|
26
|
+
Options:
|
|
27
|
+
-P, --port [number] Local CLI server port (default: 5338)
|
|
28
|
+
--parallel Marks the build as one of many parallel builds
|
|
29
|
+
--partial Marks the build as a partial build
|
|
30
|
+
|
|
31
|
+
Percy options:
|
|
32
|
+
-c, --config <file> Config file path
|
|
33
|
+
-d, --dry-run Print snapshot names only
|
|
34
|
+
-h, --allowed-hostname <hostname> Allowed hostnames to capture in asset discovery
|
|
35
|
+
-t, --network-idle-timeout <ms> Asset discovery network idle timeout
|
|
36
|
+
--disable-cache Disable asset discovery caches
|
|
37
|
+
--debug Debug asset discovery and do not upload snapshots
|
|
38
|
+
|
|
39
|
+
Global options:
|
|
40
|
+
-v, --verbose Log everything
|
|
41
|
+
-q, --quiet Log errors only
|
|
42
|
+
-s, --silent Log nothing
|
|
43
|
+
--help Display command help
|
|
44
|
+
|
|
45
|
+
Examples:
|
|
35
46
|
$ percy exec -- echo "percy is running around this echo command"
|
|
36
47
|
$ percy exec -- yarn test
|
|
37
48
|
```
|
|
38
49
|
|
|
39
|
-
|
|
50
|
+
### `percy exec:start`
|
|
40
51
|
|
|
41
|
-
|
|
52
|
+
Starts a local Percy snapshot server
|
|
42
53
|
|
|
43
54
|
```
|
|
44
|
-
|
|
45
|
-
$ percy exec:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
-P, --port
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
--
|
|
55
|
+
Usage:
|
|
56
|
+
$ percy exec:start [options]
|
|
57
|
+
|
|
58
|
+
Options:
|
|
59
|
+
-P, --port [number] Local CLI server port (default: 5338)
|
|
60
|
+
|
|
61
|
+
Percy options:
|
|
62
|
+
-c, --config <file> Config file path
|
|
63
|
+
-d, --dry-run Print snapshot names only
|
|
64
|
+
-h, --allowed-hostname <hostname> Allowed hostnames to capture in asset discovery
|
|
65
|
+
-t, --network-idle-timeout <ms> Asset discovery network idle timeout
|
|
66
|
+
--disable-cache Disable asset discovery caches
|
|
67
|
+
--debug Debug asset discovery and do not upload snapshots
|
|
68
|
+
|
|
69
|
+
Global options:
|
|
70
|
+
-v, --verbose Log everything
|
|
71
|
+
-q, --quiet Log errors only
|
|
72
|
+
-s, --silent Log nothing
|
|
73
|
+
--help Display command help
|
|
74
|
+
|
|
75
|
+
Examples:
|
|
76
|
+
$ percy exec:start &> percy.log
|
|
52
77
|
```
|
|
53
78
|
|
|
54
|
-
|
|
79
|
+
### `percy exec:stop`
|
|
55
80
|
|
|
56
|
-
|
|
81
|
+
Stops a local running Percy snapshot server
|
|
57
82
|
|
|
58
83
|
```
|
|
59
|
-
|
|
60
|
-
$ percy exec:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
-P, --port
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
-
|
|
67
|
-
-q, --quiet
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
--debug debug asset discovery and do not upload snapshots
|
|
71
|
-
--disable-cache disable asset discovery caches
|
|
72
|
-
--silent log nothing
|
|
73
|
-
|
|
74
|
-
EXAMPLES
|
|
75
|
-
$ percy exec:start
|
|
76
|
-
$ percy exec:start &> percy.log
|
|
84
|
+
Usage:
|
|
85
|
+
$ percy exec:stop [options]
|
|
86
|
+
|
|
87
|
+
Options:
|
|
88
|
+
-P, --port [number] Local CLI server port (default: 5338)
|
|
89
|
+
|
|
90
|
+
Global options:
|
|
91
|
+
-v, --verbose Log everything
|
|
92
|
+
-q, --quiet Log errors only
|
|
93
|
+
-s, --silent Log nothing
|
|
94
|
+
-h, --help Display command help
|
|
77
95
|
```
|
|
78
96
|
|
|
79
|
-
|
|
97
|
+
### `percy exec:ping`
|
|
80
98
|
|
|
81
|
-
|
|
99
|
+
Pings a local running Percy snapshot server
|
|
82
100
|
|
|
83
101
|
```
|
|
84
|
-
|
|
85
|
-
$ percy exec:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
-P, --port
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
--
|
|
102
|
+
Usage:
|
|
103
|
+
$ percy exec:ping [options]
|
|
104
|
+
|
|
105
|
+
Options:
|
|
106
|
+
-P, --port [number] Local CLI server port (default: 5338)
|
|
107
|
+
|
|
108
|
+
Global options:
|
|
109
|
+
-v, --verbose Log everything
|
|
110
|
+
-q, --quiet Log errors only
|
|
111
|
+
-s, --silent Log nothing
|
|
112
|
+
-h, --help Display command help
|
|
92
113
|
```
|
|
93
114
|
<!-- commandsstop -->
|
package/dist/common.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.flags = void 0;
|
|
7
|
+
const flags = [{
|
|
8
|
+
name: 'port',
|
|
9
|
+
description: 'Local CLI server port',
|
|
10
|
+
env: 'PERCY_SERVER_PORT',
|
|
11
|
+
type: 'number',
|
|
12
|
+
parse: Number,
|
|
13
|
+
default: 5338,
|
|
14
|
+
short: 'P'
|
|
15
|
+
}];
|
|
16
|
+
exports.flags = flags;
|
package/dist/exec.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.exec = exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _cliCommand = _interopRequireDefault(require("@percy/cli-command"));
|
|
9
|
+
|
|
10
|
+
var common = _interopRequireWildcard(require("./common"));
|
|
11
|
+
|
|
12
|
+
var _start = _interopRequireDefault(require("./start"));
|
|
13
|
+
|
|
14
|
+
var _stop = _interopRequireDefault(require("./stop"));
|
|
15
|
+
|
|
16
|
+
var _ping = _interopRequireDefault(require("./ping"));
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
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); }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
const exec = (0, _cliCommand.default)('exec', {
|
|
25
|
+
description: 'Start and stop Percy around a supplied command',
|
|
26
|
+
usage: '[options] -- <command>',
|
|
27
|
+
commands: [_start.default, _stop.default, _ping.default],
|
|
28
|
+
flags: [...common.flags, {
|
|
29
|
+
name: 'parallel',
|
|
30
|
+
description: 'Marks the build as one of many parallel builds',
|
|
31
|
+
parse: () => {
|
|
32
|
+
var _process$env;
|
|
33
|
+
|
|
34
|
+
return !!((_process$env = process.env).PERCY_PARALLEL_TOTAL || (_process$env.PERCY_PARALLEL_TOTAL = '-1'));
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
name: 'partial',
|
|
38
|
+
description: 'Marks the build as a partial build',
|
|
39
|
+
parse: () => {
|
|
40
|
+
var _process$env2;
|
|
41
|
+
|
|
42
|
+
return !!((_process$env2 = process.env).PERCY_PARTIAL_BUILD || (_process$env2.PERCY_PARTIAL_BUILD = '1'));
|
|
43
|
+
}
|
|
44
|
+
}],
|
|
45
|
+
examples: ['$0 -- echo "percy is running around this echo command"', '$0 -- yarn test'],
|
|
46
|
+
loose: ['Warning: Missing command separator (--),', 'some command options may not work as expected'].join(' '),
|
|
47
|
+
percy: {
|
|
48
|
+
server: true
|
|
49
|
+
}
|
|
50
|
+
}, async function* ({
|
|
51
|
+
flags,
|
|
52
|
+
argv,
|
|
53
|
+
env,
|
|
54
|
+
percy,
|
|
55
|
+
log,
|
|
56
|
+
exit
|
|
57
|
+
}) {
|
|
58
|
+
let [command, ...args] = argv; // command is required
|
|
59
|
+
|
|
60
|
+
if (!command) {
|
|
61
|
+
log.error("You must supply a command to run after '--'");
|
|
62
|
+
log.info('Example:');
|
|
63
|
+
log.info(' $ percy exec -- npm test');
|
|
64
|
+
exit(1);
|
|
65
|
+
} // verify the provided command exists
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
let which = await Promise.resolve().then(() => _interopRequireWildcard(require('which')));
|
|
69
|
+
|
|
70
|
+
if (!which.sync(command, {
|
|
71
|
+
nothrow: true
|
|
72
|
+
})) {
|
|
73
|
+
exit(127, `Command not found "${command}"`);
|
|
74
|
+
} // attempt to start percy if enabled
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
if (!percy) {
|
|
78
|
+
log.warn('Percy is disabled');
|
|
79
|
+
} else {
|
|
80
|
+
try {
|
|
81
|
+
yield* percy.start();
|
|
82
|
+
} catch (error) {
|
|
83
|
+
if (error.canceled) throw error;
|
|
84
|
+
log.warn('Skipping visual tests');
|
|
85
|
+
log.error(error);
|
|
86
|
+
}
|
|
87
|
+
} // provide SDKs with useful env vars
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
env.PERCY_SERVER_ADDRESS || (env.PERCY_SERVER_ADDRESS = percy === null || percy === void 0 ? void 0 : percy.address());
|
|
91
|
+
env.PERCY_LOGLEVEL || (env.PERCY_LOGLEVEL = log.loglevel()); // run the provided command
|
|
92
|
+
|
|
93
|
+
log.info(`Running "${[command, ...args].join(' ')}"`);
|
|
94
|
+
let [status, error] = yield* spawn(command, args); // stop percy if running (force stop if there is an error);
|
|
95
|
+
|
|
96
|
+
await (percy === null || percy === void 0 ? void 0 : percy.stop(!!error)); // forward any returned status code
|
|
97
|
+
|
|
98
|
+
if (status) exit(status, error);
|
|
99
|
+
}); // Spawn a command with cross-spawn and return an array containing the resulting status code along
|
|
100
|
+
// with any error encountered while running. Uses a generator pattern to handle interupt signals.
|
|
101
|
+
|
|
102
|
+
exports.exec = exec;
|
|
103
|
+
|
|
104
|
+
async function* spawn(cmd, args) {
|
|
105
|
+
let {
|
|
106
|
+
default: crossSpawn
|
|
107
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('cross-spawn')));
|
|
108
|
+
let proc, closed, error;
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
proc = crossSpawn(cmd, args, {
|
|
112
|
+
stdio: 'inherit'
|
|
113
|
+
});
|
|
114
|
+
proc.on('close', code => closed = code);
|
|
115
|
+
proc.on('error', err => error = err); // run until an event is triggered
|
|
116
|
+
|
|
117
|
+
/* eslint-disable-next-line no-unmodified-loop-condition */
|
|
118
|
+
|
|
119
|
+
while (closed == null && error == null) {
|
|
120
|
+
yield new Promise(r => setImmediate(r));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (error) throw error;
|
|
124
|
+
return [closed];
|
|
125
|
+
} catch (err) {
|
|
126
|
+
if (!err.signal) return [1, err];
|
|
127
|
+
proc.kill(err.signal);
|
|
128
|
+
return [0, err];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
var _default = exec;
|
|
133
|
+
exports.default = _default;
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _exec.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "exec", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _exec.exec;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "ping", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _ping.ping;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "start", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _start.start;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "stop", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _stop.stop;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
6
36
|
|
|
7
|
-
|
|
8
|
-
Ping
|
|
9
|
-
} = require('./commands/exec/ping');
|
|
37
|
+
var _exec = _interopRequireWildcard(require("./exec"));
|
|
10
38
|
|
|
11
|
-
|
|
12
|
-
Start
|
|
13
|
-
} = require('./commands/exec/start');
|
|
39
|
+
var _start = require("./start");
|
|
14
40
|
|
|
15
|
-
|
|
16
|
-
Stop
|
|
17
|
-
} = require('./commands/exec/stop');
|
|
41
|
+
var _stop = require("./stop");
|
|
18
42
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
43
|
+
var _ping = require("./ping");
|
|
44
|
+
|
|
45
|
+
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); }
|
|
46
|
+
|
|
47
|
+
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; }
|
|
@@ -3,15 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.ping = exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _cliCommand =
|
|
8
|
+
var _cliCommand = _interopRequireDefault(require("@percy/cli-command"));
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _logger = _interopRequireDefault(require("@percy/logger"));
|
|
13
|
-
|
|
14
|
-
var _flags = _interopRequireDefault(require("../../flags"));
|
|
10
|
+
var common = _interopRequireWildcard(require("./common"));
|
|
15
11
|
|
|
16
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
13
|
|
|
@@ -19,39 +15,35 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
19
15
|
|
|
20
16
|
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
17
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
18
|
+
const ping = (0, _cliCommand.default)('ping', {
|
|
19
|
+
description: 'Pings a local running Percy snapshot server',
|
|
20
|
+
flags: common.flags,
|
|
21
|
+
percy: true
|
|
22
|
+
}, async ({
|
|
23
|
+
flags,
|
|
24
|
+
percy,
|
|
25
|
+
log,
|
|
26
|
+
exit
|
|
27
|
+
}) => {
|
|
28
|
+
if (!percy) exit(0, 'Percy is disabled');
|
|
29
|
+
let {
|
|
30
|
+
request
|
|
31
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('@percy/core/dist/utils')));
|
|
32
|
+
let ping = `http://localhost:${flags.port}/percy/healthcheck`;
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
await request(ping, {
|
|
36
|
+
retryNotFound: true,
|
|
37
|
+
noProxy: true
|
|
38
|
+
});
|
|
39
|
+
} catch (err) {
|
|
40
|
+
log.error('Percy is not running');
|
|
41
|
+
log.debug(err);
|
|
42
|
+
exit(1);
|
|
47
43
|
}
|
|
48
44
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
exports.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
_defineProperty(Ping, "flags", { ..._cliCommand.flags.logging,
|
|
56
|
-
..._flags.default
|
|
57
|
-
});
|
|
45
|
+
log.info('Percy is running');
|
|
46
|
+
});
|
|
47
|
+
exports.ping = ping;
|
|
48
|
+
var _default = ping;
|
|
49
|
+
exports.default = _default;
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.start = exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _cliCommand = _interopRequireDefault(require("@percy/cli-command"));
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var common = _interopRequireWildcard(require("./common"));
|
|
11
11
|
|
|
12
12
|
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); }
|
|
13
13
|
|
|
@@ -15,9 +15,31 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
15
15
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
const start = (0, _cliCommand.default)('start', {
|
|
19
|
+
description: 'Starts a local Percy snapshot server',
|
|
20
|
+
flags: common.flags,
|
|
21
|
+
examples: ['$0 &> percy.log'],
|
|
22
|
+
percy: {
|
|
23
|
+
server: true
|
|
24
|
+
}
|
|
25
|
+
}, async function* ({
|
|
26
|
+
percy,
|
|
27
|
+
exit
|
|
28
|
+
}) {
|
|
29
|
+
if (!percy) exit(0, 'Percy is disabled'); // start percy
|
|
30
|
+
|
|
31
|
+
yield* percy.start();
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
// run until stopped or terminated
|
|
35
|
+
while (percy.readyState < 3) {
|
|
36
|
+
yield new Promise(r => setImmediate(r));
|
|
37
|
+
}
|
|
38
|
+
} catch (error) {
|
|
39
|
+
await percy.stop(true);
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
exports.start = start;
|
|
44
|
+
var _default = start;
|
|
45
|
+
exports.default = _default;
|
package/dist/stop.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.stop = exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _cliCommand = _interopRequireDefault(require("@percy/cli-command"));
|
|
9
|
+
|
|
10
|
+
var common = _interopRequireWildcard(require("./common"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
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); }
|
|
15
|
+
|
|
16
|
+
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; }
|
|
17
|
+
|
|
18
|
+
const stop = (0, _cliCommand.default)('stop', {
|
|
19
|
+
description: 'Stops a local running Percy snapshot server',
|
|
20
|
+
flags: common.flags,
|
|
21
|
+
percy: true
|
|
22
|
+
}, async ({
|
|
23
|
+
flags,
|
|
24
|
+
percy,
|
|
25
|
+
log,
|
|
26
|
+
exit
|
|
27
|
+
}) => {
|
|
28
|
+
if (!percy) exit(0, 'Percy is disabled');
|
|
29
|
+
let {
|
|
30
|
+
request
|
|
31
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('@percy/core/dist/utils')));
|
|
32
|
+
let stop = `http://localhost:${flags.port}/percy/stop`;
|
|
33
|
+
let ping = `http://localhost:${flags.port}/percy/healthcheck`;
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
await request(stop, {
|
|
37
|
+
method: 'POST',
|
|
38
|
+
noProxy: true
|
|
39
|
+
});
|
|
40
|
+
} catch (err) {
|
|
41
|
+
log.error('Percy is not running');
|
|
42
|
+
log.debug(err);
|
|
43
|
+
exit(1);
|
|
44
|
+
} // retry heathcheck until it fails
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
await new Promise(function check(resolve) {
|
|
48
|
+
return request(ping, {
|
|
49
|
+
noProxy: true
|
|
50
|
+
}).then(() => setTimeout(check, 100, resolve)).catch(resolve);
|
|
51
|
+
});
|
|
52
|
+
log.info('Percy has stopped');
|
|
53
|
+
});
|
|
54
|
+
exports.stop = stop;
|
|
55
|
+
var _default = stop;
|
|
56
|
+
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/cli-exec",
|
|
3
|
-
"
|
|
4
|
-
"version": "1.0.0-beta.71",
|
|
3
|
+
"version": "1.0.0-beta.72",
|
|
5
4
|
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/percy/cli",
|
|
8
|
+
"directory": "packages/cli-exec"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
6
13
|
"main": "dist/index.js",
|
|
7
14
|
"files": [
|
|
8
|
-
"dist"
|
|
9
|
-
"oclif.manifest.json"
|
|
15
|
+
"dist"
|
|
10
16
|
],
|
|
11
17
|
"engines": {
|
|
12
18
|
"node": ">=12"
|
|
@@ -14,37 +20,20 @@
|
|
|
14
20
|
"scripts": {
|
|
15
21
|
"build": "node ../../scripts/build",
|
|
16
22
|
"lint": "eslint --ignore-path ../../.gitignore .",
|
|
17
|
-
"
|
|
18
|
-
"readme": "oclif-dev readme",
|
|
23
|
+
"readme": "percy-cli-readme",
|
|
19
24
|
"test": "node ../../scripts/test",
|
|
20
25
|
"test:coverage": "yarn test --coverage"
|
|
21
26
|
},
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"bin": "percy",
|
|
27
|
-
"commands": "./dist/commands",
|
|
28
|
-
"hooks": {
|
|
29
|
-
"init": "./dist/hooks/init"
|
|
30
|
-
},
|
|
31
|
-
"topics": {
|
|
32
|
-
"exec": {
|
|
33
|
-
"description": "capture and upload snapshots"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
27
|
+
"@percy/cli": {
|
|
28
|
+
"commands": [
|
|
29
|
+
"./dist/exec.js"
|
|
30
|
+
]
|
|
36
31
|
},
|
|
37
32
|
"dependencies": {
|
|
38
|
-
"@percy/cli-command": "1.0.0-beta.
|
|
39
|
-
"@percy/core": "1.0.0-beta.
|
|
40
|
-
"@percy/logger": "1.0.0-beta.71",
|
|
33
|
+
"@percy/cli-command": "1.0.0-beta.72",
|
|
34
|
+
"@percy/core": "1.0.0-beta.72",
|
|
41
35
|
"cross-spawn": "^7.0.3",
|
|
42
36
|
"which": "^2.0.2"
|
|
43
37
|
},
|
|
44
|
-
"
|
|
45
|
-
"type": "git",
|
|
46
|
-
"url": "https://github.com/percy/cli",
|
|
47
|
-
"directory": "packages/cli-exec"
|
|
48
|
-
},
|
|
49
|
-
"gitHead": "364d1df717fb19a26ccb024458df6e78a9c11f99"
|
|
38
|
+
"gitHead": "6219287e18a0cacb609d0c2696a5785abc9009b9"
|
|
50
39
|
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Exec = void 0;
|
|
7
|
-
|
|
8
|
-
var _cliCommand = _interopRequireWildcard(require("@percy/cli-command"));
|
|
9
|
-
|
|
10
|
-
var _core = _interopRequireDefault(require("@percy/core"));
|
|
11
|
-
|
|
12
|
-
var _logger = _interopRequireDefault(require("@percy/logger"));
|
|
13
|
-
|
|
14
|
-
var _crossSpawn = _interopRequireDefault(require("cross-spawn"));
|
|
15
|
-
|
|
16
|
-
var _which = _interopRequireDefault(require("which"));
|
|
17
|
-
|
|
18
|
-
var _flags = _interopRequireDefault(require("../../flags"));
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
|
-
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); }
|
|
23
|
-
|
|
24
|
-
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; }
|
|
25
|
-
|
|
26
|
-
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; }
|
|
27
|
-
|
|
28
|
-
class Exec extends _cliCommand.default {
|
|
29
|
-
constructor(...args) {
|
|
30
|
-
super(...args);
|
|
31
|
-
|
|
32
|
-
_defineProperty(this, "log", (0, _logger.default)('cli:exec'));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async run() {
|
|
36
|
-
var _this$percy;
|
|
37
|
-
|
|
38
|
-
let {
|
|
39
|
-
argv
|
|
40
|
-
} = this.parse(Exec);
|
|
41
|
-
let command = argv.shift(); // validate the passed command
|
|
42
|
-
|
|
43
|
-
if (!command) {
|
|
44
|
-
this.log.error('You must supply a command to run after --');
|
|
45
|
-
this.log.info('Example:');
|
|
46
|
-
this.log.info('$ percy exec -- echo "run your test suite"');
|
|
47
|
-
return this.exit(1);
|
|
48
|
-
} else if (!_which.default.sync(command, {
|
|
49
|
-
nothrow: true
|
|
50
|
-
})) {
|
|
51
|
-
this.log.error(`Error: command not found "${command}"`);
|
|
52
|
-
return this.exit(127);
|
|
53
|
-
} // set environment parallel total for `n` parallel builds (use with build:finalize)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (this.flags.parallel && !process.env.PERCY_PARALLEL_TOTAL) {
|
|
57
|
-
process.env.PERCY_PARALLEL_TOTAL = '-1';
|
|
58
|
-
} // set environment partial build flag
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (this.flags.partial) {
|
|
62
|
-
process.env.PERCY_PARTIAL_BUILD = '1';
|
|
63
|
-
} // attempt to start percy if enabled
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (this.isPercyEnabled()) {
|
|
67
|
-
try {
|
|
68
|
-
this.percy = await _core.default.start({
|
|
69
|
-
port: this.flags.port,
|
|
70
|
-
...this.percyrc()
|
|
71
|
-
});
|
|
72
|
-
} catch (err) {
|
|
73
|
-
this.log.info(`Skipping visual tests - ${err.message}`);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
this.log.info(`Running "${[command].concat(argv).join(' ')}"`);
|
|
77
|
-
} // provide SDKs with useful env vars
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
let env = {
|
|
81
|
-
PERCY_SERVER_ADDRESS: (_this$percy = this.percy) === null || _this$percy === void 0 ? void 0 : _this$percy.address(),
|
|
82
|
-
PERCY_LOGLEVEL: _logger.default.loglevel(),
|
|
83
|
-
...process.env
|
|
84
|
-
}; // run the passed command async
|
|
85
|
-
|
|
86
|
-
let status = await new Promise((resolve, reject) => {
|
|
87
|
-
(0, _crossSpawn.default)(command, argv, {
|
|
88
|
-
stdio: 'inherit',
|
|
89
|
-
env
|
|
90
|
-
}).on('error', reject).on('close', resolve);
|
|
91
|
-
}); // forward status code
|
|
92
|
-
|
|
93
|
-
if (status) {
|
|
94
|
-
this.exit(status);
|
|
95
|
-
}
|
|
96
|
-
} // Called on error, interupt, or after running
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
async finally(error) {
|
|
100
|
-
var _this$percy2;
|
|
101
|
-
|
|
102
|
-
await ((_this$percy2 = this.percy) === null || _this$percy2 === void 0 ? void 0 : _this$percy2.stop(!!error));
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
exports.Exec = Exec;
|
|
108
|
-
|
|
109
|
-
_defineProperty(Exec, "description", 'Start and stop Percy around a supplied command');
|
|
110
|
-
|
|
111
|
-
_defineProperty(Exec, "strict", false);
|
|
112
|
-
|
|
113
|
-
_defineProperty(Exec, "flags", { ..._cliCommand.flags.logging,
|
|
114
|
-
..._cliCommand.flags.discovery,
|
|
115
|
-
..._cliCommand.flags.config,
|
|
116
|
-
..._flags.default,
|
|
117
|
-
parallel: _cliCommand.flags.boolean({
|
|
118
|
-
description: 'marks the build as one of many parallel builds'
|
|
119
|
-
}),
|
|
120
|
-
partial: _cliCommand.flags.boolean({
|
|
121
|
-
description: 'marks the build as a partial build'
|
|
122
|
-
})
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
_defineProperty(Exec, "examples", ['$ percy exec -- echo "percy is running around this echo command"', '$ percy exec -- yarn test']);
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Start = void 0;
|
|
7
|
-
|
|
8
|
-
var _cliCommand = _interopRequireWildcard(require("@percy/cli-command"));
|
|
9
|
-
|
|
10
|
-
var _core = _interopRequireDefault(require("@percy/core"));
|
|
11
|
-
|
|
12
|
-
var _logger = _interopRequireDefault(require("@percy/logger"));
|
|
13
|
-
|
|
14
|
-
var _flags = _interopRequireDefault(require("../../flags"));
|
|
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 Start extends _cliCommand.default {
|
|
25
|
-
constructor(...args) {
|
|
26
|
-
super(...args);
|
|
27
|
-
|
|
28
|
-
_defineProperty(this, "log", (0, _logger.default)('cli:exec:start'));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async run() {
|
|
32
|
-
if (!this.isPercyEnabled()) {
|
|
33
|
-
this.log.info('Percy has been disabled. Not starting');
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let percy = await _core.default.start({
|
|
38
|
-
port: this.flags.port,
|
|
39
|
-
...this.percyrc()
|
|
40
|
-
}); // only stop when terminated
|
|
41
|
-
|
|
42
|
-
let stop = () => percy.stop(true);
|
|
43
|
-
|
|
44
|
-
process.on('SIGHUP', stop);
|
|
45
|
-
process.on('SIGINT', stop);
|
|
46
|
-
process.on('SIGTERM', stop);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
exports.Start = Start;
|
|
52
|
-
|
|
53
|
-
_defineProperty(Start, "description", 'Starts a local Percy snapshot server');
|
|
54
|
-
|
|
55
|
-
_defineProperty(Start, "flags", { ..._cliCommand.flags.logging,
|
|
56
|
-
..._cliCommand.flags.discovery,
|
|
57
|
-
..._cliCommand.flags.config,
|
|
58
|
-
..._flags.default
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
_defineProperty(Start, "examples", ['$ percy exec:start', '$ percy exec:start &> percy.log']);
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Stop = void 0;
|
|
7
|
-
|
|
8
|
-
var _cliCommand = _interopRequireWildcard(require("@percy/cli-command"));
|
|
9
|
-
|
|
10
|
-
var _request = _interopRequireDefault(require("@percy/client/dist/request"));
|
|
11
|
-
|
|
12
|
-
var _logger = _interopRequireDefault(require("@percy/logger"));
|
|
13
|
-
|
|
14
|
-
var _flags = _interopRequireDefault(require("../../flags"));
|
|
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 Stop extends _cliCommand.default {
|
|
25
|
-
constructor(...args) {
|
|
26
|
-
super(...args);
|
|
27
|
-
|
|
28
|
-
_defineProperty(this, "log", (0, _logger.default)('cli:exec:stop'));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async run() {
|
|
32
|
-
let {
|
|
33
|
-
port
|
|
34
|
-
} = this.flags;
|
|
35
|
-
let stop = `http://localhost:${port}/percy/stop`;
|
|
36
|
-
let ping = `http://localhost:${port}/percy/healthcheck`;
|
|
37
|
-
|
|
38
|
-
if (!this.isPercyEnabled()) {
|
|
39
|
-
this.log.info('Percy is disabled');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
await (0, _request.default)(stop, {
|
|
45
|
-
method: 'POST',
|
|
46
|
-
noProxy: true
|
|
47
|
-
});
|
|
48
|
-
} catch (err) {
|
|
49
|
-
this.log.error('Percy is not running');
|
|
50
|
-
this.log.debug(err);
|
|
51
|
-
this.exit(1);
|
|
52
|
-
} // retry heathcheck until it fails
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
await new Promise(function check(resolve) {
|
|
56
|
-
return (0, _request.default)(ping, {
|
|
57
|
-
noProxy: true
|
|
58
|
-
}).then(() => setTimeout(check, 100, resolve)).catch(resolve);
|
|
59
|
-
});
|
|
60
|
-
this.log.info('Percy has stopped');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
exports.Stop = Stop;
|
|
66
|
-
|
|
67
|
-
_defineProperty(Stop, "description", 'Stops a local running Percy snapshot server');
|
|
68
|
-
|
|
69
|
-
_defineProperty(Stop, "flags", { ..._cliCommand.flags.logging,
|
|
70
|
-
..._flags.default
|
|
71
|
-
});
|
package/dist/flags.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _cliCommand = require("@percy/cli-command");
|
|
9
|
-
|
|
10
|
-
var _default = {
|
|
11
|
-
port: _cliCommand.flags.integer({
|
|
12
|
-
char: 'P',
|
|
13
|
-
description: 'server port',
|
|
14
|
-
default: process.env.PERCY_CLI_PORT || 5338
|
|
15
|
-
})
|
|
16
|
-
};
|
|
17
|
-
exports.default = _default;
|
package/oclif.manifest.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":"1.0.0-beta.71","commands":{"exec":{"id":"exec","description":"Start and stop Percy around a supplied command","pluginName":"@percy/cli-exec","pluginType":"core","aliases":[],"examples":["$ percy exec -- echo \"percy is running around this echo command\"","$ percy exec -- yarn test"],"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},"allowed-hostname":{"name":"allowed-hostname","type":"option","char":"h","description":"allowed hostnames to capture in asset discovery"},"network-idle-timeout":{"name":"network-idle-timeout","type":"option","char":"t","description":"asset discovery network idle timeout"},"disable-cache":{"name":"disable-cache","type":"boolean","description":"disable asset discovery caches","allowNo":false},"dry-run":{"name":"dry-run","type":"boolean","char":"d","description":"print logs only, do not run asset discovery or upload snapshots","allowNo":false},"debug":{"name":"debug","type":"boolean","description":"debug asset discovery and do not upload snapshots","allowNo":false},"config":{"name":"config","type":"option","char":"c","description":"configuration file path"},"port":{"name":"port","type":"option","char":"P","description":"server port","default":5338},"parallel":{"name":"parallel","type":"boolean","description":"marks the build as one of many parallel builds","allowNo":false},"partial":{"name":"partial","type":"boolean","description":"marks the build as a partial build","allowNo":false}},"args":[]},"exec:ping":{"id":"exec:ping","description":"Pings a local running Percy snapshot server","pluginName":"@percy/cli-exec","pluginType":"core","aliases":[],"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},"port":{"name":"port","type":"option","char":"P","description":"server port","default":5338}},"args":[]},"exec:start":{"id":"exec:start","description":"Starts a local Percy snapshot server","pluginName":"@percy/cli-exec","pluginType":"core","aliases":[],"examples":["$ percy exec:start","$ percy exec:start &> percy.log"],"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},"allowed-hostname":{"name":"allowed-hostname","type":"option","char":"h","description":"allowed hostnames to capture in asset discovery"},"network-idle-timeout":{"name":"network-idle-timeout","type":"option","char":"t","description":"asset discovery network idle timeout"},"disable-cache":{"name":"disable-cache","type":"boolean","description":"disable asset discovery caches","allowNo":false},"dry-run":{"name":"dry-run","type":"boolean","char":"d","description":"print logs only, do not run asset discovery or upload snapshots","allowNo":false},"debug":{"name":"debug","type":"boolean","description":"debug asset discovery and do not upload snapshots","allowNo":false},"config":{"name":"config","type":"option","char":"c","description":"configuration file path"},"port":{"name":"port","type":"option","char":"P","description":"server port","default":5338}},"args":[]},"exec:stop":{"id":"exec:stop","description":"Stops a local running Percy snapshot server","pluginName":"@percy/cli-exec","pluginType":"core","aliases":[],"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},"port":{"name":"port","type":"option","char":"P","description":"server port","default":5338}},"args":[]}}}
|