pinme 2.0.2-beta.7 → 2.0.2-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +57 -7
  2. 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.7";
1526
+ var version = "2.0.2-beta.8";
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: {
@@ -8160,12 +8162,51 @@ async function deployFrontend(projectName) {
8160
8162
  console.log(import_chalk20.default.green(`Frontend deployed to IPFS: ${uploadResult.publicUrl}`));
8161
8163
  updateFrontendUrlInConfig2(import_path12.default.join(PROJECT_DIR2, "pinme.toml"), uploadResult.publicUrl);
8162
8164
  console.log(import_chalk20.default.green("Updated pinme.toml with frontend URL"));
8165
+ return {
8166
+ contentHash: uploadResult.contentHash,
8167
+ publicUrl: uploadResult.publicUrl
8168
+ };
8163
8169
  } catch (error) {
8164
8170
  throw createCommandError("frontend deploy", "upload frontend/dist", error, [
8165
8171
  "Make sure `frontend/dist` exists and the upload API is reachable."
8166
8172
  ]);
8167
8173
  }
8168
8174
  }
8175
+ async function bindFrontendDomain(domain, contentHash, projectName, headers) {
8176
+ const displayDomain = normalizeDomain(domain);
8177
+ const isDns = isDnsDomain(displayDomain);
8178
+ if (isDns) {
8179
+ const validation = validateDnsDomain(displayDomain);
8180
+ if (!validation.valid) {
8181
+ throw createConfigError(validation.message || "Invalid domain format.", [
8182
+ "Use a complete domain like `example.com` for DNS binding."
8183
+ ]);
8184
+ }
8185
+ }
8186
+ if (isDns) {
8187
+ console.log(import_chalk20.default.blue(`Binding DNS domain: ${displayDomain}`));
8188
+ const dnsResult = await bindDnsDomainV4(
8189
+ displayDomain,
8190
+ contentHash,
8191
+ headers["token-address"],
8192
+ headers["authentication-tokens"],
8193
+ projectName
8194
+ );
8195
+ if (dnsResult.code !== 200) {
8196
+ throw new Error(dnsResult.msg || "DNS binding failed");
8197
+ }
8198
+ console.log(import_chalk20.default.green(`DNS bind success: ${displayDomain}`));
8199
+ console.log(import_chalk20.default.white(`Visit: https://${displayDomain}`));
8200
+ return;
8201
+ }
8202
+ console.log(import_chalk20.default.blue(`Binding Pinme subdomain: ${displayDomain}`));
8203
+ const ok = await bindPinmeDomain(displayDomain, contentHash, projectName);
8204
+ if (!ok) {
8205
+ throw new Error("Pinme subdomain binding failed");
8206
+ }
8207
+ console.log(import_chalk20.default.green(`Bind success: ${displayDomain}`));
8208
+ console.log(import_chalk20.default.white(`Visit: https://${displayDomain}.pinit.eth.limo`));
8209
+ }
8169
8210
  async function saveCmd(options) {
8170
8211
  try {
8171
8212
  const headers = getAuthHeaders();
@@ -8204,7 +8245,16 @@ async function saveCmd(options) {
8204
8245
  await saveWorker(workerJsPath, modulePaths, sqlFiles, metadata, projectName);
8205
8246
  console.log(import_chalk20.default.blue("\n--- Frontend ---"));
8206
8247
  buildFrontend();
8207
- await deployFrontend(projectName);
8248
+ const frontendResult = await deployFrontend(projectName);
8249
+ if (options.domain) {
8250
+ console.log(import_chalk20.default.blue("\n--- Domain Binding ---"));
8251
+ await bindFrontendDomain(
8252
+ options.domain,
8253
+ frontendResult.contentHash,
8254
+ projectName,
8255
+ headers
8256
+ );
8257
+ }
8208
8258
  console.log(import_chalk20.default.green("\nDeployment complete."));
8209
8259
  process.exit(0);
8210
8260
  } catch (error) {
@@ -8726,7 +8776,7 @@ program.command("my-domains").alias("domain").description("List domains owned by
8726
8776
  program.command("wallet").alias("wallet-balance").alias("balance").description("Show current wallet balance").action(() => walletBalanceCmd());
8727
8777
  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
8778
  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));
8779
+ program.command("save").description("Deploy the project (frontend + backend)").option("-d, --domain <name>", "Bind a domain after frontend deploy").action((options) => saveCmd(options));
8730
8780
  program.command("update-db").description("Execute database migration").action(() => updateDbCmd());
8731
8781
  program.command("update-worker").description("Execute worker migration").action(() => updateWorkerCmd());
8732
8782
  program.command("update-web").description("Deploy frontend to IPFS").action((options) => updateWebCmd(options));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinme",
3
- "version": "2.0.2-beta.7",
3
+ "version": "2.0.2-beta.8",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },