@blockquote/create-wc 1.0.0 → 1.4.0
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/CHANGELOG.md +1 -0
- package/README.md +53 -50
- package/package.json +20 -20
- package/src/Generator.js +3 -1
- package/src/app/gatherMixins.js +26 -12
- package/src/app/index.js +29 -18
- package/src/common-linting/index.js +18 -0
- package/src/common-linting/templates/package.json +41 -0
- package/src/common-repo/index.js +8 -0
- package/src/common-repo/templates/gitignore +1 -0
- package/src/common-repo/templates/package.json +19 -17
- 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/package.json +5 -12
- package/src/wc-lit-element-ts/index.js +91 -0
- package/src/wc-lit-element-ts/templates/package.json +24 -0
- package/src/wc-lit-element/templates/MyEl.js +0 -38
- package/src/wc-lit-element/templates/my-el.js +0 -3
- package/src/wc-lit-element/templates/partials/README.demoing.md +0 -13
- package/src/wc-lit-element/templates/partials/README.linting.md +0 -13
- package/src/wc-lit-element/templates/partials/README.testing.md +0 -13
- package/src/wc-lit-element/templates/static/README.md +0 -35
- package/src/wc-lit-element/templates/static/demo/index.html +0 -29
- package/src/wc-lit-element/templates/static/index.js +0 -1
- package/src/wc-lit-element/templates/styles/MyEl-styles.js +0 -16
|
@@ -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,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
|
+
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { html, LitElement } from 'lit';
|
|
2
|
-
import styles from './styles/<%= className %>-styles.js';
|
|
3
|
-
|
|
4
|
-
export class <%= className %> extends LitElement {
|
|
5
|
-
static get is() {
|
|
6
|
-
return '<%= tagName %>';
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
static get styles() {
|
|
10
|
-
return [styles];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
static get properties() {
|
|
14
|
-
return {
|
|
15
|
-
heading: { type: String },
|
|
16
|
-
counter: { type: Number },
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
constructor() {
|
|
21
|
-
super();
|
|
22
|
-
this.heading = 'Hey there';
|
|
23
|
-
this.counter = 5;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
__increment() {
|
|
27
|
-
this.counter += 1;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
render() {
|
|
31
|
-
return html`
|
|
32
|
-
<h2>
|
|
33
|
-
${this.heading} (<span><slot></slot></span>) ${this.counter}
|
|
34
|
-
</h2>
|
|
35
|
-
<button @click=${this.__increment}>increment</button>
|
|
36
|
-
`;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
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
|
-
<%= featureReadmes %>
|
|
24
|
-
|
|
25
|
-
## Tooling configs
|
|
26
|
-
|
|
27
|
-
For most of the tools, the configuration is in the `package.json` to minimize the amount of files in your project.
|
|
28
|
-
|
|
29
|
-
If you customize the configuration a lot, you can consider moving them to individual files.
|
|
30
|
-
|
|
31
|
-
## Local Demo with `vite`
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
npm start
|
|
35
|
-
```
|
|
@@ -1,29 +0,0 @@
|
|
|
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 %>.js';
|
|
17
|
-
|
|
18
|
-
const heading = 'Hello owc World!';
|
|
19
|
-
render(
|
|
20
|
-
html`
|
|
21
|
-
<<%= tagName %> .heading=${heading}>
|
|
22
|
-
some light-dom
|
|
23
|
-
</<%= tagName %>>
|
|
24
|
-
`,
|
|
25
|
-
document.querySelector('#demo')
|
|
26
|
-
);
|
|
27
|
-
</script>
|
|
28
|
-
</body>
|
|
29
|
-
</html>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { <%= className %> } from './src/<%= className %>.js';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
|
-
import { css } from 'lit';
|
|
3
|
-
|
|
4
|
-
export default css`:host {
|
|
5
|
-
display: block;
|
|
6
|
-
box-sizing: border-box;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
:host([hidden]), [hidden] {
|
|
10
|
-
display: none !important;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
*, *:before, *:after {
|
|
14
|
-
box-sizing: inherit;
|
|
15
|
-
}
|
|
16
|
-
`;
|