@teable/next-cli 1.0.1 → 1.0.3
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 +14 -5
- package/dist/cli.js +41 -9
- package/dist/platform.d.ts +11 -1
- package/dist/publish.d.ts +1 -0
- package/dist/repository.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,14 +25,22 @@ runs the app's own `bun run check` and `bun run build`, so it needs
|
|
|
25
25
|
| `publish` | Runs the app's check and build, then deploys the pushed commit, its pages too, as its next version |
|
|
26
26
|
| `versions` | The published versions, newest first: when, by whom, from which commit |
|
|
27
27
|
| `rollback --version <n>` | Deploys version `n`'s code again, as the next version |
|
|
28
|
+
| `rename "<name>"` | Names the project, as its space lists it |
|
|
28
29
|
| `whoami` | Who the token belongs to |
|
|
29
30
|
| `login --token <token>` | Saves the token for later commands |
|
|
30
31
|
|
|
31
32
|
Inside a checkout (a directory holding `teable.json`, or below one) commands
|
|
32
|
-
take the project from `teable.json`; outside one, `versions
|
|
33
|
-
take `--project <projectId>`. Every command prints one JSON result
|
|
34
|
-
and exits with 1 when it fails
|
|
35
|
-
|
|
33
|
+
take the project from `teable.json`; outside one, `versions`, `rollback` and
|
|
34
|
+
`rename` take `--project <projectId>`. Every command prints one JSON result
|
|
35
|
+
on stdout and exits with 1 when it fails, with `success: false` and why in
|
|
36
|
+
`error`; a `clone` that finds no code in the project's repository also says
|
|
37
|
+
`"code": "NO_CODE"`: start that app with `init`. What the programs a command
|
|
38
|
+
runs print goes to stderr. Nothing is ever asked for. `teable-next <command>
|
|
39
|
+
--help` says more.
|
|
40
|
+
|
|
41
|
+
A new project has no name until someone names it: `init`, `clone` and
|
|
42
|
+
`publish` print its name as `projectName`, null until then. Once you know
|
|
43
|
+
what the app is, `teable-next rename "<name>"` names the project after it.
|
|
36
44
|
|
|
37
45
|
## Signing in
|
|
38
46
|
|
|
@@ -45,4 +53,5 @@ give it your projects with base read and update. Teable is
|
|
|
45
53
|
says otherwise; `TEABLE_NEXT_ENDPOINT` says where teable-next itself is
|
|
46
54
|
served (its runtime's API and the builder), when that is another address.
|
|
47
55
|
|
|
48
|
-
Publishing
|
|
56
|
+
Publishing and renaming take the creator or owner role in the project's
|
|
57
|
+
space.
|
package/dist/cli.js
CHANGED
|
@@ -329,6 +329,9 @@ function field(answer, name, what) {
|
|
|
329
329
|
return value;
|
|
330
330
|
}
|
|
331
331
|
var projectPath = (projectId) => `/base/${encodeURIComponent(projectId)}`;
|
|
332
|
+
function nameOf(project) {
|
|
333
|
+
return typeof project.name === "string" && project.name.trim() !== "" ? project.name : null;
|
|
334
|
+
}
|
|
332
335
|
async function currentUser(teable) {
|
|
333
336
|
const user = await request(teable, "GET", "/auth/user");
|
|
334
337
|
return {
|
|
@@ -339,14 +342,18 @@ async function currentUser(teable) {
|
|
|
339
342
|
}
|
|
340
343
|
async function teableNextProject(teable, projectId) {
|
|
341
344
|
const project = await request(teable, "GET", projectPath(projectId));
|
|
342
|
-
const name =
|
|
345
|
+
const name = nameOf(project);
|
|
343
346
|
if (project.runtime !== "next") {
|
|
344
347
|
throw new CommandError(
|
|
345
|
-
`Project ${projectId}${name ? ` ("${name}")`
|
|
348
|
+
`Project ${projectId}${name === null ? "" : ` ("${name}")`} does not run in teable-next, so it has no app of its own: it is a classic Teable project, and its apps are App Builder apps, which the \`teable\` CLI works on (\`teable app --help\`).`
|
|
346
349
|
);
|
|
347
350
|
}
|
|
348
351
|
return { id: projectId, name };
|
|
349
352
|
}
|
|
353
|
+
async function renameProject(teable, projectId, name) {
|
|
354
|
+
const project = await request(teable, "PATCH", projectPath(projectId), { name });
|
|
355
|
+
return { id: projectId, name: nameOf(project) };
|
|
356
|
+
}
|
|
350
357
|
async function identityToken(teable, projectId) {
|
|
351
358
|
const answer = await request(teable, "POST", `${projectPath(projectId)}/teable-next/identity`, {
|
|
352
359
|
delivery: "token"
|
|
@@ -788,6 +795,7 @@ async function publish(teable, cwd) {
|
|
|
788
795
|
stop({ step: "git" })
|
|
789
796
|
);
|
|
790
797
|
}
|
|
798
|
+
const project = await teableNextProject(teable, appId);
|
|
791
799
|
const remote = await fetchMain(root, await checkoutCredentials(root, appId, teable, "fetch"));
|
|
792
800
|
if (remote !== commit) {
|
|
793
801
|
throw new CommandError(await unpushedReason(root, commit, remote), stop({ step: "git" }));
|
|
@@ -824,9 +832,11 @@ async function publish(teable, cwd) {
|
|
|
824
832
|
throw error;
|
|
825
833
|
}
|
|
826
834
|
const where = deployed.pagesUrl ? ` Its pages are at ${deployed.pagesUrl}.` : "";
|
|
835
|
+
const unnamed = project.name === null ? ` The project has no name yet: name it after the app, in the user's language, with \`teable-next rename "<name>"\`.` : "";
|
|
827
836
|
return {
|
|
828
837
|
success: true,
|
|
829
838
|
appId,
|
|
839
|
+
projectName: project.name,
|
|
830
840
|
dir: root,
|
|
831
841
|
version: deployed.version,
|
|
832
842
|
commitSha: commit,
|
|
@@ -834,7 +844,7 @@ async function publish(teable, cwd) {
|
|
|
834
844
|
urls: { ...appUrls(teable, appId), pages: deployed.pagesUrl },
|
|
835
845
|
...pages && { pages: { files: pages.size, uploaded, worker: worker !== null } },
|
|
836
846
|
...deployed.manifest && { deployed: deployed.manifest },
|
|
837
|
-
message: `Version ${deployed.version} of ${appId} is live, built from ${commit.slice(0, 8)} ("${subject}").${where}`
|
|
847
|
+
message: `Version ${deployed.version} of ${appId} is live, built from ${commit.slice(0, 8)} ("${subject}").${where}${unnamed}`
|
|
838
848
|
};
|
|
839
849
|
}
|
|
840
850
|
async function versions(teable, appId, limit) {
|
|
@@ -882,7 +892,7 @@ function workflow(root, pull2) {
|
|
|
882
892
|
];
|
|
883
893
|
}
|
|
884
894
|
function directoryFor(name, projectId) {
|
|
885
|
-
const slug = name.trim().replace(/[\\/:*?"<>|\s]+/g, "-").replace(/^[-.]+|-+$/g, "").toLowerCase();
|
|
895
|
+
const slug = (name ?? "").trim().replace(/[\\/:*?"<>|\s]+/g, "-").replace(/^[-.]+|-+$/g, "").toLowerCase();
|
|
886
896
|
return slug || projectId;
|
|
887
897
|
}
|
|
888
898
|
var NO_GIT_IDENTITY = /Please tell me who you are|empty ident|unable to auto-detect email|no email was given/i;
|
|
@@ -966,7 +976,7 @@ async function init(teable, input) {
|
|
|
966
976
|
return {
|
|
967
977
|
success: true,
|
|
968
978
|
appId,
|
|
969
|
-
|
|
979
|
+
projectName: project.name,
|
|
970
980
|
dir: root,
|
|
971
981
|
commitSha,
|
|
972
982
|
createApp: `@teable/create-app@${version2}`,
|
|
@@ -991,7 +1001,8 @@ async function clone(teable, input) {
|
|
|
991
1001
|
} catch (error) {
|
|
992
1002
|
if (/Remote branch \S+ not found|empty repository/i.test(messageOf(error))) {
|
|
993
1003
|
throw new CommandError(
|
|
994
|
-
`The project has no code yet. Start it with \`teable-next init <dir> --project ${appId}
|
|
1004
|
+
`The project has no code yet. Start it with \`teable-next init <dir> --project ${appId}\`.`,
|
|
1005
|
+
{ code: "NO_CODE" }
|
|
995
1006
|
);
|
|
996
1007
|
}
|
|
997
1008
|
throw error;
|
|
@@ -1006,7 +1017,7 @@ async function clone(teable, input) {
|
|
|
1006
1017
|
return {
|
|
1007
1018
|
success: true,
|
|
1008
1019
|
appId,
|
|
1009
|
-
|
|
1020
|
+
projectName: project.name,
|
|
1010
1021
|
dir: root,
|
|
1011
1022
|
commitSha,
|
|
1012
1023
|
nextSteps: workflow(root, true),
|
|
@@ -1145,7 +1156,8 @@ it goes on from the scaffold. A project whose repository has code is cloned inst
|
|
|
1145
1156
|
usage: "clone <projectId> [dir]",
|
|
1146
1157
|
summary: "Check out the project's app",
|
|
1147
1158
|
details: `Clones the project's repository into [dir] (default: a new directory named after the project),
|
|
1148
|
-
its remote named \`teable\`. The repository is the whole app
|
|
1159
|
+
its remote named \`teable\`. The repository is the whole app. A project with no code yet fails with
|
|
1160
|
+
code NO_CODE: start its app with \`teable-next init\`.`,
|
|
1149
1161
|
options: {},
|
|
1150
1162
|
optionHelp: [],
|
|
1151
1163
|
takes: [1, 2],
|
|
@@ -1182,7 +1194,8 @@ pushed since your last pull. Nothing is deployed: \`teable-next publish\` deploy
|
|
|
1182
1194
|
pages and the app's own Worker (dist/worker.js, if any), with the commit's id and subject. The
|
|
1183
1195
|
runtime runs the version's migrations on a copy of the live data, then on the live data, and
|
|
1184
1196
|
makes it live, with its pages, only if both work.
|
|
1185
|
-
Prints the version
|
|
1197
|
+
Prints the version, the project's name (null until someone names it) and the app's URLs (its pages
|
|
1198
|
+
at its own host, builder, API, OpenAPI, MCP).
|
|
1186
1199
|
Publish each change once it is checked: no approval is needed. Publishing takes the creator or
|
|
1187
1200
|
owner role in the project's space.
|
|
1188
1201
|
TEABLE_NEXT_ENDPOINT points it at another runtime (a local one); by default the runtime is under
|
|
@@ -1224,6 +1237,25 @@ app repository is unchanged: fix or revert the code there before the next publis
|
|
|
1224
1237
|
return rollBack(teable, await appOf(teable, values), to);
|
|
1225
1238
|
}
|
|
1226
1239
|
},
|
|
1240
|
+
rename: {
|
|
1241
|
+
usage: 'rename "<name>" [--project <projectId>]',
|
|
1242
|
+
summary: "Name the project, as its space lists it",
|
|
1243
|
+
details: `Names the project (the app) on Teable: the name its space lists and the builder shows. A project
|
|
1244
|
+
nobody named has none: init, clone and publish print its projectName as null. Once you know what
|
|
1245
|
+
the app is, name it after the app, in the user's language; rename a project that has a name only
|
|
1246
|
+
when asked to. The name is trimmed, and cannot be empty. Prints the name Teable kept. Renaming
|
|
1247
|
+
takes the creator or owner role in the project's space.`,
|
|
1248
|
+
options: { project: { type: "string" } },
|
|
1249
|
+
optionHelp: [PROJECT_OPTION],
|
|
1250
|
+
takes: [1, 1],
|
|
1251
|
+
run: async (values, [given = ""]) => {
|
|
1252
|
+
const name = given.trim();
|
|
1253
|
+
if (name === "") throw new CommandError('rename needs a name: teable-next rename "<name>".');
|
|
1254
|
+
const teable = teableOf(values);
|
|
1255
|
+
const project = await renameProject(teable, await appOf(teable, values), name);
|
|
1256
|
+
return { success: true, project };
|
|
1257
|
+
}
|
|
1258
|
+
},
|
|
1227
1259
|
whoami: {
|
|
1228
1260
|
usage: "whoami",
|
|
1229
1261
|
summary: "Who your token belongs to",
|
package/dist/platform.d.ts
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
*
|
|
6
6
|
* - `GET /api/auth/user`: who the token belongs to.
|
|
7
7
|
* - `GET /api/base/:projectId`: the project; `runtime: "next"` when it runs in teable-next.
|
|
8
|
+
* - `PATCH /api/base/:projectId` with `{"name"}`: names the project, for its space's
|
|
9
|
+
* owners and creators (`base|update`); answers the name it keeps.
|
|
8
10
|
* - `POST /api/base/:projectId/teable-next/identity` with `{"delivery":"token"}`:
|
|
9
11
|
* a 15-minute identity token for the runtime, good for every app of the project's space.
|
|
10
12
|
* - `POST /api/base/:projectId/teable-next/git/credentials` with `{"ops":"fetch"|"push"}`:
|
|
@@ -25,7 +27,15 @@ export declare function currentUser(teable: Teable): Promise<{
|
|
|
25
27
|
*/
|
|
26
28
|
export declare function teableNextProject(teable: Teable, projectId: string): Promise<{
|
|
27
29
|
id: string;
|
|
28
|
-
name: string;
|
|
30
|
+
name: string | null;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Name the project: the name its space lists and the builder shows. Its
|
|
34
|
+
* space's owners and creators may; the platform refuses anyone else.
|
|
35
|
+
*/
|
|
36
|
+
export declare function renameProject(teable: Teable, projectId: string, name: string): Promise<{
|
|
37
|
+
id: string;
|
|
38
|
+
name: string | null;
|
|
29
39
|
}>;
|
|
30
40
|
/** A 15-minute identity token for the runtime, for the space of the project. */
|
|
31
41
|
export declare function identityToken(teable: Teable, projectId: string): Promise<string>;
|
package/dist/publish.d.ts
CHANGED
package/dist/repository.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare function init(teable: Teable, input: {
|
|
|
15
15
|
}): Promise<{
|
|
16
16
|
success: boolean;
|
|
17
17
|
appId: string;
|
|
18
|
-
|
|
18
|
+
projectName: string | null;
|
|
19
19
|
dir: string;
|
|
20
20
|
commitSha: string;
|
|
21
21
|
createApp: string;
|
|
@@ -29,7 +29,7 @@ export declare function clone(teable: Teable, input: {
|
|
|
29
29
|
}): Promise<{
|
|
30
30
|
success: boolean;
|
|
31
31
|
appId: string;
|
|
32
|
-
|
|
32
|
+
projectName: string | null;
|
|
33
33
|
dir: string;
|
|
34
34
|
commitSha: string;
|
|
35
35
|
nextSteps: string[];
|