@le-space/node 0.1.17 → 0.1.19
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/README.md +1 -2
- package/index.d.ts +8 -8
- package/index.js +14 -10
- package/package.json +4 -4
- package/reference/publish-static-site.py +65 -0
package/README.md
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { MessageSigner, InstanceAllocation, PortMapping, RuntimeDiagnostics, CrnRecord, RootfsRequiredPortForward, MessageHasher, RootfsManifest as RootfsManifest$1 } from '@
|
|
1
|
+
import * as _le_space_shared_types from '@le-space/shared-types';
|
|
2
|
+
import { MessageSigner, InstanceAllocation, PortMapping, RuntimeDiagnostics, CrnRecord, RootfsRequiredPortForward, MessageHasher, RootfsManifest as RootfsManifest$1 } from '@le-space/shared-types';
|
|
3
3
|
|
|
4
4
|
declare function requiredEnv(name: string, env?: NodeJS.ProcessEnv): string;
|
|
5
5
|
declare function optionalEnv(name: string, fallback?: string, env?: NodeJS.ProcessEnv): string;
|
|
@@ -175,9 +175,9 @@ declare function forgetAlephMessages(args: {
|
|
|
175
175
|
}): Promise<{
|
|
176
176
|
sender: string;
|
|
177
177
|
itemHash: string;
|
|
178
|
-
response:
|
|
178
|
+
response: _le_space_shared_types.AlephBroadcastResponse;
|
|
179
179
|
httpStatus: number;
|
|
180
|
-
status:
|
|
180
|
+
status: _le_space_shared_types.MessageStatus;
|
|
181
181
|
}>;
|
|
182
182
|
|
|
183
183
|
interface RetentionRecord {
|
|
@@ -210,8 +210,8 @@ declare function retainSuccessfulDeployments(args: {
|
|
|
210
210
|
keepCount: number;
|
|
211
211
|
aggregatePublication: {
|
|
212
212
|
itemHash: string;
|
|
213
|
-
status:
|
|
214
|
-
response:
|
|
213
|
+
status: _le_space_shared_types.MessageStatus;
|
|
214
|
+
response: _le_space_shared_types.AlephBroadcastResponse;
|
|
215
215
|
httpStatus: number;
|
|
216
216
|
};
|
|
217
217
|
retainedRecords: RetentionRecord[];
|
|
@@ -223,9 +223,9 @@ declare function retainSuccessfulDeployments(args: {
|
|
|
223
223
|
forgetResult: {
|
|
224
224
|
sender: string;
|
|
225
225
|
itemHash: string;
|
|
226
|
-
response:
|
|
226
|
+
response: _le_space_shared_types.AlephBroadcastResponse;
|
|
227
227
|
httpStatus: number;
|
|
228
|
-
status:
|
|
228
|
+
status: _le_space_shared_types.MessageStatus;
|
|
229
229
|
} | null;
|
|
230
230
|
followUpForgetResults: {
|
|
231
231
|
hash: string;
|
package/index.js
CHANGED
|
@@ -2285,7 +2285,7 @@ async function runActionMode(env = process.env, hooks = {}) {
|
|
|
2285
2285
|
return;
|
|
2286
2286
|
}
|
|
2287
2287
|
if (mode !== "deploy") {
|
|
2288
|
-
throw new Error(`Unsupported ALEPH_VM_MODE "${mode}" in
|
|
2288
|
+
throw new Error(`Unsupported ALEPH_VM_MODE "${mode}" in Aleph action runner.`);
|
|
2289
2289
|
}
|
|
2290
2290
|
const providedDeployResult = parseOptionalJson(env.ALEPH_VM_DEPLOY_RESULT_JSON);
|
|
2291
2291
|
let deployResult = providedDeployResult;
|
|
@@ -2301,19 +2301,19 @@ async function runActionMode(env = process.env, hooks = {}) {
|
|
|
2301
2301
|
}
|
|
2302
2302
|
}
|
|
2303
2303
|
if (!deployResult) {
|
|
2304
|
-
throw new Error("
|
|
2304
|
+
throw new Error("Aleph action runner did not produce a deploy result.");
|
|
2305
2305
|
}
|
|
2306
2306
|
await emitDeployOutputs(deployResult, env);
|
|
2307
2307
|
await appendGithubOutput("action_runner_mode", mode, env);
|
|
2308
2308
|
await appendGithubOutput("action_runner_profile", optionalEnv("ALEPH_VM_PROFILE", "uc-go-peer", env), env);
|
|
2309
2309
|
await appendGithubSummary([
|
|
2310
2310
|
"",
|
|
2311
|
-
"###
|
|
2311
|
+
"### Aleph Action Runner",
|
|
2312
2312
|
"",
|
|
2313
2313
|
`- Mode: \`${mode}\``,
|
|
2314
2314
|
`- Profile: \`${optionalEnv("ALEPH_VM_PROFILE", "uc-go-peer", env)}\``
|
|
2315
2315
|
], env);
|
|
2316
|
-
actionLog("notice", `
|
|
2316
|
+
actionLog("notice", `Aleph action runner executed in ${mode} mode for profile ${optionalEnv("ALEPH_VM_PROFILE", "uc-go-peer", env)}.`);
|
|
2317
2317
|
stdout(`${JSON.stringify(deployResult)}
|
|
2318
2318
|
`);
|
|
2319
2319
|
}
|
|
@@ -2949,7 +2949,7 @@ async function emitRootfsOutputs(result, env = process.env) {
|
|
|
2949
2949
|
await appendGithubOutput("rootfs_source_size_bytes", result.finalized.publication.sourceSizeBytes, env);
|
|
2950
2950
|
}
|
|
2951
2951
|
await appendGithubSummary([
|
|
2952
|
-
"##
|
|
2952
|
+
"## Aleph Rootfs Runner",
|
|
2953
2953
|
"",
|
|
2954
2954
|
`- Version: \`${result.finalized.manifest.version}\``,
|
|
2955
2955
|
`- Execution mode: \`${result.pipeline.executionPlan.mode}\``,
|
|
@@ -2993,7 +2993,7 @@ async function runRootfsMode(env = process.env, hooks = {}) {
|
|
|
2993
2993
|
`);
|
|
2994
2994
|
return;
|
|
2995
2995
|
}
|
|
2996
|
-
throw new Error(`Unsupported ALEPH_VM_MODE "${mode}" in
|
|
2996
|
+
throw new Error(`Unsupported ALEPH_VM_MODE "${mode}" in Aleph rootfs runner.`);
|
|
2997
2997
|
}
|
|
2998
2998
|
async function rootfsMain() {
|
|
2999
2999
|
await runRootfsMode(process.env);
|
|
@@ -3009,6 +3009,7 @@ if (import.meta.url === pathToFileURL2(process.argv[1] ?? "").href) {
|
|
|
3009
3009
|
// src/site-runner.ts
|
|
3010
3010
|
import process2 from "process";
|
|
3011
3011
|
import { spawn as spawn2 } from "child_process";
|
|
3012
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
3012
3013
|
async function runCapture(command, args, options = {}) {
|
|
3013
3014
|
return await new Promise((resolve, reject) => {
|
|
3014
3015
|
const child = spawn2(command, args, {
|
|
@@ -3061,6 +3062,9 @@ async function waitForAlephMessage(itemHash, env = process2.env) {
|
|
|
3061
3062
|
}
|
|
3062
3063
|
throw new Error(`Aleph STORE message ${itemHash} did not become processed in time.`);
|
|
3063
3064
|
}
|
|
3065
|
+
function defaultSitePublishScriptPath() {
|
|
3066
|
+
return fileURLToPath2(new URL("../reference/publish-static-site.py", import.meta.url));
|
|
3067
|
+
}
|
|
3064
3068
|
function mergedAddrs(env = process2.env) {
|
|
3065
3069
|
const combined = [];
|
|
3066
3070
|
for (const key of ["PROBE_MULTIADDRS_JSON", "BROWSER_BOOTSTRAP_MULTIADDRS_JSON"]) {
|
|
@@ -3076,7 +3080,7 @@ function mergedAddrs(env = process2.env) {
|
|
|
3076
3080
|
}
|
|
3077
3081
|
async function runSitePublishMode(env = process2.env) {
|
|
3078
3082
|
const projectDir = requiredEnv("ALEPH_SITE_PROJECT_DIR", env);
|
|
3079
|
-
const publishScript = optionalEnv("ALEPH_SITE_PUBLISH_SCRIPT",
|
|
3083
|
+
const publishScript = optionalEnv("ALEPH_SITE_PUBLISH_SCRIPT", defaultSitePublishScriptPath(), env);
|
|
3080
3084
|
const siteDirectory = requiredEnv("ALEPH_SITE_DIRECTORY", env);
|
|
3081
3085
|
const pythonBin = optionalEnv("ALEPH_SITE_PYTHON", "python3", env);
|
|
3082
3086
|
const alephBin = optionalEnv("ALEPH_SITE_ALEPH_BIN", "aleph", env);
|
|
@@ -3113,7 +3117,7 @@ async function runSitePublishMode(env = process2.env) {
|
|
|
3113
3117
|
await waitForAlephMessage(itemHash, env);
|
|
3114
3118
|
}
|
|
3115
3119
|
await appendGithubSummary([
|
|
3116
|
-
"##
|
|
3120
|
+
"## Aleph Site Runner",
|
|
3117
3121
|
"",
|
|
3118
3122
|
`- Site directory: \`${siteDirectory}\``,
|
|
3119
3123
|
`- IPFS CID v0: \`${cidV0}\``,
|
|
@@ -3140,7 +3144,7 @@ async function runDomainLinkMode(env = process2.env) {
|
|
|
3140
3144
|
await appendGithubOutput("item_hash", itemHash, env);
|
|
3141
3145
|
await appendGithubOutput("url", `https://${domain}`, env);
|
|
3142
3146
|
await appendGithubSummary([
|
|
3143
|
-
"##
|
|
3147
|
+
"## Aleph Site Runner",
|
|
3144
3148
|
"",
|
|
3145
3149
|
`- Linked domain: \`${domain}\``,
|
|
3146
3150
|
`- Aleph item hash: \`${itemHash}\``,
|
|
@@ -3181,7 +3185,7 @@ async function runSiteMode(env = process2.env) {
|
|
|
3181
3185
|
if (mode === "site-domain-link") return await runDomainLinkMode(env);
|
|
3182
3186
|
if (mode === "relay-probe") return await runProbeMode(env);
|
|
3183
3187
|
if (mode === "bootstrap-env") return await runBootstrapEnvMode(env);
|
|
3184
|
-
throw new Error(`Unsupported ALEPH_VM_MODE "${mode}" in
|
|
3188
|
+
throw new Error(`Unsupported ALEPH_VM_MODE "${mode}" in Aleph site runner.`);
|
|
3185
3189
|
}
|
|
3186
3190
|
export {
|
|
3187
3191
|
actionLog,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@le-space/node",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "Node and GitHub Actions adapters for shared Aleph tooling.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@le-space/core": "0.1.
|
|
20
|
-
"@le-space/shared-types": "0.1.
|
|
21
|
-
"@le-space/rootfs": "0.1.
|
|
19
|
+
"@le-space/core": "0.1.19",
|
|
20
|
+
"@le-space/shared-types": "0.1.19",
|
|
21
|
+
"@le-space/rootfs": "0.1.19",
|
|
22
22
|
"ethers": "^6.15.0"
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import json
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
import requests
|
|
7
|
+
from cid import make_cid
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def upload_directory(folder: Path, gateway: str) -> dict[str, str]:
|
|
11
|
+
url = f"{gateway.rstrip('/')}/api/v0/add"
|
|
12
|
+
params = {
|
|
13
|
+
"recursive": "true",
|
|
14
|
+
"wrap-with-directory": "true",
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
handles = []
|
|
18
|
+
files = []
|
|
19
|
+
try:
|
|
20
|
+
for path in sorted(folder.rglob("*")):
|
|
21
|
+
if not path.is_file():
|
|
22
|
+
continue
|
|
23
|
+
relative_path = path.relative_to(folder)
|
|
24
|
+
handle = path.open("rb")
|
|
25
|
+
handles.append(handle)
|
|
26
|
+
files.append(("file", (str(relative_path), handle)))
|
|
27
|
+
|
|
28
|
+
if not files:
|
|
29
|
+
raise RuntimeError(f"No files found under {folder}")
|
|
30
|
+
|
|
31
|
+
response = requests.post(url, params=params, files=files, timeout=300)
|
|
32
|
+
response.raise_for_status()
|
|
33
|
+
|
|
34
|
+
cid_v0 = None
|
|
35
|
+
for line in response.text.strip().splitlines():
|
|
36
|
+
entry = json.loads(line)
|
|
37
|
+
cid_v0 = entry.get("Hash") or cid_v0
|
|
38
|
+
|
|
39
|
+
if not cid_v0:
|
|
40
|
+
raise RuntimeError("CID not found in IPFS response")
|
|
41
|
+
|
|
42
|
+
cid_v1 = make_cid(cid_v0).to_v1().encode("base32").decode()
|
|
43
|
+
return {"cid_v0": cid_v0, "cid_v1": cid_v1}
|
|
44
|
+
finally:
|
|
45
|
+
for handle in handles:
|
|
46
|
+
handle.close()
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def main() -> int:
|
|
50
|
+
if len(sys.argv) != 2:
|
|
51
|
+
print("usage: publish-static-site.py <directory>", file=sys.stderr)
|
|
52
|
+
return 2
|
|
53
|
+
|
|
54
|
+
directory = Path(sys.argv[1]).resolve()
|
|
55
|
+
if not directory.is_dir():
|
|
56
|
+
print(f"Error: path must be a directory: {directory}", file=sys.stderr)
|
|
57
|
+
return 1
|
|
58
|
+
|
|
59
|
+
result = upload_directory(directory, "https://ipfs-2.aleph.im")
|
|
60
|
+
print(json.dumps(result))
|
|
61
|
+
return 0
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
if __name__ == "__main__":
|
|
65
|
+
raise SystemExit(main())
|