My app
- -Edit src/OwcApp.js and save to reload.
diff --git a/owc-app/.editorconfig b/owc-app/.editorconfig deleted file mode 100644 index c8c2d2a..0000000 --- a/owc-app/.editorconfig +++ /dev/null @@ -1,29 +0,0 @@ -# EditorConfig helps developers define and maintain consistent -# coding styles between different editors and IDEs -# editorconfig.org - -root = true - - -[*] - -# Change these settings to your own preference -indent_style = space -indent_size = 2 - -# We recommend you to keep these unchanged -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[*.md] -trim_trailing_whitespace = false - -[*.json] -indent_size = 2 - -[*.{html,js,md}] -block_comment_start = /** -block_comment = * -block_comment_end = */ diff --git a/owc-app/.gitignore b/owc-app/.gitignore deleted file mode 100644 index f3d7ea0..0000000 --- a/owc-app/.gitignore +++ /dev/null @@ -1,20 +0,0 @@ -## editors -/.idea -/.vscode - -## system files -.DS_Store - -## npm -/node_modules/ -/npm-debug.log - -## testing -/coverage/ - -## temp folders -/.tmp/ - -# build -/_site/ -/dist/ diff --git a/owc-app/LICENSE b/owc-app/LICENSE deleted file mode 100644 index 7246e5a..0000000 --- a/owc-app/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2019 owc-app - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/owc-app/README.md b/owc-app/README.md deleted file mode 100644 index f62e851..0000000 --- a/owc-app/README.md +++ /dev/null @@ -1,30 +0,0 @@ -
-
-
Edit src/OwcApp.js and save to reload.
Edit src/<%= className %>.js and save to reload.
Edit src/<%= className %>.js and save to reload.
Slotted content
`, +}; +SlottedContent.argTypes = { + slot: { table: { disable: true } }, +}; diff --git a/src/generators/demoing-storybook-ts/templates/static/.storybook/main.js b/src/generators/demoing-storybook-ts/templates/static/.storybook/main.js index c926a24..cbdd056 100644 --- a/src/generators/demoing-storybook-ts/templates/static/.storybook/main.js +++ b/src/generators/demoing-storybook-ts/templates/static/.storybook/main.js @@ -1,14 +1,3 @@ module.exports = { - stories: ['../stories/**/*.stories.{js,md,mdx}'], - addons: [ - 'storybook-prebuilt/addon-knobs/register.js', - 'storybook-prebuilt/addon-docs/register.js', - 'storybook-prebuilt/addon-viewport/register.js', - ], - esDevServer: { - // custom es-dev-server options - nodeResolve: true, - watch: true, - open: true - }, + stories: ['../dist/stories/**/*.stories.{js,md,mdx}'], }; diff --git a/src/generators/demoing-storybook-ts/templates/static/.storybook/preview.js b/src/generators/demoing-storybook-ts/templates/static/.storybook/preview.js deleted file mode 100644 index 2cc90bb..0000000 --- a/src/generators/demoing-storybook-ts/templates/static/.storybook/preview.js +++ /dev/null @@ -1,17 +0,0 @@ -import { addParameters, setCustomElements } from '@open-wc/demoing-storybook'; - -addParameters({ - docs: { - iframeHeight: '200px', - } -}); - -async function run() { - const customElements = await ( - await fetch(new URL('../custom-elements.json', import.meta.url)) - ).json(); - - setCustomElements(customElements); -} - -run(); diff --git a/src/generators/demoing-storybook-ts/templates/static/.storybook/server.mjs b/src/generators/demoing-storybook-ts/templates/static/.storybook/server.mjs new file mode 100644 index 0000000..c24942b --- /dev/null +++ b/src/generators/demoing-storybook-ts/templates/static/.storybook/server.mjs @@ -0,0 +1,8 @@ +import { storybookPlugin } from '@web/dev-server-storybook'; +import baseConfig from '../web-dev-server.config.mjs'; + +export default /** @type {import('@web/dev-server').DevServerConfig} */ ({ + ...baseConfig, + open: '/', + plugins: [...baseConfig.plugins, storybookPlugin({ type: 'web-components' })], +}); diff --git a/src/generators/demoing-storybook/templates/_package.json b/src/generators/demoing-storybook/templates/_package.json index 201434e..61ca8d6 100644 --- a/src/generators/demoing-storybook/templates/_package.json +++ b/src/generators/demoing-storybook/templates/_package.json @@ -1,9 +1,9 @@ { "scripts": { - "storybook": "start-storybook", + "storybook": "web-dev-server -c .storybook/server.mjs", "storybook:build": "build-storybook" }, "devDependencies": { - "@open-wc/demoing-storybook": "^2.0.0" + "@web/dev-server-storybook": "^0.3.2" } } diff --git a/src/generators/demoing-storybook/templates/static-scaffold/stories/index.stories.js b/src/generators/demoing-storybook/templates/static-scaffold/stories/index.stories.js new file mode 100644 index 0000000..feec9e7 --- /dev/null +++ b/src/generators/demoing-storybook/templates/static-scaffold/stories/index.stories.js @@ -0,0 +1,44 @@ +import { html } from 'lit-html'; +import '../<%= tagName %>.js'; + +export default { + title: '<%= className %>', + component: '<%= tagName %>', + argTypes: { + title: { control: 'text' }, + counter: { control: 'number' }, + textColor: { control: 'color' }, + }, +}; + +function Template({ title = 'Hello world', counter = 5, textColor, slot }) { + return html` + <<%= tagName %> + style="--<%= tagName %>-text-color: ${textColor || 'black'}" + .title=${title} + .counter=${counter} + > + ${slot} + <%= tagName %>> + `; +} + +export const Regular = Template.bind({}); + +export const CustomTitle = Template.bind({}); +CustomTitle.args = { + title: 'My title', +}; + +export const CustomCounter = Template.bind({}); +CustomCounter.args = { + counter: 123456, +}; + +export const SlottedContent = Template.bind({}); +SlottedContent.args = { + slot: html`Slotted content
`, +}; +SlottedContent.argTypes = { + slot: { table: { disable: true } }, +}; diff --git a/src/generators/demoing-storybook/templates/static-scaffold/stories/index.stories.md b/src/generators/demoing-storybook/templates/static-scaffold/stories/index.stories.md deleted file mode 100644 index e807928..0000000 --- a/src/generators/demoing-storybook/templates/static-scaffold/stories/index.stories.md +++ /dev/null @@ -1,48 +0,0 @@ -```js script -import { html } from '@open-wc/demoing-storybook'; -import '../<%= tagName %>.js'; - -export default { - title: '<%= className %>', - component: '<%= tagName %>', - options: { selectedPanel: "storybookjs/knobs/panel" }, -}; -``` - -# <%= className %> - -A component for... - -## Features: - -- a -- b -- ... - -## How to use - -### Installation - -```bash -yarn add <%= tagName %> -``` - -```js -import '<%= tagName %>/<%= tagName %>.js'; -``` - -```js preview-story -export const Simple = () => html` - <<%= tagName %>><%= tagName %>> -`; -``` - -## Variations - -###### Custom Title - -```js preview-story -export const CustomTitle = () => html` - <<%= tagName %> title="Hello World"><%= tagName %>> -`; -``` diff --git a/src/generators/demoing-storybook/templates/static/.storybook/main.js b/src/generators/demoing-storybook/templates/static/.storybook/main.js index c926a24..b3a4c59 100644 --- a/src/generators/demoing-storybook/templates/static/.storybook/main.js +++ b/src/generators/demoing-storybook/templates/static/.storybook/main.js @@ -1,14 +1,3 @@ module.exports = { stories: ['../stories/**/*.stories.{js,md,mdx}'], - addons: [ - 'storybook-prebuilt/addon-knobs/register.js', - 'storybook-prebuilt/addon-docs/register.js', - 'storybook-prebuilt/addon-viewport/register.js', - ], - esDevServer: { - // custom es-dev-server options - nodeResolve: true, - watch: true, - open: true - }, }; diff --git a/src/generators/demoing-storybook/templates/static/.storybook/preview.js b/src/generators/demoing-storybook/templates/static/.storybook/preview.js deleted file mode 100644 index 2cc90bb..0000000 --- a/src/generators/demoing-storybook/templates/static/.storybook/preview.js +++ /dev/null @@ -1,17 +0,0 @@ -import { addParameters, setCustomElements } from '@open-wc/demoing-storybook'; - -addParameters({ - docs: { - iframeHeight: '200px', - } -}); - -async function run() { - const customElements = await ( - await fetch(new URL('../custom-elements.json', import.meta.url)) - ).json(); - - setCustomElements(customElements); -} - -run(); diff --git a/src/generators/demoing-storybook/templates/static/.storybook/server.mjs b/src/generators/demoing-storybook/templates/static/.storybook/server.mjs new file mode 100644 index 0000000..c24942b --- /dev/null +++ b/src/generators/demoing-storybook/templates/static/.storybook/server.mjs @@ -0,0 +1,8 @@ +import { storybookPlugin } from '@web/dev-server-storybook'; +import baseConfig from '../web-dev-server.config.mjs'; + +export default /** @type {import('@web/dev-server').DevServerConfig} */ ({ + ...baseConfig, + open: '/', + plugins: [...baseConfig.plugins, storybookPlugin({ type: 'web-components' })], +}); diff --git a/src/generators/linting-eslint-ts/templates/_.eslintrc.js b/src/generators/linting-eslint-ts/templates/_.eslintrc.js deleted file mode 100644 index c4cfa86..0000000 --- a/src/generators/linting-eslint-ts/templates/_.eslintrc.js +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = { - root: true, - parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint', 'import', 'html'], - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/eslint-recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:import/errors', - 'plugin:import/warnings', - ], - rules: { - // disable the rule for all files - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/no-non-null-assertion': 'off', - 'import/named': 'off', - 'import/no-unresolved': 'off', - 'import/extensions': ['error', 'always', { ignorePackages: true }], - }, -}; \ No newline at end of file diff --git a/src/generators/linting-eslint-ts/templates/_package.json b/src/generators/linting-eslint-ts/templates/_package.json index bcf036e..7291cb5 100644 --- a/src/generators/linting-eslint-ts/templates/_package.json +++ b/src/generators/linting-eslint-ts/templates/_package.json @@ -1,17 +1,19 @@ { - "scripts": { - "lint:eslint": "eslint --ext .ts,.html . --ignore-path .gitignore", - "format:eslint": "eslint --ext .ts,.html . --fix --ignore-path .gitignore" - }, "devDependencies": { "eslint": "^6.1.0", - "@open-wc/eslint-config": "^4.0.0", - "@typescript-eslint/eslint-plugin": "^2.20.0", - "@typescript-eslint/parser": "^2.20.0" + "@open-wc/eslint-config": "^4.2.0", + "@typescript-eslint/parser": "^2.20.0", + "@typescript-eslint/eslint-plugin": "^2.20.0" }, "eslintConfig": { - "extends": [ - "@open-wc/eslint-config" - ] + "parser": "@typescript-eslint/parser", + "extends": ["@open-wc/eslint-config"], + "plugins": ["@typescript-eslint"], + "rules": { + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": ["error"], + "import/no-unresolved": "off", + "import/extensions": ["error", "always", { "ignorePackages": true }] + } } } diff --git a/src/generators/linting-eslint/templates/_package.json b/src/generators/linting-eslint/templates/_package.json index 36e2ed5..ee725eb 100644 --- a/src/generators/linting-eslint/templates/_package.json +++ b/src/generators/linting-eslint/templates/_package.json @@ -1,11 +1,7 @@ { - "scripts": { - "lint:eslint": "eslint --ext .js,.html . --ignore-path .gitignore", - "format:eslint": "eslint --ext .js,.html . --fix --ignore-path .gitignore" - }, "devDependencies": { "eslint": "^6.1.0", - "@open-wc/eslint-config": "^4.0.0" + "@open-wc/eslint-config": "^4.2.0" }, "eslintConfig": { "extends": [ diff --git a/src/generators/linting-prettier-ts/templates/_package.json b/src/generators/linting-prettier-ts/templates/_package.json index aef2c21..bb6b45a 100644 --- a/src/generators/linting-prettier-ts/templates/_package.json +++ b/src/generators/linting-prettier-ts/templates/_package.json @@ -1,8 +1,4 @@ { - "scripts": { - "lint:prettier": "prettier \"**/*.js\" \"**/*.ts\" --check --ignore-path .gitignore", - "format:prettier": "prettier \"**/*.js\" \"**/*.ts\" --write --ignore-path .gitignore" - }, "devDependencies": { "prettier": "^2.0.4", "eslint-config-prettier": "^6.11.0" diff --git a/src/generators/linting-prettier/templates/_package.json b/src/generators/linting-prettier/templates/_package.json index f26ac3d..bb6b45a 100644 --- a/src/generators/linting-prettier/templates/_package.json +++ b/src/generators/linting-prettier/templates/_package.json @@ -1,8 +1,4 @@ { - "scripts": { - "lint:prettier": "prettier \"**/*.js\" --check --ignore-path .gitignore", - "format:prettier": "prettier \"**/*.js\" --write --ignore-path .gitignore" - }, "devDependencies": { "prettier": "^2.0.4", "eslint-config-prettier": "^6.11.0" diff --git a/src/generators/linting-ts/templates/_package.json b/src/generators/linting-ts/templates/_package.json index 1dc1998..df8a13d 100644 --- a/src/generators/linting-ts/templates/_package.json +++ b/src/generators/linting-ts/templates/_package.json @@ -12,8 +12,8 @@ ] }, "scripts": { - "lint": "npm run lint:eslint && npm run lint:prettier", - "format": "npm run format:eslint && npm run format:prettier" + "lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore", + "format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore" }, "devDependencies": { "husky": "^1.0.0", diff --git a/src/generators/linting/templates/_package.json b/src/generators/linting/templates/_package.json index 9ad72fd..9c242ad 100644 --- a/src/generators/linting/templates/_package.json +++ b/src/generators/linting/templates/_package.json @@ -12,8 +12,8 @@ ] }, "scripts": { - "lint": "npm run lint:eslint && npm run lint:prettier", - "format": "npm run format:eslint && npm run format:prettier" + "lint": "eslint --ext .js,.html . --ignore-path .gitignore && prettier \"**/*.js\" --check --ignore-path .gitignore", + "format": "eslint --ext .js,.html . --fix --ignore-path .gitignore && prettier \"**/*.js\" --write --ignore-path .gitignore" }, "devDependencies": { "husky": "^1.0.0", diff --git a/src/generators/testing-ts/templates/_my-el.test.ts b/src/generators/testing-ts/templates/_my-el.test.ts index 6e137cc..dbbc091 100644 --- a/src/generators/testing-ts/templates/_my-el.test.ts +++ b/src/generators/testing-ts/templates/_my-el.test.ts @@ -1,39 +1,31 @@ import { html, fixture, expect } from '@open-wc/testing'; -import {<%= className %>} from '../src/<%= className %>.js'; +import { <%= className %> } from '../src/<%= className %>.js'; import '../<%= tagName %>.js'; describe('<%= className %>', () => { it('has a default title "Hey there" and counter 5', async () => { - const el: <%= className %> = await fixture(html` - <<%= tagName %>><%= tagName %>> - `); + const el = await fixture<<%= className %>>(html`<<%= tagName %>><%= tagName %>>`); expect(el.title).to.equal('Hey there'); expect(el.counter).to.equal(5); }); it('increases the counter on button click', async () => { - const el: <%= className %> = await fixture(html` - <<%= tagName %>><%= tagName %>> - `); + const el = await fixture<<%= className %>>(html`<<%= tagName %>><%= tagName %>>`); el.shadowRoot!.querySelector('button')!.click(); expect(el.counter).to.equal(6); }); it('can override the title via attribute', async () => { - const el: <%= className %> = await fixture(html` - <<%= tagName %> title="attribute title"><%= tagName %>> - `); + const el = await fixture<<%= className %>>(html`<<%= tagName %> title="attribute title"><%= tagName %>>`); expect(el.title).to.equal('attribute title'); }); it('passes the a11y audit', async () => { - const el: <%= className %> = await fixture(html` - <<%= tagName %>><%= tagName %>> - `); + const el = await fixture<<%= className %>>(html`<<%= tagName %>><%= tagName %>>`); await expect(el).shadowDom.to.be.accessible(); }); diff --git a/src/generators/testing-wtr-ts/templates/_package.json b/src/generators/testing-wtr-ts/templates/_package.json index 97d64f9..dfdff2e 100644 --- a/src/generators/testing-wtr-ts/templates/_package.json +++ b/src/generators/testing-wtr-ts/templates/_package.json @@ -1,9 +1,9 @@ { "scripts": { - "test": "tsc && web-test-runner --coverage", - "test:watch": "web-test-runner --watch" + "test": "tsc && wtr --coverage", + "test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\"" }, "devDependencies": { - "@web/test-runner": "^0.7.41" + "@web/test-runner": "^0.11.5" } } \ No newline at end of file diff --git a/src/generators/testing-wtr-ts/templates/static/web-test-runner.config.mjs b/src/generators/testing-wtr-ts/templates/static/web-test-runner.config.mjs index 6f07564..2e57b01 100644 --- a/src/generators/testing-wtr-ts/templates/static/web-test-runner.config.mjs +++ b/src/generators/testing-wtr-ts/templates/static/web-test-runner.config.mjs @@ -1,4 +1,29 @@ -export default { - files: 'dist/**/test/**/*.test.js', - nodeResolve: true -}; \ No newline at end of file +// import { playwrightLauncher } from '@web/test-runner-playwright'; + +export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({ + files: 'dist/test/**/*.test.js', + nodeResolve: true, + + /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */ + // esbuildTarget: 'auto', + + /** Confgure bare import resolve plugin */ + // nodeResolve: { + // exportConditions: ['browser', 'development'] + // }, + + /** Amount of browsers to run concurrently */ + // concurrentBrowsers: 2, + + /** Amount of test files per browser to test concurrently */ + // concurrency: 1, + + /** Browsers to run tests on */ + // browsers: [ + // playwrightLauncher({ product: 'chromium' }), + // playwrightLauncher({ product: 'firefox' }), + // playwrightLauncher({ product: 'webkit' }), + // ], + + // See documentation for all available options +}); diff --git a/src/generators/testing-wtr/templates/_package.json b/src/generators/testing-wtr/templates/_package.json index fbd8ad8..56ad249 100644 --- a/src/generators/testing-wtr/templates/_package.json +++ b/src/generators/testing-wtr/templates/_package.json @@ -4,6 +4,6 @@ "test:watch": "web-test-runner --watch" }, "devDependencies": { - "@web/test-runner": "^0.7.41" + "@web/test-runner": "^0.11.5" } } \ No newline at end of file diff --git a/src/generators/testing-wtr/templates/static/web-test-runner.config.mjs b/src/generators/testing-wtr/templates/static/web-test-runner.config.mjs index bbb5f73..93ec00e 100644 --- a/src/generators/testing-wtr/templates/static/web-test-runner.config.mjs +++ b/src/generators/testing-wtr/templates/static/web-test-runner.config.mjs @@ -1,4 +1,29 @@ -export default { +// import { playwrightLauncher } from '@web/test-runner-playwright'; + +export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({ files: 'test/**/*.test.js', - nodeResolve: true -}; \ No newline at end of file + nodeResolve: true, + + /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */ + // esbuildTarget: 'auto', + + /** Confgure bare import resolve plugin */ + // nodeResolve: { + // exportConditions: ['browser', 'development'] + // }, + + /** Amount of browsers to run concurrently */ + // concurrentBrowsers: 2, + + /** Amount of test files per browser to test concurrently */ + // concurrency: 1, + + /** Browsers to run tests on */ + // browsers: [ + // playwrightLauncher({ product: 'chromium' }), + // playwrightLauncher({ product: 'firefox' }), + // playwrightLauncher({ product: 'webkit' }), + // ], + + // See documentation for all available options +}); diff --git a/src/generators/testing/templates/_my-el.test.js b/src/generators/testing/templates/_my-el.test.js index 7efe9e0..b9a800a 100644 --- a/src/generators/testing/templates/_my-el.test.js +++ b/src/generators/testing/templates/_my-el.test.js @@ -4,35 +4,27 @@ import '../<%= tagName %>.js'; describe('<%= className %>', () => { it('has a default title "Hey there" and counter 5', async () => { - const el = await fixture(html` - <<%= tagName %>><%= tagName %>> - `); + const el = await fixture(html`<<%= tagName %>><%= tagName %>>`); expect(el.title).to.equal('Hey there'); expect(el.counter).to.equal(5); }); it('increases the counter on button click', async () => { - const el = await fixture(html` - <<%= tagName %>><%= tagName %>> - `); + const el = await fixture(html`<<%= tagName %>><%= tagName %>>`); el.shadowRoot.querySelector('button').click(); expect(el.counter).to.equal(6); }); it('can override the title via attribute', async () => { - const el = await fixture(html` - <<%= tagName %> title="attribute title"><%= tagName %>> - `); + const el = await fixture(html`<<%= tagName %> title="attribute title"><%= tagName %>>`); expect(el.title).to.equal('attribute title'); }); it('passes the a11y audit', async () => { - const el = await fixture(html` - <<%= tagName %>><%= tagName %>> - `); + const el = await fixture(html`<<%= tagName %>><%= tagName %>>`); await expect(el).shadowDom.to.be.accessible(); }); diff --git a/src/generators/wc-lit-element-ts/templates/_MyEl.ts b/src/generators/wc-lit-element-ts/templates/_MyEl.ts index 90a65d1..01550bd 100644 --- a/src/generators/wc-lit-element-ts/templates/_MyEl.ts +++ b/src/generators/wc-lit-element-ts/templates/_MyEl.ts @@ -1,7 +1,7 @@ import { html, css, LitElement, property } from 'lit-element'; export class <%= className %> extends LitElement { - static styles =css` + static styles = css` :host { display: block; padding: 25px; @@ -9,9 +9,9 @@ export class <%= className %> extends LitElement { } `; - @property({type: String}) title = 'Hey there'; + @property({ type: String }) title = 'Hey there'; - @property({type: Number}) counter = 5; + @property({ type: Number }) counter = 5; __increment() { this.counter += 1; diff --git a/src/generators/wc-lit-element-ts/templates/_package.json b/src/generators/wc-lit-element-ts/templates/_package.json index a5f652e..c81a1a3 100644 --- a/src/generators/wc-lit-element-ts/templates/_package.json +++ b/src/generators/wc-lit-element-ts/templates/_package.json @@ -2,8 +2,8 @@ "main": "dist/index.js", "module": "dist/index.js", "scripts": { - "start": "concurrently --kill-others --names tsc,web-dev-server \"npm run tsc:watch\" \"web-dev-server --app-index demo/index.html --node-resolve --open --watch\"", - "tsc:watch": "tsc --watch", + "start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"", + "build": "tsc", "prepublish": "tsc" }, "dependencies": { @@ -11,10 +11,9 @@ "lit-element": "^2.2.1" }, "devDependencies": { - "@types/node": "13.11.1", - "@web/dev-server": "^0.0.12", - "typescript": "~4.0.3", - "concurrently": "^5.1.0", - "tslib": "^1.11.0" + "@web/dev-server": "^0.1.1", + "concurrently": "^5.3.0", + "typescript": "^4.1.3", + "tslib": "^2.0.3" } } diff --git a/src/generators/wc-lit-element-ts/templates/static/web-dev-server.config.mjs b/src/generators/wc-lit-element-ts/templates/static/web-dev-server.config.mjs new file mode 100644 index 0000000..f44a6d2 --- /dev/null +++ b/src/generators/wc-lit-element-ts/templates/static/web-dev-server.config.mjs @@ -0,0 +1,28 @@ +// import { hmrPlugin, presets } from '@open-wc/dev-server-hmr'; + +/** Use Hot Module replacement by adding --hmr to the start command */ +const hmr = process.argv.includes('--hmr'); + +export default /** @type {import('@web/dev-server').DevServerConfig} */ ({ + nodeResolve: true, + open: '/demo/', + watch: !hmr, + + /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */ + // esbuildTarget: 'auto' + + /** Set appIndex to enable SPA routing */ + // appIndex: 'demo/index.html', + + /** Confgure bare import resolve plugin */ + // nodeResolve: { + // exportConditions: ['browser', 'development'] + // }, + + plugins: [ + /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */ + // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }), + ], + + // See documentation for all available options +}); diff --git a/src/generators/wc-lit-element/templates/_package.json b/src/generators/wc-lit-element/templates/_package.json index ec2c3a6..da9381c 100644 --- a/src/generators/wc-lit-element/templates/_package.json +++ b/src/generators/wc-lit-element/templates/_package.json @@ -2,13 +2,13 @@ "main": "index.js", "module": "index.js", "scripts": { - "start": "web-dev-server --app-index demo/index.html --node-resolve --open --watch" + "start": "web-dev-server" }, "dependencies": { "lit-html": "^1.1.2", "lit-element": "^2.2.1" }, "devDependencies": { - "@web/dev-server": "^0.0.12" + "@web/dev-server": "^0.1.1" } } \ No newline at end of file diff --git a/src/generators/wc-lit-element/templates/static/web-dev-server.config.mjs b/src/generators/wc-lit-element/templates/static/web-dev-server.config.mjs new file mode 100644 index 0000000..f44a6d2 --- /dev/null +++ b/src/generators/wc-lit-element/templates/static/web-dev-server.config.mjs @@ -0,0 +1,28 @@ +// import { hmrPlugin, presets } from '@open-wc/dev-server-hmr'; + +/** Use Hot Module replacement by adding --hmr to the start command */ +const hmr = process.argv.includes('--hmr'); + +export default /** @type {import('@web/dev-server').DevServerConfig} */ ({ + nodeResolve: true, + open: '/demo/', + watch: !hmr, + + /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */ + // esbuildTarget: 'auto' + + /** Set appIndex to enable SPA routing */ + // appIndex: 'demo/index.html', + + /** Confgure bare import resolve plugin */ + // nodeResolve: { + // exportConditions: ['browser', 'development'] + // }, + + plugins: [ + /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */ + // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }), + ], + + // See documentation for all available options +}); diff --git a/test/snapshots/fully-loaded-app/.gitignore b/test/snapshots/fully-loaded-app/.gitignore index cd190ee..ee91b02 100644 --- a/test/snapshots/fully-loaded-app/.gitignore +++ b/test/snapshots/fully-loaded-app/.gitignore @@ -18,4 +18,6 @@ # build /_site/ /dist/ -/out-tsc/ \ No newline at end of file +/out-tsc/ + +storybook-static \ No newline at end of file diff --git a/test/snapshots/fully-loaded-app/.storybook/main.js b/test/snapshots/fully-loaded-app/.storybook/main.js index 1a4258d..94f9cf8 100644 --- a/test/snapshots/fully-loaded-app/.storybook/main.js +++ b/test/snapshots/fully-loaded-app/.storybook/main.js @@ -1,14 +1,3 @@ module.exports = { stories: ['../**/stories/*.stories.{js,md,mdx}'], - addons: [ - 'storybook-prebuilt/addon-knobs/register.js', - 'storybook-prebuilt/addon-docs/register.js', - 'storybook-prebuilt/addon-viewport/register.js', - ], - esDevServer: { - // custom es-dev-server options - nodeResolve: true, - watch: true, - open: true - }, }; diff --git a/test/snapshots/fully-loaded-app/.storybook/preview.js b/test/snapshots/fully-loaded-app/.storybook/preview.js deleted file mode 100644 index 2cc90bb..0000000 --- a/test/snapshots/fully-loaded-app/.storybook/preview.js +++ /dev/null @@ -1,17 +0,0 @@ -import { addParameters, setCustomElements } from '@open-wc/demoing-storybook'; - -addParameters({ - docs: { - iframeHeight: '200px', - } -}); - -async function run() { - const customElements = await ( - await fetch(new URL('../custom-elements.json', import.meta.url)) - ).json(); - - setCustomElements(customElements); -} - -run(); diff --git a/test/snapshots/fully-loaded-app/.storybook/server.mjs b/test/snapshots/fully-loaded-app/.storybook/server.mjs new file mode 100644 index 0000000..c24942b --- /dev/null +++ b/test/snapshots/fully-loaded-app/.storybook/server.mjs @@ -0,0 +1,8 @@ +import { storybookPlugin } from '@web/dev-server-storybook'; +import baseConfig from '../web-dev-server.config.mjs'; + +export default /** @type {import('@web/dev-server').DevServerConfig} */ ({ + ...baseConfig, + open: '/', + plugins: [...baseConfig.plugins, storybookPlugin({ type: 'web-components' })], +}); diff --git a/test/snapshots/fully-loaded-app/package.json b/test/snapshots/fully-loaded-app/package.json index 05fc718..4183945 100644 --- a/test/snapshots/fully-loaded-app/package.json +++ b/test/snapshots/fully-loaded-app/package.json @@ -1,34 +1,39 @@ { - "scripts": { - "lint:eslint": "eslint --ext .js,.html . --ignore-path .gitignore", - "format:eslint": "eslint --ext .js,.html . --fix --ignore-path .gitignore", - "lint:prettier": "prettier \"**/*.js\" --check --ignore-path .gitignore", - "format:prettier": "prettier \"**/*.js\" --write --ignore-path .gitignore", - "lint": "npm run lint:eslint && npm run lint:prettier", - "format": "npm run format:eslint && npm run format:prettier", - "test": "web-test-runner --coverage", - "test:watch": "web-test-runner --watch", - "storybook": "start-storybook", - "storybook:build": "build-storybook", - "build": "rimraf dist && rollup -c rollup.config.js", - "start:build": "npm run build && web-dev-server --root-dir dist --app-index index.html --open --compatibility none", - "start": "web-dev-server --app-index index.html --node-resolve --open --watch" - }, "devDependencies": { "eslint": "^6.1.0", - "@open-wc/eslint-config": "^4.0.0", + "@open-wc/eslint-config": "^4.2.0", "prettier": "^2.0.4", "eslint-config-prettier": "^6.11.0", "husky": "^1.0.0", "lint-staged": "^10.0.0", - "@web/test-runner": "^0.7.41", + "@web/test-runner": "^0.11.5", "@open-wc/testing": "^2.0.0", - "@open-wc/demoing-storybook": "^2.0.0", + "@web/dev-server-storybook": "^0.3.2", "@open-wc/building-rollup": "^1.0.0", "deepmerge": "^4.2.2", "rimraf": "^2.6.3", "rollup": "^2.3.4", - "@web/dev-server": "^0.0.12" + "@web/dev-server": "^0.1.1" + }, + "scripts": { + "lint": "eslint --ext .js,.html . --ignore-path .gitignore && prettier \"**/*.js\" --check --ignore-path .gitignore", + "format": "eslint --ext .js,.html . --fix --ignore-path .gitignore && prettier \"**/*.js\" --write --ignore-path .gitignore", + "test": "web-test-runner --coverage", + "test:watch": "web-test-runner --watch", + "storybook": "web-dev-server -c .storybook/server.mjs", + "storybook:build": "build-storybook", + "build": "rimraf dist && rollup -c rollup.config.js", + "start:build": "npm run build && web-dev-server --root-dir dist --app-index index.html --open --compatibility none", + "start": "web-dev-server" + }, + "name": "scaffold-app", + "version": "0.0.0", + "description": "Webcomponent scaffold-app following open-wc recommendations", + "author": "scaffold-app", + "license": "MIT", + "dependencies": { + "lit-html": "^1.0.0", + "lit-element": "^2.0.1" }, "eslintConfig": { "extends": [ @@ -51,14 +56,5 @@ "prettier --write", "git add" ] - }, - "name": "scaffold-app", - "version": "0.0.0", - "description": "Webcomponent scaffold-app following open-wc recommendations", - "author": "scaffold-app", - "license": "MIT", - "dependencies": { - "lit-html": "^1.0.0", - "lit-element": "^2.0.1" } } \ No newline at end of file diff --git a/test/snapshots/fully-loaded-app/rollup.config.js b/test/snapshots/fully-loaded-app/rollup.config.js index babc0bf..f71b49b 100644 --- a/test/snapshots/fully-loaded-app/rollup.config.js +++ b/test/snapshots/fully-loaded-app/rollup.config.js @@ -28,4 +28,4 @@ export default merge(baseConfig, { // alternatively, you can use your JS as entrypoint for rollup and // optionally set a HTML template manually // input: './app.js', -}); \ No newline at end of file +}); diff --git a/test/snapshots/fully-loaded-app/src/ScaffoldApp.js b/test/snapshots/fully-loaded-app/src/ScaffoldApp.js index 08e2b58..a05882d 100644 --- a/test/snapshots/fully-loaded-app/src/ScaffoldApp.js +++ b/test/snapshots/fully-loaded-app/src/ScaffoldApp.js @@ -5,7 +5,6 @@ export class ScaffoldApp extends LitElement { static get properties() { return { title: { type: String }, - page: { type: String }, }; } @@ -22,6 +21,7 @@ export class ScaffoldApp extends LitElement { max-width: 960px; margin: 0 auto; text-align: center; + background-color: var(--scaffold-app-background-color); } main { @@ -53,11 +53,16 @@ export class ScaffoldApp extends LitElement { `; } + constructor() { + super(); + this.title = 'My app'; + } + render() { return html`Edit src/ScaffoldApp.js and save to reload.