pinme 2.0.2-beta.7 → 2.0.2-beta.9
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 +54 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1523,7 +1523,7 @@ var import_chalk25 = __toESM(require("chalk"));
|
|
|
1523
1523
|
var import_figlet5 = __toESM(require("figlet"));
|
|
1524
1524
|
|
|
1525
1525
|
// package.json
|
|
1526
|
-
var version = "2.0.2-beta.
|
|
1526
|
+
var version = "2.0.2-beta.9";
|
|
1527
1527
|
|
|
1528
1528
|
// bin/upload.ts
|
|
1529
1529
|
var import_path6 = __toESM(require("path"));
|
|
@@ -5069,12 +5069,13 @@ async function checkDomainAvailable(domainName) {
|
|
|
5069
5069
|
}
|
|
5070
5070
|
return { is_valid: true };
|
|
5071
5071
|
}
|
|
5072
|
-
async function bindPinmeDomain(domainName, hash) {
|
|
5072
|
+
async function bindPinmeDomain(domainName, hash, projectName) {
|
|
5073
5073
|
try {
|
|
5074
5074
|
const client = createPinmeApiClient();
|
|
5075
5075
|
const { data } = await client.post("/bind_pinme_domain", {
|
|
5076
5076
|
domain_name: domainName,
|
|
5077
|
-
hash
|
|
5077
|
+
hash,
|
|
5078
|
+
...projectName ? { project_name: projectName } : {}
|
|
5078
5079
|
});
|
|
5079
5080
|
return (data == null ? void 0 : data.code) === 200;
|
|
5080
5081
|
} catch (e) {
|
|
@@ -5111,14 +5112,15 @@ async function getMyDomains() {
|
|
|
5111
5112
|
throw e;
|
|
5112
5113
|
}
|
|
5113
5114
|
}
|
|
5114
|
-
async function bindDnsDomainV4(domainName, hash, tokenAddress, authToken) {
|
|
5115
|
+
async function bindDnsDomainV4(domainName, hash, tokenAddress, authToken, projectName) {
|
|
5115
5116
|
try {
|
|
5116
5117
|
const client = createPinmeApiClient();
|
|
5117
5118
|
const { data } = await client.post(
|
|
5118
5119
|
"/bind_dns",
|
|
5119
5120
|
{
|
|
5120
5121
|
domain_name: domainName,
|
|
5121
|
-
hash
|
|
5122
|
+
hash,
|
|
5123
|
+
...projectName ? { project_name: projectName } : {}
|
|
5122
5124
|
},
|
|
5123
5125
|
{
|
|
5124
5126
|
headers: {
|
|
@@ -8157,15 +8159,47 @@ async function deployFrontend(projectName) {
|
|
|
8157
8159
|
projectName,
|
|
8158
8160
|
uid: headers["token-address"]
|
|
8159
8161
|
});
|
|
8160
|
-
console.log(import_chalk20.default.green(`Frontend deployed to IPFS: ${uploadResult.publicUrl}`));
|
|
8161
8162
|
updateFrontendUrlInConfig2(import_path12.default.join(PROJECT_DIR2, "pinme.toml"), uploadResult.publicUrl);
|
|
8162
|
-
|
|
8163
|
+
return {
|
|
8164
|
+
contentHash: uploadResult.contentHash,
|
|
8165
|
+
publicUrl: uploadResult.publicUrl
|
|
8166
|
+
};
|
|
8163
8167
|
} catch (error) {
|
|
8164
8168
|
throw createCommandError("frontend deploy", "upload frontend/dist", error, [
|
|
8165
8169
|
"Make sure `frontend/dist` exists and the upload API is reachable."
|
|
8166
8170
|
]);
|
|
8167
8171
|
}
|
|
8168
8172
|
}
|
|
8173
|
+
async function bindFrontendDomain(domain, contentHash, projectName, headers) {
|
|
8174
|
+
const displayDomain = normalizeDomain(domain);
|
|
8175
|
+
const isDns = isDnsDomain(displayDomain);
|
|
8176
|
+
if (isDns) {
|
|
8177
|
+
const validation = validateDnsDomain(displayDomain);
|
|
8178
|
+
if (!validation.valid) {
|
|
8179
|
+
throw createConfigError(validation.message || "Invalid domain format.", [
|
|
8180
|
+
"Use a complete domain like `example.com` for DNS binding."
|
|
8181
|
+
]);
|
|
8182
|
+
}
|
|
8183
|
+
}
|
|
8184
|
+
if (isDns) {
|
|
8185
|
+
const dnsResult = await bindDnsDomainV4(
|
|
8186
|
+
displayDomain,
|
|
8187
|
+
contentHash,
|
|
8188
|
+
headers["token-address"],
|
|
8189
|
+
headers["authentication-tokens"],
|
|
8190
|
+
projectName
|
|
8191
|
+
);
|
|
8192
|
+
if (dnsResult.code !== 200) {
|
|
8193
|
+
throw new Error(dnsResult.msg || "DNS binding failed");
|
|
8194
|
+
}
|
|
8195
|
+
return `https://${displayDomain}`;
|
|
8196
|
+
}
|
|
8197
|
+
const ok = await bindPinmeDomain(displayDomain, contentHash, projectName);
|
|
8198
|
+
if (!ok) {
|
|
8199
|
+
throw new Error("Pinme subdomain binding failed");
|
|
8200
|
+
}
|
|
8201
|
+
return `https://${displayDomain}.pinit.eth.limo`;
|
|
8202
|
+
}
|
|
8169
8203
|
async function saveCmd(options) {
|
|
8170
8204
|
try {
|
|
8171
8205
|
const headers = getAuthHeaders();
|
|
@@ -8204,7 +8238,18 @@ async function saveCmd(options) {
|
|
|
8204
8238
|
await saveWorker(workerJsPath, modulePaths, sqlFiles, metadata, projectName);
|
|
8205
8239
|
console.log(import_chalk20.default.blue("\n--- Frontend ---"));
|
|
8206
8240
|
buildFrontend();
|
|
8207
|
-
await deployFrontend(projectName);
|
|
8241
|
+
const frontendResult = await deployFrontend(projectName);
|
|
8242
|
+
let finalFrontendUrl = frontendResult.publicUrl;
|
|
8243
|
+
if (options.domain) {
|
|
8244
|
+
finalFrontendUrl = await bindFrontendDomain(
|
|
8245
|
+
options.domain,
|
|
8246
|
+
frontendResult.contentHash,
|
|
8247
|
+
projectName,
|
|
8248
|
+
headers
|
|
8249
|
+
);
|
|
8250
|
+
}
|
|
8251
|
+
console.log(import_chalk20.default.blue("\n--- Access ---"));
|
|
8252
|
+
console.log(import_chalk20.default.white(`Frontend URL: ${finalFrontendUrl}`));
|
|
8208
8253
|
console.log(import_chalk20.default.green("\nDeployment complete."));
|
|
8209
8254
|
process.exit(0);
|
|
8210
8255
|
} catch (error) {
|
|
@@ -8726,7 +8771,7 @@ program.command("my-domains").alias("domain").description("List domains owned by
|
|
|
8726
8771
|
program.command("wallet").alias("wallet-balance").alias("balance").description("Show current wallet balance").action(() => walletBalanceCmd());
|
|
8727
8772
|
program.command("bind").description("Upload and bind to a domain (requires wallet balance)").option("-d, --domain <name>", "Domain name to bind").option("--dns", "Force DNS domain mode").action(() => bindCmd());
|
|
8728
8773
|
program.command("create").description("Create a new project from template").argument("[name]", "Project name").option("-f, --force", "Overwrite if exists").action((name, options) => createCmd({ name, force: options == null ? void 0 : options.force }));
|
|
8729
|
-
program.command("save").description("Deploy the project (frontend + backend)").action((options) => saveCmd(options));
|
|
8774
|
+
program.command("save").description("Deploy the project (frontend + backend)").option("-d, --domain <name>", "Bind a domain after frontend deploy").action((options) => saveCmd(options));
|
|
8730
8775
|
program.command("update-db").description("Execute database migration").action(() => updateDbCmd());
|
|
8731
8776
|
program.command("update-worker").description("Execute worker migration").action(() => updateWorkerCmd());
|
|
8732
8777
|
program.command("update-web").description("Deploy frontend to IPFS").action((options) => updateWebCmd(options));
|