@fedify/init 2.2.0-dev.628 → 2.2.0-dev.638
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/action/{configs.mjs → configs.js} +7 -7
- package/dist/action/{deps.mjs → deps.js} +7 -6
- package/dist/action/{env.mjs → env.js} +2 -2
- package/dist/action/{mod.d.mts → mod.d.ts} +2 -2
- package/dist/action/{mod.mjs → mod.js} +9 -11
- package/dist/action/{notice.mjs → notice.js} +2 -2
- package/dist/action/{patch.mjs → patch.js} +6 -6
- package/dist/action/{recommend.mjs → recommend.js} +4 -4
- package/dist/action/{set.mjs → set.js} +3 -3
- package/dist/action/{templates.mjs → templates.js} +2 -2
- package/dist/action/{utils.mjs → utils.js} +22 -1
- package/dist/ask/{dir.mjs → dir.js} +4 -3
- package/dist/ask/{kv.mjs → kv.js} +3 -3
- package/dist/ask/{mod.mjs → mod.js} +5 -5
- package/dist/ask/{mq.mjs → mq.js} +3 -3
- package/dist/ask/{pm.mjs → pm.js} +3 -3
- package/dist/ask/{wf.mjs → wf.js} +2 -2
- package/dist/{command.d.mts → command.d.ts} +3 -3
- package/dist/{command.mjs → command.js} +1 -1
- package/dist/{const.mjs → const.js} +4 -3
- package/dist/{deno.mjs → deno.js} +1 -1
- package/dist/json/deps.js +31 -0
- package/dist/json/deps.json +31 -0
- package/dist/json/{kv.mjs → kv.js} +3 -3
- package/dist/json/kv.json +63 -17
- package/dist/json/{mq.mjs → mq.js} +5 -5
- package/dist/json/mq.json +5 -5
- package/dist/{lib.mjs → lib.js} +10 -13
- package/dist/mod.d.ts +3 -0
- package/dist/mod.js +3 -0
- package/dist/templates/solidstart/app.config.ts.tpl +8 -0
- package/dist/templates/solidstart/src/app.tsx.tpl +11 -0
- package/dist/templates/solidstart/src/entry-client.tsx.tpl +4 -0
- package/dist/templates/solidstart/src/entry-server.tsx.tpl +20 -0
- package/dist/templates/solidstart/src/middleware/index.ts.tpl +4 -0
- package/dist/templates/solidstart/src/routes/index.tsx.tpl +10 -0
- package/dist/test/{action.mjs → action.js} +5 -5
- package/dist/test/{create.mjs → create.js} +14 -28
- package/dist/test/{db.mjs → db.js} +3 -3
- package/dist/test/{fill.mjs → fill.js} +1 -1
- package/dist/test/lookup.js +111 -0
- package/dist/test/{mod.mjs → mod.js} +4 -3
- package/dist/test/port.js +128 -0
- package/dist/test/{run.mjs → run.js} +4 -4
- package/dist/test/server.js +137 -0
- package/dist/test/{utils.mjs → utils.js} +1 -1
- package/dist/{types.d.mts → types.d.ts} +3 -3
- package/dist/{utils.d.mts → utils.d.ts} +1 -3
- package/dist/{utils.mjs → utils.js} +2 -78
- package/dist/webframeworks/{astro.mjs → astro.js} +10 -8
- package/dist/webframeworks/{bare-bones.mjs → bare-bones.js} +13 -12
- package/dist/webframeworks/{const.mjs → const.js} +4 -2
- package/dist/webframeworks/{elysia.mjs → elysia.js} +15 -14
- package/dist/webframeworks/{express.mjs → express.js} +10 -9
- package/dist/webframeworks/{hono.mjs → hono.js} +17 -16
- package/dist/webframeworks/{mod.mjs → mod.js} +10 -8
- package/dist/webframeworks/{next.mjs → next.js} +6 -5
- package/dist/webframeworks/{nitro.mjs → nitro.js} +4 -4
- package/dist/webframeworks/solidstart.js +70 -0
- package/dist/webframeworks/{utils.mjs → utils.js} +1 -1
- package/package.json +4 -1
- package/dist/action/install.mjs +0 -18
- package/dist/action/precommand.mjs +0 -22
- package/dist/mod.d.mts +0 -3
- package/dist/mod.mjs +0 -3
- package/dist/test/lookup.mjs +0 -185
- /package/dist/action/{const.mjs → const.js} +0 -0
- /package/dist/action/{dir.mjs → dir.js} +0 -0
- /package/dist/{const.d.mts → const.d.ts} +0 -0
- /package/dist/json/{biome.mjs → biome.js} +0 -0
- /package/dist/json/{db-to-check.mjs → db-to-check.js} +0 -0
- /package/dist/json/{pm.mjs → pm.js} +0 -0
- /package/dist/json/{rt.mjs → rt.js} +0 -0
- /package/dist/json/{vscode-settings-for-deno.mjs → vscode-settings-for-deno.js} +0 -0
- /package/dist/json/{vscode-settings.mjs → vscode-settings.js} +0 -0
- /package/dist/test/{mod.d.mts → mod.d.ts} +0 -0
package/dist/test/lookup.mjs
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { printErrorMessage, printMessage, runSubCommand } from "../utils.mjs";
|
|
2
|
-
import { getDevCommand } from "../lib.mjs";
|
|
3
|
-
import webFrameworks from "../webframeworks/mod.mjs";
|
|
4
|
-
import process from "node:process";
|
|
5
|
-
import { values } from "@optique/core";
|
|
6
|
-
import { spawn } from "node:child_process";
|
|
7
|
-
import { createWriteStream } from "node:fs";
|
|
8
|
-
import { join, sep } from "node:path";
|
|
9
|
-
import { isEmpty } from "@fxts/core/index.js";
|
|
10
|
-
//#region src/test/lookup.ts
|
|
11
|
-
const HANDLE = "john";
|
|
12
|
-
const STARTUP_TIMEOUT = 3e4;
|
|
13
|
-
const CWD = process.cwd();
|
|
14
|
-
const BANNED_WFS = ["next"];
|
|
15
|
-
/**
|
|
16
|
-
* Run servers for all generated apps and test them with the lookup command.
|
|
17
|
-
*
|
|
18
|
-
* @param dirs - Array of paths to generated app directories
|
|
19
|
-
*/
|
|
20
|
-
async function runServerAndLookupUser(dirs) {
|
|
21
|
-
const valid = dirs.filter(Boolean);
|
|
22
|
-
if (valid.length === 0) {
|
|
23
|
-
printErrorMessage`\nNo directories to lookup test.`;
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const filtered = filterWebFrameworks(valid);
|
|
27
|
-
printMessage`\nLookup Test start for ${String(filtered.length)} app(s)!`;
|
|
28
|
-
const results = await Array.fromAsync(filtered, testApp);
|
|
29
|
-
const successCount = results.filter(Boolean).length;
|
|
30
|
-
const failCount = results.length - successCount;
|
|
31
|
-
printMessage`Lookup Test Results:
|
|
32
|
-
Total: ${String(results.length)}
|
|
33
|
-
Passed: ${String(successCount)}
|
|
34
|
-
Failed: ${String(failCount)}\n\n`;
|
|
35
|
-
}
|
|
36
|
-
function filterWebFrameworks(dirs) {
|
|
37
|
-
const wfs = new Set(dirs.map((dir) => dir.split(sep).slice(-4, -3)[0]));
|
|
38
|
-
const hasBanned = BANNED_WFS.filter((wf) => wfs.has(wf));
|
|
39
|
-
if (isEmpty(hasBanned)) return dirs;
|
|
40
|
-
printErrorMessage`\n${values(hasBanned.map((wf) => webFrameworks[wf]["label"]))} is not supported in lookup test yet.`;
|
|
41
|
-
return dirs.filter((dir) => !BANNED_WFS.includes(dir.split(sep).slice(-4, -3)[0]));
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Run the dev server and test with lookup command.
|
|
45
|
-
*/
|
|
46
|
-
async function testApp(dir) {
|
|
47
|
-
const [wf, pm, kv, mq] = dir.split(sep).slice(-4);
|
|
48
|
-
printMessage` Testing ${values([
|
|
49
|
-
wf,
|
|
50
|
-
pm,
|
|
51
|
-
kv,
|
|
52
|
-
mq
|
|
53
|
-
])}...`;
|
|
54
|
-
const result = await serverClosure(dir, getDevCommand(pm), webFrameworks[wf].defaultPort, sendLookup).catch(() => false);
|
|
55
|
-
printMessage` Lookup ${result ? "successful" : "failed"} for ${values([
|
|
56
|
-
wf,
|
|
57
|
-
pm,
|
|
58
|
-
kv,
|
|
59
|
-
mq
|
|
60
|
-
])}!`;
|
|
61
|
-
if (!result) printMessage` Check out these files for more details:
|
|
62
|
-
${join(dir, "out.txt")} and
|
|
63
|
-
${join(dir, "err.txt")}\n`;
|
|
64
|
-
printMessage`\n`;
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
67
|
-
const sendLookup = async (port) => {
|
|
68
|
-
const serverUrl = `http://localhost:${port}`;
|
|
69
|
-
const lookupTarget = `${serverUrl}/users/${HANDLE}`;
|
|
70
|
-
printMessage` Waiting for server to start at ${serverUrl}...`;
|
|
71
|
-
if (!await waitForServer(serverUrl, STARTUP_TIMEOUT)) {
|
|
72
|
-
printErrorMessage`Server did not start within \
|
|
73
|
-
${String(STARTUP_TIMEOUT)}ms`;
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
printMessage` Server is ready. Running lookup command...`;
|
|
77
|
-
try {
|
|
78
|
-
await runSubCommand([
|
|
79
|
-
"deno",
|
|
80
|
-
"task",
|
|
81
|
-
"cli",
|
|
82
|
-
"lookup",
|
|
83
|
-
lookupTarget
|
|
84
|
-
], { cwd: CWD });
|
|
85
|
-
return true;
|
|
86
|
-
} catch (error) {
|
|
87
|
-
if (error instanceof Error) printErrorMessage`${error.message}`;
|
|
88
|
-
}
|
|
89
|
-
return false;
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Wait for the server to be ready by checking if it responds to requests.
|
|
93
|
-
*/
|
|
94
|
-
async function waitForServer(url, timeout) {
|
|
95
|
-
const startTime = Date.now();
|
|
96
|
-
while (Date.now() - startTime < timeout) {
|
|
97
|
-
try {
|
|
98
|
-
if ((await fetch(url, { signal: AbortSignal.timeout(1e3) })).ok) return true;
|
|
99
|
-
} catch {}
|
|
100
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
101
|
-
}
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
async function serverClosure(dir, cmd, defaultPort, callback) {
|
|
105
|
-
const devCommand = cmd.split(" ");
|
|
106
|
-
const serverProcess = spawn(devCommand[0], devCommand.slice(1), {
|
|
107
|
-
cwd: dir,
|
|
108
|
-
stdio: [
|
|
109
|
-
"ignore",
|
|
110
|
-
"pipe",
|
|
111
|
-
"pipe"
|
|
112
|
-
],
|
|
113
|
-
detached: true
|
|
114
|
-
});
|
|
115
|
-
const stdout = createWriteStream(join(dir, "out.txt"), { flags: "a" });
|
|
116
|
-
const stderr = createWriteStream(join(dir, "err.txt"), { flags: "a" });
|
|
117
|
-
serverProcess.stdout?.pipe(stdout);
|
|
118
|
-
serverProcess.stderr?.pipe(stderr);
|
|
119
|
-
try {
|
|
120
|
-
return await callback(await determinePort(serverProcess).catch((err) => {
|
|
121
|
-
printErrorMessage`Failed to determine server port: ${err.message}`;
|
|
122
|
-
printErrorMessage`Use default port ${String(defaultPort)} for lookup.`;
|
|
123
|
-
return defaultPort;
|
|
124
|
-
}));
|
|
125
|
-
} finally {
|
|
126
|
-
try {
|
|
127
|
-
process.kill(-serverProcess.pid, "SIGKILL");
|
|
128
|
-
} catch {
|
|
129
|
-
serverProcess.kill("SIGKILL");
|
|
130
|
-
stdout.end();
|
|
131
|
-
stderr.end();
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
function determinePort(server) {
|
|
136
|
-
return new Promise((resolve, reject) => {
|
|
137
|
-
const timeout = setTimeout(() => {
|
|
138
|
-
reject(/* @__PURE__ */ new Error("Timeout: Could not determine port from server output"));
|
|
139
|
-
}, STARTUP_TIMEOUT);
|
|
140
|
-
let stdoutData = "";
|
|
141
|
-
let stderrData = "";
|
|
142
|
-
const portPatterns = [
|
|
143
|
-
/listening on.*:(\d+)/i,
|
|
144
|
-
/server.*:(\d+)/i,
|
|
145
|
-
/port\s*:?\s*(\d+)/i,
|
|
146
|
-
/https?:\/\/localhost:(\d+)/i,
|
|
147
|
-
/https?:\/\/0\.0\.0\.0:(\d+)/i,
|
|
148
|
-
/https?:\/\/127\.0\.0\.1:(\d+)/i,
|
|
149
|
-
/https?:\/\/[^:]+:(\d+)/i
|
|
150
|
-
];
|
|
151
|
-
const checkForPort = (data) => {
|
|
152
|
-
for (const pattern of portPatterns) {
|
|
153
|
-
const match = data.match(pattern);
|
|
154
|
-
if (match && match[1]) {
|
|
155
|
-
const port = Number.parseInt(match[1], 10);
|
|
156
|
-
if (port > 0 && port < 65536) {
|
|
157
|
-
clearTimeout(timeout);
|
|
158
|
-
return port;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return null;
|
|
163
|
-
};
|
|
164
|
-
server.stdout.on("data", (chunk) => {
|
|
165
|
-
stdoutData += chunk.toString();
|
|
166
|
-
const port = checkForPort(stdoutData);
|
|
167
|
-
if (port) resolve(port);
|
|
168
|
-
});
|
|
169
|
-
server.stderr.on("data", (chunk) => {
|
|
170
|
-
stderrData += chunk.toString();
|
|
171
|
-
const port = checkForPort(stderrData);
|
|
172
|
-
if (port) resolve(port);
|
|
173
|
-
});
|
|
174
|
-
server.on("error", (err) => {
|
|
175
|
-
clearTimeout(timeout);
|
|
176
|
-
reject(err);
|
|
177
|
-
});
|
|
178
|
-
server.on("exit", (code) => {
|
|
179
|
-
clearTimeout(timeout);
|
|
180
|
-
reject(/* @__PURE__ */ new Error(`Server exited with code ${code} before port could be determined`));
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
//#endregion
|
|
185
|
-
export { runServerAndLookupUser as default };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|