@teable/agent-gateway 1.0.14 → 1.0.15
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/cli.js +26 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -569,10 +569,11 @@ var AGENTS = {
|
|
|
569
569
|
|
|
570
570
|
// src/checkout.ts
|
|
571
571
|
import { execFile } from "node:child_process";
|
|
572
|
-
import { existsSync, mkdirSync as mkdirSync2 } from "node:fs";
|
|
572
|
+
import { existsSync, mkdirSync as mkdirSync2, readdirSync } from "node:fs";
|
|
573
573
|
import { join as join2 } from "node:path";
|
|
574
574
|
var APP_DIRECTORY = /^[A-Za-z0-9_-]+$/;
|
|
575
575
|
var CLONE_TIMEOUT_MS = 5 * 6e4;
|
|
576
|
+
var CHECK_TIMEOUT_MS = 2e4;
|
|
576
577
|
var RULES_MARK = "[Teable]";
|
|
577
578
|
var where = (appId) => `${RULES_MARK} You work in a person's Teable sandbox, on the Teable app ${appId}, in this directory.`;
|
|
578
579
|
var NAME_IT = 'once you know what the app is, name the project after it, in the person\'s language, with `teable-next rename "<name>"`.';
|
|
@@ -586,6 +587,12 @@ function newProject(appId) {
|
|
|
586
587
|
`If \`init\` prints the projectName as null, nobody has named the project yet: ${NAME_IT}`
|
|
587
588
|
].join(" ");
|
|
588
589
|
}
|
|
590
|
+
var UPGRADE = [
|
|
591
|
+
"The app was made from an older scaffold than Teable's newest, so its AGENTS.md may say how",
|
|
592
|
+
"apps were built then: before anything else, run `teable-next upgrade`, which replaces AGENTS.md",
|
|
593
|
+
"and moves the app's packages to the versions apps build with now. Then read AGENTS.md again,",
|
|
594
|
+
"all of it, run the checks and fix what they find, and commit the upgrade with your change."
|
|
595
|
+
].join(" ");
|
|
589
596
|
function unnamed(appId) {
|
|
590
597
|
return [
|
|
591
598
|
where(appId),
|
|
@@ -633,21 +640,37 @@ function clone(appId, dir, env) {
|
|
|
633
640
|
);
|
|
634
641
|
});
|
|
635
642
|
}
|
|
643
|
+
function behind(cwd, env) {
|
|
644
|
+
return new Promise((resolve) => {
|
|
645
|
+
execFile(
|
|
646
|
+
"teable-next",
|
|
647
|
+
["upgrade", "--check"],
|
|
648
|
+
{ cwd, env, timeout: CHECK_TIMEOUT_MS, maxBuffer: 1 << 20 },
|
|
649
|
+
(error, stdout) => resolve(error === null && fieldOf(stdout, "behind") === true)
|
|
650
|
+
);
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
async function upgradedFirst(made, appId, env) {
|
|
654
|
+
if (!await behind(made.cwd, env)) return made;
|
|
655
|
+
return { ...made, rules: `${made.rules ?? where(appId)} ${UPGRADE}` };
|
|
656
|
+
}
|
|
636
657
|
var cloning = /* @__PURE__ */ new Map();
|
|
637
658
|
function checkout(home2, appId, env, log2) {
|
|
638
659
|
if (!APP_DIRECTORY.test(appId)) {
|
|
639
660
|
return Promise.reject(new Error(`"${appId}" is not an app id`));
|
|
640
661
|
}
|
|
641
662
|
const cwd = join2(home2, "apps", appId);
|
|
642
|
-
if (existsSync(cwd)) return Promise.resolve({ cwd, rules: null });
|
|
643
663
|
const running = cloning.get(cwd);
|
|
644
664
|
if (running) return running;
|
|
665
|
+
if (existsSync(cwd) && readdirSync(cwd).length > 0) {
|
|
666
|
+
return upgradedFirst({ cwd, rules: null }, appId, env);
|
|
667
|
+
}
|
|
645
668
|
const made = (async () => {
|
|
646
669
|
mkdirSync2(join2(home2, "apps"), { recursive: true });
|
|
647
670
|
log2(`cloning ${appId} into ${cwd}`);
|
|
648
671
|
const cloned = await clone(appId, cwd, env);
|
|
649
672
|
if (cloned.kind === "cloned" && existsSync(cwd)) {
|
|
650
|
-
return { cwd, rules: cloned.named ? null : unnamed(appId) };
|
|
673
|
+
return upgradedFirst({ cwd, rules: cloned.named ? null : unnamed(appId) }, appId, env);
|
|
651
674
|
}
|
|
652
675
|
mkdirSync2(cwd, { recursive: true });
|
|
653
676
|
switch (cloned.kind) {
|
package/package.json
CHANGED