create-vitrify 0.3.6 → 0.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/dist/cli.js +15 -10
- package/dist/templates.js +128 -12
- package/dist/types/templates.d.ts +21 -15
- package/package.json +3 -1
- package/templates/quasar/.vscode/extensions.json +1 -1
- package/templates/quasar/_eslintignore +2 -0
- package/templates/quasar/_eslintrc.cjs +19 -0
- package/templates/quasar/_prettierignore +3 -0
- package/templates/quasar/_prettierrc.json +22 -0
- package/templates/quasar/index.html +3 -7
- package/templates/quasar/src/App.vue +16 -5
- package/templates/quasar/src/components/HelloWorld.vue +6 -1
- package/templates/quasar/src/layouts/MainLayout.vue +4 -8
- package/templates/quasar/src/pages/{Error404.vue → Error404Page.vue} +7 -3
- package/templates/quasar/src/pages/{Index.vue → IndexPage.vue} +6 -0
- package/templates/quasar/src/router/routes.ts +2 -2
- package/templates/quasar/src/setup.ts +8 -0
- package/templates/quasar/src/shims-vue.d.ts +6 -0
- package/templates/quasar/vitrify.config.ts +36 -0
- package/templates/vite-ui-plugin/.vscode/extensions.json +3 -0
- package/templates/vite-ui-plugin/_eslintignore +2 -0
- package/templates/vite-ui-plugin/_eslintrc.cjs +19 -0
- package/templates/vite-ui-plugin/_gitignore +3 -0
- package/templates/vite-ui-plugin/_prettierignore +3 -0
- package/templates/vite-ui-plugin/_prettierrc.json +22 -0
- package/templates/vite-ui-plugin/src/shims-vue.d.ts +6 -0
- package/templates/vite-ui-plugin/src/ui/components/HelloWorld.vue +20 -0
- package/templates/vite-ui-plugin/src/ui/icon-set/index.ts +40 -0
- package/templates/vite-ui-plugin/src/ui/icon-set/material-icons.ts +8 -0
- package/templates/vite-ui-plugin/src/ui/index.ts +9 -0
- package/templates/vite-ui-plugin/src/ui/lang/en-US.ts +8 -0
- package/templates/vite-ui-plugin/src/ui/lang/index.ts +42 -0
- package/templates/vite-ui-plugin/src/ui/utils/helpers.ts +1 -0
- package/templates/vite-ui-plugin/src/ui/vue-plugin.ts +15 -0
- package/templates/vite-ui-plugin/src/vite-plugin.ts +53 -0
- package/templates/vite-ui-plugin/tsconfig.build.plugin.json +7 -0
- package/templates/vite-ui-plugin/tsconfig.node.json +11 -0
- package/templates/vite-ui-plugin/tsconfig.types.json +17 -0
- package/templates/vite-ui-plugin/vite.config.ts +41 -0
- package/dist/index.js +0 -83
- package/dist/types/index.d.ts +0 -16
- package/templates/quasar/package.json.hbs +0 -29
- package/templates/quasar/tsconfig.json +0 -15
- package/templates/quasar/vitrify.config.js +0 -23
package/dist/cli.js
CHANGED
@@ -1,17 +1,14 @@
|
|
1
|
-
import {
|
1
|
+
import { renderDirectory, renderPackageJson, renderTsconfigJson } from '@vitrify/tools/render';
|
2
2
|
import parseArgs from 'minimist';
|
3
3
|
import inquirer from 'inquirer';
|
4
|
+
import { promises } from 'fs';
|
4
5
|
import { templates } from './templates.js';
|
5
6
|
const escape = (val) => JSON.stringify(val).slice(1, -1);
|
6
|
-
// const templates = (await promises.readdir(new URL('../templates/', import.meta.url), { withFileTypes: true }))
|
7
|
-
// .filter((file) => file.isDirectory())
|
8
|
-
// .map((file) => file.name)
|
9
7
|
const argv = parseArgs(process.argv.slice(2), {
|
10
8
|
string: ['template']
|
11
9
|
});
|
12
10
|
let questions = [];
|
13
11
|
if (!argv.template) {
|
14
|
-
// throw new Error('Please provide a template argument: --template')
|
15
12
|
questions = [
|
16
13
|
...questions,
|
17
14
|
{
|
@@ -64,11 +61,19 @@ questions = [
|
|
64
61
|
const answers = await inquirer.prompt(questions);
|
65
62
|
const cwdUrl = new URL('', `file://${process.cwd()}/`);
|
66
63
|
const templateVariables = answers;
|
67
|
-
const templateUrl =
|
68
64
|
// @ts-ignore
|
69
|
-
templates[answers.template]
|
70
|
-
|
71
|
-
|
65
|
+
const template = templates[answers.template] || templates[argv.template];
|
66
|
+
const directoryUrl = template.url;
|
67
|
+
const outputDir = new URL(`./${answers.name}/`, cwdUrl);
|
68
|
+
await renderDirectory({
|
69
|
+
directoryUrl,
|
72
70
|
templateVariables,
|
73
|
-
outputDir
|
71
|
+
outputDir
|
74
72
|
});
|
73
|
+
promises.writeFile(new URL('./package.json', outputDir), renderPackageJson({
|
74
|
+
...templateVariables,
|
75
|
+
version: '0.1.0',
|
76
|
+
license: 'UNLICENSED',
|
77
|
+
...template.pkgJson
|
78
|
+
}));
|
79
|
+
promises.writeFile(new URL('./tsconfig.json', outputDir), renderTsconfigJson(template.tsconfigJson));
|
package/dist/templates.js
CHANGED
@@ -1,20 +1,136 @@
|
|
1
|
+
import latestVersion from 'latest-version';
|
2
|
+
const getLatestVersions = async (dependencies) => {
|
3
|
+
console.log('Fetching latest package versions...');
|
4
|
+
const deps = {};
|
5
|
+
for (const dep of dependencies) {
|
6
|
+
deps[dep] = await latestVersion(dep);
|
7
|
+
}
|
8
|
+
return deps;
|
9
|
+
};
|
1
10
|
export const templates = {
|
2
11
|
quasar: {
|
3
12
|
name: 'quasar',
|
4
13
|
fullName: 'Quasar Project',
|
5
14
|
description: 'Quasar Framework project',
|
6
|
-
url: new URL('../templates/quasar/', import.meta.url)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
15
|
+
url: new URL('../templates/quasar/', import.meta.url),
|
16
|
+
pkgJson: {
|
17
|
+
scripts: {
|
18
|
+
dev: 'vitrify dev',
|
19
|
+
'dev:ssr': 'vitrify dev -m ssr',
|
20
|
+
build: 'vitrify build',
|
21
|
+
'build:ssr': 'vitrify build -m ssr',
|
22
|
+
'build:ssg': 'vitrify build -m ssg',
|
23
|
+
test: 'vitrify test',
|
24
|
+
lint: 'eslint --ext .vue --ext .ts src',
|
25
|
+
'lint:fix': 'eslint --ext .vue --ext .ts src --fix',
|
26
|
+
'format:check': 'prettier --check .',
|
27
|
+
'format:write': 'prettier --write .'
|
28
|
+
},
|
29
|
+
dependencies: await getLatestVersions([
|
30
|
+
'@fastify/middie',
|
31
|
+
'@fastify/static',
|
32
|
+
'@quasar/extras',
|
33
|
+
'quasar',
|
34
|
+
'vue',
|
35
|
+
'vue-router'
|
36
|
+
]),
|
37
|
+
devDependencies: await getLatestVersions([
|
38
|
+
'@vitejs/plugin-vue',
|
39
|
+
'@typescript-eslint/eslint-plugin',
|
40
|
+
'@typescript-eslint/parser',
|
41
|
+
'critters',
|
42
|
+
'eslint',
|
43
|
+
'eslint-config-prettier',
|
44
|
+
'eslint-plugin-prettier-vue',
|
45
|
+
'eslint-plugin-vue',
|
46
|
+
'devcert',
|
47
|
+
'fastify',
|
48
|
+
'typescript',
|
49
|
+
'vite',
|
50
|
+
'vitrify'
|
51
|
+
])
|
52
|
+
},
|
53
|
+
tsconfigJson: {
|
54
|
+
paths: {
|
55
|
+
src: ['./src']
|
56
|
+
},
|
57
|
+
types: ['vite/client', 'vitrify/client'],
|
58
|
+
include: [
|
59
|
+
'vitrify.config.ts',
|
60
|
+
'src/**/*.ts',
|
61
|
+
'src/**/*.d.ts',
|
62
|
+
'src/**/*.tsx',
|
63
|
+
'src/**/*.vue'
|
64
|
+
]
|
65
|
+
}
|
13
66
|
},
|
14
|
-
|
15
|
-
name: '
|
16
|
-
fullName: '
|
17
|
-
description: '
|
18
|
-
url: new URL('../templates/
|
67
|
+
uiPlugin: {
|
68
|
+
name: 'vite-ui-plugin',
|
69
|
+
fullName: 'Vite UI plugin',
|
70
|
+
description: 'A Vite plugin for UI components',
|
71
|
+
url: new URL('../templates/vite-ui-plugin/', import.meta.url),
|
72
|
+
pkgJson: {
|
73
|
+
exports: {
|
74
|
+
'.': {
|
75
|
+
types: './dist/types/index.d.ts',
|
76
|
+
import: './dist/index.js',
|
77
|
+
src: './src/ui/index.ts'
|
78
|
+
},
|
79
|
+
'./vite-plugin': {
|
80
|
+
types: './dist/vite-plugin.d.ts',
|
81
|
+
import: './dist/vite-plugin.js',
|
82
|
+
src: './src/vite-plugin.ts'
|
83
|
+
}
|
84
|
+
},
|
85
|
+
scripts: {
|
86
|
+
'build:plugin': 'vite build',
|
87
|
+
'build:vite-plugin': 'tsc -p tsconfig.build.plugin.json',
|
88
|
+
'generate:types': 'vue-tsc -p tsconfig.types.json',
|
89
|
+
'clean:buildinfo': 'rimraf tsconfig.build.plugin.tsbuildinfo',
|
90
|
+
clean: 'run-s clean:buildinfo',
|
91
|
+
build: 'run-s clean build:plugin build:vite-plugin generate:types',
|
92
|
+
lint: 'eslint --ext .vue --ext .ts src',
|
93
|
+
'lint:fix': 'eslint --ext .vue --ext .ts src --fix',
|
94
|
+
'format:check': 'prettier --check .',
|
95
|
+
'format:write': 'prettier --write .'
|
96
|
+
},
|
97
|
+
dependencies: await getLatestVersions(['unplugin-vue-components']),
|
98
|
+
devDependencies: await getLatestVersions([
|
99
|
+
'@types/node',
|
100
|
+
'@types/ws',
|
101
|
+
'@vitejs/plugin-vue',
|
102
|
+
'@vue/server-renderer',
|
103
|
+
'@typescript-eslint/eslint-plugin',
|
104
|
+
'@typescript-eslint/parser',
|
105
|
+
'eslint',
|
106
|
+
'eslint-config-prettier',
|
107
|
+
'eslint-plugin-prettier-vue',
|
108
|
+
'eslint-plugin-vue',
|
109
|
+
'npm-run-all',
|
110
|
+
'quasar',
|
111
|
+
'typescript',
|
112
|
+
'rimraf',
|
113
|
+
'vite',
|
114
|
+
'vitrify',
|
115
|
+
'vue',
|
116
|
+
'vue-router',
|
117
|
+
'vue-tsc'
|
118
|
+
])
|
119
|
+
},
|
120
|
+
tsconfigJson: {
|
121
|
+
types: ['vite/client']
|
122
|
+
}
|
19
123
|
}
|
124
|
+
// plugin: {
|
125
|
+
// name: 'quasar-plugin',
|
126
|
+
// fullName: 'Quasar Plugin',
|
127
|
+
// description: 'Quasar Framework plugin',
|
128
|
+
// url: new URL('../templates/quasar-plugin/', import.meta.url)
|
129
|
+
// },
|
130
|
+
// quasarMonorepo: {
|
131
|
+
// name: 'quasar-monorepo',
|
132
|
+
// fullName: 'Quasar monorepo (project + plugin)',
|
133
|
+
// description: 'Quasar Framework monorepo',
|
134
|
+
// url: new URL('../templates/quasar-monorepo/', import.meta.url)
|
135
|
+
// }
|
20
136
|
};
|
@@ -1,20 +1,26 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
interface Templates {
|
2
|
+
[key: string]: {
|
3
3
|
name: string;
|
4
4
|
fullName: string;
|
5
5
|
description: string;
|
6
6
|
url: URL;
|
7
|
+
pkgJson: {
|
8
|
+
scripts: Record<string, string>;
|
9
|
+
exports?: Record<string, {
|
10
|
+
types?: string;
|
11
|
+
import: string;
|
12
|
+
src?: string;
|
13
|
+
}>;
|
14
|
+
dependencies?: Record<string, string>;
|
15
|
+
devDependencies?: Record<string, string>;
|
16
|
+
peerDependencies?: Record<string, string>;
|
17
|
+
};
|
18
|
+
tsconfigJson: {
|
19
|
+
paths?: Record<string, string[]>;
|
20
|
+
types?: string[];
|
21
|
+
include?: string[];
|
22
|
+
};
|
7
23
|
};
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
description: string;
|
12
|
-
url: URL;
|
13
|
-
};
|
14
|
-
quasarMonorepo: {
|
15
|
-
name: string;
|
16
|
-
fullName: string;
|
17
|
-
description: string;
|
18
|
-
url: URL;
|
19
|
-
};
|
20
|
-
};
|
24
|
+
}
|
25
|
+
export declare const templates: Templates;
|
26
|
+
export {};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "create-vitrify",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.4.1",
|
4
4
|
"license": "MIT",
|
5
5
|
"author": "Stefan van Herwijnen",
|
6
6
|
"type": "module",
|
@@ -25,8 +25,10 @@
|
|
25
25
|
},
|
26
26
|
"homepage": "https://github.com/simsustech/vitrify/tree/main/packages/create-vitrify#readme",
|
27
27
|
"dependencies": {
|
28
|
+
"@vitrify/tools": "^0.1.0",
|
28
29
|
"handlebars": "^4.7.7",
|
29
30
|
"inquirer": "^8.2.2",
|
31
|
+
"latest-version": "^7.0.0",
|
30
32
|
"minimist": "^1.2.6"
|
31
33
|
},
|
32
34
|
"devDependencies": {
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module.exports = {
|
2
|
+
ignorePatterns: ['.eslintrc.cjs'],
|
3
|
+
extends: [
|
4
|
+
'eslint:recommended',
|
5
|
+
'plugin:@typescript-eslint/recommended',
|
6
|
+
'plugin:vue/vue3-recommended',
|
7
|
+
'plugin:prettier-vue/recommended'
|
8
|
+
],
|
9
|
+
parser: 'vue-eslint-parser',
|
10
|
+
parserOptions: {
|
11
|
+
parser: '@typescript-eslint/parser',
|
12
|
+
sourceType: 'module'
|
13
|
+
},
|
14
|
+
rules: {
|
15
|
+
'@typescript-eslint/ban-ts-comment': 0
|
16
|
+
},
|
17
|
+
plugins: ['@typescript-eslint'],
|
18
|
+
root: true
|
19
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"semi": false,
|
3
|
+
"tabWidth": 2,
|
4
|
+
"singleQuote": true,
|
5
|
+
"printWidth": 80,
|
6
|
+
"trailingComma": "none",
|
7
|
+
"overrides": [
|
8
|
+
{
|
9
|
+
"files": ["*.json5"],
|
10
|
+
"options": {
|
11
|
+
"singleQuote": false,
|
12
|
+
"quoteProps": "preserve"
|
13
|
+
}
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"files": ["*.yml"],
|
17
|
+
"options": {
|
18
|
+
"singleQuote": false
|
19
|
+
}
|
20
|
+
}
|
21
|
+
]
|
22
|
+
}
|
@@ -3,15 +3,11 @@
|
|
3
3
|
<head>
|
4
4
|
<meta charset="UTF-8" />
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6
|
-
<title
|
7
|
-
<!--preload-links-->
|
6
|
+
<title></title>
|
8
7
|
</head>
|
9
8
|
|
10
9
|
<body>
|
11
|
-
<!--
|
12
|
-
<div id="app"
|
13
|
-
<!--dev-ssr-css-->
|
14
|
-
<!--entry-script-->
|
15
|
-
<!--initial-state-->
|
10
|
+
<!-- A body opening and closing tag is sufficient for Vitrify -->
|
11
|
+
<div id="app"></div>
|
16
12
|
</body>
|
17
13
|
</html>
|
@@ -1,9 +1,20 @@
|
|
1
1
|
<template>
|
2
|
-
<router-view
|
2
|
+
<router-view v-slot="{ Component }">
|
3
|
+
<Suspense>
|
4
|
+
<template #default>
|
5
|
+
<component :is="Component" />
|
6
|
+
</template>
|
7
|
+
<template #fallback>
|
8
|
+
<div>Loading...</div>
|
9
|
+
</template>
|
10
|
+
</Suspense>
|
11
|
+
</router-view>
|
3
12
|
</template>
|
4
13
|
|
5
|
-
<script
|
14
|
+
<script lang="ts">
|
15
|
+
export default {
|
16
|
+
name: 'App'
|
17
|
+
}
|
18
|
+
</script>
|
6
19
|
|
7
|
-
<
|
8
|
-
// do not remove, required for additionalData import
|
9
|
-
</style>
|
20
|
+
<script setup lang="ts"></script>
|
@@ -10,7 +10,12 @@
|
|
10
10
|
</q-card>
|
11
11
|
</template>
|
12
12
|
|
13
|
+
<script lang="ts">
|
14
|
+
export default {
|
15
|
+
name: 'HelloWorldComponent'
|
16
|
+
}
|
17
|
+
</script>
|
18
|
+
|
13
19
|
<script lang="ts" setup>
|
14
20
|
import logo from 'src/assets/quasar-logo-vertical.svg'
|
15
|
-
const name = 'HelloWorld'
|
16
21
|
</script>
|
@@ -2,14 +2,9 @@
|
|
2
2
|
<q-layout view="lHh Lpr lFf">
|
3
3
|
<q-header elevated>
|
4
4
|
<q-toolbar>
|
5
|
-
<q-btn
|
6
|
-
|
7
|
-
|
8
|
-
round
|
9
|
-
icon="menu"
|
10
|
-
aria-label="Menu"
|
11
|
-
@click="toggleLeftDrawer"
|
12
|
-
/>
|
5
|
+
<q-btn flat dense round aria-label="Menu" @click="toggleLeftDrawer">
|
6
|
+
<q-icon :name="matMenu" />
|
7
|
+
</q-btn>
|
13
8
|
|
14
9
|
<q-toolbar-title> Quasar App </q-toolbar-title>
|
15
10
|
|
@@ -32,6 +27,7 @@
|
|
32
27
|
<script setup lang="ts">
|
33
28
|
import { ref } from 'vue'
|
34
29
|
import { useQuasar } from 'quasar'
|
30
|
+
import { matMenu } from '@quasar/extras/material-icons'
|
35
31
|
|
36
32
|
const $q = useQuasar()
|
37
33
|
const leftDrawerOpen = ref(false)
|
@@ -4,14 +4,14 @@ const routes: RouteRecordRaw[] = [
|
|
4
4
|
{
|
5
5
|
path: '/',
|
6
6
|
component: () => import('src/layouts/MainLayout.vue'),
|
7
|
-
children: [{ path: '', component: () => import('src/pages/
|
7
|
+
children: [{ path: '', component: () => import('src/pages/IndexPage.vue') }]
|
8
8
|
},
|
9
9
|
|
10
10
|
// Always leave this as last one,
|
11
11
|
// but you can also remove it
|
12
12
|
{
|
13
13
|
path: '/:catchAll(.*)*',
|
14
|
-
component: () => import('src/pages/
|
14
|
+
component: () => import('src/pages/Error404Page.vue')
|
15
15
|
}
|
16
16
|
]
|
17
17
|
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import type { VitrifyConfig } from 'vitrify'
|
2
|
+
import { certificateFor } from 'devcert'
|
3
|
+
|
4
|
+
export default async function ({ mode, command }): Promise<VitrifyConfig> {
|
5
|
+
const config: VitrifyConfig = {
|
6
|
+
vitrify: {
|
7
|
+
hooks: {
|
8
|
+
onSetup: [new URL('src/setup.ts', import.meta.url)]
|
9
|
+
},
|
10
|
+
sass: {
|
11
|
+
variables: {
|
12
|
+
$primary: '#000000'
|
13
|
+
}
|
14
|
+
},
|
15
|
+
ssr: {
|
16
|
+
serverModules: []
|
17
|
+
}
|
18
|
+
},
|
19
|
+
quasar: {
|
20
|
+
// extras: ['material-icons'],
|
21
|
+
framework: {
|
22
|
+
components: [
|
23
|
+
// Deprecated
|
24
|
+
],
|
25
|
+
iconSet: 'svg-material-icons',
|
26
|
+
plugins: ['Dialog', 'Notify']
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
if (mode === 'development') {
|
31
|
+
config.server = {
|
32
|
+
https: await certificateFor('vitrify.test')
|
33
|
+
}
|
34
|
+
}
|
35
|
+
return config
|
36
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module.exports = {
|
2
|
+
ignorePatterns: ['.eslintrc.cjs'],
|
3
|
+
extends: [
|
4
|
+
'eslint:recommended',
|
5
|
+
'plugin:@typescript-eslint/recommended',
|
6
|
+
'plugin:vue/vue3-recommended',
|
7
|
+
'plugin:prettier-vue/recommended'
|
8
|
+
],
|
9
|
+
parser: 'vue-eslint-parser',
|
10
|
+
parserOptions: {
|
11
|
+
parser: '@typescript-eslint/parser',
|
12
|
+
sourceType: 'module'
|
13
|
+
},
|
14
|
+
rules: {
|
15
|
+
'@typescript-eslint/ban-ts-comment': 0
|
16
|
+
},
|
17
|
+
plugins: ['@typescript-eslint'],
|
18
|
+
root: true
|
19
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"semi": false,
|
3
|
+
"tabWidth": 2,
|
4
|
+
"singleQuote": true,
|
5
|
+
"printWidth": 80,
|
6
|
+
"trailingComma": "none",
|
7
|
+
"overrides": [
|
8
|
+
{
|
9
|
+
"files": ["*.json5"],
|
10
|
+
"options": {
|
11
|
+
"singleQuote": false,
|
12
|
+
"quoteProps": "preserve"
|
13
|
+
}
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"files": ["*.yml"],
|
17
|
+
"options": {
|
18
|
+
"singleQuote": false
|
19
|
+
}
|
20
|
+
}
|
21
|
+
]
|
22
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<template>
|
2
|
+
<div>
|
3
|
+
{{ lang.helloWorld }}
|
4
|
+
{{ iconSet.someIcon }}
|
5
|
+
</div>
|
6
|
+
</template>
|
7
|
+
|
8
|
+
<script lang="ts">
|
9
|
+
export default {
|
10
|
+
name: 'HelloWorld'
|
11
|
+
}
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script setup lang="ts">
|
15
|
+
import { useIconSet } from '../icon-set'
|
16
|
+
import { useLang } from '../lang'
|
17
|
+
|
18
|
+
const lang = useLang()
|
19
|
+
const iconSet = useIconSet()
|
20
|
+
</script>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
export interface IconSet {
|
2
|
+
name: string
|
3
|
+
someIcon: string
|
4
|
+
}
|
5
|
+
|
6
|
+
import type { Ref } from 'vue'
|
7
|
+
import { ref } from 'vue'
|
8
|
+
import material from './material-icons'
|
9
|
+
export const iconSet = ref(material)
|
10
|
+
|
11
|
+
const iconSets = import.meta.glob<{ default: IconSet }>([
|
12
|
+
'./*.ts',
|
13
|
+
'!./index.ts'
|
14
|
+
])
|
15
|
+
|
16
|
+
export const defineIconSet = (iconSet: IconSet) => {
|
17
|
+
return iconSet
|
18
|
+
}
|
19
|
+
|
20
|
+
export const useIconSet = () => {
|
21
|
+
return iconSet as Ref<IconSet>
|
22
|
+
}
|
23
|
+
|
24
|
+
let loadingIconSet = false
|
25
|
+
export const loadIconSet = async (name: string) => {
|
26
|
+
if (!loadingIconSet) {
|
27
|
+
loadingIconSet = true
|
28
|
+
try {
|
29
|
+
const data = (await iconSets[`./${name}.ts`]()).default
|
30
|
+
|
31
|
+
if (data) {
|
32
|
+
iconSet.value = data
|
33
|
+
}
|
34
|
+
} catch (e) {
|
35
|
+
if (import.meta.env.DEBUG) console.error(e)
|
36
|
+
throw new Error(`[quasar-components] Failed to load ${name} icon set.`)
|
37
|
+
}
|
38
|
+
loadingIconSet = false
|
39
|
+
}
|
40
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
export interface Language {
|
2
|
+
isoName: string
|
3
|
+
helloWorld: string
|
4
|
+
}
|
5
|
+
|
6
|
+
import type { Ref } from 'vue'
|
7
|
+
import { ref } from 'vue'
|
8
|
+
import en from './en-US'
|
9
|
+
export const lang = ref(en)
|
10
|
+
|
11
|
+
const locales = import.meta.glob<{ default: Language }>([
|
12
|
+
'./*.ts',
|
13
|
+
'!./index.ts'
|
14
|
+
])
|
15
|
+
|
16
|
+
export const defineLang = (lang: Language) => {
|
17
|
+
return lang
|
18
|
+
}
|
19
|
+
|
20
|
+
export const useLang = () => {
|
21
|
+
return lang as Ref<Language>
|
22
|
+
}
|
23
|
+
|
24
|
+
let loadingLanguage = false
|
25
|
+
export const loadLang = async (isoName: string) => {
|
26
|
+
if (!loadingLanguage) {
|
27
|
+
loadingLanguage = true
|
28
|
+
try {
|
29
|
+
const data = (await locales[`./${isoName}.ts`]()).default
|
30
|
+
|
31
|
+
if (data) {
|
32
|
+
lang.value = data
|
33
|
+
}
|
34
|
+
} catch (e) {
|
35
|
+
if (import.meta.env.DEBUG) console.error(e)
|
36
|
+
throw new Error(
|
37
|
+
`[quasar-components] Failed to load ${isoName} language file.`
|
38
|
+
)
|
39
|
+
}
|
40
|
+
loadingLanguage = false
|
41
|
+
}
|
42
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export default {}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
const components = import.meta.glob('./components/*.vue')
|
2
|
+
|
3
|
+
import { loadLang } from './lang'
|
4
|
+
|
5
|
+
function install(app: any, options: { lang: string }) {
|
6
|
+
loadLang(options?.lang || 'en-us')
|
7
|
+
for (const path in components) {
|
8
|
+
components[path]().then((mod) => {
|
9
|
+
// @ts-ignore
|
10
|
+
app.component(mod.name, mod)
|
11
|
+
})
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
export { install }
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import type { Plugin } from 'vite'
|
2
|
+
import { promises } from 'fs'
|
3
|
+
const { readFile } = promises
|
4
|
+
|
5
|
+
export default async function ({
|
6
|
+
buildFromSrc
|
7
|
+
}: {
|
8
|
+
buildFromSrc?: boolean
|
9
|
+
} = {}): Promise<Plugin> {
|
10
|
+
const pkgJson = JSON.parse(
|
11
|
+
await readFile(
|
12
|
+
new URL('../package.json', import.meta.url).pathname,
|
13
|
+
'utf-8'
|
14
|
+
)
|
15
|
+
)
|
16
|
+
const exports = pkgJson.exports as Record<
|
17
|
+
string,
|
18
|
+
{
|
19
|
+
types: string
|
20
|
+
import: string
|
21
|
+
src: string
|
22
|
+
}
|
23
|
+
>[]
|
24
|
+
const name = pkgJson.name
|
25
|
+
|
26
|
+
return {
|
27
|
+
name: `${name}-plugin`,
|
28
|
+
config(config, { mode }) {
|
29
|
+
if (mode === 'development' || buildFromSrc) {
|
30
|
+
const alias = Object.entries(exports)
|
31
|
+
.map(([key, val]) => {
|
32
|
+
return {
|
33
|
+
find: name + key.slice(1),
|
34
|
+
replacement: new URL('.' + val.src, import.meta.url).pathname
|
35
|
+
}
|
36
|
+
})
|
37
|
+
.sort(
|
38
|
+
(a, b) =>
|
39
|
+
(b.find.match(/\//g) || []).length -
|
40
|
+
(a.find.match(/\//g) || []).length
|
41
|
+
)
|
42
|
+
|
43
|
+
return {
|
44
|
+
resolve: {
|
45
|
+
alias
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
return {}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"target": "esnext",
|
4
|
+
"module": "esnext",
|
5
|
+
"lib": ["esnext", "DOM"],
|
6
|
+
"strict": true,
|
7
|
+
"skipLibCheck": true,
|
8
|
+
"moduleResolution": "node",
|
9
|
+
"declaration": true,
|
10
|
+
"outDir": "dist",
|
11
|
+
"emitDeclarationOnly": true,
|
12
|
+
"declarationDir": "./dist/types",
|
13
|
+
"isolatedModules": true,
|
14
|
+
"types": ["vite/client"]
|
15
|
+
},
|
16
|
+
"include": ["./src/ui"]
|
17
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { defineConfig } from 'vite'
|
2
|
+
import vue from '@vitejs/plugin-vue'
|
3
|
+
import Components from 'unplugin-vue-components/vite'
|
4
|
+
import { QuasarResolver } from 'unplugin-vue-components/resolvers'
|
5
|
+
|
6
|
+
export default defineConfig(async ({ command, mode }) => ({
|
7
|
+
plugins: [
|
8
|
+
vue(),
|
9
|
+
Components({
|
10
|
+
resolvers: [QuasarResolver()]
|
11
|
+
})
|
12
|
+
],
|
13
|
+
build: {
|
14
|
+
// minify: false,
|
15
|
+
lib: {
|
16
|
+
fileName: 'ui',
|
17
|
+
formats: ['es'],
|
18
|
+
entry: './src/ui/index.ts'
|
19
|
+
},
|
20
|
+
minify: false,
|
21
|
+
emptyOutDir: true,
|
22
|
+
rollupOptions: {
|
23
|
+
/**
|
24
|
+
* For building subpath exports
|
25
|
+
*/
|
26
|
+
// input: {
|
27
|
+
// subodule: new URL(
|
28
|
+
// './src/ui/submodule/index.ts',
|
29
|
+
// import.meta.url
|
30
|
+
// ).pathname
|
31
|
+
// },
|
32
|
+
output: {
|
33
|
+
entryFileNames: '[name].js'
|
34
|
+
},
|
35
|
+
/**
|
36
|
+
* Add (UI) frameworks that are used
|
37
|
+
*/
|
38
|
+
external: ['vue', 'vue-router', 'quasar']
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}))
|
package/dist/index.js
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'fs';
|
2
|
-
import Handlebars from 'handlebars';
|
3
|
-
export const renderAll = ({ inputPath, outputPath, templateVariables, exclude }) => {
|
4
|
-
if (!existsSync(outputPath)) {
|
5
|
-
mkdirSync(outputPath);
|
6
|
-
}
|
7
|
-
const content = readdirSync(inputPath, { withFileTypes: true });
|
8
|
-
const files = content
|
9
|
-
.filter((dirent) => !dirent.isDirectory())
|
10
|
-
.map((dirent) => dirent.name);
|
11
|
-
const directories = content
|
12
|
-
.filter((dirent) => dirent.isDirectory())
|
13
|
-
.map((dirent) => dirent.name);
|
14
|
-
for (let file of files) {
|
15
|
-
const fileContent = readFileSync(new URL(`./${file}`, inputPath), 'utf-8');
|
16
|
-
let output;
|
17
|
-
if (file.endsWith('.hbs')) {
|
18
|
-
const template = Handlebars.compile(fileContent);
|
19
|
-
output = template(templateVariables);
|
20
|
-
}
|
21
|
-
else {
|
22
|
-
output = fileContent;
|
23
|
-
}
|
24
|
-
if (file.startsWith('_'))
|
25
|
-
file = file.replace('_', '.');
|
26
|
-
const fileOutputPath = new URL(file.replace('.hbs', ''), outputPath);
|
27
|
-
writeFileSync(fileOutputPath, output, 'utf-8');
|
28
|
-
}
|
29
|
-
for (const directory of directories) {
|
30
|
-
renderAll({
|
31
|
-
inputPath: new URL(`./${directory}/`, inputPath),
|
32
|
-
outputPath: new URL(`./${directory}/`, outputPath),
|
33
|
-
templateVariables
|
34
|
-
});
|
35
|
-
}
|
36
|
-
};
|
37
|
-
export const render = ({ inputPath, outputPath, templateVariables }) => {
|
38
|
-
const outputFolder = new URL('./', outputPath);
|
39
|
-
if (!existsSync(outputFolder)) {
|
40
|
-
mkdirSync(outputFolder);
|
41
|
-
}
|
42
|
-
const fileContent = readFileSync(new URL(inputPath), 'utf-8');
|
43
|
-
const template = Handlebars.compile(fileContent);
|
44
|
-
const compiled = template(templateVariables);
|
45
|
-
writeFileSync(outputPath, compiled, 'utf-8');
|
46
|
-
};
|
47
|
-
export const renderTemplate = ({ templateUrl, templateVariables, outputDir }) => {
|
48
|
-
if (outputDir.pathname[outputDir.pathname.length - 1] !== '/') {
|
49
|
-
throw new Error('outputDir is not a directory. Make sure the URL ends with a /');
|
50
|
-
}
|
51
|
-
// const templatesDir = new URL(`../templates/`, import.meta.url)
|
52
|
-
// const templateDir = new URL(`../templates/${template}/`, import.meta.url)
|
53
|
-
/**
|
54
|
-
* General Quasar project files
|
55
|
-
*/
|
56
|
-
// render({
|
57
|
-
// inputPath: new URL('./package.json.hbs', templatesDir),
|
58
|
-
// outputPath: new URL(`./package.json`, outputDir),
|
59
|
-
// templateVariables
|
60
|
-
// })
|
61
|
-
// render({
|
62
|
-
// inputPath: new URL('./quasar.conf.js', templatesDir),
|
63
|
-
// outputPath: new URL(`./quasar.conf.js`, outputDir),
|
64
|
-
// templateVariables
|
65
|
-
// })
|
66
|
-
// render({
|
67
|
-
// inputPath: new URL('_gitignore', templateUrl),
|
68
|
-
// outputPath: new URL(`.gitignore`, outputDir),
|
69
|
-
// templateVariables
|
70
|
-
// })
|
71
|
-
/**
|
72
|
-
* Specific template files
|
73
|
-
*/
|
74
|
-
renderAll({
|
75
|
-
inputPath: new URL(`./`, templateUrl),
|
76
|
-
outputPath: new URL(`./`, outputDir),
|
77
|
-
templateVariables
|
78
|
-
});
|
79
|
-
};
|
80
|
-
// renderTemplate({
|
81
|
-
// template: 'quasar-ts',
|
82
|
-
// outputDir: new URL('./generated/', import.meta.url)
|
83
|
-
// })
|
package/dist/types/index.d.ts
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
export declare const renderAll: ({ inputPath, outputPath, templateVariables, exclude }: {
|
2
|
-
inputPath: URL;
|
3
|
-
outputPath: URL;
|
4
|
-
templateVariables: Record<string, any>;
|
5
|
-
exclude?: string[] | undefined;
|
6
|
-
}) => void;
|
7
|
-
export declare const render: ({ inputPath, outputPath, templateVariables }: {
|
8
|
-
inputPath: URL;
|
9
|
-
outputPath: URL;
|
10
|
-
templateVariables: Record<string, any>;
|
11
|
-
}) => void;
|
12
|
-
export declare const renderTemplate: ({ templateUrl, templateVariables, outputDir }: {
|
13
|
-
templateUrl: URL;
|
14
|
-
templateVariables: Record<string, any>;
|
15
|
-
outputDir: URL;
|
16
|
-
}) => void;
|
@@ -1,29 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "{{ name }}",
|
3
|
-
"productName": "{{ productName }}",
|
4
|
-
"version": "1.0.0",
|
5
|
-
"type": "module",
|
6
|
-
"description": "{{ description }}",
|
7
|
-
"scripts": {
|
8
|
-
"dev": "vitrify dev",
|
9
|
-
"build": "vitrify build",
|
10
|
-
"build:ssr": "vitrify build -m ssr",
|
11
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
12
|
-
},
|
13
|
-
"author": "{{ author }}",
|
14
|
-
"dependencies": {
|
15
|
-
"@fastify/static": "^6.4.0",
|
16
|
-
"fastify": "^4.0.0",
|
17
|
-
"fastify-plugin": "^3.0.1",
|
18
|
-
"vue": "^3.2.37",
|
19
|
-
"vue-router": "^4.0.12",
|
20
|
-
"@quasar/extras": "^1.13.1",
|
21
|
-
"quasar": "^2.6.0"
|
22
|
-
},
|
23
|
-
"devDependencies": {
|
24
|
-
"@vue/server-renderer": "^3.2.37",
|
25
|
-
"critters": "^0.0.16",
|
26
|
-
"vitrify": "^0.6.0",
|
27
|
-
"typescript": "^4.6.2"
|
28
|
-
}
|
29
|
-
}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"compilerOptions": {
|
3
|
-
"target": "esnext",
|
4
|
-
"useDefineForClassFields": true,
|
5
|
-
"module": "esnext",
|
6
|
-
"moduleResolution": "node",
|
7
|
-
"strict": true,
|
8
|
-
"jsx": "preserve",
|
9
|
-
"sourceMap": true,
|
10
|
-
"resolveJsonModule": true,
|
11
|
-
"esModuleInterop": true,
|
12
|
-
"lib": ["esnext", "dom"]
|
13
|
-
},
|
14
|
-
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
|
15
|
-
}
|
@@ -1,23 +0,0 @@
|
|
1
|
-
export default function ({ mode, command }) {
|
2
|
-
return {
|
3
|
-
vitrify: {
|
4
|
-
hooks: {
|
5
|
-
// Vitrify hooks
|
6
|
-
},
|
7
|
-
sass: {
|
8
|
-
variables: {
|
9
|
-
$primary: '#000000'
|
10
|
-
}
|
11
|
-
}
|
12
|
-
},
|
13
|
-
quasar: {
|
14
|
-
extras: ['material-icons'],
|
15
|
-
framework: {
|
16
|
-
components: [
|
17
|
-
// Deprecated
|
18
|
-
],
|
19
|
-
plugins: []
|
20
|
-
}
|
21
|
-
}
|
22
|
-
}
|
23
|
-
}
|