pinme 2.0.2-beta.11 → 2.0.2-beta.12
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 +430 -371
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4755,6 +4755,7 @@ var init_config = __esm({
|
|
|
4755
4755
|
),
|
|
4756
4756
|
pinmeCheckDomainPath: process.env.PINME_CHECK_DOMAIN_PATH || "/check_domain",
|
|
4757
4757
|
ipfsPreviewUrl: "https://pinme.eth.limo/#/preview/",
|
|
4758
|
+
projectPeviewUrl: "https://test-pinme.pinit.eth.limo/#/console/projects/",
|
|
4758
4759
|
secretKey: "pinme-secret-key",
|
|
4759
4760
|
pinmeProjectName: (_a = process.env.PINME_PROJECT_NAME) == null ? void 0 : _a.trim(),
|
|
4760
4761
|
upload: {
|
|
@@ -5643,15 +5644,15 @@ function checkNodeVersion() {
|
|
|
5643
5644
|
|
|
5644
5645
|
// bin/index.ts
|
|
5645
5646
|
var import_commander = require("commander");
|
|
5646
|
-
var
|
|
5647
|
+
var import_chalk26 = __toESM(require("chalk"));
|
|
5647
5648
|
var import_figlet5 = __toESM(require("figlet"));
|
|
5648
5649
|
|
|
5649
5650
|
// package.json
|
|
5650
|
-
var version = "2.0.2-beta.
|
|
5651
|
+
var version = "2.0.2-beta.12";
|
|
5651
5652
|
|
|
5652
5653
|
// bin/upload.ts
|
|
5653
5654
|
var import_path6 = __toESM(require("path"));
|
|
5654
|
-
var
|
|
5655
|
+
var import_chalk6 = __toESM(require("chalk"));
|
|
5655
5656
|
var import_inquirer = __toESM(require("inquirer"));
|
|
5656
5657
|
var import_figlet = __toESM(require("figlet"));
|
|
5657
5658
|
var import_fs2 = __toESM(require("fs"));
|
|
@@ -6623,10 +6624,11 @@ async function formatPreferredUrl(value, options) {
|
|
|
6623
6624
|
return withProtocol.replace(/\/$/, "");
|
|
6624
6625
|
}
|
|
6625
6626
|
}
|
|
6626
|
-
async function resolveUploadUrls(contentHash, urls, uid) {
|
|
6627
|
+
async function resolveUploadUrls(contentHash, urls, projectName, uid) {
|
|
6627
6628
|
const resolvedUid = (uid == null ? void 0 : uid.trim()) || getUid();
|
|
6628
6629
|
const encryptedCID = encryptHash(contentHash, APP_CONFIG.secretKey, resolvedUid);
|
|
6629
|
-
const
|
|
6630
|
+
const normalizedProjectName = projectName == null ? void 0 : projectName.trim();
|
|
6631
|
+
const managementUrl = normalizedProjectName ? `${APP_CONFIG.projectPeviewUrl}${normalizedProjectName}` : `${APP_CONFIG.ipfsPreviewUrl}${encryptedCID}`;
|
|
6630
6632
|
const publicUrl = await formatPreferredUrl(urls == null ? void 0 : urls.dnsUrl) || await formatPreferredUrl(urls == null ? void 0 : urls.pinmeUrl, { appendRootDomain: true }) || await formatShortUrl(urls == null ? void 0 : urls.shortUrl) || managementUrl;
|
|
6631
6633
|
return {
|
|
6632
6634
|
publicUrl,
|
|
@@ -6653,6 +6655,7 @@ async function uploadPath(targetPath, options = {}) {
|
|
|
6653
6655
|
pinmeUrl: result.pinmeUrl,
|
|
6654
6656
|
shortUrl: result.shortUrl
|
|
6655
6657
|
},
|
|
6658
|
+
options.projectName,
|
|
6656
6659
|
options.uid
|
|
6657
6660
|
);
|
|
6658
6661
|
return {
|
|
@@ -6665,6 +6668,19 @@ async function uploadPath(targetPath, options = {}) {
|
|
|
6665
6668
|
};
|
|
6666
6669
|
}
|
|
6667
6670
|
|
|
6671
|
+
// bin/utils/urlDisplay.ts
|
|
6672
|
+
var import_chalk5 = __toESM(require("chalk"));
|
|
6673
|
+
function printHighlightedUrl(label, url2, tone = "primary") {
|
|
6674
|
+
const safeLabel = label.trim() || "URL";
|
|
6675
|
+
const safeUrl = url2.trim();
|
|
6676
|
+
const labelStyle = import_chalk5.default.black.bgWhiteBright.bold;
|
|
6677
|
+
const urlStyle = tone === "management" ? import_chalk5.default.blueBright.bold.underline : import_chalk5.default.cyanBright.bold;
|
|
6678
|
+
console.log("");
|
|
6679
|
+
console.log(labelStyle(` ${safeLabel} `));
|
|
6680
|
+
console.log(urlStyle(safeUrl));
|
|
6681
|
+
console.log("");
|
|
6682
|
+
}
|
|
6683
|
+
|
|
6668
6684
|
// bin/upload.ts
|
|
6669
6685
|
checkNodeVersion();
|
|
6670
6686
|
function checkPathSync(inputPath) {
|
|
@@ -6675,7 +6691,7 @@ function checkPathSync(inputPath) {
|
|
|
6675
6691
|
}
|
|
6676
6692
|
return null;
|
|
6677
6693
|
} catch (error) {
|
|
6678
|
-
console.error(
|
|
6694
|
+
console.error(import_chalk6.default.red(`error checking path: ${error.message}`));
|
|
6679
6695
|
return null;
|
|
6680
6696
|
}
|
|
6681
6697
|
}
|
|
@@ -6687,17 +6703,11 @@ async function printUploadUrls(result) {
|
|
|
6687
6703
|
dnsUrl: result.dnsUrl,
|
|
6688
6704
|
pinmeUrl: result.pinmeUrl,
|
|
6689
6705
|
shortUrl: result.shortUrl
|
|
6690
|
-
}
|
|
6706
|
+
},
|
|
6707
|
+
projectName
|
|
6691
6708
|
);
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
console.log(import_chalk5.default.cyan(publicUrl));
|
|
6695
|
-
console.log(import_chalk5.default.cyan(`Management page:`));
|
|
6696
|
-
console.log(import_chalk5.default.cyan(managementUrl));
|
|
6697
|
-
return;
|
|
6698
|
-
}
|
|
6699
|
-
console.log(import_chalk5.default.cyan(`URL:`));
|
|
6700
|
-
console.log(import_chalk5.default.cyan(publicUrl));
|
|
6709
|
+
printHighlightedUrl("URL", publicUrl, "primary");
|
|
6710
|
+
printHighlightedUrl("Management URL", managementUrl, "management");
|
|
6701
6711
|
}
|
|
6702
6712
|
function getDomainFromArgs() {
|
|
6703
6713
|
const args = process.argv.slice(2);
|
|
@@ -6713,45 +6723,59 @@ function getDnsFromArgs() {
|
|
|
6713
6723
|
}
|
|
6714
6724
|
async function checkWalletBalanceStatus(authConfig) {
|
|
6715
6725
|
var _a2;
|
|
6716
|
-
console.log(
|
|
6726
|
+
console.log(import_chalk6.default.blue("Checking wallet balance..."));
|
|
6717
6727
|
try {
|
|
6718
|
-
const balanceResult = await getWalletBalance(
|
|
6728
|
+
const balanceResult = await getWalletBalance(
|
|
6729
|
+
authConfig.address,
|
|
6730
|
+
authConfig.token
|
|
6731
|
+
);
|
|
6719
6732
|
const balance = Number(((_a2 = balanceResult.data) == null ? void 0 : _a2.wallet_balance_usd) ?? 0);
|
|
6720
6733
|
if (!Number.isFinite(balance) || balance <= 0) {
|
|
6721
6734
|
return false;
|
|
6722
6735
|
}
|
|
6723
|
-
console.log(
|
|
6736
|
+
console.log(
|
|
6737
|
+
import_chalk6.default.green(`Wallet balance available: $${balance.toFixed(2)}`)
|
|
6738
|
+
);
|
|
6724
6739
|
return true;
|
|
6725
6740
|
} catch (e) {
|
|
6726
6741
|
if (e.message === "Token expired") {
|
|
6727
6742
|
throw e;
|
|
6728
6743
|
}
|
|
6729
|
-
console.log(
|
|
6744
|
+
console.log(import_chalk6.default.yellow("Failed to check wallet balance, continuing..."));
|
|
6730
6745
|
return true;
|
|
6731
6746
|
}
|
|
6732
6747
|
}
|
|
6733
6748
|
async function bindDomain(domain, contentHash, isDns, authConfig) {
|
|
6734
6749
|
const displayDomain = normalizeDomain(domain);
|
|
6735
6750
|
if (isDns) {
|
|
6736
|
-
console.log(
|
|
6737
|
-
const dnsResult = await bindDnsDomainV4(
|
|
6751
|
+
console.log(import_chalk6.default.blue("Binding DNS domain..."));
|
|
6752
|
+
const dnsResult = await bindDnsDomainV4(
|
|
6753
|
+
displayDomain,
|
|
6754
|
+
contentHash,
|
|
6755
|
+
authConfig.address,
|
|
6756
|
+
authConfig.token
|
|
6757
|
+
);
|
|
6738
6758
|
if (dnsResult.code !== 200) {
|
|
6739
|
-
console.log(
|
|
6759
|
+
console.log(import_chalk6.default.red(`DNS binding failed: ${dnsResult.msg}`));
|
|
6740
6760
|
return false;
|
|
6741
6761
|
}
|
|
6742
|
-
console.log(
|
|
6743
|
-
console.log(
|
|
6744
|
-
console.log(
|
|
6762
|
+
console.log(import_chalk6.default.green(`DNS bind success: ${displayDomain}`));
|
|
6763
|
+
console.log(import_chalk6.default.white(`Visit: https://${displayDomain}`));
|
|
6764
|
+
console.log(
|
|
6765
|
+
import_chalk6.default.cyan(
|
|
6766
|
+
"\n\u{1F4DA} DNS Setup Guide: https://pinme.eth.limo/#/docs?id=custom-domain"
|
|
6767
|
+
)
|
|
6768
|
+
);
|
|
6745
6769
|
} else {
|
|
6746
|
-
console.log(
|
|
6770
|
+
console.log(import_chalk6.default.blue("Binding Pinme subdomain..."));
|
|
6747
6771
|
const ok = await bindPinmeDomain(displayDomain, contentHash);
|
|
6748
6772
|
if (!ok) {
|
|
6749
|
-
console.log(
|
|
6773
|
+
console.log(import_chalk6.default.red("Binding failed. Please try again later."));
|
|
6750
6774
|
return false;
|
|
6751
6775
|
}
|
|
6752
|
-
console.log(
|
|
6776
|
+
console.log(import_chalk6.default.green(`Bind success: ${displayDomain}`));
|
|
6753
6777
|
const rootDomain = await (await Promise.resolve().then(() => (init_pinmeApi(), pinmeApi_exports))).getRootDomain();
|
|
6754
|
-
console.log(
|
|
6778
|
+
console.log(import_chalk6.default.white(`Visit: https://${displayDomain}.${rootDomain}`));
|
|
6755
6779
|
}
|
|
6756
6780
|
return true;
|
|
6757
6781
|
}
|
|
@@ -6768,7 +6792,7 @@ var upload_default = async (options) => {
|
|
|
6768
6792
|
);
|
|
6769
6793
|
const authConfig = getAuthConfig();
|
|
6770
6794
|
if (!authConfig) {
|
|
6771
|
-
console.log(
|
|
6795
|
+
console.log(import_chalk6.default.red("Please login first. Run: pinme login"));
|
|
6772
6796
|
return;
|
|
6773
6797
|
}
|
|
6774
6798
|
const domainArg = getDomainFromArgs();
|
|
@@ -6777,7 +6801,7 @@ var upload_default = async (options) => {
|
|
|
6777
6801
|
if (argPath && !argPath.startsWith("-")) {
|
|
6778
6802
|
const absolutePath = checkPathSync(argPath);
|
|
6779
6803
|
if (!absolutePath) {
|
|
6780
|
-
console.log(
|
|
6804
|
+
console.log(import_chalk6.default.red(`path ${argPath} does not exist`));
|
|
6781
6805
|
return;
|
|
6782
6806
|
}
|
|
6783
6807
|
const isDns = dnsArg || (domainArg ? isDnsDomain(domainArg) : false);
|
|
@@ -6785,7 +6809,7 @@ var upload_default = async (options) => {
|
|
|
6785
6809
|
if (isDns && domainArg) {
|
|
6786
6810
|
const validation = validateDnsDomain(domainArg);
|
|
6787
6811
|
if (!validation.valid) {
|
|
6788
|
-
console.log(
|
|
6812
|
+
console.log(import_chalk6.default.red(validation.message));
|
|
6789
6813
|
return;
|
|
6790
6814
|
}
|
|
6791
6815
|
}
|
|
@@ -6793,7 +6817,11 @@ var upload_default = async (options) => {
|
|
|
6793
6817
|
try {
|
|
6794
6818
|
const hasWalletBalance = await checkWalletBalanceStatus(authConfig);
|
|
6795
6819
|
if (!hasWalletBalance) {
|
|
6796
|
-
console.log(
|
|
6820
|
+
console.log(
|
|
6821
|
+
import_chalk6.default.red(
|
|
6822
|
+
"Insufficient wallet balance. Please recharge your wallet first."
|
|
6823
|
+
)
|
|
6824
|
+
);
|
|
6797
6825
|
return;
|
|
6798
6826
|
}
|
|
6799
6827
|
} catch (e) {
|
|
@@ -6808,13 +6836,13 @@ var upload_default = async (options) => {
|
|
|
6808
6836
|
const check = await checkDomainAvailable(displayDomain);
|
|
6809
6837
|
if (!check.is_valid) {
|
|
6810
6838
|
console.log(
|
|
6811
|
-
|
|
6839
|
+
import_chalk6.default.red(
|
|
6812
6840
|
`Domain not available: ${check.error || "unknown reason"}`
|
|
6813
6841
|
)
|
|
6814
6842
|
);
|
|
6815
6843
|
return;
|
|
6816
6844
|
}
|
|
6817
|
-
console.log(
|
|
6845
|
+
console.log(import_chalk6.default.green(`Domain available: ${displayDomain}`));
|
|
6818
6846
|
} catch (e) {
|
|
6819
6847
|
if (e.message === "Token expired") {
|
|
6820
6848
|
return;
|
|
@@ -6822,7 +6850,7 @@ var upload_default = async (options) => {
|
|
|
6822
6850
|
throw e;
|
|
6823
6851
|
}
|
|
6824
6852
|
}
|
|
6825
|
-
console.log(
|
|
6853
|
+
console.log(import_chalk6.default.blue(`uploading ${absolutePath} to ipfs...`));
|
|
6826
6854
|
let result;
|
|
6827
6855
|
try {
|
|
6828
6856
|
result = await uploadPath(absolutePath, {
|
|
@@ -6830,22 +6858,20 @@ var upload_default = async (options) => {
|
|
|
6830
6858
|
uid: authConfig == null ? void 0 : authConfig.address
|
|
6831
6859
|
});
|
|
6832
6860
|
} catch (error) {
|
|
6833
|
-
console.error(
|
|
6861
|
+
console.error(import_chalk6.default.red(`Upload error: ${error.message}`));
|
|
6834
6862
|
process.exit(1);
|
|
6835
6863
|
}
|
|
6836
6864
|
if (!result) {
|
|
6837
|
-
console.error(
|
|
6865
|
+
console.error(import_chalk6.default.red("Upload failed: no result returned"));
|
|
6838
6866
|
process.exit(1);
|
|
6839
6867
|
}
|
|
6840
6868
|
console.log(
|
|
6841
|
-
|
|
6842
|
-
import_figlet.default.textSync("Successful", { horizontalLayout: "full" })
|
|
6843
|
-
)
|
|
6869
|
+
import_chalk6.default.cyan(import_figlet.default.textSync("Successful", { horizontalLayout: "full" }))
|
|
6844
6870
|
);
|
|
6845
6871
|
await printUploadUrls(result);
|
|
6846
6872
|
if (domainArg) {
|
|
6847
6873
|
console.log(
|
|
6848
|
-
|
|
6874
|
+
import_chalk6.default.blue(
|
|
6849
6875
|
`Binding domain: ${displayDomain} with CID: ${result.contentHash}`
|
|
6850
6876
|
)
|
|
6851
6877
|
);
|
|
@@ -6858,7 +6884,7 @@ var upload_default = async (options) => {
|
|
|
6858
6884
|
throw e;
|
|
6859
6885
|
}
|
|
6860
6886
|
}
|
|
6861
|
-
console.log(
|
|
6887
|
+
console.log(import_chalk6.default.green("\n\u{1F389} upload successful, program exit"));
|
|
6862
6888
|
process.exit(0);
|
|
6863
6889
|
}
|
|
6864
6890
|
const answer = await import_inquirer.default.prompt([
|
|
@@ -6871,7 +6897,7 @@ var upload_default = async (options) => {
|
|
|
6871
6897
|
if (answer.path) {
|
|
6872
6898
|
const absolutePath = checkPathSync(answer.path);
|
|
6873
6899
|
if (!absolutePath) {
|
|
6874
|
-
console.log(
|
|
6900
|
+
console.log(import_chalk6.default.red(`path ${answer.path} does not exist`));
|
|
6875
6901
|
return;
|
|
6876
6902
|
}
|
|
6877
6903
|
const isDns = dnsArg || (domainArg ? isDnsDomain(domainArg) : false);
|
|
@@ -6879,7 +6905,7 @@ var upload_default = async (options) => {
|
|
|
6879
6905
|
if (isDns && domainArg) {
|
|
6880
6906
|
const validation = validateDnsDomain(domainArg);
|
|
6881
6907
|
if (!validation.valid) {
|
|
6882
|
-
console.log(
|
|
6908
|
+
console.log(import_chalk6.default.red(validation.message));
|
|
6883
6909
|
return;
|
|
6884
6910
|
}
|
|
6885
6911
|
}
|
|
@@ -6887,7 +6913,11 @@ var upload_default = async (options) => {
|
|
|
6887
6913
|
try {
|
|
6888
6914
|
const hasWalletBalance = await checkWalletBalanceStatus(authConfig);
|
|
6889
6915
|
if (!hasWalletBalance) {
|
|
6890
|
-
console.log(
|
|
6916
|
+
console.log(
|
|
6917
|
+
import_chalk6.default.red(
|
|
6918
|
+
"Insufficient wallet balance. Please recharge your wallet first."
|
|
6919
|
+
)
|
|
6920
|
+
);
|
|
6891
6921
|
return;
|
|
6892
6922
|
}
|
|
6893
6923
|
} catch (e) {
|
|
@@ -6902,13 +6932,13 @@ var upload_default = async (options) => {
|
|
|
6902
6932
|
const check = await checkDomainAvailable(displayDomain);
|
|
6903
6933
|
if (!check.is_valid) {
|
|
6904
6934
|
console.log(
|
|
6905
|
-
|
|
6935
|
+
import_chalk6.default.red(
|
|
6906
6936
|
`Domain not available: ${check.error || "unknown reason"}`
|
|
6907
6937
|
)
|
|
6908
6938
|
);
|
|
6909
6939
|
return;
|
|
6910
6940
|
}
|
|
6911
|
-
console.log(
|
|
6941
|
+
console.log(import_chalk6.default.green(`Domain available: ${displayDomain}`));
|
|
6912
6942
|
} catch (e) {
|
|
6913
6943
|
if (e.message === "Token expired") {
|
|
6914
6944
|
return;
|
|
@@ -6916,7 +6946,7 @@ var upload_default = async (options) => {
|
|
|
6916
6946
|
throw e;
|
|
6917
6947
|
}
|
|
6918
6948
|
}
|
|
6919
|
-
console.log(
|
|
6949
|
+
console.log(import_chalk6.default.blue(`uploading ${absolutePath} to ipfs...`));
|
|
6920
6950
|
let result;
|
|
6921
6951
|
try {
|
|
6922
6952
|
result = await uploadPath(absolutePath, {
|
|
@@ -6924,22 +6954,20 @@ var upload_default = async (options) => {
|
|
|
6924
6954
|
uid: authConfig == null ? void 0 : authConfig.address
|
|
6925
6955
|
});
|
|
6926
6956
|
} catch (error) {
|
|
6927
|
-
console.error(
|
|
6957
|
+
console.error(import_chalk6.default.red(`Upload error: ${error.message}`));
|
|
6928
6958
|
process.exit(1);
|
|
6929
6959
|
}
|
|
6930
6960
|
if (!result) {
|
|
6931
|
-
console.error(
|
|
6961
|
+
console.error(import_chalk6.default.red("Upload failed: no result returned"));
|
|
6932
6962
|
process.exit(1);
|
|
6933
6963
|
}
|
|
6934
6964
|
console.log(
|
|
6935
|
-
|
|
6936
|
-
import_figlet.default.textSync("Successful", { horizontalLayout: "full" })
|
|
6937
|
-
)
|
|
6965
|
+
import_chalk6.default.cyan(import_figlet.default.textSync("Successful", { horizontalLayout: "full" }))
|
|
6938
6966
|
);
|
|
6939
6967
|
await printUploadUrls(result);
|
|
6940
6968
|
if (domainArg) {
|
|
6941
6969
|
console.log(
|
|
6942
|
-
|
|
6970
|
+
import_chalk6.default.blue(
|
|
6943
6971
|
`Binding domain: ${displayDomain} with CID: ${result.contentHash}`
|
|
6944
6972
|
)
|
|
6945
6973
|
);
|
|
@@ -6952,18 +6980,18 @@ var upload_default = async (options) => {
|
|
|
6952
6980
|
throw e;
|
|
6953
6981
|
}
|
|
6954
6982
|
}
|
|
6955
|
-
console.log(
|
|
6983
|
+
console.log(import_chalk6.default.green("\n\u{1F389} upload successful, program exit"));
|
|
6956
6984
|
process.exit(0);
|
|
6957
6985
|
}
|
|
6958
6986
|
} catch (error) {
|
|
6959
|
-
console.error(
|
|
6987
|
+
console.error(import_chalk6.default.red(`error executing: ${error.message}`));
|
|
6960
6988
|
console.error(error.stack);
|
|
6961
6989
|
}
|
|
6962
6990
|
};
|
|
6963
6991
|
|
|
6964
6992
|
// bin/importCar.ts
|
|
6965
6993
|
var import_path7 = __toESM(require("path"));
|
|
6966
|
-
var
|
|
6994
|
+
var import_chalk7 = __toESM(require("chalk"));
|
|
6967
6995
|
var import_inquirer2 = __toESM(require("inquirer"));
|
|
6968
6996
|
var import_figlet2 = __toESM(require("figlet"));
|
|
6969
6997
|
var import_fs3 = __toESM(require("fs"));
|
|
@@ -6994,7 +7022,7 @@ function checkPathSync2(inputPath) {
|
|
|
6994
7022
|
}
|
|
6995
7023
|
return null;
|
|
6996
7024
|
} catch (error) {
|
|
6997
|
-
console.error(
|
|
7025
|
+
console.error(import_chalk7.default.red(`error checking path: ${error.message}`));
|
|
6998
7026
|
return null;
|
|
6999
7027
|
}
|
|
7000
7028
|
}
|
|
@@ -7026,7 +7054,7 @@ var importCar_default = async (options) => {
|
|
|
7026
7054
|
);
|
|
7027
7055
|
const auth = getAuthConfig();
|
|
7028
7056
|
if (!auth) {
|
|
7029
|
-
console.log(
|
|
7057
|
+
console.log(import_chalk7.default.red("Please login first. Run: pinme login"));
|
|
7030
7058
|
return;
|
|
7031
7059
|
}
|
|
7032
7060
|
const argPath = process.argv[3];
|
|
@@ -7034,18 +7062,18 @@ var importCar_default = async (options) => {
|
|
|
7034
7062
|
if (argPath && !argPath.startsWith("-")) {
|
|
7035
7063
|
const absolutePath = checkPathSync2(argPath);
|
|
7036
7064
|
if (!absolutePath) {
|
|
7037
|
-
console.log(
|
|
7065
|
+
console.log(import_chalk7.default.red(`path ${argPath} does not exist`));
|
|
7038
7066
|
return;
|
|
7039
7067
|
}
|
|
7040
7068
|
if (domainArg) {
|
|
7041
7069
|
const check = await checkDomainAvailable(domainArg);
|
|
7042
7070
|
if (!check.is_valid) {
|
|
7043
|
-
console.log(
|
|
7071
|
+
console.log(import_chalk7.default.red(`Domain not available: ${check.error || "unknown reason"}`));
|
|
7044
7072
|
return;
|
|
7045
7073
|
}
|
|
7046
|
-
console.log(
|
|
7074
|
+
console.log(import_chalk7.default.green(`Domain available: ${domainArg}`));
|
|
7047
7075
|
}
|
|
7048
|
-
console.log(
|
|
7076
|
+
console.log(import_chalk7.default.blue(`importing ${absolutePath} to ipfs as CAR...`));
|
|
7049
7077
|
try {
|
|
7050
7078
|
const result = await uploadPath(absolutePath, {
|
|
7051
7079
|
importAsCar: true,
|
|
@@ -7055,27 +7083,30 @@ var importCar_default = async (options) => {
|
|
|
7055
7083
|
const uid = getUid2();
|
|
7056
7084
|
const encryptedCID = encryptHash2(result.contentHash, APP_CONFIG.secretKey, uid);
|
|
7057
7085
|
console.log(
|
|
7058
|
-
|
|
7086
|
+
import_chalk7.default.cyan(
|
|
7059
7087
|
import_figlet2.default.textSync("Successful", { horizontalLayout: "full" })
|
|
7060
7088
|
)
|
|
7061
7089
|
);
|
|
7062
|
-
|
|
7063
|
-
|
|
7090
|
+
printHighlightedUrl(
|
|
7091
|
+
"URL",
|
|
7092
|
+
`${APP_CONFIG.ipfsPreviewUrl}${encryptedCID}`,
|
|
7093
|
+
"primary"
|
|
7094
|
+
);
|
|
7064
7095
|
if (domainArg) {
|
|
7065
|
-
console.log(
|
|
7096
|
+
console.log(import_chalk7.default.blue(`Binding domain: ${domainArg} with CID: ${result.contentHash}`));
|
|
7066
7097
|
const ok = await bindPinmeDomain(domainArg, result.contentHash);
|
|
7067
7098
|
if (ok) {
|
|
7068
|
-
console.log(
|
|
7099
|
+
console.log(import_chalk7.default.green(`Bind success: ${domainArg}`));
|
|
7069
7100
|
const rootDomain = await getRootDomain();
|
|
7070
|
-
console.log(
|
|
7101
|
+
console.log(import_chalk7.default.white(`Visit (Pinme subdomain example): https://${domainArg}.${rootDomain}`));
|
|
7071
7102
|
} else {
|
|
7072
|
-
console.log(
|
|
7103
|
+
console.log(import_chalk7.default.red("Binding failed. Please try again later."));
|
|
7073
7104
|
}
|
|
7074
7105
|
}
|
|
7075
|
-
console.log(
|
|
7106
|
+
console.log(import_chalk7.default.green("\n\u{1F389} import successful, program exit"));
|
|
7076
7107
|
}
|
|
7077
7108
|
} catch (error) {
|
|
7078
|
-
console.error(
|
|
7109
|
+
console.error(import_chalk7.default.red(`Error: ${error.message}`));
|
|
7079
7110
|
}
|
|
7080
7111
|
process.exit(0);
|
|
7081
7112
|
}
|
|
@@ -7089,18 +7120,18 @@ var importCar_default = async (options) => {
|
|
|
7089
7120
|
if (answer.path) {
|
|
7090
7121
|
const absolutePath = checkPathSync2(answer.path);
|
|
7091
7122
|
if (!absolutePath) {
|
|
7092
|
-
console.log(
|
|
7123
|
+
console.log(import_chalk7.default.red(`path ${answer.path} does not exist`));
|
|
7093
7124
|
return;
|
|
7094
7125
|
}
|
|
7095
7126
|
if (domainArg) {
|
|
7096
7127
|
const check = await checkDomainAvailable(domainArg);
|
|
7097
7128
|
if (!check.is_valid) {
|
|
7098
|
-
console.log(
|
|
7129
|
+
console.log(import_chalk7.default.red(`Domain not available: ${check.error || "unknown reason"}`));
|
|
7099
7130
|
return;
|
|
7100
7131
|
}
|
|
7101
|
-
console.log(
|
|
7132
|
+
console.log(import_chalk7.default.green(`Domain available: ${domainArg}`));
|
|
7102
7133
|
}
|
|
7103
|
-
console.log(
|
|
7134
|
+
console.log(import_chalk7.default.blue(`importing ${absolutePath} to ipfs as CAR...`));
|
|
7104
7135
|
try {
|
|
7105
7136
|
const result = await uploadPath(absolutePath, {
|
|
7106
7137
|
importAsCar: true,
|
|
@@ -7110,39 +7141,42 @@ var importCar_default = async (options) => {
|
|
|
7110
7141
|
const uid = getUid2();
|
|
7111
7142
|
const encryptedCID = encryptHash2(result.contentHash, APP_CONFIG.secretKey, uid);
|
|
7112
7143
|
console.log(
|
|
7113
|
-
|
|
7144
|
+
import_chalk7.default.cyan(
|
|
7114
7145
|
import_figlet2.default.textSync("Successful", { horizontalLayout: "full" })
|
|
7115
7146
|
)
|
|
7116
7147
|
);
|
|
7117
|
-
|
|
7118
|
-
|
|
7148
|
+
printHighlightedUrl(
|
|
7149
|
+
"URL",
|
|
7150
|
+
`${APP_CONFIG.ipfsPreviewUrl}${encryptedCID}`,
|
|
7151
|
+
"primary"
|
|
7152
|
+
);
|
|
7119
7153
|
if (domainArg) {
|
|
7120
|
-
console.log(
|
|
7154
|
+
console.log(import_chalk7.default.blue(`Binding domain: ${domainArg} with CID: ${result.contentHash}`));
|
|
7121
7155
|
const ok = await bindPinmeDomain(domainArg, result.contentHash);
|
|
7122
7156
|
if (ok) {
|
|
7123
|
-
console.log(
|
|
7157
|
+
console.log(import_chalk7.default.green(`Bind success: ${domainArg}`));
|
|
7124
7158
|
const rootDomain = await getRootDomain();
|
|
7125
|
-
console.log(
|
|
7159
|
+
console.log(import_chalk7.default.white(`Visit (Pinme subdomain example): https://${domainArg}.${rootDomain}`));
|
|
7126
7160
|
} else {
|
|
7127
|
-
console.log(
|
|
7161
|
+
console.log(import_chalk7.default.red("Binding failed. Please try again later."));
|
|
7128
7162
|
}
|
|
7129
7163
|
}
|
|
7130
|
-
console.log(
|
|
7164
|
+
console.log(import_chalk7.default.green("\n\u{1F389} import successful, program exit"));
|
|
7131
7165
|
}
|
|
7132
7166
|
} catch (error) {
|
|
7133
|
-
console.error(
|
|
7167
|
+
console.error(import_chalk7.default.red(`Error: ${error.message}`));
|
|
7134
7168
|
}
|
|
7135
7169
|
process.exit(0);
|
|
7136
7170
|
}
|
|
7137
7171
|
} catch (error) {
|
|
7138
|
-
console.error(
|
|
7172
|
+
console.error(import_chalk7.default.red(`error executing: ${error.message}`));
|
|
7139
7173
|
console.error(error.stack);
|
|
7140
7174
|
}
|
|
7141
7175
|
};
|
|
7142
7176
|
|
|
7143
7177
|
// bin/exportCar.ts
|
|
7144
7178
|
var import_path8 = __toESM(require("path"));
|
|
7145
|
-
var
|
|
7179
|
+
var import_chalk8 = __toESM(require("chalk"));
|
|
7146
7180
|
var import_inquirer3 = __toESM(require("inquirer"));
|
|
7147
7181
|
var import_figlet3 = __toESM(require("figlet"));
|
|
7148
7182
|
var import_fs4 = __toESM(require("fs"));
|
|
@@ -7169,7 +7203,7 @@ async function pollExportStatus(taskId, cid, spinner, startTime) {
|
|
|
7169
7203
|
spinner.text = `Exporting CAR file... (${minutes}m ${seconds}s)`;
|
|
7170
7204
|
}
|
|
7171
7205
|
} catch (error) {
|
|
7172
|
-
console.log(
|
|
7206
|
+
console.log(import_chalk8.default.yellow(`Polling error: ${error.message}`));
|
|
7173
7207
|
}
|
|
7174
7208
|
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL2));
|
|
7175
7209
|
}
|
|
@@ -7209,7 +7243,7 @@ async function downloadCarFile(downloadUrl, outputPath) {
|
|
|
7209
7243
|
});
|
|
7210
7244
|
});
|
|
7211
7245
|
} catch (error) {
|
|
7212
|
-
console.error(
|
|
7246
|
+
console.error(import_chalk8.default.red(`Download error: ${error.message}`));
|
|
7213
7247
|
return false;
|
|
7214
7248
|
}
|
|
7215
7249
|
}
|
|
@@ -7267,7 +7301,7 @@ var exportCar_default = async () => {
|
|
|
7267
7301
|
cid = answer.cid.trim();
|
|
7268
7302
|
}
|
|
7269
7303
|
if (!cid || !isValidCID(cid)) {
|
|
7270
|
-
console.log(
|
|
7304
|
+
console.log(import_chalk8.default.red("Invalid CID format. CID should start with Qm, bafy, bafk, or bafz"));
|
|
7271
7305
|
return;
|
|
7272
7306
|
}
|
|
7273
7307
|
let outputDir = getOutputPathFromArgs();
|
|
@@ -7287,7 +7321,7 @@ var exportCar_default = async () => {
|
|
|
7287
7321
|
if (!import_fs4.default.existsSync(outputDir)) {
|
|
7288
7322
|
import_fs4.default.mkdirSync(outputDir, { recursive: true });
|
|
7289
7323
|
} else if (!import_fs4.default.statSync(outputDir).isDirectory()) {
|
|
7290
|
-
console.log(
|
|
7324
|
+
console.log(import_chalk8.default.red(`Error: ${outputDir} exists but is not a directory.`));
|
|
7291
7325
|
return;
|
|
7292
7326
|
}
|
|
7293
7327
|
const finalOutputPath = import_path8.default.join(outputDir, `${cid}.car`);
|
|
@@ -7301,7 +7335,7 @@ var exportCar_default = async () => {
|
|
|
7301
7335
|
}
|
|
7302
7336
|
]);
|
|
7303
7337
|
if (!answer.overwrite) {
|
|
7304
|
-
console.log(
|
|
7338
|
+
console.log(import_chalk8.default.blue("Export cancelled."));
|
|
7305
7339
|
return;
|
|
7306
7340
|
}
|
|
7307
7341
|
}
|
|
@@ -7319,7 +7353,7 @@ var exportCar_default = async () => {
|
|
|
7319
7353
|
startTime
|
|
7320
7354
|
);
|
|
7321
7355
|
if (!downloadUrl) {
|
|
7322
|
-
console.log(
|
|
7356
|
+
console.log(import_chalk8.default.red("Export failed or timed out."));
|
|
7323
7357
|
return;
|
|
7324
7358
|
}
|
|
7325
7359
|
const success = await downloadCarFile(downloadUrl, finalOutputPath);
|
|
@@ -7327,42 +7361,42 @@ var exportCar_default = async () => {
|
|
|
7327
7361
|
const fileSize = import_fs4.default.statSync(finalOutputPath).size;
|
|
7328
7362
|
const fileSizeMB = (fileSize / (1024 * 1024)).toFixed(2);
|
|
7329
7363
|
console.log(
|
|
7330
|
-
|
|
7364
|
+
import_chalk8.default.cyan(
|
|
7331
7365
|
import_figlet3.default.textSync("Successful", { horizontalLayout: "full" })
|
|
7332
7366
|
)
|
|
7333
7367
|
);
|
|
7334
|
-
console.log(
|
|
7368
|
+
console.log(import_chalk8.default.green(`
|
|
7335
7369
|
\u{1F389} Export successful!`));
|
|
7336
|
-
console.log(
|
|
7337
|
-
console.log(
|
|
7338
|
-
console.log(
|
|
7370
|
+
console.log(import_chalk8.default.cyan(`File: ${finalOutputPath}`));
|
|
7371
|
+
console.log(import_chalk8.default.cyan(`Size: ${fileSizeMB} MB`));
|
|
7372
|
+
console.log(import_chalk8.default.cyan(`CID: ${cid}`));
|
|
7339
7373
|
} else {
|
|
7340
|
-
console.log(
|
|
7374
|
+
console.log(import_chalk8.default.red("Download failed."));
|
|
7341
7375
|
}
|
|
7342
7376
|
} catch (error) {
|
|
7343
7377
|
spinner.fail(`Error: ${error.message}`);
|
|
7344
|
-
console.error(
|
|
7378
|
+
console.error(import_chalk8.default.red(`Export error: ${error.message}`));
|
|
7345
7379
|
}
|
|
7346
7380
|
} catch (error) {
|
|
7347
|
-
console.error(
|
|
7381
|
+
console.error(import_chalk8.default.red(`error executing: ${error.message}`));
|
|
7348
7382
|
console.error(error.stack);
|
|
7349
7383
|
}
|
|
7350
7384
|
};
|
|
7351
7385
|
|
|
7352
7386
|
// bin/remove.ts
|
|
7353
|
-
var
|
|
7387
|
+
var import_chalk10 = __toESM(require("chalk"));
|
|
7354
7388
|
var import_inquirer4 = __toESM(require("inquirer"));
|
|
7355
7389
|
var import_figlet4 = __toESM(require("figlet"));
|
|
7356
7390
|
|
|
7357
7391
|
// bin/utils/removeFromIpfs.ts
|
|
7358
7392
|
init_axios2();
|
|
7359
|
-
var
|
|
7393
|
+
var import_chalk9 = __toESM(require("chalk"));
|
|
7360
7394
|
init_config();
|
|
7361
7395
|
var ipfsApiUrl = APP_CONFIG.ipfsApiUrl;
|
|
7362
7396
|
async function removeFromIpfs(value, type = "hash") {
|
|
7363
7397
|
try {
|
|
7364
7398
|
const uid = getUid();
|
|
7365
|
-
console.log(
|
|
7399
|
+
console.log(import_chalk9.default.blue(`Removing content from IPFS: ${value}...`));
|
|
7366
7400
|
const queryParams = new URLSearchParams({
|
|
7367
7401
|
uid
|
|
7368
7402
|
});
|
|
@@ -7380,49 +7414,49 @@ async function removeFromIpfs(value, type = "hash") {
|
|
|
7380
7414
|
);
|
|
7381
7415
|
const { code, msg, data } = response.data;
|
|
7382
7416
|
if (code === 200) {
|
|
7383
|
-
console.log(
|
|
7417
|
+
console.log(import_chalk9.default.green("\u2713 Removal successful!"));
|
|
7384
7418
|
console.log(
|
|
7385
|
-
|
|
7419
|
+
import_chalk9.default.cyan(
|
|
7386
7420
|
`Content ${type}: ${value} has been removed from IPFS network`
|
|
7387
7421
|
)
|
|
7388
7422
|
);
|
|
7389
7423
|
return true;
|
|
7390
7424
|
} else {
|
|
7391
|
-
console.log(
|
|
7392
|
-
console.log(
|
|
7425
|
+
console.log(import_chalk9.default.red("\u2717 Removal failed"));
|
|
7426
|
+
console.log(import_chalk9.default.red(`Error: ${msg || "Unknown error occurred"}`));
|
|
7393
7427
|
return false;
|
|
7394
7428
|
}
|
|
7395
7429
|
} catch (error) {
|
|
7396
|
-
console.log(
|
|
7430
|
+
console.log(import_chalk9.default.red("\u2717 Removal failed", error));
|
|
7397
7431
|
if (error.response) {
|
|
7398
7432
|
const { status, data } = error.response;
|
|
7399
7433
|
console.log(
|
|
7400
|
-
|
|
7434
|
+
import_chalk9.default.red(`HTTP Error ${status}: ${(data == null ? void 0 : data.msg) || "Server error"}`)
|
|
7401
7435
|
);
|
|
7402
7436
|
if (status === 404) {
|
|
7403
7437
|
console.log(
|
|
7404
|
-
|
|
7438
|
+
import_chalk9.default.yellow("Content not found on the network or already removed")
|
|
7405
7439
|
);
|
|
7406
7440
|
} else if (status === 403) {
|
|
7407
7441
|
console.log(
|
|
7408
|
-
|
|
7442
|
+
import_chalk9.default.yellow(
|
|
7409
7443
|
"Permission denied - you may not have access to remove this content"
|
|
7410
7444
|
)
|
|
7411
7445
|
);
|
|
7412
7446
|
} else if (status === 500) {
|
|
7413
7447
|
console.log(
|
|
7414
|
-
|
|
7448
|
+
import_chalk9.default.yellow("Server internal error - please try again later")
|
|
7415
7449
|
);
|
|
7416
7450
|
}
|
|
7417
7451
|
} else if (error.request) {
|
|
7418
7452
|
console.log(
|
|
7419
|
-
|
|
7453
|
+
import_chalk9.default.red("Network error: Unable to connect to IPFS service")
|
|
7420
7454
|
);
|
|
7421
7455
|
console.log(
|
|
7422
|
-
|
|
7456
|
+
import_chalk9.default.yellow("Please check your internet connection and try again")
|
|
7423
7457
|
);
|
|
7424
7458
|
} else {
|
|
7425
|
-
console.log(
|
|
7459
|
+
console.log(import_chalk9.default.red(`Error: ${error.message}`));
|
|
7426
7460
|
}
|
|
7427
7461
|
return false;
|
|
7428
7462
|
}
|
|
@@ -7482,29 +7516,29 @@ var remove_default = async (options) => {
|
|
|
7482
7516
|
if (argHash && !argHash.startsWith("-")) {
|
|
7483
7517
|
const parsedInput = parseInput(argHash);
|
|
7484
7518
|
if (!parsedInput) {
|
|
7485
|
-
console.log(
|
|
7486
|
-
console.log(
|
|
7487
|
-
console.log(
|
|
7488
|
-
console.log(
|
|
7489
|
-
console.log(
|
|
7519
|
+
console.log(import_chalk10.default.red(`Invalid input format: ${argHash}`));
|
|
7520
|
+
console.log(import_chalk10.default.yellow("Supported formats:"));
|
|
7521
|
+
console.log(import_chalk10.default.yellow(" - IPFS hash: bafybeig..."));
|
|
7522
|
+
console.log(import_chalk10.default.yellow(" - Subname: 3abt6ztu"));
|
|
7523
|
+
console.log(import_chalk10.default.yellow(" - Subname URL: https://3abt6ztu.<root-domain>"));
|
|
7490
7524
|
return;
|
|
7491
7525
|
}
|
|
7492
7526
|
try {
|
|
7493
7527
|
const success = await removeFromIpfs(parsedInput.value, parsedInput.type);
|
|
7494
7528
|
if (success) {
|
|
7495
7529
|
console.log(
|
|
7496
|
-
|
|
7530
|
+
import_chalk10.default.cyan(
|
|
7497
7531
|
import_figlet4.default.textSync("Successful", { horizontalLayout: "full" })
|
|
7498
7532
|
)
|
|
7499
7533
|
);
|
|
7500
7534
|
}
|
|
7501
7535
|
} catch (error) {
|
|
7502
|
-
console.error(
|
|
7536
|
+
console.error(import_chalk10.default.red(`Error: ${error.message}`));
|
|
7503
7537
|
}
|
|
7504
7538
|
return;
|
|
7505
7539
|
}
|
|
7506
|
-
console.log(
|
|
7507
|
-
console.log(
|
|
7540
|
+
console.log(import_chalk10.default.yellow("\u26A0\uFE0F Warning: This action will permanently remove the content from IPFS network"));
|
|
7541
|
+
console.log(import_chalk10.default.yellow("\u26A0\uFE0F Make sure you have the correct IPFS hash"));
|
|
7508
7542
|
console.log("");
|
|
7509
7543
|
const confirmAnswer = await import_inquirer4.default.prompt([
|
|
7510
7544
|
{
|
|
@@ -7515,7 +7549,7 @@ var remove_default = async (options) => {
|
|
|
7515
7549
|
}
|
|
7516
7550
|
]);
|
|
7517
7551
|
if (!confirmAnswer.confirm) {
|
|
7518
|
-
console.log(
|
|
7552
|
+
console.log(import_chalk10.default.yellow("Operation cancelled"));
|
|
7519
7553
|
return;
|
|
7520
7554
|
}
|
|
7521
7555
|
const answer = await import_inquirer4.default.prompt([
|
|
@@ -7538,7 +7572,7 @@ var remove_default = async (options) => {
|
|
|
7538
7572
|
if (answer.input) {
|
|
7539
7573
|
const parsedInput = parseInput(answer.input.trim());
|
|
7540
7574
|
if (!parsedInput) {
|
|
7541
|
-
console.log(
|
|
7575
|
+
console.log(import_chalk10.default.red("Invalid input format"));
|
|
7542
7576
|
return;
|
|
7543
7577
|
}
|
|
7544
7578
|
const finalConfirm = await import_inquirer4.default.prompt([
|
|
@@ -7550,30 +7584,30 @@ var remove_default = async (options) => {
|
|
|
7550
7584
|
}
|
|
7551
7585
|
]);
|
|
7552
7586
|
if (!finalConfirm.confirm) {
|
|
7553
|
-
console.log(
|
|
7587
|
+
console.log(import_chalk10.default.yellow("Operation cancelled"));
|
|
7554
7588
|
return;
|
|
7555
7589
|
}
|
|
7556
7590
|
try {
|
|
7557
7591
|
const success = await removeFromIpfs(parsedInput.value, parsedInput.type);
|
|
7558
7592
|
if (success) {
|
|
7559
7593
|
console.log(
|
|
7560
|
-
|
|
7594
|
+
import_chalk10.default.cyan(
|
|
7561
7595
|
import_figlet4.default.textSync("Successful", { horizontalLayout: "full" })
|
|
7562
7596
|
)
|
|
7563
7597
|
);
|
|
7564
7598
|
}
|
|
7565
7599
|
} catch (error) {
|
|
7566
|
-
console.error(
|
|
7600
|
+
console.error(import_chalk10.default.red(`Error: ${error.message}`));
|
|
7567
7601
|
}
|
|
7568
7602
|
}
|
|
7569
7603
|
} catch (error) {
|
|
7570
|
-
console.error(
|
|
7604
|
+
console.error(import_chalk10.default.red(`Error executing remove command: ${error.message}`));
|
|
7571
7605
|
console.error(error.stack);
|
|
7572
7606
|
}
|
|
7573
7607
|
};
|
|
7574
7608
|
|
|
7575
7609
|
// bin/set-appkey.ts
|
|
7576
|
-
var
|
|
7610
|
+
var import_chalk11 = __toESM(require("chalk"));
|
|
7577
7611
|
var import_inquirer5 = __toESM(require("inquirer"));
|
|
7578
7612
|
init_webLogin();
|
|
7579
7613
|
init_pinmeApi();
|
|
@@ -7592,32 +7626,32 @@ async function setAppKeyCmd() {
|
|
|
7592
7626
|
appKey = ans.appKey;
|
|
7593
7627
|
}
|
|
7594
7628
|
if (!appKey) {
|
|
7595
|
-
console.log(
|
|
7629
|
+
console.log(import_chalk11.default.red("AppKey not provided."));
|
|
7596
7630
|
return;
|
|
7597
7631
|
}
|
|
7598
7632
|
const saved = setAuthToken(appKey);
|
|
7599
|
-
console.log(
|
|
7633
|
+
console.log(import_chalk11.default.green(`Auth set for address: ${saved.address}`));
|
|
7600
7634
|
const deviceId = getDeviceId();
|
|
7601
7635
|
const ok = await bindAnonymousDevice(deviceId);
|
|
7602
7636
|
if (ok) {
|
|
7603
|
-
console.log(
|
|
7637
|
+
console.log(import_chalk11.default.green("Anonymous history merged to current account."));
|
|
7604
7638
|
} else {
|
|
7605
|
-
console.log(
|
|
7639
|
+
console.log(import_chalk11.default.yellow("Anonymous history merge not confirmed. You may retry later."));
|
|
7606
7640
|
}
|
|
7607
7641
|
} catch (e) {
|
|
7608
|
-
console.log(
|
|
7642
|
+
console.log(import_chalk11.default.red(`Failed to set AppKey: ${(e == null ? void 0 : e.message) || e}`));
|
|
7609
7643
|
}
|
|
7610
7644
|
}
|
|
7611
7645
|
|
|
7612
7646
|
// bin/logout.ts
|
|
7613
|
-
var
|
|
7647
|
+
var import_chalk12 = __toESM(require("chalk"));
|
|
7614
7648
|
var import_inquirer6 = __toESM(require("inquirer"));
|
|
7615
7649
|
init_webLogin();
|
|
7616
7650
|
async function logoutCmd() {
|
|
7617
7651
|
try {
|
|
7618
7652
|
const auth = getAuthConfig();
|
|
7619
7653
|
if (!auth) {
|
|
7620
|
-
console.log(
|
|
7654
|
+
console.log(import_chalk12.default.yellow("No active session found. You are already logged out."));
|
|
7621
7655
|
return;
|
|
7622
7656
|
}
|
|
7623
7657
|
const answer = await import_inquirer6.default.prompt([
|
|
@@ -7629,81 +7663,81 @@ async function logoutCmd() {
|
|
|
7629
7663
|
}
|
|
7630
7664
|
]);
|
|
7631
7665
|
if (!answer.confirm) {
|
|
7632
|
-
console.log(
|
|
7666
|
+
console.log(import_chalk12.default.blue("Logout cancelled."));
|
|
7633
7667
|
return;
|
|
7634
7668
|
}
|
|
7635
7669
|
clearAuthToken();
|
|
7636
|
-
console.log(
|
|
7637
|
-
console.log(
|
|
7670
|
+
console.log(import_chalk12.default.green("Successfully logged out."));
|
|
7671
|
+
console.log(import_chalk12.default.gray(`Address ${auth.address} has been removed from local storage.`));
|
|
7638
7672
|
} catch (e) {
|
|
7639
|
-
console.log(
|
|
7673
|
+
console.log(import_chalk12.default.red(`Failed to logout: ${(e == null ? void 0 : e.message) || e}`));
|
|
7640
7674
|
}
|
|
7641
7675
|
}
|
|
7642
7676
|
|
|
7643
7677
|
// bin/show-appkey.ts
|
|
7644
|
-
var
|
|
7678
|
+
var import_chalk13 = __toESM(require("chalk"));
|
|
7645
7679
|
init_webLogin();
|
|
7646
7680
|
function showAppKeyCmd() {
|
|
7647
7681
|
try {
|
|
7648
7682
|
const auth = getAuthConfig();
|
|
7649
7683
|
if (!auth) {
|
|
7650
|
-
console.log(
|
|
7651
|
-
console.log(
|
|
7684
|
+
console.log(import_chalk13.default.yellow("No AppKey found. Please set your AppKey first."));
|
|
7685
|
+
console.log(import_chalk13.default.gray("Run: pinme set-appkey <AppKey>"));
|
|
7652
7686
|
return;
|
|
7653
7687
|
}
|
|
7654
|
-
console.log(
|
|
7655
|
-
console.log(
|
|
7688
|
+
console.log(import_chalk13.default.green("Current AppKey Information:"));
|
|
7689
|
+
console.log(import_chalk13.default.cyan(` Address: ${auth.address}`));
|
|
7656
7690
|
const token = auth.token;
|
|
7657
7691
|
if (token.length > 12) {
|
|
7658
7692
|
const maskedToken = `${token.substring(0, 8)}${"*".repeat(token.length - 12)}${token.substring(token.length - 4)}`;
|
|
7659
|
-
console.log(
|
|
7693
|
+
console.log(import_chalk13.default.cyan(` Token: ${maskedToken}`));
|
|
7660
7694
|
} else {
|
|
7661
|
-
console.log(
|
|
7695
|
+
console.log(import_chalk13.default.cyan(` Token: ${"*".repeat(token.length)}`));
|
|
7662
7696
|
}
|
|
7663
7697
|
const combined = `${auth.address}-${auth.token}`;
|
|
7664
7698
|
if (combined.length > 20) {
|
|
7665
7699
|
const maskedAppKey = `${combined.substring(0, 12)}${"*".repeat(combined.length - 16)}${combined.substring(combined.length - 4)}`;
|
|
7666
|
-
console.log(
|
|
7700
|
+
console.log(import_chalk13.default.cyan(` AppKey: ${maskedAppKey}`));
|
|
7667
7701
|
} else {
|
|
7668
|
-
console.log(
|
|
7702
|
+
console.log(import_chalk13.default.cyan(` AppKey: ${"*".repeat(combined.length)}`));
|
|
7669
7703
|
}
|
|
7670
7704
|
} catch (e) {
|
|
7671
|
-
console.log(
|
|
7705
|
+
console.log(import_chalk13.default.red(`Failed to show AppKey: ${(e == null ? void 0 : e.message) || e}`));
|
|
7672
7706
|
}
|
|
7673
7707
|
}
|
|
7674
7708
|
|
|
7675
7709
|
// bin/my-domains.ts
|
|
7676
|
-
var
|
|
7710
|
+
var import_chalk14 = __toESM(require("chalk"));
|
|
7677
7711
|
var import_dayjs2 = __toESM(require("dayjs"));
|
|
7678
7712
|
init_pinmeApi();
|
|
7679
7713
|
async function myDomainsCmd() {
|
|
7680
7714
|
try {
|
|
7681
7715
|
const list = await getMyDomains();
|
|
7682
7716
|
if (!list.length) {
|
|
7683
|
-
console.log(
|
|
7717
|
+
console.log(import_chalk14.default.yellow("No bound domains found."));
|
|
7684
7718
|
return;
|
|
7685
7719
|
}
|
|
7686
|
-
console.log(
|
|
7687
|
-
console.log(
|
|
7720
|
+
console.log(import_chalk14.default.cyan("My domains:"));
|
|
7721
|
+
console.log(import_chalk14.default.cyan("-".repeat(80)));
|
|
7688
7722
|
list.forEach((item, i) => {
|
|
7689
|
-
console.log(
|
|
7690
|
-
console.log(
|
|
7723
|
+
console.log(import_chalk14.default.green(`${i + 1}. ${item.domain_name}`));
|
|
7724
|
+
console.log(import_chalk14.default.white(` Type: ${item.domain_type}`));
|
|
7691
7725
|
if (item.bind_time) {
|
|
7692
|
-
console.log(
|
|
7726
|
+
console.log(import_chalk14.default.white(` Bind time: ${(0, import_dayjs2.default)(item.bind_time * 1e3).format("YYYY-MM-DD HH:mm:ss")}`));
|
|
7693
7727
|
}
|
|
7694
7728
|
if (typeof item.expire_time === "number") {
|
|
7695
7729
|
const label = item.expire_time === 0 ? "Never" : (0, import_dayjs2.default)(item.expire_time * 1e3).format("YYYY-MM-DD HH:mm:ss");
|
|
7696
|
-
console.log(
|
|
7730
|
+
console.log(import_chalk14.default.white(` Expire time: ${label}`));
|
|
7697
7731
|
}
|
|
7698
|
-
console.log(
|
|
7732
|
+
console.log(import_chalk14.default.cyan("-".repeat(80)));
|
|
7699
7733
|
});
|
|
7700
7734
|
} catch (e) {
|
|
7701
|
-
console.log(
|
|
7735
|
+
console.log(import_chalk14.default.red(`Failed to fetch domains: ${(e == null ? void 0 : e.message) || e}`));
|
|
7702
7736
|
}
|
|
7703
7737
|
}
|
|
7704
7738
|
|
|
7705
7739
|
// bin/wallet-balance.ts
|
|
7706
|
-
var
|
|
7740
|
+
var import_chalk15 = __toESM(require("chalk"));
|
|
7707
7741
|
init_pinmeApi();
|
|
7708
7742
|
init_webLogin();
|
|
7709
7743
|
async function walletBalanceCmd() {
|
|
@@ -7711,25 +7745,25 @@ async function walletBalanceCmd() {
|
|
|
7711
7745
|
try {
|
|
7712
7746
|
const auth = getAuthConfig();
|
|
7713
7747
|
if (!auth) {
|
|
7714
|
-
console.log(
|
|
7748
|
+
console.log(import_chalk15.default.yellow("Please login first. Run: pinme set-appkey <AppKey>"));
|
|
7715
7749
|
return;
|
|
7716
7750
|
}
|
|
7717
7751
|
const result = await getWalletBalance(auth.address, auth.token);
|
|
7718
7752
|
const balance = Number(((_a2 = result.data) == null ? void 0 : _a2.wallet_balance_usd) ?? 0);
|
|
7719
7753
|
if (!Number.isFinite(balance)) {
|
|
7720
|
-
console.log(
|
|
7754
|
+
console.log(import_chalk15.default.red("Failed to parse wallet balance."));
|
|
7721
7755
|
return;
|
|
7722
7756
|
}
|
|
7723
|
-
console.log(
|
|
7724
|
-
console.log(
|
|
7757
|
+
console.log(import_chalk15.default.cyan("Wallet balance:"));
|
|
7758
|
+
console.log(import_chalk15.default.green(` USD: $${balance.toFixed(2)}`));
|
|
7725
7759
|
} catch (e) {
|
|
7726
|
-
console.log(
|
|
7760
|
+
console.log(import_chalk15.default.red(`Failed to fetch wallet balance: ${(e == null ? void 0 : e.message) || e}`));
|
|
7727
7761
|
}
|
|
7728
7762
|
}
|
|
7729
7763
|
|
|
7730
7764
|
// bin/bind.ts
|
|
7731
7765
|
var import_path9 = __toESM(require("path"));
|
|
7732
|
-
var
|
|
7766
|
+
var import_chalk16 = __toESM(require("chalk"));
|
|
7733
7767
|
var import_inquirer7 = __toESM(require("inquirer"));
|
|
7734
7768
|
init_pinmeApi();
|
|
7735
7769
|
init_webLogin();
|
|
@@ -7753,20 +7787,20 @@ function parseArgs() {
|
|
|
7753
7787
|
}
|
|
7754
7788
|
async function checkWalletBalanceStatus2(authConfig) {
|
|
7755
7789
|
var _a2;
|
|
7756
|
-
console.log(
|
|
7790
|
+
console.log(import_chalk16.default.blue("Checking wallet balance..."));
|
|
7757
7791
|
try {
|
|
7758
7792
|
const balanceResult = await getWalletBalance(authConfig.address, authConfig.token);
|
|
7759
7793
|
const balance = Number(((_a2 = balanceResult.data) == null ? void 0 : _a2.wallet_balance_usd) ?? 0);
|
|
7760
7794
|
if (!Number.isFinite(balance) || balance <= 0) {
|
|
7761
7795
|
return false;
|
|
7762
7796
|
}
|
|
7763
|
-
console.log(
|
|
7797
|
+
console.log(import_chalk16.default.green(`Wallet balance available: $${balance.toFixed(2)}`));
|
|
7764
7798
|
return true;
|
|
7765
7799
|
} catch (e) {
|
|
7766
7800
|
if (e.message === "Token expired") {
|
|
7767
7801
|
throw e;
|
|
7768
7802
|
}
|
|
7769
|
-
console.log(
|
|
7803
|
+
console.log(import_chalk16.default.yellow("Failed to check wallet balance, continuing..."));
|
|
7770
7804
|
return true;
|
|
7771
7805
|
}
|
|
7772
7806
|
}
|
|
@@ -7776,7 +7810,7 @@ async function bindCmd() {
|
|
|
7776
7810
|
let { domain, targetPath, dns } = parseArgs();
|
|
7777
7811
|
const authConfig = getAuthConfig();
|
|
7778
7812
|
if (!authConfig) {
|
|
7779
|
-
console.log(
|
|
7813
|
+
console.log(import_chalk16.default.red("Please login first. Run: pinme set-appkey <AppKey>"));
|
|
7780
7814
|
return;
|
|
7781
7815
|
}
|
|
7782
7816
|
if (!targetPath) {
|
|
@@ -7792,7 +7826,7 @@ async function bindCmd() {
|
|
|
7792
7826
|
domain = (_a2 = ans.domain) == null ? void 0 : _a2.trim();
|
|
7793
7827
|
}
|
|
7794
7828
|
if (!targetPath || !domain) {
|
|
7795
|
-
console.log(
|
|
7829
|
+
console.log(import_chalk16.default.red("Missing parameters. Path and domain are required."));
|
|
7796
7830
|
return;
|
|
7797
7831
|
}
|
|
7798
7832
|
const isDns = dns || isDnsDomain(domain);
|
|
@@ -7800,14 +7834,14 @@ async function bindCmd() {
|
|
|
7800
7834
|
if (isDns) {
|
|
7801
7835
|
const validation = validateDnsDomain(domain);
|
|
7802
7836
|
if (!validation.valid) {
|
|
7803
|
-
console.log(
|
|
7837
|
+
console.log(import_chalk16.default.red(validation.message));
|
|
7804
7838
|
return;
|
|
7805
7839
|
}
|
|
7806
7840
|
}
|
|
7807
7841
|
try {
|
|
7808
7842
|
const hasWalletBalance = await checkWalletBalanceStatus2(authConfig);
|
|
7809
7843
|
if (!hasWalletBalance) {
|
|
7810
|
-
console.log(
|
|
7844
|
+
console.log(import_chalk16.default.red("Insufficient wallet balance. Please recharge your wallet first."));
|
|
7811
7845
|
return;
|
|
7812
7846
|
}
|
|
7813
7847
|
} catch (e) {
|
|
@@ -7819,10 +7853,10 @@ async function bindCmd() {
|
|
|
7819
7853
|
try {
|
|
7820
7854
|
const check = await checkDomainAvailable(displayDomain);
|
|
7821
7855
|
if (!check.is_valid) {
|
|
7822
|
-
console.log(
|
|
7856
|
+
console.log(import_chalk16.default.red(`Domain not available: ${check.error || "unknown reason"}`));
|
|
7823
7857
|
return;
|
|
7824
7858
|
}
|
|
7825
|
-
console.log(
|
|
7859
|
+
console.log(import_chalk16.default.green(`Domain available: ${displayDomain}`));
|
|
7826
7860
|
} catch (e) {
|
|
7827
7861
|
if (e.message === "Token expired") {
|
|
7828
7862
|
return;
|
|
@@ -7830,34 +7864,34 @@ async function bindCmd() {
|
|
|
7830
7864
|
throw e;
|
|
7831
7865
|
}
|
|
7832
7866
|
const absolutePath = import_path9.default.resolve(targetPath);
|
|
7833
|
-
console.log(
|
|
7867
|
+
console.log(import_chalk16.default.blue(`Uploading: ${absolutePath}`));
|
|
7834
7868
|
const up = await uploadPath(absolutePath, { uid: authConfig.address });
|
|
7835
7869
|
if (!(up == null ? void 0 : up.contentHash)) {
|
|
7836
|
-
console.log(
|
|
7870
|
+
console.log(import_chalk16.default.red("Upload failed, binding aborted."));
|
|
7837
7871
|
return;
|
|
7838
7872
|
}
|
|
7839
|
-
console.log(
|
|
7873
|
+
console.log(import_chalk16.default.green(`Upload success, CID: ${up.contentHash}`));
|
|
7840
7874
|
try {
|
|
7841
7875
|
if (isDns) {
|
|
7842
|
-
console.log(
|
|
7876
|
+
console.log(import_chalk16.default.blue("Binding DNS domain..."));
|
|
7843
7877
|
const dnsResult = await bindDnsDomainV4(displayDomain, up.contentHash, authConfig.address, authConfig.token);
|
|
7844
7878
|
if (dnsResult.code !== 200) {
|
|
7845
|
-
console.log(
|
|
7879
|
+
console.log(import_chalk16.default.red(`DNS binding failed: ${dnsResult.msg}`));
|
|
7846
7880
|
return;
|
|
7847
7881
|
}
|
|
7848
|
-
console.log(
|
|
7849
|
-
console.log(
|
|
7850
|
-
console.log(
|
|
7882
|
+
console.log(import_chalk16.default.green(`DNS bind success: ${displayDomain}`));
|
|
7883
|
+
console.log(import_chalk16.default.white(`Visit: https://${displayDomain}`));
|
|
7884
|
+
console.log(import_chalk16.default.cyan("\n\u{1F4DA} DNS Setup Guide: https://pinme.eth.limo/#/docs?id=custom-domain"));
|
|
7851
7885
|
} else {
|
|
7852
|
-
console.log(
|
|
7886
|
+
console.log(import_chalk16.default.blue("Binding Pinme subdomain..."));
|
|
7853
7887
|
const ok = await bindPinmeDomain(displayDomain, up.contentHash);
|
|
7854
7888
|
if (!ok) {
|
|
7855
|
-
console.log(
|
|
7889
|
+
console.log(import_chalk16.default.red("Binding failed. Please try again later."));
|
|
7856
7890
|
return;
|
|
7857
7891
|
}
|
|
7858
|
-
console.log(
|
|
7892
|
+
console.log(import_chalk16.default.green(`Bind success: ${displayDomain}`));
|
|
7859
7893
|
const rootDomain = await getRootDomain();
|
|
7860
|
-
console.log(
|
|
7894
|
+
console.log(import_chalk16.default.white(`Visit: https://${displayDomain}.${rootDomain}`));
|
|
7861
7895
|
}
|
|
7862
7896
|
} catch (e) {
|
|
7863
7897
|
if (e.message === "Token expired") {
|
|
@@ -7866,12 +7900,12 @@ async function bindCmd() {
|
|
|
7866
7900
|
throw e;
|
|
7867
7901
|
}
|
|
7868
7902
|
} catch (e) {
|
|
7869
|
-
console.log(
|
|
7903
|
+
console.log(import_chalk16.default.red(`Execution failed: ${(e == null ? void 0 : e.message) || e}`));
|
|
7870
7904
|
}
|
|
7871
7905
|
}
|
|
7872
7906
|
|
|
7873
7907
|
// bin/login.ts
|
|
7874
|
-
var
|
|
7908
|
+
var import_chalk17 = __toESM(require("chalk"));
|
|
7875
7909
|
init_webLogin();
|
|
7876
7910
|
init_pinmeApi();
|
|
7877
7911
|
var ENV_URLS = {
|
|
@@ -7885,34 +7919,34 @@ async function loginCmd(options = {}) {
|
|
|
7885
7919
|
const env = (options.env || "prod").toLowerCase();
|
|
7886
7920
|
if (ENV_URLS[env]) {
|
|
7887
7921
|
webBaseUrl = ENV_URLS[env];
|
|
7888
|
-
console.log(
|
|
7922
|
+
console.log(import_chalk17.default.blue(`Using ${env} environment: ${webBaseUrl}`));
|
|
7889
7923
|
} else {
|
|
7890
7924
|
console.log(
|
|
7891
|
-
|
|
7925
|
+
import_chalk17.default.yellow(
|
|
7892
7926
|
`Unknown environment: ${options.env}. Using default prod.`
|
|
7893
7927
|
)
|
|
7894
7928
|
);
|
|
7895
7929
|
webBaseUrl = ENV_URLS.prod;
|
|
7896
|
-
console.log(
|
|
7930
|
+
console.log(import_chalk17.default.blue(`Using prod environment: ${webBaseUrl}`));
|
|
7897
7931
|
}
|
|
7898
7932
|
const manager = new WebLoginManager({ webBaseUrl });
|
|
7899
7933
|
await manager.login();
|
|
7900
|
-
console.log(
|
|
7934
|
+
console.log(import_chalk17.default.blue("\nMerging history..."));
|
|
7901
7935
|
const deviceId = getDeviceId();
|
|
7902
7936
|
const ok = await bindAnonymousDevice(deviceId);
|
|
7903
7937
|
if (ok) {
|
|
7904
|
-
console.log(
|
|
7938
|
+
console.log(import_chalk17.default.green("History merged to your account"));
|
|
7905
7939
|
}
|
|
7906
7940
|
process.exit(0);
|
|
7907
7941
|
} catch (e) {
|
|
7908
|
-
console.log(
|
|
7942
|
+
console.log(import_chalk17.default.red(`
|
|
7909
7943
|
Login failed: ${(e == null ? void 0 : e.message) || e}`));
|
|
7910
7944
|
process.exit(1);
|
|
7911
7945
|
}
|
|
7912
7946
|
}
|
|
7913
7947
|
|
|
7914
7948
|
// bin/create.ts
|
|
7915
|
-
var
|
|
7949
|
+
var import_chalk20 = __toESM(require("chalk"));
|
|
7916
7950
|
var import_fs_extra6 = __toESM(require("fs-extra"));
|
|
7917
7951
|
var import_path11 = __toESM(require("path"));
|
|
7918
7952
|
var import_inquirer8 = __toESM(require("inquirer"));
|
|
@@ -7924,7 +7958,7 @@ init_webLogin();
|
|
|
7924
7958
|
var import_fs_extra5 = __toESM(require("fs-extra"));
|
|
7925
7959
|
var import_os4 = __toESM(require("os"));
|
|
7926
7960
|
var import_path10 = __toESM(require("path"));
|
|
7927
|
-
var
|
|
7961
|
+
var import_chalk18 = __toESM(require("chalk"));
|
|
7928
7962
|
var import_child_process2 = require("child_process");
|
|
7929
7963
|
function makeTempCacheDir() {
|
|
7930
7964
|
return import_fs_extra5.default.mkdtempSync(import_path10.default.join(import_os4.default.tmpdir(), "pinme-npm-cache-"));
|
|
@@ -7947,7 +7981,7 @@ function installProjectDependencies(cwd) {
|
|
|
7947
7981
|
const cacheDir = makeTempCacheDir();
|
|
7948
7982
|
try {
|
|
7949
7983
|
if (attempt > 1) {
|
|
7950
|
-
console.log(
|
|
7984
|
+
console.log(import_chalk18.default.yellow(" Retrying dependency install with a fresh npm cache..."));
|
|
7951
7985
|
}
|
|
7952
7986
|
runInstall(cwd, cacheDir);
|
|
7953
7987
|
return;
|
|
@@ -7961,7 +7995,7 @@ function installProjectDependencies(cwd) {
|
|
|
7961
7995
|
}
|
|
7962
7996
|
|
|
7963
7997
|
// bin/utils/cliError.ts
|
|
7964
|
-
var
|
|
7998
|
+
var import_chalk19 = __toESM(require("chalk"));
|
|
7965
7999
|
var CliError = class extends Error {
|
|
7966
8000
|
stage;
|
|
7967
8001
|
details;
|
|
@@ -8092,18 +8126,18 @@ function normalizeCliError(error, fallbackSummary, suggestions = []) {
|
|
|
8092
8126
|
}
|
|
8093
8127
|
function printCliError(error, fallbackSummary) {
|
|
8094
8128
|
const cliError = normalizeCliError(error, fallbackSummary);
|
|
8095
|
-
console.error(
|
|
8129
|
+
console.error(import_chalk19.default.red(`
|
|
8096
8130
|
Error: ${cliError.message}`));
|
|
8097
8131
|
if (cliError.stage) {
|
|
8098
|
-
console.error(
|
|
8132
|
+
console.error(import_chalk19.default.gray(`Stage: ${cliError.stage}`));
|
|
8099
8133
|
}
|
|
8100
8134
|
for (const detail of cliError.details) {
|
|
8101
|
-
console.error(
|
|
8135
|
+
console.error(import_chalk19.default.gray(detail));
|
|
8102
8136
|
}
|
|
8103
8137
|
if (cliError.suggestions.length > 0) {
|
|
8104
|
-
console.error(
|
|
8138
|
+
console.error(import_chalk19.default.yellow("\nNext steps:"));
|
|
8105
8139
|
for (const suggestion of cliError.suggestions) {
|
|
8106
|
-
console.error(
|
|
8140
|
+
console.error(import_chalk19.default.yellow(`- ${suggestion}`));
|
|
8107
8141
|
}
|
|
8108
8142
|
}
|
|
8109
8143
|
}
|
|
@@ -8164,6 +8198,9 @@ function updateFrontendUrlInConfig(configPath, frontendUrl) {
|
|
|
8164
8198
|
}
|
|
8165
8199
|
import_fs_extra6.default.writeFileSync(configPath, config);
|
|
8166
8200
|
}
|
|
8201
|
+
function getProjectManagementUrl(projectName) {
|
|
8202
|
+
return `${APP_CONFIG.projectPeviewUrl}${projectName}`;
|
|
8203
|
+
}
|
|
8167
8204
|
async function createCmd(options) {
|
|
8168
8205
|
var _a2, _b;
|
|
8169
8206
|
try {
|
|
@@ -8173,7 +8210,7 @@ async function createCmd(options) {
|
|
|
8173
8210
|
"Run `pinme login` and retry."
|
|
8174
8211
|
]);
|
|
8175
8212
|
}
|
|
8176
|
-
console.log(
|
|
8213
|
+
console.log(import_chalk20.default.blue("Creating new project from template...\n"));
|
|
8177
8214
|
let projectName = options.name;
|
|
8178
8215
|
if (!projectName) {
|
|
8179
8216
|
const answers = await import_inquirer8.default.prompt([
|
|
@@ -8194,7 +8231,7 @@ async function createCmd(options) {
|
|
|
8194
8231
|
}
|
|
8195
8232
|
const targetDir = import_path11.default.join(PROJECT_DIR, projectName);
|
|
8196
8233
|
if (import_fs_extra6.default.existsSync(targetDir) && !options.force) {
|
|
8197
|
-
console.log(
|
|
8234
|
+
console.log(import_chalk20.default.yellow(`
|
|
8198
8235
|
Directory "${projectName}" already exists.`));
|
|
8199
8236
|
const answers = await import_inquirer8.default.prompt([
|
|
8200
8237
|
{
|
|
@@ -8205,16 +8242,16 @@ Directory "${projectName}" already exists.`));
|
|
|
8205
8242
|
}
|
|
8206
8243
|
]);
|
|
8207
8244
|
if (!answers.overwrite) {
|
|
8208
|
-
console.log(
|
|
8245
|
+
console.log(import_chalk20.default.gray("Cancelled."));
|
|
8209
8246
|
process.exit(0);
|
|
8210
8247
|
}
|
|
8211
8248
|
import_fs_extra6.default.removeSync(targetDir);
|
|
8212
8249
|
}
|
|
8213
|
-
console.log(
|
|
8250
|
+
console.log(import_chalk20.default.blue("\n1. Creating worker and database..."));
|
|
8214
8251
|
const apiUrl = getPinmeApiUrl("/create_worker");
|
|
8215
|
-
console.log(
|
|
8252
|
+
console.log(import_chalk20.default.gray(`API URL: ${apiUrl}`));
|
|
8216
8253
|
const normalizedProjectName = projectName.toLowerCase();
|
|
8217
|
-
console.log(
|
|
8254
|
+
console.log(import_chalk20.default.gray(`Project name: ${normalizedProjectName}`));
|
|
8218
8255
|
let workerData;
|
|
8219
8256
|
try {
|
|
8220
8257
|
const response = await axios_default.post(apiUrl, {
|
|
@@ -8233,24 +8270,24 @@ Directory "${projectName}" already exists.`));
|
|
|
8233
8270
|
]);
|
|
8234
8271
|
}
|
|
8235
8272
|
workerData = data.data;
|
|
8236
|
-
console.log(
|
|
8237
|
-
console.log(
|
|
8238
|
-
console.log(
|
|
8273
|
+
console.log(import_chalk20.default.gray(` API Response: ${JSON.stringify(workerData)}`));
|
|
8274
|
+
console.log(import_chalk20.default.green(` API Domain: ${workerData.api_domain}`));
|
|
8275
|
+
console.log(import_chalk20.default.green(` Project Name: ${workerData.project_name}`));
|
|
8239
8276
|
} catch (error) {
|
|
8240
8277
|
throw createApiError("project creation", error, [
|
|
8241
8278
|
`Project name: ${normalizedProjectName}`,
|
|
8242
8279
|
`Endpoint: ${apiUrl}`
|
|
8243
8280
|
]);
|
|
8244
8281
|
}
|
|
8245
|
-
console.log(
|
|
8282
|
+
console.log(import_chalk20.default.blue("\n2. Downloading template from repository..."));
|
|
8246
8283
|
const zipPath = import_path11.default.join(PROJECT_DIR, "template.zip");
|
|
8247
8284
|
const extractDir = import_path11.default.join(PROJECT_DIR, `.pinme-template-${Date.now()}`);
|
|
8248
8285
|
const templateZipUrl = getTemplateZipUrl(TEMPLATE_BRANCH);
|
|
8249
8286
|
let downloadSuccess = false;
|
|
8250
|
-
console.log(
|
|
8287
|
+
console.log(import_chalk20.default.gray(` Template branch: ${TEMPLATE_BRANCH}`));
|
|
8251
8288
|
for (let attempt = 1; attempt <= 3 && !downloadSuccess; attempt++) {
|
|
8252
8289
|
try {
|
|
8253
|
-
console.log(
|
|
8290
|
+
console.log(import_chalk20.default.gray(` Download attempt ${attempt}/3...`));
|
|
8254
8291
|
(0, import_child_process3.execSync)(`curl -L --retry 3 --retry-delay 2 -o "${zipPath}" "${templateZipUrl}"`, {
|
|
8255
8292
|
stdio: "inherit"
|
|
8256
8293
|
});
|
|
@@ -8259,7 +8296,7 @@ Directory "${projectName}" already exists.`));
|
|
|
8259
8296
|
}
|
|
8260
8297
|
downloadSuccess = true;
|
|
8261
8298
|
} catch (downloadError) {
|
|
8262
|
-
console.log(
|
|
8299
|
+
console.log(import_chalk20.default.yellow(` Attempt ${attempt} failed: ${downloadError.message}`));
|
|
8263
8300
|
if (import_fs_extra6.default.existsSync(zipPath)) {
|
|
8264
8301
|
import_fs_extra6.default.removeSync(zipPath);
|
|
8265
8302
|
}
|
|
@@ -8280,11 +8317,11 @@ Directory "${projectName}" already exists.`));
|
|
|
8280
8317
|
const nodeModulesPath = import_path11.default.join(targetDir, "node_modules");
|
|
8281
8318
|
const packageLockPath = import_path11.default.join(targetDir, "package-lock.json");
|
|
8282
8319
|
if (import_fs_extra6.default.existsSync(nodeModulesPath)) {
|
|
8283
|
-
console.log(
|
|
8320
|
+
console.log(import_chalk20.default.gray(" Removing existing node_modules..."));
|
|
8284
8321
|
import_fs_extra6.default.removeSync(nodeModulesPath);
|
|
8285
8322
|
}
|
|
8286
8323
|
if (import_fs_extra6.default.existsSync(packageLockPath)) {
|
|
8287
|
-
console.log(
|
|
8324
|
+
console.log(import_chalk20.default.gray(" Removing existing package-lock.json..."));
|
|
8288
8325
|
import_fs_extra6.default.removeSync(packageLockPath);
|
|
8289
8326
|
}
|
|
8290
8327
|
const frontendNodeModules = import_path11.default.join(targetDir, "frontend", "node_modules");
|
|
@@ -8295,13 +8332,13 @@ Directory "${projectName}" already exists.`));
|
|
|
8295
8332
|
if (import_fs_extra6.default.existsSync(backendNodeModules)) import_fs_extra6.default.removeSync(backendNodeModules);
|
|
8296
8333
|
if (import_fs_extra6.default.existsSync(frontendPackageLock)) import_fs_extra6.default.removeSync(frontendPackageLock);
|
|
8297
8334
|
if (import_fs_extra6.default.existsSync(backendPackageLock)) import_fs_extra6.default.removeSync(backendPackageLock);
|
|
8298
|
-
console.log(
|
|
8335
|
+
console.log(import_chalk20.default.green(` Template downloaded to: ${targetDir}`));
|
|
8299
8336
|
} catch (error) {
|
|
8300
8337
|
throw createCommandError("template extraction", `unzip -o "${zipPath}" -d "${PROJECT_DIR}"`, error, [
|
|
8301
8338
|
"Check whether `unzip` is available and the downloaded template archive is valid."
|
|
8302
8339
|
]);
|
|
8303
8340
|
}
|
|
8304
|
-
console.log(
|
|
8341
|
+
console.log(import_chalk20.default.blue("\n3. Updating configuration..."));
|
|
8305
8342
|
const configPath = import_path11.default.join(targetDir, "pinme.toml");
|
|
8306
8343
|
const config = import_fs_extra6.default.readFileSync(configPath, "utf-8");
|
|
8307
8344
|
let updatedConfig = config.replace(
|
|
@@ -8309,8 +8346,8 @@ Directory "${projectName}" already exists.`));
|
|
|
8309
8346
|
`project_name = "${workerData.project_name}"`
|
|
8310
8347
|
);
|
|
8311
8348
|
import_fs_extra6.default.writeFileSync(configPath, updatedConfig);
|
|
8312
|
-
console.log(
|
|
8313
|
-
console.log(
|
|
8349
|
+
console.log(import_chalk20.default.green(` Updated pinme.toml`));
|
|
8350
|
+
console.log(import_chalk20.default.gray(` metadata: ${workerData.metadata}`));
|
|
8314
8351
|
const backendDir = import_path11.default.join(targetDir, "backend");
|
|
8315
8352
|
if (import_fs_extra6.default.existsSync(backendDir) && workerData.metadata) {
|
|
8316
8353
|
const metadataContent = typeof workerData.metadata === "string" ? workerData.metadata : JSON.stringify(workerData.metadata, null, 2);
|
|
@@ -8318,7 +8355,7 @@ Directory "${projectName}" already exists.`));
|
|
|
8318
8355
|
import_path11.default.join(backendDir, "metadata.json"),
|
|
8319
8356
|
metadataContent
|
|
8320
8357
|
);
|
|
8321
|
-
console.log(
|
|
8358
|
+
console.log(import_chalk20.default.green(` Saved metadata.json`));
|
|
8322
8359
|
}
|
|
8323
8360
|
const wranglerPath = import_path11.default.join(backendDir, "wrangler.toml");
|
|
8324
8361
|
if (import_fs_extra6.default.existsSync(wranglerPath) && workerData.api_key) {
|
|
@@ -8328,7 +8365,7 @@ Directory "${projectName}" already exists.`));
|
|
|
8328
8365
|
`name = "${workerData.project_name}"`
|
|
8329
8366
|
);
|
|
8330
8367
|
import_fs_extra6.default.writeFileSync(wranglerPath, wranglerContent);
|
|
8331
|
-
console.log(
|
|
8368
|
+
console.log(import_chalk20.default.green(` Updated backend/wrangler.toml API_KEY`));
|
|
8332
8369
|
}
|
|
8333
8370
|
const frontendConfigPath = import_path11.default.join(targetDir, "frontend", "src", "utils", "config.ts");
|
|
8334
8371
|
if (workerData.public_client_config) {
|
|
@@ -8338,7 +8375,7 @@ Directory "${projectName}" already exists.`));
|
|
|
8338
8375
|
frontendConfigPath,
|
|
8339
8376
|
injectPublicClientConfigIntoFile(frontendConfigContent, workerData.public_client_config)
|
|
8340
8377
|
);
|
|
8341
|
-
console.log(
|
|
8378
|
+
console.log(import_chalk20.default.green(` Updated frontend/src/utils/config.ts public_client_config`));
|
|
8342
8379
|
}
|
|
8343
8380
|
const envExamplePath = import_path11.default.join(targetDir, "frontend", ".env.example");
|
|
8344
8381
|
const envPath = import_path11.default.join(targetDir, "frontend", ".env");
|
|
@@ -8350,8 +8387,8 @@ Directory "${projectName}" already exists.`));
|
|
|
8350
8387
|
`VITE_API_URL=${workerData.api_domain}`
|
|
8351
8388
|
);
|
|
8352
8389
|
import_fs_extra6.default.writeFileSync(envPath, envContent);
|
|
8353
|
-
console.log(
|
|
8354
|
-
console.log(
|
|
8390
|
+
console.log(import_chalk20.default.green(` Created frontend/.env file`));
|
|
8391
|
+
console.log(import_chalk20.default.gray(` VITE_API_URL: ${workerData.api_domain}`));
|
|
8355
8392
|
}
|
|
8356
8393
|
let pinmeConfig = import_fs_extra6.default.readFileSync(configPath, "utf-8");
|
|
8357
8394
|
if (pinmeConfig.includes("api_url")) {
|
|
@@ -8371,11 +8408,11 @@ Directory "${projectName}" already exists.`));
|
|
|
8371
8408
|
pinmeConfig = newLines.join("\n");
|
|
8372
8409
|
}
|
|
8373
8410
|
import_fs_extra6.default.writeFileSync(configPath, pinmeConfig);
|
|
8374
|
-
console.log(
|
|
8375
|
-
console.log(
|
|
8411
|
+
console.log(import_chalk20.default.green(` Updated pinme.toml with api_url`));
|
|
8412
|
+
console.log(import_chalk20.default.blue("\n4. Installing dependencies..."));
|
|
8376
8413
|
try {
|
|
8377
8414
|
installProjectDependencies(targetDir);
|
|
8378
|
-
console.log(
|
|
8415
|
+
console.log(import_chalk20.default.green(" Project dependencies installed"));
|
|
8379
8416
|
} catch (error) {
|
|
8380
8417
|
const errorMsg = error.message || "";
|
|
8381
8418
|
if (errorMsg.includes("EACCES") || errorMsg.includes("EPERM") || errorMsg.includes("permission denied")) {
|
|
@@ -8414,13 +8451,13 @@ Directory "${projectName}" already exists.`));
|
|
|
8414
8451
|
" sudo chown -R $(whoami) " + targetDir + "/node_modules"
|
|
8415
8452
|
]);
|
|
8416
8453
|
}
|
|
8417
|
-
console.log(
|
|
8454
|
+
console.log(import_chalk20.default.blue("\n5. Building backend worker..."));
|
|
8418
8455
|
try {
|
|
8419
8456
|
(0, import_child_process3.execSync)("npm run build:worker", {
|
|
8420
8457
|
cwd: targetDir,
|
|
8421
8458
|
stdio: "inherit"
|
|
8422
8459
|
});
|
|
8423
|
-
console.log(
|
|
8460
|
+
console.log(import_chalk20.default.green(" Worker built"));
|
|
8424
8461
|
} catch (error) {
|
|
8425
8462
|
throw createCommandError("worker build", "npm run build:worker", error, [
|
|
8426
8463
|
"Fix the build error shown above, then rerun `pinme create`."
|
|
@@ -8446,12 +8483,12 @@ Directory "${projectName}" already exists.`));
|
|
|
8446
8483
|
const sqlFileNames = import_fs_extra6.default.readdirSync(sqlDir).filter((f) => f.endsWith(".sql")).sort();
|
|
8447
8484
|
for (const filename of sqlFileNames) {
|
|
8448
8485
|
sqlFiles.push(import_path11.default.join(sqlDir, filename));
|
|
8449
|
-
console.log(
|
|
8486
|
+
console.log(import_chalk20.default.gray(` Including SQL: ${filename}`));
|
|
8450
8487
|
}
|
|
8451
8488
|
}
|
|
8452
|
-
console.log(
|
|
8489
|
+
console.log(import_chalk20.default.blue("\n6. Deploying backend worker..."));
|
|
8453
8490
|
const saveApiUrl = `${getPinmeApiUrl("/save_worker")}?project_name=${encodeURIComponent(workerData.project_name)}`;
|
|
8454
|
-
console.log(
|
|
8491
|
+
console.log(import_chalk20.default.gray(` API URL: ${saveApiUrl}`));
|
|
8455
8492
|
try {
|
|
8456
8493
|
const FormData4 = (await import("formdata-node")).FormData;
|
|
8457
8494
|
const Blob2 = (await import("formdata-node")).Blob;
|
|
@@ -8483,10 +8520,10 @@ Directory "${projectName}" already exists.`));
|
|
|
8483
8520
|
timeout: 12e4
|
|
8484
8521
|
});
|
|
8485
8522
|
if (response.data) {
|
|
8486
|
-
console.log(
|
|
8523
|
+
console.log(import_chalk20.default.green(" Worker deployed"));
|
|
8487
8524
|
if ((_b = (_a2 = response.data) == null ? void 0 : _a2.data) == null ? void 0 : _b.sql_results) {
|
|
8488
8525
|
for (const result of response.data.data.sql_results) {
|
|
8489
|
-
console.log(
|
|
8526
|
+
console.log(import_chalk20.default.gray(` SQL ${result.filename}: ${result.status}`));
|
|
8490
8527
|
}
|
|
8491
8528
|
}
|
|
8492
8529
|
} else {
|
|
@@ -8505,7 +8542,7 @@ Directory "${projectName}" already exists.`));
|
|
|
8505
8542
|
"Check whether backend metadata, SQL files, or worker bundle contains invalid content."
|
|
8506
8543
|
]);
|
|
8507
8544
|
}
|
|
8508
|
-
console.log(
|
|
8545
|
+
console.log(import_chalk20.default.blue("\n7. Building frontend..."));
|
|
8509
8546
|
const frontendDir = import_path11.default.join(targetDir, "frontend");
|
|
8510
8547
|
if (import_fs_extra6.default.existsSync(frontendDir)) {
|
|
8511
8548
|
try {
|
|
@@ -8513,37 +8550,42 @@ Directory "${projectName}" already exists.`));
|
|
|
8513
8550
|
cwd: targetDir,
|
|
8514
8551
|
stdio: "inherit"
|
|
8515
8552
|
});
|
|
8516
|
-
console.log(
|
|
8553
|
+
console.log(import_chalk20.default.green(" Frontend built"));
|
|
8517
8554
|
} catch (error) {
|
|
8518
8555
|
throw createCommandError("frontend build", "npm run build:frontend", error, [
|
|
8519
8556
|
"Fix the frontend build error shown above, then rerun `pinme create`."
|
|
8520
8557
|
]);
|
|
8521
8558
|
}
|
|
8522
|
-
console.log(
|
|
8559
|
+
console.log(import_chalk20.default.blue(" Uploading to IPFS..."));
|
|
8523
8560
|
try {
|
|
8524
8561
|
const uploadResult = await uploadPath(import_path11.default.join(frontendDir, "dist"), {
|
|
8525
8562
|
projectName: workerData.project_name,
|
|
8526
8563
|
uid: headers["token-address"]
|
|
8527
8564
|
});
|
|
8528
|
-
|
|
8565
|
+
printHighlightedUrl("Frontend URL", uploadResult.publicUrl, "primary");
|
|
8529
8566
|
updateFrontendUrlInConfig(
|
|
8530
8567
|
import_path11.default.join(targetDir, "pinme.toml"),
|
|
8531
8568
|
uploadResult.publicUrl
|
|
8532
8569
|
);
|
|
8533
|
-
console.log(
|
|
8570
|
+
console.log(import_chalk20.default.green(" Updated pinme.toml with frontend URL"));
|
|
8534
8571
|
} catch (error) {
|
|
8535
|
-
console.log(
|
|
8572
|
+
console.log(import_chalk20.default.yellow(" Warning: IPFS upload failed, you can upload manually later"));
|
|
8536
8573
|
}
|
|
8537
8574
|
}
|
|
8538
|
-
console.log(
|
|
8539
|
-
console.log(
|
|
8575
|
+
console.log(import_chalk20.default.green("\nProject created successfully."));
|
|
8576
|
+
console.log(import_chalk20.default.gray(`
|
|
8540
8577
|
Project Details:`));
|
|
8541
|
-
console.log(
|
|
8542
|
-
console.log(
|
|
8543
|
-
|
|
8578
|
+
console.log(import_chalk20.default.gray(` API Domain: ${workerData.api_domain}`));
|
|
8579
|
+
console.log(import_chalk20.default.gray(` Project Name: ${workerData.project_name}`));
|
|
8580
|
+
printHighlightedUrl(
|
|
8581
|
+
"Project Management URL",
|
|
8582
|
+
getProjectManagementUrl(workerData.project_name),
|
|
8583
|
+
"management"
|
|
8584
|
+
);
|
|
8585
|
+
console.log(import_chalk20.default.gray(`
|
|
8544
8586
|
Next steps:`));
|
|
8545
|
-
console.log(
|
|
8546
|
-
console.log(
|
|
8587
|
+
console.log(import_chalk20.default.gray(` cd ${projectName}`));
|
|
8588
|
+
console.log(import_chalk20.default.gray(` pinme save`));
|
|
8547
8589
|
process.exit(0);
|
|
8548
8590
|
} catch (error) {
|
|
8549
8591
|
printCliError(error, "Project creation failed.");
|
|
@@ -8552,7 +8594,7 @@ Next steps:`));
|
|
|
8552
8594
|
}
|
|
8553
8595
|
|
|
8554
8596
|
// bin/save.ts
|
|
8555
|
-
var
|
|
8597
|
+
var import_chalk21 = __toESM(require("chalk"));
|
|
8556
8598
|
var import_fs_extra7 = __toESM(require("fs-extra"));
|
|
8557
8599
|
var import_path12 = __toESM(require("path"));
|
|
8558
8600
|
init_axios2();
|
|
@@ -8575,22 +8617,25 @@ function loadConfig() {
|
|
|
8575
8617
|
project_name: (projectNameMatch == null ? void 0 : projectNameMatch[1]) || ""
|
|
8576
8618
|
};
|
|
8577
8619
|
}
|
|
8620
|
+
function getProjectManagementUrl2(projectName) {
|
|
8621
|
+
return `${APP_CONFIG.projectPeviewUrl}${projectName}`;
|
|
8622
|
+
}
|
|
8578
8623
|
function getMetadata() {
|
|
8579
8624
|
const metadataPath = import_path12.default.join(PROJECT_DIR2, "backend", "metadata.json");
|
|
8580
8625
|
if (!import_fs_extra7.default.existsSync(metadataPath)) {
|
|
8581
|
-
console.log(
|
|
8626
|
+
console.log(import_chalk21.default.yellow(" Warning: metadata.json not found, using empty metadata"));
|
|
8582
8627
|
return {};
|
|
8583
8628
|
}
|
|
8584
8629
|
return import_fs_extra7.default.readJsonSync(metadataPath);
|
|
8585
8630
|
}
|
|
8586
8631
|
function buildWorker() {
|
|
8587
|
-
console.log(
|
|
8632
|
+
console.log(import_chalk21.default.blue("Building worker..."));
|
|
8588
8633
|
try {
|
|
8589
8634
|
(0, import_child_process4.execSync)("npm run build:worker", {
|
|
8590
8635
|
cwd: PROJECT_DIR2,
|
|
8591
8636
|
stdio: "inherit"
|
|
8592
8637
|
});
|
|
8593
|
-
console.log(
|
|
8638
|
+
console.log(import_chalk21.default.green("Worker built"));
|
|
8594
8639
|
} catch (error) {
|
|
8595
8640
|
throw createCommandError("worker build", "npm run build:worker", error, [
|
|
8596
8641
|
"Fix the build error shown above, then rerun `pinme save`."
|
|
@@ -8598,10 +8643,10 @@ function buildWorker() {
|
|
|
8598
8643
|
}
|
|
8599
8644
|
}
|
|
8600
8645
|
function installDependencies() {
|
|
8601
|
-
console.log(
|
|
8646
|
+
console.log(import_chalk21.default.blue("Installing dependencies..."));
|
|
8602
8647
|
try {
|
|
8603
8648
|
installProjectDependencies(PROJECT_DIR2);
|
|
8604
|
-
console.log(
|
|
8649
|
+
console.log(import_chalk21.default.green("Project dependencies installed"));
|
|
8605
8650
|
} catch (error) {
|
|
8606
8651
|
const errorMsg = error.message || "";
|
|
8607
8652
|
if (errorMsg.includes("EACCES") || errorMsg.includes("EPERM") || errorMsg.includes("permission denied")) {
|
|
@@ -8673,15 +8718,15 @@ function getSqlFiles() {
|
|
|
8673
8718
|
}
|
|
8674
8719
|
async function saveWorker(workerJsPath, modulePaths, sqlFiles, metadata, projectName) {
|
|
8675
8720
|
var _a2, _b;
|
|
8676
|
-
console.log(
|
|
8677
|
-
console.log(
|
|
8678
|
-
console.log(
|
|
8679
|
-
console.log(
|
|
8680
|
-
console.log(
|
|
8681
|
-
console.log(
|
|
8721
|
+
console.log(import_chalk21.default.blue("Saving worker to platform..."));
|
|
8722
|
+
console.log(import_chalk21.default.gray(`Project: ${projectName}`));
|
|
8723
|
+
console.log(import_chalk21.default.gray(`workerJsPath: ${workerJsPath}`));
|
|
8724
|
+
console.log(import_chalk21.default.gray(`modulePaths: ${modulePaths}`));
|
|
8725
|
+
console.log(import_chalk21.default.gray(`sqlFiles: ${sqlFiles}`));
|
|
8726
|
+
console.log(import_chalk21.default.gray(`metadata: ${metadata}`));
|
|
8682
8727
|
const apiUrl = `${getPinmeApiUrl("/save_worker")}?project_name=${encodeURIComponent(projectName)}`;
|
|
8683
8728
|
const headers = getAuthHeaders();
|
|
8684
|
-
console.log(
|
|
8729
|
+
console.log(import_chalk21.default.gray(`API URL: ${apiUrl}`));
|
|
8685
8730
|
try {
|
|
8686
8731
|
const FormData4 = (await import("formdata-node")).FormData;
|
|
8687
8732
|
const Blob2 = (await import("formdata-node")).Blob;
|
|
@@ -8706,18 +8751,18 @@ async function saveWorker(workerJsPath, modulePaths, sqlFiles, metadata, project
|
|
|
8706
8751
|
formData.append("sql_file", new Blob2([content], {
|
|
8707
8752
|
type: "application/sql"
|
|
8708
8753
|
}), filename);
|
|
8709
|
-
console.log(
|
|
8754
|
+
console.log(import_chalk21.default.gray(` Including SQL: ${filename}`));
|
|
8710
8755
|
}
|
|
8711
8756
|
const response = await axios_default.put(apiUrl, formData, {
|
|
8712
8757
|
headers: { ...headers },
|
|
8713
8758
|
timeout: 12e4
|
|
8714
8759
|
});
|
|
8715
|
-
console.log(
|
|
8760
|
+
console.log(import_chalk21.default.gray(` Response: ${JSON.stringify(response.data)}`));
|
|
8716
8761
|
if (response.data) {
|
|
8717
|
-
console.log(
|
|
8762
|
+
console.log(import_chalk21.default.green("Worker saved"));
|
|
8718
8763
|
if ((_b = (_a2 = response.data) == null ? void 0 : _a2.data) == null ? void 0 : _b.sql_results) {
|
|
8719
8764
|
for (const result of response.data.data.sql_results) {
|
|
8720
|
-
console.log(
|
|
8765
|
+
console.log(import_chalk21.default.gray(` SQL ${result.filename}: ${result.status}`));
|
|
8721
8766
|
}
|
|
8722
8767
|
}
|
|
8723
8768
|
} else {
|
|
@@ -8738,13 +8783,13 @@ async function saveWorker(workerJsPath, modulePaths, sqlFiles, metadata, project
|
|
|
8738
8783
|
}
|
|
8739
8784
|
}
|
|
8740
8785
|
function buildFrontend() {
|
|
8741
|
-
console.log(
|
|
8786
|
+
console.log(import_chalk21.default.blue("Building frontend..."));
|
|
8742
8787
|
try {
|
|
8743
8788
|
(0, import_child_process4.execSync)("npm run build:frontend", {
|
|
8744
8789
|
cwd: PROJECT_DIR2,
|
|
8745
8790
|
stdio: "inherit"
|
|
8746
8791
|
});
|
|
8747
|
-
console.log(
|
|
8792
|
+
console.log(import_chalk21.default.green("Frontend built"));
|
|
8748
8793
|
} catch (error) {
|
|
8749
8794
|
throw createCommandError("frontend build", "npm run build:frontend", error, [
|
|
8750
8795
|
"Fix the frontend build error shown above, then rerun `pinme save`."
|
|
@@ -8768,7 +8813,7 @@ function updateFrontendUrlInConfig2(configPath, frontendUrl) {
|
|
|
8768
8813
|
import_fs_extra7.default.writeFileSync(configPath, config);
|
|
8769
8814
|
}
|
|
8770
8815
|
async function deployFrontend(projectName) {
|
|
8771
|
-
console.log(
|
|
8816
|
+
console.log(import_chalk21.default.blue("Deploying frontend to IPFS..."));
|
|
8772
8817
|
try {
|
|
8773
8818
|
const headers = getAuthHeaders();
|
|
8774
8819
|
const uploadResult = await uploadPath(import_path12.default.join(PROJECT_DIR2, "frontend", "dist"), {
|
|
@@ -8831,8 +8876,8 @@ async function saveCmd(options) {
|
|
|
8831
8876
|
if (import_fs_extra7.default.existsSync(tokenFileSrc) && !import_fs_extra7.default.existsSync(tokenFileDst)) {
|
|
8832
8877
|
import_fs_extra7.default.copySync(tokenFileSrc, tokenFileDst);
|
|
8833
8878
|
}
|
|
8834
|
-
console.log(
|
|
8835
|
-
console.log(
|
|
8879
|
+
console.log(import_chalk21.default.blue("Deploying to platform...\n"));
|
|
8880
|
+
console.log(import_chalk21.default.gray(`Project dir: ${PROJECT_DIR2}`));
|
|
8836
8881
|
const config = loadConfig();
|
|
8837
8882
|
const projectName = config.project_name;
|
|
8838
8883
|
if (!projectName) {
|
|
@@ -8840,20 +8885,20 @@ async function saveCmd(options) {
|
|
|
8840
8885
|
'Set `project_name = "your-project-name"` in `pinme.toml`.'
|
|
8841
8886
|
]);
|
|
8842
8887
|
}
|
|
8843
|
-
console.log(
|
|
8888
|
+
console.log(import_chalk21.default.gray(`Project: ${projectName}`));
|
|
8844
8889
|
const apiUrl = `${getPinmeApiUrl("/save_worker")}?project_name=${encodeURIComponent(projectName)}`;
|
|
8845
|
-
console.log(
|
|
8846
|
-
console.log(
|
|
8890
|
+
console.log(import_chalk21.default.gray(`API URL: ${apiUrl}`));
|
|
8891
|
+
console.log(import_chalk21.default.blue("\n--- Backend ---"));
|
|
8847
8892
|
installDependencies();
|
|
8848
8893
|
buildWorker();
|
|
8849
8894
|
const metadata = getMetadata();
|
|
8850
8895
|
const { workerJsPath, modulePaths } = getBuiltWorker();
|
|
8851
|
-
console.log(
|
|
8852
|
-
console.log(
|
|
8896
|
+
console.log(import_chalk21.default.gray(`Worker JS: ${workerJsPath}`));
|
|
8897
|
+
console.log(import_chalk21.default.gray(`Module paths: ${JSON.stringify(modulePaths)}`));
|
|
8853
8898
|
const sqlFiles = getSqlFiles();
|
|
8854
|
-
console.log(
|
|
8899
|
+
console.log(import_chalk21.default.gray(`SQL files: ${JSON.stringify(sqlFiles)}`));
|
|
8855
8900
|
await saveWorker(workerJsPath, modulePaths, sqlFiles, metadata, projectName);
|
|
8856
|
-
console.log(
|
|
8901
|
+
console.log(import_chalk21.default.blue("\n--- Frontend ---"));
|
|
8857
8902
|
buildFrontend();
|
|
8858
8903
|
const frontendResult = await deployFrontend(projectName);
|
|
8859
8904
|
let finalFrontendUrl = frontendResult.publicUrl;
|
|
@@ -8865,9 +8910,14 @@ async function saveCmd(options) {
|
|
|
8865
8910
|
headers
|
|
8866
8911
|
);
|
|
8867
8912
|
}
|
|
8868
|
-
console.log(
|
|
8869
|
-
|
|
8870
|
-
|
|
8913
|
+
console.log(import_chalk21.default.blue("\n--- Access ---"));
|
|
8914
|
+
printHighlightedUrl("Frontend URL", finalFrontendUrl, "primary");
|
|
8915
|
+
printHighlightedUrl(
|
|
8916
|
+
"Project Management URL",
|
|
8917
|
+
getProjectManagementUrl2(projectName),
|
|
8918
|
+
"management"
|
|
8919
|
+
);
|
|
8920
|
+
console.log(import_chalk21.default.green("\nDeployment complete."));
|
|
8871
8921
|
process.exit(0);
|
|
8872
8922
|
} catch (error) {
|
|
8873
8923
|
printCliError(error, "Save failed.");
|
|
@@ -8876,7 +8926,7 @@ async function saveCmd(options) {
|
|
|
8876
8926
|
}
|
|
8877
8927
|
|
|
8878
8928
|
// bin/updateDb.ts
|
|
8879
|
-
var
|
|
8929
|
+
var import_chalk22 = __toESM(require("chalk"));
|
|
8880
8930
|
var import_fs_extra8 = __toESM(require("fs-extra"));
|
|
8881
8931
|
var import_path13 = __toESM(require("path"));
|
|
8882
8932
|
init_axios2();
|
|
@@ -8912,12 +8962,12 @@ function getSqlFiles2() {
|
|
|
8912
8962
|
return files.map((f) => import_path13.default.join(sqlDir, f));
|
|
8913
8963
|
}
|
|
8914
8964
|
async function updateDb(sqlFiles, projectName) {
|
|
8915
|
-
console.log(
|
|
8916
|
-
console.log(
|
|
8917
|
-
console.log(
|
|
8965
|
+
console.log(import_chalk22.default.blue("Importing SQL files to database..."));
|
|
8966
|
+
console.log(import_chalk22.default.gray(`Project: ${projectName}`));
|
|
8967
|
+
console.log(import_chalk22.default.gray(`SQL files: ${sqlFiles.length}`));
|
|
8918
8968
|
const apiUrl = `${getPinmeApiUrl("/update_db")}?project_name=${encodeURIComponent(projectName)}`;
|
|
8919
8969
|
const headers = getAuthHeaders();
|
|
8920
|
-
console.log(
|
|
8970
|
+
console.log(import_chalk22.default.gray(`API URL: ${apiUrl}`));
|
|
8921
8971
|
try {
|
|
8922
8972
|
const FormData4 = (await import("formdata-node")).FormData;
|
|
8923
8973
|
const Blob2 = (await import("formdata-node")).Blob;
|
|
@@ -8935,24 +8985,24 @@ async function updateDb(sqlFiles, projectName) {
|
|
|
8935
8985
|
formData.append("file", new Blob2([content], {
|
|
8936
8986
|
type: "application/sql"
|
|
8937
8987
|
}), filename);
|
|
8938
|
-
console.log(
|
|
8988
|
+
console.log(import_chalk22.default.gray(` Including: ${filename} (${content.length} bytes)`));
|
|
8939
8989
|
}
|
|
8940
8990
|
const response = await axios_default.post(apiUrl, formData, {
|
|
8941
8991
|
headers: { ...headers },
|
|
8942
8992
|
timeout: 12e4
|
|
8943
8993
|
});
|
|
8944
|
-
console.log(
|
|
8994
|
+
console.log(import_chalk22.default.gray(` Response: ${JSON.stringify(response.data)}`));
|
|
8945
8995
|
if (response.data.code === 200) {
|
|
8946
|
-
console.log(
|
|
8996
|
+
console.log(import_chalk22.default.green("SQL files imported successfully!"));
|
|
8947
8997
|
const results = response.data.data.results;
|
|
8948
8998
|
for (const result of results) {
|
|
8949
8999
|
if (result.status === "complete") {
|
|
8950
|
-
console.log(
|
|
9000
|
+
console.log(import_chalk22.default.green(` COMPLETE ${result.filename}: ${result.num_queries} queries, ${result.duration}ms`));
|
|
8951
9001
|
if (result.changes !== void 0) {
|
|
8952
|
-
console.log(
|
|
9002
|
+
console.log(import_chalk22.default.gray(` Changes: ${result.changes}, Read: ${result.rows_read}, Written: ${result.rows_written}`));
|
|
8953
9003
|
}
|
|
8954
9004
|
} else if (result.status === "error") {
|
|
8955
|
-
console.log(
|
|
9005
|
+
console.log(import_chalk22.default.red(` ERROR ${result.filename}: ${result.error}`));
|
|
8956
9006
|
}
|
|
8957
9007
|
}
|
|
8958
9008
|
} else {
|
|
@@ -8986,8 +9036,8 @@ async function updateDbCmd(options) {
|
|
|
8986
9036
|
if (import_fs_extra8.default.existsSync(tokenFileSrc) && !import_fs_extra8.default.existsSync(tokenFileDst)) {
|
|
8987
9037
|
import_fs_extra8.default.copySync(tokenFileSrc, tokenFileDst);
|
|
8988
9038
|
}
|
|
8989
|
-
console.log(
|
|
8990
|
-
console.log(
|
|
9039
|
+
console.log(import_chalk22.default.blue("Importing SQL to database...\n"));
|
|
9040
|
+
console.log(import_chalk22.default.gray(`Project dir: ${PROJECT_DIR3}`));
|
|
8991
9041
|
const config = loadConfig2();
|
|
8992
9042
|
const projectName = config.project_name;
|
|
8993
9043
|
if (!projectName) {
|
|
@@ -8995,11 +9045,11 @@ async function updateDbCmd(options) {
|
|
|
8995
9045
|
'Set `project_name = "your-project-name"` in `pinme.toml`.'
|
|
8996
9046
|
]);
|
|
8997
9047
|
}
|
|
8998
|
-
console.log(
|
|
9048
|
+
console.log(import_chalk22.default.gray(`Project: ${projectName}`));
|
|
8999
9049
|
const sqlFiles = getSqlFiles2();
|
|
9000
|
-
console.log(
|
|
9050
|
+
console.log(import_chalk22.default.gray(`Found ${sqlFiles.length} SQL file(s) in db`));
|
|
9001
9051
|
await updateDb(sqlFiles, projectName);
|
|
9002
|
-
console.log(
|
|
9052
|
+
console.log(import_chalk22.default.green("\nDatabase update complete."));
|
|
9003
9053
|
process.exit(0);
|
|
9004
9054
|
} catch (error) {
|
|
9005
9055
|
printCliError(error, "Database update failed.");
|
|
@@ -9008,7 +9058,7 @@ async function updateDbCmd(options) {
|
|
|
9008
9058
|
}
|
|
9009
9059
|
|
|
9010
9060
|
// bin/updateWorker.ts
|
|
9011
|
-
var
|
|
9061
|
+
var import_chalk23 = __toESM(require("chalk"));
|
|
9012
9062
|
var import_fs_extra9 = __toESM(require("fs-extra"));
|
|
9013
9063
|
var import_path14 = __toESM(require("path"));
|
|
9014
9064
|
init_axios2();
|
|
@@ -9039,13 +9089,13 @@ function getMetadata2() {
|
|
|
9039
9089
|
return import_fs_extra9.default.readJsonSync(metadataPath);
|
|
9040
9090
|
}
|
|
9041
9091
|
function buildWorker2() {
|
|
9042
|
-
console.log(
|
|
9092
|
+
console.log(import_chalk23.default.blue("Building worker..."));
|
|
9043
9093
|
try {
|
|
9044
9094
|
(0, import_child_process5.execSync)("npm run build:worker", {
|
|
9045
9095
|
cwd: PROJECT_DIR4,
|
|
9046
9096
|
stdio: "inherit"
|
|
9047
9097
|
});
|
|
9048
|
-
console.log(
|
|
9098
|
+
console.log(import_chalk23.default.green("Worker built"));
|
|
9049
9099
|
} catch (error) {
|
|
9050
9100
|
throw createCommandError("worker build", "npm run build:worker", error, [
|
|
9051
9101
|
"Fix the build error shown above, then rerun `pinme update-worker`."
|
|
@@ -9075,14 +9125,14 @@ function getBuiltWorker2() {
|
|
|
9075
9125
|
return { workerJsPath, modulePaths };
|
|
9076
9126
|
}
|
|
9077
9127
|
async function updateWorker(workerJsPath, modulePaths, metadata, projectName) {
|
|
9078
|
-
console.log(
|
|
9079
|
-
console.log(
|
|
9080
|
-
console.log(
|
|
9081
|
-
console.log(
|
|
9082
|
-
console.log(
|
|
9128
|
+
console.log(import_chalk23.default.blue("Updating worker on platform..."));
|
|
9129
|
+
console.log(import_chalk23.default.gray(`Project: ${projectName}`));
|
|
9130
|
+
console.log(import_chalk23.default.gray(`workerJsPath: ${workerJsPath}`));
|
|
9131
|
+
console.log(import_chalk23.default.gray(`modulePaths: ${modulePaths}`));
|
|
9132
|
+
console.log(import_chalk23.default.gray(`metadata: ${metadata}`));
|
|
9083
9133
|
const apiUrl = `${getPinmeApiUrl("/update_worker")}?project_name=${encodeURIComponent(projectName)}`;
|
|
9084
9134
|
const headers = getAuthHeaders();
|
|
9085
|
-
console.log(
|
|
9135
|
+
console.log(import_chalk23.default.gray(`API URL: ${apiUrl}`));
|
|
9086
9136
|
try {
|
|
9087
9137
|
const FormData4 = (await import("formdata-node")).FormData;
|
|
9088
9138
|
const Blob2 = (await import("formdata-node")).Blob;
|
|
@@ -9105,33 +9155,33 @@ async function updateWorker(workerJsPath, modulePaths, metadata, projectName) {
|
|
|
9105
9155
|
headers: { ...headers },
|
|
9106
9156
|
timeout: 12e4
|
|
9107
9157
|
});
|
|
9108
|
-
console.log(
|
|
9158
|
+
console.log(import_chalk23.default.gray(` Response: ${JSON.stringify(response.data)}`));
|
|
9109
9159
|
if (response.data) {
|
|
9110
|
-
console.log(
|
|
9160
|
+
console.log(import_chalk23.default.green("Worker updated"));
|
|
9111
9161
|
const data = response.data.data;
|
|
9112
9162
|
if (data.worker_id) {
|
|
9113
|
-
console.log(
|
|
9163
|
+
console.log(import_chalk23.default.gray(` Worker ID: ${data.worker_id}`));
|
|
9114
9164
|
}
|
|
9115
9165
|
if (data.deployment_id) {
|
|
9116
|
-
console.log(
|
|
9166
|
+
console.log(import_chalk23.default.gray(` Deployment ID: ${data.deployment_id}`));
|
|
9117
9167
|
}
|
|
9118
9168
|
if (data.entry_point) {
|
|
9119
|
-
console.log(
|
|
9169
|
+
console.log(import_chalk23.default.gray(` Entry Point: ${data.entry_point}`));
|
|
9120
9170
|
}
|
|
9121
9171
|
if (data.created_on) {
|
|
9122
|
-
console.log(
|
|
9172
|
+
console.log(import_chalk23.default.gray(` Created: ${data.created_on}`));
|
|
9123
9173
|
}
|
|
9124
9174
|
if (data.modified_on) {
|
|
9125
|
-
console.log(
|
|
9175
|
+
console.log(import_chalk23.default.gray(` Modified: ${data.modified_on}`));
|
|
9126
9176
|
}
|
|
9127
9177
|
if (data.startup_time_ms !== void 0) {
|
|
9128
|
-
console.log(
|
|
9178
|
+
console.log(import_chalk23.default.gray(` Startup Time: ${data.startup_time_ms}ms`));
|
|
9129
9179
|
}
|
|
9130
9180
|
if (data.has_modules !== void 0) {
|
|
9131
|
-
console.log(
|
|
9181
|
+
console.log(import_chalk23.default.gray(` Has Modules: ${data.has_modules}`));
|
|
9132
9182
|
}
|
|
9133
9183
|
if (data.domain) {
|
|
9134
|
-
console.log(
|
|
9184
|
+
console.log(import_chalk23.default.gray(` Domain: ${data.domain}`));
|
|
9135
9185
|
}
|
|
9136
9186
|
} else {
|
|
9137
9187
|
throw createApiError("worker update", { response: { data: response.data } }, [
|
|
@@ -9164,8 +9214,8 @@ async function updateWorkerCmd(options) {
|
|
|
9164
9214
|
if (import_fs_extra9.default.existsSync(tokenFileSrc) && !import_fs_extra9.default.existsSync(tokenFileDst)) {
|
|
9165
9215
|
import_fs_extra9.default.copySync(tokenFileSrc, tokenFileDst);
|
|
9166
9216
|
}
|
|
9167
|
-
console.log(
|
|
9168
|
-
console.log(
|
|
9217
|
+
console.log(import_chalk23.default.blue("Updating worker...\n"));
|
|
9218
|
+
console.log(import_chalk23.default.gray(`Project dir: ${PROJECT_DIR4}`));
|
|
9169
9219
|
const config = loadConfig3();
|
|
9170
9220
|
const projectName = config.project_name;
|
|
9171
9221
|
if (!projectName) {
|
|
@@ -9173,16 +9223,16 @@ async function updateWorkerCmd(options) {
|
|
|
9173
9223
|
'Set `project_name = "your-project-name"` in `pinme.toml`.'
|
|
9174
9224
|
]);
|
|
9175
9225
|
}
|
|
9176
|
-
console.log(
|
|
9177
|
-
console.log(
|
|
9226
|
+
console.log(import_chalk23.default.gray(`Project: ${projectName}`));
|
|
9227
|
+
console.log(import_chalk23.default.blue("\n--- Worker Update ---"));
|
|
9178
9228
|
buildWorker2();
|
|
9179
9229
|
const metadata = getMetadata2();
|
|
9180
9230
|
const { workerJsPath, modulePaths } = getBuiltWorker2();
|
|
9181
|
-
console.log(
|
|
9182
|
-
console.log(
|
|
9183
|
-
console.log(
|
|
9231
|
+
console.log(import_chalk23.default.gray(`Worker JS: ${workerJsPath}`));
|
|
9232
|
+
console.log(import_chalk23.default.gray(`Module paths: ${JSON.stringify(modulePaths)}`));
|
|
9233
|
+
console.log(import_chalk23.default.gray(`SQL files: ignored (not processed for update_worker)`));
|
|
9184
9234
|
await updateWorker(workerJsPath, modulePaths, metadata, projectName);
|
|
9185
|
-
console.log(
|
|
9235
|
+
console.log(import_chalk23.default.green("\nWorker update complete."));
|
|
9186
9236
|
process.exit(0);
|
|
9187
9237
|
} catch (error) {
|
|
9188
9238
|
printCliError(error, "Worker update failed.");
|
|
@@ -9191,11 +9241,12 @@ async function updateWorkerCmd(options) {
|
|
|
9191
9241
|
}
|
|
9192
9242
|
|
|
9193
9243
|
// bin/updateWeb.ts
|
|
9194
|
-
var
|
|
9244
|
+
var import_chalk24 = __toESM(require("chalk"));
|
|
9195
9245
|
var import_fs_extra10 = __toESM(require("fs-extra"));
|
|
9196
9246
|
var import_path15 = __toESM(require("path"));
|
|
9197
9247
|
var import_child_process6 = require("child_process");
|
|
9198
9248
|
init_webLogin();
|
|
9249
|
+
init_config();
|
|
9199
9250
|
var PROJECT_DIR5 = process.cwd();
|
|
9200
9251
|
function loadConfig4() {
|
|
9201
9252
|
const configPath = import_path15.default.join(PROJECT_DIR5, "pinme.toml");
|
|
@@ -9210,14 +9261,17 @@ function loadConfig4() {
|
|
|
9210
9261
|
project_name: (projectNameMatch == null ? void 0 : projectNameMatch[1]) || ""
|
|
9211
9262
|
};
|
|
9212
9263
|
}
|
|
9264
|
+
function getProjectManagementUrl3(projectName) {
|
|
9265
|
+
return `${APP_CONFIG.projectPeviewUrl}${projectName}`;
|
|
9266
|
+
}
|
|
9213
9267
|
function buildFrontend2() {
|
|
9214
|
-
console.log(
|
|
9268
|
+
console.log(import_chalk24.default.blue("Building frontend..."));
|
|
9215
9269
|
try {
|
|
9216
9270
|
(0, import_child_process6.execSync)("npm run build:frontend", {
|
|
9217
9271
|
cwd: PROJECT_DIR5,
|
|
9218
9272
|
stdio: "inherit"
|
|
9219
9273
|
});
|
|
9220
|
-
console.log(
|
|
9274
|
+
console.log(import_chalk24.default.green("Frontend built"));
|
|
9221
9275
|
} catch (error) {
|
|
9222
9276
|
throw createCommandError("frontend build", "npm run build:frontend", error, [
|
|
9223
9277
|
"Fix the frontend build error shown above, then rerun `pinme update-web`."
|
|
@@ -9225,14 +9279,19 @@ function buildFrontend2() {
|
|
|
9225
9279
|
}
|
|
9226
9280
|
}
|
|
9227
9281
|
async function deployFrontend2(projectName) {
|
|
9228
|
-
console.log(
|
|
9282
|
+
console.log(import_chalk24.default.blue("Deploying frontend to IPFS..."));
|
|
9229
9283
|
try {
|
|
9230
9284
|
const headers = getAuthHeaders();
|
|
9231
9285
|
const uploadResult = await uploadPath(import_path15.default.join(PROJECT_DIR5, "frontend", "dist"), {
|
|
9232
9286
|
projectName,
|
|
9233
9287
|
uid: headers["token-address"]
|
|
9234
9288
|
});
|
|
9235
|
-
|
|
9289
|
+
printHighlightedUrl("Frontend URL", uploadResult.publicUrl, "primary");
|
|
9290
|
+
printHighlightedUrl(
|
|
9291
|
+
"Project Management URL",
|
|
9292
|
+
getProjectManagementUrl3(projectName),
|
|
9293
|
+
"management"
|
|
9294
|
+
);
|
|
9236
9295
|
} catch (error) {
|
|
9237
9296
|
throw createCommandError("frontend deploy", "upload frontend/dist", error, [
|
|
9238
9297
|
"Make sure `frontend/dist` exists and the upload API is reachable."
|
|
@@ -9253,8 +9312,8 @@ async function updateWebCmd(options) {
|
|
|
9253
9312
|
if (import_fs_extra10.default.existsSync(tokenFileSrc) && !import_fs_extra10.default.existsSync(tokenFileDst)) {
|
|
9254
9313
|
import_fs_extra10.default.copySync(tokenFileSrc, tokenFileDst);
|
|
9255
9314
|
}
|
|
9256
|
-
console.log(
|
|
9257
|
-
console.log(
|
|
9315
|
+
console.log(import_chalk24.default.blue("Updating web (frontend)...\n"));
|
|
9316
|
+
console.log(import_chalk24.default.gray(`Project dir: ${PROJECT_DIR5}`));
|
|
9258
9317
|
const config = loadConfig4();
|
|
9259
9318
|
const projectName = config.project_name;
|
|
9260
9319
|
if (!projectName) {
|
|
@@ -9262,11 +9321,11 @@ async function updateWebCmd(options) {
|
|
|
9262
9321
|
'Set `project_name = "your-project-name"` in `pinme.toml`.'
|
|
9263
9322
|
]);
|
|
9264
9323
|
}
|
|
9265
|
-
console.log(
|
|
9266
|
-
console.log(
|
|
9324
|
+
console.log(import_chalk24.default.gray(`Project: ${projectName}`));
|
|
9325
|
+
console.log(import_chalk24.default.blue("\n--- Frontend Update ---"));
|
|
9267
9326
|
buildFrontend2();
|
|
9268
9327
|
await deployFrontend2(projectName);
|
|
9269
|
-
console.log(
|
|
9328
|
+
console.log(import_chalk24.default.green("\nWeb update complete."));
|
|
9270
9329
|
process.exit(0);
|
|
9271
9330
|
} catch (error) {
|
|
9272
9331
|
printCliError(error, "Web update failed.");
|
|
@@ -9275,7 +9334,7 @@ async function updateWebCmd(options) {
|
|
|
9275
9334
|
}
|
|
9276
9335
|
|
|
9277
9336
|
// bin/delete.ts
|
|
9278
|
-
var
|
|
9337
|
+
var import_chalk25 = __toESM(require("chalk"));
|
|
9279
9338
|
var import_inquirer9 = __toESM(require("inquirer"));
|
|
9280
9339
|
init_axios2();
|
|
9281
9340
|
var import_fs_extra11 = __toESM(require("fs-extra"));
|
|
@@ -9296,23 +9355,23 @@ async function deleteCmd(options) {
|
|
|
9296
9355
|
try {
|
|
9297
9356
|
const headers = getAuthHeaders();
|
|
9298
9357
|
if (!headers["authentication-tokens"] || !headers["token-address"]) {
|
|
9299
|
-
console.log(
|
|
9300
|
-
console.log(
|
|
9358
|
+
console.log(import_chalk25.default.yellow("\n\u26A0\uFE0F You are not logged in."));
|
|
9359
|
+
console.log(import_chalk25.default.gray("Please run: pinme login"));
|
|
9301
9360
|
process.exit(1);
|
|
9302
9361
|
}
|
|
9303
|
-
console.log(
|
|
9362
|
+
console.log(import_chalk25.default.blue("Deleting project...\n"));
|
|
9304
9363
|
let projectName = options.name || getProjectName();
|
|
9305
9364
|
if (!projectName) {
|
|
9306
|
-
console.log(
|
|
9307
|
-
console.log(
|
|
9308
|
-
console.log(
|
|
9309
|
-
console.log(
|
|
9310
|
-
console.log(
|
|
9311
|
-
console.log(
|
|
9365
|
+
console.log(import_chalk25.default.red("\n\u274C Error: Cannot find project name."));
|
|
9366
|
+
console.log(import_chalk25.default.yellow(" Please make sure you are in the project directory."));
|
|
9367
|
+
console.log(import_chalk25.default.gray(" The project directory should contain a pinme.toml file."));
|
|
9368
|
+
console.log(import_chalk25.default.gray("\n Or specify the project name:"));
|
|
9369
|
+
console.log(import_chalk25.default.gray(" cd /path/to/your-project"));
|
|
9370
|
+
console.log(import_chalk25.default.gray(" pinme delete"));
|
|
9312
9371
|
process.exit(1);
|
|
9313
9372
|
}
|
|
9314
|
-
console.log(
|
|
9315
|
-
console.log(
|
|
9373
|
+
console.log(import_chalk25.default.gray(`Project: ${projectName}`));
|
|
9374
|
+
console.log(import_chalk25.default.gray(`Directory: ${process.cwd()}`));
|
|
9316
9375
|
if (!options.force) {
|
|
9317
9376
|
const answers = await import_inquirer9.default.prompt([
|
|
9318
9377
|
{
|
|
@@ -9323,14 +9382,14 @@ async function deleteCmd(options) {
|
|
|
9323
9382
|
}
|
|
9324
9383
|
]);
|
|
9325
9384
|
if (!answers.confirm) {
|
|
9326
|
-
console.log(
|
|
9385
|
+
console.log(import_chalk25.default.gray("Cancelled."));
|
|
9327
9386
|
process.exit(0);
|
|
9328
9387
|
}
|
|
9329
9388
|
}
|
|
9330
|
-
console.log(
|
|
9389
|
+
console.log(import_chalk25.default.blue("Deleting project on platform..."));
|
|
9331
9390
|
const apiUrl = getPinmeApiUrl("/delete_project");
|
|
9332
|
-
console.log(
|
|
9333
|
-
console.log(
|
|
9391
|
+
console.log(import_chalk25.default.gray(`API URL: ${apiUrl}`));
|
|
9392
|
+
console.log(import_chalk25.default.gray(`Project name: ${projectName}`));
|
|
9334
9393
|
const response = await axios_default.post(apiUrl, {
|
|
9335
9394
|
project_name: projectName
|
|
9336
9395
|
}, {
|
|
@@ -9341,31 +9400,31 @@ async function deleteCmd(options) {
|
|
|
9341
9400
|
}).catch((error) => {
|
|
9342
9401
|
var _a3, _b2;
|
|
9343
9402
|
if (error.response) {
|
|
9344
|
-
console.log(
|
|
9345
|
-
console.log(
|
|
9403
|
+
console.log(import_chalk25.default.red(` Response status: ${(_a3 = error.response) == null ? void 0 : _a3.status}`));
|
|
9404
|
+
console.log(import_chalk25.default.red(` Response data: ${JSON.stringify((_b2 = error.response) == null ? void 0 : _b2.data)}`));
|
|
9346
9405
|
} else {
|
|
9347
|
-
console.log(
|
|
9406
|
+
console.log(import_chalk25.default.red("No Response"));
|
|
9348
9407
|
}
|
|
9349
9408
|
throw error;
|
|
9350
9409
|
});
|
|
9351
9410
|
const data = response.data;
|
|
9352
9411
|
if (data.code === 200) {
|
|
9353
|
-
console.log(
|
|
9354
|
-
console.log(
|
|
9412
|
+
console.log(import_chalk25.default.green("\n\u2705 Project deleted successfully!"));
|
|
9413
|
+
console.log(import_chalk25.default.gray(`
|
|
9355
9414
|
Project: ${data.data.project_name}`));
|
|
9356
|
-
console.log(
|
|
9357
|
-
console.log(
|
|
9358
|
-
console.log(
|
|
9359
|
-
console.log(
|
|
9415
|
+
console.log(import_chalk25.default.gray(` Domain deleted: ${data.data.domain_deleted ? "\u2705" : "\u274C"}`));
|
|
9416
|
+
console.log(import_chalk25.default.gray(` Worker deleted: ${data.data.worker_deleted ? "\u2705" : "\u274C"}`));
|
|
9417
|
+
console.log(import_chalk25.default.gray(` Database deleted: ${data.data.database_deleted ? "\u2705" : "\u274C"}`));
|
|
9418
|
+
console.log(import_chalk25.default.gray("\nLocal files are kept unchanged."));
|
|
9360
9419
|
} else {
|
|
9361
9420
|
const errorMsg = (data == null ? void 0 : data.msg) || "Failed to delete project";
|
|
9362
9421
|
throw new Error(errorMsg);
|
|
9363
9422
|
}
|
|
9364
9423
|
process.exit(0);
|
|
9365
9424
|
} catch (error) {
|
|
9366
|
-
console.log(
|
|
9425
|
+
console.log(import_chalk25.default.red(error));
|
|
9367
9426
|
const errorMsg = ((_b = (_a2 = error.response) == null ? void 0 : _a2.data) == null ? void 0 : _b.msg) || error.message || "Failed to delete project";
|
|
9368
|
-
console.error(
|
|
9427
|
+
console.error(import_chalk25.default.red(`
|
|
9369
9428
|
\u274C Error: ${errorMsg}`));
|
|
9370
9429
|
process.exit(1);
|
|
9371
9430
|
}
|
|
@@ -9376,9 +9435,9 @@ import_dotenv.default.config();
|
|
|
9376
9435
|
checkNodeVersion();
|
|
9377
9436
|
function showBanner() {
|
|
9378
9437
|
console.log(
|
|
9379
|
-
|
|
9438
|
+
import_chalk26.default.cyan(import_figlet5.default.textSync("Pinme", { horizontalLayout: "full" }))
|
|
9380
9439
|
);
|
|
9381
|
-
console.log(
|
|
9440
|
+
console.log(import_chalk26.default.cyan("A command-line tool for uploading files to IPFS\n"));
|
|
9382
9441
|
}
|
|
9383
9442
|
var program = new import_commander.Command();
|
|
9384
9443
|
program.name("pinme").version(version).option("-v, --version", "output the current version");
|