@fedify/cli 1.8.12 → 2.0.0-dev.1761
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/deno.json +71 -0
- package/dist/cache.js +17 -0
- package/dist/deno.js +71 -0
- package/dist/docloader.js +52 -0
- package/dist/globals.js +49 -0
- package/dist/imagerenderer.js +105 -0
- package/dist/inbox/rendercode.js +57 -0
- package/dist/inbox/view.js +508 -0
- package/dist/inbox.js +315 -0
- package/dist/init/action/configs.js +81 -0
- package/dist/init/action/deps.js +52 -0
- package/dist/init/action/dir.js +16 -0
- package/dist/init/action/env.js +13 -0
- package/dist/init/action/install.js +22 -0
- package/dist/init/action/mod.js +39 -0
- package/dist/init/action/notice.js +62 -0
- package/dist/init/action/patch.js +141 -0
- package/dist/init/action/precommand.js +23 -0
- package/dist/init/action/recommend.js +24 -0
- package/dist/init/action/set.js +31 -0
- package/dist/init/action/templates.js +57 -0
- package/dist/init/action/utils.js +50 -0
- package/dist/init/ask/dir.js +82 -0
- package/dist/init/ask/kv.js +33 -0
- package/dist/init/ask/mod.js +16 -0
- package/dist/init/ask/mq.js +33 -0
- package/dist/init/ask/pm.js +49 -0
- package/dist/init/ask/wf.js +29 -0
- package/dist/init/command.js +25 -0
- package/dist/init/const.js +31 -0
- package/dist/init/json/biome.js +24 -0
- package/dist/init/json/kv.js +53 -0
- package/dist/init/json/mq.js +72 -0
- package/dist/init/json/pm.js +44 -0
- package/dist/init/json/rt.js +39 -0
- package/dist/init/json/vscode-settings-for-deno.js +53 -0
- package/dist/init/json/vscode-settings.js +49 -0
- package/dist/init/lib.js +129 -0
- package/dist/init/mod.js +5 -0
- package/dist/init/webframeworks.js +133 -0
- package/dist/kv.bun.js +17 -0
- package/dist/kv.node.js +17 -0
- package/dist/log.js +52 -0
- package/dist/lookup.js +287 -0
- package/dist/mod.js +34 -0
- package/dist/nodeinfo.js +261 -0
- package/dist/table.js +24 -0
- package/dist/tempserver.js +71 -0
- package/dist/tunnel.js +21 -0
- package/dist/utils.js +67 -0
- package/dist/webfinger/action.js +44 -0
- package/dist/webfinger/command.js +20 -0
- package/dist/webfinger/error.js +47 -0
- package/dist/webfinger/lib.js +45 -0
- package/dist/webfinger/mod.js +5 -0
- package/package.json +64 -24
- package/scripts/pack.ts +64 -0
- package/src/cache.ts +17 -0
- package/src/docloader.ts +67 -0
- package/src/globals.ts +43 -0
- package/src/imagerenderer.ts +149 -0
- package/src/inbox/entry.ts +10 -0
- package/src/inbox/rendercode.ts +68 -0
- package/src/inbox/view.tsx +598 -0
- package/src/inbox.tsx +535 -0
- package/src/init/action/configs.ts +88 -0
- package/src/init/action/deps.ts +93 -0
- package/src/init/action/dir.ts +11 -0
- package/src/init/action/env.ts +14 -0
- package/src/init/action/install.ts +59 -0
- package/src/init/action/mod.ts +66 -0
- package/src/init/action/notice.ts +101 -0
- package/src/init/action/patch.ts +212 -0
- package/src/init/action/precommand.ts +22 -0
- package/src/init/action/recommend.ts +38 -0
- package/src/init/action/set.ts +78 -0
- package/src/init/action/templates.ts +95 -0
- package/src/init/action/utils.ts +64 -0
- package/src/init/ask/dir.ts +98 -0
- package/src/init/ask/kv.ts +39 -0
- package/src/init/ask/mod.ts +23 -0
- package/src/init/ask/mq.ts +37 -0
- package/src/init/ask/pm.ts +58 -0
- package/src/init/ask/wf.ts +27 -0
- package/src/init/command.ts +64 -0
- package/src/init/const.ts +4 -0
- package/src/init/json/biome.json +17 -0
- package/src/init/json/kv.json +39 -0
- package/src/init/json/mq.json +95 -0
- package/src/init/json/pm.json +47 -0
- package/src/init/json/rt.json +42 -0
- package/src/init/json/vscode-settings-for-deno.json +43 -0
- package/src/init/json/vscode-settings.json +41 -0
- package/src/init/lib.ts +220 -0
- package/src/init/mod.ts +2 -0
- package/src/init/templates/defaults/federation.ts.tpl +23 -0
- package/src/init/templates/defaults/logging.ts.tpl +23 -0
- package/src/init/templates/express/app.ts.tpl +16 -0
- package/src/init/templates/express/index.ts.tpl +6 -0
- package/src/init/templates/hono/app.tsx.tpl +14 -0
- package/src/init/templates/hono/index/bun.ts.tpl +10 -0
- package/src/init/templates/hono/index/deno.ts.tpl +13 -0
- package/src/init/templates/hono/index/node.ts.tpl +14 -0
- package/src/init/templates/next/middleware.ts.tpl +45 -0
- package/src/init/templates/nitro/nitro.config.ts.tpl +5 -0
- package/src/init/templates/nitro/server/error.ts.tpl +3 -0
- package/src/init/templates/nitro/server/middleware/federation.ts.tpl +8 -0
- package/src/init/types.ts +88 -0
- package/src/init/webframeworks.ts +151 -0
- package/src/kv.bun.ts +12 -0
- package/src/kv.node.ts +11 -0
- package/src/log.ts +64 -0
- package/src/lookup.test.ts +182 -0
- package/src/lookup.ts +558 -0
- package/src/mod.ts +45 -0
- package/src/nodeinfo.test.ts +229 -0
- package/src/nodeinfo.ts +447 -0
- package/src/table.ts +17 -0
- package/src/tempserver.ts +87 -0
- package/src/tunnel.ts +32 -0
- package/src/utils.ts +136 -0
- package/src/webfinger/action.ts +50 -0
- package/src/webfinger/command.ts +59 -0
- package/src/webfinger/error.ts +47 -0
- package/src/webfinger/lib.ts +37 -0
- package/src/webfinger/mod.test.ts +79 -0
- package/src/webfinger/mod.ts +2 -0
- package/tsdown.config.ts +24 -0
- package/src/install.mjs +0 -189
- package/src/run.mjs +0 -22
package/src/install.mjs
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { execFile } from "node:child_process";
|
|
2
|
-
import { createWriteStream, existsSync } from "node:fs";
|
|
3
|
-
import {
|
|
4
|
-
access,
|
|
5
|
-
chmod,
|
|
6
|
-
constants,
|
|
7
|
-
copyFile,
|
|
8
|
-
mkdir,
|
|
9
|
-
mkdtemp,
|
|
10
|
-
readFile,
|
|
11
|
-
realpath,
|
|
12
|
-
} from "node:fs/promises";
|
|
13
|
-
import { tmpdir } from "node:os";
|
|
14
|
-
import { dirname, join } from "node:path";
|
|
15
|
-
import process from "node:process";
|
|
16
|
-
import { Readable } from "node:stream";
|
|
17
|
-
import { fileURLToPath } from "node:url";
|
|
18
|
-
|
|
19
|
-
const platforms = {
|
|
20
|
-
darwin: {
|
|
21
|
-
arm64: "macos-aarch64.tar.xz",
|
|
22
|
-
x64: "macos-x86_64.tar.xz",
|
|
23
|
-
},
|
|
24
|
-
linux: {
|
|
25
|
-
arm64: "linux-aarch64.tar.xz",
|
|
26
|
-
x64: "linux-x86_64.tar.xz",
|
|
27
|
-
},
|
|
28
|
-
win32: {
|
|
29
|
-
arm64: "windows-x86_64.zip",
|
|
30
|
-
x64: "windows-x86_64.zip",
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export async function main(version) {
|
|
35
|
-
const filename = fileURLToPath(import.meta.url);
|
|
36
|
-
const dirName = dirname(dirname(filename));
|
|
37
|
-
const packageJson = await readFile(join(dirName, "package.json"), {
|
|
38
|
-
encoding: "utf8",
|
|
39
|
-
});
|
|
40
|
-
const pkg = JSON.parse(packageJson);
|
|
41
|
-
const binDir = join(dirName, "bin");
|
|
42
|
-
await mkdir(binDir, { recursive: true });
|
|
43
|
-
await install(version ?? pkg.version, binDir);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async function install(version, targetDir) {
|
|
47
|
-
const downloadUrl = getDownloadUrl(version);
|
|
48
|
-
const downloadPath = await download(downloadUrl);
|
|
49
|
-
if (downloadPath == null) {
|
|
50
|
-
throw new Error(`Failed to download from ${downloadUrl}`);
|
|
51
|
-
}
|
|
52
|
-
let extractPath;
|
|
53
|
-
if (downloadPath.endsWith(".zip")) {
|
|
54
|
-
extractPath = await extractZip(downloadPath);
|
|
55
|
-
} else {
|
|
56
|
-
extractPath = await extractTar(downloadPath);
|
|
57
|
-
}
|
|
58
|
-
const exePath = join(extractPath, "fedify.exe");
|
|
59
|
-
if (await isFile(exePath)) {
|
|
60
|
-
const targetPath = join(targetDir, "fedify.exe");
|
|
61
|
-
await copyFile(exePath, targetPath);
|
|
62
|
-
return targetPath;
|
|
63
|
-
}
|
|
64
|
-
const binPath = join(extractPath, "fedify");
|
|
65
|
-
if (await isFile(binPath)) {
|
|
66
|
-
const targetPath = join(targetDir, "fedify");
|
|
67
|
-
await copyFile(binPath, targetPath);
|
|
68
|
-
await chmod(targetPath, 0o755);
|
|
69
|
-
return targetPath;
|
|
70
|
-
}
|
|
71
|
-
throw new Error("Executable not found in the archive");
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function getDownloadUrl(version) {
|
|
75
|
-
const platform = platforms[process.platform];
|
|
76
|
-
if (!platform) {
|
|
77
|
-
console.error("Unsupported platform:", process.platform);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const suffix = platform[process.arch];
|
|
81
|
-
if (!suffix) {
|
|
82
|
-
console.error("Unsupported architecture:", process.arch);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
const filename = `fedify-cli-${version}-${suffix}`;
|
|
86
|
-
const url =
|
|
87
|
-
`https://github.com/fedify-dev/fedify/releases/download/${version}/${filename}`;
|
|
88
|
-
return url;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
async function download(url) {
|
|
92
|
-
const response = await fetch(url, { redirect: "follow" });
|
|
93
|
-
if (!response.ok) {
|
|
94
|
-
console.error("Download failed:", response.statusText);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const tmpDir = await mkdtemp(join(tmpdir(), `fedify-`));
|
|
98
|
-
const filename = url.substring(url.lastIndexOf("/") + 1);
|
|
99
|
-
const downloadPath = join(tmpDir, filename);
|
|
100
|
-
const fileStream = createWriteStream(downloadPath);
|
|
101
|
-
const readable = Readable.fromWeb(response.body);
|
|
102
|
-
await new Promise((resolve, reject) => {
|
|
103
|
-
readable.pipe(fileStream);
|
|
104
|
-
readable.on("error", reject);
|
|
105
|
-
fileStream.on("finish", resolve);
|
|
106
|
-
});
|
|
107
|
-
return downloadPath;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
async function extractZip(path) {
|
|
111
|
-
const dir = await mkdtemp(join(tmpdir(), "fedify-"));
|
|
112
|
-
await new Promise((resolve, reject) => {
|
|
113
|
-
execFile("powershell", [
|
|
114
|
-
"-NoProfile",
|
|
115
|
-
"-ExecutionPolicy",
|
|
116
|
-
"Bypass",
|
|
117
|
-
"-Command",
|
|
118
|
-
`Import-Module Microsoft.PowerShell.Archive;\
|
|
119
|
-
Expand-Archive -LiteralPath '${path}' -DestinationPath '${dir}'`,
|
|
120
|
-
], (error, _, stderr) => {
|
|
121
|
-
if (error) {
|
|
122
|
-
console.error("Extraction failed:", error);
|
|
123
|
-
reject(error);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
if (stderr) console.warn(stderr);
|
|
127
|
-
resolve();
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
return dir;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
async function extractTar(path) {
|
|
134
|
-
const switches = {
|
|
135
|
-
".tar": "",
|
|
136
|
-
".tar.gz": "z",
|
|
137
|
-
".tgz": "z",
|
|
138
|
-
".tar.bz2": "j",
|
|
139
|
-
".tbz2": "j",
|
|
140
|
-
".tar.xz": "J",
|
|
141
|
-
".txz": "J",
|
|
142
|
-
};
|
|
143
|
-
let switch_ = "";
|
|
144
|
-
for (const ext in switches) {
|
|
145
|
-
if (path.endsWith(ext)) {
|
|
146
|
-
switch_ = switches[ext];
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
path = await realpath(path);
|
|
151
|
-
const dir = await mkdtemp(join(tmpdir(), "fedify-"));
|
|
152
|
-
await execTar(`xvf${switch_}`, dir, path);
|
|
153
|
-
return dir;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function execTar(switch_, dir, path) {
|
|
157
|
-
return new Promise((resolve, reject) => {
|
|
158
|
-
execFile("tar", [switch_, path], { cwd: dir }, (error, _, stderr) => {
|
|
159
|
-
if (error) {
|
|
160
|
-
console.error("Extraction failed:", error);
|
|
161
|
-
reject(error);
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
if (stderr) console.warn(stderr);
|
|
165
|
-
resolve();
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export async function isFile(path) {
|
|
171
|
-
try {
|
|
172
|
-
await access(path, constants.R_OK);
|
|
173
|
-
return true;
|
|
174
|
-
} catch (error) {
|
|
175
|
-
if (error.code === "ENOENT") return false;
|
|
176
|
-
throw error;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (fileURLToPath(import.meta.url) === process.argv[1]) {
|
|
181
|
-
if (existsSync(join(dirname(dirname(fileURLToPath(import.meta.url))), "deno.json"))) {
|
|
182
|
-
console.error(
|
|
183
|
-
"This post-install script is not intended to be run within a workspace; " +
|
|
184
|
-
"skipping installation.",
|
|
185
|
-
);
|
|
186
|
-
} else {
|
|
187
|
-
await main(process.argv[2]);
|
|
188
|
-
}
|
|
189
|
-
}
|
package/src/run.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { spawnSync } from "node:child_process";
|
|
3
|
-
import { dirname, join } from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { main as install, isFile } from "./install.mjs";
|
|
6
|
-
|
|
7
|
-
async function main() {
|
|
8
|
-
const filename = fileURLToPath(import.meta.url);
|
|
9
|
-
const dirName = dirname(dirname(filename));
|
|
10
|
-
const binPath = join(
|
|
11
|
-
dirName,
|
|
12
|
-
"bin",
|
|
13
|
-
process.platform === "win32" ? "fedify.exe" : "fedify",
|
|
14
|
-
);
|
|
15
|
-
if (!await isFile(binPath)) await install();
|
|
16
|
-
const result = spawnSync(binPath, process.argv.slice(2), {
|
|
17
|
-
stdio: "inherit",
|
|
18
|
-
});
|
|
19
|
-
process.exit(result.status);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
await main();
|