x4js 2.3.1 → 2.3.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/cli/config.mjs +2 -3
- package/cli/create.mjs +32 -14
- package/cli/dev.mjs +6 -4
- package/package.json +1 -1
- package/src/components/themes.scss +44 -44
- package/src/x4.scss +4 -4
package/cli/config.mjs
CHANGED
|
@@ -9,7 +9,6 @@ const DEFAULTS = Object.freeze({
|
|
|
9
9
|
define: {},
|
|
10
10
|
dev: {
|
|
11
11
|
host: "127.0.0.1",
|
|
12
|
-
port: 8000,
|
|
13
12
|
https: false,
|
|
14
13
|
},
|
|
15
14
|
});
|
|
@@ -96,8 +95,8 @@ export function loadConfig(root = process.cwd(), env = process.env) {
|
|
|
96
95
|
if (typeof host !== "string" || !host)
|
|
97
96
|
throw new Error("x4.dev.host must be a non-empty string");
|
|
98
97
|
|
|
99
|
-
const port = devCfg.port
|
|
100
|
-
if (!Number.isInteger(port) || port < 0 || port > 65535)
|
|
98
|
+
const port = devCfg.port;
|
|
99
|
+
if (port !== undefined && (!Number.isInteger(port) || port < 0 || port > 65535))
|
|
101
100
|
throw new Error("x4.dev.port must be an integer between 0 and 65535");
|
|
102
101
|
|
|
103
102
|
const https = devCfg.https ?? DEFAULTS.dev.https;
|
package/cli/create.mjs
CHANGED
|
@@ -33,12 +33,6 @@ async function ensureEmptyTarget(target) {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
async function clearDirectory(target) {
|
|
37
|
-
const entries = await fs.readdir(target, { withFileTypes: true });
|
|
38
|
-
await Promise.all(entries.map((entry) =>
|
|
39
|
-
fs.rm(path.join(target, entry.name), { recursive: true, force: true })
|
|
40
|
-
));
|
|
41
|
-
}
|
|
42
36
|
|
|
43
37
|
async function patchPackage(target, projectName, version) {
|
|
44
38
|
const filename = path.join(target, "package.json");
|
|
@@ -66,18 +60,39 @@ async function patchPackage(target, projectName, version) {
|
|
|
66
60
|
}
|
|
67
61
|
|
|
68
62
|
async function npmInstall(target) {
|
|
69
|
-
|
|
63
|
+
let command;
|
|
64
|
+
let args;
|
|
65
|
+
|
|
66
|
+
if (process.platform === "win32") {
|
|
67
|
+
command = process.env.ComSpec || "cmd.exe";
|
|
68
|
+
args = ["/d", "/s", "/c", "npm install"];
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
command = "npm";
|
|
72
|
+
args = ["install"];
|
|
73
|
+
}
|
|
74
|
+
|
|
70
75
|
await new Promise((resolve, reject) => {
|
|
71
|
-
const child = spawn(command,
|
|
76
|
+
const child = spawn(command, args, {
|
|
72
77
|
cwd: target,
|
|
73
78
|
stdio: "inherit",
|
|
74
79
|
});
|
|
80
|
+
|
|
75
81
|
child.on("error", reject);
|
|
82
|
+
|
|
76
83
|
child.on("exit", (code, signal) => {
|
|
77
|
-
if (code === 0)
|
|
84
|
+
if (code === 0) {
|
|
78
85
|
resolve();
|
|
79
|
-
|
|
80
|
-
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
reject(
|
|
90
|
+
new Error(
|
|
91
|
+
`npm install failed${
|
|
92
|
+
signal ? ` (${signal})` : ` (exit ${code})`
|
|
93
|
+
}`
|
|
94
|
+
)
|
|
95
|
+
);
|
|
81
96
|
});
|
|
82
97
|
});
|
|
83
98
|
}
|
|
@@ -105,6 +120,7 @@ export async function create(argv = [], { version = "unknown", cwd = process.cwd
|
|
|
105
120
|
throw new Error(`Unknown template '${values.template}'. Run 'x4js templates' to list templates.`);
|
|
106
121
|
|
|
107
122
|
const targetCreated = await ensureEmptyTarget(target);
|
|
123
|
+
let projectReady = false;
|
|
108
124
|
info("create", target);
|
|
109
125
|
info("template", values.template);
|
|
110
126
|
|
|
@@ -121,6 +137,7 @@ export async function create(argv = [], { version = "unknown", cwd = process.cwd
|
|
|
121
137
|
}));
|
|
122
138
|
|
|
123
139
|
await patchPackage(target, projectName, version);
|
|
140
|
+
projectReady = true;
|
|
124
141
|
|
|
125
142
|
if (!values["no-install"]) {
|
|
126
143
|
info("install", "npm");
|
|
@@ -130,10 +147,11 @@ export async function create(argv = [], { version = "unknown", cwd = process.cwd
|
|
|
130
147
|
success("created", target);
|
|
131
148
|
}
|
|
132
149
|
catch (error) {
|
|
133
|
-
|
|
150
|
+
// Never remove a directory that existed before `x4js create`.
|
|
151
|
+
// Once package.json has been patched, the project is considered
|
|
152
|
+
// created and is also kept if `npm install` fails.
|
|
153
|
+
if (targetCreated && !projectReady)
|
|
134
154
|
await fs.rm(target, { recursive: true, force: true });
|
|
135
|
-
else
|
|
136
|
-
await clearDirectory(target);
|
|
137
155
|
throw error;
|
|
138
156
|
}
|
|
139
157
|
}
|
package/cli/dev.mjs
CHANGED
|
@@ -52,7 +52,7 @@ function serverUrl(host, port, https) {
|
|
|
52
52
|
displayHost = "[::1]";
|
|
53
53
|
else if (host.includes(":") && !host.startsWith("["))
|
|
54
54
|
displayHost = `[${host}]`;
|
|
55
|
-
return `${https ? "https" : "http"}://${displayHost}:${port}
|
|
55
|
+
return `${https ? "https" : "http"}://${displayHost}:${port}`;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export async function dev(argv = [], root = process.cwd()) {
|
|
@@ -85,16 +85,18 @@ export async function dev(argv = [], root = process.cwd()) {
|
|
|
85
85
|
async function start(config) {
|
|
86
86
|
const host = values.host ?? config.dev.host;
|
|
87
87
|
const port = values.port === undefined ? config.dev.port : Number(values.port);
|
|
88
|
-
if (port < 0 || port > 65535)
|
|
88
|
+
if (port !== undefined && (port < 0 || port > 65535))
|
|
89
89
|
throw new Error("--port must be between 0 and 65535");
|
|
90
90
|
|
|
91
91
|
const useHttps = protocolConfig(config, values);
|
|
92
92
|
const serveOptions = {
|
|
93
93
|
host,
|
|
94
|
-
port,
|
|
95
94
|
servedir: config.outdir,
|
|
96
95
|
};
|
|
97
96
|
|
|
97
|
+
if (port !== undefined)
|
|
98
|
+
serveOptions.port = port;
|
|
99
|
+
|
|
98
100
|
if (useHttps)
|
|
99
101
|
Object.assign(serveOptions, resolveTls(config));
|
|
100
102
|
|
|
@@ -108,7 +110,7 @@ export async function dev(argv = [], root = process.cwd()) {
|
|
|
108
110
|
const url = serverUrl(actualHost, result.port, useHttps);
|
|
109
111
|
info("mode", "dev");
|
|
110
112
|
info("outdir", config.outdir);
|
|
111
|
-
success("
|
|
113
|
+
success("server", url);
|
|
112
114
|
|
|
113
115
|
if (values.open && !browserOpened) {
|
|
114
116
|
browserOpened = true;
|
package/package.json
CHANGED
|
@@ -14,77 +14,77 @@
|
|
|
14
14
|
* that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
15
15
|
**/
|
|
16
16
|
|
|
17
|
+
@use "sass:color";
|
|
17
18
|
|
|
18
19
|
$color--base: #569cd6;
|
|
19
20
|
$color--interval: 8.4%;
|
|
20
21
|
|
|
21
22
|
:root {
|
|
22
23
|
--color-primary-a0: #ffffff;
|
|
23
|
-
--color-primary-a5:
|
|
24
|
-
--color-primary-a10:
|
|
25
|
-
--color-primary-a20: #{
|
|
26
|
-
--color-primary-a30: #{
|
|
27
|
-
--color-primary-a40: #{
|
|
24
|
+
--color-primary-a5: #{color.adjust($color--base, $lightness: 35%)};
|
|
25
|
+
--color-primary-a10: #{color.adjust($color--base, $lightness: $color--interval * 4)};
|
|
26
|
+
--color-primary-a20: #{color.adjust($color--base, $lightness: $color--interval * 3)};
|
|
27
|
+
--color-primary-a30: #{color.adjust($color--base, $lightness: $color--interval * 2)};
|
|
28
|
+
--color-primary-a40: #{color.adjust($color--base, $lightness: $color--interval)};
|
|
28
29
|
--color-primary-a50: #{$color--base};
|
|
29
|
-
--color-primary-a55: #{
|
|
30
|
-
--color-primary-a60: #{
|
|
31
|
-
--color-primary-a70: #{
|
|
32
|
-
--color-primary-a80: #{
|
|
33
|
-
--color-primary-a90: #{
|
|
30
|
+
--color-primary-a55: #{color.adjust($color--base, $lightness: -5%)};
|
|
31
|
+
--color-primary-a60: #{color.adjust($color--base, $lightness: -$color--interval)};
|
|
32
|
+
--color-primary-a70: #{color.adjust($color--base, $lightness: -$color--interval * 2)};
|
|
33
|
+
--color-primary-a80: #{color.adjust($color--base, $lightness: -$color--interval * 3)};
|
|
34
|
+
--color-primary-a90: #{color.adjust($color--base, $lightness: -$color--interval * 4)};
|
|
34
35
|
--color-primary-a100: #000000;
|
|
35
36
|
|
|
36
|
-
--color-danger-a30: #{
|
|
37
|
+
--color-danger-a30: #{color.adjust(#c01010, $lightness: 30%)};
|
|
37
38
|
--color-danger-a50: #c01010;
|
|
38
|
-
--color-danger-a60: #{
|
|
39
|
+
--color-danger-a60: #{color.adjust(#c01010, $lightness: -10%)};
|
|
39
40
|
|
|
40
41
|
--color-warning-a50: #b67b0d;
|
|
41
42
|
|
|
42
43
|
--color-success-a50: #10c01f;
|
|
43
|
-
--color-success-a60: #{
|
|
44
|
+
--color-success-a60: #{color.adjust(#10c01f, $lightness: -10%)};
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
:root {
|
|
47
48
|
// Backgrounds
|
|
48
|
-
--background-primary: var(--color-primary-a0);
|
|
49
|
-
--background-secondary: var(--color-primary-a10);
|
|
50
|
-
--background-ternary: #f4f4f4;
|
|
49
|
+
--background-primary: var(--color-primary-a0);
|
|
50
|
+
--background-secondary: var(--color-primary-a10);
|
|
51
|
+
--background-ternary: #f4f4f4;
|
|
51
52
|
|
|
52
53
|
// Texts
|
|
53
|
-
--text-primary: var(--color-primary-a100);
|
|
54
|
-
--text-secondary: #999;
|
|
55
|
-
--text-ternary: #666;
|
|
54
|
+
--text-primary: var(--color-primary-a100);
|
|
55
|
+
--text-secondary: #999;
|
|
56
|
+
--text-ternary: #666;
|
|
56
57
|
|
|
57
|
-
//
|
|
58
|
+
// Disabled
|
|
58
59
|
--disabled-background: #ccc;
|
|
59
60
|
--disabled-color: white;
|
|
60
61
|
--disabled-color-dark: #aaa;
|
|
61
62
|
|
|
62
|
-
//
|
|
63
|
-
--accent-background: var(--color-primary-a60);
|
|
64
|
-
--accent-background-hover: var(--color-primary-a55);
|
|
63
|
+
// Accents
|
|
64
|
+
--accent-background: var(--color-primary-a60);
|
|
65
|
+
--accent-background-hover: var(--color-primary-a55);
|
|
65
66
|
--accent-background-focus: var(--color-primary-a70);
|
|
66
|
-
--accent-background-active: var(--color-primary-a80);
|
|
67
|
+
--accent-background-active: var(--color-primary-a80);
|
|
67
68
|
|
|
68
|
-
--accent-color: var(--color-primary-a0);
|
|
69
|
-
--accent-color-hover: var(--color-primary-a0);
|
|
69
|
+
--accent-color: var(--color-primary-a0);
|
|
70
|
+
--accent-color-hover: var(--color-primary-a0);
|
|
70
71
|
--accent-color-focus: var(--color-primary-a0);
|
|
71
|
-
--accent-color-active: var(--color-primary-a0);
|
|
72
|
+
--accent-color-active: var(--color-primary-a0);
|
|
72
73
|
|
|
73
74
|
// Borders
|
|
74
|
-
--border: #e1e1e1;
|
|
75
|
-
--border-light: #eaeaea;
|
|
76
|
-
--border-hover: #c2c2c2;
|
|
77
|
-
--border-focus: var(
|
|
78
|
-
|
|
79
|
-
--alert-background: var(
|
|
80
|
-
--alert-background-active: var(
|
|
81
|
-
--alert-color: var(
|
|
82
|
-
|
|
83
|
-
--warning-background: var(
|
|
84
|
-
--warning-color: var(
|
|
85
|
-
|
|
86
|
-
--success-background: var(
|
|
87
|
-
--success-background-active: var(
|
|
88
|
-
--success-color: var(
|
|
89
|
-
}
|
|
90
|
-
|
|
75
|
+
--border: #e1e1e1;
|
|
76
|
+
--border-light: #eaeaea;
|
|
77
|
+
--border-hover: #c2c2c2;
|
|
78
|
+
--border-focus: var(--accent-background);
|
|
79
|
+
|
|
80
|
+
--alert-background: var(--color-danger-a50);
|
|
81
|
+
--alert-background-active: var(--color-danger-a60);
|
|
82
|
+
--alert-color: var(--color-primary-a0);
|
|
83
|
+
|
|
84
|
+
--warning-background: var(--color-warning-a50);
|
|
85
|
+
--warning-color: var(--color-primary-a0);
|
|
86
|
+
|
|
87
|
+
--success-background: var(--color-success-a50);
|
|
88
|
+
--success-background-active: var(--color-success-a60);
|
|
89
|
+
--success-color: var(--color-primary-a0);
|
|
90
|
+
}
|
package/src/x4.scss
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
15
15
|
**/
|
|
16
16
|
|
|
17
|
-
@
|
|
18
|
-
@
|
|
19
|
-
@
|
|
20
|
-
@
|
|
17
|
+
@use "./components/normalize";
|
|
18
|
+
@use "./components/colors";
|
|
19
|
+
@use "./components/themes";
|
|
20
|
+
@use "./components/base";
|