@quatronic/qore 0.4.0-rc.2 → 0.4.0-test.009bcec
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 +6 -0
- package/dist/cli.js +87 -47
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -293,6 +293,12 @@ a hint rather than leaving a bare error (spec §14.2):
|
|
|
293
293
|
- **A leftover `qore dev` holds the port**: in a TTY, offers to stop it
|
|
294
294
|
(`Stop the previous qore dev (pid N)?`); outside a TTY it's just
|
|
295
295
|
`QORE_PORT_IN_USE`.
|
|
296
|
+
- **Another checkout of the same module holds `DB_PORT`** (a worktree or a
|
|
297
|
+
second clone, whose compose project is named after its own folder): the
|
|
298
|
+
error names that checkout and suggests stopping its database there or
|
|
299
|
+
running `qore dev` from it. The two checkouts are matched on the managed
|
|
300
|
+
keys `QORE_MODULE` and `QORE_CUSTOMER_ID` in their env files, so this needs
|
|
301
|
+
no portal call. `qore doctor` reports the same.
|
|
296
302
|
- **The dev server exits within seconds of starting**: its tail output is
|
|
297
303
|
classified into a hint — a missing dependency (`Cannot find module`), an
|
|
298
304
|
invalid/missing env var (a `ZodError`'s keys, never values), a port taken
|
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]="fdf8ddca-c1bb-5549-9d3b-a2a664c8a79c")}catch(e){}}();
|
|
4
4
|
import { createRequire as __qoreCreateRequire } from "node:module"; const require = __qoreCreateRequire(import.meta.url);
|
|
5
5
|
import {
|
|
6
6
|
addSecretValues,
|
|
@@ -135,6 +135,7 @@ function processIo(interactive, stderrTTY = Boolean(process.stderr.isTTY)) {
|
|
|
135
135
|
stderrTTY,
|
|
136
136
|
stderrRaw: process.stderr,
|
|
137
137
|
async select(message, choices) {
|
|
138
|
+
if (choices.length === 0) throw noChoices(message);
|
|
138
139
|
try {
|
|
139
140
|
return await select({ message, choices });
|
|
140
141
|
} catch (e) {
|
|
@@ -170,6 +171,11 @@ function processIo(interactive, stderrTTY = Boolean(process.stderr.isTTY)) {
|
|
|
170
171
|
openUrl: openBrowser
|
|
171
172
|
};
|
|
172
173
|
}
|
|
174
|
+
function noChoices(message) {
|
|
175
|
+
return new QoreError("QORE_RESOURCE_NOT_FOUND", `Nothing to choose from (${message}): the list is empty`, {
|
|
176
|
+
hint: "Run `qore whoami` to check what your account has access to, or pass the value as an argument."
|
|
177
|
+
});
|
|
178
|
+
}
|
|
173
179
|
function createWaitForEnter(input2, output) {
|
|
174
180
|
return (message, signal) => new Promise((resolve9, reject) => {
|
|
175
181
|
const rl = createInterface({ input: input2, output, terminal: true });
|
|
@@ -4615,9 +4621,9 @@ async function erdApp(ctx, f, ws) {
|
|
|
4615
4621
|
|
|
4616
4622
|
// src/cli/commands/dev.ts
|
|
4617
4623
|
import { randomBytes as randomBytes8 } from "crypto";
|
|
4618
|
-
import { realpath as
|
|
4624
|
+
import { realpath as realpath12 } from "fs/promises";
|
|
4619
4625
|
import { constants as constants5 } from "os";
|
|
4620
|
-
import { dirname as dirname10, join as
|
|
4626
|
+
import { dirname as dirname10, join as join29, relative as relative9 } from "path";
|
|
4621
4627
|
import { StringDecoder } from "string_decoder";
|
|
4622
4628
|
|
|
4623
4629
|
// src/core/diagnostics/node.ts
|
|
@@ -4901,6 +4907,10 @@ function noLocalRole(o) {
|
|
|
4901
4907
|
};
|
|
4902
4908
|
}
|
|
4903
4909
|
|
|
4910
|
+
// src/core/dev/preflight.ts
|
|
4911
|
+
import { realpath as realpath10 } from "fs/promises";
|
|
4912
|
+
import { join as join25 } from "path";
|
|
4913
|
+
|
|
4904
4914
|
// src/core/dev/project.ts
|
|
4905
4915
|
import { access, readFile as readFile7 } from "fs/promises";
|
|
4906
4916
|
import { join as join23 } from "path";
|
|
@@ -5189,6 +5199,24 @@ async function installIfNeeded(deps2, r, slug, onLine, report, signal) {
|
|
|
5189
5199
|
}
|
|
5190
5200
|
report({ module: slug, step: "install", status: "done", detail: secs(deps2.now().getTime() - began) });
|
|
5191
5201
|
}
|
|
5202
|
+
async function checkoutEnv(dir2) {
|
|
5203
|
+
const named2 = await readRepoConfig(dir2).then((c) => c.envFile, () => void 0);
|
|
5204
|
+
for (const file of [named2, ".env.local", ".env"]) {
|
|
5205
|
+
if (!file) continue;
|
|
5206
|
+
const text2 = await readOrNull(join25(dir2, file));
|
|
5207
|
+
if (text2 !== null) return Object.fromEntries(parseEnv(text2));
|
|
5208
|
+
}
|
|
5209
|
+
return null;
|
|
5210
|
+
}
|
|
5211
|
+
async function isOtherCheckoutOfModule(dir2, o) {
|
|
5212
|
+
const module = o.env?.QORE_MODULE;
|
|
5213
|
+
const customer = o.env?.QORE_CUSTOMER_ID;
|
|
5214
|
+
if (!module || !customer || !o.root) return false;
|
|
5215
|
+
const resolve9 = (p) => realpath10(p).catch(() => p);
|
|
5216
|
+
if (await resolve9(dir2) === await resolve9(o.root)) return false;
|
|
5217
|
+
const other = await checkoutEnv(dir2);
|
|
5218
|
+
return other?.QORE_MODULE === module && other.QORE_CUSTOMER_ID === customer;
|
|
5219
|
+
}
|
|
5192
5220
|
async function portInUseError(deps2, o) {
|
|
5193
5221
|
const owner = await deps2.ports.owner(o.port);
|
|
5194
5222
|
const qoreRun = (o.runs ?? []).find((r) => r.children.some((c) => c.port === o.port) || owner !== null && (r.qorePid === owner.pid || r.children.some((c) => c.pid === owner.pid)));
|
|
@@ -5201,6 +5229,12 @@ async function portInUseError(deps2, o) {
|
|
|
5201
5229
|
if (owner) {
|
|
5202
5230
|
if (/^(com\.docker\.backend|com\.docker\.vpnkit|docker-proxy|vpnkit|dockerd)$/.test(owner.command)) {
|
|
5203
5231
|
const pub = await deps2.ports.dockerPublisher(o.port);
|
|
5232
|
+
if (pub?.workingDir && await isOtherCheckoutOfModule(pub.workingDir, o)) {
|
|
5233
|
+
return new QoreError("QORE_PORT_IN_USE", `Port ${o.port} is held by ${o.slug}'s database from ${pub.workingDir}`, {
|
|
5234
|
+
hint: `That is another checkout of ${o.slug}, and both use port ${o.port}. Stop it there (docker compose down in ${pub.workingDir}, or docker stop ${pub.name}), or run qore dev from that checkout instead.`,
|
|
5235
|
+
details: { port: o.port, module: o.slug, key: o.key, owner: "docker", sameModule: true, ...pub }
|
|
5236
|
+
});
|
|
5237
|
+
}
|
|
5204
5238
|
if (pub) {
|
|
5205
5239
|
return new QoreError("QORE_PORT_IN_USE", `Port ${o.port} is held by the Docker container ${pub.name} (needed by ${o.slug})`, {
|
|
5206
5240
|
hint: `It belongs to compose project ${pub.project} in ${pub.workingDir} \u2014 typically another module's or tenant's database. Stop it there with docker compose down, or docker stop ${pub.name}.`,
|
|
@@ -5270,7 +5304,7 @@ async function startServices(deps2, r, slug, env, dbPort2, waitMs, signal, onLin
|
|
|
5270
5304
|
const res = await runTool(deps2, cmd, args, { cwd: r.root, env, onLine, signal });
|
|
5271
5305
|
if (res.code !== 0) {
|
|
5272
5306
|
if (dbPort2 !== null && /port is already allocated|address already in use/i.test(res.tail.join("\n"))) {
|
|
5273
|
-
throw await portInUseError(deps2, { slug, port: dbPort2, key: "DB_PORT" });
|
|
5307
|
+
throw await portInUseError(deps2, { slug, port: dbPort2, key: "DB_PORT", root: r.root, env });
|
|
5274
5308
|
}
|
|
5275
5309
|
throw await composeFailure(deps2, r, slug, env, signal, `${script} failed in ${slug}`, `${cmd} ${args.join(" ")}`, res.tail);
|
|
5276
5310
|
}
|
|
@@ -5444,11 +5478,11 @@ function hintContext(recipe, pkg, env) {
|
|
|
5444
5478
|
|
|
5445
5479
|
// src/core/dev/runFile.ts
|
|
5446
5480
|
import { readdir as readdir5, unlink as unlink2 } from "fs/promises";
|
|
5447
|
-
import { join as
|
|
5481
|
+
import { join as join26 } from "path";
|
|
5448
5482
|
async function runFilePath(deps2, root) {
|
|
5449
|
-
const dir2 =
|
|
5483
|
+
const dir2 = join26(deps2.config.dir, "run");
|
|
5450
5484
|
const name = `${await stateKey(deps2, root)}.json`;
|
|
5451
|
-
return { dir: dir2, name, path:
|
|
5485
|
+
return { dir: dir2, name, path: join26(dir2, name) };
|
|
5452
5486
|
}
|
|
5453
5487
|
async function writeRunFile(deps2, root, rec) {
|
|
5454
5488
|
const { dir: dir2, name } = await runFilePath(deps2, root);
|
|
@@ -5469,9 +5503,9 @@ async function leftoverRun(deps2, root, o = {}) {
|
|
|
5469
5503
|
return null;
|
|
5470
5504
|
}
|
|
5471
5505
|
async function listRunFiles(deps2) {
|
|
5472
|
-
const dir2 =
|
|
5506
|
+
const dir2 = join26(deps2.config.dir, "run");
|
|
5473
5507
|
const names = await readdir5(dir2).catch(() => []);
|
|
5474
|
-
const recs = await Promise.all(names.filter((n) => n.endsWith(".json")).map((n) => readJson(
|
|
5508
|
+
const recs = await Promise.all(names.filter((n) => n.endsWith(".json")).map((n) => readJson(join26(dir2, n)).catch(() => null)));
|
|
5475
5509
|
return recs.filter((r) => !!r && r.schemaVersion === 1 && Array.isArray(r.children));
|
|
5476
5510
|
}
|
|
5477
5511
|
|
|
@@ -5600,8 +5634,8 @@ async function inPreflight(signals, outer, fn) {
|
|
|
5600
5634
|
// src/cli/commands/devWorkspace.ts
|
|
5601
5635
|
import { randomBytes as randomBytes7 } from "crypto";
|
|
5602
5636
|
import { constants as constants4 } from "os";
|
|
5603
|
-
import { realpath as
|
|
5604
|
-
import { basename as basename7, join as
|
|
5637
|
+
import { realpath as realpath11 } from "fs/promises";
|
|
5638
|
+
import { basename as basename7, join as join28, relative as relative8 } from "path";
|
|
5605
5639
|
|
|
5606
5640
|
// src/core/dev/order.ts
|
|
5607
5641
|
function selectSkips(modules, sel) {
|
|
@@ -5922,7 +5956,7 @@ function supervise(o) {
|
|
|
5922
5956
|
|
|
5923
5957
|
// src/core/workspace/stray.ts
|
|
5924
5958
|
import { lstat as lstat4, readdir as readdir6 } from "fs/promises";
|
|
5925
|
-
import { join as
|
|
5959
|
+
import { join as join27 } from "path";
|
|
5926
5960
|
var VIEW_ENTRIES = /* @__PURE__ */ new Set(["qore.workspace.json", ".idea", ".claude", "CLAUDE.md", "README.md"]);
|
|
5927
5961
|
async function strayRepos(root, slugs, o = {}) {
|
|
5928
5962
|
let entries;
|
|
@@ -5936,8 +5970,8 @@ async function strayRepos(root, slugs, o = {}) {
|
|
|
5936
5970
|
if (slugs.has(name)) continue;
|
|
5937
5971
|
if (o.view && (VIEW_ENTRIES.has(name) || name.endsWith(".code-workspace"))) continue;
|
|
5938
5972
|
try {
|
|
5939
|
-
if ((await readEntry(
|
|
5940
|
-
await lstat4(
|
|
5973
|
+
if ((await readEntry(join27(root, name))).kind !== "dir") continue;
|
|
5974
|
+
await lstat4(join27(root, name, ".git"));
|
|
5941
5975
|
names.push(name);
|
|
5942
5976
|
} catch {
|
|
5943
5977
|
}
|
|
@@ -6141,7 +6175,7 @@ async function prepareWorkspace(ctx, ws, f, waitTimeout, p) {
|
|
|
6141
6175
|
let neutral;
|
|
6142
6176
|
const units = [];
|
|
6143
6177
|
for (const u of planned) {
|
|
6144
|
-
u.realDir = await
|
|
6178
|
+
u.realDir = await realpath11(u.dir).catch(() => u.dir);
|
|
6145
6179
|
const match = await findRunning(running, { moduleId: u.m.id, realDir: u.realDir, exceptPid: deps2.pid, exceptRoot: ws.root });
|
|
6146
6180
|
const port = match?.child.port ?? null;
|
|
6147
6181
|
if (!match) {
|
|
@@ -6255,7 +6289,7 @@ async function prepareWorkspace(ctx, ws, f, waitTimeout, p) {
|
|
|
6255
6289
|
workspace: ws,
|
|
6256
6290
|
module: { id: u.m.id, slug: u.m.slug, name: u.m.name, type: u.m.type, access: u.m.access, tenant: am.app.tenant, apps: [appRef] }
|
|
6257
6291
|
});
|
|
6258
|
-
const rootReal = await
|
|
6292
|
+
const rootReal = await realpath11(ws.root);
|
|
6259
6293
|
const withDocker = dockerRecovery(ctx, p.signal);
|
|
6260
6294
|
for (const u of units.filter((x) => x.recipe && x.trusted)) {
|
|
6261
6295
|
const slug = u.m.slug;
|
|
@@ -6281,7 +6315,7 @@ async function prepareWorkspace(ctx, ws, f, waitTimeout, p) {
|
|
|
6281
6315
|
warn(`${slug}: the portal is unreachable \u2014 starting from ${relative8(rootReal, dev.envFile)} as last written; values may be stale.`, { module: slug });
|
|
6282
6316
|
}
|
|
6283
6317
|
if (dev.ignored === false) {
|
|
6284
|
-
const repo = await
|
|
6318
|
+
const repo = await realpath11(u.dir);
|
|
6285
6319
|
warn(`${slug}: ${notIgnoredWarning(relative8(repo, dev.envFile), relative8(rootReal, repo))}`, { module: slug });
|
|
6286
6320
|
}
|
|
6287
6321
|
if (dev.kept.length) {
|
|
@@ -6337,7 +6371,7 @@ async function prepareWorkspace(ctx, ws, f, waitTimeout, p) {
|
|
|
6337
6371
|
if (online && units.every((u) => !u.dev.offline)) {
|
|
6338
6372
|
const envFile = (m) => {
|
|
6339
6373
|
const u = units.find((x) => x.m.id === m.id);
|
|
6340
|
-
return u ? relative8(rootReal, u.dev.envFile) :
|
|
6374
|
+
return u ? relative8(rootReal, u.dev.envFile) : join28(m.slug, moduleDefaults(m.type).envFile);
|
|
6341
6375
|
};
|
|
6342
6376
|
await saveLastStart(deps2, ws.root, {
|
|
6343
6377
|
schemaVersion: 1,
|
|
@@ -6622,7 +6656,7 @@ async function providerFindings(ctx, root, mc, app, env) {
|
|
|
6622
6656
|
let fix = `qore clone ${app.slug}`;
|
|
6623
6657
|
if (ws && ws.appId === app.id) fix = cdAndDev(deps2.home, ws.root);
|
|
6624
6658
|
else if (providers.length === 1) {
|
|
6625
|
-
const sibling =
|
|
6659
|
+
const sibling = join29(dirname10(root), providers[0].slug);
|
|
6626
6660
|
if ((await deps2.git.inspect(sibling)).isRepo) fix = cdAndDev(deps2.home, sibling);
|
|
6627
6661
|
}
|
|
6628
6662
|
return providerDown({
|
|
@@ -6758,7 +6792,7 @@ async function prepareModule(ctx, f, waitTimeout, p) {
|
|
|
6758
6792
|
if (c.offlineCause && isOffline(e)) throw c.offlineCause;
|
|
6759
6793
|
throw e;
|
|
6760
6794
|
}
|
|
6761
|
-
const envFile = relative9(await
|
|
6795
|
+
const envFile = relative9(await realpath12(root), dev.envFile);
|
|
6762
6796
|
if (dev.offline) io2.err(`! The portal is unreachable \u2014 starting from ${envFile} as last written; values may be stale.`);
|
|
6763
6797
|
if (dev.ignored === false) io2.err(`! ${notIgnoredWarning(envFile)}`);
|
|
6764
6798
|
if (dev.kept.length) {
|
|
@@ -6819,7 +6853,7 @@ function registerDebugTelemetry(program, ctx) {
|
|
|
6819
6853
|
import pc3 from "picocolors";
|
|
6820
6854
|
|
|
6821
6855
|
// src/core/doctor/checks.ts
|
|
6822
|
-
import { realpath as
|
|
6856
|
+
import { realpath as realpath13, stat as stat6 } from "fs/promises";
|
|
6823
6857
|
import { basename as basename8 } from "path";
|
|
6824
6858
|
|
|
6825
6859
|
// src/core/diagnostics/ssh.ts
|
|
@@ -6998,11 +7032,12 @@ function checkClock(meta) {
|
|
|
6998
7032
|
function ownerText(e) {
|
|
6999
7033
|
const d = e.details ?? {};
|
|
7000
7034
|
if (d.owner === "process") return ` by ${String(d.command)} (pid ${String(d.pid)})`;
|
|
7035
|
+
if (d.owner === "docker" && d.sameModule) return ` by another checkout of ${String(d.module)} (${String(d.workingDir)})`;
|
|
7001
7036
|
if (d.owner === "docker") return ` by the Docker container ${String(d.name)}`;
|
|
7002
7037
|
if (d.owner === "qore") return ` by a previous qore dev (pid ${String(d.pid)})`;
|
|
7003
7038
|
return "";
|
|
7004
7039
|
}
|
|
7005
|
-
var sameDir = async (a, b) => await
|
|
7040
|
+
var sameDir = async (a, b) => await realpath13(a).catch(() => a) === await realpath13(b).catch(() => b);
|
|
7006
7041
|
async function moduleBody(deps2, m, runs, signal) {
|
|
7007
7042
|
const parts = [];
|
|
7008
7043
|
const part = async (fn) => {
|
|
@@ -7045,7 +7080,7 @@ async function moduleBody(deps2, m, runs, signal) {
|
|
|
7045
7080
|
if (!await deps2.ports.inUse(dbPort2)) return { status: "ok", label: `db:up (DB_PORT ${dbPort2} free)` };
|
|
7046
7081
|
const pub = await deps2.ports.dockerPublisher(dbPort2);
|
|
7047
7082
|
if (pub?.workingDir && await sameDir(pub.workingDir, m.root)) return { status: "ok", label: "db running" };
|
|
7048
|
-
const e = await portInUseError(deps2, { slug: m.slug, port: dbPort2, key: "DB_PORT" });
|
|
7083
|
+
const e = await portInUseError(deps2, { slug: m.slug, port: dbPort2, key: "DB_PORT", root: m.root, env: env ?? void 0 });
|
|
7049
7084
|
return { status: "fail", label: `DB_PORT ${dbPort2} in use${ownerText(e)}`, error: e };
|
|
7050
7085
|
});
|
|
7051
7086
|
const status2 = parts.reduce((w, p) => RANK[p.status] > RANK[w] ? p.status : w, "ok");
|
|
@@ -7291,17 +7326,17 @@ function registerDoctor(program, ctx) {
|
|
|
7291
7326
|
|
|
7292
7327
|
// src/cli/commands/env.ts
|
|
7293
7328
|
import { randomBytes as randomBytes9 } from "crypto";
|
|
7294
|
-
import { chmod as chmod4, realpath as
|
|
7295
|
-
import { dirname as dirname11, join as
|
|
7329
|
+
import { chmod as chmod4, realpath as realpath14 } from "fs/promises";
|
|
7330
|
+
import { dirname as dirname11, join as join31, relative as relative10 } from "path";
|
|
7296
7331
|
|
|
7297
7332
|
// src/core/env/mobile.ts
|
|
7298
7333
|
import { chmod as chmod3, stat as stat7 } from "fs/promises";
|
|
7299
|
-
import { join as
|
|
7334
|
+
import { join as join30 } from "path";
|
|
7300
7335
|
var MOBILE_ENV_FILE = "mobile/.env.local";
|
|
7301
7336
|
var MOBILE_KEYS = ["EXPO_PUBLIC_SERVER_URL", "EXPO_PUBLIC_SENTRY_DSN", "EXPO_PUBLIC_QORE_ENV"];
|
|
7302
7337
|
async function hasMobileApp(repoRoot) {
|
|
7303
7338
|
try {
|
|
7304
|
-
return (await stat7(
|
|
7339
|
+
return (await stat7(join30(repoRoot, "mobile"))).isDirectory();
|
|
7305
7340
|
} catch {
|
|
7306
7341
|
return false;
|
|
7307
7342
|
}
|
|
@@ -7353,7 +7388,7 @@ function registerEnv(program, ctx) {
|
|
|
7353
7388
|
const target = f.target ? await resolveTarget(mc.repoRoot, f.target, deps2.cwd) : await resolveTarget(mc.repoRoot, cfg.envFile ?? defaults.envFile);
|
|
7354
7389
|
await ensureTrusted(c, mc, app, { yes: f.yes });
|
|
7355
7390
|
const existing = await readOrNull(target);
|
|
7356
|
-
const example = existing === null ? await readOrNull(
|
|
7391
|
+
const example = existing === null ? await readOrNull(join31(dirname11(target), ".env.example")) : null;
|
|
7357
7392
|
const local = await fetchLocalEnv(deps2, mc, app);
|
|
7358
7393
|
const inputs = {
|
|
7359
7394
|
existing,
|
|
@@ -7394,7 +7429,7 @@ function registerEnv(program, ctx) {
|
|
|
7394
7429
|
} else {
|
|
7395
7430
|
await writeSecurely(target, plan.text);
|
|
7396
7431
|
}
|
|
7397
|
-
const rel = relative10(await
|
|
7432
|
+
const rel = relative10(await realpath14(mc.repoRoot), target);
|
|
7398
7433
|
const mobile = await pullMobile(c, mc, app);
|
|
7399
7434
|
if (g.json) {
|
|
7400
7435
|
const names = {
|
|
@@ -7942,7 +7977,7 @@ function registerErrors(program, ctx) {
|
|
|
7942
7977
|
}
|
|
7943
7978
|
|
|
7944
7979
|
// src/cli/commands/init.ts
|
|
7945
|
-
import { realpath as
|
|
7980
|
+
import { realpath as realpath15 } from "fs/promises";
|
|
7946
7981
|
|
|
7947
7982
|
// src/core/auth/oidc.ts
|
|
7948
7983
|
import * as oc from "openid-client";
|
|
@@ -8186,6 +8221,11 @@ async function useTenant(ctx, slug, known) {
|
|
|
8186
8221
|
const portal = resolvePortal(g.portal, cfg.defaultProfile);
|
|
8187
8222
|
const me = known ?? await (await openSession(deps2, portal, "tenant use", requestLog(ctx))).api.get("/api/cli/v1/me");
|
|
8188
8223
|
const candidates = me.tenants.map((t) => ({ kind: "tenant", id: t.id, slug: t.slug, name: t.name }));
|
|
8224
|
+
if (me.tenants.length === 0) {
|
|
8225
|
+
throw new QoreError("QORE_NO_DEVELOPER_ACCESS", "Your account is not a developer in any organisation", {
|
|
8226
|
+
hint: "Ask an admin to invite you as a developer."
|
|
8227
|
+
});
|
|
8228
|
+
}
|
|
8189
8229
|
let chosen;
|
|
8190
8230
|
if (slug) {
|
|
8191
8231
|
const found = me.tenants.find((t) => t.slug === slug);
|
|
@@ -8216,7 +8256,7 @@ async function rootStep(ctx, f) {
|
|
|
8216
8256
|
input2 = await io2.input("Projects folder", { default: current ?? "~/qore" }) || current || "~/qore";
|
|
8217
8257
|
}
|
|
8218
8258
|
const wanted = await checkRoot(deps2, input2);
|
|
8219
|
-
const asked = await
|
|
8259
|
+
const asked = await realpath15(wanted).catch(() => wanted);
|
|
8220
8260
|
if (current && asked !== current && io2.interactive && !await io2.confirm(`Change the projects folder from ${current} to ${asked}? Nothing is moved.`, ctx.signal)) {
|
|
8221
8261
|
return step("skipped", current);
|
|
8222
8262
|
}
|
|
@@ -8400,7 +8440,7 @@ function registerPortal(program, ctx) {
|
|
|
8400
8440
|
}
|
|
8401
8441
|
|
|
8402
8442
|
// src/core/roles/read.ts
|
|
8403
|
-
import { join as
|
|
8443
|
+
import { join as join32 } from "path";
|
|
8404
8444
|
|
|
8405
8445
|
// src/core/roles/extract.ts
|
|
8406
8446
|
var KNOWN = { user: "User", admin: "App admin" };
|
|
@@ -8431,11 +8471,11 @@ async function extractRoles(source) {
|
|
|
8431
8471
|
|
|
8432
8472
|
// src/core/roles/read.ts
|
|
8433
8473
|
var PERMISSIONS_FILE = "src/lib/permissions.ts";
|
|
8434
|
-
var SLUG = /^[
|
|
8474
|
+
var SLUG = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
8435
8475
|
var MAX_SLUG = 64;
|
|
8436
8476
|
var MAX_ROLES = 100;
|
|
8437
8477
|
async function readCodeRoles(repoRoot) {
|
|
8438
|
-
const source = await readOrNull(
|
|
8478
|
+
const source = await readOrNull(join32(repoRoot, PERMISSIONS_FILE));
|
|
8439
8479
|
if (source === null) {
|
|
8440
8480
|
throw new QoreError("QORE_CONTEXT_UNSUPPORTED", `No ${PERMISSIONS_FILE} in this module`, {
|
|
8441
8481
|
hint: "App roles live in the app's frontend module; run this there."
|
|
@@ -8450,7 +8490,7 @@ async function readCodeRoles(repoRoot) {
|
|
|
8450
8490
|
const invalid4 = roles.filter((r) => !SLUG.test(r.slug) || r.slug.length > MAX_SLUG).map((r) => r.slug);
|
|
8451
8491
|
if (invalid4.length) {
|
|
8452
8492
|
throw new QoreError("QORE_CONTEXT_INVALID", `The portal refuses these role names: ${invalid4.join(", ")}`, {
|
|
8453
|
-
hint: `Use
|
|
8493
|
+
hint: `Use letters, digits, - and _, starting with a letter or digit, at most ${MAX_SLUG} characters.`,
|
|
8454
8494
|
details: { invalid: invalid4 }
|
|
8455
8495
|
});
|
|
8456
8496
|
}
|
|
@@ -8626,8 +8666,8 @@ function registerStatus(program, ctx) {
|
|
|
8626
8666
|
}
|
|
8627
8667
|
|
|
8628
8668
|
// src/cli/commands/sync.ts
|
|
8629
|
-
import { realpath as
|
|
8630
|
-
import { basename as basename9, join as
|
|
8669
|
+
import { realpath as realpath16 } from "fs/promises";
|
|
8670
|
+
import { basename as basename9, join as join33, relative as relative11 } from "path";
|
|
8631
8671
|
import { Option as Option3 } from "commander";
|
|
8632
8672
|
function asFailure2(slug, e) {
|
|
8633
8673
|
if (e instanceof QoreError && e.code !== "QORE_GIT_UNAVAILABLE") {
|
|
@@ -8647,7 +8687,7 @@ async function syncInPlace(deps2, o) {
|
|
|
8647
8687
|
continue;
|
|
8648
8688
|
}
|
|
8649
8689
|
try {
|
|
8650
|
-
dirs[m.slug] = await deps2.git.inspect(
|
|
8690
|
+
dirs[m.slug] = await deps2.git.inspect(join33(root, m.slug));
|
|
8651
8691
|
modulesForPlan.push(m);
|
|
8652
8692
|
} catch (e) {
|
|
8653
8693
|
earlyFailures.push(asFailure2(m.slug, e));
|
|
@@ -8679,7 +8719,7 @@ async function syncTenant(ctx, o) {
|
|
|
8679
8719
|
const { deps: deps2, io: io2 } = ctx;
|
|
8680
8720
|
const { layout, app } = o;
|
|
8681
8721
|
const label3 = (root) => relative11(layout.tenantDir, root) || basename9(root);
|
|
8682
|
-
const own = await
|
|
8722
|
+
const own = await realpath16(o.wsRoot).catch(() => o.wsRoot);
|
|
8683
8723
|
const apps = [{ appSlug: app.app.slug, root: own, kind: o.kind, modules: app.modules }];
|
|
8684
8724
|
const views = [{ appSlug: app.app.slug, name: app.app.name, appId: app.app.id, modules: app.modules }];
|
|
8685
8725
|
const leftAlone = [];
|
|
@@ -9093,7 +9133,7 @@ async function maybeNotifyUpdate(deps2, io2, o, timeoutMs = DEFAULT_TIMEOUT_MS)
|
|
|
9093
9133
|
|
|
9094
9134
|
// src/core/config.ts
|
|
9095
9135
|
import { readFile as readFile8 } from "fs/promises";
|
|
9096
|
-
import { join as
|
|
9136
|
+
import { join as join34 } from "path";
|
|
9097
9137
|
var empty = () => ({ schemaVersion: 1, profiles: {} });
|
|
9098
9138
|
var ConfigStore = class {
|
|
9099
9139
|
constructor(dir2) {
|
|
@@ -9101,7 +9141,7 @@ var ConfigStore = class {
|
|
|
9101
9141
|
}
|
|
9102
9142
|
dir;
|
|
9103
9143
|
get file() {
|
|
9104
|
-
return
|
|
9144
|
+
return join34(this.dir, "config.json");
|
|
9105
9145
|
}
|
|
9106
9146
|
async read() {
|
|
9107
9147
|
let raw;
|
|
@@ -9134,7 +9174,7 @@ var ConfigStore = class {
|
|
|
9134
9174
|
import { execFile, execFileSync } from "child_process";
|
|
9135
9175
|
import { mkdir as mkdir6, readdir as readdir7, stat as stat8 } from "fs/promises";
|
|
9136
9176
|
import { homedir } from "os";
|
|
9137
|
-
import { dirname as dirname12, join as
|
|
9177
|
+
import { dirname as dirname12, join as join35 } from "path";
|
|
9138
9178
|
function parseRemotes(stdout) {
|
|
9139
9179
|
const seen = /* @__PURE__ */ new Set();
|
|
9140
9180
|
const out = [];
|
|
@@ -9292,7 +9332,7 @@ async function inspect(dir2) {
|
|
|
9292
9332
|
throw new QoreError("QORE_INTERNAL", `could not read ${dir2}`, { cause: err });
|
|
9293
9333
|
}
|
|
9294
9334
|
const empty2 = entries.length === 0;
|
|
9295
|
-
const isRepo = await statOrThrow(
|
|
9335
|
+
const isRepo = await statOrThrow(join35(dir2, ".git")) !== void 0;
|
|
9296
9336
|
const dirRemotes = isRepo ? await remotes(dir2) : [];
|
|
9297
9337
|
return { exists: true, empty: empty2, isRepo, remotes: dirRemotes };
|
|
9298
9338
|
}
|
|
@@ -9425,13 +9465,13 @@ var OsKeychain = class extends ChunkedKeychain {
|
|
|
9425
9465
|
|
|
9426
9466
|
// src/platform/lock.ts
|
|
9427
9467
|
import { mkdir as mkdir7, writeFile as writeFile7 } from "fs/promises";
|
|
9428
|
-
import { join as
|
|
9468
|
+
import { join as join36 } from "path";
|
|
9429
9469
|
import lockfile from "proper-lockfile";
|
|
9430
9470
|
function fileLock(dir2) {
|
|
9431
9471
|
return async (name, fn) => {
|
|
9432
|
-
const locks =
|
|
9472
|
+
const locks = join36(dir2, "locks");
|
|
9433
9473
|
await mkdir7(locks, { recursive: true, mode: 448 });
|
|
9434
|
-
const target =
|
|
9474
|
+
const target = join36(locks, `${name}.lock`);
|
|
9435
9475
|
await writeFile7(target, "", { flag: "a" });
|
|
9436
9476
|
let release;
|
|
9437
9477
|
let compromised;
|
|
@@ -9884,4 +9924,4 @@ if (!drained) {
|
|
|
9884
9924
|
process.exit();
|
|
9885
9925
|
}
|
|
9886
9926
|
//# sourceMappingURL=cli.js.map
|
|
9887
|
-
//# debugId=
|
|
9927
|
+
//# debugId=fdf8ddca-c1bb-5549-9d3b-a2a664c8a79c
|