Skip to content

Commit

Permalink
♻ Refactor @percy/cli-snapshot to utilize new @percy/cli-command (#682)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wil Wilsman authored Dec 16, 2021
1 parent 647dcbb commit 470419d
Show file tree
Hide file tree
Showing 16 changed files with 445 additions and 444 deletions.
59 changes: 33 additions & 26 deletions packages/cli-snapshot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,46 @@ Snapshot a list or static directory of web pages.

## Commands
<!-- commands -->
* [`percy snapshot DIR|FILE|SITEMAP`](#percy-snapshot-dirfilesitemap)
* [`percy snapshot`](#percy-snapshot)

## `percy snapshot DIR|FILE|SITEMAP`
### `percy snapshot`

Take snapshots from a static directory, snapshots file, or sitemap url
Snapshot a static directory, snapshots file, or sitemap URL

```
USAGE
$ percy snapshot DIR|FILE|SITEMAP
ARGUMENTS
DIR|FILE|SITEMAP static directory, snapshots file, or sitemap url
OPTIONS
-b, --base-url=base-url the base url pages are hosted at when snapshotting
-c, --config=config configuration file path
-d, --dry-run print logs only, do not run asset discovery or upload snapshots
-h, --allowed-hostname=allowed-hostname allowed hostnames to capture in asset discovery
-q, --quiet log errors only
-t, --network-idle-timeout=network-idle-timeout asset discovery network idle timeout
-v, --verbose log everything
--clean-urls rewrite static index and filepath URLs to be clean
--debug debug asset discovery and do not upload snapshots
--disable-cache disable asset discovery caches
--exclude=exclude one or more globs/patterns matching snapshots to exclude
--include=include one or more globs/patterns matching snapshots to include
--silent log nothing
EXAMPLES
Usage:
$ percy snapshot [options] <dir|file|sitemap>
Arguments:
dir|file|sitemap Static directory, snapshots file, or sitemap url
Options:
-b, --base-url <string> The base url pages are hosted at when snapshotting
--include <pattern> One or more globs/patterns matching snapshots to include
--exclude <pattern> One or more globs/patterns matching snapshots to exclude
Static options:
--clean-urls Rewrite static index and filepath URLs to be clean
Percy options:
-c, --config <file> Config file path
-d, --dry-run Print snapshot names only
-h, --allowed-hostname <hostname> Allowed hostnames to capture in asset discovery
-t, --network-idle-timeout <ms> Asset discovery network idle timeout
--disable-cache Disable asset discovery caches
--debug Debug asset discovery and do not upload snapshots
Global options:
-v, --verbose Log everything
-q, --quiet Log errors only
-s, --silent Log nothing
--help Display command help
Examples:
$ percy snapshot ./public
$ percy snapshot snapshots.yml
$ percy snapshot https://percy.io/sitemap.xml
```

<!-- commandsstop -->

## Usage
Expand Down
33 changes: 14 additions & 19 deletions packages/cli-snapshot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,41 @@
"name": "@percy/cli-snapshot",
"version": "1.0.0-beta.71",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/percy/cli",
"directory": "packages/cli-snapshot"
},
"publishConfig": {
"access": "public"
},
"main": "dist/index.js",
"files": [
"dist",
"oclif.manifest.json"
"dist"
],
"engines": {
"node": ">=12"
},
"scripts": {
"build": "node ../../scripts/build",
"lint": "eslint --ignore-path ../../.gitignore .",
"postbuild": "oclif-dev manifest",
"readme": "oclif-dev readme",
"readme": "percy-cli-readme",
"test": "node ../../scripts/test",
"test:coverage": "yarn test --coverage"
},
"publishConfig": {
"access": "public"
},
"oclif": {
"bin": "percy",
"commands": "./dist/commands",
"hooks": {
"init": "./dist/hooks/init"
}
"@percy/cli": {
"commands": [
"./dist/snapshot.js"
]
},
"dependencies": {
"@percy/cli-command": "1.0.0-beta.71",
"@percy/config": "1.0.0-beta.71",
"@percy/core": "1.0.0-beta.71",
"@percy/logger": "1.0.0-beta.71",
"globby": "^11.0.4",
"path-to-regexp": "^6.2.0",
"picomatch": "^2.3.0",
"serve-handler": "^6.1.3",
"yaml": "^1.10.0"
},
"repository": {
"type": "git",
"url": "https://github.com/percy/cli",
"directory": "packages/cli-snapshot"
}
}
225 changes: 0 additions & 225 deletions packages/cli-snapshot/src/commands/snapshot.js

This file was deleted.

16 changes: 5 additions & 11 deletions packages/cli-snapshot/src/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { snapshotSchema } from '@percy/core/dist/config';

// Common schemas referenced by other schemas
export const cliSchema = {
export const commonSchema = {
$id: '/snapshot/cli',
$refs: {
predicate: {
Expand Down Expand Up @@ -76,9 +76,9 @@ export const configSchema = {
}
};

// Page listing schema
export const snapshotListSchema = {
$id: '/snapshot/list',
// Snapshots file schema
export const snapshotsFileSchema = {
$id: '/snapshot/file',
oneOf: [{
type: 'array',
items: {
Expand All @@ -105,13 +105,7 @@ export const snapshotListSchema = {
}]
};

export const schemas = [
cliSchema,
configSchema,
snapshotListSchema
];

export function migration(config, util) {
export function configMigration(config, util) {
/* eslint-disable curly */
if (config.version < 2) {
// static-snapshots and options were renamed
Expand Down
Loading

0 comments on commit 470419d

Please sign in to comment.