generator-hubble 0.0.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/LICENSE +21 -0
- package/README.md +38 -0
- package/generators/app/index.js +123 -0
- package/generators/app/templates/_README.md +7 -0
- package/generators/app/templates/_index.html +10 -0
- package/generators/app/templates/_package.json +39 -0
- package/generators/app/templates/resources/icon.svg +1 -0
- package/generators/app/templates/rollup.config.mjs +41 -0
- package/generators/app/templates/src/hello-world.ts +51 -0
- package/generators/app/templates/src/tailwind.css +3 -0
- package/generators/app/templates/tailwind.config.js +12 -0
- package/generators/app/templates/typings.d.ts +5 -0
- package/package.json +88 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Jamie Smith
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# generator-hubble
|
|
2
|
+
|
|
3
|
+
A yeoman generator for a lit, tailwind, typescript, rollup hubble
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Have [node.js](https://nodejs.org/) installed
|
|
8
|
+
|
|
9
|
+
If you need to install [Yeoman](http://yeoman.io) run:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm i -g yo
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
To install the generator run:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm i -g generator-hubble
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Then to generate, run:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
yo hubble
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
or use npx to run the generator without installing it:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx -p yo -p generator-hubble -c 'yo hubble'
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## License
|
|
34
|
+
|
|
35
|
+
[MIT License](./LICENSE)
|
|
36
|
+
|
|
37
|
+
[npm-image]: https://badge.fury.io/js/generator-hubble.svg
|
|
38
|
+
[npm-url]: https://npmjs.org/package/generator-hubble
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import Generator from 'yeoman-generator';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import yosay from 'yosay';
|
|
4
|
+
|
|
5
|
+
import { exec } from 'child_process';
|
|
6
|
+
import { promisify } from 'util';
|
|
7
|
+
const execute = promisify(exec);
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export default class extends Generator {
|
|
11
|
+
prompting() {
|
|
12
|
+
|
|
13
|
+
this.log(
|
|
14
|
+
yosay( `Welcome to the ${chalk.blue("hubble")} generator!` )
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const prompts = [
|
|
19
|
+
{
|
|
20
|
+
type: "confirm",
|
|
21
|
+
name: "areYouSure",
|
|
22
|
+
message: `Would you like to create the project in the current directory?`,
|
|
23
|
+
default: true
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: "string",
|
|
27
|
+
name: "packageName",
|
|
28
|
+
message: "What's the name of the project?",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: "string",
|
|
32
|
+
name: "elementName",
|
|
33
|
+
message: "What's the name of the element?",
|
|
34
|
+
default: this.props.packageName.replace('hubble-', '')
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: "string",
|
|
38
|
+
name: "description",
|
|
39
|
+
message: "What's the description of the project?",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: "string",
|
|
43
|
+
name: "authorName",
|
|
44
|
+
message: "What's the author's name?",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: "string",
|
|
48
|
+
name: "gitUserName",
|
|
49
|
+
message: "What's the author's GitHub username?",
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
return this.prompt(prompts).then(props => {
|
|
54
|
+
// To access props later use this.props.someAnswer;
|
|
55
|
+
this.props = props;
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
writing() {
|
|
60
|
+
if(this.props.areYouSure) {
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
const NON_TPLS = [
|
|
64
|
+
'artifacts',
|
|
65
|
+
'build',
|
|
66
|
+
'resources/icon.svg',
|
|
67
|
+
'src/hello-world.ts',
|
|
68
|
+
'src/tailwind.css',
|
|
69
|
+
'.gitignore',
|
|
70
|
+
'rollup.config.js',
|
|
71
|
+
'tailwind.config.js',
|
|
72
|
+
'typings.d.ts',
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
const TPLS = [
|
|
76
|
+
'_index.html',
|
|
77
|
+
'_package.json',
|
|
78
|
+
'_README.md',
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
NON_TPLS.map((n) => {
|
|
82
|
+
return this.fs.copy(
|
|
83
|
+
this.templatePath(n),
|
|
84
|
+
this.destinationPath(n),
|
|
85
|
+
this.props);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
TPLS.map((n) => {
|
|
89
|
+
return this.fs.copyTpl(
|
|
90
|
+
this.templatePath(n),
|
|
91
|
+
this.destinationPath(n.replace(/(_)/gi, '')),
|
|
92
|
+
this.props);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
this.log( chalk.red(`🔥 Canceling ${this.props.name}...`) )
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async install(){
|
|
101
|
+
try {
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
if(!this.props.areYouSure) return undefined;
|
|
105
|
+
|
|
106
|
+
this.log( chalk.green(`🎉 Created ${this.props.name} and copied files...`) )
|
|
107
|
+
|
|
108
|
+
this.log( `${chalk.blue(`📚 Installing dependencies...`)}` )
|
|
109
|
+
|
|
110
|
+
await execute(`cd ${this.props.name} && npm i`);
|
|
111
|
+
|
|
112
|
+
this.log( `${chalk.green(`📚 Installed dependencies...`)}` )
|
|
113
|
+
|
|
114
|
+
this.log()
|
|
115
|
+
this.log(`${chalk.blue(`cd ${this.props.name} && npm start`)}` )
|
|
116
|
+
this.log(`🚀 Run above to go to your new project and start it up` )
|
|
117
|
+
this.log()
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
this.log( `🔥 ${chalk.red(`Error Installing: ${error.message}`)}` )
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<html style="background-color: grey;">
|
|
2
|
+
<head>
|
|
3
|
+
<title><%= elementName %> Demo</title>
|
|
4
|
+
<script src="./build/lit.js"></script>
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
</head>
|
|
7
|
+
<body style="padding: 0px; margin:0px;">
|
|
8
|
+
<hello-world></hello-world>
|
|
9
|
+
</body>
|
|
10
|
+
</html>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "<%= packageName %>",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A hubble to: <%= description %>",
|
|
5
|
+
"main": "build/lit.js",
|
|
6
|
+
"author": "<%= authorName %>",
|
|
7
|
+
"hubbles": {
|
|
8
|
+
"name": "<%= elementName %>",
|
|
9
|
+
"description": "<%= description %>",
|
|
10
|
+
"site": "https://github.com/<%= gitUserName %>/<%= packageName %>",
|
|
11
|
+
"icon": "https://raw.githubusercontent.com/<%= gitUserName %>/<%= packageName %>/main/resources/icon.svg?raw=true",
|
|
12
|
+
"executable": "https://unpkg.com/<%= packageName %>@0.0.1/build/lit.js"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
16
|
+
"build:tw": "tailwindcss -i ./src/tailwind.css -o ./artifacts/tw.css",
|
|
17
|
+
"build:tw:watch": "npm run build:tw --watch",
|
|
18
|
+
"build:twlit": "twlit --output ./artifacts/twlit.js --input ./artifacts/tw.css --watch",
|
|
19
|
+
"build:twlit:watch": "npm run build:twlit --watch",
|
|
20
|
+
"build:js": "rollup -c",
|
|
21
|
+
"build:js:watch": "rollup -c --watch",
|
|
22
|
+
"build:all": "npm run build:tw && npm run build:twlit && npm run build:js",
|
|
23
|
+
"dev": "concurrently \"tailwindcss -i ./src/tailwind.css -o ./artifacts/tw.css --watch\" \"twlit --output ./artifacts/twlit.js --input ./artifacts/tw.css --watch\" \"rollup -c --watch\""
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"lit": "^3.1.1"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
30
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
31
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
32
|
+
"@web/rollup-plugin-copy": "^0.5.1",
|
|
33
|
+
"concurrently": "^8.2.2",
|
|
34
|
+
"rollup": "^4.9.6",
|
|
35
|
+
"tailwindcss": "^3.4.1",
|
|
36
|
+
"twlit": "^0.0.1-alpha.37",
|
|
37
|
+
"typescript": "^4.9.5"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M80-200v-240q0-27 11-49t29-39v-112q0-50 35-85t85-35h160q23 0 43 8.5t37 23.5q17-15 37-23.5t43-8.5h160q50 0 85 35t35 85v112q18 17 29 39t11 49v240h-80v-80H160v80H80Zm440-360h240v-80q0-17-11.5-28.5T720-680H560q-17 0-28.5 11.5T520-640v80Zm-320 0h240v-80q0-17-11.5-28.5T400-680H240q-17 0-28.5 11.5T200-640v80Zm-40 200h640v-80q0-17-11.5-28.5T760-480H200q-17 0-28.5 11.5T160-440v80Zm640 0H160h640Z"/></svg>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
|
2
|
+
import typescript from '@rollup/plugin-typescript';
|
|
3
|
+
|
|
4
|
+
import {copy} from '@web/rollup-plugin-copy';
|
|
5
|
+
import terser from '@rollup/plugin-terser';
|
|
6
|
+
|
|
7
|
+
// Not installed by default but can be useful:
|
|
8
|
+
//import html from '@web/rollup-plugin-html';
|
|
9
|
+
//import resolve from '@rollup/plugin-node-resolve';
|
|
10
|
+
//import minifyHTML from 'rollup-plugin-minify-html-literals';
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
input: './src/hello-world.ts',
|
|
14
|
+
output: {
|
|
15
|
+
file: './build/lit.js',
|
|
16
|
+
format: 'esm',
|
|
17
|
+
},
|
|
18
|
+
plugins: [
|
|
19
|
+
nodeResolve(),
|
|
20
|
+
typescript({
|
|
21
|
+
compilerOptions: {
|
|
22
|
+
lib: ["es6", "dom"],
|
|
23
|
+
target: "es6",
|
|
24
|
+
experimentalDecorators: true,
|
|
25
|
+
useDefineForClassFields: false,
|
|
26
|
+
}
|
|
27
|
+
}),
|
|
28
|
+
terser({
|
|
29
|
+
ecma: 2021,
|
|
30
|
+
module: true,
|
|
31
|
+
warnings: true,
|
|
32
|
+
}),
|
|
33
|
+
// Optional: copy any static assets to build directory
|
|
34
|
+
copy({
|
|
35
|
+
patterns: [
|
|
36
|
+
'resources/**/*',
|
|
37
|
+
'package.json',
|
|
38
|
+
],
|
|
39
|
+
}),
|
|
40
|
+
]
|
|
41
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { LitElement, html } from "lit";
|
|
2
|
+
import { customElement, } from 'lit/decorators.js';
|
|
3
|
+
import { TWStyles } from "../artifacts/twlit.js";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@customElement('hello-world')
|
|
7
|
+
class HelloWorld extends LitElement {
|
|
8
|
+
|
|
9
|
+
static styles = [TWStyles];
|
|
10
|
+
|
|
11
|
+
static properties = {};
|
|
12
|
+
|
|
13
|
+
_init = false;
|
|
14
|
+
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
connectedCallback() {
|
|
20
|
+
super.connectedCallback();
|
|
21
|
+
if(!this._init) {
|
|
22
|
+
this._initialize();
|
|
23
|
+
this._init = true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private _initialize() {
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
render() {
|
|
31
|
+
return getHtml();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getHtml() {
|
|
37
|
+
return html`
|
|
38
|
+
<div class="flex justify-center items-center h-screen">
|
|
39
|
+
<div class="max-w-xl bg-white rounded-lg shadow-lg overflow-hidden">
|
|
40
|
+
Hello World
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
declare global {
|
|
48
|
+
interface HTMLElementTagNameMap {
|
|
49
|
+
"hello-world": HelloWorld;
|
|
50
|
+
}
|
|
51
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "generator-hubble",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"description": "A yeoman generator to easily create a lit-element project with tailwindcss and typescript",
|
|
6
|
+
"homepage": "https://github.com/jsmithdev/generator-hubble",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "jsmithdev",
|
|
9
|
+
"email": "hubble@jsmith.dev",
|
|
10
|
+
"url": "https://github.com/jsmithdev/generator-hubble"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"generators"
|
|
14
|
+
],
|
|
15
|
+
"main": "generators/index.js",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"lit",
|
|
18
|
+
"tailwind",
|
|
19
|
+
"typescript",
|
|
20
|
+
"yeoman",
|
|
21
|
+
"generator",
|
|
22
|
+
"yeoman-generator"
|
|
23
|
+
],
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"coveralls": "^3.0.7",
|
|
26
|
+
"eslint": "^6.6.0",
|
|
27
|
+
"eslint-config-prettier": "^6.6.0",
|
|
28
|
+
"eslint-config-xo": "^0.27.2",
|
|
29
|
+
"eslint-plugin-prettier": "^3.1.1",
|
|
30
|
+
"husky": "^3.0.9",
|
|
31
|
+
"jest": "^26.1.0",
|
|
32
|
+
"lint-staged": "^9.4.3",
|
|
33
|
+
"prettier": "^1.19.1",
|
|
34
|
+
"yeoman-assert": "^3.1.1",
|
|
35
|
+
"yeoman-test": "^6.3.0"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"npm": ">= 4.0.0"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"chalk": "^2.1.0",
|
|
42
|
+
"yeoman-generator": "^5.6.1",
|
|
43
|
+
"yosay": "^2.0.2"
|
|
44
|
+
},
|
|
45
|
+
"jest": {
|
|
46
|
+
"testEnvironment": "node"
|
|
47
|
+
},
|
|
48
|
+
"lint-staged": {
|
|
49
|
+
"*.js": [
|
|
50
|
+
"eslint --fix",
|
|
51
|
+
"git add"
|
|
52
|
+
],
|
|
53
|
+
"*.json": [
|
|
54
|
+
"prettier --write",
|
|
55
|
+
"git add"
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
"husky": {
|
|
59
|
+
"hooks": {
|
|
60
|
+
"pre-commit": "lint-staged"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"eslintConfig": {
|
|
64
|
+
"extends": [
|
|
65
|
+
"xo",
|
|
66
|
+
"prettier"
|
|
67
|
+
],
|
|
68
|
+
"env": {
|
|
69
|
+
"jest": true,
|
|
70
|
+
"node": true
|
|
71
|
+
},
|
|
72
|
+
"rules": {
|
|
73
|
+
"prettier/prettier": "off"
|
|
74
|
+
},
|
|
75
|
+
"plugins": [
|
|
76
|
+
"prettier"
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
"scripts": {
|
|
80
|
+
"pretest": "eslint .",
|
|
81
|
+
"test": "jest"
|
|
82
|
+
},
|
|
83
|
+
"repository": {
|
|
84
|
+
"type": "git",
|
|
85
|
+
"url": "https://github.com/jsmithdev/generator-hubble"
|
|
86
|
+
},
|
|
87
|
+
"license": "MIT"
|
|
88
|
+
}
|