rtgl 2.0.1 → 2.0.3
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/LICENSE +21 -0
- package/cli.js +16 -50
- package/package.json +8 -6
- package/src/config.js +20 -0
- package/src/options.js +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yuusoft
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the “Software”), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software
|
|
10
|
+
is furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included
|
|
13
|
+
in all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
21
|
+
IN THE SOFTWARE.
|
package/cli.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { Command
|
|
3
|
+
import { Command } from "commander";
|
|
4
4
|
import { readFileSync, existsSync } from "fs";
|
|
5
5
|
import { resolve } from "path";
|
|
6
|
-
import
|
|
6
|
+
import { readConfig } from "./src/config.js";
|
|
7
|
+
import {
|
|
8
|
+
collectValues,
|
|
9
|
+
parseIntegerOption,
|
|
10
|
+
parseIsolationOption,
|
|
11
|
+
parsePortOption,
|
|
12
|
+
} from "./src/options.js";
|
|
7
13
|
|
|
8
14
|
const packageJson = JSON.parse(
|
|
9
15
|
readFileSync(new URL("./package.json", import.meta.url)),
|
|
@@ -94,54 +100,6 @@ function requireBeCommand(handler, name) {
|
|
|
94
100
|
return handler;
|
|
95
101
|
}
|
|
96
102
|
|
|
97
|
-
// Function to read config file
|
|
98
|
-
function readConfig() {
|
|
99
|
-
const configPath = resolve(process.cwd(), "rettangoli.config.yaml");
|
|
100
|
-
|
|
101
|
-
if (!existsSync(configPath)) {
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
try {
|
|
106
|
-
const configContent = readFileSync(configPath, "utf8");
|
|
107
|
-
return yaml.load(configContent);
|
|
108
|
-
} catch (error) {
|
|
109
|
-
throw new Error(`Error reading config file "${configPath}": ${error.message}`);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function collectValues(value, previous = []) {
|
|
114
|
-
return [...previous, value];
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function parseIntegerOption(value) {
|
|
118
|
-
if (!/^-?\d+$/.test(String(value))) {
|
|
119
|
-
throw new InvalidArgumentError(`Expected an integer but received "${value}"`);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const parsed = Number.parseInt(value, 10);
|
|
123
|
-
if (!Number.isSafeInteger(parsed)) {
|
|
124
|
-
throw new InvalidArgumentError(`Expected a safe integer but received "${value}"`);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return parsed;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function parsePortOption(value) {
|
|
131
|
-
const parsed = parseIntegerOption(value);
|
|
132
|
-
if (parsed < 1 || parsed > 65535) {
|
|
133
|
-
throw new InvalidArgumentError(`Port must be between 1 and 65535, received "${value}"`);
|
|
134
|
-
}
|
|
135
|
-
return parsed;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function parseIsolationOption(value) {
|
|
139
|
-
if (value === "fast" || value === "strict") {
|
|
140
|
-
return value;
|
|
141
|
-
}
|
|
142
|
-
throw new InvalidArgumentError(`Isolation must be "fast" or "strict", received "${value}"`);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
103
|
function resolveBeRuntimePaths(config) {
|
|
146
104
|
const be = config?.be || {};
|
|
147
105
|
const dirs = Array.isArray(be.dirs) && be.dirs.length > 0 ? be.dirs : ["./src/modules"];
|
|
@@ -417,6 +375,10 @@ feCommand
|
|
|
417
375
|
.description("Watch for changes")
|
|
418
376
|
.option("-p, --port <port>", "The port to use", parsePortOption, 3001)
|
|
419
377
|
.option("-s, --setup-path <path>", "Custom setup file path")
|
|
378
|
+
.option(
|
|
379
|
+
"--public-dir <path>",
|
|
380
|
+
"Directory to serve as untransformed static assets",
|
|
381
|
+
)
|
|
420
382
|
.addHelpText(
|
|
421
383
|
"after",
|
|
422
384
|
`
|
|
@@ -427,6 +389,7 @@ Examples:
|
|
|
427
389
|
$ rettangoli fe watch -p 4000
|
|
428
390
|
$ rettangoli fe watch -s src/setup.tauri.js
|
|
429
391
|
$ rettangoli fe watch --setup-path src/setup.web.js
|
|
392
|
+
$ rettangoli fe watch --public-dir static
|
|
430
393
|
`,
|
|
431
394
|
)
|
|
432
395
|
.action(async (options) => {
|
|
@@ -458,6 +421,9 @@ Examples:
|
|
|
458
421
|
if (!options.outfile && config.fe.outfile) {
|
|
459
422
|
options.outfile = config.fe.outfile;
|
|
460
423
|
}
|
|
424
|
+
if (options.publicDir === undefined && config.fe.publicDir !== undefined) {
|
|
425
|
+
options.publicDir = config.fe.publicDir;
|
|
426
|
+
}
|
|
461
427
|
|
|
462
428
|
await watch(options);
|
|
463
429
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rtgl",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "CLI tool for Rettangoli - A frontend framework and development toolkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -8,11 +8,13 @@
|
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"cli.js",
|
|
11
|
+
"src",
|
|
11
12
|
"README.md",
|
|
12
13
|
"LICENSE"
|
|
13
14
|
],
|
|
14
15
|
"scripts": {
|
|
15
|
-
"test": "
|
|
16
|
+
"test": "node --test test/*.test.js",
|
|
17
|
+
"test:package": "node test/package-smoke-test.js"
|
|
16
18
|
},
|
|
17
19
|
"keywords": [
|
|
18
20
|
"rettangoli",
|
|
@@ -47,11 +49,11 @@
|
|
|
47
49
|
"dependencies": {
|
|
48
50
|
"commander": "^14.0.0",
|
|
49
51
|
"js-yaml": "^4.1.0",
|
|
50
|
-
"@rettangoli/check": "0.1.
|
|
52
|
+
"@rettangoli/check": "0.1.4",
|
|
51
53
|
"@rettangoli/be": "2.0.0",
|
|
52
|
-
"@rettangoli/fe": "1.2.
|
|
54
|
+
"@rettangoli/fe": "1.2.3",
|
|
53
55
|
"@rettangoli/sites": "1.2.0",
|
|
54
|
-
"@rettangoli/vt": "1.0.
|
|
55
|
-
"@rettangoli/ui": "1.
|
|
56
|
+
"@rettangoli/vt": "1.0.6",
|
|
57
|
+
"@rettangoli/ui": "1.11.0"
|
|
56
58
|
}
|
|
57
59
|
}
|
package/src/config.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import yaml from "js-yaml";
|
|
4
|
+
|
|
5
|
+
export function readConfig(cwd = process.cwd()) {
|
|
6
|
+
const configPath = resolve(cwd, "rettangoli.config.yaml");
|
|
7
|
+
|
|
8
|
+
if (!existsSync(configPath)) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
return yaml.load(readFileSync(configPath, "utf8"));
|
|
14
|
+
} catch (error) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
`Error reading config file "${configPath}": ${error.message}`,
|
|
17
|
+
{ cause: error },
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
}
|
package/src/options.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { InvalidArgumentError } from "commander";
|
|
2
|
+
|
|
3
|
+
export function collectValues(value, previous = []) {
|
|
4
|
+
return [...previous, value];
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function parseIntegerOption(value) {
|
|
8
|
+
if (!/^-?\d+$/.test(String(value))) {
|
|
9
|
+
throw new InvalidArgumentError(`Expected an integer but received "${value}"`);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const parsed = Number.parseInt(value, 10);
|
|
13
|
+
if (!Number.isSafeInteger(parsed)) {
|
|
14
|
+
throw new InvalidArgumentError(
|
|
15
|
+
`Expected a safe integer but received "${value}"`,
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return parsed;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function parsePortOption(value) {
|
|
23
|
+
const parsed = parseIntegerOption(value);
|
|
24
|
+
if (parsed < 1 || parsed > 65535) {
|
|
25
|
+
throw new InvalidArgumentError(
|
|
26
|
+
`Port must be between 1 and 65535, received "${value}"`,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return parsed;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function parseIsolationOption(value) {
|
|
33
|
+
if (value === "fast" || value === "strict") {
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
throw new InvalidArgumentError(
|
|
37
|
+
`Isolation must be "fast" or "strict", received "${value}"`,
|
|
38
|
+
);
|
|
39
|
+
}
|