@quatronic/qore 0.4.0-rc.1 → 0.4.0
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 +13 -0
- package/dist/cli.js +103 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -141,6 +141,19 @@ qore env pull
|
|
|
141
141
|
directory, then renamed over the target — it's never truncated in place.
|
|
142
142
|
(On Windows, POSIX file modes don't apply — setting `0600` there is a
|
|
143
143
|
no-op; there's no equivalent file-permission hardening on that platform.)
|
|
144
|
+
- When the repository has a `mobile/` directory (an Expo app), the pull also
|
|
145
|
+
writes `mobile/.env.local` with the app's **public** staging config:
|
|
146
|
+
`EXPO_PUBLIC_SERVER_URL`, `EXPO_PUBLIC_SENTRY_DSN` and
|
|
147
|
+
`EXPO_PUBLIC_QORE_ENV=staging`. qore owns those three keys and overwrites
|
|
148
|
+
them; every other line in the file is kept. A value the portal does not have
|
|
149
|
+
yet is left out rather than written empty, because an empty `EXPO_PUBLIC_*`
|
|
150
|
+
value would override the one baked into `app.config.ts`. Until staging is
|
|
151
|
+
deployed there is no server URL; the pull says so, and running it again
|
|
152
|
+
after the deploy fills it in. A portal too old to serve this config is
|
|
153
|
+
skipped with a note, and a failed fetch warns without failing the pull.
|
|
154
|
+
`--json` reports it as
|
|
155
|
+
`mobile: { target, environment, serverUrl, sentryDsn: <set?>, written }`
|
|
156
|
+
(`null` without a `mobile/` directory). `qore dev` does not write this file.
|
|
144
157
|
|
|
145
158
|
**First use of a repository** requires confirmation — see "Trust on first
|
|
146
159
|
use" below. **Values are never printed**: not in `qore env pull`'s output,
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="61c8b355-f1e5-5a19-8b8d-2f4dc57679da")}catch(e){}}();
|
|
4
4
|
import { createRequire as __qoreCreateRequire } from "node:module"; const require = __qoreCreateRequire(import.meta.url);
|
|
5
5
|
import {
|
|
6
6
|
addSecretValues,
|
|
@@ -7291,8 +7291,50 @@ function registerDoctor(program, ctx) {
|
|
|
7291
7291
|
|
|
7292
7292
|
// src/cli/commands/env.ts
|
|
7293
7293
|
import { randomBytes as randomBytes9 } from "crypto";
|
|
7294
|
-
import { chmod as
|
|
7295
|
-
import { dirname as dirname11, join as
|
|
7294
|
+
import { chmod as chmod4, realpath as realpath13 } from "fs/promises";
|
|
7295
|
+
import { dirname as dirname11, join as join30, relative as relative10 } from "path";
|
|
7296
|
+
|
|
7297
|
+
// src/core/env/mobile.ts
|
|
7298
|
+
import { chmod as chmod3, stat as stat7 } from "fs/promises";
|
|
7299
|
+
import { join as join29 } from "path";
|
|
7300
|
+
var MOBILE_ENV_FILE = "mobile/.env.local";
|
|
7301
|
+
var MOBILE_KEYS = ["EXPO_PUBLIC_SERVER_URL", "EXPO_PUBLIC_SENTRY_DSN", "EXPO_PUBLIC_QORE_ENV"];
|
|
7302
|
+
async function hasMobileApp(repoRoot) {
|
|
7303
|
+
try {
|
|
7304
|
+
return (await stat7(join29(repoRoot, "mobile"))).isDirectory();
|
|
7305
|
+
} catch {
|
|
7306
|
+
return false;
|
|
7307
|
+
}
|
|
7308
|
+
}
|
|
7309
|
+
async function fetchMobileConfig(deps2, mc, app) {
|
|
7310
|
+
if (!await hasCapability(deps2, mc.portal.apiOrigin, "module.mobile-config")) return null;
|
|
7311
|
+
return mc.session.api.get(
|
|
7312
|
+
`/api/cli/v1/modules/${encodeURIComponent(mc.module.id)}/mobile-config?app_id=${encodeURIComponent(app.id)}`
|
|
7313
|
+
);
|
|
7314
|
+
}
|
|
7315
|
+
function mobileEnvValues(config) {
|
|
7316
|
+
const values = {};
|
|
7317
|
+
if (config.serverUrl) values.EXPO_PUBLIC_SERVER_URL = config.serverUrl;
|
|
7318
|
+
if (config.sentryDsn) values.EXPO_PUBLIC_SENTRY_DSN = config.sentryDsn;
|
|
7319
|
+
values.EXPO_PUBLIC_QORE_ENV = config.environment;
|
|
7320
|
+
return values;
|
|
7321
|
+
}
|
|
7322
|
+
function planMobileEnv(existing, config) {
|
|
7323
|
+
const original = existing ?? "";
|
|
7324
|
+
const { merged } = planEnvUpdate({ current: parseEnv(original), fetched: mobileEnvValues(config), managed: [...MOBILE_KEYS] });
|
|
7325
|
+
const text2 = renderEnv(original, merged);
|
|
7326
|
+
return { text: text2, changed: existing === null || text2 !== existing };
|
|
7327
|
+
}
|
|
7328
|
+
async function writeMobileEnv(repoRoot, config) {
|
|
7329
|
+
const target = await resolveTarget(repoRoot, MOBILE_ENV_FILE);
|
|
7330
|
+
const existing = await readOrNull(target);
|
|
7331
|
+
const plan = planMobileEnv(existing, config);
|
|
7332
|
+
if (plan.changed) await writeSecurely(target, plan.text);
|
|
7333
|
+
else await chmod3(target, 384);
|
|
7334
|
+
return { target, written: plan.changed };
|
|
7335
|
+
}
|
|
7336
|
+
|
|
7337
|
+
// src/cli/commands/env.ts
|
|
7296
7338
|
var maskLen = (v) => v === void 0 ? "(unset)" : `\u2022\u2022\u2022\u2022 (${v.length} chars)`;
|
|
7297
7339
|
function registerEnv(program, ctx) {
|
|
7298
7340
|
const env = program.command("env").description("Local environment");
|
|
@@ -7311,7 +7353,7 @@ function registerEnv(program, ctx) {
|
|
|
7311
7353
|
const target = f.target ? await resolveTarget(mc.repoRoot, f.target, deps2.cwd) : await resolveTarget(mc.repoRoot, cfg.envFile ?? defaults.envFile);
|
|
7312
7354
|
await ensureTrusted(c, mc, app, { yes: f.yes });
|
|
7313
7355
|
const existing = await readOrNull(target);
|
|
7314
|
-
const example = existing === null ? await readOrNull(
|
|
7356
|
+
const example = existing === null ? await readOrNull(join30(dirname11(target), ".env.example")) : null;
|
|
7315
7357
|
const local = await fetchLocalEnv(deps2, mc, app);
|
|
7316
7358
|
const inputs = {
|
|
7317
7359
|
existing,
|
|
@@ -7348,11 +7390,12 @@ function registerEnv(program, ctx) {
|
|
|
7348
7390
|
plan = planPull({ ...inputs, choices });
|
|
7349
7391
|
}
|
|
7350
7392
|
if (existing !== null && plan.text === existing) {
|
|
7351
|
-
await
|
|
7393
|
+
await chmod4(target, 384);
|
|
7352
7394
|
} else {
|
|
7353
7395
|
await writeSecurely(target, plan.text);
|
|
7354
7396
|
}
|
|
7355
7397
|
const rel = relative10(await realpath13(mc.repoRoot), target);
|
|
7398
|
+
const mobile = await pullMobile(c, mc, app);
|
|
7356
7399
|
if (g.json) {
|
|
7357
7400
|
const names = {
|
|
7358
7401
|
created: plan.created,
|
|
@@ -7364,7 +7407,7 @@ function registerEnv(program, ctx) {
|
|
|
7364
7407
|
unchanged: plan.unchanged,
|
|
7365
7408
|
generated: plan.generated
|
|
7366
7409
|
};
|
|
7367
|
-
renderJson(io2, { context: contextJson(mc, app), target: rel, ...names });
|
|
7410
|
+
renderJson(io2, { context: contextJson(mc, app), target: rel, ...names, mobile: mobile && mobileJson(mobile) });
|
|
7368
7411
|
return;
|
|
7369
7412
|
}
|
|
7370
7413
|
if (await isGitIgnored(deps2.git, mc.repoRoot, target) === false) io2.err(`! ${notIgnoredWarning(rel)}`);
|
|
@@ -7379,8 +7422,48 @@ function registerEnv(program, ctx) {
|
|
|
7379
7422
|
plan.generated.length && `${plan.generated.length} generated`
|
|
7380
7423
|
].filter(Boolean);
|
|
7381
7424
|
io2.out(`\u2713 ${rel}${plan.seededFromExample ? " (created from .env.example)" : ""} \u2014 ${parts.length ? parts.join(", ") : "up to date"}`);
|
|
7425
|
+
if (mobile) await reportMobile(c, mc.repoRoot, mobile);
|
|
7382
7426
|
});
|
|
7383
7427
|
}
|
|
7428
|
+
async function pullMobile(c, mc, app) {
|
|
7429
|
+
if (!mc.repoRoot || !await hasMobileApp(mc.repoRoot)) return null;
|
|
7430
|
+
try {
|
|
7431
|
+
const config = await fetchMobileConfig(c.deps, mc, app);
|
|
7432
|
+
if (!config) return { kind: "unsupported" };
|
|
7433
|
+
return { kind: "written", config, ...await writeMobileEnv(mc.repoRoot, config) };
|
|
7434
|
+
} catch (e) {
|
|
7435
|
+
if (e instanceof QoreError) return { kind: "failed", error: e };
|
|
7436
|
+
throw e;
|
|
7437
|
+
}
|
|
7438
|
+
}
|
|
7439
|
+
function mobileJson(m) {
|
|
7440
|
+
if (m.kind === "unsupported") return { target: MOBILE_ENV_FILE, skipped: "unsupported-portal" };
|
|
7441
|
+
if (m.kind === "failed") return { target: MOBILE_ENV_FILE, error: { code: m.error.code, message: m.error.message } };
|
|
7442
|
+
return {
|
|
7443
|
+
target: MOBILE_ENV_FILE,
|
|
7444
|
+
environment: m.config.environment,
|
|
7445
|
+
serverUrl: m.config.serverUrl,
|
|
7446
|
+
sentryDsn: m.config.sentryDsn !== null,
|
|
7447
|
+
written: m.written
|
|
7448
|
+
};
|
|
7449
|
+
}
|
|
7450
|
+
async function reportMobile(c, repoRoot, m) {
|
|
7451
|
+
const { io: io2, deps: deps2 } = c;
|
|
7452
|
+
if (m.kind === "unsupported") {
|
|
7453
|
+
io2.err(`! ${MOBILE_ENV_FILE}: skipped \u2014 this portal cannot serve the mobile app's config yet`);
|
|
7454
|
+
return;
|
|
7455
|
+
}
|
|
7456
|
+
if (m.kind === "failed") {
|
|
7457
|
+
io2.err(`! ${MOBILE_ENV_FILE}: not updated \u2014 ${m.error.message}`);
|
|
7458
|
+
return;
|
|
7459
|
+
}
|
|
7460
|
+
if (await isGitIgnored(deps2.git, repoRoot, m.target) === false) io2.err(`! ${notIgnoredWarning(MOBILE_ENV_FILE)}`);
|
|
7461
|
+
if (m.config.serverUrl === null) {
|
|
7462
|
+
io2.err(`! ${MOBILE_ENV_FILE}: ${m.config.environment} has no server URL yet \u2014 deploy ${m.config.environment}, then run qore env pull again`);
|
|
7463
|
+
}
|
|
7464
|
+
const server = m.config.serverUrl ? `server ${m.config.serverUrl}` : "no server URL";
|
|
7465
|
+
io2.out(`\u2713 ${MOBILE_ENV_FILE} \u2014 ${server} (${m.config.environment})${m.written ? "" : ", up to date"}`);
|
|
7466
|
+
}
|
|
7384
7467
|
|
|
7385
7468
|
// src/core/observability/compose.ts
|
|
7386
7469
|
function pageWarnings(...pages) {
|
|
@@ -8317,7 +8400,7 @@ function registerPortal(program, ctx) {
|
|
|
8317
8400
|
}
|
|
8318
8401
|
|
|
8319
8402
|
// src/core/roles/read.ts
|
|
8320
|
-
import { join as
|
|
8403
|
+
import { join as join31 } from "path";
|
|
8321
8404
|
|
|
8322
8405
|
// src/core/roles/extract.ts
|
|
8323
8406
|
var KNOWN = { user: "User", admin: "App admin" };
|
|
@@ -8352,7 +8435,7 @@ var SLUG = /^[a-z0-9][a-z0-9_-]*$/;
|
|
|
8352
8435
|
var MAX_SLUG = 64;
|
|
8353
8436
|
var MAX_ROLES = 100;
|
|
8354
8437
|
async function readCodeRoles(repoRoot) {
|
|
8355
|
-
const source = await readOrNull(
|
|
8438
|
+
const source = await readOrNull(join31(repoRoot, PERMISSIONS_FILE));
|
|
8356
8439
|
if (source === null) {
|
|
8357
8440
|
throw new QoreError("QORE_CONTEXT_UNSUPPORTED", `No ${PERMISSIONS_FILE} in this module`, {
|
|
8358
8441
|
hint: "App roles live in the app's frontend module; run this there."
|
|
@@ -8544,7 +8627,7 @@ function registerStatus(program, ctx) {
|
|
|
8544
8627
|
|
|
8545
8628
|
// src/cli/commands/sync.ts
|
|
8546
8629
|
import { realpath as realpath15 } from "fs/promises";
|
|
8547
|
-
import { basename as basename9, join as
|
|
8630
|
+
import { basename as basename9, join as join32, relative as relative11 } from "path";
|
|
8548
8631
|
import { Option as Option3 } from "commander";
|
|
8549
8632
|
function asFailure2(slug, e) {
|
|
8550
8633
|
if (e instanceof QoreError && e.code !== "QORE_GIT_UNAVAILABLE") {
|
|
@@ -8564,7 +8647,7 @@ async function syncInPlace(deps2, o) {
|
|
|
8564
8647
|
continue;
|
|
8565
8648
|
}
|
|
8566
8649
|
try {
|
|
8567
|
-
dirs[m.slug] = await deps2.git.inspect(
|
|
8650
|
+
dirs[m.slug] = await deps2.git.inspect(join32(root, m.slug));
|
|
8568
8651
|
modulesForPlan.push(m);
|
|
8569
8652
|
} catch (e) {
|
|
8570
8653
|
earlyFailures.push(asFailure2(m.slug, e));
|
|
@@ -9010,7 +9093,7 @@ async function maybeNotifyUpdate(deps2, io2, o, timeoutMs = DEFAULT_TIMEOUT_MS)
|
|
|
9010
9093
|
|
|
9011
9094
|
// src/core/config.ts
|
|
9012
9095
|
import { readFile as readFile8 } from "fs/promises";
|
|
9013
|
-
import { join as
|
|
9096
|
+
import { join as join33 } from "path";
|
|
9014
9097
|
var empty = () => ({ schemaVersion: 1, profiles: {} });
|
|
9015
9098
|
var ConfigStore = class {
|
|
9016
9099
|
constructor(dir2) {
|
|
@@ -9018,7 +9101,7 @@ var ConfigStore = class {
|
|
|
9018
9101
|
}
|
|
9019
9102
|
dir;
|
|
9020
9103
|
get file() {
|
|
9021
|
-
return
|
|
9104
|
+
return join33(this.dir, "config.json");
|
|
9022
9105
|
}
|
|
9023
9106
|
async read() {
|
|
9024
9107
|
let raw;
|
|
@@ -9049,9 +9132,9 @@ var ConfigStore = class {
|
|
|
9049
9132
|
|
|
9050
9133
|
// src/platform/git.ts
|
|
9051
9134
|
import { execFile, execFileSync } from "child_process";
|
|
9052
|
-
import { mkdir as mkdir6, readdir as readdir7, stat as
|
|
9135
|
+
import { mkdir as mkdir6, readdir as readdir7, stat as stat8 } from "fs/promises";
|
|
9053
9136
|
import { homedir } from "os";
|
|
9054
|
-
import { dirname as dirname12, join as
|
|
9137
|
+
import { dirname as dirname12, join as join34 } from "path";
|
|
9055
9138
|
function parseRemotes(stdout) {
|
|
9056
9139
|
const seen = /* @__PURE__ */ new Set();
|
|
9057
9140
|
const out = [];
|
|
@@ -9192,7 +9275,7 @@ async function stashCount(repoRoot) {
|
|
|
9192
9275
|
}
|
|
9193
9276
|
async function statOrThrow(path2) {
|
|
9194
9277
|
try {
|
|
9195
|
-
return await
|
|
9278
|
+
return await stat8(path2);
|
|
9196
9279
|
} catch (err) {
|
|
9197
9280
|
if (err.code === "ENOENT") return void 0;
|
|
9198
9281
|
throw new QoreError("QORE_INTERNAL", `could not stat ${path2}`, { cause: err });
|
|
@@ -9209,7 +9292,7 @@ async function inspect(dir2) {
|
|
|
9209
9292
|
throw new QoreError("QORE_INTERNAL", `could not read ${dir2}`, { cause: err });
|
|
9210
9293
|
}
|
|
9211
9294
|
const empty2 = entries.length === 0;
|
|
9212
|
-
const isRepo = await statOrThrow(
|
|
9295
|
+
const isRepo = await statOrThrow(join34(dir2, ".git")) !== void 0;
|
|
9213
9296
|
const dirRemotes = isRepo ? await remotes(dir2) : [];
|
|
9214
9297
|
return { exists: true, empty: empty2, isRepo, remotes: dirRemotes };
|
|
9215
9298
|
}
|
|
@@ -9342,13 +9425,13 @@ var OsKeychain = class extends ChunkedKeychain {
|
|
|
9342
9425
|
|
|
9343
9426
|
// src/platform/lock.ts
|
|
9344
9427
|
import { mkdir as mkdir7, writeFile as writeFile7 } from "fs/promises";
|
|
9345
|
-
import { join as
|
|
9428
|
+
import { join as join35 } from "path";
|
|
9346
9429
|
import lockfile from "proper-lockfile";
|
|
9347
9430
|
function fileLock(dir2) {
|
|
9348
9431
|
return async (name, fn) => {
|
|
9349
|
-
const locks =
|
|
9432
|
+
const locks = join35(dir2, "locks");
|
|
9350
9433
|
await mkdir7(locks, { recursive: true, mode: 448 });
|
|
9351
|
-
const target =
|
|
9434
|
+
const target = join35(locks, `${name}.lock`);
|
|
9352
9435
|
await writeFile7(target, "", { flag: "a" });
|
|
9353
9436
|
let release;
|
|
9354
9437
|
let compromised;
|
|
@@ -9801,4 +9884,4 @@ if (!drained) {
|
|
|
9801
9884
|
process.exit();
|
|
9802
9885
|
}
|
|
9803
9886
|
//# sourceMappingURL=cli.js.map
|
|
9804
|
-
//# debugId=
|
|
9887
|
+
//# debugId=61c8b355-f1e5-5a19-8b8d-2f4dc57679da
|