@craftrpgs/cli 0.1.0 → 0.1.1
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/bin.js +49 -15
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -25409,15 +25409,39 @@ import { existsSync as existsSync3, readFileSync } from "node:fs";
|
|
|
25409
25409
|
import { dirname as dirname3, join as join4, resolve as resolve3 } from "node:path";
|
|
25410
25410
|
var CRAFT_ENV_FILE = ".craft-env";
|
|
25411
25411
|
var PUBLIC_ENVIRONMENTS = {
|
|
25412
|
-
production:
|
|
25412
|
+
production: {
|
|
25413
|
+
api: "https://api.craftrpgs.com",
|
|
25414
|
+
app: "https://www.craftrpgs.com"
|
|
25415
|
+
}
|
|
25413
25416
|
};
|
|
25414
25417
|
var DEV_ENVIRONMENTS = {
|
|
25415
|
-
local: "http://localhost:3002",
|
|
25416
|
-
staging:
|
|
25418
|
+
local: { api: "http://localhost:3002", app: "http://localhost:3000" },
|
|
25419
|
+
staging: {
|
|
25420
|
+
api: "https://alpha.craftrpgs.com",
|
|
25421
|
+
app: "https://alpha.craftrpgs.com"
|
|
25422
|
+
}
|
|
25423
|
+
};
|
|
25424
|
+
var LEGACY_ORIGIN_ALIASES = {
|
|
25425
|
+
"https://craftrpgs.com": "production",
|
|
25426
|
+
"https://www.craftrpgs.com": "production",
|
|
25427
|
+
"http://localhost:3000": "local"
|
|
25417
25428
|
};
|
|
25418
25429
|
function craftEnvironments() {
|
|
25419
25430
|
return process.env.CRAFT_DEV === "1" ? { ...PUBLIC_ENVIRONMENTS, ...DEV_ENVIRONMENTS } : { ...PUBLIC_ENVIRONMENTS };
|
|
25420
25431
|
}
|
|
25432
|
+
function canonicalApiOrigin(origin) {
|
|
25433
|
+
const aliasedName = LEGACY_ORIGIN_ALIASES[origin];
|
|
25434
|
+
const environment = aliasedName ? craftEnvironments()[aliasedName] : undefined;
|
|
25435
|
+
if (environment) {
|
|
25436
|
+
return environment.api;
|
|
25437
|
+
}
|
|
25438
|
+
for (const candidate of Object.values(craftEnvironments())) {
|
|
25439
|
+
if (candidate.app === origin || candidate.api === origin) {
|
|
25440
|
+
return candidate.api;
|
|
25441
|
+
}
|
|
25442
|
+
}
|
|
25443
|
+
return origin;
|
|
25444
|
+
}
|
|
25421
25445
|
var ENVIRONMENT_ALIASES = {
|
|
25422
25446
|
dev: "local",
|
|
25423
25447
|
localhost: "local",
|
|
@@ -25425,15 +25449,15 @@ var ENVIRONMENT_ALIASES = {
|
|
|
25425
25449
|
release: "staging",
|
|
25426
25450
|
prod: "production"
|
|
25427
25451
|
};
|
|
25428
|
-
var DEFAULT_REMOTE = PUBLIC_ENVIRONMENTS.production;
|
|
25452
|
+
var DEFAULT_REMOTE = PUBLIC_ENVIRONMENTS.production.api;
|
|
25429
25453
|
var HTTP_URL_PREFIX = /^https?:\/\//i;
|
|
25430
25454
|
function environmentNames() {
|
|
25431
25455
|
return Object.keys(craftEnvironments());
|
|
25432
25456
|
}
|
|
25433
25457
|
function environmentNameForRemote(remote) {
|
|
25434
25458
|
const origin = toOrigin(remote) ?? remote;
|
|
25435
|
-
for (const [name,
|
|
25436
|
-
if (
|
|
25459
|
+
for (const [name, urls] of Object.entries(craftEnvironments())) {
|
|
25460
|
+
if (urls.api === origin || urls.app === origin) {
|
|
25437
25461
|
return name;
|
|
25438
25462
|
}
|
|
25439
25463
|
}
|
|
@@ -25451,20 +25475,26 @@ function resolveRemoteInput(input) {
|
|
|
25451
25475
|
const canonical = ENVIRONMENT_ALIASES[key] ?? key;
|
|
25452
25476
|
const named = craftEnvironments()[canonical];
|
|
25453
25477
|
if (named) {
|
|
25454
|
-
return named;
|
|
25478
|
+
return named.api;
|
|
25455
25479
|
}
|
|
25456
25480
|
if (HTTP_URL_PREFIX.test(input.trim())) {
|
|
25457
25481
|
const origin = toOrigin(input.trim());
|
|
25458
25482
|
if (origin) {
|
|
25459
|
-
|
|
25460
|
-
|
|
25483
|
+
const apiOrigin = canonicalApiOrigin(origin);
|
|
25484
|
+
assertRemoteAllowsCleartext(apiOrigin);
|
|
25485
|
+
return apiOrigin;
|
|
25461
25486
|
}
|
|
25462
25487
|
}
|
|
25463
25488
|
throw new CliError(`Unknown environment "${input}". Use ${environmentNames().map((name) => `"${name}"`).join(", ")}, or a full origin URL (https://…).`, 2);
|
|
25464
25489
|
}
|
|
25465
25490
|
function appOriginForRemote(remote) {
|
|
25466
25491
|
const origin = toOrigin(remote) ?? remote;
|
|
25467
|
-
|
|
25492
|
+
for (const candidate of Object.values(craftEnvironments())) {
|
|
25493
|
+
if (candidate.api === origin || candidate.app === origin) {
|
|
25494
|
+
return candidate.app;
|
|
25495
|
+
}
|
|
25496
|
+
}
|
|
25497
|
+
return origin;
|
|
25468
25498
|
}
|
|
25469
25499
|
var LOOPBACK_HOSTS = new Set(["localhost", "127.0.0.1", "[::1]", "::1"]);
|
|
25470
25500
|
function assertRemoteAllowsCleartext(origin) {
|
|
@@ -25534,7 +25564,10 @@ function resolveRemote({
|
|
|
25534
25564
|
};
|
|
25535
25565
|
}
|
|
25536
25566
|
if (context) {
|
|
25537
|
-
return {
|
|
25567
|
+
return {
|
|
25568
|
+
remote: canonicalApiOrigin(context.remote),
|
|
25569
|
+
source: context.source
|
|
25570
|
+
};
|
|
25538
25571
|
}
|
|
25539
25572
|
const envFile = findEnvFile(cwd);
|
|
25540
25573
|
if (envFile) {
|
|
@@ -25581,7 +25614,7 @@ function describeRemoteSource(resolved) {
|
|
|
25581
25614
|
// package.json
|
|
25582
25615
|
var package_default = {
|
|
25583
25616
|
name: "@craftrpgs/cli",
|
|
25584
|
-
version: "0.1.
|
|
25617
|
+
version: "0.1.1",
|
|
25585
25618
|
description: "Sync Craft projects with a local folder — clone, edit with any coding agent, push back.",
|
|
25586
25619
|
license: "UNLICENSED",
|
|
25587
25620
|
homepage: "https://craftrpgs.com",
|
|
@@ -31180,7 +31213,7 @@ Options available on every command:
|
|
|
31180
31213
|
|
|
31181
31214
|
craft --version prints the CLI version.
|
|
31182
31215
|
|
|
31183
|
-
Environments: the CLI talks to production (craftrpgs.com) by default. Pin a
|
|
31216
|
+
Environments: the CLI talks to production (api.craftrpgs.com) by default. Pin a
|
|
31184
31217
|
directory tree to another environment with \`craft env local\` (or staging, or
|
|
31185
31218
|
a full origin URL) \u2014 it writes a one-line .craft-env file. --remote and
|
|
31186
31219
|
CRAFT_REMOTE accept the same names/URLs and override it. Commands inside a
|
|
@@ -31209,8 +31242,9 @@ directory pinning it (and everything beneath it) to that environment.
|
|
|
31209
31242
|
--clear removes this directory's .craft-env.
|
|
31210
31243
|
|
|
31211
31244
|
Environments: local (http://localhost:3002), staging
|
|
31212
|
-
(https://alpha.craftrpgs.com), production (https://craftrpgs.com \u2014 the
|
|
31213
|
-
default when nothing is configured
|
|
31245
|
+
(https://alpha.craftrpgs.com), production (https://api.craftrpgs.com \u2014 the
|
|
31246
|
+
default when nothing is configured; pasted craftrpgs.com project URLs
|
|
31247
|
+
normalize to it). Precedence: --remote > CRAFT_REMOTE >
|
|
31214
31248
|
the enclosing workspace's pinned remote > nearest .craft-env > production.
|
|
31215
31249
|
A cloned workspace always syncs with the server it was cloned from.
|
|
31216
31250
|
`,
|
package/package.json
CHANGED