rtgl 1.0.0-rc29 → 1.0.0-rc31
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/cli.js +22 -5
- package/package.json +3 -3
package/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ import { build as buildBe, check as checkBe, watch as watchBe } from "@rettangol
|
|
|
6
6
|
import { generate, screenshot, report, accept } from "@rettangoli/vt/cli";
|
|
7
7
|
import { buildSite, watchSite, initSite } from "@rettangoli/sites/cli";
|
|
8
8
|
import { buildSvg } from "@rettangoli/ui/cli";
|
|
9
|
-
import { Command } from "commander";
|
|
9
|
+
import { Command, InvalidArgumentError } from "commander";
|
|
10
10
|
import { readFileSync, existsSync } from "fs";
|
|
11
11
|
import { resolve } from "path";
|
|
12
12
|
import yaml from "js-yaml";
|
|
@@ -36,7 +36,24 @@ function collectValues(value, previous = []) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function parseIntegerOption(value) {
|
|
39
|
-
|
|
39
|
+
if (!/^-?\d+$/.test(String(value))) {
|
|
40
|
+
throw new InvalidArgumentError(`Expected an integer but received "${value}"`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const parsed = Number.parseInt(value, 10);
|
|
44
|
+
if (!Number.isSafeInteger(parsed)) {
|
|
45
|
+
throw new InvalidArgumentError(`Expected a safe integer but received "${value}"`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return parsed;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function parsePortOption(value) {
|
|
52
|
+
const parsed = parseIntegerOption(value);
|
|
53
|
+
if (parsed < 1 || parsed > 65535) {
|
|
54
|
+
throw new InvalidArgumentError(`Port must be between 1 and 65535, received "${value}"`);
|
|
55
|
+
}
|
|
56
|
+
return parsed;
|
|
40
57
|
}
|
|
41
58
|
|
|
42
59
|
const program = new Command();
|
|
@@ -208,7 +225,7 @@ Examples:
|
|
|
208
225
|
feCommand
|
|
209
226
|
.command("watch")
|
|
210
227
|
.description("Watch for changes")
|
|
211
|
-
.option("-p, --port <port>", "The port to use",
|
|
228
|
+
.option("-p, --port <port>", "The port to use", parsePortOption, 3001)
|
|
212
229
|
.option("-s, --setup-path <path>", "Custom setup file path")
|
|
213
230
|
.addHelpText(
|
|
214
231
|
"after",
|
|
@@ -495,7 +512,7 @@ sitesCommand
|
|
|
495
512
|
sitesCommand
|
|
496
513
|
.command("watch")
|
|
497
514
|
.description("Watch and rebuild site on changes")
|
|
498
|
-
.option("-p, --port <port>", "The port to use",
|
|
515
|
+
.option("-p, --port <port>", "The port to use", parsePortOption, 3001)
|
|
499
516
|
.option("-r, --root-dir <path>", "Path to root directory", ".")
|
|
500
517
|
.option("--rootDir <path>", "Deprecated alias for --root-dir")
|
|
501
518
|
.option("-o, --output-path <path>", "Path to destination directory", "./_site")
|
|
@@ -503,7 +520,7 @@ sitesCommand
|
|
|
503
520
|
.option("--reload-mode <mode>", "Reload mode: body (hot body replacement) or full (full-page reload)", "body")
|
|
504
521
|
.option("-q, --quiet", "Suppress non-error logs")
|
|
505
522
|
.action(async (options) => {
|
|
506
|
-
watchSite({
|
|
523
|
+
await watchSite({
|
|
507
524
|
port: options.port,
|
|
508
525
|
rootDir: options.rootDir,
|
|
509
526
|
outputPath: options.outputPath,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rtgl",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc31",
|
|
4
4
|
"description": "CLI tool for Rettangoli - A frontend framework and development toolkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"js-yaml": "^4.1.0",
|
|
50
50
|
"@rettangoli/check": "0.1.2",
|
|
51
51
|
"@rettangoli/be": "1.0.0-rc1",
|
|
52
|
-
"@rettangoli/fe": "1.0.0-
|
|
52
|
+
"@rettangoli/fe": "1.0.0-rc4",
|
|
53
53
|
"@rettangoli/sites": "1.0.0-rc13",
|
|
54
|
-
"@rettangoli/vt": "1.0.0-
|
|
54
|
+
"@rettangoli/vt": "1.0.0-rc16",
|
|
55
55
|
"@rettangoli/ui": "1.0.0-rc16"
|
|
56
56
|
}
|
|
57
57
|
}
|