@le-space/node 0.1.12 → 0.1.14
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/index.d.ts +3 -1
- package/index.js +39 -5
- package/package.json +4 -4
package/index.d.ts
CHANGED
|
@@ -412,9 +412,11 @@ interface RunResult {
|
|
|
412
412
|
stderr: string;
|
|
413
413
|
exitCode: number;
|
|
414
414
|
}
|
|
415
|
+
declare function parseLastJsonObject(text: string): Record<string, unknown>;
|
|
415
416
|
declare function runSitePublishMode(env?: NodeJS.ProcessEnv): Promise<void>;
|
|
417
|
+
declare function runDomainLinkMode(env?: NodeJS.ProcessEnv): Promise<void>;
|
|
416
418
|
declare function runProbeMode(env?: NodeJS.ProcessEnv): Promise<void>;
|
|
417
419
|
declare function runBootstrapEnvMode(env?: NodeJS.ProcessEnv): Promise<void>;
|
|
418
420
|
declare function runSiteMode(env?: NodeJS.ProcessEnv): Promise<void>;
|
|
419
421
|
|
|
420
|
-
export { type DeployConfigurationResult, type DeployExecutorDependencies, type DeployMetadataResult, type DeployOutputResult, type DeployPlan, type ParsedRootfsRunnerInputs, type PrivateKeyIdentity, type RunResult, actionLog, appendGithubOutput, appendGithubSummary, booleanEnv, buildScaffoldDeployResult, createPrivateKeyIdentity, createPrivateKeySigner, emitDeployOutputs, emitGeocodedCrnOutputs, emitRootfsOutputs, executeDeployPlan, integerEnv, jsonEnv, main, optionalEnv, parseDeployPlan, parseRootfsRunnerInputs, requiredEnv, rootfsMain, runActionMode, runBootstrapEnvMode, runLocalCommand, runProbeMode, runRootfsMode, runSiteMode, runSitePublishMode };
|
|
422
|
+
export { type DeployConfigurationResult, type DeployExecutorDependencies, type DeployMetadataResult, type DeployOutputResult, type DeployPlan, type ParsedRootfsRunnerInputs, type PrivateKeyIdentity, type RunResult, actionLog, appendGithubOutput, appendGithubSummary, booleanEnv, buildScaffoldDeployResult, createPrivateKeyIdentity, createPrivateKeySigner, emitDeployOutputs, emitGeocodedCrnOutputs, emitRootfsOutputs, executeDeployPlan, integerEnv, jsonEnv, main, optionalEnv, parseDeployPlan, parseLastJsonObject, parseRootfsRunnerInputs, requiredEnv, rootfsMain, runActionMode, runBootstrapEnvMode, runDomainLinkMode, runLocalCommand, runProbeMode, runRootfsMode, runSiteMode, runSitePublishMode };
|
package/index.js
CHANGED
|
@@ -2849,11 +2849,15 @@ async function runCapture(command, args, options = {}) {
|
|
|
2849
2849
|
});
|
|
2850
2850
|
}
|
|
2851
2851
|
function parseLastJsonObject(text) {
|
|
2852
|
-
const lines = text.split(/\r?\n/).
|
|
2852
|
+
const lines = text.split(/\r?\n/).filter((line) => line.trim().length > 0);
|
|
2853
2853
|
for (let index = lines.length - 1; index >= 0; index -= 1) {
|
|
2854
|
-
const
|
|
2855
|
-
if (!
|
|
2856
|
-
|
|
2854
|
+
const candidate = lines[index]?.trimStart() ?? "";
|
|
2855
|
+
if (!candidate.startsWith("{")) continue;
|
|
2856
|
+
const suffix = lines.slice(index).join("\n");
|
|
2857
|
+
try {
|
|
2858
|
+
return JSON.parse(suffix);
|
|
2859
|
+
} catch {
|
|
2860
|
+
}
|
|
2857
2861
|
}
|
|
2858
2862
|
throw new Error(`Could not parse JSON object from output: ${text}`);
|
|
2859
2863
|
}
|
|
@@ -2895,6 +2899,7 @@ async function runSitePublishMode(env = process2.env) {
|
|
|
2895
2899
|
const publishScript = optionalEnv("ALEPH_SITE_PUBLISH_SCRIPT", "go-peer/aleph/publish-static-site.py", env);
|
|
2896
2900
|
const siteDirectory = requiredEnv("ALEPH_SITE_DIRECTORY", env);
|
|
2897
2901
|
const pythonBin = optionalEnv("ALEPH_SITE_PYTHON", "python3", env);
|
|
2902
|
+
const alephBin = optionalEnv("ALEPH_SITE_ALEPH_BIN", "aleph", env);
|
|
2898
2903
|
const pin = optionalEnv("ALEPH_SITE_PIN", "true", env) === "true";
|
|
2899
2904
|
const publish = await runCapture(pythonBin, [publishScript, siteDirectory], { cwd: projectDir });
|
|
2900
2905
|
process2.stdout.write(publish.stdout);
|
|
@@ -2913,7 +2918,7 @@ async function runSitePublishMode(env = process2.env) {
|
|
|
2913
2918
|
await appendGithubOutput("url", `https://${cidV1}.ipfs.aleph.sh`, env);
|
|
2914
2919
|
let itemHash = "";
|
|
2915
2920
|
if (pin) {
|
|
2916
|
-
const pinResult = await runCapture(
|
|
2921
|
+
const pinResult = await runCapture(alephBin, ["file", "pin", cidV0], { cwd: projectDir });
|
|
2917
2922
|
if (pinResult.stdout) process2.stdout.write(pinResult.stdout);
|
|
2918
2923
|
if (pinResult.stderr) process2.stderr.write(pinResult.stderr);
|
|
2919
2924
|
if (pinResult.exitCode !== 0) {
|
|
@@ -2936,6 +2941,32 @@ async function runSitePublishMode(env = process2.env) {
|
|
|
2936
2941
|
`- Aleph item hash: \`${itemHash}\``
|
|
2937
2942
|
], env);
|
|
2938
2943
|
}
|
|
2944
|
+
async function runDomainLinkMode(env = process2.env) {
|
|
2945
|
+
const projectDir = optionalEnv("ALEPH_SITE_PROJECT_DIR", process2.cwd(), env);
|
|
2946
|
+
const domain = requiredEnv("ALEPH_SITE_DOMAIN", env);
|
|
2947
|
+
const itemHash = requiredEnv("ALEPH_SITE_ITEM_HASH", env);
|
|
2948
|
+
const catchAllPath = optionalEnv("ALEPH_SITE_DOMAIN_CATCH_ALL_PATH", "/index.html", env);
|
|
2949
|
+
const alephBin = optionalEnv("ALEPH_SITE_ALEPH_BIN", "aleph", env);
|
|
2950
|
+
const detach = await runCapture(alephBin, ["domain", "detach", domain, "--no-ask"], { cwd: projectDir });
|
|
2951
|
+
if (detach.stdout) process2.stdout.write(detach.stdout);
|
|
2952
|
+
if (detach.stderr) process2.stderr.write(detach.stderr);
|
|
2953
|
+
const attach = await runCapture(alephBin, ["domain", "attach", domain, "--item-hash", itemHash, "--catch-all-path", catchAllPath, "--no-ask"], { cwd: projectDir });
|
|
2954
|
+
if (attach.stdout) process2.stdout.write(attach.stdout);
|
|
2955
|
+
if (attach.stderr) process2.stderr.write(attach.stderr);
|
|
2956
|
+
if (attach.exitCode !== 0) {
|
|
2957
|
+
throw new Error(`aleph domain attach ${domain} failed with exit code ${attach.exitCode}`);
|
|
2958
|
+
}
|
|
2959
|
+
await appendGithubOutput("domain", domain, env);
|
|
2960
|
+
await appendGithubOutput("item_hash", itemHash, env);
|
|
2961
|
+
await appendGithubOutput("url", `https://${domain}`, env);
|
|
2962
|
+
await appendGithubSummary([
|
|
2963
|
+
"## Shared Site Runner",
|
|
2964
|
+
"",
|
|
2965
|
+
`- Linked domain: \`${domain}\``,
|
|
2966
|
+
`- Aleph item hash: \`${itemHash}\``,
|
|
2967
|
+
`- Catch-all path: \`${catchAllPath}\``
|
|
2968
|
+
], env);
|
|
2969
|
+
}
|
|
2939
2970
|
async function runProbeMode(env = process2.env) {
|
|
2940
2971
|
const addrs = mergedAddrs(env);
|
|
2941
2972
|
if (addrs.length === 0) throw new Error("No relay probe or browser bootstrap multiaddrs were supplied.");
|
|
@@ -2967,6 +2998,7 @@ async function runBootstrapEnvMode(env = process2.env) {
|
|
|
2967
2998
|
async function runSiteMode(env = process2.env) {
|
|
2968
2999
|
const mode = optionalEnv("ALEPH_VM_MODE", "site-publish", env);
|
|
2969
3000
|
if (mode === "site-publish") return await runSitePublishMode(env);
|
|
3001
|
+
if (mode === "site-domain-link") return await runDomainLinkMode(env);
|
|
2970
3002
|
if (mode === "relay-probe") return await runProbeMode(env);
|
|
2971
3003
|
if (mode === "bootstrap-env") return await runBootstrapEnvMode(env);
|
|
2972
3004
|
throw new Error(`Unsupported ALEPH_VM_MODE "${mode}" in shared site runner.`);
|
|
@@ -2988,11 +3020,13 @@ export {
|
|
|
2988
3020
|
main,
|
|
2989
3021
|
optionalEnv,
|
|
2990
3022
|
parseDeployPlan,
|
|
3023
|
+
parseLastJsonObject,
|
|
2991
3024
|
parseRootfsRunnerInputs,
|
|
2992
3025
|
requiredEnv,
|
|
2993
3026
|
rootfsMain,
|
|
2994
3027
|
runActionMode,
|
|
2995
3028
|
runBootstrapEnvMode,
|
|
3029
|
+
runDomainLinkMode,
|
|
2996
3030
|
runLocalCommand,
|
|
2997
3031
|
runProbeMode,
|
|
2998
3032
|
runRootfsMode,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@le-space/node",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
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.14",
|
|
20
|
+
"@le-space/shared-types": "0.1.14",
|
|
21
|
+
"@le-space/rootfs": "0.1.14",
|
|
22
22
|
"ethers": "^6.15.0"
|
|
23
23
|
}
|
|
24
24
|
}
|