@cadiraca/crowntrack-cli 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -71,6 +71,11 @@ async function addNote(projectId, content) {
71
71
  body: JSON.stringify({ content })
72
72
  });
73
73
  }
74
+ async function deleteProject(id, confirm) {
75
+ return request(`/api/projects/${id}?confirm=${encodeURIComponent(confirm)}`, {
76
+ method: "DELETE"
77
+ });
78
+ }
74
79
  async function getStats() {
75
80
  return request("/api/stats");
76
81
  }
@@ -269,6 +274,19 @@ update.command("project <id>").description("Update project fields").option("-s,
269
274
  handleError(e);
270
275
  }
271
276
  });
277
+ program.command("delete <id>").description("Delete a project (only if status=Idea, no actions, no notes)").requiredOption("--confirm <word>", "Magic word to confirm deletion").action(async (id, opts) => {
278
+ try {
279
+ const p = await resolveProject(id);
280
+ if (opts.confirm !== "hailtheking") {
281
+ console.log(chalk.red("\u2715") + " Wrong magic word. \u{1F451}");
282
+ process.exit(1);
283
+ }
284
+ const result = await deleteProject(p.id, opts.confirm);
285
+ console.log(chalk.green("\u2713") + ` Deleted project: ${amber(result.deleted || p.name)}`);
286
+ } catch (e) {
287
+ handleError(e);
288
+ }
289
+ });
272
290
  program.command("stats").description("Show KPI summary").action(async () => {
273
291
  try {
274
292
  const s = await getStats();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cadiraca/crowntrack-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "👑 CrownTrack CLI — Rule your projects from the terminal",
5
5
  "author": "Carlos Diego Ramírez <cadiraca>",
6
6
  "license": "MIT",