@jingyi0605/codingns 0.1.3 → 0.1.4
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/codingns.mjs +47 -8
- package/dist/public/assets/{TerminalPage-Nq5sPc5c.js → TerminalPage-4ulgBhv9.js} +19 -19
- package/dist/public/assets/{index-9hnprhO7.css → index-C5lu52cQ.css} +1 -1
- package/dist/public/assets/index-WpdUo_Vs.js +108 -0
- package/dist/public/index.html +2 -2
- package/dist/server/config/env.d.ts +1 -0
- package/dist/server/config/env.js +2 -1
- package/dist/server/config/env.js.map +1 -1
- package/dist/server/modules/auth/auth-service.d.ts +7 -1
- package/dist/server/modules/auth/auth-service.js +23 -3
- package/dist/server/modules/auth/auth-service.js.map +1 -1
- package/dist/server/modules/bootstrap/bootstrap-service.d.ts +3 -1
- package/dist/server/modules/bootstrap/bootstrap-service.js +7 -2
- package/dist/server/modules/bootstrap/bootstrap-service.js.map +1 -1
- package/dist/server/modules/demo/demo-cleanup-service.d.ts +41 -0
- package/dist/server/modules/demo/demo-cleanup-service.js +111 -0
- package/dist/server/modules/demo/demo-cleanup-service.js.map +1 -0
- package/dist/server/modules/terminal/terminal-service.js +2 -2
- package/dist/server/modules/terminal/terminal-service.js.map +1 -1
- package/dist/server/routes/sessions.d.ts +1 -0
- package/dist/server/routes/sessions.js +12 -3
- package/dist/server/routes/sessions.js.map +1 -1
- package/dist/server/server/create-server.js +32 -6
- package/dist/server/server/create-server.js.map +1 -1
- package/package.json +1 -1
- package/dist/public/assets/index-BTpmuKhG.js +0 -108
package/bin/codingns.mjs
CHANGED
|
@@ -25,6 +25,13 @@ if (options.help) {
|
|
|
25
25
|
printHelp(0);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
if (options.errors.length > 0) {
|
|
29
|
+
for (const error of options.errors) {
|
|
30
|
+
console.error(`[codingns] ${error}`);
|
|
31
|
+
}
|
|
32
|
+
printHelp(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
28
35
|
const host = readStringOption(
|
|
29
36
|
options.values.host,
|
|
30
37
|
process.env.HOST,
|
|
@@ -41,6 +48,7 @@ const dataDir = resolveDataDir(
|
|
|
41
48
|
path.join(os.homedir(), ".codingns")
|
|
42
49
|
)
|
|
43
50
|
);
|
|
51
|
+
const demoMode = options.flags.demo || process.env.DEMO_MODE === "true";
|
|
44
52
|
|
|
45
53
|
fs.mkdirSync(dataDir, { recursive: true });
|
|
46
54
|
fs.mkdirSync(path.join(dataDir, "releases"), { recursive: true });
|
|
@@ -53,11 +61,14 @@ await startHost({
|
|
|
53
61
|
webUiDir: path.join(distRoot, "public"),
|
|
54
62
|
databasePath: path.join(dataDir, "host.sqlite"),
|
|
55
63
|
releaseManifestRoot: path.join(dataDir, "releases"),
|
|
56
|
-
serverUpdatePackageName: "@jingyi0605/codingns"
|
|
64
|
+
serverUpdatePackageName: "@jingyi0605/codingns",
|
|
65
|
+
demoMode
|
|
57
66
|
});
|
|
58
67
|
|
|
59
68
|
function parseArgs(argv) {
|
|
60
69
|
const values = {};
|
|
70
|
+
const flags = {};
|
|
71
|
+
const errors = [];
|
|
61
72
|
let index = 0;
|
|
62
73
|
|
|
63
74
|
while (index < argv.length) {
|
|
@@ -66,18 +77,37 @@ function parseArgs(argv) {
|
|
|
66
77
|
if (token === "--help" || token === "-h") {
|
|
67
78
|
return {
|
|
68
79
|
help: true,
|
|
69
|
-
values
|
|
80
|
+
values,
|
|
81
|
+
flags,
|
|
82
|
+
errors
|
|
70
83
|
};
|
|
71
84
|
}
|
|
72
85
|
|
|
73
86
|
if (!token.startsWith("--")) {
|
|
74
|
-
|
|
87
|
+
errors.push(`无效参数:${token}`);
|
|
88
|
+
index += 1;
|
|
89
|
+
continue;
|
|
75
90
|
}
|
|
76
91
|
|
|
77
92
|
const [rawName, inlineValue] = token.slice(2).split("=", 2);
|
|
78
93
|
|
|
79
|
-
if (!rawName
|
|
80
|
-
|
|
94
|
+
if (!rawName) {
|
|
95
|
+
errors.push(`无效参数:${token}`);
|
|
96
|
+
index += 1;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// 布尔标志(不需要值)
|
|
101
|
+
if (isSupportedFlag(rawName)) {
|
|
102
|
+
flags[rawName] = true;
|
|
103
|
+
index += 1;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!isSupportedOption(rawName)) {
|
|
108
|
+
errors.push(`不支持的参数:${token}`);
|
|
109
|
+
index += 1;
|
|
110
|
+
continue;
|
|
81
111
|
}
|
|
82
112
|
|
|
83
113
|
if (inlineValue !== undefined) {
|
|
@@ -89,7 +119,9 @@ function parseArgs(argv) {
|
|
|
89
119
|
const nextValue = argv[index + 1];
|
|
90
120
|
|
|
91
121
|
if (!nextValue || nextValue.startsWith("--")) {
|
|
92
|
-
|
|
122
|
+
errors.push(`参数 ${token} 缺少取值`);
|
|
123
|
+
index += 1;
|
|
124
|
+
continue;
|
|
93
125
|
}
|
|
94
126
|
|
|
95
127
|
values[rawName] = nextValue;
|
|
@@ -98,7 +130,9 @@ function parseArgs(argv) {
|
|
|
98
130
|
|
|
99
131
|
return {
|
|
100
132
|
help: false,
|
|
101
|
-
values
|
|
133
|
+
values,
|
|
134
|
+
flags,
|
|
135
|
+
errors
|
|
102
136
|
};
|
|
103
137
|
}
|
|
104
138
|
|
|
@@ -106,6 +140,10 @@ function isSupportedOption(name) {
|
|
|
106
140
|
return name === "host" || name === "port" || name === "data-dir";
|
|
107
141
|
}
|
|
108
142
|
|
|
143
|
+
function isSupportedFlag(name) {
|
|
144
|
+
return name === "demo";
|
|
145
|
+
}
|
|
146
|
+
|
|
109
147
|
function readStringOption(...values) {
|
|
110
148
|
for (const value of values) {
|
|
111
149
|
if (typeof value === "string" && value.trim().length > 0) {
|
|
@@ -148,13 +186,14 @@ function printHelp(exitCode) {
|
|
|
148
186
|
const output = `
|
|
149
187
|
codingns 用法:
|
|
150
188
|
|
|
151
|
-
codingns start [--host 0.0.0.0] [--port 3002] [--data-dir ~/.codingns]
|
|
189
|
+
codingns start [--host 0.0.0.0] [--port 3002] [--data-dir ~/.codingns] [--demo]
|
|
152
190
|
|
|
153
191
|
说明:
|
|
154
192
|
|
|
155
193
|
--host 服务监听地址,默认 0.0.0.0
|
|
156
194
|
--port 服务监听端口,默认 3002
|
|
157
195
|
--data-dir 数据目录,默认 ~/.codingns
|
|
196
|
+
--demo 以演示模式启动(自动创建 demo 账户、15 分钟会话超时、开放 CORS)
|
|
158
197
|
--help 显示帮助
|
|
159
198
|
`.trim();
|
|
160
199
|
|