vitrify 0.1.1 → 0.2.2
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/app-urls.js +14 -10
- package/dist/bin/cli.js +14 -12
- package/dist/bin/dev.js +5 -3
- package/dist/bin/run.js +5 -2
- package/dist/{vue → frameworks/vue}/fastify-ssr-plugin.js +0 -0
- package/dist/{vue → frameworks/vue}/prerender.js +1 -1
- package/dist/{vue → frameworks/vue}/server.js +0 -0
- package/dist/index.js +73 -20
- package/dist/plugins/quasar.js +19 -14
- package/dist/types/app-urls.d.ts +7 -6
- package/dist/types/bin/run.d.ts +2 -2
- package/dist/types/{vue → frameworks/vue}/fastify-ssr-plugin.d.ts +1 -1
- package/dist/types/{vue → frameworks/vue}/prerender.d.ts +1 -1
- package/dist/types/{vue → frameworks/vue}/server.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/vitrify-config.d.ts +4 -1
- package/package.json +16 -18
- package/src/node/app-urls.ts +38 -0
- package/src/node/bin/build.ts +87 -0
- package/src/node/bin/cli.ts +157 -0
- package/src/node/bin/dev.ts +138 -0
- package/src/node/bin/run.ts +47 -0
- package/src/node/bin/test.ts +24 -0
- package/src/node/frameworks/vue/fastify-ssr-plugin.ts +137 -0
- package/src/node/frameworks/vue/prerender.ts +49 -0
- package/src/node/frameworks/vue/server.ts +38 -0
- package/src/node/helpers/logger.ts +142 -0
- package/src/node/helpers/routes.ts +29 -0
- package/src/node/helpers/ssr.ts.bak +52 -0
- package/src/node/helpers/utils.ts +37 -0
- package/src/node/index.ts +402 -0
- package/src/node/plugins/index.ts +12 -0
- package/src/node/plugins/quasar.ts +387 -0
- package/src/node/vitrify-config.ts +79 -0
- package/src/vite/vue/ssr/fastify-ssr-plugin.ts +1 -1
- package/src/vite/vue/ssr/prerender.ts +1 -1
- package/src/vite/vue/ssr/server.ts +6 -3
- package/src/vite/vue/components.d.ts +0 -25
package/dist/app-urls.js
CHANGED
|
@@ -7,17 +7,18 @@ export const getPkgJsonDir = (dir) => {
|
|
|
7
7
|
}
|
|
8
8
|
return getPkgJsonDir(new URL('..', dir));
|
|
9
9
|
};
|
|
10
|
-
export const
|
|
11
|
-
export const
|
|
12
|
-
export const
|
|
13
|
-
export const
|
|
10
|
+
export const getAppDir = () => getPkgJsonDir(new URL(`file://${process.cwd()}/`));
|
|
11
|
+
export const getCliDir = () => getPkgJsonDir(new URL('./', import.meta.url));
|
|
12
|
+
export const getCliViteDir = (cliDir) => new URL('src/vite/', cliDir);
|
|
13
|
+
export const getSrcDir = (appDir) => new URL('src/', appDir);
|
|
14
|
+
export const getCwd = () => new URL(`file://${process.cwd()}/`);
|
|
14
15
|
// export const quasarDir = getPkgJsonDir(new URL('./', await resolve('quasar', appDir.href)))
|
|
15
|
-
export const parsePath = (path) => {
|
|
16
|
+
export const parsePath = (path, basePath) => {
|
|
16
17
|
if (path) {
|
|
17
18
|
if (path.slice(-1) !== '/')
|
|
18
19
|
path += '/';
|
|
19
20
|
if (path.startsWith('.')) {
|
|
20
|
-
return new URL(path,
|
|
21
|
+
return new URL(path, basePath);
|
|
21
22
|
}
|
|
22
23
|
else if (path) {
|
|
23
24
|
return new URL(`file://${path}`);
|
|
@@ -25,8 +26,11 @@ export const parsePath = (path) => {
|
|
|
25
26
|
}
|
|
26
27
|
return;
|
|
27
28
|
};
|
|
28
|
-
export const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
export const getProjectURLs = (appDir, cliDir) => {
|
|
30
|
+
const srcDir = getSrcDir(appDir);
|
|
31
|
+
return {
|
|
32
|
+
src: (path) => new URL(path, srcDir),
|
|
33
|
+
app: (path) => new URL(path, appDir),
|
|
34
|
+
cli: (path) => new URL(path, cliDir)
|
|
35
|
+
};
|
|
32
36
|
};
|
package/dist/bin/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import cac from 'cac';
|
|
3
|
-
import {
|
|
3
|
+
import { getAppDir, parsePath } from '../app-urls.js';
|
|
4
4
|
import { printHttpServerUrls } from '../helpers/logger.js';
|
|
5
5
|
const cli = cac('vitrify');
|
|
6
6
|
cli
|
|
@@ -13,21 +13,21 @@ cli
|
|
|
13
13
|
.option('--productName [productName]', 'Product name')
|
|
14
14
|
.action(async (options) => {
|
|
15
15
|
const { build } = await import('./build.js');
|
|
16
|
-
let prerender;
|
|
17
16
|
let appDir;
|
|
17
|
+
let prerender, ssrFunctions;
|
|
18
18
|
if (options.appDir) {
|
|
19
19
|
if (options.appDir.slice(-1) !== '/')
|
|
20
20
|
options.appDir += '/';
|
|
21
21
|
appDir = new URL(`file://${options.appDir}`);
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
|
-
appDir =
|
|
24
|
+
appDir = getAppDir();
|
|
25
25
|
}
|
|
26
|
-
const baseOutDir = parsePath(options.outDir) || new URL('dist/', appDir);
|
|
26
|
+
const baseOutDir = parsePath(options.outDir, appDir) || new URL('dist/', appDir);
|
|
27
27
|
const args = {
|
|
28
28
|
base: options.base,
|
|
29
29
|
appDir,
|
|
30
|
-
publicDir: parsePath(options.publicDir)
|
|
30
|
+
publicDir: parsePath(options.publicDir, appDir)
|
|
31
31
|
};
|
|
32
32
|
switch (options.mode) {
|
|
33
33
|
case 'csr':
|
|
@@ -59,14 +59,15 @@ cli
|
|
|
59
59
|
...args,
|
|
60
60
|
outDir: new URL('ssr/server/', baseOutDir).pathname
|
|
61
61
|
});
|
|
62
|
-
prerender =
|
|
62
|
+
({ prerender, ssrFunctions } = await import(new URL('ssr/server/prerender.mjs', baseOutDir).pathname));
|
|
63
63
|
prerender({
|
|
64
64
|
outDir: new URL('static/', baseOutDir).pathname,
|
|
65
65
|
templatePath: new URL('static/index.html', baseOutDir).pathname,
|
|
66
66
|
manifestPath: new URL('static/ssr-manifest.json', baseOutDir)
|
|
67
67
|
.pathname,
|
|
68
68
|
entryServerPath: new URL('ssr/server/entry-server.mjs', baseOutDir)
|
|
69
|
-
.pathname
|
|
69
|
+
.pathname,
|
|
70
|
+
ssrFunctions
|
|
70
71
|
});
|
|
71
72
|
break;
|
|
72
73
|
default:
|
|
@@ -87,22 +88,23 @@ cli
|
|
|
87
88
|
options.host = '0.0.0.0';
|
|
88
89
|
}
|
|
89
90
|
const { createServer } = await import('./dev.js');
|
|
91
|
+
const cwd = (await import('../app-urls.js')).getCwd();
|
|
90
92
|
switch (options.mode) {
|
|
91
93
|
case 'ssr':
|
|
92
94
|
;
|
|
93
95
|
({ server, vite } = await createServer({
|
|
94
96
|
mode: 'ssr',
|
|
95
97
|
host: options.host,
|
|
96
|
-
appDir: parsePath(options.appDir),
|
|
97
|
-
publicDir: parsePath(options.publicDir)
|
|
98
|
+
appDir: parsePath(options.appDir, cwd),
|
|
99
|
+
publicDir: parsePath(options.publicDir, cwd)
|
|
98
100
|
}));
|
|
99
101
|
break;
|
|
100
102
|
default:
|
|
101
103
|
;
|
|
102
104
|
({ server, vite } = await createServer({
|
|
103
105
|
host: options.host,
|
|
104
|
-
appDir: parsePath(options.appDir),
|
|
105
|
-
publicDir: parsePath(options.publicDir)
|
|
106
|
+
appDir: parsePath(options.appDir, cwd),
|
|
107
|
+
publicDir: parsePath(options.publicDir, cwd)
|
|
106
108
|
}));
|
|
107
109
|
break;
|
|
108
110
|
}
|
|
@@ -118,7 +120,7 @@ cli.command('test').action(async (options) => {
|
|
|
118
120
|
appDir = new URL(`file://${options.appDir}`);
|
|
119
121
|
}
|
|
120
122
|
else {
|
|
121
|
-
appDir =
|
|
123
|
+
appDir = getAppDir();
|
|
122
124
|
}
|
|
123
125
|
await test({
|
|
124
126
|
appDir
|
package/dist/bin/dev.js
CHANGED
|
@@ -3,10 +3,11 @@ import { baseConfig } from '../index.js';
|
|
|
3
3
|
import fastify from 'fastify';
|
|
4
4
|
import { readFileSync } from 'fs';
|
|
5
5
|
export async function createServer({ port = 3000, logLevel = 'info', mode = 'csr', framework = 'vue', host, appDir, publicDir }) {
|
|
6
|
-
const {
|
|
7
|
-
const cwd =
|
|
6
|
+
const { getAppDir, getCliDir, getCwd } = await import('../app-urls.js');
|
|
7
|
+
const cwd = getCwd();
|
|
8
|
+
const cliDir = getCliDir();
|
|
8
9
|
if (!appDir)
|
|
9
|
-
appDir =
|
|
10
|
+
appDir = getAppDir();
|
|
10
11
|
const { fastifySsrPlugin } = await import(`../${framework}/fastify-ssr-plugin.js`);
|
|
11
12
|
/**
|
|
12
13
|
* @type {import('vite').ViteDevServer}
|
|
@@ -25,6 +26,7 @@ export async function createServer({ port = 3000, logLevel = 'info', mode = 'csr
|
|
|
25
26
|
fs: {
|
|
26
27
|
allow: [
|
|
27
28
|
searchForWorkspaceRoot(process.cwd()),
|
|
29
|
+
searchForWorkspaceRoot(appDir.pathname),
|
|
28
30
|
searchForWorkspaceRoot(cliDir.pathname)
|
|
29
31
|
// appDir.pathname,
|
|
30
32
|
]
|
package/dist/bin/run.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { projectURLs } from '../app-urls.js';
|
|
2
1
|
import { promises as fs } from 'fs';
|
|
3
2
|
import readline from 'readline';
|
|
4
|
-
|
|
3
|
+
import { getAppDir, getCliDir, getProjectURLs } from '../app-urls.js';
|
|
5
4
|
const rl = readline.createInterface({
|
|
6
5
|
input: process.stdin,
|
|
7
6
|
output: process.stdout
|
|
8
7
|
});
|
|
9
8
|
export async function run(filePath) {
|
|
10
9
|
const { run } = await import(filePath);
|
|
10
|
+
const appDir = getAppDir();
|
|
11
|
+
const cliDir = getCliDir();
|
|
12
|
+
const projectURLs = getProjectURLs(appDir, cliDir);
|
|
13
|
+
const pkg = JSON.parse((await fs.readFile(projectURLs.cli('package.json'), 'utf-8')).toString());
|
|
11
14
|
if (!run)
|
|
12
15
|
throw new Error(`${filePath} does not have an export named run. Aborting...`);
|
|
13
16
|
rl.question(`
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { promises as fs } from 'fs';
|
|
2
|
-
import { routesToPaths } from '
|
|
2
|
+
import { routesToPaths } from '../../helpers/routes.js';
|
|
3
3
|
export const prerender = async ({ outDir, templatePath, manifestPath, entryServerPath, ssrFunctions }) => {
|
|
4
4
|
const promises = [];
|
|
5
5
|
const template = (await fs.readFile(templatePath)).toString();
|
|
File without changes
|
package/dist/index.js
CHANGED
|
@@ -17,11 +17,22 @@ export const VIRTUAL_MODULES = [
|
|
|
17
17
|
'virtual:static-imports'
|
|
18
18
|
];
|
|
19
19
|
export const baseConfig = async ({ ssr, appDir, publicDir, command = 'build', mode = 'production', framework = 'vue', pwa = false }) => {
|
|
20
|
-
const {
|
|
21
|
-
|
|
20
|
+
const { getAppDir, getCliDir, getCliViteDir, getSrcDir, getCwd } = await import('./app-urls.js');
|
|
21
|
+
if (!appDir) {
|
|
22
|
+
appDir = getAppDir();
|
|
23
|
+
}
|
|
24
|
+
const srcDir = getSrcDir(appDir);
|
|
25
|
+
const cwd = getCwd();
|
|
26
|
+
const cliDir = getCliDir();
|
|
27
|
+
const cliViteDir = getCliViteDir(cliDir);
|
|
28
|
+
// const {
|
|
29
|
+
// appDir: tempAppDir,
|
|
30
|
+
// cliDir,
|
|
31
|
+
// cliViteDir,
|
|
32
|
+
// srcDir
|
|
33
|
+
// } = await import('./app-urls.js')
|
|
34
|
+
// const cwd = appDir || tempAppDir
|
|
22
35
|
const frameworkDir = new URL(`${framework}/`, cliViteDir);
|
|
23
|
-
if (!appDir)
|
|
24
|
-
appDir = tempAppDir;
|
|
25
36
|
// const localPackages = ['vue', 'vue-router', 'quasar']
|
|
26
37
|
const localPackages = ['vue', 'vue-router'];
|
|
27
38
|
const cliPackages = ['vitest'];
|
|
@@ -61,17 +72,10 @@ export const baseConfig = async ({ ssr, appDir, publicDir, command = 'build', mo
|
|
|
61
72
|
console.log('No vitrify.config.js file found, using defaults');
|
|
62
73
|
vitrifyConfig = {};
|
|
63
74
|
}
|
|
64
|
-
|
|
75
|
+
let { productName = 'Product name' } = JSON.parse(readFileSync(new URL('package.json', appDir).pathname, {
|
|
65
76
|
encoding: 'utf-8'
|
|
66
77
|
}));
|
|
67
78
|
const fastifySetup = vitrifyConfig.vitrify?.fastify?.setup || ((fastify) => { });
|
|
68
|
-
const sass = [];
|
|
69
|
-
const sassVariables = vitrifyConfig.vitrify?.sassVariables;
|
|
70
|
-
if (sassVariables) {
|
|
71
|
-
for (const variable in sassVariables) {
|
|
72
|
-
sass.push(`${variable}: ${sassVariables[variable]}`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
79
|
const ssrTransformCustomDir = () => {
|
|
76
80
|
return {
|
|
77
81
|
props: [],
|
|
@@ -93,6 +97,8 @@ export const baseConfig = async ({ ssr, appDir, publicDir, command = 'build', mo
|
|
|
93
97
|
let onMountedHooks;
|
|
94
98
|
let globalCss;
|
|
95
99
|
let staticImports;
|
|
100
|
+
let sassVariables;
|
|
101
|
+
let additionalData;
|
|
96
102
|
const plugins = [
|
|
97
103
|
vuePlugin({
|
|
98
104
|
template: {
|
|
@@ -121,7 +127,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, command = 'build', mo
|
|
|
121
127
|
// // quasarDir: packageUrls.quasar
|
|
122
128
|
// }),
|
|
123
129
|
{
|
|
124
|
-
name: 'vitrify-
|
|
130
|
+
name: 'vitrify-setup',
|
|
125
131
|
enforce: 'post',
|
|
126
132
|
config: async (config, env) => {
|
|
127
133
|
bootFunctions = config.vitrify?.bootFunctions || [];
|
|
@@ -129,6 +135,27 @@ export const baseConfig = async ({ ssr, appDir, publicDir, command = 'build', mo
|
|
|
129
135
|
onMountedHooks = config.vitrify?.hooks?.onMounted || [];
|
|
130
136
|
globalCss = config.vitrify?.globalCss || [];
|
|
131
137
|
staticImports = config.vitrify?.staticImports || {};
|
|
138
|
+
sassVariables = config.vitrify?.sass?.variables || {};
|
|
139
|
+
additionalData = config.vitrify?.sass?.additionalData || [];
|
|
140
|
+
return {
|
|
141
|
+
css: {
|
|
142
|
+
preprocessorOptions: {
|
|
143
|
+
sass: {
|
|
144
|
+
additionalData: [
|
|
145
|
+
...Object.entries(sassVariables).map(([key, value]) => `${key}: ${value}`),
|
|
146
|
+
...additionalData
|
|
147
|
+
// config.css?.preprocessorOptions?.sass.additionalData
|
|
148
|
+
].join('\n')
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
},
|
|
154
|
+
configResolved: (config) => {
|
|
155
|
+
if (process.env.DEBUG) {
|
|
156
|
+
console.log(config.css?.preprocessorOptions?.sass.additionalData);
|
|
157
|
+
console.log(config.optimizeDeps);
|
|
158
|
+
}
|
|
132
159
|
},
|
|
133
160
|
resolveId(id) {
|
|
134
161
|
if (VIRTUAL_MODULES.includes(id))
|
|
@@ -170,6 +197,16 @@ export const baseConfig = async ({ ssr, appDir, publicDir, command = 'build', mo
|
|
|
170
197
|
plugins.unshift({
|
|
171
198
|
name: 'html-transform',
|
|
172
199
|
enforce: 'pre',
|
|
200
|
+
transform: (code, id) => {
|
|
201
|
+
if (id.endsWith('App.vue')) {
|
|
202
|
+
code =
|
|
203
|
+
code +
|
|
204
|
+
`<style lang="sass">
|
|
205
|
+
// do not remove, required for additionalData import
|
|
206
|
+
</style>`;
|
|
207
|
+
}
|
|
208
|
+
return code;
|
|
209
|
+
},
|
|
173
210
|
transformIndexHtml: {
|
|
174
211
|
enforce: 'pre',
|
|
175
212
|
transform: (html) => {
|
|
@@ -191,6 +228,21 @@ export const baseConfig = async ({ ssr, appDir, publicDir, command = 'build', mo
|
|
|
191
228
|
}
|
|
192
229
|
}
|
|
193
230
|
});
|
|
231
|
+
plugins.unshift({
|
|
232
|
+
name: 'product-name',
|
|
233
|
+
enforce: 'post',
|
|
234
|
+
config: (config, env) => {
|
|
235
|
+
if (config.vitrify?.productName)
|
|
236
|
+
productName = config.vitrify?.productName;
|
|
237
|
+
},
|
|
238
|
+
transformIndexHtml: {
|
|
239
|
+
enforce: 'post',
|
|
240
|
+
transform: (html) => {
|
|
241
|
+
html = html.replace('<!--product-name-->', productName);
|
|
242
|
+
return html;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
});
|
|
194
246
|
}
|
|
195
247
|
const alias = [
|
|
196
248
|
{ find: 'src', replacement: srcDir.pathname },
|
|
@@ -244,6 +296,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, command = 'build', mo
|
|
|
244
296
|
? {
|
|
245
297
|
input: [
|
|
246
298
|
new URL('ssr/entry-server.ts', frameworkDir).pathname,
|
|
299
|
+
new URL('ssr/prerender.ts', frameworkDir).pathname,
|
|
247
300
|
new URL('ssr/server.ts', frameworkDir).pathname
|
|
248
301
|
],
|
|
249
302
|
output: {
|
|
@@ -267,13 +320,13 @@ export const baseConfig = async ({ ssr, appDir, publicDir, command = 'build', mo
|
|
|
267
320
|
}
|
|
268
321
|
}
|
|
269
322
|
},
|
|
270
|
-
css: {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
},
|
|
323
|
+
// css: {
|
|
324
|
+
// preprocessorOptions: {
|
|
325
|
+
// sass: {
|
|
326
|
+
// additionalData: sass ? [...sass].join('\n') : undefined
|
|
327
|
+
// }
|
|
328
|
+
// }
|
|
329
|
+
// },
|
|
277
330
|
ssr: {
|
|
278
331
|
// Create a SSR bundle
|
|
279
332
|
noExternal: [
|
package/dist/plugins/quasar.js
CHANGED
|
@@ -91,7 +91,7 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
91
91
|
// @ts-ignore
|
|
92
92
|
const quasarPlugins = await import('virtual:quasar-plugins');
|
|
93
93
|
// @ts-ignore
|
|
94
|
-
const directives = await import('quasar/directives');
|
|
94
|
+
const directives = await import('quasar/src/directives.js');
|
|
95
95
|
app.use(staticImports.Quasar, {
|
|
96
96
|
plugins: quasarPlugins,
|
|
97
97
|
directives
|
|
@@ -109,6 +109,9 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
109
109
|
},
|
|
110
110
|
hooks: {
|
|
111
111
|
onMounted: onMountedHooks
|
|
112
|
+
},
|
|
113
|
+
sass: {
|
|
114
|
+
additionalData: [`@import 'quasar/src/css/index.sass'`]
|
|
112
115
|
}
|
|
113
116
|
}
|
|
114
117
|
};
|
|
@@ -237,18 +240,19 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
237
240
|
__QUASAR_SSR_CLIENT__: ssr === 'client',
|
|
238
241
|
__QUASAR_SSR_PWA__: ssr === 'client' && pwa
|
|
239
242
|
},
|
|
240
|
-
css: {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
243
|
+
// css: {
|
|
244
|
+
// preprocessorOptions: {
|
|
245
|
+
// sass: {
|
|
246
|
+
// additionalData: `@import 'quasar/src/css/index.sass'`
|
|
247
|
+
// // [
|
|
248
|
+
// // // ...extras.map(extra => `@import "@quasar/extras/${extra}/${extra}.css"`),
|
|
249
|
+
// // // ...extras.map(extra => `@import ${new URL(`${extra}/${extra}.css`, urls?.packages?.['@quasar/extras']).pathname}`) || [],
|
|
250
|
+
// // // config.css?.preprocessorOptions?.sass?.additionalData,
|
|
251
|
+
// // `@import 'quasar/src/css/index.sass'`
|
|
252
|
+
// // ].join('\n')
|
|
253
|
+
// }
|
|
254
|
+
// }
|
|
255
|
+
// },
|
|
252
256
|
ssr: {
|
|
253
257
|
noExternal: ['quasar']
|
|
254
258
|
}
|
|
@@ -284,7 +288,8 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
284
288
|
export * from 'quasar/src/components.js';
|
|
285
289
|
export * from 'quasar/src/composables.js';
|
|
286
290
|
export * from 'quasar/src/directives.js';
|
|
287
|
-
export
|
|
291
|
+
export * from 'quasar/src/utils.js';
|
|
292
|
+
export { default as Quasar } from 'quasar/src/install-quasar.js'`;
|
|
288
293
|
}
|
|
289
294
|
return null;
|
|
290
295
|
}
|
package/dist/types/app-urls.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export declare const getPkgJsonDir: (dir: URL) => URL;
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
2
|
+
export declare const getAppDir: () => URL;
|
|
3
|
+
export declare const getCliDir: () => URL;
|
|
4
|
+
export declare const getCliViteDir: (cliDir: URL) => URL;
|
|
5
|
+
export declare const getSrcDir: (appDir: URL) => URL;
|
|
6
|
+
export declare const getCwd: () => URL;
|
|
7
|
+
export declare const parsePath: (path: string, basePath: URL) => URL | undefined;
|
|
8
|
+
export declare const getProjectURLs: (appDir: URL, cliDir: URL) => {
|
|
8
9
|
src: (path: string) => URL;
|
|
9
10
|
app: (path: string) => URL;
|
|
10
11
|
cli: (path: string) => URL;
|
package/dist/types/bin/run.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getProjectURLs } from '../app-urls.js';
|
|
2
2
|
export interface VitrifyContext {
|
|
3
3
|
vitrify: {
|
|
4
4
|
version: string;
|
|
5
5
|
};
|
|
6
|
-
projectURLs: typeof
|
|
6
|
+
projectURLs: ReturnType<typeof getProjectURLs>;
|
|
7
7
|
}
|
|
8
8
|
export declare function run(filePath: string): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FastifyPluginCallback, FastifyRequest, FastifyReply } from 'fastify';
|
|
2
2
|
import type { ViteDevServer } from 'vite';
|
|
3
|
-
import type { SsrFunction } from '
|
|
3
|
+
import type { SsrFunction } from '../../vitrify-config.js';
|
|
4
4
|
export interface FastifySsrOptions {
|
|
5
5
|
baseUrl?: string;
|
|
6
6
|
provide?: (req: FastifyRequest, res: FastifyReply) => Promise<Record<string, unknown>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { FastifyInstance } from 'fastify';
|
|
3
|
-
import type { SsrFunction } from '
|
|
3
|
+
import type { SsrFunction } from '../../vitrify-config.js';
|
|
4
4
|
export declare const createApp: ({ setup, appDir, baseUrl, ssrFunctions }: {
|
|
5
5
|
setup: (fastify: FastifyInstance) => any;
|
|
6
6
|
appDir: URL;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InlineConfig } from 'vite';
|
|
2
|
-
import type { VitrifyConfig } from './vitrify-config.js';
|
|
2
|
+
import type { BootFunction, VitrifyConfig } from './vitrify-config.js';
|
|
3
3
|
import type { VitrifyContext } from './bin/run.js';
|
|
4
4
|
import type { VitrifyPlugin } from './plugins/index.js';
|
|
5
5
|
export declare const VIRTUAL_MODULES: string[];
|
|
@@ -12,4 +12,4 @@ export declare const baseConfig: ({ ssr, appDir, publicDir, command, mode, frame
|
|
|
12
12
|
framework?: "vue" | undefined;
|
|
13
13
|
pwa?: boolean | undefined;
|
|
14
14
|
}) => Promise<InlineConfig>;
|
|
15
|
-
export type { VitrifyConfig, VitrifyPlugin, VitrifyContext };
|
|
15
|
+
export type { VitrifyConfig, VitrifyPlugin, VitrifyContext, BootFunction };
|
|
@@ -37,7 +37,10 @@ export interface VitrifyConfig extends UserConfig {
|
|
|
37
37
|
/**
|
|
38
38
|
* Global SASS variables
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
sass?: {
|
|
41
|
+
variables?: Record<string, string>;
|
|
42
|
+
additionalData?: string[];
|
|
43
|
+
};
|
|
41
44
|
fastify?: {
|
|
42
45
|
/**
|
|
43
46
|
* setup() is called directly after instantiating fastify. Use it to register your own plugins, routes etc.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitrify",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Stefan van Herwijnen",
|
|
6
6
|
"description": "Pre-configured Vite CLI for your framework",
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"./dist/types/helpers/*.d.ts"
|
|
26
26
|
],
|
|
27
27
|
"build": [
|
|
28
|
-
"./dist/types/
|
|
28
|
+
"./dist/types/bin/build.d.ts"
|
|
29
29
|
],
|
|
30
30
|
"dev": [
|
|
31
|
-
"./dist/types/
|
|
31
|
+
"./dist/types/bin/dev.d.ts"
|
|
32
32
|
],
|
|
33
33
|
"help": [
|
|
34
|
-
"./dist/types/
|
|
34
|
+
"./dist/types/bin/help.d.ts"
|
|
35
35
|
]
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
|
-
"node": ">=
|
|
39
|
+
"node": ">=16.0.0"
|
|
40
40
|
},
|
|
41
41
|
"repository": {
|
|
42
42
|
"type": "git",
|
|
@@ -54,15 +54,15 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@quasar/extras": "^1.13.5",
|
|
56
56
|
"@vitejs/plugin-vue": "^2.3.1",
|
|
57
|
-
"@vue/compiler-sfc": "^3.2.
|
|
58
|
-
"@vue/server-renderer": "^3.2.
|
|
57
|
+
"@vue/compiler-sfc": "^3.2.33",
|
|
58
|
+
"@vue/server-renderer": "^3.2.33",
|
|
59
59
|
"builtin-modules": "^3.2.0",
|
|
60
60
|
"cac": "^6.7.12",
|
|
61
61
|
"chalk": "^5.0.1",
|
|
62
62
|
"cross-env": "^7.0.3",
|
|
63
63
|
"fastify": "^3.28.0",
|
|
64
64
|
"fastify-static": "^4.6.1",
|
|
65
|
-
"glob": "^
|
|
65
|
+
"glob": "^8.0.1",
|
|
66
66
|
"happy-dom": "^2.55.0",
|
|
67
67
|
"import-meta-resolve": "^1.1.1",
|
|
68
68
|
"local-pkg": "^0.4.1",
|
|
@@ -71,22 +71,21 @@
|
|
|
71
71
|
"middie": "^6.0.0",
|
|
72
72
|
"readline": "^1.3.0",
|
|
73
73
|
"sass": "1.50.0",
|
|
74
|
-
"vite": "^2.9.
|
|
74
|
+
"vite": "^2.9.5",
|
|
75
75
|
"vitest": "^0.9.3"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@types/glob": "^7.2.0",
|
|
79
79
|
"@types/merge-deep": "^3.0.0",
|
|
80
|
-
"@types/node": "^17.0.
|
|
80
|
+
"@types/node": "^17.0.24",
|
|
81
81
|
"@types/ws": "^8.5.3",
|
|
82
|
-
"@vue/runtime-core": "^3.2.
|
|
82
|
+
"@vue/runtime-core": "^3.2.33",
|
|
83
83
|
"quasar": "^2.6.6",
|
|
84
84
|
"rollup": "^2.70.1",
|
|
85
85
|
"typescript": "^4.6.3",
|
|
86
|
-
"unplugin-vue-components": "^0.19.
|
|
87
|
-
"vite": "^2.9.
|
|
88
|
-
"
|
|
89
|
-
"vue": "^3.2.31",
|
|
86
|
+
"unplugin-vue-components": "^0.19.3",
|
|
87
|
+
"vite": "^2.9.5",
|
|
88
|
+
"vue": "^3.2.33",
|
|
90
89
|
"vue-router": "^4.0.14"
|
|
91
90
|
},
|
|
92
91
|
"peerDependencies": {
|
|
@@ -95,7 +94,7 @@
|
|
|
95
94
|
"fastify-sensible": "^3.1.2",
|
|
96
95
|
"fastify-static": "^4.6.1",
|
|
97
96
|
"quasar": "^2.6.6",
|
|
98
|
-
"vue": "^3.2.
|
|
97
|
+
"vue": "^3.2.33",
|
|
99
98
|
"vue-router": "^4.0.14"
|
|
100
99
|
},
|
|
101
100
|
"publishConfig": {
|
|
@@ -104,8 +103,7 @@
|
|
|
104
103
|
},
|
|
105
104
|
"files": [
|
|
106
105
|
"dist",
|
|
107
|
-
"src
|
|
108
|
-
"src/vite",
|
|
106
|
+
"src",
|
|
109
107
|
"!dist/**/*.test.js",
|
|
110
108
|
"!dist/**/test.js"
|
|
111
109
|
]
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// import { resolve } from 'import-meta-resolve'
|
|
2
|
+
import { existsSync } from 'fs'
|
|
3
|
+
|
|
4
|
+
export const getPkgJsonDir = (dir: URL): URL => {
|
|
5
|
+
const pkgJsonPath = new URL('package.json', dir)
|
|
6
|
+
if (existsSync(pkgJsonPath.pathname)) {
|
|
7
|
+
return new URL('./', pkgJsonPath)
|
|
8
|
+
}
|
|
9
|
+
return getPkgJsonDir(new URL('..', dir))
|
|
10
|
+
}
|
|
11
|
+
export const getAppDir = () =>
|
|
12
|
+
getPkgJsonDir(new URL(`file://${process.cwd()}/`))
|
|
13
|
+
export const getCliDir = () => getPkgJsonDir(new URL('./', import.meta.url))
|
|
14
|
+
export const getCliViteDir = (cliDir: URL) => new URL('src/vite/', cliDir)
|
|
15
|
+
export const getSrcDir = (appDir: URL) => new URL('src/', appDir)
|
|
16
|
+
export const getCwd = () => new URL(`file://${process.cwd()}/`)
|
|
17
|
+
// export const quasarDir = getPkgJsonDir(new URL('./', await resolve('quasar', appDir.href)))
|
|
18
|
+
|
|
19
|
+
export const parsePath = (path: string, basePath: URL) => {
|
|
20
|
+
if (path) {
|
|
21
|
+
if (path.slice(-1) !== '/') path += '/'
|
|
22
|
+
if (path.startsWith('.')) {
|
|
23
|
+
return new URL(path, basePath)
|
|
24
|
+
} else if (path) {
|
|
25
|
+
return new URL(`file://${path}`)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const getProjectURLs = (appDir: URL, cliDir: URL) => {
|
|
32
|
+
const srcDir = getSrcDir(appDir)
|
|
33
|
+
return {
|
|
34
|
+
src: (path: string) => new URL(path, srcDir),
|
|
35
|
+
app: (path: string) => new URL(path, appDir),
|
|
36
|
+
cli: (path: string) => new URL(path, cliDir)
|
|
37
|
+
}
|
|
38
|
+
}
|