@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
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# create-blockquote-wc
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Web Component with Lit
|
|
1
|
+
# Web Component with Lit - Scaffolding
|
|
2
2
|
|
|
3
3
|
This scaffold generator extends and customizes the core parts of [@open-wc/create](https://open-wc.org/docs/development/generator/#extending) providing a starting point for creating a web component with [Lit](https://lit.dev/).
|
|
4
4
|
|
|
@@ -14,12 +14,18 @@ This scaffold generator extends and customizes the core parts of [@open-wc/creat
|
|
|
14
14
|
- ### [vitejs](https://vitejs.dev/)
|
|
15
15
|
|
|
16
16
|
- Dev Server
|
|
17
|
-
-
|
|
17
|
+
- Static demo
|
|
18
18
|
- TypeScript
|
|
19
19
|
|
|
20
20
|
- ### [sass](https://github.com/oscarmarina/sass-style-template)
|
|
21
|
+
|
|
21
22
|
- SCSS watcher with autoprefixer
|
|
22
23
|
|
|
24
|
+
- ### miscellany
|
|
25
|
+
- [tsconfig](https://github.com/lit/lit/blob/main/packages/lit-starter-ts/tsconfig.json)
|
|
26
|
+
- [Custom Elements Manifest](https://custom-elements-manifest.open-wc.org/blog/intro/)
|
|
27
|
+
- [ESLint 8 - decorators](https://github.com/eslint/eslint/issues/15299#issuecomment-968099681)
|
|
28
|
+
|
|
23
29
|
<hr>
|
|
24
30
|
|
|
25
31
|
## Installation
|
|
@@ -61,12 +67,23 @@ npm run format
|
|
|
61
67
|
import { defaultReporter } from '@web/test-runner';
|
|
62
68
|
import { mochaStyleReporter } from '@blockquote/test-runner-mocha-style-reporter';
|
|
63
69
|
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
const outDir = process.env.OUTDIR || '.';
|
|
71
|
+
|
|
72
|
+
export default ({
|
|
73
|
+
files: [`${outDir}/test/**/*.test.js`],
|
|
74
|
+
|
|
75
|
+
nodeResolve: {
|
|
76
|
+
exportConditions: ['browser', 'development'],
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
reporters: [
|
|
80
|
+
defaultReporter(),
|
|
81
|
+
mochaStyleReporter(),
|
|
82
|
+
],
|
|
66
83
|
|
|
67
84
|
coverageConfig: {
|
|
68
85
|
report: true,
|
|
69
|
-
reportDir:
|
|
86
|
+
reportDir: `${outDir}/test/coverage`,
|
|
70
87
|
threshold: {
|
|
71
88
|
statements: 80,
|
|
72
89
|
branches: 80,
|
|
@@ -80,6 +97,8 @@ export default {
|
|
|
80
97
|
ui: 'tdd',
|
|
81
98
|
},
|
|
82
99
|
},
|
|
100
|
+
|
|
101
|
+
...
|
|
83
102
|
};
|
|
84
103
|
```
|
|
85
104
|
|
|
@@ -102,20 +121,22 @@ npm run test:watch
|
|
|
102
121
|
|
|
103
122
|
### dev server
|
|
104
123
|
|
|
124
|
+
- Vite supports importing .ts files out of the box ([4848](https://github.com/vitejs/vite/issues/4848), [3040](https://github.com/vitejs/vite/issues/3040#issuecomment-940697809))
|
|
125
|
+
|
|
105
126
|
```bash
|
|
106
127
|
npm run vite
|
|
107
128
|
```
|
|
108
129
|
|
|
109
|
-
###
|
|
110
|
-
|
|
130
|
+
### For hosting a static demo purposes only - [Do not bundle](https://justinfagnani.com/2019/11/01/how-to-publish-web-components-to-npm/#do-not-bundle)
|
|
111
131
|
|
|
112
132
|
```bash
|
|
113
|
-
npm run vite
|
|
133
|
+
npm run dev:vite
|
|
114
134
|
```
|
|
115
|
-
|
|
135
|
+
|
|
136
|
+
### [server static-deploy](https://vitejs.dev/guide/static-deploy.html)
|
|
116
137
|
|
|
117
138
|
```bash
|
|
118
|
-
npm run vite
|
|
139
|
+
npm run preview:vite
|
|
119
140
|
```
|
|
120
141
|
|
|
121
142
|
<hr>
|
|
@@ -131,6 +152,16 @@ npm run sass:watch
|
|
|
131
152
|
|
|
132
153
|
<hr>
|
|
133
154
|
<br>
|
|
155
|
+
|
|
156
|
+
## TypeScript
|
|
157
|
+
|
|
158
|
+
### build ts
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
npm run build
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
<hr>
|
|
134
165
|
<br>
|
|
135
166
|
|
|
136
167
|
### Start:
|
|
@@ -141,43 +172,19 @@ npm run sass:watch
|
|
|
141
172
|
npm start
|
|
142
173
|
```
|
|
143
174
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
## scripts - package.json
|
|
175
|
+
Example:
|
|
147
176
|
|
|
148
|
-
|
|
149
|
-
"scripts": {
|
|
150
|
-
"analyze": "cem analyze --litelement --globs \"{src,define}/**/*.{js,ts}\" \"index.js\"",
|
|
151
|
-
"format": "eslint --ext .js,.html . --fix --ignore-path .gitignore && prettier \"**/*.js\" --write --ignore-path .gitignore",
|
|
152
|
-
"postinstall": "npm run sort:package",
|
|
153
|
-
"lint": "eslint --ext .js,.html . --ignore-path .gitignore && prettier \"**/*.js\" --check --ignore-path .gitignore",
|
|
154
|
-
"openwc": "web-dev-server",
|
|
155
|
-
"sass:watch": "sass-style-template",
|
|
156
|
-
"sort:package": "npx sort-package-json",
|
|
157
|
-
"start": "concurrently -k -r \"npm:sass:watch\" \"npm:vite\"",
|
|
158
|
-
"start:openwc": "concurrently -k -r \"npm:sass:watch\" \"npm:openwc\"",
|
|
159
|
-
"test": "web-test-runner --coverage",
|
|
160
|
-
"test:watch": "web-test-runner --watch",
|
|
161
|
-
"vite": "vite",
|
|
162
|
-
"vite-build": "vite build",
|
|
163
|
-
"vite-preview": "vite preview",
|
|
164
|
-
"wca": "wca analyze \"{src,define}/**/*.{js,ts}\" \"index.js\" --visibility private --outFile custom-elements-wca.json && wca analyze \"{src,define}/**/*.{js,ts}\" \"index.js\" --outFile README.md"
|
|
165
|
-
},
|
|
166
|
-
```
|
|
177
|
+
### [open-wc-vitejs-sass](https://github.com/oscarmarina/open-wc-vitejs-sass)
|
|
167
178
|
|
|
168
179
|
<hr>
|
|
169
180
|
<br>
|
|
170
181
|
|
|
171
182
|
## Different major versions:
|
|
172
183
|
|
|
173
|
-
blockquote scaffold
|
|
174
|
-
|
|
175
184
|
```json
|
|
176
185
|
"devDependencies": {
|
|
177
186
|
"eslint": "^8.0.0",
|
|
178
187
|
"@open-wc/eslint-config": "^7.0.0",
|
|
179
|
-
"husky": "^7.0.0",
|
|
180
|
-
"lint-staged": "^11.0.0",
|
|
181
188
|
...
|
|
182
189
|
}
|
|
183
190
|
|
|
@@ -189,8 +196,6 @@ open-wc scaffold
|
|
|
189
196
|
"devDependencies": {
|
|
190
197
|
"eslint": "^7.32.0",
|
|
191
198
|
"@open-wc/eslint-config": "^4.3.0",
|
|
192
|
-
"husky": "^4.3.8",
|
|
193
|
-
"lint-staged": "^10.5.4",
|
|
194
199
|
...
|
|
195
200
|
}
|
|
196
201
|
|
|
@@ -198,26 +203,26 @@ open-wc scaffold
|
|
|
198
203
|
|
|
199
204
|
<hr>
|
|
200
205
|
|
|
201
|
-
## File structure
|
|
206
|
+
## File structure JS & TS
|
|
202
207
|
|
|
203
208
|
```css
|
|
204
209
|
./
|
|
205
210
|
├── my-el/
|
|
206
211
|
│ ├── define/
|
|
207
|
-
│ │ └── my-el.js
|
|
212
|
+
│ │ └── my-el.{js,ts}
|
|
208
213
|
│ ├── demo/
|
|
209
214
|
│ │ └── index.html
|
|
210
215
|
│ ├── src/
|
|
211
216
|
│ │ ├── styles/
|
|
212
|
-
│ │ │ ├── MyEl-styles.js
|
|
217
|
+
│ │ │ ├── MyEl-styles.{js,ts}
|
|
213
218
|
│ │ │ └── MyEl.scss
|
|
214
|
-
│ │ └── MyEl.js
|
|
219
|
+
│ │ └── MyEl.{js,ts}
|
|
215
220
|
│ ├── test/
|
|
216
|
-
│ │ └── my-el.test.js
|
|
221
|
+
│ │ └── my-el.test.{js,ts}
|
|
217
222
|
│ ├── .editorconfig
|
|
218
223
|
│ ├── .gitignore
|
|
219
224
|
│ ├── index.html
|
|
220
|
-
│ ├── index.js
|
|
225
|
+
│ ├── index.{js,ts}
|
|
221
226
|
│ ├── LICENSE
|
|
222
227
|
│ ├── package.json
|
|
223
228
|
│ ├── README.md
|
|
@@ -226,15 +231,13 @@ open-wc scaffold
|
|
|
226
231
|
│ └── web-test-runner.config.mjs
|
|
227
232
|
```
|
|
228
233
|
|
|
234
|
+
<hr>
|
|
235
|
+
|
|
229
236
|
### the component definition is generated in its own folder
|
|
237
|
+
|
|
230
238
|
```css
|
|
231
239
|
./
|
|
232
240
|
├── my-el/
|
|
233
241
|
│ ├── define/
|
|
234
|
-
│ │ └── my-el.js
|
|
235
|
-
```
|
|
236
|
-
```js
|
|
237
|
-
import { MyEl } from '../src/MyEl.js';
|
|
238
|
-
|
|
239
|
-
customElements.define(MyEl.is, MyEl);
|
|
242
|
+
│ │ └── my-el.{js,ts}
|
|
240
243
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blockquote/create-wc",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "Web component with Lit scaffolding - Extending Open Web Component",
|
|
4
5
|
"keywords": [
|
|
5
6
|
"LitElement",
|
|
6
7
|
"web-component",
|
|
@@ -10,33 +11,32 @@
|
|
|
10
11
|
"openwc",
|
|
11
12
|
"generator"
|
|
12
13
|
],
|
|
13
|
-
"
|
|
14
|
-
"access": "public"
|
|
15
|
-
},
|
|
16
|
-
"description": "Web component with Lit scaffolding - Extending Open Web Component",
|
|
17
|
-
"license": "MIT",
|
|
18
|
-
"type": "module",
|
|
14
|
+
"homepage": "https://github.com/oscarmarina/create",
|
|
19
15
|
"repository": {
|
|
20
16
|
"type": "git",
|
|
21
17
|
"url": "https://github.com/oscarmarina/create.git"
|
|
22
18
|
},
|
|
23
|
-
"
|
|
19
|
+
"license": "MIT",
|
|
24
20
|
"author": "Oscar Marina",
|
|
21
|
+
"type": "module",
|
|
25
22
|
"bin": {
|
|
26
23
|
"create-blockquote-wc": "./src/create.js"
|
|
27
24
|
},
|
|
25
|
+
"files": [
|
|
26
|
+
"/src/"
|
|
27
|
+
],
|
|
28
28
|
"scripts": {
|
|
29
|
-
"
|
|
29
|
+
"format": "eslint --ext .ts,.js,.mjs,.cjs --fix && prettier \"**/*.{ts,js,mjs,cjs,md}\" --check --ignore-path .eslintignore --write",
|
|
30
30
|
"lint": "npm run lint:eslint && npm run lint:prettier",
|
|
31
31
|
"lint:eslint": "eslint --ext .js,.mjs,.cjs .",
|
|
32
32
|
"lint:prettier": "prettier \"**/*.{js,mjs,cjs,md.json}\" --check --ignore-path .eslintignore",
|
|
33
|
-
"
|
|
33
|
+
"start": "node ./src/create.js"
|
|
34
34
|
},
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
35
|
+
"prettier": {
|
|
36
|
+
"arrowParens": "always",
|
|
37
|
+
"printWidth": 100,
|
|
38
|
+
"singleQuote": true,
|
|
39
|
+
"trailingComma": "all"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@open-wc/create": "^0.37.95",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"eslint-config-prettier": "^8.2.0",
|
|
52
52
|
"prettier": "^2.2.1"
|
|
53
53
|
},
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=14.15.0"
|
|
56
|
+
},
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public"
|
|
59
59
|
}
|
|
60
60
|
}
|
package/src/Generator.js
CHANGED
|
@@ -4,9 +4,11 @@ import _Generator from '@open-wc/create/dist/Generator.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Options for the generator
|
|
6
6
|
* @typedef {object} GeneratorOptions
|
|
7
|
-
* @property {string} [
|
|
7
|
+
* @property {string} [tagName] the dash-case tag name
|
|
8
8
|
* @property {string} [destinationPath='auto'] path to output to. default value 'auto' will output to current working directory
|
|
9
|
+
* @property {'scaffold'} [type='scaffold'] path to output to. default value 'auto' will output to current working directory
|
|
9
10
|
* @property {'true'|'false'} [writeToDisk] whether to write to disk
|
|
11
|
+
* @property {'yarn'|'npm'|'false'} [installDependencies] whether and with which tool to install dependencies
|
|
10
12
|
*/
|
|
11
13
|
|
|
12
14
|
class Generator extends _Generator.default {
|
package/src/app/gatherMixins.js
CHANGED
|
@@ -1,20 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
// js
|
|
2
|
+
import { CommonLintingMixin } from '../common-linting/index.js';
|
|
3
|
+
import { CommonTestingWtrMixin } from '../common-testing-wtr/index.js';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import { LintingMixin } from '../linting/index.js';
|
|
7
|
+
import { WcLitElementPackageMixin } from '../wc-lit-element/index.js';
|
|
3
8
|
import { TestingMixin, TestingScaffoldMixin } from '../testing/index.js';
|
|
4
9
|
|
|
5
|
-
//
|
|
10
|
+
// ts
|
|
11
|
+
import { TsLintingMixin } from '../linting-ts/index.js';
|
|
12
|
+
import { TsWcLitElementPackageMixin } from '../wc-lit-element-ts/index.js';
|
|
13
|
+
import { TsTestingMixin, TsTestingScaffoldMixin } from '../testing-ts/index.js';
|
|
6
14
|
|
|
7
15
|
export function gatherMixins(options) {
|
|
8
16
|
const mixins = [];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
if (options.typescript === 'true') {
|
|
18
|
+
mixins.push(CommonLintingMixin);
|
|
19
|
+
mixins.push(TsLintingMixin);
|
|
20
|
+
mixins.push(CommonTestingWtrMixin);
|
|
21
|
+
mixins.push(TsTestingMixin);
|
|
22
|
+
mixins.push(TsTestingScaffoldMixin);
|
|
23
|
+
mixins.push(TsWcLitElementPackageMixin);
|
|
24
|
+
} else {
|
|
25
|
+
mixins.push(CommonLintingMixin);
|
|
26
|
+
mixins.push(LintingMixin);
|
|
27
|
+
mixins.push(CommonTestingWtrMixin);
|
|
28
|
+
mixins.push(TestingMixin);
|
|
29
|
+
mixins.push(TestingScaffoldMixin);
|
|
30
|
+
mixins.push(WcLitElementPackageMixin);
|
|
18
31
|
}
|
|
32
|
+
|
|
19
33
|
return mixins;
|
|
20
34
|
}
|
package/src/app/index.js
CHANGED
|
@@ -1,27 +1,12 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import prompts from 'prompts';
|
|
3
|
-
import commandLineArgs from 'command-line-args';
|
|
3
|
+
// import commandLineArgs from 'command-line-args';
|
|
4
4
|
import { executeMixinGenerator } from '@open-wc/create/dist/core.js';
|
|
5
5
|
|
|
6
6
|
import header from './header.js';
|
|
7
7
|
import { gatherMixins } from './gatherMixins.js';
|
|
8
8
|
import Generator from '../Generator.js';
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* Allows to control the data via command line
|
|
12
|
-
*
|
|
13
|
-
* example:
|
|
14
|
-
* npm init code-workshop-kit --type python --writeToDisk true
|
|
15
|
-
*/
|
|
16
|
-
const optionDefinitions = [
|
|
17
|
-
{ name: 'destinationPath', type: String },
|
|
18
|
-
{ name: 'type', type: String },
|
|
19
|
-
{ name: 'tagName', type: String },
|
|
20
|
-
{ name: 'writeToDisk', type: String },
|
|
21
|
-
];
|
|
22
|
-
const overrides = commandLineArgs(optionDefinitions);
|
|
23
|
-
prompts.override(overrides);
|
|
24
|
-
|
|
25
10
|
export const AppMixin = (subclass) =>
|
|
26
11
|
// eslint-disable-next-line no-shadow
|
|
27
12
|
class AppMixin extends subclass {
|
|
@@ -39,12 +24,38 @@ export const AppMixin = (subclass) =>
|
|
|
39
24
|
type: 'text',
|
|
40
25
|
name: 'tagName',
|
|
41
26
|
message: 'What is the tag name of your web component',
|
|
42
|
-
typeLabel: '{underline string}',
|
|
43
27
|
validate: (tagName) =>
|
|
44
28
|
!/^([a-z])(?!.*[<>])(?=.*-).+$/.test(tagName)
|
|
45
29
|
? 'You need a minimum of two lowercase words separated by dashes (e.g. foo-bar)'
|
|
46
30
|
: true,
|
|
47
31
|
},
|
|
32
|
+
{
|
|
33
|
+
type: 'select',
|
|
34
|
+
name: 'nameSpaceSelect',
|
|
35
|
+
message: 'Would you like to use namespace (without @)?',
|
|
36
|
+
choices: [
|
|
37
|
+
{ title: 'Yes', value: 'true' },
|
|
38
|
+
{ title: 'No', value: 'false' },
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: (prev, all) => (all.nameSpaceSelect === 'true' ? 'text' : null),
|
|
43
|
+
name: 'nameSpace',
|
|
44
|
+
message: 'What is the namespace of your web component',
|
|
45
|
+
validate: (nameSpace) =>
|
|
46
|
+
/^[@]/.test(nameSpace)
|
|
47
|
+
? 'Without @'
|
|
48
|
+
: true,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: 'select',
|
|
52
|
+
name: 'typescript',
|
|
53
|
+
message: 'Would you like to use typescript?',
|
|
54
|
+
choices: [
|
|
55
|
+
{ title: 'No', value: 'false' },
|
|
56
|
+
{ title: 'Yes', value: 'true' },
|
|
57
|
+
],
|
|
58
|
+
},
|
|
48
59
|
];
|
|
49
60
|
|
|
50
61
|
this.options = await prompts(questions, {
|
|
@@ -53,7 +64,7 @@ export const AppMixin = (subclass) =>
|
|
|
53
64
|
},
|
|
54
65
|
});
|
|
55
66
|
|
|
56
|
-
// simulate
|
|
67
|
+
// simulate 'scaffold' option - @open-wc,
|
|
57
68
|
this.options.type = 'scaffold';
|
|
58
69
|
|
|
59
70
|
const mixins = gatherMixins(this.options);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { dirname } from 'path';
|
|
4
|
+
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = dirname(__filename);
|
|
7
|
+
|
|
8
|
+
export const CommonLintingMixin = (subclass) =>
|
|
9
|
+
class extends subclass {
|
|
10
|
+
async execute() {
|
|
11
|
+
await super.execute();
|
|
12
|
+
// extend package.json
|
|
13
|
+
this.copyTemplateJsonInto(
|
|
14
|
+
`${__dirname}/templates/package.json`,
|
|
15
|
+
this.destinationPath('package.json'),
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"husky": {
|
|
3
|
+
"hooks": {
|
|
4
|
+
"pre-commit": "lint-staged"
|
|
5
|
+
}
|
|
6
|
+
},
|
|
7
|
+
"lint-staged": {
|
|
8
|
+
"**/*.{js,ts,json,html}": [
|
|
9
|
+
"npm run format"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"eslintConfig": {
|
|
13
|
+
"extends": [
|
|
14
|
+
"prettier",
|
|
15
|
+
"@open-wc"
|
|
16
|
+
],
|
|
17
|
+
"rules": {
|
|
18
|
+
"import/no-unresolved": "off",
|
|
19
|
+
"class-methods-use-this": "off",
|
|
20
|
+
"object-curly-newline": "off",
|
|
21
|
+
"import/extensions": ["error", "always", { "ignorePackages": true }]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"prettier": {
|
|
25
|
+
"arrowParens": "avoid",
|
|
26
|
+
"singleQuote": true,
|
|
27
|
+
"trailingComma": "all"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"format": "eslint \"{src,define,test}/**/*.{js,ts,json,html}\" \"index.*\" . --fix --ignore-path .gitignore && prettier \"**/*.{js,ts,json,html,md}\" --write --ignore-path .gitignore",
|
|
31
|
+
"lint": "eslint \"{src,define,test}/**/*.{js,ts,json,html}\" \"index.*\" . --ignore-path .gitignore && prettier \"**/*.{js,ts,json,html,md}\" --check --ignore-path .gitignore"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"eslint": "^8.0.0",
|
|
35
|
+
"@open-wc/eslint-config": "^7.0.0",
|
|
36
|
+
"husky": "^4.3.8",
|
|
37
|
+
"lint-staged": "^12.0.0",
|
|
38
|
+
"prettier": "^2.4.1",
|
|
39
|
+
"eslint-config-prettier": "^8.3.0"
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/common-repo/index.js
CHANGED
|
@@ -11,15 +11,23 @@ export const CommonRepoMixin = (subclass) =>
|
|
|
11
11
|
...this.templateData,
|
|
12
12
|
scriptRunCommand: this.options.installDependencies === 'yarn' ? 'yarn' : 'npm run',
|
|
13
13
|
year: new Date().getFullYear(),
|
|
14
|
+
nameSpace: this.options.nameSpace ? `@${this.options.nameSpace}/` : '',
|
|
14
15
|
};
|
|
15
16
|
|
|
16
17
|
await super.execute();
|
|
18
|
+
const { className } = this.templateData;
|
|
17
19
|
|
|
18
20
|
this.copyTemplateJsonInto(
|
|
19
21
|
`${__dirname}/templates/package.json`,
|
|
20
22
|
this.destinationPath('package.json'),
|
|
21
23
|
);
|
|
22
24
|
|
|
25
|
+
// write & rename el scss template
|
|
26
|
+
this.copyTemplate(
|
|
27
|
+
`${__dirname}/templates/styles/MyEl.scss`,
|
|
28
|
+
this.destinationPath(`src/styles/${className}.scss`),
|
|
29
|
+
);
|
|
30
|
+
|
|
23
31
|
// write and rename .gitignore
|
|
24
32
|
this.copyTemplate(`${__dirname}/templates/gitignore`, this.destinationPath(`.gitignore`));
|
|
25
33
|
|
|
@@ -1,42 +1,44 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "<%= tagName %>",
|
|
2
|
+
"name": "<%= nameSpace %><%= tagName %>",
|
|
3
3
|
"version": "1.0.0-rc.1",
|
|
4
4
|
"description": "Webcomponent <%= tagName %> following open-wc recommendations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lit",
|
|
7
|
-
"web-component"
|
|
7
|
+
"web-component",
|
|
8
|
+
"lit-element"
|
|
8
9
|
],
|
|
9
10
|
"author": "<%= tagName %>",
|
|
10
11
|
"license": "MIT",
|
|
11
12
|
"customElements": "custom-elements.json",
|
|
12
13
|
"scripts": {
|
|
13
|
-
"start
|
|
14
|
-
"
|
|
15
|
-
"vite
|
|
16
|
-
"vite
|
|
14
|
+
"start": "concurrently -k -r \"npm:sass:watch\" \"npm:vite\"",
|
|
15
|
+
"vite": "vite",
|
|
16
|
+
"dev:vite": "vite build",
|
|
17
|
+
"preview:vite": "vite preview",
|
|
17
18
|
"analyze": "cem analyze --litelement --globs \"{src,define}/**/*.{js,ts}\" \"index.js\"",
|
|
18
|
-
"
|
|
19
|
-
"sort:package"
|
|
19
|
+
"analyze:watch": "cem analyze --litelement --globs \"{src,define}/**/*.{js,ts}\" \"index.js\" --watch",
|
|
20
|
+
"sort:package": "npx sort-package-json",
|
|
20
21
|
"postinstall": "npm run sort:package"
|
|
21
22
|
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"lit": "^2.0.2"
|
|
25
|
+
},
|
|
22
26
|
"devDependencies": {
|
|
23
27
|
"@blockquote/sass-style-template": "^2.0.0",
|
|
24
28
|
"@blockquote/test-runner-mocha-style-reporter": "^1.0.0",
|
|
25
29
|
"@custom-elements-manifest/analyzer": "^0.5.3",
|
|
30
|
+
"@custom-elements-manifest/to-markdown": "^0.1.0",
|
|
26
31
|
"@ungap/global-this": "^0.4.4",
|
|
32
|
+
"@web/dev-server": "^0.1.25",
|
|
27
33
|
"@web/rollup-plugin-html": "^1.10.1",
|
|
28
34
|
"@webcomponents/shadycss": "^1.11.0",
|
|
29
35
|
"@webcomponents/webcomponentsjs": "^2.6.0",
|
|
30
|
-
"concurrently": "^6.
|
|
36
|
+
"concurrently": "^6.4.0",
|
|
31
37
|
"rollup-plugin-copy": "^3.4.0",
|
|
32
|
-
"rollup-plugin-
|
|
38
|
+
"rollup-plugin-summary": "^1.3.0",
|
|
33
39
|
"rollup-plugin-minify-html-literals": "^1.2.6",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"sort-package-json": "^1.52.0"
|
|
37
|
-
"eslint": "^8.0.0",
|
|
38
|
-
"@open-wc/eslint-config": "^7.0.0",
|
|
39
|
-
"husky": "^7.0.0",
|
|
40
|
-
"lint-staged": "^11.0.0"
|
|
40
|
+
"tiny-array-flat-polyfill": "^0.2.1",
|
|
41
|
+
"vite": "^2.7.0-beta.8",
|
|
42
|
+
"sort-package-json": "^1.52.0"
|
|
41
43
|
}
|
|
42
44
|
}
|