pinme 2.0.0 → 2.0.1-beta.2

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 (3) hide show
  1. package/README.md +11 -11
  2. package/dist/index.js +601 -327
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -96,9 +96,9 @@ var require_package = __commonJS({
96
96
  // node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/main.js
97
97
  var require_main = __commonJS({
98
98
  "node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/main.js"(exports2, module2) {
99
- var fs16 = require("fs");
100
- var path17 = require("path");
101
- var os5 = require("os");
99
+ var fs17 = require("fs");
100
+ var path18 = require("path");
101
+ var os6 = require("os");
102
102
  var crypto3 = require("crypto");
103
103
  var packageJson = require_package();
104
104
  var version2 = packageJson.version;
@@ -200,7 +200,7 @@ var require_main = __commonJS({
200
200
  if (options && options.path && options.path.length > 0) {
201
201
  if (Array.isArray(options.path)) {
202
202
  for (const filepath of options.path) {
203
- if (fs16.existsSync(filepath)) {
203
+ if (fs17.existsSync(filepath)) {
204
204
  possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
205
205
  }
206
206
  }
@@ -208,15 +208,15 @@ var require_main = __commonJS({
208
208
  possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
209
209
  }
210
210
  } else {
211
- possibleVaultPath = path17.resolve(process.cwd(), ".env.vault");
211
+ possibleVaultPath = path18.resolve(process.cwd(), ".env.vault");
212
212
  }
213
- if (fs16.existsSync(possibleVaultPath)) {
213
+ if (fs17.existsSync(possibleVaultPath)) {
214
214
  return possibleVaultPath;
215
215
  }
216
216
  return null;
217
217
  }
218
218
  function _resolveHome(envPath) {
219
- return envPath[0] === "~" ? path17.join(os5.homedir(), envPath.slice(1)) : envPath;
219
+ return envPath[0] === "~" ? path18.join(os6.homedir(), envPath.slice(1)) : envPath;
220
220
  }
221
221
  function _configVault(options) {
222
222
  const debug = Boolean(options && options.debug);
@@ -232,7 +232,7 @@ var require_main = __commonJS({
232
232
  return { parsed };
233
233
  }
234
234
  function configDotenv(options) {
235
- const dotenvPath = path17.resolve(process.cwd(), ".env");
235
+ const dotenvPath = path18.resolve(process.cwd(), ".env");
236
236
  let encoding = "utf8";
237
237
  const debug = Boolean(options && options.debug);
238
238
  if (options && options.encoding) {
@@ -255,13 +255,13 @@ var require_main = __commonJS({
255
255
  }
256
256
  let lastError;
257
257
  const parsedAll = {};
258
- for (const path18 of optionPaths) {
258
+ for (const path19 of optionPaths) {
259
259
  try {
260
- const parsed = DotenvModule.parse(fs16.readFileSync(path18, { encoding }));
260
+ const parsed = DotenvModule.parse(fs17.readFileSync(path19, { encoding }));
261
261
  DotenvModule.populate(parsedAll, parsed, options);
262
262
  } catch (e) {
263
263
  if (debug) {
264
- _debug(`Failed to load ${path18} ${e.message}`);
264
+ _debug(`Failed to load ${path19} ${e.message}`);
265
265
  }
266
266
  lastError = e;
267
267
  }
@@ -810,7 +810,7 @@ var require_has_flag = __commonJS({
810
810
  var require_supports_color = __commonJS({
811
811
  "node_modules/.pnpm/supports-color@5.5.0/node_modules/supports-color/index.js"(exports2, module2) {
812
812
  "use strict";
813
- var os5 = require("os");
813
+ var os6 = require("os");
814
814
  var hasFlag = require_has_flag();
815
815
  var env = process.env;
816
816
  var forceColor;
@@ -848,7 +848,7 @@ var require_supports_color = __commonJS({
848
848
  }
849
849
  const min = forceColor ? 1 : 0;
850
850
  if (process.platform === "win32") {
851
- const osRelease = os5.release().split(".");
851
+ const osRelease = os6.release().split(".");
852
852
  if (Number(process.versions.node.split(".")[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
853
853
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
854
854
  }
@@ -1519,11 +1519,11 @@ function checkNodeVersion() {
1519
1519
 
1520
1520
  // bin/index.ts
1521
1521
  var import_commander = require("commander");
1522
- var import_chalk23 = __toESM(require("chalk"));
1522
+ var import_chalk24 = __toESM(require("chalk"));
1523
1523
  var import_figlet5 = __toESM(require("figlet"));
1524
1524
 
1525
1525
  // package.json
1526
- var version = "2.0.0";
1526
+ var version = "2.0.1-beta.2";
1527
1527
 
1528
1528
  // bin/upload.ts
1529
1529
  var import_path7 = __toESM(require("path"));
@@ -1968,9 +1968,9 @@ function isVisitable(thing) {
1968
1968
  function removeBrackets(key) {
1969
1969
  return utils_default.endsWith(key, "[]") ? key.slice(0, -2) : key;
1970
1970
  }
1971
- function renderKey(path17, key, dots) {
1972
- if (!path17) return key;
1973
- return path17.concat(key).map(function each(token, i) {
1971
+ function renderKey(path18, key, dots) {
1972
+ if (!path18) return key;
1973
+ return path18.concat(key).map(function each(token, i) {
1974
1974
  token = removeBrackets(token);
1975
1975
  return !dots && i ? "[" + token + "]" : token;
1976
1976
  }).join(dots ? "." : "");
@@ -2015,9 +2015,9 @@ function toFormData(obj, formData, options) {
2015
2015
  }
2016
2016
  return value;
2017
2017
  }
2018
- function defaultVisitor(value, key, path17) {
2018
+ function defaultVisitor(value, key, path18) {
2019
2019
  let arr = value;
2020
- if (value && !path17 && typeof value === "object") {
2020
+ if (value && !path18 && typeof value === "object") {
2021
2021
  if (utils_default.endsWith(key, "{}")) {
2022
2022
  key = metaTokens ? key : key.slice(0, -2);
2023
2023
  value = JSON.stringify(value);
@@ -2036,7 +2036,7 @@ function toFormData(obj, formData, options) {
2036
2036
  if (isVisitable(value)) {
2037
2037
  return true;
2038
2038
  }
2039
- formData.append(renderKey(path17, key, dots), convertValue(value));
2039
+ formData.append(renderKey(path18, key, dots), convertValue(value));
2040
2040
  return false;
2041
2041
  }
2042
2042
  const stack = [];
@@ -2045,10 +2045,10 @@ function toFormData(obj, formData, options) {
2045
2045
  convertValue,
2046
2046
  isVisitable
2047
2047
  });
2048
- function build(value, path17) {
2048
+ function build(value, path18) {
2049
2049
  if (utils_default.isUndefined(value)) return;
2050
2050
  if (stack.indexOf(value) !== -1) {
2051
- throw Error("Circular reference detected in " + path17.join("."));
2051
+ throw Error("Circular reference detected in " + path18.join("."));
2052
2052
  }
2053
2053
  stack.push(value);
2054
2054
  utils_default.forEach(value, function each(el, key) {
@@ -2056,11 +2056,11 @@ function toFormData(obj, formData, options) {
2056
2056
  formData,
2057
2057
  el,
2058
2058
  utils_default.isString(key) ? key.trim() : key,
2059
- path17,
2059
+ path18,
2060
2060
  exposedHelpers
2061
2061
  );
2062
2062
  if (result === true) {
2063
- build(el, path17 ? path17.concat(key) : [key]);
2063
+ build(el, path18 ? path18.concat(key) : [key]);
2064
2064
  }
2065
2065
  });
2066
2066
  stack.pop();
@@ -2221,7 +2221,7 @@ var node_default = {
2221
2221
  // node_modules/.pnpm/axios@1.3.2/node_modules/axios/lib/helpers/toURLEncodedForm.js
2222
2222
  function toURLEncodedForm(data, options) {
2223
2223
  return toFormData_default(data, new node_default.classes.URLSearchParams(), Object.assign({
2224
- visitor: function(value, key, path17, helpers) {
2224
+ visitor: function(value, key, path18, helpers) {
2225
2225
  if (node_default.isNode && utils_default.isBuffer(value)) {
2226
2226
  this.append(key, value.toString("base64"));
2227
2227
  return false;
@@ -2250,10 +2250,10 @@ function arrayToObject(arr) {
2250
2250
  return obj;
2251
2251
  }
2252
2252
  function formDataToJSON(formData) {
2253
- function buildPath(path17, value, target, index) {
2254
- let name = path17[index++];
2253
+ function buildPath(path18, value, target, index) {
2254
+ let name = path18[index++];
2255
2255
  const isNumericKey = Number.isFinite(+name);
2256
- const isLast = index >= path17.length;
2256
+ const isLast = index >= path18.length;
2257
2257
  name = !name && utils_default.isArray(target) ? target.length : name;
2258
2258
  if (isLast) {
2259
2259
  if (utils_default.hasOwnProp(target, name)) {
@@ -2266,7 +2266,7 @@ function formDataToJSON(formData) {
2266
2266
  if (!target[name] || !utils_default.isObject(target[name])) {
2267
2267
  target[name] = [];
2268
2268
  }
2269
- const result = buildPath(path17, value, target[name], index);
2269
+ const result = buildPath(path18, value, target[name], index);
2270
2270
  if (result && utils_default.isArray(target[name])) {
2271
2271
  target[name] = arrayToObject(target[name]);
2272
2272
  }
@@ -3328,9 +3328,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
3328
3328
  auth = urlUsername + ":" + urlPassword;
3329
3329
  }
3330
3330
  auth && headers.delete("authorization");
3331
- let path17;
3331
+ let path18;
3332
3332
  try {
3333
- path17 = buildURL(
3333
+ path18 = buildURL(
3334
3334
  parsed.pathname + parsed.search,
3335
3335
  config.params,
3336
3336
  config.paramsSerializer
@@ -3348,7 +3348,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
3348
3348
  false
3349
3349
  );
3350
3350
  const options = {
3351
- path: path17,
3351
+ path: path18,
3352
3352
  method,
3353
3353
  headers: headers.toJSON(),
3354
3354
  agents: { http: config.httpAgent, https: config.httpsAgent },
@@ -3567,14 +3567,14 @@ var cookies_default = node_default.isStandardBrowserEnv ? (
3567
3567
  // Standard browser envs support document.cookie
3568
3568
  /* @__PURE__ */ function standardBrowserEnv() {
3569
3569
  return {
3570
- write: function write(name, value, expires, path17, domain, secure) {
3570
+ write: function write(name, value, expires, path18, domain, secure) {
3571
3571
  const cookie = [];
3572
3572
  cookie.push(name + "=" + encodeURIComponent(value));
3573
3573
  if (utils_default.isNumber(expires)) {
3574
3574
  cookie.push("expires=" + new Date(expires).toGMTString());
3575
3575
  }
3576
- if (utils_default.isString(path17)) {
3577
- cookie.push("path=" + path17);
3576
+ if (utils_default.isString(path18)) {
3577
+ cookie.push("path=" + path18);
3578
3578
  }
3579
3579
  if (utils_default.isString(domain)) {
3580
3580
  cookie.push("domain=" + domain);
@@ -7140,14 +7140,54 @@ Login failed: ${(e == null ? void 0 : e.message) || e}`));
7140
7140
  }
7141
7141
 
7142
7142
  // bin/create.ts
7143
- var import_chalk17 = __toESM(require("chalk"));
7143
+ var import_chalk18 = __toESM(require("chalk"));
7144
+ var import_fs_extra7 = __toESM(require("fs-extra"));
7145
+ var import_path12 = __toESM(require("path"));
7146
+ var import_inquirer8 = __toESM(require("inquirer"));
7147
+ var import_child_process3 = require("child_process");
7148
+
7149
+ // bin/utils/installProjectDependencies.ts
7144
7150
  var import_fs_extra6 = __toESM(require("fs-extra"));
7151
+ var import_os5 = __toESM(require("os"));
7145
7152
  var import_path11 = __toESM(require("path"));
7146
- var import_inquirer8 = __toESM(require("inquirer"));
7153
+ var import_chalk16 = __toESM(require("chalk"));
7147
7154
  var import_child_process2 = require("child_process");
7155
+ function makeTempCacheDir() {
7156
+ return import_fs_extra6.default.mkdtempSync(import_path11.default.join(import_os5.default.tmpdir(), "pinme-npm-cache-"));
7157
+ }
7158
+ function runInstall(cwd, cacheDir) {
7159
+ (0, import_child_process2.execFileSync)("npm", ["install", "--cache", cacheDir, "--no-audit", "--no-fund"], {
7160
+ cwd,
7161
+ stdio: "inherit",
7162
+ env: {
7163
+ ...process.env,
7164
+ npm_config_cache: cacheDir,
7165
+ npm_config_audit: "false",
7166
+ npm_config_fund: "false"
7167
+ }
7168
+ });
7169
+ }
7170
+ function installProjectDependencies(cwd) {
7171
+ let lastError;
7172
+ for (let attempt = 1; attempt <= 2; attempt += 1) {
7173
+ const cacheDir = makeTempCacheDir();
7174
+ try {
7175
+ if (attempt > 1) {
7176
+ console.log(import_chalk16.default.yellow(" Retrying dependency install with a fresh npm cache..."));
7177
+ }
7178
+ runInstall(cwd, cacheDir);
7179
+ return;
7180
+ } catch (error) {
7181
+ lastError = error;
7182
+ } finally {
7183
+ import_fs_extra6.default.removeSync(cacheDir);
7184
+ }
7185
+ }
7186
+ throw lastError;
7187
+ }
7148
7188
 
7149
7189
  // bin/utils/cliError.ts
7150
- var import_chalk16 = __toESM(require("chalk"));
7190
+ var import_chalk17 = __toESM(require("chalk"));
7151
7191
  var CliError = class extends Error {
7152
7192
  stage;
7153
7193
  details;
@@ -7278,18 +7318,18 @@ function normalizeCliError(error, fallbackSummary, suggestions = []) {
7278
7318
  }
7279
7319
  function printCliError(error, fallbackSummary) {
7280
7320
  const cliError = normalizeCliError(error, fallbackSummary);
7281
- console.error(import_chalk16.default.red(`
7321
+ console.error(import_chalk17.default.red(`
7282
7322
  Error: ${cliError.message}`));
7283
7323
  if (cliError.stage) {
7284
- console.error(import_chalk16.default.gray(`Stage: ${cliError.stage}`));
7324
+ console.error(import_chalk17.default.gray(`Stage: ${cliError.stage}`));
7285
7325
  }
7286
7326
  for (const detail of cliError.details) {
7287
- console.error(import_chalk16.default.gray(detail));
7327
+ console.error(import_chalk17.default.gray(detail));
7288
7328
  }
7289
7329
  if (cliError.suggestions.length > 0) {
7290
- console.error(import_chalk16.default.yellow("\nNext steps:"));
7330
+ console.error(import_chalk17.default.yellow("\nNext steps:"));
7291
7331
  for (const suggestion of cliError.suggestions) {
7292
- console.error(import_chalk16.default.yellow(`- ${suggestion}`));
7332
+ console.error(import_chalk17.default.yellow(`- ${suggestion}`));
7293
7333
  }
7294
7334
  }
7295
7335
  }
@@ -7300,6 +7340,7 @@ var API_BASE = "https://pinme.dev/api/v4";
7300
7340
  var TEMPLATE_REPO = "glitternetwork/pinme-worker-template";
7301
7341
  var TEMPLATE_ZIP_URL = `https://github.com/${TEMPLATE_REPO}/archive/refs/heads/main.zip`;
7302
7342
  async function createCmd(options) {
7343
+ var _a, _b;
7303
7344
  try {
7304
7345
  const headers = getAuthHeaders();
7305
7346
  if (!headers["authentication-tokens"] || !headers["token-address"]) {
@@ -7307,7 +7348,7 @@ async function createCmd(options) {
7307
7348
  "Run `pinme login` and retry."
7308
7349
  ]);
7309
7350
  }
7310
- console.log(import_chalk17.default.blue("Creating new project from template...\n"));
7351
+ console.log(import_chalk18.default.blue("Creating new project from template...\n"));
7311
7352
  let projectName = options.name;
7312
7353
  if (!projectName) {
7313
7354
  const answers = await import_inquirer8.default.prompt([
@@ -7326,9 +7367,9 @@ async function createCmd(options) {
7326
7367
  ]);
7327
7368
  projectName = answers.projectName;
7328
7369
  }
7329
- const targetDir = import_path11.default.join(PROJECT_DIR, projectName);
7330
- if (import_fs_extra6.default.existsSync(targetDir) && !options.force) {
7331
- console.log(import_chalk17.default.yellow(`
7370
+ const targetDir = import_path12.default.join(PROJECT_DIR, projectName);
7371
+ if (import_fs_extra7.default.existsSync(targetDir) && !options.force) {
7372
+ console.log(import_chalk18.default.yellow(`
7332
7373
  Directory "${projectName}" already exists.`));
7333
7374
  const answers = await import_inquirer8.default.prompt([
7334
7375
  {
@@ -7339,16 +7380,16 @@ Directory "${projectName}" already exists.`));
7339
7380
  }
7340
7381
  ]);
7341
7382
  if (!answers.overwrite) {
7342
- console.log(import_chalk17.default.gray("Cancelled."));
7383
+ console.log(import_chalk18.default.gray("Cancelled."));
7343
7384
  process.exit(0);
7344
7385
  }
7345
- import_fs_extra6.default.removeSync(targetDir);
7386
+ import_fs_extra7.default.removeSync(targetDir);
7346
7387
  }
7347
- console.log(import_chalk17.default.blue("\n1. Creating worker and database..."));
7388
+ console.log(import_chalk18.default.blue("\n1. Creating worker and database..."));
7348
7389
  const apiUrl = `${API_BASE}/create_worker`;
7349
- console.log(import_chalk17.default.gray(`API URL: ${apiUrl}`));
7390
+ console.log(import_chalk18.default.gray(`API URL: ${apiUrl}`));
7350
7391
  const normalizedProjectName = projectName.toLowerCase();
7351
- console.log(import_chalk17.default.gray(`Project name: ${normalizedProjectName}`));
7392
+ console.log(import_chalk18.default.gray(`Project name: ${normalizedProjectName}`));
7352
7393
  let workerData;
7353
7394
  try {
7354
7395
  const response = await axios_default.post(apiUrl, {
@@ -7367,33 +7408,32 @@ Directory "${projectName}" already exists.`));
7367
7408
  ]);
7368
7409
  }
7369
7410
  workerData = data.data;
7370
- console.log(import_chalk17.default.gray(` API Response: ${JSON.stringify(workerData)}`));
7371
- console.log(import_chalk17.default.green(` API Domain: ${workerData.api_domain}`));
7372
- console.log(import_chalk17.default.green(` Project Name: ${workerData.project_name}`));
7373
- console.log(import_chalk17.default.green(` D1 UUID: ${workerData.uuid}`));
7411
+ console.log(import_chalk18.default.gray(` API Response: ${JSON.stringify(workerData)}`));
7412
+ console.log(import_chalk18.default.green(` API Domain: ${workerData.api_domain}`));
7413
+ console.log(import_chalk18.default.green(` Project Name: ${workerData.project_name}`));
7374
7414
  } catch (error) {
7375
7415
  throw createApiError("project creation", error, [
7376
7416
  `Project name: ${normalizedProjectName}`,
7377
7417
  `Endpoint: ${apiUrl}`
7378
7418
  ]);
7379
7419
  }
7380
- console.log(import_chalk17.default.blue("\n2. Downloading template from repository..."));
7381
- const zipPath = import_path11.default.join(PROJECT_DIR, "template.zip");
7420
+ console.log(import_chalk18.default.blue("\n2. Downloading template from repository..."));
7421
+ const zipPath = import_path12.default.join(PROJECT_DIR, "template.zip");
7382
7422
  let downloadSuccess = false;
7383
7423
  for (let attempt = 1; attempt <= 3 && !downloadSuccess; attempt++) {
7384
7424
  try {
7385
- console.log(import_chalk17.default.gray(` Download attempt ${attempt}/3...`));
7386
- (0, import_child_process2.execSync)(`curl -L --retry 3 --retry-delay 2 -o "${zipPath}" "${TEMPLATE_ZIP_URL}"`, {
7425
+ console.log(import_chalk18.default.gray(` Download attempt ${attempt}/3...`));
7426
+ (0, import_child_process3.execSync)(`curl -L --retry 3 --retry-delay 2 -o "${zipPath}" "${TEMPLATE_ZIP_URL}"`, {
7387
7427
  stdio: "inherit"
7388
7428
  });
7389
- if (!import_fs_extra6.default.existsSync(zipPath) || import_fs_extra6.default.statSync(zipPath).size < 100) {
7429
+ if (!import_fs_extra7.default.existsSync(zipPath) || import_fs_extra7.default.statSync(zipPath).size < 100) {
7390
7430
  throw new Error("Downloaded file is too small or empty");
7391
7431
  }
7392
7432
  downloadSuccess = true;
7393
7433
  } catch (downloadError) {
7394
- console.log(import_chalk17.default.yellow(` Attempt ${attempt} failed: ${downloadError.message}`));
7395
- if (import_fs_extra6.default.existsSync(zipPath)) {
7396
- import_fs_extra6.default.removeSync(zipPath);
7434
+ console.log(import_chalk18.default.yellow(` Attempt ${attempt} failed: ${downloadError.message}`));
7435
+ if (import_fs_extra7.default.existsSync(zipPath)) {
7436
+ import_fs_extra7.default.removeSync(zipPath);
7397
7437
  }
7398
7438
  if (attempt === 3) {
7399
7439
  throw new Error(`Failed to download template after 3 attempts: ${downloadError.message}`);
@@ -7401,113 +7441,295 @@ Directory "${projectName}" already exists.`));
7401
7441
  }
7402
7442
  }
7403
7443
  try {
7404
- (0, import_child_process2.execSync)(`unzip -o "${zipPath}" -d "${PROJECT_DIR}"`, {
7444
+ (0, import_child_process3.execSync)(`unzip -o "${zipPath}" -d "${PROJECT_DIR}"`, {
7405
7445
  stdio: "inherit"
7406
7446
  });
7407
- const subDir = import_path11.default.join(PROJECT_DIR, "pinme-worker-template-main");
7408
- if (import_fs_extra6.default.existsSync(subDir)) {
7409
- import_fs_extra6.default.copySync(subDir, targetDir);
7410
- import_fs_extra6.default.removeSync(subDir);
7411
- }
7412
- import_fs_extra6.default.removeSync(zipPath);
7413
- console.log(import_chalk17.default.green(` Template downloaded to: ${targetDir}`));
7447
+ const subDir = import_path12.default.join(PROJECT_DIR, "pinme-worker-template-main");
7448
+ if (import_fs_extra7.default.existsSync(subDir)) {
7449
+ import_fs_extra7.default.copySync(subDir, targetDir);
7450
+ import_fs_extra7.default.removeSync(subDir);
7451
+ }
7452
+ import_fs_extra7.default.removeSync(zipPath);
7453
+ const nodeModulesPath = import_path12.default.join(targetDir, "node_modules");
7454
+ const packageLockPath = import_path12.default.join(targetDir, "package-lock.json");
7455
+ if (import_fs_extra7.default.existsSync(nodeModulesPath)) {
7456
+ console.log(import_chalk18.default.gray(" Removing existing node_modules..."));
7457
+ import_fs_extra7.default.removeSync(nodeModulesPath);
7458
+ }
7459
+ if (import_fs_extra7.default.existsSync(packageLockPath)) {
7460
+ console.log(import_chalk18.default.gray(" Removing existing package-lock.json..."));
7461
+ import_fs_extra7.default.removeSync(packageLockPath);
7462
+ }
7463
+ const frontendNodeModules = import_path12.default.join(targetDir, "frontend", "node_modules");
7464
+ const backendNodeModules = import_path12.default.join(targetDir, "backend", "node_modules");
7465
+ const frontendPackageLock = import_path12.default.join(targetDir, "frontend", "package-lock.json");
7466
+ const backendPackageLock = import_path12.default.join(targetDir, "backend", "package-lock.json");
7467
+ if (import_fs_extra7.default.existsSync(frontendNodeModules)) import_fs_extra7.default.removeSync(frontendNodeModules);
7468
+ if (import_fs_extra7.default.existsSync(backendNodeModules)) import_fs_extra7.default.removeSync(backendNodeModules);
7469
+ if (import_fs_extra7.default.existsSync(frontendPackageLock)) import_fs_extra7.default.removeSync(frontendPackageLock);
7470
+ if (import_fs_extra7.default.existsSync(backendPackageLock)) import_fs_extra7.default.removeSync(backendPackageLock);
7471
+ console.log(import_chalk18.default.green(` Template downloaded to: ${targetDir}`));
7414
7472
  } catch (error) {
7415
7473
  throw createCommandError("template extraction", `unzip -o "${zipPath}" -d "${PROJECT_DIR}"`, error, [
7416
7474
  "Check whether `unzip` is available and the downloaded template archive is valid."
7417
7475
  ]);
7418
7476
  }
7419
- console.log(import_chalk17.default.blue("\n3. Updating configuration..."));
7420
- const configPath = import_path11.default.join(targetDir, "pinme.toml");
7421
- const config = import_fs_extra6.default.readFileSync(configPath, "utf-8");
7477
+ console.log(import_chalk18.default.blue("\n3. Updating configuration..."));
7478
+ const configPath = import_path12.default.join(targetDir, "pinme.toml");
7479
+ const config = import_fs_extra7.default.readFileSync(configPath, "utf-8");
7422
7480
  let updatedConfig = config.replace(
7423
7481
  /project_name = ".*"/,
7424
7482
  `project_name = "${workerData.project_name}"`
7425
7483
  );
7426
- import_fs_extra6.default.writeFileSync(configPath, updatedConfig);
7427
- console.log(import_chalk17.default.green(` Updated pinme.toml`));
7428
- console.log(import_chalk17.default.gray(` metadata: ${workerData.metadata}`));
7429
- console.log(import_chalk17.default.gray(` VITE_API_URL: ${workerData.api_domain}`));
7430
- const backendDir = import_path11.default.join(targetDir, "backend");
7431
- if (import_fs_extra6.default.existsSync(backendDir) && workerData.metadata) {
7484
+ import_fs_extra7.default.writeFileSync(configPath, updatedConfig);
7485
+ console.log(import_chalk18.default.green(` Updated pinme.toml`));
7486
+ console.log(import_chalk18.default.gray(` metadata: ${workerData.metadata}`));
7487
+ const backendDir = import_path12.default.join(targetDir, "backend");
7488
+ if (import_fs_extra7.default.existsSync(backendDir) && workerData.metadata) {
7432
7489
  const metadataContent = typeof workerData.metadata === "string" ? workerData.metadata : JSON.stringify(workerData.metadata, null, 2);
7433
- import_fs_extra6.default.writeFileSync(
7434
- import_path11.default.join(backendDir, "metadata.json"),
7490
+ import_fs_extra7.default.writeFileSync(
7491
+ import_path12.default.join(backendDir, "metadata.json"),
7435
7492
  metadataContent
7436
7493
  );
7437
- console.log(import_chalk17.default.green(` Saved metadata.json`));
7494
+ console.log(import_chalk18.default.green(` Saved metadata.json`));
7438
7495
  }
7439
- const wranglerPath = import_path11.default.join(backendDir, "wrangler.toml");
7440
- if (import_fs_extra6.default.existsSync(wranglerPath) && workerData.api_key) {
7441
- let wranglerContent = import_fs_extra6.default.readFileSync(wranglerPath, "utf-8");
7496
+ const wranglerPath = import_path12.default.join(backendDir, "wrangler.toml");
7497
+ if (import_fs_extra7.default.existsSync(wranglerPath) && workerData.api_key) {
7498
+ let wranglerContent = import_fs_extra7.default.readFileSync(wranglerPath, "utf-8");
7442
7499
  wranglerContent = wranglerContent.replace(
7443
7500
  /^name = ".*"$/m,
7444
7501
  `name = "${workerData.project_name}"`
7445
7502
  );
7446
- import_fs_extra6.default.writeFileSync(wranglerPath, wranglerContent);
7447
- console.log(import_chalk17.default.green(` Updated backend/wrangler.toml API_KEY`));
7503
+ import_fs_extra7.default.writeFileSync(wranglerPath, wranglerContent);
7504
+ console.log(import_chalk18.default.green(` Updated backend/wrangler.toml API_KEY`));
7448
7505
  }
7449
- const envExamplePath = import_path11.default.join(targetDir, "frontend", ".env.example");
7450
- const envPath = import_path11.default.join(targetDir, "frontend", ".env");
7451
- if (import_fs_extra6.default.existsSync(envExamplePath)) {
7452
- let envContent = import_fs_extra6.default.readFileSync(envExamplePath, "utf-8");
7506
+ const envExamplePath = import_path12.default.join(targetDir, "frontend", ".env.example");
7507
+ const envPath = import_path12.default.join(targetDir, "frontend", ".env");
7508
+ if (import_fs_extra7.default.existsSync(envExamplePath)) {
7509
+ let envContent = import_fs_extra7.default.readFileSync(envExamplePath, "utf-8");
7453
7510
  envContent = envContent.replace(/your-project/g, workerData.project_name);
7454
7511
  envContent = envContent.replace(
7455
7512
  /^VITE_API_URL=.*$/m,
7456
7513
  `VITE_API_URL=${workerData.api_domain}`
7457
7514
  );
7458
- import_fs_extra6.default.writeFileSync(envPath, envContent);
7459
- console.log(import_chalk17.default.green(` Created frontend/.env file`));
7515
+ import_fs_extra7.default.writeFileSync(envPath, envContent);
7516
+ console.log(import_chalk18.default.green(` Created frontend/.env file`));
7517
+ console.log(import_chalk18.default.gray(` VITE_API_URL: ${workerData.api_domain}`));
7518
+ }
7519
+ let pinmeConfig = import_fs_extra7.default.readFileSync(configPath, "utf-8");
7520
+ if (pinmeConfig.includes("api_url")) {
7521
+ pinmeConfig = pinmeConfig.replace(
7522
+ /api_url\s*=\s*"[^"]*"/,
7523
+ `api_url = "${workerData.api_domain}"`
7524
+ );
7525
+ } else {
7526
+ const lines = pinmeConfig.split("\n");
7527
+ const newLines = [];
7528
+ for (const line of lines) {
7529
+ newLines.push(line);
7530
+ if (line.trim().startsWith("project_name")) {
7531
+ newLines.push(`api_url = "${workerData.api_domain}"`);
7532
+ }
7533
+ }
7534
+ pinmeConfig = newLines.join("\n");
7535
+ }
7536
+ import_fs_extra7.default.writeFileSync(configPath, pinmeConfig);
7537
+ console.log(import_chalk18.default.green(` Updated pinme.toml with api_url`));
7538
+ console.log(import_chalk18.default.blue("\n4. Installing dependencies..."));
7539
+ try {
7540
+ installProjectDependencies(targetDir);
7541
+ console.log(import_chalk18.default.green(" Project dependencies installed"));
7542
+ } catch (error) {
7543
+ const errorMsg = error.message || "";
7544
+ if (errorMsg.includes("EACCES") || errorMsg.includes("EPERM") || errorMsg.includes("permission denied")) {
7545
+ throw createCommandError("project dependency install", "npm install", error, [
7546
+ "Permission error detected. Here are some solutions:",
7547
+ "",
7548
+ "Option 1: Fix npm permissions (Recommended)",
7549
+ " mkdir -p ~/.npm-global",
7550
+ " npm config set prefix ~/.npm-global",
7551
+ " Then add ~/.npm-global/bin to your PATH in ~/.bashrc or ~/.zshrc",
7552
+ "",
7553
+ "Option 2: Use npx to avoid global installs",
7554
+ " npx npm install",
7555
+ "",
7556
+ "Option 3: Check if you have write permissions",
7557
+ " ls -la " + targetDir,
7558
+ "",
7559
+ "For more help: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally"
7560
+ ]);
7561
+ }
7562
+ if (errorMsg.includes("ENOTFOUND") || errorMsg.includes("ETIMEDOUT") || errorMsg.includes("network")) {
7563
+ throw createCommandError("project dependency install", "npm install", error, [
7564
+ "Network error detected. Please check:",
7565
+ " 1. Internet connection is available",
7566
+ " 2. npm registry is accessible (https://registry.npmjs.org)",
7567
+ " 3. Try using a mirror: npm config set registry https://registry.npmmirror.com"
7568
+ ]);
7569
+ }
7570
+ throw createCommandError("project dependency install", "npm install", error, [
7571
+ "Dependency installation failed.",
7572
+ "Check network connectivity and npm registry availability.",
7573
+ "Inspect the generated workspace `package.json` files for dependency conflicts.",
7574
+ "",
7575
+ "If this is a permission issue, try:",
7576
+ " sudo chown -R $(whoami) ~/.npm",
7577
+ " sudo chown -R $(whoami) " + targetDir + "/node_modules"
7578
+ ]);
7460
7579
  }
7461
- console.log(import_chalk17.default.blue("\n4. Building frontend..."));
7580
+ console.log(import_chalk18.default.blue("\n5. Building backend worker..."));
7462
7581
  try {
7463
- (0, import_child_process2.execSync)("npm install", {
7582
+ (0, import_child_process3.execSync)("npm run build:worker", {
7464
7583
  cwd: targetDir,
7465
7584
  stdio: "inherit"
7466
7585
  });
7467
- console.log(import_chalk17.default.green(" Project dependencies installed"));
7586
+ console.log(import_chalk18.default.green(" Worker built"));
7468
7587
  } catch (error) {
7469
- throw createCommandError("project dependency install", "npm install", error, [
7470
- "Check network connectivity and npm registry availability.",
7471
- "Inspect the generated workspace `package.json` files for dependency conflicts."
7588
+ throw createCommandError("worker build", "npm run build:worker", error, [
7589
+ "Fix the build error shown above, then rerun `pinme create`."
7590
+ ]);
7591
+ }
7592
+ const distWorkerDir = import_path12.default.join(targetDir, "dist-worker");
7593
+ const workerJsPath = import_path12.default.join(distWorkerDir, "worker.js");
7594
+ if (!import_fs_extra7.default.existsSync(distWorkerDir) || !import_fs_extra7.default.existsSync(workerJsPath)) {
7595
+ throw createConfigError("Built worker output not found: `dist-worker/worker.js`.", [
7596
+ "Make sure `npm run build:worker` completed successfully."
7597
+ ]);
7598
+ }
7599
+ const modulePaths = [];
7600
+ const files = import_fs_extra7.default.readdirSync(distWorkerDir);
7601
+ for (const file of files) {
7602
+ if (file.endsWith(".js") && file !== "worker.js") {
7603
+ modulePaths.push(import_path12.default.join(distWorkerDir, file));
7604
+ }
7605
+ }
7606
+ const sqlDir = import_path12.default.join(targetDir, "db");
7607
+ const sqlFiles = [];
7608
+ if (import_fs_extra7.default.existsSync(sqlDir)) {
7609
+ const sqlFileNames = import_fs_extra7.default.readdirSync(sqlDir).filter((f) => f.endsWith(".sql")).sort();
7610
+ for (const filename of sqlFileNames) {
7611
+ sqlFiles.push(import_path12.default.join(sqlDir, filename));
7612
+ console.log(import_chalk18.default.gray(` Including SQL: ${filename}`));
7613
+ }
7614
+ }
7615
+ console.log(import_chalk18.default.blue("\n6. Deploying backend worker..."));
7616
+ const saveApiUrl = `${API_BASE}/save_worker?project_name=${encodeURIComponent(workerData.project_name)}`;
7617
+ console.log(import_chalk18.default.gray(` API URL: ${saveApiUrl}`));
7618
+ try {
7619
+ const FormData4 = (await import("formdata-node")).FormData;
7620
+ const Blob2 = (await import("formdata-node")).Blob;
7621
+ const formData = new FormData4();
7622
+ const metadataContent = typeof workerData.metadata === "string" ? workerData.metadata : JSON.stringify(workerData.metadata, null, 2);
7623
+ formData.append("metadata", new Blob2([metadataContent], {
7624
+ type: "application/json"
7625
+ }), "metadata.json");
7626
+ const workerCode = import_fs_extra7.default.readFileSync(workerJsPath, "utf-8");
7627
+ formData.append("worker.js", new Blob2([workerCode], {
7628
+ type: "application/javascript+module"
7629
+ }), "worker.js");
7630
+ for (const modulePath of modulePaths) {
7631
+ const filename = import_path12.default.basename(modulePath);
7632
+ const content = import_fs_extra7.default.readFileSync(modulePath, "utf-8");
7633
+ formData.append(filename, new Blob2([content], {
7634
+ type: "application/javascript+module"
7635
+ }), filename);
7636
+ }
7637
+ for (const sqlFile of sqlFiles) {
7638
+ const filename = import_path12.default.basename(sqlFile);
7639
+ const content = import_fs_extra7.default.readFileSync(sqlFile, "utf-8");
7640
+ formData.append("sql_file", new Blob2([content], {
7641
+ type: "application/sql"
7642
+ }), filename);
7643
+ }
7644
+ const response = await axios_default.put(saveApiUrl, formData, {
7645
+ headers: { ...headers },
7646
+ timeout: 12e4
7647
+ });
7648
+ if (response.data) {
7649
+ console.log(import_chalk18.default.green(" Worker deployed"));
7650
+ if ((_b = (_a = response.data) == null ? void 0 : _a.data) == null ? void 0 : _b.sql_results) {
7651
+ for (const result of response.data.data.sql_results) {
7652
+ console.log(import_chalk18.default.gray(` SQL ${result.filename}: ${result.status}`));
7653
+ }
7654
+ }
7655
+ } else {
7656
+ throw createApiError("worker save", { response: { data: response.data } }, [
7657
+ `Project: ${workerData.project_name}`,
7658
+ `Endpoint: ${saveApiUrl}`
7659
+ ], [
7660
+ "Verify the project exists and your account has permission to update it."
7661
+ ]);
7662
+ }
7663
+ } catch (error) {
7664
+ throw createApiError("worker save", error, [
7665
+ `Project: ${workerData.project_name}`,
7666
+ `Endpoint: ${saveApiUrl}`
7667
+ ], [
7668
+ "Check whether backend metadata, SQL files, or worker bundle contains invalid content."
7472
7669
  ]);
7473
7670
  }
7474
- const frontendDir = import_path11.default.join(targetDir, "frontend");
7475
- if (import_fs_extra6.default.existsSync(frontendDir)) {
7671
+ console.log(import_chalk18.default.blue("\n7. Building frontend..."));
7672
+ const frontendDir = import_path12.default.join(targetDir, "frontend");
7673
+ if (import_fs_extra7.default.existsSync(frontendDir)) {
7476
7674
  try {
7477
- (0, import_child_process2.execSync)("npm run build:frontend", {
7675
+ (0, import_child_process3.execSync)("npm run build:frontend", {
7478
7676
  cwd: targetDir,
7479
7677
  stdio: "inherit"
7480
7678
  });
7481
- console.log(import_chalk17.default.green(" Frontend built"));
7679
+ console.log(import_chalk18.default.green(" Frontend built"));
7482
7680
  } catch (error) {
7483
7681
  throw createCommandError("frontend build", "npm run build:frontend", error, [
7484
7682
  "Fix the frontend build error shown above, then rerun `pinme create`."
7485
7683
  ]);
7486
7684
  }
7487
- console.log(import_chalk17.default.blue(" Uploading to IPFS..."));
7685
+ console.log(import_chalk18.default.blue(" Uploading to IPFS..."));
7686
+ let frontendUrl = "";
7488
7687
  try {
7489
- (0, import_child_process2.execSync)("pinme upload ./dist", {
7688
+ const uploadOutput = (0, import_child_process3.execSync)("pinme upload ./dist", {
7490
7689
  cwd: frontendDir,
7491
- stdio: "inherit",
7690
+ encoding: "utf-8",
7492
7691
  env: {
7493
7692
  ...process.env,
7494
7693
  PINME_PROJECT_NAME: workerData.project_name
7495
7694
  }
7496
7695
  });
7497
- console.log(import_chalk17.default.green(" Frontend uploaded to IPFS"));
7696
+ console.log(uploadOutput);
7697
+ const urlMatch = uploadOutput.match(/https:\/\/[\w-]+\.pinme\.dev/);
7698
+ if (urlMatch) {
7699
+ frontendUrl = urlMatch[0];
7700
+ console.log(import_chalk18.default.green(` Frontend uploaded to IPFS: ${frontendUrl}`));
7701
+ const configPath2 = import_path12.default.join(targetDir, "pinme.toml");
7702
+ let config2 = import_fs_extra7.default.readFileSync(configPath2, "utf-8");
7703
+ if (config2.includes("frontend_url")) {
7704
+ config2 = config2.replace(
7705
+ /frontend_url\s*=\s*"[^"]*"/,
7706
+ `frontend_url = "${frontendUrl}"`
7707
+ );
7708
+ } else {
7709
+ config2 = config2.replace(
7710
+ /(project_name\s*=\s*"[^"]*"\n)/,
7711
+ `$1frontend_url = "${frontendUrl}"
7712
+ `
7713
+ );
7714
+ }
7715
+ import_fs_extra7.default.writeFileSync(configPath2, config2);
7716
+ console.log(import_chalk18.default.green(" Updated pinme.toml with frontend URL"));
7717
+ } else {
7718
+ console.log(import_chalk18.default.green(" Frontend uploaded to IPFS"));
7719
+ }
7498
7720
  } catch (error) {
7499
- console.log(import_chalk17.default.yellow(" Warning: IPFS upload failed, you can upload manually later"));
7721
+ console.log(import_chalk18.default.yellow(" Warning: IPFS upload failed, you can upload manually later"));
7500
7722
  }
7501
7723
  }
7502
- console.log(import_chalk17.default.green("\nProject created successfully."));
7503
- console.log(import_chalk17.default.gray(`
7724
+ console.log(import_chalk18.default.green("\nProject created successfully."));
7725
+ console.log(import_chalk18.default.gray(`
7504
7726
  Project Details:`));
7505
- console.log(import_chalk17.default.gray(` API Domain: ${workerData.api_domain}`));
7506
- console.log(import_chalk17.default.gray(` Project Name: ${workerData.project_name}`));
7507
- console.log(import_chalk17.default.gray(`
7727
+ console.log(import_chalk18.default.gray(` API Domain: ${workerData.api_domain}`));
7728
+ console.log(import_chalk18.default.gray(` Project Name: ${workerData.project_name}`));
7729
+ console.log(import_chalk18.default.gray(`
7508
7730
  Next steps:`));
7509
- console.log(import_chalk17.default.gray(` cd ${projectName}`));
7510
- console.log(import_chalk17.default.gray(` pinme save`));
7731
+ console.log(import_chalk18.default.gray(` cd ${projectName}`));
7732
+ console.log(import_chalk18.default.gray(` pinme save`));
7511
7733
  process.exit(0);
7512
7734
  } catch (error) {
7513
7735
  printCliError(error, "Project creation failed.");
@@ -7516,42 +7738,42 @@ Next steps:`));
7516
7738
  }
7517
7739
 
7518
7740
  // bin/save.ts
7519
- var import_chalk18 = __toESM(require("chalk"));
7520
- var import_fs_extra7 = __toESM(require("fs-extra"));
7521
- var import_path12 = __toESM(require("path"));
7522
- var import_child_process3 = require("child_process");
7741
+ var import_chalk19 = __toESM(require("chalk"));
7742
+ var import_fs_extra8 = __toESM(require("fs-extra"));
7743
+ var import_path13 = __toESM(require("path"));
7744
+ var import_child_process4 = require("child_process");
7523
7745
  var PROJECT_DIR2 = process.cwd();
7524
7746
  var API_BASE2 = "https://pinme.dev/api/v4";
7525
7747
  function loadConfig() {
7526
- const configPath = import_path12.default.join(PROJECT_DIR2, "pinme.toml");
7527
- if (!import_fs_extra7.default.existsSync(configPath)) {
7748
+ const configPath = import_path13.default.join(PROJECT_DIR2, "pinme.toml");
7749
+ if (!import_fs_extra8.default.existsSync(configPath)) {
7528
7750
  throw createConfigError("`pinme.toml` not found in the current directory.", [
7529
7751
  "Run this command from the Pinme project root.",
7530
7752
  "If the project has not been initialized yet, create or restore `pinme.toml` first."
7531
7753
  ]);
7532
7754
  }
7533
- const configContent = import_fs_extra7.default.readFileSync(configPath, "utf-8");
7755
+ const configContent = import_fs_extra8.default.readFileSync(configPath, "utf-8");
7534
7756
  const projectNameMatch = configContent.match(/project_name\s*=\s*"([^"]+)"/);
7535
7757
  return {
7536
7758
  project_name: (projectNameMatch == null ? void 0 : projectNameMatch[1]) || ""
7537
7759
  };
7538
7760
  }
7539
7761
  function getMetadata() {
7540
- const metadataPath = import_path12.default.join(PROJECT_DIR2, "backend", "metadata.json");
7541
- if (!import_fs_extra7.default.existsSync(metadataPath)) {
7542
- console.log(import_chalk18.default.yellow(" Warning: metadata.json not found, using empty metadata"));
7762
+ const metadataPath = import_path13.default.join(PROJECT_DIR2, "backend", "metadata.json");
7763
+ if (!import_fs_extra8.default.existsSync(metadataPath)) {
7764
+ console.log(import_chalk19.default.yellow(" Warning: metadata.json not found, using empty metadata"));
7543
7765
  return {};
7544
7766
  }
7545
- return import_fs_extra7.default.readJsonSync(metadataPath);
7767
+ return import_fs_extra8.default.readJsonSync(metadataPath);
7546
7768
  }
7547
7769
  function buildWorker() {
7548
- console.log(import_chalk18.default.blue("Building worker..."));
7770
+ console.log(import_chalk19.default.blue("Building worker..."));
7549
7771
  try {
7550
- (0, import_child_process3.execSync)("npm run build:worker", {
7772
+ (0, import_child_process4.execSync)("npm run build:worker", {
7551
7773
  cwd: PROJECT_DIR2,
7552
7774
  stdio: "inherit"
7553
7775
  });
7554
- console.log(import_chalk18.default.green("Worker built"));
7776
+ console.log(import_chalk19.default.green("Worker built"));
7555
7777
  } catch (error) {
7556
7778
  throw createCommandError("worker build", "npm run build:worker", error, [
7557
7779
  "Fix the build error shown above, then rerun `pinme save`."
@@ -7559,61 +7781,90 @@ function buildWorker() {
7559
7781
  }
7560
7782
  }
7561
7783
  function installDependencies() {
7562
- console.log(import_chalk18.default.blue("Installing dependencies..."));
7784
+ console.log(import_chalk19.default.blue("Installing dependencies..."));
7563
7785
  try {
7564
- (0, import_child_process3.execSync)("npm install", {
7565
- cwd: PROJECT_DIR2,
7566
- stdio: "inherit"
7567
- });
7568
- console.log(import_chalk18.default.green("Project dependencies installed"));
7786
+ installProjectDependencies(PROJECT_DIR2);
7787
+ console.log(import_chalk19.default.green("Project dependencies installed"));
7569
7788
  } catch (error) {
7789
+ const errorMsg = error.message || "";
7790
+ if (errorMsg.includes("EACCES") || errorMsg.includes("EPERM") || errorMsg.includes("permission denied")) {
7791
+ throw createCommandError("project dependency install", "npm install", error, [
7792
+ "Permission error detected. Here are some solutions:",
7793
+ "",
7794
+ "Option 1: Fix npm permissions (Recommended)",
7795
+ " mkdir -p ~/.npm-global",
7796
+ " npm config set prefix ~/.npm-global",
7797
+ " Then add ~/.npm-global/bin to your PATH in ~/.bashrc or ~/.zshrc",
7798
+ "",
7799
+ "Option 2: Use npx to avoid global installs",
7800
+ " npx npm install",
7801
+ "",
7802
+ "Option 3: Check if you have write permissions",
7803
+ " ls -la " + PROJECT_DIR2,
7804
+ "",
7805
+ "For more help: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally"
7806
+ ]);
7807
+ }
7808
+ if (errorMsg.includes("ENOTFOUND") || errorMsg.includes("ETIMEDOUT") || errorMsg.includes("network")) {
7809
+ throw createCommandError("project dependency install", "npm install", error, [
7810
+ "Network error detected. Please check:",
7811
+ " 1. Internet connection is available",
7812
+ " 2. npm registry is accessible (https://registry.npmjs.org)",
7813
+ " 3. Try using a mirror: npm config set registry https://registry.npmmirror.com"
7814
+ ]);
7815
+ }
7570
7816
  throw createCommandError("project dependency install", "npm install", error, [
7817
+ "Dependency installation failed.",
7571
7818
  "Check network connectivity and npm registry availability.",
7572
- "If `package-lock.json` is stale or conflicted, resolve that before retrying."
7819
+ "If `package-lock.json` is stale or conflicted, resolve that before retrying.",
7820
+ "",
7821
+ "If this is a permission issue, try:",
7822
+ " sudo chown -R $(whoami) ~/.npm",
7823
+ " sudo chown -R $(whoami) " + PROJECT_DIR2 + "/node_modules"
7573
7824
  ]);
7574
7825
  }
7575
7826
  }
7576
7827
  function getBuiltWorker() {
7577
- const distWorkerDir = import_path12.default.join(PROJECT_DIR2, "dist-worker");
7578
- if (!import_fs_extra7.default.existsSync(distWorkerDir)) {
7828
+ const distWorkerDir = import_path13.default.join(PROJECT_DIR2, "dist-worker");
7829
+ if (!import_fs_extra8.default.existsSync(distWorkerDir)) {
7579
7830
  throw createConfigError("Built worker output not found: `dist-worker/`.", [
7580
7831
  "Make sure `npm run build:worker` completed successfully."
7581
7832
  ]);
7582
7833
  }
7583
- const workerJsPath = import_path12.default.join(distWorkerDir, "worker.js");
7584
- if (!import_fs_extra7.default.existsSync(workerJsPath)) {
7834
+ const workerJsPath = import_path13.default.join(distWorkerDir, "worker.js");
7835
+ if (!import_fs_extra8.default.existsSync(workerJsPath)) {
7585
7836
  throw createConfigError("Built worker entry file not found: `dist-worker/worker.js`.", [
7586
7837
  "Check the worker build output and bundler config."
7587
7838
  ]);
7588
7839
  }
7589
7840
  const modulePaths = [];
7590
- const files = import_fs_extra7.default.readdirSync(distWorkerDir);
7841
+ const files = import_fs_extra8.default.readdirSync(distWorkerDir);
7591
7842
  for (const file of files) {
7592
7843
  if (file.endsWith(".js") && file !== "worker.js") {
7593
- modulePaths.push(import_path12.default.join(distWorkerDir, file));
7844
+ modulePaths.push(import_path13.default.join(distWorkerDir, file));
7594
7845
  }
7595
7846
  }
7596
7847
  return { workerJsPath, modulePaths };
7597
7848
  }
7598
7849
  function getSqlFiles() {
7599
- const sqlDir = import_path12.default.join(PROJECT_DIR2, "db");
7600
- if (!import_fs_extra7.default.existsSync(sqlDir)) {
7850
+ const sqlDir = import_path13.default.join(PROJECT_DIR2, "db");
7851
+ if (!import_fs_extra8.default.existsSync(sqlDir)) {
7601
7852
  return [];
7602
7853
  }
7603
- const files = import_fs_extra7.default.readdirSync(sqlDir).filter((f) => f.endsWith(".sql")).sort();
7604
- return files.map((f) => import_path12.default.join(sqlDir, f));
7854
+ const files = import_fs_extra8.default.readdirSync(sqlDir).filter((f) => f.endsWith(".sql")).sort();
7855
+ return files.map((f) => import_path13.default.join(sqlDir, f));
7605
7856
  }
7606
7857
  async function saveWorker(workerJsPath, modulePaths, sqlFiles, metadata, projectName) {
7607
7858
  var _a, _b;
7608
- console.log(import_chalk18.default.blue("Saving worker to platform..."));
7609
- console.log(import_chalk18.default.gray(`Project: ${projectName}`));
7610
- console.log(import_chalk18.default.gray(`workerJsPath: ${workerJsPath}`));
7611
- console.log(import_chalk18.default.gray(`modulePaths: ${modulePaths}`));
7612
- console.log(import_chalk18.default.gray(`sqlFiles: ${sqlFiles}`));
7613
- console.log(import_chalk18.default.gray(`metadata: ${metadata}`));
7859
+ console.log(import_chalk19.default.blue("Saving worker to platform..."));
7860
+ console.log(import_chalk19.default.gray(`Project: ${projectName}`));
7861
+ console.log(import_chalk19.default.gray(`workerJsPath: ${workerJsPath}`));
7862
+ console.log(import_chalk19.default.gray(`modulePaths: ${modulePaths}`));
7863
+ console.log(import_chalk19.default.gray(`sqlFiles: ${sqlFiles}`));
7864
+ console.log(import_chalk19.default.gray(`metadata: ${metadata}`));
7614
7865
  const apiUrl = `${API_BASE2}/save_worker?project_name=${encodeURIComponent(projectName)}`;
7615
7866
  const headers = getAuthHeaders();
7616
- console.log(import_chalk18.default.gray(`API URL: ${apiUrl}`));
7867
+ console.log(import_chalk19.default.gray(`API URL: ${apiUrl}`));
7617
7868
  try {
7618
7869
  const FormData4 = (await import("formdata-node")).FormData;
7619
7870
  const Blob2 = (await import("formdata-node")).Blob;
@@ -7621,35 +7872,35 @@ async function saveWorker(workerJsPath, modulePaths, sqlFiles, metadata, project
7621
7872
  formData.append("metadata", new Blob2([JSON.stringify(metadata)], {
7622
7873
  type: "application/json"
7623
7874
  }), "metadata.json");
7624
- const workerCode = import_fs_extra7.default.readFileSync(workerJsPath, "utf-8");
7875
+ const workerCode = import_fs_extra8.default.readFileSync(workerJsPath, "utf-8");
7625
7876
  formData.append("worker.js", new Blob2([workerCode], {
7626
7877
  type: "application/javascript+module"
7627
7878
  }), "worker.js");
7628
7879
  for (const modulePath of modulePaths) {
7629
- const filename = import_path12.default.basename(modulePath);
7630
- const content = import_fs_extra7.default.readFileSync(modulePath, "utf-8");
7880
+ const filename = import_path13.default.basename(modulePath);
7881
+ const content = import_fs_extra8.default.readFileSync(modulePath, "utf-8");
7631
7882
  formData.append(filename, new Blob2([content], {
7632
7883
  type: "application/javascript+module"
7633
7884
  }), filename);
7634
7885
  }
7635
7886
  for (const sqlFile of sqlFiles) {
7636
- const filename = import_path12.default.basename(sqlFile);
7637
- const content = import_fs_extra7.default.readFileSync(sqlFile, "utf-8");
7887
+ const filename = import_path13.default.basename(sqlFile);
7888
+ const content = import_fs_extra8.default.readFileSync(sqlFile, "utf-8");
7638
7889
  formData.append("sql_file", new Blob2([content], {
7639
7890
  type: "application/sql"
7640
7891
  }), filename);
7641
- console.log(import_chalk18.default.gray(` Including SQL: ${filename}`));
7892
+ console.log(import_chalk19.default.gray(` Including SQL: ${filename}`));
7642
7893
  }
7643
7894
  const response = await axios_default.put(apiUrl, formData, {
7644
7895
  headers: { ...headers },
7645
7896
  timeout: 12e4
7646
7897
  });
7647
- console.log(import_chalk18.default.gray(` Response: ${JSON.stringify(response.data)}`));
7898
+ console.log(import_chalk19.default.gray(` Response: ${JSON.stringify(response.data)}`));
7648
7899
  if (response.data) {
7649
- console.log(import_chalk18.default.green("Worker saved"));
7900
+ console.log(import_chalk19.default.green("Worker saved"));
7650
7901
  if ((_b = (_a = response.data) == null ? void 0 : _a.data) == null ? void 0 : _b.sql_results) {
7651
7902
  for (const result of response.data.data.sql_results) {
7652
- console.log(import_chalk18.default.gray(` SQL ${result.filename}: ${result.status}`));
7903
+ console.log(import_chalk19.default.gray(` SQL ${result.filename}: ${result.status}`));
7653
7904
  }
7654
7905
  }
7655
7906
  } else {
@@ -7670,13 +7921,13 @@ async function saveWorker(workerJsPath, modulePaths, sqlFiles, metadata, project
7670
7921
  }
7671
7922
  }
7672
7923
  function buildFrontend() {
7673
- console.log(import_chalk18.default.blue("Building frontend..."));
7924
+ console.log(import_chalk19.default.blue("Building frontend..."));
7674
7925
  try {
7675
- (0, import_child_process3.execSync)("npm run build:frontend", {
7926
+ (0, import_child_process4.execSync)("npm run build:frontend", {
7676
7927
  cwd: PROJECT_DIR2,
7677
7928
  stdio: "inherit"
7678
7929
  });
7679
- console.log(import_chalk18.default.green("Frontend built"));
7930
+ console.log(import_chalk19.default.green("Frontend built"));
7680
7931
  } catch (error) {
7681
7932
  throw createCommandError("frontend build", "npm run build:frontend", error, [
7682
7933
  "Fix the frontend build error shown above, then rerun `pinme save`."
@@ -7684,17 +7935,40 @@ function buildFrontend() {
7684
7935
  }
7685
7936
  }
7686
7937
  function deployFrontend(projectName) {
7687
- console.log(import_chalk18.default.blue("Deploying frontend to IPFS..."));
7938
+ console.log(import_chalk19.default.blue("Deploying frontend to IPFS..."));
7688
7939
  try {
7689
- (0, import_child_process3.execSync)("pinme upload ./frontend/dist", {
7940
+ const uploadOutput = (0, import_child_process4.execSync)("pinme upload ./frontend/dist", {
7690
7941
  cwd: PROJECT_DIR2,
7691
- stdio: "inherit",
7942
+ encoding: "utf-8",
7692
7943
  env: {
7693
7944
  ...process.env,
7694
7945
  PINME_PROJECT_NAME: projectName
7695
7946
  }
7696
7947
  });
7697
- console.log(import_chalk18.default.green("Frontend deployed to IPFS"));
7948
+ console.log(uploadOutput);
7949
+ const urlMatch = uploadOutput.match(/https:\/\/[\w-]+\.pinme\.dev/);
7950
+ if (urlMatch) {
7951
+ const frontendUrl = urlMatch[0];
7952
+ console.log(import_chalk19.default.green(`Frontend deployed to IPFS: ${frontendUrl}`));
7953
+ const configPath = import_path13.default.join(PROJECT_DIR2, "pinme.toml");
7954
+ let config = import_fs_extra8.default.readFileSync(configPath, "utf-8");
7955
+ if (config.includes("frontend_url")) {
7956
+ config = config.replace(
7957
+ /frontend_url\s*=\s*"[^"]*"/,
7958
+ `frontend_url = "${frontendUrl}"`
7959
+ );
7960
+ } else {
7961
+ config = config.replace(
7962
+ /(project_name\s*=\s*"[^"]*"\n)/,
7963
+ `$1frontend_url = "${frontendUrl}"
7964
+ `
7965
+ );
7966
+ }
7967
+ import_fs_extra8.default.writeFileSync(configPath, config);
7968
+ console.log(import_chalk19.default.green("Updated pinme.toml with frontend URL"));
7969
+ } else {
7970
+ console.log(import_chalk19.default.green("Frontend deployed to IPFS"));
7971
+ }
7698
7972
  } catch (error) {
7699
7973
  throw createCommandError("frontend deploy", "pinme upload ./frontend/dist", error, [
7700
7974
  "Make sure `frontend/dist` exists and `pinme upload` works in this environment."
@@ -7709,14 +7983,14 @@ async function saveCmd(options) {
7709
7983
  "Run `pinme login` and retry."
7710
7984
  ]);
7711
7985
  }
7712
- const projectDir = options.projectName || options.name ? import_path12.default.join(PROJECT_DIR2, options.projectName || options.name) : PROJECT_DIR2;
7713
- const tokenFileSrc = import_path12.default.join(PROJECT_DIR2, ".token.json");
7714
- const tokenFileDst = import_path12.default.join(projectDir, ".token.json");
7715
- if (import_fs_extra7.default.existsSync(tokenFileSrc) && !import_fs_extra7.default.existsSync(tokenFileDst)) {
7716
- import_fs_extra7.default.copySync(tokenFileSrc, tokenFileDst);
7986
+ const projectDir = options.projectName || options.name ? import_path13.default.join(PROJECT_DIR2, options.projectName || options.name) : PROJECT_DIR2;
7987
+ const tokenFileSrc = import_path13.default.join(PROJECT_DIR2, ".token.json");
7988
+ const tokenFileDst = import_path13.default.join(projectDir, ".token.json");
7989
+ if (import_fs_extra8.default.existsSync(tokenFileSrc) && !import_fs_extra8.default.existsSync(tokenFileDst)) {
7990
+ import_fs_extra8.default.copySync(tokenFileSrc, tokenFileDst);
7717
7991
  }
7718
- console.log(import_chalk18.default.blue("Deploying to platform...\n"));
7719
- console.log(import_chalk18.default.gray(`Project dir: ${PROJECT_DIR2}`));
7992
+ console.log(import_chalk19.default.blue("Deploying to platform...\n"));
7993
+ console.log(import_chalk19.default.gray(`Project dir: ${PROJECT_DIR2}`));
7720
7994
  const config = loadConfig();
7721
7995
  const projectName = config.project_name;
7722
7996
  if (!projectName) {
@@ -7724,23 +7998,23 @@ async function saveCmd(options) {
7724
7998
  'Set `project_name = "your-project-name"` in `pinme.toml`.'
7725
7999
  ]);
7726
8000
  }
7727
- console.log(import_chalk18.default.gray(`Project: ${projectName}`));
8001
+ console.log(import_chalk19.default.gray(`Project: ${projectName}`));
7728
8002
  const apiUrl = `${API_BASE2}/save_worker?project_name=${encodeURIComponent(projectName)}`;
7729
- console.log(import_chalk18.default.gray(`API URL: ${apiUrl}`));
7730
- console.log(import_chalk18.default.blue("\n--- Backend ---"));
8003
+ console.log(import_chalk19.default.gray(`API URL: ${apiUrl}`));
8004
+ console.log(import_chalk19.default.blue("\n--- Backend ---"));
7731
8005
  installDependencies();
7732
8006
  buildWorker();
7733
8007
  const metadata = getMetadata();
7734
8008
  const { workerJsPath, modulePaths } = getBuiltWorker();
7735
- console.log(import_chalk18.default.gray(`Worker JS: ${workerJsPath}`));
7736
- console.log(import_chalk18.default.gray(`Module paths: ${JSON.stringify(modulePaths)}`));
8009
+ console.log(import_chalk19.default.gray(`Worker JS: ${workerJsPath}`));
8010
+ console.log(import_chalk19.default.gray(`Module paths: ${JSON.stringify(modulePaths)}`));
7737
8011
  const sqlFiles = getSqlFiles();
7738
- console.log(import_chalk18.default.gray(`SQL files: ${JSON.stringify(sqlFiles)}`));
8012
+ console.log(import_chalk19.default.gray(`SQL files: ${JSON.stringify(sqlFiles)}`));
7739
8013
  await saveWorker(workerJsPath, modulePaths, sqlFiles, metadata, projectName);
7740
- console.log(import_chalk18.default.blue("\n--- Frontend ---"));
8014
+ console.log(import_chalk19.default.blue("\n--- Frontend ---"));
7741
8015
  buildFrontend();
7742
8016
  deployFrontend(projectName);
7743
- console.log(import_chalk18.default.green("\nDeployment complete."));
8017
+ console.log(import_chalk19.default.green("\nDeployment complete."));
7744
8018
  process.exit(0);
7745
8019
  } catch (error) {
7746
8020
  printCliError(error, "Save failed.");
@@ -7749,54 +8023,54 @@ async function saveCmd(options) {
7749
8023
  }
7750
8024
 
7751
8025
  // bin/updateDb.ts
7752
- var import_chalk19 = __toESM(require("chalk"));
7753
- var import_fs_extra8 = __toESM(require("fs-extra"));
7754
- var import_path13 = __toESM(require("path"));
8026
+ var import_chalk20 = __toESM(require("chalk"));
8027
+ var import_fs_extra9 = __toESM(require("fs-extra"));
8028
+ var import_path14 = __toESM(require("path"));
7755
8029
  var PROJECT_DIR3 = process.cwd();
7756
8030
  var API_BASE3 = "https://pinme.dev/api/v4";
7757
8031
  function loadConfig2() {
7758
- const configPath = import_path13.default.join(PROJECT_DIR3, "pinme.toml");
7759
- if (!import_fs_extra8.default.existsSync(configPath)) {
8032
+ const configPath = import_path14.default.join(PROJECT_DIR3, "pinme.toml");
8033
+ if (!import_fs_extra9.default.existsSync(configPath)) {
7760
8034
  throw createConfigError("`pinme.toml` not found in the current directory.", [
7761
8035
  "Run this command from the Pinme project root."
7762
8036
  ]);
7763
8037
  }
7764
- const configContent = import_fs_extra8.default.readFileSync(configPath, "utf-8");
8038
+ const configContent = import_fs_extra9.default.readFileSync(configPath, "utf-8");
7765
8039
  const projectNameMatch = configContent.match(/project_name\s*=\s*"([^"]+)"/);
7766
8040
  return {
7767
8041
  project_name: (projectNameMatch == null ? void 0 : projectNameMatch[1]) || ""
7768
8042
  };
7769
8043
  }
7770
8044
  function getSqlFiles2() {
7771
- const sqlDir = import_path13.default.join(PROJECT_DIR3, "db");
7772
- if (!import_fs_extra8.default.existsSync(sqlDir)) {
8045
+ const sqlDir = import_path14.default.join(PROJECT_DIR3, "db");
8046
+ if (!import_fs_extra9.default.existsSync(sqlDir)) {
7773
8047
  throw createConfigError("SQL directory not found: `db/`.", [
7774
8048
  "Create a `db/` directory and add at least one `.sql` migration file."
7775
8049
  ]);
7776
8050
  }
7777
- const files = import_fs_extra8.default.readdirSync(sqlDir).filter((f) => f.endsWith(".sql")).sort();
8051
+ const files = import_fs_extra9.default.readdirSync(sqlDir).filter((f) => f.endsWith(".sql")).sort();
7778
8052
  if (files.length === 0) {
7779
8053
  throw createConfigError("No `.sql` files were found in `db/`.", [
7780
8054
  "Add one or more migration files before running `pinme update-db`."
7781
8055
  ]);
7782
8056
  }
7783
- return files.map((f) => import_path13.default.join(sqlDir, f));
8057
+ return files.map((f) => import_path14.default.join(sqlDir, f));
7784
8058
  }
7785
8059
  async function updateDb(sqlFiles, projectName) {
7786
- console.log(import_chalk19.default.blue("Importing SQL files to database..."));
7787
- console.log(import_chalk19.default.gray(`Project: ${projectName}`));
7788
- console.log(import_chalk19.default.gray(`SQL files: ${sqlFiles.length}`));
8060
+ console.log(import_chalk20.default.blue("Importing SQL files to database..."));
8061
+ console.log(import_chalk20.default.gray(`Project: ${projectName}`));
8062
+ console.log(import_chalk20.default.gray(`SQL files: ${sqlFiles.length}`));
7789
8063
  const apiUrl = `${API_BASE3}/update_db?project_name=${encodeURIComponent(projectName)}`;
7790
8064
  const headers = getAuthHeaders();
7791
- console.log(import_chalk19.default.gray(`API URL: ${apiUrl}`));
8065
+ console.log(import_chalk20.default.gray(`API URL: ${apiUrl}`));
7792
8066
  try {
7793
8067
  const FormData4 = (await import("formdata-node")).FormData;
7794
8068
  const Blob2 = (await import("formdata-node")).Blob;
7795
8069
  const formData = new FormData4();
7796
8070
  let totalSize = 0;
7797
8071
  for (const sqlFile of sqlFiles) {
7798
- const filename = import_path13.default.basename(sqlFile);
7799
- const content = import_fs_extra8.default.readFileSync(sqlFile);
8072
+ const filename = import_path14.default.basename(sqlFile);
8073
+ const content = import_fs_extra9.default.readFileSync(sqlFile);
7800
8074
  totalSize += content.length;
7801
8075
  if (totalSize > 10 * 1024 * 1024) {
7802
8076
  throw createConfigError("Total SQL payload exceeds the 10MB platform limit.", [
@@ -7806,24 +8080,24 @@ async function updateDb(sqlFiles, projectName) {
7806
8080
  formData.append("file", new Blob2([content], {
7807
8081
  type: "application/sql"
7808
8082
  }), filename);
7809
- console.log(import_chalk19.default.gray(` Including: ${filename} (${content.length} bytes)`));
8083
+ console.log(import_chalk20.default.gray(` Including: ${filename} (${content.length} bytes)`));
7810
8084
  }
7811
8085
  const response = await axios_default.post(apiUrl, formData, {
7812
8086
  headers: { ...headers },
7813
8087
  timeout: 12e4
7814
8088
  });
7815
- console.log(import_chalk19.default.gray(` Response: ${JSON.stringify(response.data)}`));
8089
+ console.log(import_chalk20.default.gray(` Response: ${JSON.stringify(response.data)}`));
7816
8090
  if (response.data.code === 200) {
7817
- console.log(import_chalk19.default.green("SQL files imported successfully!"));
8091
+ console.log(import_chalk20.default.green("SQL files imported successfully!"));
7818
8092
  const results = response.data.data.results;
7819
8093
  for (const result of results) {
7820
8094
  if (result.status === "complete") {
7821
- console.log(import_chalk19.default.green(` COMPLETE ${result.filename}: ${result.num_queries} queries, ${result.duration}ms`));
8095
+ console.log(import_chalk20.default.green(` COMPLETE ${result.filename}: ${result.num_queries} queries, ${result.duration}ms`));
7822
8096
  if (result.changes !== void 0) {
7823
- console.log(import_chalk19.default.gray(` Changes: ${result.changes}, Read: ${result.rows_read}, Written: ${result.rows_written}`));
8097
+ console.log(import_chalk20.default.gray(` Changes: ${result.changes}, Read: ${result.rows_read}, Written: ${result.rows_written}`));
7824
8098
  }
7825
8099
  } else if (result.status === "error") {
7826
- console.log(import_chalk19.default.red(` ERROR ${result.filename}: ${result.error}`));
8100
+ console.log(import_chalk20.default.red(` ERROR ${result.filename}: ${result.error}`));
7827
8101
  }
7828
8102
  }
7829
8103
  } else {
@@ -7851,14 +8125,14 @@ async function updateDbCmd(options) {
7851
8125
  "Run `pinme login` and retry."
7852
8126
  ]);
7853
8127
  }
7854
- const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path13.default.join(PROJECT_DIR3, options.projectName || options.name) : PROJECT_DIR3;
7855
- const tokenFileSrc = import_path13.default.join(PROJECT_DIR3, ".token.json");
7856
- const tokenFileDst = import_path13.default.join(projectDir, ".token.json");
7857
- if (import_fs_extra8.default.existsSync(tokenFileSrc) && !import_fs_extra8.default.existsSync(tokenFileDst)) {
7858
- import_fs_extra8.default.copySync(tokenFileSrc, tokenFileDst);
8128
+ const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path14.default.join(PROJECT_DIR3, options.projectName || options.name) : PROJECT_DIR3;
8129
+ const tokenFileSrc = import_path14.default.join(PROJECT_DIR3, ".token.json");
8130
+ const tokenFileDst = import_path14.default.join(projectDir, ".token.json");
8131
+ if (import_fs_extra9.default.existsSync(tokenFileSrc) && !import_fs_extra9.default.existsSync(tokenFileDst)) {
8132
+ import_fs_extra9.default.copySync(tokenFileSrc, tokenFileDst);
7859
8133
  }
7860
- console.log(import_chalk19.default.blue("Importing SQL to database...\n"));
7861
- console.log(import_chalk19.default.gray(`Project dir: ${PROJECT_DIR3}`));
8134
+ console.log(import_chalk20.default.blue("Importing SQL to database...\n"));
8135
+ console.log(import_chalk20.default.gray(`Project dir: ${PROJECT_DIR3}`));
7862
8136
  const config = loadConfig2();
7863
8137
  const projectName = config.project_name;
7864
8138
  if (!projectName) {
@@ -7866,11 +8140,11 @@ async function updateDbCmd(options) {
7866
8140
  'Set `project_name = "your-project-name"` in `pinme.toml`.'
7867
8141
  ]);
7868
8142
  }
7869
- console.log(import_chalk19.default.gray(`Project: ${projectName}`));
8143
+ console.log(import_chalk20.default.gray(`Project: ${projectName}`));
7870
8144
  const sqlFiles = getSqlFiles2();
7871
- console.log(import_chalk19.default.gray(`Found ${sqlFiles.length} SQL file(s) in db`));
8145
+ console.log(import_chalk20.default.gray(`Found ${sqlFiles.length} SQL file(s) in db`));
7872
8146
  await updateDb(sqlFiles, projectName);
7873
- console.log(import_chalk19.default.green("\nDatabase update complete."));
8147
+ console.log(import_chalk20.default.green("\nDatabase update complete."));
7874
8148
  process.exit(0);
7875
8149
  } catch (error) {
7876
8150
  printCliError(error, "Database update failed.");
@@ -7879,42 +8153,42 @@ async function updateDbCmd(options) {
7879
8153
  }
7880
8154
 
7881
8155
  // bin/updateWorker.ts
7882
- var import_chalk20 = __toESM(require("chalk"));
7883
- var import_fs_extra9 = __toESM(require("fs-extra"));
7884
- var import_path14 = __toESM(require("path"));
7885
- var import_child_process4 = require("child_process");
8156
+ var import_chalk21 = __toESM(require("chalk"));
8157
+ var import_fs_extra10 = __toESM(require("fs-extra"));
8158
+ var import_path15 = __toESM(require("path"));
8159
+ var import_child_process5 = require("child_process");
7886
8160
  var PROJECT_DIR4 = process.cwd();
7887
8161
  var API_BASE4 = "https://pinme.dev/api/v4";
7888
8162
  function loadConfig3() {
7889
- const configPath = import_path14.default.join(PROJECT_DIR4, "pinme.toml");
7890
- if (!import_fs_extra9.default.existsSync(configPath)) {
8163
+ const configPath = import_path15.default.join(PROJECT_DIR4, "pinme.toml");
8164
+ if (!import_fs_extra10.default.existsSync(configPath)) {
7891
8165
  throw createConfigError("`pinme.toml` not found in the current directory.", [
7892
8166
  "Run this command from the Pinme project root."
7893
8167
  ]);
7894
8168
  }
7895
- const configContent = import_fs_extra9.default.readFileSync(configPath, "utf-8");
8169
+ const configContent = import_fs_extra10.default.readFileSync(configPath, "utf-8");
7896
8170
  const projectNameMatch = configContent.match(/project_name\s*=\s*"([^"]+)"/);
7897
8171
  return {
7898
8172
  project_name: (projectNameMatch == null ? void 0 : projectNameMatch[1]) || ""
7899
8173
  };
7900
8174
  }
7901
8175
  function getMetadata2() {
7902
- const metadataPath = import_path14.default.join(PROJECT_DIR4, "backend", "metadata.json");
7903
- if (!import_fs_extra9.default.existsSync(metadataPath)) {
8176
+ const metadataPath = import_path15.default.join(PROJECT_DIR4, "backend", "metadata.json");
8177
+ if (!import_fs_extra10.default.existsSync(metadataPath)) {
7904
8178
  throw createConfigError("`backend/metadata.json` not found.", [
7905
8179
  "Create `backend/metadata.json` or restore it from the project template."
7906
8180
  ]);
7907
8181
  }
7908
- return import_fs_extra9.default.readJsonSync(metadataPath);
8182
+ return import_fs_extra10.default.readJsonSync(metadataPath);
7909
8183
  }
7910
8184
  function buildWorker2() {
7911
- console.log(import_chalk20.default.blue("Building worker..."));
8185
+ console.log(import_chalk21.default.blue("Building worker..."));
7912
8186
  try {
7913
- (0, import_child_process4.execSync)("npm run build:worker", {
8187
+ (0, import_child_process5.execSync)("npm run build:worker", {
7914
8188
  cwd: PROJECT_DIR4,
7915
8189
  stdio: "inherit"
7916
8190
  });
7917
- console.log(import_chalk20.default.green("Worker built"));
8191
+ console.log(import_chalk21.default.green("Worker built"));
7918
8192
  } catch (error) {
7919
8193
  throw createCommandError("worker build", "npm run build:worker", error, [
7920
8194
  "Fix the build error shown above, then rerun `pinme update-worker`."
@@ -7922,36 +8196,36 @@ function buildWorker2() {
7922
8196
  }
7923
8197
  }
7924
8198
  function getBuiltWorker2() {
7925
- const distWorkerDir = import_path14.default.join(PROJECT_DIR4, "dist-worker");
7926
- if (!import_fs_extra9.default.existsSync(distWorkerDir)) {
8199
+ const distWorkerDir = import_path15.default.join(PROJECT_DIR4, "dist-worker");
8200
+ if (!import_fs_extra10.default.existsSync(distWorkerDir)) {
7927
8201
  throw createConfigError("Built worker output not found: `dist-worker/`.", [
7928
8202
  "Make sure `npm run build:worker` completed successfully."
7929
8203
  ]);
7930
8204
  }
7931
- const workerJsPath = import_path14.default.join(distWorkerDir, "worker.js");
7932
- if (!import_fs_extra9.default.existsSync(workerJsPath)) {
8205
+ const workerJsPath = import_path15.default.join(distWorkerDir, "worker.js");
8206
+ if (!import_fs_extra10.default.existsSync(workerJsPath)) {
7933
8207
  throw createConfigError("Built worker entry file not found: `dist-worker/worker.js`.", [
7934
8208
  "Check the worker build output and bundler config."
7935
8209
  ]);
7936
8210
  }
7937
8211
  const modulePaths = [];
7938
- const files = import_fs_extra9.default.readdirSync(distWorkerDir);
8212
+ const files = import_fs_extra10.default.readdirSync(distWorkerDir);
7939
8213
  for (const file of files) {
7940
8214
  if (file.endsWith(".js") && file !== "worker.js") {
7941
- modulePaths.push(import_path14.default.join(distWorkerDir, file));
8215
+ modulePaths.push(import_path15.default.join(distWorkerDir, file));
7942
8216
  }
7943
8217
  }
7944
8218
  return { workerJsPath, modulePaths };
7945
8219
  }
7946
8220
  async function updateWorker(workerJsPath, modulePaths, metadata, projectName) {
7947
- console.log(import_chalk20.default.blue("Updating worker on platform..."));
7948
- console.log(import_chalk20.default.gray(`Project: ${projectName}`));
7949
- console.log(import_chalk20.default.gray(`workerJsPath: ${workerJsPath}`));
7950
- console.log(import_chalk20.default.gray(`modulePaths: ${modulePaths}`));
7951
- console.log(import_chalk20.default.gray(`metadata: ${metadata}`));
8221
+ console.log(import_chalk21.default.blue("Updating worker on platform..."));
8222
+ console.log(import_chalk21.default.gray(`Project: ${projectName}`));
8223
+ console.log(import_chalk21.default.gray(`workerJsPath: ${workerJsPath}`));
8224
+ console.log(import_chalk21.default.gray(`modulePaths: ${modulePaths}`));
8225
+ console.log(import_chalk21.default.gray(`metadata: ${metadata}`));
7952
8226
  const apiUrl = `${API_BASE4}/update_worker?project_name=${encodeURIComponent(projectName)}`;
7953
8227
  const headers = getAuthHeaders();
7954
- console.log(import_chalk20.default.gray(`API URL: ${apiUrl}`));
8228
+ console.log(import_chalk21.default.gray(`API URL: ${apiUrl}`));
7955
8229
  try {
7956
8230
  const FormData4 = (await import("formdata-node")).FormData;
7957
8231
  const Blob2 = (await import("formdata-node")).Blob;
@@ -7959,13 +8233,13 @@ async function updateWorker(workerJsPath, modulePaths, metadata, projectName) {
7959
8233
  formData.append("metadata", new Blob2([JSON.stringify(metadata)], {
7960
8234
  type: "application/json"
7961
8235
  }), "metadata.json");
7962
- const workerCode = import_fs_extra9.default.readFileSync(workerJsPath, "utf-8");
8236
+ const workerCode = import_fs_extra10.default.readFileSync(workerJsPath, "utf-8");
7963
8237
  formData.append("worker.js", new Blob2([workerCode], {
7964
8238
  type: "application/javascript+module"
7965
8239
  }), "worker.js");
7966
8240
  for (const modulePath of modulePaths) {
7967
- const filename = import_path14.default.basename(modulePath);
7968
- const content = import_fs_extra9.default.readFileSync(modulePath, "utf-8");
8241
+ const filename = import_path15.default.basename(modulePath);
8242
+ const content = import_fs_extra10.default.readFileSync(modulePath, "utf-8");
7969
8243
  formData.append(filename, new Blob2([content], {
7970
8244
  type: "application/javascript+module"
7971
8245
  }), filename);
@@ -7974,33 +8248,33 @@ async function updateWorker(workerJsPath, modulePaths, metadata, projectName) {
7974
8248
  headers: { ...headers },
7975
8249
  timeout: 12e4
7976
8250
  });
7977
- console.log(import_chalk20.default.gray(` Response: ${JSON.stringify(response.data)}`));
8251
+ console.log(import_chalk21.default.gray(` Response: ${JSON.stringify(response.data)}`));
7978
8252
  if (response.data) {
7979
- console.log(import_chalk20.default.green("Worker updated"));
8253
+ console.log(import_chalk21.default.green("Worker updated"));
7980
8254
  const data = response.data.data;
7981
8255
  if (data.worker_id) {
7982
- console.log(import_chalk20.default.gray(` Worker ID: ${data.worker_id}`));
8256
+ console.log(import_chalk21.default.gray(` Worker ID: ${data.worker_id}`));
7983
8257
  }
7984
8258
  if (data.deployment_id) {
7985
- console.log(import_chalk20.default.gray(` Deployment ID: ${data.deployment_id}`));
8259
+ console.log(import_chalk21.default.gray(` Deployment ID: ${data.deployment_id}`));
7986
8260
  }
7987
8261
  if (data.entry_point) {
7988
- console.log(import_chalk20.default.gray(` Entry Point: ${data.entry_point}`));
8262
+ console.log(import_chalk21.default.gray(` Entry Point: ${data.entry_point}`));
7989
8263
  }
7990
8264
  if (data.created_on) {
7991
- console.log(import_chalk20.default.gray(` Created: ${data.created_on}`));
8265
+ console.log(import_chalk21.default.gray(` Created: ${data.created_on}`));
7992
8266
  }
7993
8267
  if (data.modified_on) {
7994
- console.log(import_chalk20.default.gray(` Modified: ${data.modified_on}`));
8268
+ console.log(import_chalk21.default.gray(` Modified: ${data.modified_on}`));
7995
8269
  }
7996
8270
  if (data.startup_time_ms !== void 0) {
7997
- console.log(import_chalk20.default.gray(` Startup Time: ${data.startup_time_ms}ms`));
8271
+ console.log(import_chalk21.default.gray(` Startup Time: ${data.startup_time_ms}ms`));
7998
8272
  }
7999
8273
  if (data.has_modules !== void 0) {
8000
- console.log(import_chalk20.default.gray(` Has Modules: ${data.has_modules}`));
8274
+ console.log(import_chalk21.default.gray(` Has Modules: ${data.has_modules}`));
8001
8275
  }
8002
8276
  if (data.domain) {
8003
- console.log(import_chalk20.default.gray(` Domain: ${data.domain}`));
8277
+ console.log(import_chalk21.default.gray(` Domain: ${data.domain}`));
8004
8278
  }
8005
8279
  } else {
8006
8280
  throw createApiError("worker update", { response: { data: response.data } }, [
@@ -8027,14 +8301,14 @@ async function updateWorkerCmd(options) {
8027
8301
  "Run `pinme login` and retry."
8028
8302
  ]);
8029
8303
  }
8030
- const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path14.default.join(PROJECT_DIR4, options.projectName || options.name) : PROJECT_DIR4;
8031
- const tokenFileSrc = import_path14.default.join(PROJECT_DIR4, ".token.json");
8032
- const tokenFileDst = import_path14.default.join(projectDir, ".token.json");
8033
- if (import_fs_extra9.default.existsSync(tokenFileSrc) && !import_fs_extra9.default.existsSync(tokenFileDst)) {
8034
- import_fs_extra9.default.copySync(tokenFileSrc, tokenFileDst);
8304
+ const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path15.default.join(PROJECT_DIR4, options.projectName || options.name) : PROJECT_DIR4;
8305
+ const tokenFileSrc = import_path15.default.join(PROJECT_DIR4, ".token.json");
8306
+ const tokenFileDst = import_path15.default.join(projectDir, ".token.json");
8307
+ if (import_fs_extra10.default.existsSync(tokenFileSrc) && !import_fs_extra10.default.existsSync(tokenFileDst)) {
8308
+ import_fs_extra10.default.copySync(tokenFileSrc, tokenFileDst);
8035
8309
  }
8036
- console.log(import_chalk20.default.blue("Updating worker...\n"));
8037
- console.log(import_chalk20.default.gray(`Project dir: ${PROJECT_DIR4}`));
8310
+ console.log(import_chalk21.default.blue("Updating worker...\n"));
8311
+ console.log(import_chalk21.default.gray(`Project dir: ${PROJECT_DIR4}`));
8038
8312
  const config = loadConfig3();
8039
8313
  const projectName = config.project_name;
8040
8314
  if (!projectName) {
@@ -8042,16 +8316,16 @@ async function updateWorkerCmd(options) {
8042
8316
  'Set `project_name = "your-project-name"` in `pinme.toml`.'
8043
8317
  ]);
8044
8318
  }
8045
- console.log(import_chalk20.default.gray(`Project: ${projectName}`));
8046
- console.log(import_chalk20.default.blue("\n--- Worker Update ---"));
8319
+ console.log(import_chalk21.default.gray(`Project: ${projectName}`));
8320
+ console.log(import_chalk21.default.blue("\n--- Worker Update ---"));
8047
8321
  buildWorker2();
8048
8322
  const metadata = getMetadata2();
8049
8323
  const { workerJsPath, modulePaths } = getBuiltWorker2();
8050
- console.log(import_chalk20.default.gray(`Worker JS: ${workerJsPath}`));
8051
- console.log(import_chalk20.default.gray(`Module paths: ${JSON.stringify(modulePaths)}`));
8052
- console.log(import_chalk20.default.gray(`SQL files: ignored (not processed for update_worker)`));
8324
+ console.log(import_chalk21.default.gray(`Worker JS: ${workerJsPath}`));
8325
+ console.log(import_chalk21.default.gray(`Module paths: ${JSON.stringify(modulePaths)}`));
8326
+ console.log(import_chalk21.default.gray(`SQL files: ignored (not processed for update_worker)`));
8053
8327
  await updateWorker(workerJsPath, modulePaths, metadata, projectName);
8054
- console.log(import_chalk20.default.green("\nWorker update complete."));
8328
+ console.log(import_chalk21.default.green("\nWorker update complete."));
8055
8329
  process.exit(0);
8056
8330
  } catch (error) {
8057
8331
  printCliError(error, "Worker update failed.");
@@ -8060,32 +8334,32 @@ async function updateWorkerCmd(options) {
8060
8334
  }
8061
8335
 
8062
8336
  // bin/updateWeb.ts
8063
- var import_chalk21 = __toESM(require("chalk"));
8064
- var import_fs_extra10 = __toESM(require("fs-extra"));
8065
- var import_path15 = __toESM(require("path"));
8066
- var import_child_process5 = require("child_process");
8337
+ var import_chalk22 = __toESM(require("chalk"));
8338
+ var import_fs_extra11 = __toESM(require("fs-extra"));
8339
+ var import_path16 = __toESM(require("path"));
8340
+ var import_child_process6 = require("child_process");
8067
8341
  var PROJECT_DIR5 = process.cwd();
8068
8342
  function loadConfig4() {
8069
- const configPath = import_path15.default.join(PROJECT_DIR5, "pinme.toml");
8070
- if (!import_fs_extra10.default.existsSync(configPath)) {
8343
+ const configPath = import_path16.default.join(PROJECT_DIR5, "pinme.toml");
8344
+ if (!import_fs_extra11.default.existsSync(configPath)) {
8071
8345
  throw createConfigError("`pinme.toml` not found in the current directory.", [
8072
8346
  "Run this command from the Pinme project root."
8073
8347
  ]);
8074
8348
  }
8075
- const configContent = import_fs_extra10.default.readFileSync(configPath, "utf-8");
8349
+ const configContent = import_fs_extra11.default.readFileSync(configPath, "utf-8");
8076
8350
  const projectNameMatch = configContent.match(/project_name\s*=\s*"([^"]+)"/);
8077
8351
  return {
8078
8352
  project_name: (projectNameMatch == null ? void 0 : projectNameMatch[1]) || ""
8079
8353
  };
8080
8354
  }
8081
8355
  function buildFrontend2() {
8082
- console.log(import_chalk21.default.blue("Building frontend..."));
8356
+ console.log(import_chalk22.default.blue("Building frontend..."));
8083
8357
  try {
8084
- (0, import_child_process5.execSync)("npm run build:frontend", {
8358
+ (0, import_child_process6.execSync)("npm run build:frontend", {
8085
8359
  cwd: PROJECT_DIR5,
8086
8360
  stdio: "inherit"
8087
8361
  });
8088
- console.log(import_chalk21.default.green("Frontend built"));
8362
+ console.log(import_chalk22.default.green("Frontend built"));
8089
8363
  } catch (error) {
8090
8364
  throw createCommandError("frontend build", "npm run build:frontend", error, [
8091
8365
  "Fix the frontend build error shown above, then rerun `pinme update-web`."
@@ -8093,9 +8367,9 @@ function buildFrontend2() {
8093
8367
  }
8094
8368
  }
8095
8369
  function deployFrontend2(projectName) {
8096
- console.log(import_chalk21.default.blue("Deploying frontend to IPFS..."));
8370
+ console.log(import_chalk22.default.blue("Deploying frontend to IPFS..."));
8097
8371
  try {
8098
- (0, import_child_process5.execSync)("pinme upload ./frontend/dist", {
8372
+ (0, import_child_process6.execSync)("pinme upload ./frontend/dist", {
8099
8373
  cwd: PROJECT_DIR5,
8100
8374
  stdio: "inherit",
8101
8375
  env: {
@@ -8103,7 +8377,7 @@ function deployFrontend2(projectName) {
8103
8377
  PINME_PROJECT_NAME: projectName
8104
8378
  }
8105
8379
  });
8106
- console.log(import_chalk21.default.green("Frontend deployed to IPFS"));
8380
+ console.log(import_chalk22.default.green("Frontend deployed to IPFS"));
8107
8381
  } catch (error) {
8108
8382
  throw createCommandError("frontend deploy", "pinme upload ./frontend/dist", error, [
8109
8383
  "Make sure `frontend/dist` exists and `pinme upload` can run successfully."
@@ -8118,14 +8392,14 @@ async function updateWebCmd(options) {
8118
8392
  "Run `pinme login` and retry."
8119
8393
  ]);
8120
8394
  }
8121
- const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path15.default.join(PROJECT_DIR5, options.projectName || options.name) : PROJECT_DIR5;
8122
- const tokenFileSrc = import_path15.default.join(PROJECT_DIR5, ".token.json");
8123
- const tokenFileDst = import_path15.default.join(projectDir, ".token.json");
8124
- if (import_fs_extra10.default.existsSync(tokenFileSrc) && !import_fs_extra10.default.existsSync(tokenFileDst)) {
8125
- import_fs_extra10.default.copySync(tokenFileSrc, tokenFileDst);
8395
+ const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path16.default.join(PROJECT_DIR5, options.projectName || options.name) : PROJECT_DIR5;
8396
+ const tokenFileSrc = import_path16.default.join(PROJECT_DIR5, ".token.json");
8397
+ const tokenFileDst = import_path16.default.join(projectDir, ".token.json");
8398
+ if (import_fs_extra11.default.existsSync(tokenFileSrc) && !import_fs_extra11.default.existsSync(tokenFileDst)) {
8399
+ import_fs_extra11.default.copySync(tokenFileSrc, tokenFileDst);
8126
8400
  }
8127
- console.log(import_chalk21.default.blue("Updating web (frontend)...\n"));
8128
- console.log(import_chalk21.default.gray(`Project dir: ${PROJECT_DIR5}`));
8401
+ console.log(import_chalk22.default.blue("Updating web (frontend)...\n"));
8402
+ console.log(import_chalk22.default.gray(`Project dir: ${PROJECT_DIR5}`));
8129
8403
  const config = loadConfig4();
8130
8404
  const projectName = config.project_name;
8131
8405
  if (!projectName) {
@@ -8133,11 +8407,11 @@ async function updateWebCmd(options) {
8133
8407
  'Set `project_name = "your-project-name"` in `pinme.toml`.'
8134
8408
  ]);
8135
8409
  }
8136
- console.log(import_chalk21.default.gray(`Project: ${projectName}`));
8137
- console.log(import_chalk21.default.blue("\n--- Frontend Update ---"));
8410
+ console.log(import_chalk22.default.gray(`Project: ${projectName}`));
8411
+ console.log(import_chalk22.default.blue("\n--- Frontend Update ---"));
8138
8412
  buildFrontend2();
8139
8413
  deployFrontend2(projectName);
8140
- console.log(import_chalk21.default.green("\nWeb update complete."));
8414
+ console.log(import_chalk22.default.green("\nWeb update complete."));
8141
8415
  process.exit(0);
8142
8416
  } catch (error) {
8143
8417
  printCliError(error, "Web update failed.");
@@ -8146,17 +8420,17 @@ async function updateWebCmd(options) {
8146
8420
  }
8147
8421
 
8148
8422
  // bin/delete.ts
8149
- var import_chalk22 = __toESM(require("chalk"));
8423
+ var import_chalk23 = __toESM(require("chalk"));
8150
8424
  var import_inquirer9 = __toESM(require("inquirer"));
8151
- var import_fs_extra11 = __toESM(require("fs-extra"));
8152
- var import_path16 = __toESM(require("path"));
8425
+ var import_fs_extra12 = __toESM(require("fs-extra"));
8426
+ var import_path17 = __toESM(require("path"));
8153
8427
  var API_BASE5 = "https://pinme.dev/api/v4";
8154
8428
  function getProjectName() {
8155
- const configPath = import_path16.default.join(process.cwd(), "pinme.toml");
8156
- if (!import_fs_extra11.default.existsSync(configPath)) {
8429
+ const configPath = import_path17.default.join(process.cwd(), "pinme.toml");
8430
+ if (!import_fs_extra12.default.existsSync(configPath)) {
8157
8431
  return null;
8158
8432
  }
8159
- const config = import_fs_extra11.default.readFileSync(configPath, "utf-8");
8433
+ const config = import_fs_extra12.default.readFileSync(configPath, "utf-8");
8160
8434
  const match = config.match(/project_name\s*=\s*"([^"]+)"/);
8161
8435
  return (match == null ? void 0 : match[1]) || null;
8162
8436
  }
@@ -8165,23 +8439,23 @@ async function deleteCmd(options) {
8165
8439
  try {
8166
8440
  const headers = getAuthHeaders();
8167
8441
  if (!headers["authentication-tokens"] || !headers["token-address"]) {
8168
- console.log(import_chalk22.default.yellow("\n\u26A0\uFE0F You are not logged in."));
8169
- console.log(import_chalk22.default.gray("Please run: pinme login"));
8442
+ console.log(import_chalk23.default.yellow("\n\u26A0\uFE0F You are not logged in."));
8443
+ console.log(import_chalk23.default.gray("Please run: pinme login"));
8170
8444
  process.exit(1);
8171
8445
  }
8172
- console.log(import_chalk22.default.blue("Deleting project...\n"));
8446
+ console.log(import_chalk23.default.blue("Deleting project...\n"));
8173
8447
  let projectName = options.name || getProjectName();
8174
8448
  if (!projectName) {
8175
- console.log(import_chalk22.default.red("\n\u274C Error: Cannot find project name."));
8176
- console.log(import_chalk22.default.yellow(" Please make sure you are in the project directory."));
8177
- console.log(import_chalk22.default.gray(" The project directory should contain a pinme.toml file."));
8178
- console.log(import_chalk22.default.gray("\n Or specify the project name:"));
8179
- console.log(import_chalk22.default.gray(" cd /path/to/your-project"));
8180
- console.log(import_chalk22.default.gray(" pinme delete"));
8449
+ console.log(import_chalk23.default.red("\n\u274C Error: Cannot find project name."));
8450
+ console.log(import_chalk23.default.yellow(" Please make sure you are in the project directory."));
8451
+ console.log(import_chalk23.default.gray(" The project directory should contain a pinme.toml file."));
8452
+ console.log(import_chalk23.default.gray("\n Or specify the project name:"));
8453
+ console.log(import_chalk23.default.gray(" cd /path/to/your-project"));
8454
+ console.log(import_chalk23.default.gray(" pinme delete"));
8181
8455
  process.exit(1);
8182
8456
  }
8183
- console.log(import_chalk22.default.gray(`Project: ${projectName}`));
8184
- console.log(import_chalk22.default.gray(`Directory: ${process.cwd()}`));
8457
+ console.log(import_chalk23.default.gray(`Project: ${projectName}`));
8458
+ console.log(import_chalk23.default.gray(`Directory: ${process.cwd()}`));
8185
8459
  if (!options.force) {
8186
8460
  const answers = await import_inquirer9.default.prompt([
8187
8461
  {
@@ -8192,14 +8466,14 @@ async function deleteCmd(options) {
8192
8466
  }
8193
8467
  ]);
8194
8468
  if (!answers.confirm) {
8195
- console.log(import_chalk22.default.gray("Cancelled."));
8469
+ console.log(import_chalk23.default.gray("Cancelled."));
8196
8470
  process.exit(0);
8197
8471
  }
8198
8472
  }
8199
- console.log(import_chalk22.default.blue("Deleting project on platform..."));
8473
+ console.log(import_chalk23.default.blue("Deleting project on platform..."));
8200
8474
  const apiUrl = `${API_BASE5}/delete_project`;
8201
- console.log(import_chalk22.default.gray(`API URL: ${apiUrl}`));
8202
- console.log(import_chalk22.default.gray(`Project name: ${projectName}`));
8475
+ console.log(import_chalk23.default.gray(`API URL: ${apiUrl}`));
8476
+ console.log(import_chalk23.default.gray(`Project name: ${projectName}`));
8203
8477
  const response = await axios_default.post(apiUrl, {
8204
8478
  project_name: projectName
8205
8479
  }, {
@@ -8210,31 +8484,31 @@ async function deleteCmd(options) {
8210
8484
  }).catch((error) => {
8211
8485
  var _a2, _b2;
8212
8486
  if (error.response) {
8213
- console.log(import_chalk22.default.red(` Response status: ${(_a2 = error.response) == null ? void 0 : _a2.status}`));
8214
- console.log(import_chalk22.default.red(` Response data: ${JSON.stringify((_b2 = error.response) == null ? void 0 : _b2.data)}`));
8487
+ console.log(import_chalk23.default.red(` Response status: ${(_a2 = error.response) == null ? void 0 : _a2.status}`));
8488
+ console.log(import_chalk23.default.red(` Response data: ${JSON.stringify((_b2 = error.response) == null ? void 0 : _b2.data)}`));
8215
8489
  } else {
8216
- console.log(import_chalk22.default.red("No Response"));
8490
+ console.log(import_chalk23.default.red("No Response"));
8217
8491
  }
8218
8492
  throw error;
8219
8493
  });
8220
8494
  const data = response.data;
8221
8495
  if (data.code === 200) {
8222
- console.log(import_chalk22.default.green("\n\u2705 Project deleted successfully!"));
8223
- console.log(import_chalk22.default.gray(`
8496
+ console.log(import_chalk23.default.green("\n\u2705 Project deleted successfully!"));
8497
+ console.log(import_chalk23.default.gray(`
8224
8498
  Project: ${data.data.project_name}`));
8225
- console.log(import_chalk22.default.gray(` Domain deleted: ${data.data.domain_deleted ? "\u2705" : "\u274C"}`));
8226
- console.log(import_chalk22.default.gray(` Worker deleted: ${data.data.worker_deleted ? "\u2705" : "\u274C"}`));
8227
- console.log(import_chalk22.default.gray(` Database deleted: ${data.data.database_deleted ? "\u2705" : "\u274C"}`));
8228
- console.log(import_chalk22.default.gray("\nLocal files are kept unchanged."));
8499
+ console.log(import_chalk23.default.gray(` Domain deleted: ${data.data.domain_deleted ? "\u2705" : "\u274C"}`));
8500
+ console.log(import_chalk23.default.gray(` Worker deleted: ${data.data.worker_deleted ? "\u2705" : "\u274C"}`));
8501
+ console.log(import_chalk23.default.gray(` Database deleted: ${data.data.database_deleted ? "\u2705" : "\u274C"}`));
8502
+ console.log(import_chalk23.default.gray("\nLocal files are kept unchanged."));
8229
8503
  } else {
8230
8504
  const errorMsg = (data == null ? void 0 : data.msg) || "Failed to delete project";
8231
8505
  throw new Error(errorMsg);
8232
8506
  }
8233
8507
  process.exit(0);
8234
8508
  } catch (error) {
8235
- console.log(import_chalk22.default.red(error));
8509
+ console.log(import_chalk23.default.red(error));
8236
8510
  const errorMsg = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.msg) || error.message || "Failed to delete project";
8237
- console.error(import_chalk22.default.red(`
8511
+ console.error(import_chalk23.default.red(`
8238
8512
  \u274C Error: ${errorMsg}`));
8239
8513
  process.exit(1);
8240
8514
  }
@@ -8245,9 +8519,9 @@ import_dotenv.default.config();
8245
8519
  checkNodeVersion();
8246
8520
  function showBanner() {
8247
8521
  console.log(
8248
- import_chalk23.default.cyan(import_figlet5.default.textSync("Pinme", { horizontalLayout: "full" }))
8522
+ import_chalk24.default.cyan(import_figlet5.default.textSync("Pinme", { horizontalLayout: "full" }))
8249
8523
  );
8250
- console.log(import_chalk23.default.cyan("A command-line tool for uploading files to IPFS\n"));
8524
+ console.log(import_chalk24.default.cyan("A command-line tool for uploading files to IPFS\n"));
8251
8525
  }
8252
8526
  var program = new import_commander.Command();
8253
8527
  program.name("pinme").version(version).option("-v, --version", "output the current version");