diff --git a/lerna.json b/lerna.json index 0f0274ed2..89fb8b634 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.18.0", + "version": "1.19.2-alpha.0", "packages": [ "packages/*" ], diff --git a/package.json b/package.json index 0e6ded240..89094e4b3 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,9 @@ "postinstall": "lerna run --stream postinstall", "test": "lerna run --stream --concurrency=1 test", "test:coverage": "lerna run --stream --concurrency=1 --no-bail test:coverage", - "test:types": "lerna run --parallel test:types" + "test:types": "lerna run --parallel test:types", + "global:link": "lerna exec -- yarn link", + "global:unlink": "lerna exec -- yarn unlink" }, "devDependencies": { "@babel/cli": "^7.11.6", diff --git a/packages/cli-app/package.json b/packages/cli-app/package.json index 6a32b7543..0e55fa6f4 100644 --- a/packages/cli-app/package.json +++ b/packages/cli-app/package.json @@ -1,6 +1,6 @@ { "name": "@percy/cli-app", - "version": "1.18.0", + "version": "1.19.2-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -32,7 +32,7 @@ ] }, "dependencies": { - "@percy/cli-command": "1.18.0", - "@percy/cli-exec": "1.18.0" + "@percy/cli-command": "1.19.2-alpha.0", + "@percy/cli-exec": "1.19.2-alpha.0" } } diff --git a/packages/cli-build/package.json b/packages/cli-build/package.json index aef697eb2..c4cfc0e38 100644 --- a/packages/cli-build/package.json +++ b/packages/cli-build/package.json @@ -1,6 +1,6 @@ { "name": "@percy/cli-build", - "version": "1.18.0", + "version": "1.19.2-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -32,6 +32,6 @@ ] }, "dependencies": { - "@percy/cli-command": "1.18.0" + "@percy/cli-command": "1.19.2-alpha.0" } } diff --git a/packages/cli-command/package.json b/packages/cli-command/package.json index 0681be792..94c925939 100644 --- a/packages/cli-command/package.json +++ b/packages/cli-command/package.json @@ -1,6 +1,6 @@ { "name": "@percy/cli-command", - "version": "1.18.0", + "version": "1.19.2-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -35,8 +35,8 @@ "test:coverage": "yarn test --coverage" }, "dependencies": { - "@percy/config": "1.18.0", - "@percy/core": "1.18.0", - "@percy/logger": "1.18.0" + "@percy/config": "1.19.2-alpha.0", + "@percy/core": "1.19.2-alpha.0", + "@percy/logger": "1.19.2-alpha.0" } } diff --git a/packages/cli-config/package.json b/packages/cli-config/package.json index 9c28e0b39..881b86cc9 100644 --- a/packages/cli-config/package.json +++ b/packages/cli-config/package.json @@ -1,6 +1,6 @@ { "name": "@percy/cli-config", - "version": "1.18.0", + "version": "1.19.2-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -32,6 +32,6 @@ ] }, "dependencies": { - "@percy/cli-command": "1.18.0" + "@percy/cli-command": "1.19.2-alpha.0" } } diff --git a/packages/cli-exec/package.json b/packages/cli-exec/package.json index e75ae73ca..63118c5e3 100644 --- a/packages/cli-exec/package.json +++ b/packages/cli-exec/package.json @@ -1,6 +1,6 @@ { "name": "@percy/cli-exec", - "version": "1.18.0", + "version": "1.19.2-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -32,7 +32,7 @@ ] }, "dependencies": { - "@percy/cli-command": "1.18.0", + "@percy/cli-command": "1.19.2-alpha.0", "cross-spawn": "^7.0.3", "which": "^2.0.2" } diff --git a/packages/cli-snapshot/package.json b/packages/cli-snapshot/package.json index c65e9a986..fef1bfa1d 100644 --- a/packages/cli-snapshot/package.json +++ b/packages/cli-snapshot/package.json @@ -1,6 +1,6 @@ { "name": "@percy/cli-snapshot", - "version": "1.18.0", + "version": "1.19.2-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -32,7 +32,7 @@ ] }, "dependencies": { - "@percy/cli-command": "1.18.0", + "@percy/cli-command": "1.19.2-alpha.0", "yaml": "^2.0.0" } } diff --git a/packages/cli-upload/package.json b/packages/cli-upload/package.json index 3ecc0818e..842e1f916 100644 --- a/packages/cli-upload/package.json +++ b/packages/cli-upload/package.json @@ -1,6 +1,6 @@ { "name": "@percy/cli-upload", - "version": "1.18.0", + "version": "1.19.2-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -32,7 +32,7 @@ ] }, "dependencies": { - "@percy/cli-command": "1.18.0", + "@percy/cli-command": "1.19.2-alpha.0", "fast-glob": "^3.2.11", "image-size": "^1.0.0" } diff --git a/packages/cli/README.md b/packages/cli/README.md index 953693e7c..6c60dbce5 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -60,6 +60,13 @@ use the following scripts for various development tasks: - `yarn readme` - generate cli commands readme usage - `yarn test` - run all tests, one package after another - `yarn test:coverage` - run all tests with coverage, one package after another +- `yarn global:link` - links all packages being developed as global. + - requires `yarn build` to be run before + - we can then consume this package using + `[npm|yarn] link @percy/[core|cli..]` + - **Note**: linking is only required once, subsequent changes for development requires running build command. + +- `yarn global:unlink` - unlinks all packages globally Individual package scripts can be invoked using yarn's [workspace](https://classic.yarnpkg.com/en/docs/cli/workspace/) command. For example: @@ -67,3 +74,31 @@ Individual package scripts can be invoked using yarn's ```sh-session $ yarn workspace @percy/core test ``` + + +## Publish + +Most of the repos have similar setup as CLI, steps as follows + +1. bump version + +``` +yarn bump-version +``` + +2. commit with following commit message => `:bookmark: vTAG` + +3. Draft a new release and publish it + +This will run release.yml workflow on github actions, which publishes the NPM packages + +### Publish with specific tag + +Currently release workflow only support publishing with latest tag. +To publish with alpha/any other TAG. + +1. follow till step 2 above and then run + +``` +yarn lerna publish from-package --dist-tag TAG +``` diff --git a/packages/cli/package.json b/packages/cli/package.json index 6f861792e..7a2b128dc 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@percy/cli", - "version": "1.18.0", + "version": "1.19.2-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -30,14 +30,14 @@ "test:coverage": "yarn test --coverage" }, "dependencies": { - "@percy/cli-app": "1.18.0", - "@percy/cli-build": "1.18.0", - "@percy/cli-command": "1.18.0", - "@percy/cli-config": "1.18.0", - "@percy/cli-exec": "1.18.0", - "@percy/cli-snapshot": "1.18.0", - "@percy/cli-upload": "1.18.0", - "@percy/client": "1.18.0", - "@percy/logger": "1.18.0" + "@percy/cli-app": "1.19.2-alpha.0", + "@percy/cli-build": "1.19.2-alpha.0", + "@percy/cli-command": "1.19.2-alpha.0", + "@percy/cli-config": "1.19.2-alpha.0", + "@percy/cli-exec": "1.19.2-alpha.0", + "@percy/cli-snapshot": "1.19.2-alpha.0", + "@percy/cli-upload": "1.19.2-alpha.0", + "@percy/client": "1.19.2-alpha.0", + "@percy/logger": "1.19.2-alpha.0" } } diff --git a/packages/client/package.json b/packages/client/package.json index 4d8c7a9cb..5578a3901 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@percy/client", - "version": "1.18.0", + "version": "1.19.2-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -31,7 +31,7 @@ "test:coverage": "yarn test --coverage" }, "dependencies": { - "@percy/env": "1.18.0", - "@percy/logger": "1.18.0" + "@percy/env": "1.19.2-alpha.0", + "@percy/logger": "1.19.2-alpha.0" } } diff --git a/packages/config/package.json b/packages/config/package.json index 904d39d9e..c8f495870 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -1,6 +1,6 @@ { "name": "@percy/config", - "version": "1.18.0", + "version": "1.19.2-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -34,7 +34,7 @@ "test:types": "tsd" }, "dependencies": { - "@percy/logger": "1.18.0", + "@percy/logger": "1.19.2-alpha.0", "ajv": "^8.6.2", "cosmiconfig": "^7.0.0", "yaml": "^2.0.0" diff --git a/packages/config/src/utils/normalize.js b/packages/config/src/utils/normalize.js index 56c197f5e..1b07c4c42 100644 --- a/packages/config/src/utils/normalize.js +++ b/packages/config/src/utils/normalize.js @@ -4,7 +4,8 @@ import { getSchema } from '../validate.js'; // Edge case camelizations const CAMELCASE_MAP = new Map([ ['css', 'CSS'], - ['javascript', 'JavaScript'] + ['javascript', 'JavaScript'], + ['dom', 'DOM'] ]); // Regular expression that matches words from boundaries or consecutive casing diff --git a/packages/config/test/index.test.js b/packages/config/test/index.test.js index 093281974..443b7f6e1 100644 --- a/packages/config/test/index.test.js +++ b/packages/config/test/index.test.js @@ -1100,14 +1100,16 @@ describe('PercyConfig', () => { 'foo_bar-baz': 'qux', 'Bar BAZ qux': 'xyzzy', 'percy-css': '', - 'enable-javascript': false + 'enable-javascript': false, + 'disable-shadow-dom': true })).toEqual({ fooBar: 'baz', foo: { barBaz: 'qux' }, fooBarBaz: 'qux', barBazQux: 'xyzzy', percyCSS: '', - enableJavaScript: false + enableJavaScript: false, + disableShadowDOM: true }); }); @@ -1117,13 +1119,15 @@ describe('PercyConfig', () => { foo: { bar_baz: 'qux' }, fooBar_baz: ['qux'], percyCSS: '', - enableJavaScript: false + enableJavaScript: false, + disableShadowDOM: true }, { kebab: true })).toEqual({ 'foo-bar': 'baz', foo: { 'bar-baz': 'qux' }, 'foo-bar-baz': ['qux'], 'percy-css': '', - 'enable-javascript': false + 'enable-javascript': false, + 'disable-shadow-dom': true }); }); @@ -1133,13 +1137,15 @@ describe('PercyConfig', () => { foo: { bar_baz: 'qux' }, fooBar_baz: ['qux'], percyCSS: '', - enableJavaScript: false + enableJavaScript: false, + disableShadowDOM: true }, { snake: true })).toEqual({ foo_bar: 'baz', foo: { bar_baz: 'qux' }, foo_bar_baz: ['qux'], percy_css: '', - enable_javascript: false + enable_javascript: false, + disable_shadow_dom: true }); }); diff --git a/packages/core/package.json b/packages/core/package.json index 487b46737..e906b2a51 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@percy/core", - "version": "1.18.0", + "version": "1.19.2-alpha.0", "license": "MIT", "repository": { "type": "git", @@ -39,10 +39,10 @@ "test:types": "tsd" }, "dependencies": { - "@percy/client": "1.18.0", - "@percy/config": "1.18.0", - "@percy/dom": "1.18.0", - "@percy/logger": "1.18.0", + "@percy/client": "1.19.2-alpha.0", + "@percy/config": "1.19.2-alpha.0", + "@percy/dom": "1.19.2-alpha.0", + "@percy/logger": "1.19.2-alpha.0", "content-disposition": "^0.5.4", "cross-spawn": "^7.0.3", "extract-zip": "^2.0.1", diff --git a/packages/core/src/config.js b/packages/core/src/config.js index 655e5779c..ea6c782d3 100644 --- a/packages/core/src/config.js +++ b/packages/core/src/config.js @@ -35,6 +35,10 @@ export const configSchema = { enableJavaScript: { type: 'boolean' }, + disableShadowDOM: { + type: 'boolean', + default: false + }, scope: { type: 'string' } @@ -149,6 +153,7 @@ export const snapshotSchema = { minHeight: { $ref: '/config/snapshot#/properties/minHeight' }, percyCSS: { $ref: '/config/snapshot#/properties/percyCSS' }, enableJavaScript: { $ref: '/config/snapshot#/properties/enableJavaScript' }, + disableShadowDOM: { $ref: '/config/snapshot#/properties/disableShadowDOM' }, discovery: { type: 'object', additionalProperties: false, diff --git a/packages/core/src/discovery.js b/packages/core/src/discovery.js index 6eced049b..67e5a7d94 100644 --- a/packages/core/src/discovery.js +++ b/packages/core/src/discovery.js @@ -34,6 +34,7 @@ function debugSnapshotOptions(snapshot) { debugProp(snapshot, 'widths', v => `${v}px`); debugProp(snapshot, 'minHeight', v => `${v}px`); debugProp(snapshot, 'enableJavaScript'); + debugProp(snapshot, 'disableShadowDOM'); debugProp(snapshot, 'deviceScaleFactor'); debugProp(snapshot, 'waitForTimeout'); debugProp(snapshot, 'waitForSelector'); diff --git a/packages/core/src/page.js b/packages/core/src/page.js index 1a47d200d..462a22fac 100644 --- a/packages/core/src/page.js +++ b/packages/core/src/page.js @@ -140,7 +140,7 @@ export class Page { execute, ...snapshot }) { - let { name, width, enableJavaScript } = snapshot; + let { name, width, enableJavaScript, disableShadowDOM } = snapshot; this.log.debug(`Taking snapshot: ${name}${width ? ` @${width}px` : ''}`, this.meta); // wait for any specified timeout @@ -181,7 +181,7 @@ export class Page { /* eslint-disable-next-line no-undef */ domSnapshot: PercyDOM.serialize(options), url: document.URL - }), { enableJavaScript }); + }), { enableJavaScript, disableShadowDOM }); return { ...snapshot, ...capture }; } diff --git a/packages/core/test/discovery.test.js b/packages/core/test/discovery.test.js index c85ac55d8..00b01261e 100644 --- a/packages/core/test/discovery.test.js +++ b/packages/core/test/discovery.test.js @@ -305,7 +305,8 @@ describe('Discovery', () => { await percy.snapshot({ name: 'test event snapshot', url: 'http://localhost:8000/events', - enableJavaScript: true + enableJavaScript: true, + disableShadowDOM: true }); await percy.idle(); diff --git a/packages/core/test/percy.test.js b/packages/core/test/percy.test.js index c43200b13..4b349846c 100644 --- a/packages/core/test/percy.test.js +++ b/packages/core/test/percy.test.js @@ -56,7 +56,8 @@ describe('Percy', () => { expect(percy.config.snapshot).toEqual({ widths: [375, 1280], minHeight: 1024, - percyCSS: '' + percyCSS: '', + disableShadowDOM: false }); }); @@ -76,7 +77,8 @@ describe('Percy', () => { execute() { let p = document.querySelector('p'); p.textContent = p.textContent.replace('Hello', 'Hello there,'); - } + }, + disableShadowDOM: true }); expect(snapshot.url).toEqual('http://localhost:8000/'); diff --git a/packages/core/types/index.d.ts b/packages/core/types/index.d.ts index 97767687c..19439d61b 100644 --- a/packages/core/types/index.d.ts +++ b/packages/core/types/index.d.ts @@ -38,6 +38,7 @@ interface CommonSnapshotOptions { minHeight?: number; percyCSS?: string; enableJavaScript?: boolean; + disableShadowDOM?: boolean; devicePixelRatio?: number; scope?: string; } diff --git a/packages/dom/README.md b/packages/dom/README.md index 8f49b72aa..fcbd2788f 100644 --- a/packages/dom/README.md +++ b/packages/dom/README.md @@ -37,6 +37,7 @@ const domSnapshot = await page.evaluate(() => PercyDOM.serialize(options)) - `enableJavaScript` — When true, does not serialize some DOM elements - `domTransformation` — Function to transform the DOM after serialization +- `disableShadowDOM` — disable shadow DOM capturing, this option can be passed to `percySnapshot` its part of per-snapshot config. ## Serialized Content @@ -71,7 +72,44 @@ Videos without a `poster` attribute will have the current frame of the video serialized into an image and set as the `poster` attribute automatically. This is to ensure videos have a stable image to display when screenshots are captured. +### Shadow DOM + +Shadow dom `#shadow-root (open)` is serialized into declarative shadow DOM (`