careervivid 1.7.0 → 1.8.0

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/api.d.ts CHANGED
@@ -20,6 +20,7 @@ export interface PublishResult {
20
20
  postId: string;
21
21
  url: string;
22
22
  message: string;
23
+ title?: string;
23
24
  }
24
25
  export interface VerifyResult {
25
26
  userId: string;
@@ -39,6 +40,7 @@ export interface ApiError {
39
40
  }[];
40
41
  }
41
42
  export declare function publishPost(payload: PublishPayload, dryRun?: boolean): Promise<PublishResult | ApiError>;
43
+ export declare function getPost(postId: string): Promise<PublishResult | ApiError>;
42
44
  export declare function updatePost(postId: string, payload: Partial<PublishPayload>): Promise<PublishResult | ApiError>;
43
45
  /**
44
46
  * Verify an API key against the /verifyAuth endpoint.
package/dist/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,YAAY,CAAC;AAChD,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;AAEhD,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb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AAE,GAAG,QAAQ,CAAC,CAEnJ;AAED,wBAAsB,uBAAuB,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,QAAQ,CAAC,CAEnK;AAED,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,QAAQ,CAAC,CAEpK;AAED,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,QAAQ,CAAC,CAEvJ;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,QAAQ,CAEpD"}
package/dist/api.js CHANGED
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { getApiKey, getApiUrl } from "./config.js";
8
8
  // ── Helpers ───────────────────────────────────────────────────────────────────
9
- const CLI_VERSION = "1.7.0";
9
+ const CLI_VERSION = "1.8.0";
10
10
  function requireApiKey() {
11
11
  const key = getApiKey();
12
12
  if (!key) {
@@ -73,6 +73,9 @@ export async function publishPost(payload, dryRun = false) {
73
73
  }
74
74
  return apiRequest("POST", "publish", payload);
75
75
  }
76
+ export async function getPost(postId) {
77
+ return apiRequest("GET", `publish/${postId}`);
78
+ }
76
79
  export async function updatePost(postId, payload) {
77
80
  return apiRequest("PATCH", "publish", { ...payload, postId });
78
81
  }
@@ -1 +1 @@
1
- {"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../src/commands/publish.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA8KpC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA6J7D"}
1
+ {"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../src/commands/publish.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA4MpC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA6J7D"}
@@ -57,13 +57,16 @@ async function publishSingleFile(filePath, content, opts, jsonMode) {
57
57
  let postId = undefined;
58
58
  let cleanContent = content;
59
59
  // Robust frontmatter extraction (multiline, flexible spacing)
60
- const frontmatterMatch = content.match(/^---\s*[\r\n]+([\s\S]*?)[\r\n]+---\s*[\r\n]+/);
60
+ // Matches --- start, any non-greedy content, and --- end with optional whitespace/newlines
61
+ const frontmatterMatch = content.match(/^---\s*[\r\n]+([\s\S]*?)[\r\n]+---/);
61
62
  if (frontmatterMatch) {
62
63
  const fm = frontmatterMatch[1];
63
64
  // Match postId with potential leading/trailing whitespace or quotes
64
65
  const idMatch = fm.match(/postId:\s*["']?([a-zA-Z0-9_-]+)["']?/i);
65
66
  postId = idMatch?.[1];
66
- cleanContent = content.slice(frontmatterMatch[0].length);
67
+ // Remove the frontmatter block AND any trailing whitespace/newlines
68
+ const afterFm = content.slice(frontmatterMatch[0].length);
69
+ cleanContent = afterFm.replace(/^\s+/, "");
67
70
  }
68
71
  // Fail if onlyUpdate is set but no postId is found
69
72
  if (opts.onlyUpdate && !postId) {
@@ -77,7 +80,7 @@ async function publishSingleFile(filePath, content, opts, jsonMode) {
77
80
  const type = opts.type || inferType(format);
78
81
  let title = opts.title || "";
79
82
  if (!title && format === "markdown") {
80
- const firstHeading = cleanContent.match(/^#\s+(.+)$/m);
83
+ const firstHeading = cleanContent.match(/^[#]{1,2}\s+(.+)$/m);
81
84
  if (firstHeading) {
82
85
  title = firstHeading[1].trim();
83
86
  }
@@ -112,7 +115,32 @@ async function publishSingleFile(filePath, content, opts, jsonMode) {
112
115
  };
113
116
  let result;
114
117
  if (postId && !dryRun) {
115
- const { updatePost } = await import("../api.js");
118
+ const { updatePost, getPost } = await import("../api.js");
119
+ // Best Practice: Fetch remote title to verify identity before overwrite
120
+ const remotePost = await getPost(postId);
121
+ if (!isApiError(remotePost)) {
122
+ const remoteTitle = remotePost.title;
123
+ // Case-insensitive title comparison to catch potential mixups
124
+ if (title && remoteTitle && title.toLowerCase() !== remoteTitle.toLowerCase()) {
125
+ if (jsonMode) {
126
+ console.error(chalk.red(`\n ✖ Title mismatch for ${postId}. Local: "${title}", Remote: "${remoteTitle}". Aborting.`));
127
+ return { success: false };
128
+ }
129
+ else {
130
+ const enquirer = (await import("enquirer"));
131
+ const prompt = enquirer.default?.prompt || enquirer.prompt;
132
+ const answers = await prompt({
133
+ type: "confirm",
134
+ name: "confirm",
135
+ message: `Title Mismatch! Local: "${chalk.cyan(title)}", Remote: "${chalk.yellow(remoteTitle)}". Continue?`,
136
+ initial: false
137
+ });
138
+ if (!answers.confirm) {
139
+ return { success: false };
140
+ }
141
+ }
142
+ }
143
+ }
116
144
  result = await updatePost(postId, payload);
117
145
  }
118
146
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "careervivid",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Official CLI for CareerVivid — publish articles, diagrams, and portfolio updates from your terminal or AI agent",
5
5
  "type": "module",
6
6
  "bin": {