@adep/cli 0.1.5 → 0.1.7
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/index.js +166 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6708,6 +6708,15 @@ async function projectsCreate(paths, options) {
|
|
|
6708
6708
|
const name = options.name ?? slug;
|
|
6709
6709
|
const body = { slug, name };
|
|
6710
6710
|
if (options.spaceId !== void 0) body.spaceId = options.spaceId;
|
|
6711
|
+
if (options.gitRepoUrl !== void 0 && options.gitBranch !== void 0) {
|
|
6712
|
+
body.git = {
|
|
6713
|
+
repoUrl: options.gitRepoUrl,
|
|
6714
|
+
branch: options.gitBranch,
|
|
6715
|
+
...options.gitFunctionRoot === void 0 ? {} : { functionRoot: options.gitFunctionRoot },
|
|
6716
|
+
...options.gitUsername === void 0 ? {} : { authUsername: options.gitUsername },
|
|
6717
|
+
...options.gitToken === void 0 ? {} : { authToken: options.gitToken }
|
|
6718
|
+
};
|
|
6719
|
+
}
|
|
6711
6720
|
const created = await client.request(
|
|
6712
6721
|
"/api/v1/projects",
|
|
6713
6722
|
{ body },
|
|
@@ -6750,6 +6759,70 @@ var init_projects = __esm({
|
|
|
6750
6759
|
}
|
|
6751
6760
|
});
|
|
6752
6761
|
|
|
6762
|
+
// packages/cli/src/git.ts
|
|
6763
|
+
var git_exports = {};
|
|
6764
|
+
__export(git_exports, {
|
|
6765
|
+
gitBind: () => gitBind,
|
|
6766
|
+
gitStatus: () => gitStatus,
|
|
6767
|
+
gitSync: () => gitSync
|
|
6768
|
+
});
|
|
6769
|
+
async function resolveProjectId3(client, cwd, slug) {
|
|
6770
|
+
const resolvedSlug = await resolveSlug(cwd, slug);
|
|
6771
|
+
const listed = await client.request("/api/v1/projects", {}, "PROJECT_LIST_FAILED");
|
|
6772
|
+
const match = listed.projects.find((project2) => project2.slug === resolvedSlug);
|
|
6773
|
+
if (match === void 0) {
|
|
6774
|
+
throw new CliError(
|
|
6775
|
+
"PROJECT_NOT_FOUND",
|
|
6776
|
+
`\u5E73\u53F0\u9879\u76EE "${resolvedSlug}" \u4E0D\u5B58\u5728\u6216\u4F60\u6CA1\u6709\u8BBF\u95EE\u6743\u9650\uFF1A\u5148\u6267\u884C adep projects create ${resolvedSlug}`
|
|
6777
|
+
);
|
|
6778
|
+
}
|
|
6779
|
+
return { id: match.id, slug: match.slug };
|
|
6780
|
+
}
|
|
6781
|
+
async function gitBind(paths, options) {
|
|
6782
|
+
const client = await createClient(paths);
|
|
6783
|
+
const { id } = await resolveProjectId3(client, options.cwd, options.slug);
|
|
6784
|
+
const body = {
|
|
6785
|
+
repoUrl: options.repoUrl,
|
|
6786
|
+
branch: options.branch
|
|
6787
|
+
};
|
|
6788
|
+
if (options.functionRoot !== void 0) body.functionRoot = options.functionRoot;
|
|
6789
|
+
if (options.syncEnabled !== void 0) body.syncEnabled = options.syncEnabled;
|
|
6790
|
+
if (options.username !== void 0) body.authUsername = options.username;
|
|
6791
|
+
if (options.token !== void 0) body.authToken = options.token;
|
|
6792
|
+
const view = await client.request(
|
|
6793
|
+
`/api/v1/projects/${id}/gitsync/bind`,
|
|
6794
|
+
{ body },
|
|
6795
|
+
"GIT_BIND_FAILED"
|
|
6796
|
+
);
|
|
6797
|
+
return view;
|
|
6798
|
+
}
|
|
6799
|
+
async function gitSync(paths, options) {
|
|
6800
|
+
const client = await createClient(paths);
|
|
6801
|
+
const { id } = await resolveProjectId3(client, options.cwd, options.slug);
|
|
6802
|
+
const result = await client.request(
|
|
6803
|
+
`/api/v1/projects/${id}/gitsync/sync`,
|
|
6804
|
+
{ body: {} },
|
|
6805
|
+
"GIT_SYNC_FAILED"
|
|
6806
|
+
);
|
|
6807
|
+
return { jobId: result.jobId };
|
|
6808
|
+
}
|
|
6809
|
+
async function gitStatus(paths, options) {
|
|
6810
|
+
const client = await createClient(paths);
|
|
6811
|
+
const { id } = await resolveProjectId3(client, options.cwd, options.slug);
|
|
6812
|
+
return client.request(
|
|
6813
|
+
`/api/v1/projects/${id}/gitsync`,
|
|
6814
|
+
{},
|
|
6815
|
+
"GIT_STATUS_FAILED"
|
|
6816
|
+
);
|
|
6817
|
+
}
|
|
6818
|
+
var init_git = __esm({
|
|
6819
|
+
"packages/cli/src/git.ts"() {
|
|
6820
|
+
"use strict";
|
|
6821
|
+
init_auth();
|
|
6822
|
+
init_client();
|
|
6823
|
+
}
|
|
6824
|
+
});
|
|
6825
|
+
|
|
6753
6826
|
// packages/cli/src/functions.ts
|
|
6754
6827
|
var functions_exports = {};
|
|
6755
6828
|
__export(functions_exports, {
|
|
@@ -9199,18 +9272,25 @@ function registerMcp(program2, ctx) {
|
|
|
9199
9272
|
// packages/cli/src/commands/projects.ts
|
|
9200
9273
|
function registerProjects(program2, ctx) {
|
|
9201
9274
|
const projects = program2.command("projects").description("\u9879\u76EE\uFF1A\u521B\u5EFA / \u5217\u51FA / \u67E5\u770B\uFF08\u5B50\u57DF\u5730\u5740\u7531\u5E73\u53F0\u56DE\u663E\uFF0C\u4E0D\u5728 CLI \u4FA7\u62FC\uFF09");
|
|
9202
|
-
projects.command("create").description("\u521B\u5EFA\u9879\u76EE\u5E76\u8F93\u51FA\u5B50\u57DF\u5730\u5740").argument("<slug>", "\u9879\u76EE slug\uFF08\u5168\u5C40\u552F\u4E00\uFF0C\u5373\u5B50\u57DF\u540D\uFF09").option("-n, --name <name>", "\u9879\u76EE\u5C55\u793A\u540D\uFF08\u7F3A\u7701\u53D6 slug\uFF09").option("--space <spaceId>", "\u5F52\u5C5E\u7A7A\u95F4\uFF08\u7F3A\u7701\u4E2A\u4EBA\u7A7A\u95F4\uFF09").
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
|
|
9209
|
-
|
|
9275
|
+
projects.command("create").description("\u521B\u5EFA\u9879\u76EE\u5E76\u8F93\u51FA\u5B50\u57DF\u5730\u5740").argument("<slug>", "\u9879\u76EE slug\uFF08\u5168\u5C40\u552F\u4E00\uFF0C\u5373\u5B50\u57DF\u540D\uFF09").option("-n, --name <name>", "\u9879\u76EE\u5C55\u793A\u540D\uFF08\u7F3A\u7701\u53D6 slug\uFF09").option("--space <spaceId>", "\u5F52\u5C5E\u7A7A\u95F4\uFF08\u7F3A\u7701\u4E2A\u4EBA\u7A7A\u95F4\uFF09").option("--git <repoUrl>", "\u4ECE Git \u4ED3\u5E93\u521B\u5EFA\uFF08\u521B\u5EFA\u540E\u7ED1\u5B9A + \u9996\u6B21\u540C\u6B65/\u90E8\u7F72\uFF09").option("-b, --branch <branch>", "Git \u5206\u652F\uFF08\u914D\u5408 --git\uFF0C\u7F3A\u7701 main\uFF09").option("--username <username>", "Git \u79C1\u6709\u4ED3\u5E93\u7528\u6237\u540D\uFF08\u914D\u5408 --git\uFF09").option("--token <token>", "Git \u79C1\u6709\u4ED3\u5E93\u8BBF\u95EE\u4EE4\u724C\uFF08\u914D\u5408 --git\uFF0C\u5E73\u53F0\u52A0\u5BC6\u843D\u5E93\uFF09").option("--function-root <root>", "legacy \u5E03\u5C40\u51FD\u6570\u6839\u76EE\u5F55\uFF08\u914D\u5408 --git\uFF0C\u7F3A\u7701\u5E94\u7528\u5E03\u5C40\u81EA\u52A8\u63A2\u6D4B\uFF09").action(
|
|
9276
|
+
async (slug, flags) => {
|
|
9277
|
+
const command = ctx.io("projects create");
|
|
9278
|
+
await command.run(async () => {
|
|
9279
|
+
const { projectsCreate: projectsCreate2 } = await Promise.resolve().then(() => (init_projects(), projects_exports));
|
|
9280
|
+
const created = await projectsCreate2(ctx.paths, {
|
|
9281
|
+
slug,
|
|
9282
|
+
...flags.name === void 0 ? {} : { name: flags.name },
|
|
9283
|
+
...flags.space === void 0 ? {} : { spaceId: flags.space },
|
|
9284
|
+
...flags.git === void 0 ? {} : { gitRepoUrl: flags.git },
|
|
9285
|
+
...flags.git === void 0 ? {} : { gitBranch: flags.branch ?? "main" },
|
|
9286
|
+
...flags.username === void 0 ? {} : { gitUsername: flags.username },
|
|
9287
|
+
...flags.token === void 0 ? {} : { gitToken: flags.token },
|
|
9288
|
+
...flags.functionRoot === void 0 ? {} : { gitFunctionRoot: flags.functionRoot }
|
|
9289
|
+
});
|
|
9290
|
+
command.ok(created, (data) => `\u2713 Project created \xB7 ${data.url}`);
|
|
9210
9291
|
});
|
|
9211
|
-
|
|
9212
|
-
|
|
9213
|
-
});
|
|
9292
|
+
}
|
|
9293
|
+
);
|
|
9214
9294
|
projects.command("list").description("\u5217\u51FA\u5F53\u524D\u7528\u6237\u53EF\u8BBF\u95EE\u7684\u9879\u76EE").action(async () => {
|
|
9215
9295
|
const command = ctx.io("projects list");
|
|
9216
9296
|
await command.run(async () => {
|
|
@@ -9236,6 +9316,80 @@ function registerProjects(program2, ctx) {
|
|
|
9236
9316
|
});
|
|
9237
9317
|
}
|
|
9238
9318
|
|
|
9319
|
+
// packages/cli/src/commands/git.ts
|
|
9320
|
+
function registerGit(program2, ctx) {
|
|
9321
|
+
const git = program2.command("git").description("Git \u4ED3\u5E93\u7ED1\u5B9A\uFF1A\u7ED1\u5B9A / \u624B\u52A8\u540C\u6B65 / \u67E5\u770B\u72B6\u6001\uFF08push \u5230 main \u81EA\u52A8\u90E8\u7F72\uFF09");
|
|
9322
|
+
git.command("bind").description("\u7ED1\u5B9A/\u66F4\u65B0\u9879\u76EE Git \u4ED3\u5E93\uFF08\u6D45\u5C42 clone \u6821\u9A8C\u8FDE\u901A\u6027\uFF0C\u652F\u6301\u79C1\u6709\u4ED3\u5E93\u51ED\u636E\uFF09").argument("<repoUrl>", "\u4ED3\u5E93\u5730\u5740\uFF08https://\u2026\uFF0C\u79C1\u6709\u4ED3\u5E93\u4F20 --username/--token\uFF09").requiredOption("-b, --branch <branch>", "\u7ED1\u5B9A\u5206\u652F\uFF08\u7F3A\u7701 main\uFF09").option("--slug <slug>", "\u5E73\u53F0\u9879\u76EE slug\uFF08\u7F3A\u7701\u8BFB adep.config.ts / \u5F53\u524D\u76EE\u5F55\u540D\uFF09").option("--function-root <dir>", "legacy \u5E03\u5C40\u51FD\u6570\u6839\u76EE\u5F55\uFF08\u5E94\u7528\u5E03\u5C40\u65E0\u9700\u4F20\uFF09").option("--no-sync", "\u7ED1\u5B9A\u4F46\u4E0D\u542F\u7528\u81EA\u52A8\u540C\u6B65").option("-u, --username <username>", "\u79C1\u6709\u4ED3\u5E93\u7528\u6237\u540D").option("-t, --token <token>", "\u79C1\u6709\u4ED3\u5E93\u8BBF\u95EE\u4EE4\u724C\uFF08\u660E\u6587\u53EA\u5728\u8BF7\u6C42\u5185\u4F20\u8F93\uFF0C\u670D\u52A1\u7AEF\u52A0\u5BC6\u843D\u5E93\uFF09").action(
|
|
9323
|
+
async (repoUrl, flags) => {
|
|
9324
|
+
const command = ctx.io("git bind");
|
|
9325
|
+
await command.run(async () => {
|
|
9326
|
+
const { gitBind: gitBind2 } = await Promise.resolve().then(() => (init_git(), git_exports));
|
|
9327
|
+
const view = await gitBind2(ctx.paths, {
|
|
9328
|
+
cwd: ctx.cwd,
|
|
9329
|
+
repoUrl,
|
|
9330
|
+
branch: flags.branch,
|
|
9331
|
+
...flags.slug === void 0 ? {} : { slug: flags.slug },
|
|
9332
|
+
...flags.functionRoot === void 0 ? {} : { functionRoot: flags.functionRoot },
|
|
9333
|
+
...flags.sync === void 0 ? {} : { syncEnabled: flags.sync },
|
|
9334
|
+
...flags.username === void 0 ? {} : { username: flags.username },
|
|
9335
|
+
...flags.token === void 0 ? {} : { token: flags.token }
|
|
9336
|
+
});
|
|
9337
|
+
command.ok(view, (data) => {
|
|
9338
|
+
const v = data;
|
|
9339
|
+
const auth = v.hasAuth ? "\u79C1\u6709\u51ED\u636E" : "\u516C\u5F00";
|
|
9340
|
+
const last = v.lastStatus === null ? "\u672A\u540C\u6B65" : `${v.lastStatus.state} \xB7 ${v.lastStatus.description}`;
|
|
9341
|
+
return [
|
|
9342
|
+
`\u2713 Git \u5DF2\u7ED1\u5B9A \xB7 ${v.repoUrl} \u2192 ${v.branch}\uFF08${auth}\uFF09`,
|
|
9343
|
+
` \u81EA\u52A8\u540C\u6B65\uFF1A${v.syncEnabled ? "\u5F00\uFF08push \u540E \u226460s \u81EA\u52A8\u90E8\u7F72\uFF09" : "\u5173"}`,
|
|
9344
|
+
` \u6700\u8FD1\u72B6\u6001\uFF1A${last}`
|
|
9345
|
+
].join("\n");
|
|
9346
|
+
});
|
|
9347
|
+
});
|
|
9348
|
+
}
|
|
9349
|
+
);
|
|
9350
|
+
git.command("sync").description("\u624B\u52A8\u89E6\u53D1\u4E00\u6B21 Git \u540C\u6B65 + \u81EA\u52A8\u90E8\u7F72\uFF08\u672C\u5730\u5E73\u53F0\u65E0 webhook \u53EF\u8FBE\u65F6\u7528\uFF09").option("--slug <slug>", "\u5E73\u53F0\u9879\u76EE slug\uFF08\u7F3A\u7701\u8BFB adep.config.ts / \u5F53\u524D\u76EE\u5F55\u540D\uFF09").action(async (flags) => {
|
|
9351
|
+
const command = ctx.io("git sync");
|
|
9352
|
+
await command.run(async () => {
|
|
9353
|
+
const { gitSync: gitSync2 } = await Promise.resolve().then(() => (init_git(), git_exports));
|
|
9354
|
+
const result = await gitSync2(ctx.paths, {
|
|
9355
|
+
cwd: ctx.cwd,
|
|
9356
|
+
...flags.slug === void 0 ? {} : { slug: flags.slug }
|
|
9357
|
+
});
|
|
9358
|
+
command.ok(
|
|
9359
|
+
result,
|
|
9360
|
+
(data) => `\u2713 \u5DF2\u89E6\u53D1 Git \u540C\u6B65 + \u90E8\u7F72\uFF08job ${data.jobId}\uFF09`
|
|
9361
|
+
);
|
|
9362
|
+
});
|
|
9363
|
+
});
|
|
9364
|
+
git.command("status").description("\u67E5\u770B\u7ED1\u5B9A\u4E0E\u6700\u8FD1\u4E00\u6B21\u540C\u6B65/\u90E8\u7F72\u72B6\u6001").option("--slug <slug>", "\u5E73\u53F0\u9879\u76EE slug\uFF08\u7F3A\u7701\u8BFB adep.config.ts / \u5F53\u524D\u76EE\u5F55\u540D\uFF09").action(async (flags) => {
|
|
9365
|
+
const command = ctx.io("git status");
|
|
9366
|
+
await command.run(async () => {
|
|
9367
|
+
const { gitStatus: gitStatus2 } = await Promise.resolve().then(() => (init_git(), git_exports));
|
|
9368
|
+
const view = await gitStatus2(ctx.paths, {
|
|
9369
|
+
cwd: ctx.cwd,
|
|
9370
|
+
...flags.slug === void 0 ? {} : { slug: flags.slug }
|
|
9371
|
+
});
|
|
9372
|
+
if (view === null) {
|
|
9373
|
+
command.ok(null, () => "\u672A\u7ED1\u5B9A Git \u4ED3\u5E93\uFF1Aadep git bind <repoUrl> -b main");
|
|
9374
|
+
return;
|
|
9375
|
+
}
|
|
9376
|
+
command.ok(view, (data) => {
|
|
9377
|
+
const v = data;
|
|
9378
|
+
const auth = v.hasAuth ? "\u79C1\u6709\u51ED\u636E" : "\u516C\u5F00";
|
|
9379
|
+
const last = v.lastStatus === null ? "\u672A\u540C\u6B65" : `${v.lastStatus.state} \xB7 ${v.lastStatus.description}`;
|
|
9380
|
+
const commit = v.lastSyncedCommit === null ? "\u2014" : v.lastSyncedCommit.slice(0, 8);
|
|
9381
|
+
return [
|
|
9382
|
+
`\u4ED3\u5E93 ${v.repoUrl}`,
|
|
9383
|
+
`\u5206\u652F ${v.branch}\uFF08${auth}\uFF09`,
|
|
9384
|
+
`\u81EA\u52A8\u540C\u6B65 ${v.syncEnabled ? "\u5F00" : "\u5173"}`,
|
|
9385
|
+
`\u6700\u8FD1\u540C\u6B65 ${commit}`,
|
|
9386
|
+
`\u6700\u8FD1\u72B6\u6001 ${last}`
|
|
9387
|
+
].join("\n");
|
|
9388
|
+
});
|
|
9389
|
+
});
|
|
9390
|
+
});
|
|
9391
|
+
}
|
|
9392
|
+
|
|
9239
9393
|
// packages/cli/src/commands/functions.ts
|
|
9240
9394
|
init_auth();
|
|
9241
9395
|
function registerFunctions(program2, ctx) {
|
|
@@ -9401,6 +9555,7 @@ function buildProgram(options = {}) {
|
|
|
9401
9555
|
registerDoctor(program2, ctx);
|
|
9402
9556
|
registerAuth(program2, ctx);
|
|
9403
9557
|
registerMcp(program2, ctx);
|
|
9558
|
+
registerGit(program2, ctx);
|
|
9404
9559
|
registerDeploy(program2, ctx);
|
|
9405
9560
|
registerProjects(program2, ctx);
|
|
9406
9561
|
registerFunctions(program2, ctx);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adep/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "`adep` 命令行工具包位:登录 / 初始化 / 本地调试 / 部署 / 数据库维护 / 云存储 / 静态托管 / 微前端组件(widget),实现见任务单 CLI-001 ~ CLI-003 与 FE-002;子路径 `@adep/cli/vite` 提供云函数 vite 插件(CLI-014)",
|
|
6
6
|
"bin": {
|