From dd1fef63058c59319f310de4326e971bee930409 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Tue, 15 Aug 2023 23:59:52 -0700 Subject: [PATCH 1/5] feat(base): add static version property --- .eslintignore | 4 +++- .gitignore | 3 +++ .husky/pre-commit | 5 ++++- package.json | 7 +++++-- tools/.eslintrc.json | 6 ++++++ tools/base/src/Base.ts | 5 ++++- tools/base/src/version.d.ts | 12 ++++++++++++ tools/base/src/version.js | 2 ++ tools/base/test/base.test.ts | 4 ++++ yarn.lock | 27 +++++++++++++++++++++++++++ 10 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 tools/base/src/version.d.ts create mode 100644 tools/base/src/version.js diff --git a/.eslintignore b/.eslintignore index 98693c504e..bb58e833ca 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,4 +2,6 @@ packages/**/*.d.ts packages/*/node_modules/**/* tools/**/*.d.ts tools/*/node_modules/**/* -config/* \ No newline at end of file +config/* +!tools/base/src/version.d.ts +!tools/base/src/version.js diff --git a/.gitignore b/.gitignore index ec57979171..dfa0fd6560 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,9 @@ tools/**/*.test-vrt.ts !tools/*/test/global.d.ts !tools/*/global.d.ts !tools/*/local.d.ts +!tools/base/src/version.js +!tools/base/src/version.d.ts + .wireit diff --git a/.husky/pre-commit b/.husky/pre-commit index 4216c9ecde..007dc6fbc0 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -2,7 +2,10 @@ . "$(dirname "$0")/_/husky.sh" STAGED_FILES_TO_LINT=$(git diff --name-only --cached --diff-filter=d -- "*.ts" "*.js") +VERSION_FILE=$(dirname "$0")/../tools/base/src/version.js yarn eslint -f pretty $STAGED_FILES_TO_LINT yarn analyze yarn lint:css -yarn pretty-quick --staged \ No newline at end of file +yarn pretty-quick --staged +yarn genversion --es6 --semi $VERSION_FILE +git add $VERSION_FILE diff --git a/package.json b/package.json index ff3b7eb86d..9e755fa163 100644 --- a/package.json +++ b/package.json @@ -150,6 +150,7 @@ "fast-glob": "^3.2.12", "fs-extra": "^11.1.1", "geckodriver": "4.2.0", + "genversion": "^3.1.1", "gh-pages": "^4.0.0", "gunzip-maybe": "^1.4.2", "husky": "^8.0.3", @@ -253,7 +254,8 @@ "!test/visual/rollup.config.js", "!test/visual/src/review.js", "!test/visual/src/index.html", - "!test/visual/wds-vrt.config.js" + "!test/visual/wds-vrt.config.js", + "!tools/base/src/version.js" ], "clean": "if-file-deleted" }, @@ -271,7 +273,8 @@ "output": [ "packages/**/*.d.ts", "tools/**/*.d.ts", - "!**/local.d.ts" + "!**/local.d.ts", + "!tools/base/src/version.d.ts" ], "clean": "if-file-deleted" }, diff --git a/tools/.eslintrc.json b/tools/.eslintrc.json index 44d4544fb6..893c5fb235 100644 --- a/tools/.eslintrc.json +++ b/tools/.eslintrc.json @@ -105,6 +105,12 @@ } ] } + }, + { + "files": ["./base/src/version.js"], + "rules": { + "notice/notice": "off" + } } ] } diff --git a/tools/base/src/Base.ts b/tools/base/src/Base.ts index ae92f3c8e5..22236a8a72 100644 --- a/tools/base/src/Base.ts +++ b/tools/base/src/Base.ts @@ -11,6 +11,7 @@ governing permissions and limitations under the License. */ import { LitElement, ReactiveElement } from 'lit'; +import { version } from './version'; type ThemeRoot = HTMLElement & { startManagingContentDirection: (el: HTMLElement) => void; stopManagingContentDirection: (el: HTMLElement) => void; @@ -183,7 +184,9 @@ export function SpectrumMixin>( return SpectrumMixinElement; } -export class SpectrumElement extends SpectrumMixin(LitElement) {} +export class SpectrumElement extends SpectrumMixin(LitElement) { + static VERSION = version; +} if (window.__swc.DEBUG) { const ignoreWarningTypes = { diff --git a/tools/base/src/version.d.ts b/tools/base/src/version.d.ts new file mode 100644 index 0000000000..0387422091 --- /dev/null +++ b/tools/base/src/version.d.ts @@ -0,0 +1,12 @@ +/* +Copyright 2023 Adobe. All rights reserved. +This file is licensed to you under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. You may obtain a copy +of the License at http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under +the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +OF ANY KIND, either express or implied. See the License for the specific language +governing permissions and limitations under the License. +*/ +export declare const version: string; diff --git a/tools/base/src/version.js b/tools/base/src/version.js new file mode 100644 index 0000000000..07d20326c3 --- /dev/null +++ b/tools/base/src/version.js @@ -0,0 +1,2 @@ +// Generated by genversion. +export const version = '0.35.0'; diff --git a/tools/base/test/base.test.ts b/tools/base/test/base.test.ts index 8b1780ab74..1a28da5116 100644 --- a/tools/base/test/base.test.ts +++ b/tools/base/test/base.test.ts @@ -10,6 +10,7 @@ governing permissions and limitations under the License. */ import { SpectrumElement } from '@spectrum-web-components/base'; import { elementUpdated, expect, fixture, html } from '@open-wc/testing'; +import { version } from '../src/version'; class DirElement extends SpectrumElement {} @@ -32,4 +33,7 @@ describe('Base', () => { expect(el.dir).to.equal('rtl'); expect(el.isLTR).to.be.false; }); + it('has a static VERSION property', () => { + expect(DirElement.VERSION).to.equal(version); + }); }); diff --git a/yarn.lock b/yarn.lock index 3bb8522fba..ced3db7ad4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13250,6 +13250,13 @@ find-my-way@^7.6.0: fast-querystring "^1.0.0" safe-regex2 "^2.0.0" +find-package@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/find-package/-/find-package-1.0.0.tgz#d7738da67e3c5f055c24d3e19aa1aeed063c3e83" + integrity sha512-yVn71XCCaNgxz58ERTl8nA/8YYtIQDY9mHSrgFBfiFtdNNfY0h183Vh8BRkKxD8x9TUw3ec290uJKhDVxqGZBw== + dependencies: + parents "^1.0.1" + find-replace@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/find-replace/-/find-replace-3.0.0.tgz#3e7e23d3b05167a76f770c9fbd5258b0def68c38" @@ -13650,6 +13657,14 @@ gensync@^1.0.0-beta.1, gensync@^1.0.0-beta.2: resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg== +genversion@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/genversion/-/genversion-3.1.1.tgz#5da18c1ea21813b560f923b37dbbb0df528b7c06" + integrity sha512-/H861PMsihhjgX2qqhTN8egM11V04imhA+3JRFY3jjPua2Sy1NqaqqQPjSP8rdM9jZoKpFhVj9g3Fs9XPCjBYQ== + dependencies: + commander "^7.2.0" + find-package "^1.0.0" + get-amd-module-type@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/get-amd-module-type/-/get-amd-module-type-5.0.1.tgz#bef38ea3674e1aa1bda9c59c8b0da598582f73f2" @@ -20613,6 +20628,13 @@ parent-module@^1.0.0: dependencies: callsites "^3.0.0" +parents@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/parents/-/parents-1.0.1.tgz#fedd4d2bf193a77745fe71e371d73c3307d9c751" + integrity sha512-mXKF3xkoUt5td2DoxpLmtOmZvko9VfFpwRwkKDHSNvgmpLAeBo18YDhcPbBzJq+QLCHMbGOfzia2cX4U+0v9Mg== + dependencies: + path-platform "~0.11.15" + parse-conflict-json@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/parse-conflict-json/-/parse-conflict-json-2.0.2.tgz#3d05bc8ffe07d39600dc6436c6aefe382033d323" @@ -20915,6 +20937,11 @@ path-parse@^1.0.6, path-parse@^1.0.7: resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== +path-platform@~0.11.15: + version "0.11.15" + resolved "https://registry.yarnpkg.com/path-platform/-/path-platform-0.11.15.tgz#e864217f74c36850f0852b78dc7bf7d4a5721bf2" + integrity sha512-Y30dB6rab1A/nfEKsZxmr01nUotHX0c/ZiIAsCTatEe1CmS5Pm5He7fZ195bPT7RdquoaL8lLxFCMQi/bS7IJg== + path-root-regex@^0.1.0: version "0.1.2" resolved "https://registry.yarnpkg.com/path-root-regex/-/path-root-regex-0.1.2.tgz#bfccdc8df5b12dc52c8b43ec38d18d72c04ba96d" From 2512a52d20dde17860ac7df6dbed760e816b8e14 Mon Sep 17 00:00:00 2001 From: Ravi Sharma Date: Thu, 24 Aug 2023 11:33:28 +0530 Subject: [PATCH 2/5] chore: version update by commit --- tools/base/src/version.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/base/src/version.js b/tools/base/src/version.js index 07d20326c3..142cb1f40e 100644 --- a/tools/base/src/version.js +++ b/tools/base/src/version.js @@ -1,2 +1,2 @@ // Generated by genversion. -export const version = '0.35.0'; +export const version = '0.37.0'; From 52a2ff93a1e0c56fa4c68a16718a2b177e132357 Mon Sep 17 00:00:00 2001 From: Ravi Sharma Date: Fri, 8 Sep 2023 14:33:15 +0530 Subject: [PATCH 3/5] refactor: added version.js to eslintignore and updated file extensions --- .eslintignore | 3 +-- tools/base/package.json | 4 ++++ tools/base/src/Base.ts | 2 +- tools/base/src/version.js | 2 +- tools/base/test/base.test.ts | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.eslintignore b/.eslintignore index bb58e833ca..d57f09885e 100644 --- a/.eslintignore +++ b/.eslintignore @@ -3,5 +3,4 @@ packages/*/node_modules/**/* tools/**/*.d.ts tools/*/node_modules/**/* config/* -!tools/base/src/version.d.ts -!tools/base/src/version.js +tools/base/src/version.js diff --git a/tools/base/package.json b/tools/base/package.json index 9a4c8d6136..1dda80ef4b 100644 --- a/tools/base/package.json +++ b/tools/base/package.json @@ -65,6 +65,10 @@ "development": "./src/streaming-listener.dev.js", "default": "./src/streaming-listener.js" }, + "./src/version.js": { + "development": "./src/version.dev.js", + "default": "./src/version.js" + }, "./condition-attribute-with-id.js": { "development": "./condition-attribute-with-id.dev.js", "default": "./condition-attribute-with-id.js" diff --git a/tools/base/src/Base.ts b/tools/base/src/Base.ts index 22236a8a72..e4b5e1f507 100644 --- a/tools/base/src/Base.ts +++ b/tools/base/src/Base.ts @@ -11,7 +11,7 @@ governing permissions and limitations under the License. */ import { LitElement, ReactiveElement } from 'lit'; -import { version } from './version'; +import { version } from './version.js'; type ThemeRoot = HTMLElement & { startManagingContentDirection: (el: HTMLElement) => void; stopManagingContentDirection: (el: HTMLElement) => void; diff --git a/tools/base/src/version.js b/tools/base/src/version.js index 142cb1f40e..1e7e8c63b8 100644 --- a/tools/base/src/version.js +++ b/tools/base/src/version.js @@ -1,2 +1,2 @@ // Generated by genversion. -export const version = '0.37.0'; +export const version = '0.38.0'; diff --git a/tools/base/test/base.test.ts b/tools/base/test/base.test.ts index 1a28da5116..70b6ce6237 100644 --- a/tools/base/test/base.test.ts +++ b/tools/base/test/base.test.ts @@ -10,7 +10,7 @@ governing permissions and limitations under the License. */ import { SpectrumElement } from '@spectrum-web-components/base'; import { elementUpdated, expect, fixture, html } from '@open-wc/testing'; -import { version } from '../src/version'; +import { version } from '../src/version.js'; class DirElement extends SpectrumElement {} From 432f106b88a5247b6882f5ccd2c0007a19b8ff59 Mon Sep 17 00:00:00 2001 From: Ravi Sharma Date: Fri, 8 Sep 2023 21:25:26 +0530 Subject: [PATCH 4/5] fix(base): fixed unit test case & removed development condition from version.js --- tasks/hydrate-export-maps.js | 5 +++-- tools/base/package.json | 5 +---- tools/base/src/Base.ts | 2 +- tools/base/test/base.test.ts | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/tasks/hydrate-export-maps.js b/tasks/hydrate-export-maps.js index 42f8bb3ab7..272cfc4692 100644 --- a/tasks/hydrate-export-maps.js +++ b/tasks/hydrate-export-maps.js @@ -41,7 +41,7 @@ const excludes = [ * } * - explodes wildcards * - excludes files in the `excludes` list above - * - does not expose `development` conditions on `*.css.js` files + * - does not expose `development` conditions on `*.css.js` files & version.js file * - saves back into the `package.json` without linting * */ @@ -85,7 +85,8 @@ const hydrateExportMap = async (exportMapPath) => { if ( key.endsWith('.css.js') || exportMapResolved[key].endsWith('.css.js') || - (key !== '.' && !key.endsWith('.js')) + (key !== '.' && !key.endsWith('.js')) || + key.search('version.js') > -1 ) { // simple map for assets without "development" versions exportMapExploded[key] = exportMapResolved[key]; diff --git a/tools/base/package.json b/tools/base/package.json index 1dda80ef4b..ae375a3a74 100644 --- a/tools/base/package.json +++ b/tools/base/package.json @@ -65,10 +65,7 @@ "development": "./src/streaming-listener.dev.js", "default": "./src/streaming-listener.js" }, - "./src/version.js": { - "development": "./src/version.dev.js", - "default": "./src/version.js" - }, + "./src/version.js": "./src/version.js", "./condition-attribute-with-id.js": { "development": "./condition-attribute-with-id.dev.js", "default": "./condition-attribute-with-id.js" diff --git a/tools/base/src/Base.ts b/tools/base/src/Base.ts index e4b5e1f507..cb7fa39fc0 100644 --- a/tools/base/src/Base.ts +++ b/tools/base/src/Base.ts @@ -11,7 +11,7 @@ governing permissions and limitations under the License. */ import { LitElement, ReactiveElement } from 'lit'; -import { version } from './version.js'; +import { version } from '@spectrum-web-components/base/src/version.js'; type ThemeRoot = HTMLElement & { startManagingContentDirection: (el: HTMLElement) => void; stopManagingContentDirection: (el: HTMLElement) => void; diff --git a/tools/base/test/base.test.ts b/tools/base/test/base.test.ts index 70b6ce6237..0921f37d2e 100644 --- a/tools/base/test/base.test.ts +++ b/tools/base/test/base.test.ts @@ -10,7 +10,7 @@ governing permissions and limitations under the License. */ import { SpectrumElement } from '@spectrum-web-components/base'; import { elementUpdated, expect, fixture, html } from '@open-wc/testing'; -import { version } from '../src/version.js'; +import { version } from '@spectrum-web-components/base/src/version.js'; class DirElement extends SpectrumElement {} From 0071ff71319f817f1da9be61597b148d200d6067 Mon Sep 17 00:00:00 2001 From: Ravi Sharma Date: Fri, 8 Sep 2023 23:48:16 +0530 Subject: [PATCH 5/5] refactor: removed notice rule override as version.js has been added to .eslintignore --- tools/.eslintrc.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tools/.eslintrc.json b/tools/.eslintrc.json index 893c5fb235..44d4544fb6 100644 --- a/tools/.eslintrc.json +++ b/tools/.eslintrc.json @@ -105,12 +105,6 @@ } ] } - }, - { - "files": ["./base/src/version.js"], - "rules": { - "notice/notice": "off" - } } ] }