@keystrokehq/cli 0.0.128 → 0.0.129

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.mjs CHANGED
@@ -2103,6 +2103,10 @@ const CreateProjectRequestSchema = object({
2103
2103
  name: string().trim().min(1),
2104
2104
  description: string().trim().min(1).optional()
2105
2105
  });
2106
+ const UpdateProjectRequestSchema = object({
2107
+ name: string().trim().min(1).optional(),
2108
+ description: string().trim().optional()
2109
+ }).refine((data) => data.name !== void 0 || data.description !== void 0, { message: "At least one field is required" });
2106
2110
  const CreateProjectResponseSchema = object({ project: ProjectSchema });
2107
2111
  const ProjectResponseSchema = object({ project: ProjectSchema });
2108
2112
  const ProjectReachabilityResponseSchema = object({ reachable: boolean() });
@@ -5115,16 +5119,22 @@ function createProjectsResource(http) {
5115
5119
  throw await toPlatformError(error);
5116
5120
  }
5117
5121
  },
5118
- update: mock({
5119
- domain: "projects",
5120
- method: "update",
5121
- plannedEndpoint: "PATCH /api/projects/:id"
5122
- }, async (projectId, patch) => {
5123
- return {
5124
- id: projectId,
5125
- ...patch
5126
- };
5127
- }),
5122
+ async update(projectId, patch) {
5123
+ const body = UpdateProjectRequestSchema.parse(patch);
5124
+ try {
5125
+ const data = await http.patch(`/api/projects/${encodeURIComponent(projectId)}`, { json: body }).json();
5126
+ return ProjectResponseSchema.parse(data).project;
5127
+ } catch (error) {
5128
+ throw await toPlatformError(error);
5129
+ }
5130
+ },
5131
+ async delete(projectId) {
5132
+ try {
5133
+ await http.delete(`/api/projects/${encodeURIComponent(projectId)}`);
5134
+ } catch (error) {
5135
+ throw await toPlatformError(error);
5136
+ }
5137
+ },
5128
5138
  async checkReachability(projectId) {
5129
5139
  try {
5130
5140
  const data = await http.get(`/api/projects/${encodeURIComponent(projectId)}/reachability`, { timeout: PROJECT_REACHABILITY_REQUEST_TIMEOUT_MS }).json();
@@ -8771,6 +8781,9 @@ function setCliTargetOptions(options) {
8771
8781
  function getCliTargetOptions() {
8772
8782
  return targetOptions;
8773
8783
  }
8784
+ function resolveActiveProjectId(config) {
8785
+ return getCliTargetOptions().projectId ?? config.get("activeProjectId");
8786
+ }
8774
8787
  //#endregion
8775
8788
  //#region src/errors/example-input.ts
8776
8789
  function exampleValueFromValidationMessage(message) {
@@ -9570,8 +9583,7 @@ async function runDeploy(options) {
9570
9583
  function registerDeployCommand(program) {
9571
9584
  program.command("deploy").description("Build, upload, and deploy the project to the platform").option("--dir <path>", "Project directory", process.cwd()).option("--skip-build", "Upload the existing dist/ without rebuilding").action(async (options) => {
9572
9585
  try {
9573
- const config = createCliConfig();
9574
- const projectId = getCliTargetOptions().projectId ?? config.get("activeProjectId");
9586
+ const projectId = resolveActiveProjectId(createCliConfig());
9575
9587
  if (!projectId) throw new Error("Usage: keystroke deploy --project <id>");
9576
9588
  await runDeploy({
9577
9589
  dir: options.dir,
@@ -10154,10 +10166,23 @@ async function runProjectCreate(config, input) {
10154
10166
  writeInactiveDeployHints([project]);
10155
10167
  });
10156
10168
  }
10169
+ async function runProjectUpdate(config, input) {
10170
+ await withActivePlatformClient(config, async (platform) => {
10171
+ const { projectId, ...patch } = input;
10172
+ const project = await platform.projects.update(projectId, patch);
10173
+ process.stdout.write(`${JSON.stringify({ project }, null, 2)}\n`);
10174
+ });
10175
+ }
10176
+ async function runProjectDelete(config, projectId) {
10177
+ await withActivePlatformClient(config, async (platform) => {
10178
+ await platform.projects.delete(projectId);
10179
+ process.stdout.write(`${JSON.stringify({ deleted: projectId }, null, 2)}\n`);
10180
+ });
10181
+ }
10157
10182
  //#endregion
10158
10183
  //#region src/commands/project/index.ts
10159
10184
  function registerProjectCommand(program) {
10160
- const project = program.command("project").description("List and create platform projects");
10185
+ const project = program.command("project").description("List, create, update, and delete platform projects");
10161
10186
  project.command("list").description("List projects in the active organization").action(async () => {
10162
10187
  const config = createCliConfig();
10163
10188
  try {
@@ -10185,6 +10210,40 @@ function registerProjectCommand(program) {
10185
10210
  process.exitCode = 1;
10186
10211
  }
10187
10212
  });
10213
+ project.command("update").description("Update a platform project's name and/or description").option("--name <name>", "Project name").option("--description <description>", "Project description").action(async (options) => {
10214
+ const config = createCliConfig();
10215
+ try {
10216
+ const projectId = resolveActiveProjectId(config);
10217
+ if (!projectId) throw new Error("Usage: keystroke --project <id> project update --name <name>");
10218
+ if (!options.name && options.description === void 0) throw new Error("At least one of --name or --description is required");
10219
+ await runProjectUpdate(config, {
10220
+ projectId,
10221
+ ...options.name ? { name: options.name } : {},
10222
+ ...options.description !== void 0 ? { description: options.description } : {}
10223
+ });
10224
+ } catch (error) {
10225
+ process.stderr.write(`${formatCliError(error, "Update project failed", {
10226
+ serverUrl: getPlatformUrl(config),
10227
+ webUrl: getWebUrl(config)
10228
+ })}\n`);
10229
+ process.exitCode = 1;
10230
+ }
10231
+ });
10232
+ project.command("delete").description("Delete a platform project").option("-y, --yes", "Skip confirmation prompt").action(async (options) => {
10233
+ const config = createCliConfig();
10234
+ try {
10235
+ const projectId = resolveActiveProjectId(config);
10236
+ if (!projectId) throw new Error("Usage: keystroke --project <id> project delete");
10237
+ if (!options.yes) throw new Error("Pass --yes to confirm project deletion");
10238
+ await runProjectDelete(config, projectId);
10239
+ } catch (error) {
10240
+ process.stderr.write(`${formatCliError(error, "Delete project failed", {
10241
+ serverUrl: getPlatformUrl(config),
10242
+ webUrl: getWebUrl(config)
10243
+ })}\n`);
10244
+ process.exitCode = 1;
10245
+ }
10246
+ });
10188
10247
  }
10189
10248
  //#endregion
10190
10249
  //#region src/commands/start.ts