@matthesketh/utopia-cli 0.1.0 → 0.3.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/dist/index.js +21 -15
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -19,11 +19,17 @@ function parseArgs(argv) {
|
|
|
19
19
|
let host;
|
|
20
20
|
let open = false;
|
|
21
21
|
let outDir;
|
|
22
|
+
let config;
|
|
22
23
|
const rest = [];
|
|
23
24
|
for (let i = 0; i < flagArgs.length; i++) {
|
|
24
25
|
const arg = flagArgs[i];
|
|
25
26
|
if (arg === "--port" && flagArgs[i + 1]) {
|
|
26
|
-
|
|
27
|
+
const n = Number(flagArgs[++i]);
|
|
28
|
+
if (Number.isNaN(n) || n < 0 || n > 65535) {
|
|
29
|
+
console.error(`Invalid port: ${flagArgs[i]}`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
port = n;
|
|
27
33
|
} else if (arg === "--host") {
|
|
28
34
|
const next = flagArgs[i + 1];
|
|
29
35
|
if (next && !next.startsWith("-")) {
|
|
@@ -36,24 +42,23 @@ function parseArgs(argv) {
|
|
|
36
42
|
open = true;
|
|
37
43
|
} else if (arg === "--outDir" && flagArgs[i + 1]) {
|
|
38
44
|
outDir = flagArgs[++i];
|
|
45
|
+
} else if ((arg === "--config" || arg === "-c") && flagArgs[i + 1]) {
|
|
46
|
+
config = flagArgs[++i];
|
|
39
47
|
} else {
|
|
40
48
|
rest.push(arg);
|
|
41
49
|
}
|
|
42
50
|
}
|
|
43
|
-
return { command, port, host, open, outDir, rest };
|
|
51
|
+
return { command, port, host, open, outDir, config, rest };
|
|
44
52
|
}
|
|
45
|
-
var CONFIG_FILES = [
|
|
46
|
-
"vite.config.ts",
|
|
47
|
-
"vite.config.js",
|
|
48
|
-
"vite.config.mjs",
|
|
49
|
-
"vite.config.mts"
|
|
50
|
-
];
|
|
53
|
+
var CONFIG_FILES = ["vite.config.ts", "vite.config.js", "vite.config.mjs", "vite.config.mts"];
|
|
51
54
|
function hasViteConfig() {
|
|
52
55
|
return CONFIG_FILES.some((f) => existsSync(resolve(process.cwd(), f)));
|
|
53
56
|
}
|
|
54
57
|
function buildInlineConfig(args, mode) {
|
|
55
58
|
const config = { mode };
|
|
56
|
-
if (
|
|
59
|
+
if (args.config) {
|
|
60
|
+
config.configFile = resolve(process.cwd(), args.config);
|
|
61
|
+
} else if (!hasViteConfig()) {
|
|
57
62
|
config.plugins = [utopia()];
|
|
58
63
|
}
|
|
59
64
|
const server = {};
|
|
@@ -105,12 +110,13 @@ function printHelp() {
|
|
|
105
110
|
create Create a new project
|
|
106
111
|
|
|
107
112
|
Options:
|
|
108
|
-
--port <port>
|
|
109
|
-
--host [host]
|
|
110
|
-
--open
|
|
111
|
-
--outDir <dir>
|
|
112
|
-
-
|
|
113
|
-
-
|
|
113
|
+
--port <port> Specify port
|
|
114
|
+
--host [host] Expose to network
|
|
115
|
+
--open Open browser on startup
|
|
116
|
+
--outDir <dir> Output directory (build only)
|
|
117
|
+
-c, --config <file> Use specified config file
|
|
118
|
+
-h, --help Show this help
|
|
119
|
+
-v, --version Show version
|
|
114
120
|
`);
|
|
115
121
|
}
|
|
116
122
|
async function main() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matthesketh/utopia-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "CLI for the UtopiaJS framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dist"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@matthesketh/utopia-vite-plugin": "0.
|
|
34
|
+
"@matthesketh/utopia-vite-plugin": "0.3.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"vite": "^6.0.0 || ^7.0.0"
|