pinme 2.0.0-beta.16 → 2.0.0-beta.18

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 +42 -109
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1775,7 +1775,7 @@ var import_chalk23 = __toESM(require("chalk"));
1775
1775
  var import_figlet5 = __toESM(require("figlet"));
1776
1776
 
1777
1777
  // package.json
1778
- var version = "2.0.0-beta.16";
1778
+ var version = "2.0.0-beta.18";
1779
1779
 
1780
1780
  // bin/upload.ts
1781
1781
  var import_path7 = __toESM(require("path"));
@@ -6772,7 +6772,7 @@ async function uploadToIpfsSplit_default(filePath, importAsCar = false) {
6772
6772
  }
6773
6773
  return null;
6774
6774
  } catch (error) {
6775
- return null;
6775
+ throw error;
6776
6776
  }
6777
6777
  }
6778
6778
 
@@ -7247,6 +7247,9 @@ var upload_default = async (options) => {
7247
7247
  console.log(import_chalk5.default.blue(`uploading ${absolutePath} to ipfs...`));
7248
7248
  try {
7249
7249
  const result = await uploadToIpfsSplit_default(absolutePath);
7250
+ if (!result) {
7251
+ throw new Error("Upload failed without a result");
7252
+ }
7250
7253
  if (result) {
7251
7254
  console.log(
7252
7255
  import_chalk5.default.cyan(
@@ -7335,6 +7338,9 @@ var upload_default = async (options) => {
7335
7338
  console.log(import_chalk5.default.blue(`uploading ${absolutePath} to ipfs...`));
7336
7339
  try {
7337
7340
  const result = await uploadToIpfsSplit_default(absolutePath);
7341
+ if (!result) {
7342
+ throw new Error("Upload failed without a result");
7343
+ }
7338
7344
  if (result) {
7339
7345
  console.log(
7340
7346
  import_chalk5.default.cyan(
@@ -8340,62 +8346,20 @@ function getApiMessage(data) {
8340
8346
  var _a, _b, _c;
8341
8347
  return ((_a = data == null ? void 0 : data.data) == null ? void 0 : _a.error) || ((_c = (_b = data == null ? void 0 : data.errors) == null ? void 0 : _b[0]) == null ? void 0 : _c.message) || (data == null ? void 0 : data.message) || (data == null ? void 0 : data.msg) || (data == null ? void 0 : data.error);
8342
8348
  }
8343
- function dedupeSuggestions(suggestions) {
8344
- return Array.from(new Set(suggestions.filter(Boolean)));
8345
- }
8346
- function inferApiSummary(stage, status, errorCode, apiMessage, rawResponse) {
8347
- const text = `${apiMessage || ""} ${rawResponse}`.toLowerCase();
8348
- if (status === 401 || status === 403) {
8349
- return "Authentication expired or permission denied.";
8350
- }
8351
- if (status === 404) {
8352
- return "Project or API endpoint was not found.";
8353
- }
8354
- if (errorCode === "ECONNABORTED" || text.includes("timeout")) {
8355
- return "Request timed out while talking to the platform.";
8356
- }
8357
- if (errorCode === "ENOTFOUND" || errorCode === "ECONNREFUSED" || errorCode === "ECONNRESET") {
8358
- return "Unable to connect to the platform API.";
8359
- }
8360
- if (text.includes("sql") || text.includes("sqlite") || text.includes("migration")) {
8361
- return "Database migration failed.";
8362
- }
8363
- if (text.includes("not found") && text.includes("project")) {
8364
- return "Project was not found on the platform.";
8365
- }
8366
- if (text.includes("already exists") || text.includes("duplicate")) {
8367
- return "The platform rejected the request because of conflicting existing data.";
8349
+ function getBusinessCode(data) {
8350
+ if ((data == null ? void 0 : data.code) === void 0 || (data == null ? void 0 : data.code) === null) {
8351
+ return void 0;
8368
8352
  }
8369
- if (status && status >= 500) {
8370
- return "The platform returned a server-side error.";
8371
- }
8372
- return apiMessage || `${stage} failed.`;
8353
+ return String(data.code);
8373
8354
  }
8374
- function inferApiSuggestions(status, errorCode, apiMessage, rawResponse) {
8375
- const text = `${apiMessage || ""} ${rawResponse}`.toLowerCase();
8376
- const suggestions = [];
8377
- if (status === 401 || status === 403) {
8378
- suggestions.push("Run `pinme login` again to refresh local auth.");
8379
- }
8380
- if (status === 404 || text.includes("project") && text.includes("not found")) {
8381
- suggestions.push("Confirm `project_name` in `pinme.toml` matches an existing project.");
8382
- }
8383
- if (errorCode === "ECONNABORTED" || text.includes("timeout")) {
8384
- suggestions.push("Retry once. If it keeps timing out, check network quality and platform responsiveness.");
8385
- }
8386
- if (errorCode === "ENOTFOUND" || errorCode === "ECONNREFUSED" || errorCode === "ECONNRESET") {
8387
- suggestions.push("Check `PINME_API_BASE`, local network connectivity, and whether the API service is reachable.");
8388
- }
8389
- if (text.includes("sql") || text.includes("sqlite") || text.includes("migration")) {
8390
- suggestions.push("Review the SQL file mentioned in the response and verify it is safe to run on the current schema.");
8391
- }
8392
- if (text.includes("already exists") || text.includes("duplicate")) {
8393
- suggestions.push("Check whether this resource or schema change was already created in a previous deployment.");
8355
+ function getBusinessMessage(data) {
8356
+ if (!(data == null ? void 0 : data.msg)) {
8357
+ return void 0;
8394
8358
  }
8395
- if (status && status >= 500) {
8396
- suggestions.push("The platform returned a server-side error. Retry once and check the backend logs if it persists.");
8397
- }
8398
- return suggestions;
8359
+ return String(data.msg);
8360
+ }
8361
+ function dedupeSuggestions(suggestions) {
8362
+ return Array.from(new Set(suggestions.filter(Boolean)));
8399
8363
  }
8400
8364
  function createConfigError(summary, suggestions = []) {
8401
8365
  return new CliError({
@@ -8431,30 +8395,33 @@ function createApiError(stage, error, context = [], suggestions = []) {
8431
8395
  const responseData = (_b = error == null ? void 0 : error.response) == null ? void 0 : _b.data;
8432
8396
  const errorCode = error == null ? void 0 : error.code;
8433
8397
  const apiMessage = getApiMessage(responseData);
8434
- const summary = apiMessage || inferApiSummary(stage, status, errorCode, apiMessage, stringifyValue(responseData)) || (error == null ? void 0 : error.message) || `${stage} failed.`;
8398
+ const businessCode = getBusinessCode(responseData);
8399
+ const businessMessage = getBusinessMessage(responseData);
8400
+ const summary = apiMessage || (error == null ? void 0 : error.message) || `${stage} failed.`;
8435
8401
  const detailLines = [...context];
8436
8402
  if (status) {
8437
8403
  detailLines.push(`HTTP status: ${status}`);
8438
8404
  }
8439
- if (apiMessage && apiMessage !== summary) {
8440
- detailLines.push(`API message: ${apiMessage}`);
8405
+ if (businessCode) {
8406
+ detailLines.push(`Business code: ${businessCode}`);
8441
8407
  }
8442
- const rawResponse = stringifyValue(responseData);
8443
- if (rawResponse) {
8444
- detailLines.push(`API response: ${rawResponse}`);
8408
+ if (businessMessage && businessMessage !== apiMessage) {
8409
+ detailLines.push(`Business message: ${businessMessage}`);
8445
8410
  }
8446
- if (errorCode && errorCode !== "ERR_BAD_REQUEST") {
8411
+ if (apiMessage && apiMessage !== summary) {
8412
+ detailLines.push(`Error message: ${apiMessage}`);
8413
+ }
8414
+ if (errorCode && errorCode !== "ERR_BAD_REQUEST" && !responseData) {
8447
8415
  detailLines.push(`Error code: ${errorCode}`);
8448
8416
  }
8449
- if (!rawResponse && (error == null ? void 0 : error.message) && error.message !== apiMessage) {
8417
+ if (!responseData && (error == null ? void 0 : error.message) && error.message !== apiMessage) {
8450
8418
  detailLines.push(`Reason: ${error.message}`);
8451
8419
  }
8452
- const inferredSuggestions = inferApiSuggestions(status, errorCode, apiMessage, rawResponse);
8453
8420
  return new CliError({
8454
8421
  summary,
8455
8422
  stage,
8456
8423
  details: detailLines,
8457
- suggestions: dedupeSuggestions([...inferredSuggestions, ...suggestions]),
8424
+ suggestions: dedupeSuggestions(suggestions),
8458
8425
  cause: error
8459
8426
  });
8460
8427
  }
@@ -8664,29 +8631,23 @@ Directory "${projectName}" already exists.`));
8664
8631
  cwd: targetDir,
8665
8632
  stdio: "inherit"
8666
8633
  });
8667
- console.log(import_chalk17.default.green(" Root dependencies installed"));
8634
+ console.log(import_chalk17.default.green(" Project dependencies installed"));
8668
8635
  } catch (error) {
8669
- console.log(import_chalk17.default.yellow(" Warning: Root dependencies install failed, continuing..."));
8636
+ throw createCommandError("project dependency install", "npm install", error, [
8637
+ "Check network connectivity and npm registry availability.",
8638
+ "Inspect the generated workspace `package.json` files for dependency conflicts."
8639
+ ]);
8670
8640
  }
8671
8641
  const frontendDir = import_path11.default.join(targetDir, "frontend");
8672
8642
  if (import_fs_extra6.default.existsSync(frontendDir)) {
8673
8643
  try {
8674
- (0, import_child_process2.execSync)("npm install", {
8675
- cwd: frontendDir,
8676
- stdio: "inherit"
8677
- });
8678
- console.log(import_chalk17.default.green(" Frontend dependencies installed"));
8679
- } catch (error) {
8680
- console.log(import_chalk17.default.yellow(" Warning: Frontend dependencies install failed, continuing..."));
8681
- }
8682
- try {
8683
- (0, import_child_process2.execSync)("npm run build", {
8684
- cwd: frontendDir,
8644
+ (0, import_child_process2.execSync)("npm run build:frontend", {
8645
+ cwd: targetDir,
8685
8646
  stdio: "inherit"
8686
8647
  });
8687
8648
  console.log(import_chalk17.default.green(" Frontend built"));
8688
8649
  } catch (error) {
8689
- throw createCommandError("frontend build", "npm run build", error, [
8650
+ throw createCommandError("frontend build", "npm run build:frontend", error, [
8690
8651
  "Fix the frontend build error shown above, then rerun `pinme create`."
8691
8652
  ]);
8692
8653
  }
@@ -8771,41 +8732,13 @@ function installDependencies() {
8771
8732
  cwd: PROJECT_DIR2,
8772
8733
  stdio: "inherit"
8773
8734
  });
8774
- console.log(import_chalk18.default.green("Root dependencies installed"));
8735
+ console.log(import_chalk18.default.green("Project dependencies installed"));
8775
8736
  } catch (error) {
8776
- throw createCommandError("root dependency install", "npm install", error, [
8737
+ throw createCommandError("project dependency install", "npm install", error, [
8777
8738
  "Check network connectivity and npm registry availability.",
8778
8739
  "If `package-lock.json` is stale or conflicted, resolve that before retrying."
8779
8740
  ]);
8780
8741
  }
8781
- const backendDir = import_path12.default.join(PROJECT_DIR2, "backend");
8782
- if (import_fs_extra7.default.existsSync(import_path12.default.join(backendDir, "package.json"))) {
8783
- try {
8784
- (0, import_child_process3.execSync)("npm install", {
8785
- cwd: backendDir,
8786
- stdio: "inherit"
8787
- });
8788
- console.log(import_chalk18.default.green("Backend dependencies installed"));
8789
- } catch (error) {
8790
- throw createCommandError("backend dependency install", "npm install", error, [
8791
- "Inspect `backend/package.json` and the npm output above for the failing package."
8792
- ]);
8793
- }
8794
- }
8795
- const frontendDir = import_path12.default.join(PROJECT_DIR2, "frontend");
8796
- if (import_fs_extra7.default.existsSync(import_path12.default.join(frontendDir, "package.json"))) {
8797
- try {
8798
- (0, import_child_process3.execSync)("npm install", {
8799
- cwd: frontendDir,
8800
- stdio: "inherit"
8801
- });
8802
- console.log(import_chalk18.default.green("Frontend dependencies installed"));
8803
- } catch (error) {
8804
- throw createCommandError("frontend dependency install", "npm install", error, [
8805
- "Inspect `frontend/package.json` and the npm output above for the failing package."
8806
- ]);
8807
- }
8808
- }
8809
8742
  }
8810
8743
  function getBuiltWorker() {
8811
8744
  const distWorkerDir = import_path12.default.join(PROJECT_DIR2, "dist-worker");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinme",
3
- "version": "2.0.0-beta.16",
3
+ "version": "2.0.0-beta.18",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },