@percy/core
Advanced tools
Comparing version 1.9.1 to 1.10.0
@@ -192,11 +192,13 @@ import fs from 'fs'; | ||
serve: dir, | ||
baseUrl = '/' | ||
baseUrl = '' | ||
} = options; | ||
let server = Server.createServer(options); // used when generating an automatic sitemap | ||
let server = Server.createServer(options); // remove trailing slashes so the base snapshot name matches other snapshots | ||
baseUrl = baseUrl.replace(/\/$/, ''); // used when generating an automatic sitemap | ||
let toURL = Server.createRewriter( // reverse rewrites' src, dest, & order | ||
Object.entries((options === null || options === void 0 ? void 0 : options.rewrites) ?? {}).reduce((acc, rw) => [rw.reverse(), ...acc], []), (filename, rewrite) => new URL(path.posix.join(baseUrl, // cleanUrls will trim trailing .html/index.html from paths | ||
Object.entries((options === null || options === void 0 ? void 0 : options.rewrites) ?? {}).reduce((acc, rw) => [rw.reverse(), ...acc], []), (filename, rewrite) => new URL(path.posix.join('/', baseUrl, // cleanUrls will trim trailing .html/index.html from paths | ||
!options.cleanUrls ? rewrite(filename) : rewrite(filename).replace(/(\/index)?\.html$/, '')), server.address())); // include automatic sitemap route | ||
server.route('get', '/sitemap.xml', async (req, res) => { | ||
server.route('get', `${baseUrl}/sitemap.xml`, async (req, res) => { | ||
let { | ||
@@ -203,0 +205,0 @@ default: glob |
@@ -34,3 +34,5 @@ import PercyClient from '@percy/client'; | ||
skipUploads, | ||
// implies `skipUploads` and also skips asset discovery | ||
// run without asset discovery | ||
skipDiscovery, | ||
// implies `skipUploads` and `skipDiscovery` | ||
dryRun, | ||
@@ -57,2 +59,3 @@ // implies `dryRun`, silent logs, and adds extra api endpoints | ||
this.skipUploads = this.dryRun || !!skipUploads; | ||
this.skipDiscovery = this.dryRun || !!skipDiscovery; | ||
this.delayUploads = this.skipUploads || !!delayUploads; | ||
@@ -155,3 +158,3 @@ this.deferUploads = this.delayUploads || !!deferUploads; | ||
async *start(options) { | ||
async *start() { | ||
// already starting or started | ||
@@ -199,7 +202,4 @@ if (this.readyState != null) return; | ||
if (!this.dryRun && (options === null || options === void 0 ? void 0 : options.browser) !== false) { | ||
yield this.browser.launch(); | ||
} // start the server after everything else is ready | ||
if (!this.skipDiscovery) yield this.browser.launch(); // start the server after everything else is ready | ||
yield (_this$server2 = this.server) === null || _this$server2 === void 0 ? void 0 : _this$server2.listen(); // mark instance as started | ||
@@ -241,4 +241,4 @@ | ||
yield* this.#snapshots.flush(s => { | ||
// do not log a count when not closing or while dry-running | ||
if (!close || this.dryRun) return; | ||
// do not log a count when not closing or if asset discovery is disabled | ||
if (!close || this.skipDiscovery) return; | ||
this.log.progress(`Processing ${s} snapshot${s !== 1 ? 's' : ''}...`, !!s); | ||
@@ -245,0 +245,0 @@ }); |
@@ -120,2 +120,4 @@ import logger from '@percy/logger'; | ||
export function validateSnapshotOptions(options) { | ||
var _migrated$baseUrl; | ||
// decide which schema to validate against | ||
@@ -129,6 +131,8 @@ let schema = ['domSnapshot', 'dom-snapshot', 'dom_snapshot'].some(k => k in options) && '/snapshot/dom' || 'url' in options && '/snapshot' || 'sitemap' in options && '/snapshot/sitemap' || 'serve' in options && '/snapshot/server' || 'snapshots' in options && '/snapshot/list' || '/snapshot'; | ||
...migrated | ||
} = PercyConfig.migrate(options, schema); // gather info for validating individual snapshot URLs | ||
} = PercyConfig.migrate(options, schema); // maintain a trailing slash for base URLs to normalize them | ||
if (((_migrated$baseUrl = migrated.baseUrl) === null || _migrated$baseUrl === void 0 ? void 0 : _migrated$baseUrl.endsWith('/')) === false) migrated.baseUrl += '/'; | ||
let baseUrl = schema === '/snapshot/server' ? 'http://localhost/' : migrated.baseUrl; // gather info for validating individual snapshot URLs | ||
let isSnapshot = schema === '/snapshot/dom' || schema === '/snapshot'; | ||
let baseUrl = schema === '/snapshot/server' ? 'http://localhost' : options.baseUrl; | ||
let snaps = isSnapshot ? [migrated] : Array.isArray(snapshots) ? snapshots : []; | ||
@@ -375,4 +379,11 @@ | ||
let resources = new Map(snapshot.domSnapshot && [createRootResource(snapshot.url, snapshot.domSnapshot)].map(resource => [resource.url, resource])); // open a new browser page | ||
let resources = new Map(snapshot.domSnapshot && [createRootResource(snapshot.url, snapshot.domSnapshot)].map(resource => [resource.url, resource])); // when no discovery browser is available, do not attempt to discover other resources | ||
if (percy.skipDiscovery && !snapshot.domSnapshot) { | ||
throw new Error('Cannot capture DOM snapshot when asset discovery is disabled'); | ||
} else if (percy.skipDiscovery) { | ||
return handleSnapshotResources(snapshot, resources, callback); | ||
} // open a new browser page | ||
let page = yield percy.browser.page({ | ||
@@ -379,0 +390,0 @@ enableJavaScript: snapshot.enableJavaScript ?? !snapshot.domSnapshot, |
{ | ||
"name": "@percy/core", | ||
"version": "1.9.1", | ||
"version": "1.10.0", | ||
"license": "MIT", | ||
@@ -42,6 +42,6 @@ "repository": { | ||
"dependencies": { | ||
"@percy/client": "1.9.1", | ||
"@percy/config": "1.9.1", | ||
"@percy/dom": "1.9.1", | ||
"@percy/logger": "1.9.1", | ||
"@percy/client": "1.10.0", | ||
"@percy/config": "1.10.0", | ||
"@percy/dom": "1.10.0", | ||
"@percy/logger": "1.10.0", | ||
"content-disposition": "^0.5.4", | ||
@@ -57,3 +57,3 @@ "cross-spawn": "^7.0.3", | ||
}, | ||
"gitHead": "b2ff5100698488c8bf8c681972f4f2b9a1e2055f" | ||
"gitHead": "a6934eda4fc3b84845ae606d7f5a901f25e0a56f" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
153217
3376
+ Added@percy/client@1.10.0(transitive)
+ Added@percy/config@1.10.0(transitive)
+ Added@percy/dom@1.10.0(transitive)
+ Added@percy/env@1.10.0(transitive)
+ Added@percy/logger@1.10.0(transitive)
- Removed@percy/client@1.9.1(transitive)
- Removed@percy/config@1.9.1(transitive)
- Removed@percy/dom@1.9.1(transitive)
- Removed@percy/env@1.9.1(transitive)
- Removed@percy/logger@1.9.1(transitive)
Updated@percy/client@1.10.0
Updated@percy/config@1.10.0
Updated@percy/dom@1.10.0
Updated@percy/logger@1.10.0