@eodash/eodash 5.0.0-alpha.1.8 → 5.0.0-alpha.1.9
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/bin/app.js +1 -4
- package/bin/cli.js +13 -23
- package/bin/serverConfig.js +7 -6
- package/bin/utils.js +29 -9
- package/package.json +2 -1
package/bin/app.js
CHANGED
|
@@ -4,15 +4,12 @@ import { buildApp, createDevServer, previewApp } from './cli.js'
|
|
|
4
4
|
|
|
5
5
|
const command = process.argv?.[2];
|
|
6
6
|
(async () => {
|
|
7
|
-
const baseFlag = (
|
|
8
|
-
process.argv.indexOf('--base') > -1 ? process.argv[process.argv.indexOf('--base')+1] : null
|
|
9
|
-
);
|
|
10
7
|
switch (command) {
|
|
11
8
|
case "dev":
|
|
12
9
|
await createDevServer();
|
|
13
10
|
break;
|
|
14
11
|
case "build":
|
|
15
|
-
await buildApp(
|
|
12
|
+
await buildApp();
|
|
16
13
|
break;
|
|
17
14
|
case "preview":
|
|
18
15
|
await previewApp();
|
package/bin/cli.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { build, createServer, preview } from "vite"
|
|
4
4
|
import {
|
|
5
5
|
rootPath, appPath, buildTargetPath,
|
|
6
|
-
|
|
6
|
+
userConfig, runtimeConfigPath,
|
|
7
7
|
} from "./utils.js";
|
|
8
8
|
import { writeFile, rm, cp } from "fs/promises";
|
|
9
9
|
import { indexHtml, serverConfig } from "./serverConfig.js";
|
|
@@ -18,34 +18,22 @@ export const createDevServer = async () => {
|
|
|
18
18
|
server.bindCLIShortcuts({ print: true })
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export const buildApp = async (
|
|
21
|
+
export const buildApp = async () => {
|
|
22
22
|
const htmlPath = path.join(appPath, '/index.html')
|
|
23
23
|
await writeFile(htmlPath, indexHtml).then(async () => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
const config = await serverConfig({ mode: 'production', command: 'build' });
|
|
25
|
+
await build(config)
|
|
26
|
+
|
|
27
|
+
if (existsSync(runtimeConfigPath)) {
|
|
28
|
+
await cp(runtimeConfigPath, path.join(buildTargetPath, 'config.js'),
|
|
29
|
+
{ recursive: true }).catch((e) => {
|
|
30
30
|
console.error(e)
|
|
31
31
|
})
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const config = await serverConfig({ mode: 'production', command: 'build' });
|
|
36
|
-
if (baseFlag !== null) {
|
|
37
|
-
config.base = baseFlag
|
|
38
32
|
}
|
|
39
|
-
await build(config)
|
|
40
33
|
|
|
41
34
|
await rm(htmlPath).catch(() => {
|
|
42
35
|
console.error('failed to remove index.html')
|
|
43
36
|
})
|
|
44
|
-
if (appPath.includes('node_modules') && existsSync(appPublicPath)) {
|
|
45
|
-
await rm(appPublicPath, { recursive: true }).catch((e) => {
|
|
46
|
-
console.error(e)
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
37
|
})
|
|
50
38
|
}
|
|
51
39
|
|
|
@@ -53,12 +41,14 @@ export const buildApp = async (baseFlag) => {
|
|
|
53
41
|
export async function previewApp() {
|
|
54
42
|
const previewServer = await preview({
|
|
55
43
|
root: rootPath,
|
|
44
|
+
base: userConfig.base ?? '',
|
|
56
45
|
preview: {
|
|
57
|
-
port: 8080,
|
|
58
|
-
open:
|
|
46
|
+
port: userConfig.port ?? 8080,
|
|
47
|
+
open: userConfig.open,
|
|
48
|
+
host: userConfig.host
|
|
59
49
|
},
|
|
60
50
|
build: {
|
|
61
|
-
outDir: buildTargetPath
|
|
51
|
+
outDir: buildTargetPath,
|
|
62
52
|
}
|
|
63
53
|
})
|
|
64
54
|
previewServer.printUrls()
|
package/bin/serverConfig.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
3
|
import vue from '@vitejs/plugin-vue';
|
|
6
4
|
import vuetify, { transformAssetUrls } from 'vite-plugin-vuetify';
|
|
7
5
|
import virtual, { updateVirtualModule } from 'vite-plugin-virtual'
|
|
@@ -9,7 +7,7 @@ import { fileURLToPath, URL } from 'url';
|
|
|
9
7
|
import {
|
|
10
8
|
runtimeConfigPath,
|
|
11
9
|
appPath, compiletimeConfigPath,
|
|
12
|
-
|
|
10
|
+
cachePath, publicPath, userConfig,
|
|
13
11
|
buildTargetPath
|
|
14
12
|
} from "./utils.js";
|
|
15
13
|
import { readFile } from "fs/promises";
|
|
@@ -41,7 +39,7 @@ export const indexHtml = `
|
|
|
41
39
|
let virtualPlugin = null;
|
|
42
40
|
export const serverConfig = /** @type {import('vite').UserConfigFnPromise}*/(defineConfig(async ({ mode, command }) => {
|
|
43
41
|
return {
|
|
44
|
-
base: '',
|
|
42
|
+
base: userConfig.base ?? '',
|
|
45
43
|
cacheDir: cachePath,
|
|
46
44
|
plugins: [
|
|
47
45
|
vue({
|
|
@@ -71,17 +69,20 @@ export const serverConfig = /** @type {import('vite').UserConfigFnPromise}*/(def
|
|
|
71
69
|
extensions: ['.js', '.json', '.jsx', '.mjs', '.ts', '.tsx', '.vue'],
|
|
72
70
|
},
|
|
73
71
|
server: {
|
|
74
|
-
port: 3000,
|
|
72
|
+
port: userConfig.port ?? 3000,
|
|
73
|
+
open: userConfig.open,
|
|
75
74
|
fs: {
|
|
76
75
|
allow: [searchForWorkspaceRoot(process.cwd())]
|
|
77
76
|
},
|
|
77
|
+
host: userConfig.host
|
|
78
78
|
},
|
|
79
79
|
root: fileURLToPath(new URL('..', import.meta.url)),
|
|
80
80
|
optimizeDeps: mode === "development" ? {
|
|
81
81
|
include: ["webfontloader", "vuetify", "vue", "pinia"],
|
|
82
82
|
noDiscovery: true,
|
|
83
83
|
} : {},
|
|
84
|
-
|
|
84
|
+
/** @type {string|false} */
|
|
85
|
+
publicDir: userConfig.publicDir === false ? false : publicPath,
|
|
85
86
|
build: {
|
|
86
87
|
outDir: buildTargetPath,
|
|
87
88
|
emptyOutDir: true,
|
package/bin/utils.js
CHANGED
|
@@ -1,23 +1,43 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { readFile } from 'fs/promises';
|
|
4
|
-
import { existsSync } from 'fs';
|
|
4
|
+
import { existsSync, readFileSync } from 'fs';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { fileURLToPath } from 'url';
|
|
7
7
|
import { searchForWorkspaceRoot } from 'vite';
|
|
8
|
+
import { Command } from 'commander';
|
|
9
|
+
const cli = new Command('eodash')
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
const pkg = JSON.parse(
|
|
12
|
+
readFileSync(
|
|
13
|
+
fileURLToPath(new URL('../package.json', import.meta.url))
|
|
14
|
+
, 'utf-8')
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
cli.version(pkg.version, '-v, --version', 'output the current version')
|
|
18
|
+
.option('--publicDir <path>', 'path to statically served assets folder')
|
|
19
|
+
.option('--no-publicDir', 'stop serving static assets')
|
|
20
|
+
.option('--outDir <path>', 'minified output folder')
|
|
21
|
+
.option('-e, --entryPoint <path>', 'file exporting `defineConfig`')
|
|
22
|
+
.option('-c, --cacheDir <path>', 'cache folder')
|
|
23
|
+
.option('-r, --runtime <path>', 'file exporting eodash runtime config')
|
|
24
|
+
.option('-b, --base <path>', 'base public path')
|
|
25
|
+
.option('-p, --port <port>', 'serving port')
|
|
26
|
+
.option('-o, --open', 'open default browser when the server starts')
|
|
27
|
+
.option('--host [IP address]', 'specify which IP addresses the server should listen on')
|
|
28
|
+
.parse(process.argv)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export const userConfig = cli.opts()
|
|
10
32
|
export const appPath = fileURLToPath(new URL("..", import.meta.url)),
|
|
11
|
-
appPublicPath = path.join(appPath, './public'),
|
|
12
33
|
rootPath = searchForWorkspaceRoot(process.cwd()),
|
|
13
|
-
|
|
34
|
+
publicPath = userConfig.publicDir ? path.resolve(rootPath, userConfig.publicDir) : path.join(rootPath, './public'),
|
|
14
35
|
srcPath = path.join(rootPath, "/src"),
|
|
15
|
-
runtimeConfigPath = path.join(srcPath, "./config.runtime.js"),
|
|
16
|
-
compiletimeConfigPath = path.join(srcPath, "/config.js"),
|
|
36
|
+
runtimeConfigPath = userConfig.runtime ? path.resolve(rootPath, userConfig.runtime) : path.join(srcPath, "./config.runtime.js"),
|
|
37
|
+
compiletimeConfigPath = userConfig.entryPoint ? path.resolve(rootPath, userConfig.entryPoint) : path.join(srcPath, "/config.js"),
|
|
17
38
|
dotEodashPath = path.join(rootPath, "/.eodash"),
|
|
18
|
-
buildTargetPath = path.join(dotEodashPath, '/dist'),
|
|
19
|
-
cachePath = path.join(dotEodashPath, 'cache');
|
|
20
|
-
|
|
39
|
+
buildTargetPath = userConfig.outDir ? path.resolve(rootPath, userConfig.outDir) : path.join(dotEodashPath, '/dist'),
|
|
40
|
+
cachePath = userConfig.cacheDir ? path.resolve(rootPath, userConfig.cacheDir) : path.join(dotEodashPath, 'cache');
|
|
21
41
|
|
|
22
42
|
|
|
23
43
|
export const getUserModules = async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eodash/eodash",
|
|
3
|
-
"version": "5.0.0-alpha.1.
|
|
3
|
+
"version": "5.0.0-alpha.1.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./core/types.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"@vitejs/plugin-vue": "^5.0.0",
|
|
33
33
|
"animated-details": "gist:2912bb049fa906671807415eb0e87188",
|
|
34
34
|
"axios": "^1.6.2",
|
|
35
|
+
"commander": "^12.0.0",
|
|
35
36
|
"core-js": "^3.29.0",
|
|
36
37
|
"pinia": "^2.0.0",
|
|
37
38
|
"sass": "^1.60.0",
|