@hyphacommerce/cli 0.1.0-beta.4 → 0.1.0-beta.5
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/main.mjs +31 -49
- package/package.json +2 -2
- package/templates/hypha.config.schema.json +35 -0
- package/templates/vps/compose.yaml +2 -0
package/dist/main.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import { basename, join, relative, resolve, sep } from "node:path";
|
|
|
12
12
|
import { existsSync, readdirSync } from "node:fs";
|
|
13
13
|
import { spawn } from "node:child_process";
|
|
14
14
|
import { tmpdir } from "node:os";
|
|
15
|
-
|
|
15
|
+
// src/api.ts
|
|
16
16
|
var ApiError = class extends Error {
|
|
17
17
|
status;
|
|
18
18
|
code;
|
|
@@ -197,8 +197,7 @@ async function getJson(d, target) {
|
|
|
197
197
|
req.end();
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
|
-
|
|
201
|
-
//#region src/templates.ts
|
|
200
|
+
// src/templates.ts
|
|
202
201
|
const TEMPLATES = join(import.meta.dirname, "..", "templates");
|
|
203
202
|
/** Where a checkout of Hypha would be around this CLI: the repository when it runs from
|
|
204
203
|
* one (`pnpm hypha …`, or the package built in it), `node_modules` when installed. */
|
|
@@ -371,8 +370,7 @@ function newCloudflareEnv(owner, databaseUrl, options) {
|
|
|
371
370
|
if (options.storefront) env.comment("").comment("The storefront's publishable key and webhook secret: `hypha deploy` creates them.").set("STOREFRONT_KEY", "").set("HYPHA_WEBHOOK_SECRET", "");
|
|
372
371
|
return env;
|
|
373
372
|
}
|
|
374
|
-
|
|
375
|
-
//#region src/spores.ts
|
|
373
|
+
// src/spores.ts
|
|
376
374
|
/** Hypha's repository, as spores outside it name it in their git dependencies. */
|
|
377
375
|
const HYPHA_GIT = "https://github.com/hyphacommerce/hypha";
|
|
378
376
|
/** The first-party spores, by name: each in its own repository. */
|
|
@@ -619,8 +617,7 @@ async function writeCrate(dir, files) {
|
|
|
619
617
|
await writeFile(join(dir, "Cargo.lock"), checkout);
|
|
620
618
|
await writeFile(seed, hash);
|
|
621
619
|
}
|
|
622
|
-
|
|
623
|
-
//#region src/deployment.ts
|
|
620
|
+
// src/deployment.ts
|
|
624
621
|
const STATE_FILE = "hypha.json";
|
|
625
622
|
const ENV_FILE = ".env";
|
|
626
623
|
function apps$1(d) {
|
|
@@ -716,8 +713,7 @@ async function saveEnv(dir, env) {
|
|
|
716
713
|
await writeFile(path, env.toString(), { mode: 384 });
|
|
717
714
|
await chmod(path, 384);
|
|
718
715
|
}
|
|
719
|
-
|
|
720
|
-
//#region src/shell.ts
|
|
716
|
+
// src/shell.ts
|
|
721
717
|
var CommandFailed = class extends Error {
|
|
722
718
|
command;
|
|
723
719
|
code;
|
|
@@ -873,8 +869,7 @@ function here(dir) {
|
|
|
873
869
|
async upload() {}
|
|
874
870
|
};
|
|
875
871
|
}
|
|
876
|
-
|
|
877
|
-
//#region src/apps.ts
|
|
872
|
+
// src/apps.ts
|
|
878
873
|
/** The first-party apps, by name. */
|
|
879
874
|
const FIRST_PARTY = {
|
|
880
875
|
stripe: "git@github.com:hyphacommerce/app-stripe.git",
|
|
@@ -1166,8 +1161,7 @@ async function checkout(dir, a, runner = runHere) {
|
|
|
1166
1161
|
});
|
|
1167
1162
|
return clone;
|
|
1168
1163
|
}
|
|
1169
|
-
|
|
1170
|
-
//#region src/app-install.ts
|
|
1164
|
+
// src/app-install.ts
|
|
1171
1165
|
/** The link that starts installing `entry` into this deployment's store. */
|
|
1172
1166
|
function installLink(d, entry) {
|
|
1173
1167
|
return `${appUrl(d, entry)}/install?api=${encodeURIComponent(url(d, d.domains.api))}`;
|
|
@@ -1225,8 +1219,7 @@ async function staffFor(d, env) {
|
|
|
1225
1219
|
if (!email || !password) return void 0;
|
|
1226
1220
|
return Staff.login(d, email, password).catch(() => void 0);
|
|
1227
1221
|
}
|
|
1228
|
-
|
|
1229
|
-
//#region src/commands/shared.ts
|
|
1222
|
+
// src/commands/shared.ts
|
|
1230
1223
|
const dirArg = {
|
|
1231
1224
|
type: "string",
|
|
1232
1225
|
default: "hypha-deploy",
|
|
@@ -1276,8 +1269,7 @@ async function guarded(work) {
|
|
|
1276
1269
|
process.exit(1);
|
|
1277
1270
|
}
|
|
1278
1271
|
}
|
|
1279
|
-
|
|
1280
|
-
//#region src/cloudflare-token.ts
|
|
1272
|
+
// src/cloudflare-token.ts
|
|
1281
1273
|
/** Why an R2 key pair can't be R2's S3 credentials, if it can't: R2 shows a token's
|
|
1282
1274
|
* Access Key ID (32 hex characters) and Secret Access Key (64) apart from the token's
|
|
1283
1275
|
* value (`cfat_…`), which is what wrangler-style tools take, not the S3 API. */
|
|
@@ -1434,8 +1426,7 @@ async function checkToken(token, domain, options, get = fetch) {
|
|
|
1434
1426
|
r2
|
|
1435
1427
|
};
|
|
1436
1428
|
}
|
|
1437
|
-
|
|
1438
|
-
//#region src/commands/token.ts
|
|
1429
|
+
// src/commands/token.ts
|
|
1439
1430
|
async function obtainToken(o) {
|
|
1440
1431
|
if (!o.given && !o.known) {
|
|
1441
1432
|
const link = templateUrl(`Hypha ${o.name}`);
|
|
@@ -1482,8 +1473,7 @@ function openInBrowser(link) {
|
|
|
1482
1473
|
const [program, ...args] = process.platform === "darwin" ? ["open"] : process.platform === "win32" ? ["rundll32", "url.dll,FileProtocolHandler"] : ["xdg-open"];
|
|
1483
1474
|
run(program, [...args, link], { capture: true }).catch(() => {});
|
|
1484
1475
|
}
|
|
1485
|
-
|
|
1486
|
-
//#region src/commands/apps.ts
|
|
1476
|
+
// src/commands/apps.ts
|
|
1487
1477
|
/** `rev` as a commit: a full commit ID as given, else a branch or tag asked of the remote. */
|
|
1488
1478
|
async function resolveRev(git, rev) {
|
|
1489
1479
|
if (rev && /^[0-9a-f]{40}$/.test(rev)) return rev;
|
|
@@ -1716,11 +1706,9 @@ const apps = defineCommand({
|
|
|
1716
1706
|
})
|
|
1717
1707
|
}
|
|
1718
1708
|
});
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
//#endregion
|
|
1723
|
-
//#region src/create.ts
|
|
1709
|
+
// src/version.ts
|
|
1710
|
+
const VERSION = "0.1.0-beta.5";
|
|
1711
|
+
// src/create.ts
|
|
1724
1712
|
/** The repository the starters are downloaded from. */
|
|
1725
1713
|
const REPOSITORY = "hyphacommerce/hypha";
|
|
1726
1714
|
const STARTERS = {
|
|
@@ -1914,8 +1902,7 @@ const ROOT_ENGINES = { node: ">=24" };
|
|
|
1914
1902
|
async function exists$1(path) {
|
|
1915
1903
|
return stat(path).then(() => true, () => false);
|
|
1916
1904
|
}
|
|
1917
|
-
|
|
1918
|
-
//#region src/commands/create.ts
|
|
1905
|
+
// src/commands/create.ts
|
|
1919
1906
|
const createCommand = defineCommand({
|
|
1920
1907
|
meta: {
|
|
1921
1908
|
name: "create",
|
|
@@ -1965,8 +1952,7 @@ const createCommand = defineCommand({
|
|
|
1965
1952
|
p.outro(`${STARTERS[starter].title}.`);
|
|
1966
1953
|
})
|
|
1967
1954
|
});
|
|
1968
|
-
|
|
1969
|
-
//#region src/storefront.ts
|
|
1955
|
+
// src/storefront.ts
|
|
1970
1956
|
/** The events that change what a static page shows. */
|
|
1971
1957
|
const EVENTS = [
|
|
1972
1958
|
"product.*",
|
|
@@ -1981,7 +1967,10 @@ const EVENTS = [
|
|
|
1981
1967
|
"discount.updated",
|
|
1982
1968
|
"discount.deleted",
|
|
1983
1969
|
"discount.started",
|
|
1984
|
-
"discount.ended"
|
|
1970
|
+
"discount.ended",
|
|
1971
|
+
"translation.updated",
|
|
1972
|
+
"translation.deleted",
|
|
1973
|
+
"store.updated"
|
|
1985
1974
|
];
|
|
1986
1975
|
/**
|
|
1987
1976
|
* The storefront's order link for emails (`order_url`): `app/order/[id]/route.ts` keeps
|
|
@@ -2048,8 +2037,7 @@ async function connectStorefront(d, staff) {
|
|
|
2048
2037
|
orderUrl: linked
|
|
2049
2038
|
};
|
|
2050
2039
|
}
|
|
2051
|
-
|
|
2052
|
-
//#region src/cloudflare.ts
|
|
2040
|
+
// src/cloudflare.ts
|
|
2053
2041
|
/** The generated configuration, next to `hypha.json`. */
|
|
2054
2042
|
const WRANGLER_FILE = "wrangler.toml";
|
|
2055
2043
|
const SECRETS_FILE = ".secrets.json";
|
|
@@ -2499,7 +2487,8 @@ async function deployCloudflare(dir, d, env, tools) {
|
|
|
2499
2487
|
HYPHA_CF_WORKER: appWorker(d, app),
|
|
2500
2488
|
HYPHA_CF_DOMAIN: domain,
|
|
2501
2489
|
HYPHA_CF_API_WORKER: workerName(d),
|
|
2502
|
-
...app === "storefront" ? { HYPHA_CF_CACHE_KV: cf.cacheKvId } : {}
|
|
2490
|
+
...app === "storefront" ? { HYPHA_CF_CACHE_KV: cf.cacheKvId } : {},
|
|
2491
|
+
...app === "storefront" && env.get("STOREFRONT_NOINDEX") ? { STOREFRONT_NOINDEX: env.get("STOREFRONT_NOINDEX") } : {}
|
|
2503
2492
|
};
|
|
2504
2493
|
const appSecrets = {
|
|
2505
2494
|
HYPHA_API_URL: url(d, d.domains.api),
|
|
@@ -2637,7 +2626,7 @@ function hereTools(dir, d, env) {
|
|
|
2637
2626
|
}),
|
|
2638
2627
|
async checkToolchain() {
|
|
2639
2628
|
await run("worker-build", ["--version"], { capture: true }).catch(() => {
|
|
2640
|
-
throw new Error("worker-build is missing: `cargo install worker-build`");
|
|
2629
|
+
throw new Error("worker-build is missing: `cargo install worker-build@0.8.7`");
|
|
2641
2630
|
});
|
|
2642
2631
|
if (!(await run("rustup", [
|
|
2643
2632
|
"target",
|
|
@@ -2688,8 +2677,7 @@ function hereTools(dir, d, env) {
|
|
|
2688
2677
|
}
|
|
2689
2678
|
};
|
|
2690
2679
|
}
|
|
2691
|
-
|
|
2692
|
-
//#region src/images.ts
|
|
2680
|
+
// src/images.ts
|
|
2693
2681
|
/** Where the release workflow publishes the images. */
|
|
2694
2682
|
const REGISTRY = "ghcr.io/hyphacommerce";
|
|
2695
2683
|
/** `.env`'s image references, read by `compose.yaml`; without them it runs the
|
|
@@ -2786,8 +2774,7 @@ async function build(d, machine, image) {
|
|
|
2786
2774
|
]]);
|
|
2787
2775
|
}
|
|
2788
2776
|
}
|
|
2789
|
-
|
|
2790
|
-
//#region src/commands/deploy.ts
|
|
2777
|
+
// src/commands/deploy.ts
|
|
2791
2778
|
/** What the server runs: copied on every deploy. */
|
|
2792
2779
|
const FILES = [
|
|
2793
2780
|
ENV_FILE,
|
|
@@ -3047,8 +3034,7 @@ async function addresses(host) {
|
|
|
3047
3034
|
const [v4, v6] = await Promise.all([resolve4(host).catch(() => []), resolve6(host).catch(() => [])]);
|
|
3048
3035
|
return [...v4, ...v6];
|
|
3049
3036
|
}
|
|
3050
|
-
|
|
3051
|
-
//#region src/commands/init.ts
|
|
3037
|
+
// src/commands/init.ts
|
|
3052
3038
|
/** What `--force` keeps from the deployment's `.env`. */
|
|
3053
3039
|
const KEPT = [
|
|
3054
3040
|
"POSTGRES_PASSWORD",
|
|
@@ -3540,7 +3526,7 @@ async function initCloudflare(dir, args) {
|
|
|
3540
3526
|
`Database ${new URL(databaseUrl).host}`,
|
|
3541
3527
|
...appLines(d)
|
|
3542
3528
|
].join("\n"), `Written to ${dir}`);
|
|
3543
|
-
p.log.step("hypha deploy needs Rust with `rustup target add wasm32-unknown-unknown` and `cargo install worker-build`.");
|
|
3529
|
+
p.log.step("hypha deploy needs Rust with `rustup target add wasm32-unknown-unknown` and `cargo install worker-build@0.8.7`.");
|
|
3544
3530
|
p.outro(`Next: hypha deploy${args.dir === "hypha-deploy" ? "" : ` --dir ${args.dir}`}`);
|
|
3545
3531
|
}
|
|
3546
3532
|
/** Every value answered or flagged, else an error naming the flag. */
|
|
@@ -3732,8 +3718,7 @@ async function askApps(args, d, earlier) {
|
|
|
3732
3718
|
}
|
|
3733
3719
|
return out;
|
|
3734
3720
|
}
|
|
3735
|
-
|
|
3736
|
-
//#region src/commands/ops.ts
|
|
3721
|
+
// src/commands/ops.ts
|
|
3737
3722
|
const status = defineCommand({
|
|
3738
3723
|
meta: {
|
|
3739
3724
|
name: "status",
|
|
@@ -3824,8 +3809,7 @@ function cloudflareWorker(d, service) {
|
|
|
3824
3809
|
if (app) return appWorkerName(d, app);
|
|
3825
3810
|
throw new Error(`on Cloudflare, logs are per Worker: api, admin, storefront${(d.apps ?? []).map((a) => `, ${a.name}`).join("")} (not ${service})`);
|
|
3826
3811
|
}
|
|
3827
|
-
|
|
3828
|
-
//#region src/commands/spores.ts
|
|
3812
|
+
// src/commands/spores.ts
|
|
3829
3813
|
/** What `list` shows for a spore. */
|
|
3830
3814
|
function describeSpore(entry) {
|
|
3831
3815
|
const source = entry.git ? `${entry.git} @ ${entry.rev?.slice(0, 12) ?? "unpinned"}` : entry.version ? `crates.io ${entry.version}` : `path ${entry.path}`;
|
|
@@ -3937,8 +3921,7 @@ const spores = defineCommand({
|
|
|
3937
3921
|
})
|
|
3938
3922
|
}
|
|
3939
3923
|
});
|
|
3940
|
-
|
|
3941
|
-
//#region src/main.ts
|
|
3924
|
+
// src/main.ts
|
|
3942
3925
|
const main = defineCommand({
|
|
3943
3926
|
meta: {
|
|
3944
3927
|
name: "hypha",
|
|
@@ -3956,5 +3939,4 @@ const main = defineCommand({
|
|
|
3956
3939
|
}
|
|
3957
3940
|
});
|
|
3958
3941
|
await runMain(main);
|
|
3959
|
-
//#endregion
|
|
3960
3942
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyphacommerce/cli",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.5",
|
|
4
4
|
"description": "Hosting Hypha: `hypha init` writes a deployment, `hypha deploy` runs it on a server or on Cloudflare Workers, with the apps `hypha apps` lists beside it.",
|
|
5
5
|
"homepage": "https://hyphacommerce.com",
|
|
6
6
|
"bugs": "https://github.com/hyphacommerce/hypha/issues",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"citty": "0.2.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/node": "26.6.
|
|
32
|
+
"@types/node": "26.6.6",
|
|
33
33
|
"typescript": "5.9.3"
|
|
34
34
|
},
|
|
35
35
|
"engines": {
|
|
@@ -108,6 +108,11 @@
|
|
|
108
108
|
"2h",
|
|
109
109
|
"6h"
|
|
110
110
|
]
|
|
111
|
+
},
|
|
112
|
+
"translation_sources": {
|
|
113
|
+
"batch": 100,
|
|
114
|
+
"enabled": true,
|
|
115
|
+
"interval": "1m"
|
|
111
116
|
}
|
|
112
117
|
}
|
|
113
118
|
},
|
|
@@ -603,6 +608,14 @@
|
|
|
603
608
|
"6h"
|
|
604
609
|
]
|
|
605
610
|
}
|
|
611
|
+
},
|
|
612
|
+
"translation_sources": {
|
|
613
|
+
"$ref": "#/$defs/TranslationSourcesJob",
|
|
614
|
+
"default": {
|
|
615
|
+
"batch": 100,
|
|
616
|
+
"enabled": true,
|
|
617
|
+
"interval": "1m"
|
|
618
|
+
}
|
|
606
619
|
}
|
|
607
620
|
},
|
|
608
621
|
"additionalProperties": false
|
|
@@ -1122,6 +1135,28 @@
|
|
|
1122
1135
|
}
|
|
1123
1136
|
]
|
|
1124
1137
|
},
|
|
1138
|
+
"TranslationSourcesJob": {
|
|
1139
|
+
"description": "Keeping the translation worklist's sources up to date for the resources queued as a\nwhole: every resource there was when it was first set up, and every product or\ncategory when a custom field definition's access changes. Single changes follow by\nevent, without it. A Workers host runs it on the minute's ticks that have work.",
|
|
1140
|
+
"type": "object",
|
|
1141
|
+
"properties": {
|
|
1142
|
+
"batch": {
|
|
1143
|
+
"description": "Resources read again per step (1 to 1,000).",
|
|
1144
|
+
"type": "integer",
|
|
1145
|
+
"format": "uint32",
|
|
1146
|
+
"default": 100,
|
|
1147
|
+
"minimum": 0
|
|
1148
|
+
},
|
|
1149
|
+
"enabled": {
|
|
1150
|
+
"type": "boolean",
|
|
1151
|
+
"default": true
|
|
1152
|
+
},
|
|
1153
|
+
"interval": {
|
|
1154
|
+
"$ref": "#/$defs/Duration",
|
|
1155
|
+
"default": "1m"
|
|
1156
|
+
}
|
|
1157
|
+
},
|
|
1158
|
+
"additionalProperties": false
|
|
1159
|
+
},
|
|
1125
1160
|
"Webhooks": {
|
|
1126
1161
|
"description": "When failed deliveries (webhooks and in-process handlers) are tried again.",
|
|
1127
1162
|
"type": "object",
|
|
@@ -107,6 +107,8 @@ services:
|
|
|
107
107
|
HYPHA_WEBHOOK_SECRET: ${HYPHA_WEBHOOK_SECRET:-}
|
|
108
108
|
STOREFRONT_ROUTING: ${STOREFRONT_ROUTING:-folders}
|
|
109
109
|
STOREFRONT_URL: ${STOREFRONT_URL:-}
|
|
110
|
+
# `1` keeps a demo or staging store out of search engines.
|
|
111
|
+
STOREFRONT_NOINDEX: ${STOREFRONT_NOINDEX:-}
|
|
110
112
|
# As the admin's: the shopper's address from Caddy, for the API's per-address
|
|
111
113
|
# cart limit.
|
|
112
114
|
STOREFRONT_TRUST_X_FORWARDED_FOR: "true"
|