@blockquote/create-wc 1.1.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -50
- package/package.json +20 -20
- package/src/Generator.js +3 -1
- package/src/app/gatherMixins.js +26 -9
- package/src/app/index.js +10 -1
- package/src/common-linting/index.js +18 -0
- package/src/common-linting/templates/package.json +41 -0
- package/src/common-repo/index.js +7 -0
- package/src/common-repo/templates/gitignore +1 -0
- package/src/common-repo/templates/package.json +18 -16
- package/src/{wc-lit-element → common-repo}/templates/static/index.html +1 -1
- package/src/{wc-lit-element → common-repo}/templates/static/vite.config.js +28 -24
- package/src/{wc-lit-element → common-repo}/templates/static/web-dev-server.config.mjs +0 -0
- package/src/{wc-lit-element → common-repo}/templates/styles/MyEl.scss +1 -0
- package/src/common-testing-wtr/index.js +14 -0
- package/src/common-testing-wtr/templates/static/web-test-runner.config.mjs +69 -0
- package/src/linting/index.js +27 -0
- package/src/linting/templates/package.json +1 -0
- package/src/linting-eslint/index.js +17 -0
- package/src/linting-eslint/templates/package.json +1 -0
- package/src/linting-eslint-ts/index.js +17 -0
- package/src/linting-eslint-ts/templates/package.json +17 -0
- package/src/linting-prettier/index.js +17 -0
- package/src/linting-prettier/templates/package.json +1 -0
- package/src/linting-prettier-ts/index.js +17 -0
- package/src/linting-prettier-ts/templates/package.json +1 -0
- package/src/linting-ts/index.js +21 -0
- package/src/linting-ts/templates/package.json +1 -0
- package/src/testing/templates/my-el.test.js +1 -1
- package/src/testing/templates/package.json +2 -1
- package/src/testing-ts/index.js +32 -0
- package/src/testing-ts/templates/my-el.test.ts +62 -0
- package/src/testing-ts/templates/package.json +6 -0
- package/src/testing-wtr/index.js +1 -1
- package/src/testing-wtr/templates/package.json +3 -6
- package/src/testing-wtr/templates/static/{web-test-runner.config.mjs → _web-test-runner.config.mjs} +0 -0
- package/src/testing-wtr-ts/index.js +19 -0
- package/src/testing-wtr-ts/templates/package.json +6 -0
- package/src/testing-wtr-ts/templates/static/_web-test-runner.config.mjs +67 -0
- package/src/wc-lit-element/index.js +0 -6
- package/src/wc-lit-element/templates/MyEl.js +27 -8
- package/src/wc-lit-element/templates/my-el.js +1 -1
- package/src/wc-lit-element/templates/package.json +5 -12
- package/src/wc-lit-element/templates/static/README.md +3 -3
- package/src/wc-lit-element/templates/static/demo/index.html +21 -25
- package/src/wc-lit-element/templates/styles/MyEl-styles.js +15 -11
- package/src/wc-lit-element-ts/index.js +91 -0
- package/src/wc-lit-element-ts/templates/MyEl.ts +46 -0
- package/src/wc-lit-element-ts/templates/my-el.ts +3 -0
- package/src/wc-lit-element-ts/templates/package.json +24 -0
- package/src/wc-lit-element-ts/templates/partials/README.demoing.md +13 -0
- package/src/wc-lit-element-ts/templates/partials/README.linting.md +13 -0
- package/src/wc-lit-element-ts/templates/partials/README.testing.md +13 -0
- package/src/wc-lit-element-ts/templates/static/README.md +35 -0
- package/src/wc-lit-element-ts/templates/static/demo/index.html +25 -0
- package/src/wc-lit-element-ts/templates/static/index.ts +1 -0
- package/src/wc-lit-element-ts/templates/styles/MyEl-styles.ts +20 -0
- package/src/wc-lit-element-ts/templates/tsconfig.json +27 -0
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
/* eslint-disable no-unused-vars */
|
|
2
2
|
import { css } from 'lit';
|
|
3
3
|
|
|
4
|
-
export default css
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export default css`
|
|
5
|
+
:host {
|
|
6
|
+
display: block;
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
}
|
|
8
9
|
|
|
9
|
-
:host([hidden]),
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
:host([hidden]),
|
|
11
|
+
[hidden] {
|
|
12
|
+
display: none !important;
|
|
13
|
+
}
|
|
12
14
|
|
|
13
|
-
*,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
*,
|
|
16
|
+
*:before,
|
|
17
|
+
*:after {
|
|
18
|
+
box-sizing: inherit;
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/* eslint-disable max-classes-per-file */
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { join, dirname } from 'path';
|
|
4
|
+
import { processTemplate, readFileFromPath } from '@open-wc/create/dist/core.js';
|
|
5
|
+
import { CommonRepoMixin } from '../common-repo/index.js';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
|
|
10
|
+
const compose = (...fns) =>
|
|
11
|
+
fns.reduce(
|
|
12
|
+
(f, g) =>
|
|
13
|
+
(...args) =>
|
|
14
|
+
f(g(...args)),
|
|
15
|
+
);
|
|
16
|
+
const safeReduce = (f, initial) => (xs) => Array.isArray(xs) ? xs.reduce(f, initial) : xs;
|
|
17
|
+
|
|
18
|
+
const getTemplatePart = compose(processTemplate, readFileFromPath);
|
|
19
|
+
|
|
20
|
+
function featureReadmeBlurb(feature) {
|
|
21
|
+
const path = join(__dirname, `./templates/partials/README.${feature}.md`);
|
|
22
|
+
return getTemplatePart(path);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function featureReadme(acc, feature, i, a) {
|
|
26
|
+
return `${acc + featureReadmeBlurb(feature)}${i === a.length - 1 ? '' : '\n'}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const safeFeatureReadme = safeReduce(featureReadme, '');
|
|
30
|
+
|
|
31
|
+
/* eslint-disable no-console */
|
|
32
|
+
export const TsWcLitElementMixin = (subclass) =>
|
|
33
|
+
class extends subclass {
|
|
34
|
+
async execute() {
|
|
35
|
+
this.templateData.featureReadmes = safeFeatureReadme(this.options.features);
|
|
36
|
+
|
|
37
|
+
await super.execute();
|
|
38
|
+
const { tagName, className } = this.templateData;
|
|
39
|
+
|
|
40
|
+
// write & rename el class template
|
|
41
|
+
this.copyTemplate(
|
|
42
|
+
`${__dirname}/templates/MyEl.ts`,
|
|
43
|
+
this.destinationPath(`src/${className}.ts`),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// write & rename el styles template
|
|
47
|
+
this.copyTemplate(
|
|
48
|
+
`${__dirname}/templates/styles/MyEl-styles.ts`,
|
|
49
|
+
this.destinationPath(`src/styles/${className}-styles.ts`),
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
// write & rename el registration template
|
|
53
|
+
this.copyTemplate(
|
|
54
|
+
`${__dirname}/templates/my-el.ts`,
|
|
55
|
+
this.destinationPath(`define/${tagName}.ts`),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
await this.copyTemplates(`${__dirname}/templates/static/**/*`);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const TsWcLitElementPackageMixin = (subclass) =>
|
|
63
|
+
class extends CommonRepoMixin(TsWcLitElementMixin(subclass)) {
|
|
64
|
+
async execute() {
|
|
65
|
+
await super.execute();
|
|
66
|
+
// write & rename package.json
|
|
67
|
+
this.copyTemplateJsonInto(
|
|
68
|
+
`${__dirname}/templates/package.json`,
|
|
69
|
+
this.destinationPath('package.json'),
|
|
70
|
+
);
|
|
71
|
+
this.copyTemplate(
|
|
72
|
+
`${__dirname}/templates/custom-elements.json`,
|
|
73
|
+
this.destinationPath('custom-elements.json'),
|
|
74
|
+
);
|
|
75
|
+
this.copyTemplate(
|
|
76
|
+
`${__dirname}/templates/tsconfig.json`,
|
|
77
|
+
this.destinationPath('tsconfig.json'),
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async end() {
|
|
82
|
+
await super.end();
|
|
83
|
+
console.log('');
|
|
84
|
+
console.log('You are all set up now!');
|
|
85
|
+
console.log('');
|
|
86
|
+
console.log('All you need to do is run:');
|
|
87
|
+
console.log(` cd ${this.templateData.tagName}`);
|
|
88
|
+
console.log(' npm run start');
|
|
89
|
+
console.log('');
|
|
90
|
+
}
|
|
91
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { html, LitElement } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import styles from './styles/<%= className %>-styles.js';
|
|
4
|
+
|
|
5
|
+
export class <%= className %> extends LitElement {
|
|
6
|
+
static get is() {
|
|
7
|
+
return '<%= tagName %>';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
static override styles = [styles];
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The heading to say "Hello" to.
|
|
14
|
+
*/
|
|
15
|
+
@property({ type: String })
|
|
16
|
+
heading = 'Hey there';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The number of times the button has been clicked.
|
|
20
|
+
*/
|
|
21
|
+
@property({ type: Number })
|
|
22
|
+
counter = 5;
|
|
23
|
+
|
|
24
|
+
override render() {
|
|
25
|
+
return html`
|
|
26
|
+
<h1>${this.sayHello(this.heading)}!</h1>
|
|
27
|
+
<button @click=${this._onClick}>Counter: ${this.counter}</button>
|
|
28
|
+
<hr />
|
|
29
|
+
<slot></slot>
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private _onClick() {
|
|
34
|
+
this.counter += 1;
|
|
35
|
+
this.dispatchEvent(new CustomEvent('counter-changed'));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Formats a greeting
|
|
40
|
+
* @param heading The heading to say "Hello" to
|
|
41
|
+
* @returns {string} A greeting directed at `heading`
|
|
42
|
+
*/
|
|
43
|
+
sayHello(heading: string): string {
|
|
44
|
+
return `Hello, ${heading}`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"main": "dist/index.js",
|
|
3
|
+
"module": "dist/index.js",
|
|
4
|
+
"files": [
|
|
5
|
+
"/dist/",
|
|
6
|
+
"/dist/index.*",
|
|
7
|
+
"!/dist/test/"
|
|
8
|
+
],
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./dist/index.js",
|
|
11
|
+
"./<%= tagName %>.js": "./dist/define/<%= tagName %>.js"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"start:wds": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"npm:sass:watch\" \"npm:wds\"",
|
|
15
|
+
"wds": "web-dev-server",
|
|
16
|
+
"sass:watch": "sass-style-template -j ts",
|
|
17
|
+
"build": "npm run build:tsc && npm run dev:vite",
|
|
18
|
+
"build:tsc": "tsc"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"typescript": "^4.4.4",
|
|
22
|
+
"tslib": "^2.3.1"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# \<<%= tagName %>>
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i <%= tagName %>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<script type="module">
|
|
17
|
+
import '<%= tagName %>/<%= tagName %>.js';
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<<%= tagName %>></<%= tagName %>>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Tooling configs
|
|
24
|
+
|
|
25
|
+
For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
|
|
26
|
+
|
|
27
|
+
If you customize the configuration a lot, you can consider moving them to individual files.
|
|
28
|
+
|
|
29
|
+
## Local Demo with `vite`
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm start
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
To run a local development server that serves the basic demo located in demo/index.html
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<style>
|
|
6
|
+
body {
|
|
7
|
+
background: #fafafa;
|
|
8
|
+
}
|
|
9
|
+
</style>
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<div id="demo"></div>
|
|
13
|
+
|
|
14
|
+
<script type="module">
|
|
15
|
+
import { html, render } from 'lit';
|
|
16
|
+
import '../define/<%= tagName %>.ts';
|
|
17
|
+
|
|
18
|
+
const heading = 'World!';
|
|
19
|
+
render(
|
|
20
|
+
html`<<%= tagName %> .heading=${heading}>some light-dom</<%= tagName %>>`,
|
|
21
|
+
document.querySelector('#demo'),
|
|
22
|
+
);
|
|
23
|
+
</script>
|
|
24
|
+
</body>
|
|
25
|
+
</html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { <%= className %> } from './src/<%= className %>.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
import { css } from 'lit';
|
|
3
|
+
|
|
4
|
+
export default css`
|
|
5
|
+
:host {
|
|
6
|
+
display: block;
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
:host([hidden]),
|
|
11
|
+
[hidden] {
|
|
12
|
+
display: none !important;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
*,
|
|
16
|
+
*:before,
|
|
17
|
+
*:after {
|
|
18
|
+
box-sizing: inherit;
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2019",
|
|
4
|
+
"module": "es2020",
|
|
5
|
+
"lib": ["es2020", "DOM", "DOM.Iterable"],
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": true,
|
|
8
|
+
"sourceMap": true,
|
|
9
|
+
"inlineSources": true,
|
|
10
|
+
"outDir": "./dist",
|
|
11
|
+
"rootDirs": ["./src", "./define", ".test/"],
|
|
12
|
+
"strict": true,
|
|
13
|
+
"noUnusedLocals": true,
|
|
14
|
+
"noUnusedParameters": true,
|
|
15
|
+
"noImplicitReturns": true,
|
|
16
|
+
"noFallthroughCasesInSwitch": true,
|
|
17
|
+
"noImplicitAny": true,
|
|
18
|
+
"noImplicitThis": true,
|
|
19
|
+
"moduleResolution": "node",
|
|
20
|
+
"allowSyntheticDefaultImports": true,
|
|
21
|
+
"experimentalDecorators": true,
|
|
22
|
+
"forceConsistentCasingInFileNames": true,
|
|
23
|
+
"noImplicitOverride": true
|
|
24
|
+
},
|
|
25
|
+
"include": ["src/**/*.ts", "define/**/*.ts", "test/**/*.ts", "./index.ts"],
|
|
26
|
+
"exclude": []
|
|
27
|
+
}
|