pinme 2.0.2-beta.13 → 2.0.2-beta.14
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 +83 -47
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4724,6 +4724,66 @@ var init_axios2 = __esm({
|
|
|
4724
4724
|
}
|
|
4725
4725
|
});
|
|
4726
4726
|
|
|
4727
|
+
// bin/utils/config.ts
|
|
4728
|
+
function trimTrailingSlash(value) {
|
|
4729
|
+
return value.replace(/\/+$/, "");
|
|
4730
|
+
}
|
|
4731
|
+
function readNumberEnv(name, fallback) {
|
|
4732
|
+
const rawValue = process.env[name];
|
|
4733
|
+
if (!rawValue) {
|
|
4734
|
+
return fallback;
|
|
4735
|
+
}
|
|
4736
|
+
const parsed = Number.parseInt(rawValue, 10);
|
|
4737
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
4738
|
+
}
|
|
4739
|
+
function getPinmeApiUrl(pathname) {
|
|
4740
|
+
const normalizedPath = pathname.startsWith("/") ? pathname : `/${pathname}`;
|
|
4741
|
+
return `${APP_CONFIG.pinmeApiBase}${normalizedPath}`;
|
|
4742
|
+
}
|
|
4743
|
+
function includesAny(value, markers) {
|
|
4744
|
+
return markers.some((marker) => value.includes(marker));
|
|
4745
|
+
}
|
|
4746
|
+
function getWalletRechargeUrl() {
|
|
4747
|
+
const candidates = [APP_CONFIG.ipfsApiUrl].filter(Boolean);
|
|
4748
|
+
if (candidates.some(
|
|
4749
|
+
(candidate) => includesAny(candidate, ["test-pinme", "localhost:5173", "benny1996.win"])
|
|
4750
|
+
)) {
|
|
4751
|
+
return TEST_WALLET_RECHARGE_URL;
|
|
4752
|
+
}
|
|
4753
|
+
return PROD_WALLET_RECHARGE_URL;
|
|
4754
|
+
}
|
|
4755
|
+
var DEFAULT_PINME_WEB_URL, PROD_WALLET_RECHARGE_URL, TEST_WALLET_RECHARGE_URL, _a, APP_CONFIG;
|
|
4756
|
+
var init_config = __esm({
|
|
4757
|
+
"bin/utils/config.ts"() {
|
|
4758
|
+
DEFAULT_PINME_WEB_URL = "http://localhost:5173";
|
|
4759
|
+
PROD_WALLET_RECHARGE_URL = "https://pinme.eth.limo/#/profile?tab=wallet";
|
|
4760
|
+
TEST_WALLET_RECHARGE_URL = "https://test-pinme.pinit.eth.limo/#/profile?tab=wallet";
|
|
4761
|
+
APP_CONFIG = {
|
|
4762
|
+
pinmeApiBase: trimTrailingSlash("https://pinme.benny1996.win/api/v4"),
|
|
4763
|
+
ipfsApiUrl: trimTrailingSlash("https://pinme.benny1996.win/api/v3"),
|
|
4764
|
+
carApiBase: trimTrailingSlash(
|
|
4765
|
+
process.env.CAR_API_BASE || "https://pinme.benny1996.win/api/v3"
|
|
4766
|
+
),
|
|
4767
|
+
pinmeWebUrl: trimTrailingSlash(
|
|
4768
|
+
process.env.PINME_WEB_URL || DEFAULT_PINME_WEB_URL
|
|
4769
|
+
),
|
|
4770
|
+
pinmeCheckDomainPath: process.env.PINME_CHECK_DOMAIN_PATH || "/check_domain",
|
|
4771
|
+
ipfsPreviewUrl: "https://pinme.eth.limo/#/preview/",
|
|
4772
|
+
projectPeviewUrl: "https://test-pinme.pinit.eth.limo/#/console/projects/",
|
|
4773
|
+
secretKey: "pinme-secret-key",
|
|
4774
|
+
pinmeProjectName: (_a = process.env.PINME_PROJECT_NAME) == null ? void 0 : _a.trim(),
|
|
4775
|
+
upload: {
|
|
4776
|
+
maxRetries: readNumberEnv("MAX_RETRIES", 2),
|
|
4777
|
+
retryDelayMs: readNumberEnv("RETRY_DELAY_MS", 1e3),
|
|
4778
|
+
timeoutMs: readNumberEnv("TIMEOUT_MS", 6e5),
|
|
4779
|
+
maxPollTimeMs: readNumberEnv("MAX_POLL_TIME_MINUTES", 5) * 60 * 1e3,
|
|
4780
|
+
pollIntervalMs: readNumberEnv("POLL_INTERVAL_SECONDS", 2) * 1e3,
|
|
4781
|
+
pollTimeoutMs: readNumberEnv("POLL_TIMEOUT_SECONDS", 10) * 1e3
|
|
4782
|
+
}
|
|
4783
|
+
};
|
|
4784
|
+
}
|
|
4785
|
+
});
|
|
4786
|
+
|
|
4727
4787
|
// bin/utils/cliError.ts
|
|
4728
4788
|
function stringifyValue(value) {
|
|
4729
4789
|
if (value === void 0 || value === null) {
|
|
@@ -4767,6 +4827,13 @@ function getBusinessMessage(data) {
|
|
|
4767
4827
|
function dedupeSuggestions(suggestions) {
|
|
4768
4828
|
return Array.from(new Set(suggestions.filter(Boolean)));
|
|
4769
4829
|
}
|
|
4830
|
+
function isInsufficientBalanceError(businessCode, ...messages) {
|
|
4831
|
+
if (businessCode === "40001") {
|
|
4832
|
+
return true;
|
|
4833
|
+
}
|
|
4834
|
+
const combined = messages.filter(Boolean).join(" ").toLowerCase();
|
|
4835
|
+
return combined.includes("insufficient balance") || combined.includes("insufficient wallet balance");
|
|
4836
|
+
}
|
|
4770
4837
|
function createConfigError(summary, suggestions = []) {
|
|
4771
4838
|
return new CliError({
|
|
4772
4839
|
summary,
|
|
@@ -4805,6 +4872,13 @@ function createApiError(stage, error, context = [], suggestions = []) {
|
|
|
4805
4872
|
const apiDetailMessage = getApiDetailMessage(responseData);
|
|
4806
4873
|
const businessCode = getBusinessCode(responseData);
|
|
4807
4874
|
const businessMessage = getBusinessMessage(responseData);
|
|
4875
|
+
const hasInsufficientBalanceError = isInsufficientBalanceError(
|
|
4876
|
+
businessCode,
|
|
4877
|
+
apiMessage,
|
|
4878
|
+
apiDetailMessage,
|
|
4879
|
+
businessMessage,
|
|
4880
|
+
rawMessage
|
|
4881
|
+
);
|
|
4808
4882
|
const summary = apiMessage || businessMessage || apiDetailMessage || rawMessage || `${stage} failed.`;
|
|
4809
4883
|
const detailLines = [...context];
|
|
4810
4884
|
const hasBusinessError = Boolean(businessCode);
|
|
@@ -4823,6 +4897,9 @@ function createApiError(stage, error, context = [], suggestions = []) {
|
|
|
4823
4897
|
if (apiMessage && apiMessage !== summary && apiMessage !== apiDetailMessage) {
|
|
4824
4898
|
detailLines.push(`Error message: ${apiMessage}`);
|
|
4825
4899
|
}
|
|
4900
|
+
if (hasInsufficientBalanceError) {
|
|
4901
|
+
detailLines.push(`Recharge URL: ${getWalletRechargeUrl()}`);
|
|
4902
|
+
}
|
|
4826
4903
|
if (errorCode && errorCode !== "ERR_BAD_REQUEST" && !responseData) {
|
|
4827
4904
|
detailLines.push(`Error code: ${errorCode}`);
|
|
4828
4905
|
}
|
|
@@ -4883,6 +4960,7 @@ var import_chalk2, CliError;
|
|
|
4883
4960
|
var init_cliError = __esm({
|
|
4884
4961
|
"bin/utils/cliError.ts"() {
|
|
4885
4962
|
import_chalk2 = __toESM(require("chalk"));
|
|
4963
|
+
init_config();
|
|
4886
4964
|
CliError = class extends Error {
|
|
4887
4965
|
stage;
|
|
4888
4966
|
details;
|
|
@@ -4900,52 +4978,6 @@ var init_cliError = __esm({
|
|
|
4900
4978
|
}
|
|
4901
4979
|
});
|
|
4902
4980
|
|
|
4903
|
-
// bin/utils/config.ts
|
|
4904
|
-
function trimTrailingSlash(value) {
|
|
4905
|
-
return value.replace(/\/+$/, "");
|
|
4906
|
-
}
|
|
4907
|
-
function readNumberEnv(name, fallback) {
|
|
4908
|
-
const rawValue = process.env[name];
|
|
4909
|
-
if (!rawValue) {
|
|
4910
|
-
return fallback;
|
|
4911
|
-
}
|
|
4912
|
-
const parsed = Number.parseInt(rawValue, 10);
|
|
4913
|
-
return Number.isFinite(parsed) ? parsed : fallback;
|
|
4914
|
-
}
|
|
4915
|
-
function getPinmeApiUrl(pathname) {
|
|
4916
|
-
const normalizedPath = pathname.startsWith("/") ? pathname : `/${pathname}`;
|
|
4917
|
-
return `${APP_CONFIG.pinmeApiBase}${normalizedPath}`;
|
|
4918
|
-
}
|
|
4919
|
-
var DEFAULT_PINME_WEB_URL, _a, APP_CONFIG;
|
|
4920
|
-
var init_config = __esm({
|
|
4921
|
-
"bin/utils/config.ts"() {
|
|
4922
|
-
DEFAULT_PINME_WEB_URL = "http://localhost:5173";
|
|
4923
|
-
APP_CONFIG = {
|
|
4924
|
-
pinmeApiBase: trimTrailingSlash("https://pinme.benny1996.win/api/v4"),
|
|
4925
|
-
ipfsApiUrl: trimTrailingSlash("https://pinme.benny1996.win/api/v3"),
|
|
4926
|
-
carApiBase: trimTrailingSlash(
|
|
4927
|
-
process.env.CAR_API_BASE || "https://pinme.benny1996.win/api/v3"
|
|
4928
|
-
),
|
|
4929
|
-
pinmeWebUrl: trimTrailingSlash(
|
|
4930
|
-
process.env.PINME_WEB_URL || DEFAULT_PINME_WEB_URL
|
|
4931
|
-
),
|
|
4932
|
-
pinmeCheckDomainPath: process.env.PINME_CHECK_DOMAIN_PATH || "/check_domain",
|
|
4933
|
-
ipfsPreviewUrl: "https://pinme.eth.limo/#/preview/",
|
|
4934
|
-
projectPeviewUrl: "https://test-pinme.pinit.eth.limo/#/console/projects/",
|
|
4935
|
-
secretKey: "pinme-secret-key",
|
|
4936
|
-
pinmeProjectName: (_a = process.env.PINME_PROJECT_NAME) == null ? void 0 : _a.trim(),
|
|
4937
|
-
upload: {
|
|
4938
|
-
maxRetries: readNumberEnv("MAX_RETRIES", 2),
|
|
4939
|
-
retryDelayMs: readNumberEnv("RETRY_DELAY_MS", 1e3),
|
|
4940
|
-
timeoutMs: readNumberEnv("TIMEOUT_MS", 6e5),
|
|
4941
|
-
maxPollTimeMs: readNumberEnv("MAX_POLL_TIME_MINUTES", 5) * 60 * 1e3,
|
|
4942
|
-
pollIntervalMs: readNumberEnv("POLL_INTERVAL_SECONDS", 2) * 1e3,
|
|
4943
|
-
pollTimeoutMs: readNumberEnv("POLL_TIMEOUT_SECONDS", 10) * 1e3
|
|
4944
|
-
}
|
|
4945
|
-
};
|
|
4946
|
-
}
|
|
4947
|
-
});
|
|
4948
|
-
|
|
4949
4981
|
// bin/utils/webLogin.ts
|
|
4950
4982
|
function openBrowser(url2) {
|
|
4951
4983
|
const platform = process.platform;
|
|
@@ -5869,7 +5901,7 @@ var import_chalk26 = __toESM(require("chalk"));
|
|
|
5869
5901
|
var import_figlet5 = __toESM(require("figlet"));
|
|
5870
5902
|
|
|
5871
5903
|
// package.json
|
|
5872
|
-
var version = "2.0.2-beta.
|
|
5904
|
+
var version = "2.0.2-beta.14";
|
|
5873
5905
|
|
|
5874
5906
|
// bin/upload.ts
|
|
5875
5907
|
var import_path6 = __toESM(require("path"));
|
|
@@ -7046,6 +7078,7 @@ var upload_default = async (options) => {
|
|
|
7046
7078
|
"Insufficient wallet balance. Please recharge your wallet first."
|
|
7047
7079
|
)
|
|
7048
7080
|
);
|
|
7081
|
+
console.log(import_chalk7.default.cyan(`Recharge URL: ${getWalletRechargeUrl()}`));
|
|
7049
7082
|
return;
|
|
7050
7083
|
}
|
|
7051
7084
|
} catch (e) {
|
|
@@ -7142,6 +7175,7 @@ var upload_default = async (options) => {
|
|
|
7142
7175
|
"Insufficient wallet balance. Please recharge your wallet first."
|
|
7143
7176
|
)
|
|
7144
7177
|
);
|
|
7178
|
+
console.log(import_chalk7.default.cyan(`Recharge URL: ${getWalletRechargeUrl()}`));
|
|
7145
7179
|
return;
|
|
7146
7180
|
}
|
|
7147
7181
|
} catch (e) {
|
|
@@ -7992,6 +8026,7 @@ var import_chalk17 = __toESM(require("chalk"));
|
|
|
7992
8026
|
var import_inquirer7 = __toESM(require("inquirer"));
|
|
7993
8027
|
init_pinmeApi();
|
|
7994
8028
|
init_cliError();
|
|
8029
|
+
init_config();
|
|
7995
8030
|
init_webLogin();
|
|
7996
8031
|
function parseArgs() {
|
|
7997
8032
|
const args = process.argv.slice(2);
|
|
@@ -8068,6 +8103,7 @@ async function bindCmd() {
|
|
|
8068
8103
|
const hasWalletBalance = await checkWalletBalanceStatus2(authConfig);
|
|
8069
8104
|
if (!hasWalletBalance) {
|
|
8070
8105
|
console.log(import_chalk17.default.red("Insufficient wallet balance. Please recharge your wallet first."));
|
|
8106
|
+
console.log(import_chalk17.default.cyan(`Recharge URL: ${getWalletRechargeUrl()}`));
|
|
8071
8107
|
return;
|
|
8072
8108
|
}
|
|
8073
8109
|
} catch (e) {
|