pinme 1.1.4-alpha.1 → 1.1.4-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +113 -72
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1480,16 +1480,54 @@ var require_follow_redirects = __commonJS({
1480
1480
 
1481
1481
  // bin/index.ts
1482
1482
  var import_dotenv = __toESM(require_main());
1483
+
1484
+ // bin/utils/checkNodeVersion.ts
1485
+ var import_chalk = __toESM(require("chalk"));
1486
+ var MIN_NODE_VERSION = "16.13.0";
1487
+ function parseVersion(version2) {
1488
+ const parts = version2.replace(/^v/, "").split(".").map(Number);
1489
+ return {
1490
+ major: parts[0] || 0,
1491
+ minor: parts[1] || 0,
1492
+ patch: parts[2] || 0
1493
+ };
1494
+ }
1495
+ function compareVersions(version1, version2) {
1496
+ if (version1.major !== version2.major) {
1497
+ return version1.major - version2.major;
1498
+ }
1499
+ if (version1.minor !== version2.minor) {
1500
+ return version1.minor - version2.minor;
1501
+ }
1502
+ return version1.patch - version2.patch;
1503
+ }
1504
+ function checkNodeVersion() {
1505
+ const currentVersion = process.version;
1506
+ const current = parseVersion(currentVersion);
1507
+ const minimum = parseVersion(MIN_NODE_VERSION);
1508
+ if (compareVersions(current, minimum) < 0) {
1509
+ console.error(import_chalk.default.red("\u274C Node.js version requirement not met"));
1510
+ console.error(import_chalk.default.yellow(`Current version: ${currentVersion}`));
1511
+ console.error(import_chalk.default.yellow(`Required version: >= ${MIN_NODE_VERSION}`));
1512
+ console.error("");
1513
+ console.error(import_chalk.default.cyan("Please upgrade Node.js to version 16.13.0 or higher."));
1514
+ console.error(import_chalk.default.cyan("Download from: https://nodejs.org/"));
1515
+ console.error("");
1516
+ process.exit(1);
1517
+ }
1518
+ }
1519
+
1520
+ // bin/index.ts
1483
1521
  var import_commander = require("commander");
1484
- var import_chalk5 = __toESM(require("chalk"));
1522
+ var import_chalk6 = __toESM(require("chalk"));
1485
1523
  var import_figlet3 = __toESM(require("figlet"));
1486
1524
 
1487
1525
  // package.json
1488
- var version = "1.1.4-alpha.1";
1526
+ var version = "1.1.4-alpha.3";
1489
1527
 
1490
1528
  // bin/upload.ts
1491
1529
  var import_path5 = __toESM(require("path"));
1492
- var import_chalk2 = __toESM(require("chalk"));
1530
+ var import_chalk3 = __toESM(require("chalk"));
1493
1531
  var import_inquirer = __toESM(require("inquirer"));
1494
1532
  var import_figlet = __toESM(require("figlet"));
1495
1533
 
@@ -4414,7 +4452,7 @@ var import_fs_extra = __toESM(require("fs-extra"));
4414
4452
  var import_path2 = __toESM(require("path"));
4415
4453
  var import_os = __toESM(require("os"));
4416
4454
  var import_dayjs = __toESM(require("dayjs"));
4417
- var import_chalk = __toESM(require("chalk"));
4455
+ var import_chalk2 = __toESM(require("chalk"));
4418
4456
  var HISTORY_DIR = import_path2.default.join(import_os.default.homedir(), ".pinme");
4419
4457
  var HISTORY_FILE = import_path2.default.join(HISTORY_DIR, "upload-history.json");
4420
4458
  var ensureHistoryDir = () => {
@@ -4445,7 +4483,7 @@ var saveUploadHistory = (uploadData) => {
4445
4483
  import_fs_extra.default.writeJsonSync(HISTORY_FILE, history, { spaces: 2 });
4446
4484
  return true;
4447
4485
  } catch (error) {
4448
- console.error(import_chalk.default.red(`Error saving upload history: ${error.message}`));
4486
+ console.error(import_chalk2.default.red(`Error saving upload history: ${error.message}`));
4449
4487
  return false;
4450
4488
  }
4451
4489
  };
@@ -4455,48 +4493,48 @@ var getUploadHistory = (limit = 10) => {
4455
4493
  const history = import_fs_extra.default.readJsonSync(HISTORY_FILE);
4456
4494
  return history.uploads.slice(0, limit);
4457
4495
  } catch (error) {
4458
- console.error(import_chalk.default.red(`Error reading upload history: ${error.message}`));
4496
+ console.error(import_chalk2.default.red(`Error reading upload history: ${error.message}`));
4459
4497
  return [];
4460
4498
  }
4461
4499
  };
4462
4500
  var displayUploadHistory = (limit = 10) => {
4463
4501
  const history = getUploadHistory(limit);
4464
4502
  if (history.length === 0) {
4465
- console.log(import_chalk.default.yellow("No upload history found."));
4503
+ console.log(import_chalk2.default.yellow("No upload history found."));
4466
4504
  return;
4467
4505
  }
4468
- console.log(import_chalk.default.cyan("Upload History:"));
4469
- console.log(import_chalk.default.cyan("-".repeat(80)));
4506
+ console.log(import_chalk2.default.cyan("Upload History:"));
4507
+ console.log(import_chalk2.default.cyan("-".repeat(80)));
4470
4508
  const recentHistory = history.slice(-limit);
4471
4509
  recentHistory.forEach((item, index) => {
4472
- console.log(import_chalk.default.green(`${index + 1}. ${item.filename}`));
4473
- console.log(import_chalk.default.white(` Path: ${item.path}`));
4474
- console.log(import_chalk.default.white(` IPFS CID: ${item.contentHash}`));
4510
+ console.log(import_chalk2.default.green(`${index + 1}. ${item.filename}`));
4511
+ console.log(import_chalk2.default.white(` Path: ${item.path}`));
4512
+ console.log(import_chalk2.default.white(` IPFS CID: ${item.contentHash}`));
4475
4513
  if (item.shortUrl) {
4476
- console.log(import_chalk.default.white(` ENS URL: https://${item.shortUrl}.pinit.eth.limo`));
4514
+ console.log(import_chalk2.default.white(` ENS URL: https://${item.shortUrl}.pinit.eth.limo`));
4477
4515
  }
4478
- console.log(import_chalk.default.white(` Size: ${formatSize(item.size)}`));
4479
- console.log(import_chalk.default.white(` Files: ${item.fileCount}`));
4480
- console.log(import_chalk.default.white(` Type: ${item.type === "directory" ? "Directory" : "File"}`));
4516
+ console.log(import_chalk2.default.white(` Size: ${formatSize(item.size)}`));
4517
+ console.log(import_chalk2.default.white(` Files: ${item.fileCount}`));
4518
+ console.log(import_chalk2.default.white(` Type: ${item.type === "directory" ? "Directory" : "File"}`));
4481
4519
  if (item.timestamp) {
4482
- console.log(import_chalk.default.white(` Date: ${new Date(item.timestamp).toLocaleString()}`));
4520
+ console.log(import_chalk2.default.white(` Date: ${new Date(item.timestamp).toLocaleString()}`));
4483
4521
  }
4484
- console.log(import_chalk.default.cyan("-".repeat(80)));
4522
+ console.log(import_chalk2.default.cyan("-".repeat(80)));
4485
4523
  });
4486
4524
  const totalSize = history.reduce((sum, record) => sum + record.size, 0);
4487
4525
  const totalFiles = history.reduce((sum, record) => sum + record.fileCount, 0);
4488
- console.log(import_chalk.default.bold(`Total Uploads: ${history.length}`));
4489
- console.log(import_chalk.default.bold(`Total Files: ${totalFiles}`));
4490
- console.log(import_chalk.default.bold(`Total Size: ${formatSize(totalSize)}`));
4526
+ console.log(import_chalk2.default.bold(`Total Uploads: ${history.length}`));
4527
+ console.log(import_chalk2.default.bold(`Total Files: ${totalFiles}`));
4528
+ console.log(import_chalk2.default.bold(`Total Size: ${formatSize(totalSize)}`));
4491
4529
  };
4492
4530
  var clearUploadHistory = () => {
4493
4531
  try {
4494
4532
  ensureHistoryDir();
4495
4533
  import_fs_extra.default.writeJsonSync(HISTORY_FILE, { uploads: [] });
4496
- console.log(import_chalk.default.green("Upload history cleared successfully."));
4534
+ console.log(import_chalk2.default.green("Upload history cleared successfully."));
4497
4535
  return true;
4498
4536
  } catch (error) {
4499
- console.error(import_chalk.default.red(`Error clearing upload history: ${error.message}`));
4537
+ console.error(import_chalk2.default.red(`Error clearing upload history: ${error.message}`));
4500
4538
  return false;
4501
4539
  }
4502
4540
  };
@@ -5024,6 +5062,7 @@ var import_fs2 = __toESM(require("fs"));
5024
5062
  var import_crypto_js = __toESM(require("crypto-js"));
5025
5063
  var URL2 = "https://pinme.eth.limo/#/preview/";
5026
5064
  var secretKey = "pinme-secret-key";
5065
+ checkNodeVersion();
5027
5066
  function encryptHash(hash, key) {
5028
5067
  try {
5029
5068
  if (!key) {
@@ -5045,7 +5084,7 @@ function checkPathSync(inputPath) {
5045
5084
  }
5046
5085
  return null;
5047
5086
  } catch (error) {
5048
- console.error(import_chalk2.default.red(`error checking path: ${error.message}`));
5087
+ console.error(import_chalk3.default.red(`error checking path: ${error.message}`));
5049
5088
  return null;
5050
5089
  }
5051
5090
  }
@@ -5064,25 +5103,25 @@ var upload_default = async (options) => {
5064
5103
  if (argPath && !argPath.startsWith("-")) {
5065
5104
  const absolutePath = checkPathSync(argPath);
5066
5105
  if (!absolutePath) {
5067
- console.log(import_chalk2.default.red(`path ${argPath} does not exist`));
5106
+ console.log(import_chalk3.default.red(`path ${argPath} does not exist`));
5068
5107
  return;
5069
5108
  }
5070
- console.log(import_chalk2.default.blue(`uploading ${absolutePath} to ipfs...`));
5109
+ console.log(import_chalk3.default.blue(`uploading ${absolutePath} to ipfs...`));
5071
5110
  try {
5072
5111
  const result = await uploadToIpfsSplit_default(absolutePath);
5073
5112
  if (result) {
5074
5113
  const encryptedCID = encryptHash(result.contentHash, secretKey);
5075
5114
  console.log(
5076
- import_chalk2.default.cyan(
5115
+ import_chalk3.default.cyan(
5077
5116
  import_figlet.default.textSync("Successful", { horizontalLayout: "full" })
5078
5117
  )
5079
5118
  );
5080
- console.log(import_chalk2.default.cyan(`URL:`));
5081
- console.log(import_chalk2.default.cyan(`${URL2}${encryptedCID}`));
5082
- console.log(import_chalk2.default.green("\n\u{1F389} upload successful, program exit"));
5119
+ console.log(import_chalk3.default.cyan(`URL:`));
5120
+ console.log(import_chalk3.default.cyan(`${URL2}${encryptedCID}`));
5121
+ console.log(import_chalk3.default.green("\n\u{1F389} upload successful, program exit"));
5083
5122
  }
5084
5123
  } catch (error) {
5085
- console.error(import_chalk2.default.red(`Error: ${error.message}`));
5124
+ console.error(import_chalk3.default.red(`Error: ${error.message}`));
5086
5125
  }
5087
5126
  process.exit(0);
5088
5127
  }
@@ -5096,46 +5135,46 @@ var upload_default = async (options) => {
5096
5135
  if (answer.path) {
5097
5136
  const absolutePath = checkPathSync(answer.path);
5098
5137
  if (!absolutePath) {
5099
- console.log(import_chalk2.default.red(`path ${answer.path} does not exist`));
5138
+ console.log(import_chalk3.default.red(`path ${answer.path} does not exist`));
5100
5139
  return;
5101
5140
  }
5102
- console.log(import_chalk2.default.blue(`uploading ${absolutePath} to ipfs...`));
5141
+ console.log(import_chalk3.default.blue(`uploading ${absolutePath} to ipfs...`));
5103
5142
  try {
5104
5143
  const result = await uploadToIpfsSplit_default(absolutePath);
5105
5144
  if (result) {
5106
5145
  const encryptedCID = encryptHash(result.contentHash, secretKey);
5107
5146
  console.log(
5108
- import_chalk2.default.cyan(
5147
+ import_chalk3.default.cyan(
5109
5148
  import_figlet.default.textSync("Successful", { horizontalLayout: "full" })
5110
5149
  )
5111
5150
  );
5112
- console.log(import_chalk2.default.cyan(`URL:`));
5113
- console.log(import_chalk2.default.cyan(`${URL2}${encryptedCID}`));
5114
- console.log(import_chalk2.default.green("\n\u{1F389} upload successful, program exit"));
5151
+ console.log(import_chalk3.default.cyan(`URL:`));
5152
+ console.log(import_chalk3.default.cyan(`${URL2}${encryptedCID}`));
5153
+ console.log(import_chalk3.default.green("\n\u{1F389} upload successful, program exit"));
5115
5154
  }
5116
5155
  } catch (error) {
5117
- console.error(import_chalk2.default.red(`Error: ${error.message}`));
5156
+ console.error(import_chalk3.default.red(`Error: ${error.message}`));
5118
5157
  }
5119
5158
  process.exit(0);
5120
5159
  }
5121
5160
  } catch (error) {
5122
- console.error(import_chalk2.default.red(`error executing: ${error.message}`));
5161
+ console.error(import_chalk3.default.red(`error executing: ${error.message}`));
5123
5162
  console.error(error.stack);
5124
5163
  }
5125
5164
  };
5126
5165
 
5127
5166
  // bin/remove.ts
5128
- var import_chalk4 = __toESM(require("chalk"));
5167
+ var import_chalk5 = __toESM(require("chalk"));
5129
5168
  var import_inquirer2 = __toESM(require("inquirer"));
5130
5169
  var import_figlet2 = __toESM(require("figlet"));
5131
5170
 
5132
5171
  // bin/utils/removeFromIpfs.ts
5133
- var import_chalk3 = __toESM(require("chalk"));
5172
+ var import_chalk4 = __toESM(require("chalk"));
5134
5173
  var ipfsApiUrl = "https://pinme.dev/api/v3";
5135
5174
  async function removeFromIpfs(value, type = "hash") {
5136
5175
  try {
5137
5176
  const uid = getDeviceId();
5138
- console.log(import_chalk3.default.blue(`Removing content from IPFS: ${value}...`));
5177
+ console.log(import_chalk4.default.blue(`Removing content from IPFS: ${value}...`));
5139
5178
  const queryParams = new URLSearchParams({
5140
5179
  uid
5141
5180
  });
@@ -5150,37 +5189,38 @@ async function removeFromIpfs(value, type = "hash") {
5150
5189
  });
5151
5190
  const { code, msg, data } = response.data;
5152
5191
  if (code === 200) {
5153
- console.log(import_chalk3.default.green("\u2713 Removal successful!"));
5154
- console.log(import_chalk3.default.cyan(`Content ${type}: ${value} has been removed from IPFS network`));
5192
+ console.log(import_chalk4.default.green("\u2713 Removal successful!"));
5193
+ console.log(import_chalk4.default.cyan(`Content ${type}: ${value} has been removed from IPFS network`));
5155
5194
  return true;
5156
5195
  } else {
5157
- console.log(import_chalk3.default.red("\u2717 Removal failed"));
5158
- console.log(import_chalk3.default.red(`Error: ${msg || "Unknown error occurred"}`));
5196
+ console.log(import_chalk4.default.red("\u2717 Removal failed"));
5197
+ console.log(import_chalk4.default.red(`Error: ${msg || "Unknown error occurred"}`));
5159
5198
  return false;
5160
5199
  }
5161
5200
  } catch (error) {
5162
- console.log(import_chalk3.default.red("\u2717 Removal failed", error));
5201
+ console.log(import_chalk4.default.red("\u2717 Removal failed", error));
5163
5202
  if (error.response) {
5164
5203
  const { status, data } = error.response;
5165
- console.log(import_chalk3.default.red(`HTTP Error ${status}: ${(data == null ? void 0 : data.msg) || "Server error"}`));
5204
+ console.log(import_chalk4.default.red(`HTTP Error ${status}: ${(data == null ? void 0 : data.msg) || "Server error"}`));
5166
5205
  if (status === 404) {
5167
- console.log(import_chalk3.default.yellow("Content not found on the network or already removed"));
5206
+ console.log(import_chalk4.default.yellow("Content not found on the network or already removed"));
5168
5207
  } else if (status === 403) {
5169
- console.log(import_chalk3.default.yellow("Permission denied - you may not have access to remove this content"));
5208
+ console.log(import_chalk4.default.yellow("Permission denied - you may not have access to remove this content"));
5170
5209
  } else if (status === 500) {
5171
- console.log(import_chalk3.default.yellow("Server internal error - please try again later"));
5210
+ console.log(import_chalk4.default.yellow("Server internal error - please try again later"));
5172
5211
  }
5173
5212
  } else if (error.request) {
5174
- console.log(import_chalk3.default.red("Network error: Unable to connect to IPFS service"));
5175
- console.log(import_chalk3.default.yellow("Please check your internet connection and try again"));
5213
+ console.log(import_chalk4.default.red("Network error: Unable to connect to IPFS service"));
5214
+ console.log(import_chalk4.default.yellow("Please check your internet connection and try again"));
5176
5215
  } else {
5177
- console.log(import_chalk3.default.red(`Error: ${error.message}`));
5216
+ console.log(import_chalk4.default.red(`Error: ${error.message}`));
5178
5217
  }
5179
5218
  return false;
5180
5219
  }
5181
5220
  }
5182
5221
 
5183
5222
  // bin/remove.ts
5223
+ checkNodeVersion();
5184
5224
  function isValidIPFSHash(hash) {
5185
5225
  const v0Pattern = /^Qm[1-9A-HJ-NP-Za-km-z]{44}$/;
5186
5226
  const v1Pattern = /^bafy[a-z2-7]{50,}$/;
@@ -5233,30 +5273,30 @@ var remove_default = async (options) => {
5233
5273
  if (argHash && !argHash.startsWith("-")) {
5234
5274
  const parsedInput = parseInput(argHash);
5235
5275
  if (!parsedInput) {
5236
- console.log(import_chalk4.default.red(`Invalid input format: ${argHash}`));
5237
- console.log(import_chalk4.default.yellow("Supported formats:"));
5238
- console.log(import_chalk4.default.yellow(" - IPFS hash: bafybeig..."));
5239
- console.log(import_chalk4.default.yellow(" - Full URL: https://bafybeig....pinme.dev"));
5240
- console.log(import_chalk4.default.yellow(" - Subname: 3abt6ztu"));
5241
- console.log(import_chalk4.default.yellow(" - Subname URL: https://3abt6ztu.pinit.eth.limo"));
5276
+ console.log(import_chalk5.default.red(`Invalid input format: ${argHash}`));
5277
+ console.log(import_chalk5.default.yellow("Supported formats:"));
5278
+ console.log(import_chalk5.default.yellow(" - IPFS hash: bafybeig..."));
5279
+ console.log(import_chalk5.default.yellow(" - Full URL: https://bafybeig....pinme.dev"));
5280
+ console.log(import_chalk5.default.yellow(" - Subname: 3abt6ztu"));
5281
+ console.log(import_chalk5.default.yellow(" - Subname URL: https://3abt6ztu.pinit.eth.limo"));
5242
5282
  return;
5243
5283
  }
5244
5284
  try {
5245
5285
  const success = await removeFromIpfs(parsedInput.value, parsedInput.type);
5246
5286
  if (success) {
5247
5287
  console.log(
5248
- import_chalk4.default.cyan(
5288
+ import_chalk5.default.cyan(
5249
5289
  import_figlet2.default.textSync("Successful", { horizontalLayout: "full" })
5250
5290
  )
5251
5291
  );
5252
5292
  }
5253
5293
  } catch (error) {
5254
- console.error(import_chalk4.default.red(`Error: ${error.message}`));
5294
+ console.error(import_chalk5.default.red(`Error: ${error.message}`));
5255
5295
  }
5256
5296
  return;
5257
5297
  }
5258
- console.log(import_chalk4.default.yellow("\u26A0\uFE0F Warning: This action will permanently remove the content from IPFS network"));
5259
- console.log(import_chalk4.default.yellow("\u26A0\uFE0F Make sure you have the correct IPFS hash"));
5298
+ console.log(import_chalk5.default.yellow("\u26A0\uFE0F Warning: This action will permanently remove the content from IPFS network"));
5299
+ console.log(import_chalk5.default.yellow("\u26A0\uFE0F Make sure you have the correct IPFS hash"));
5260
5300
  console.log("");
5261
5301
  const confirmAnswer = await import_inquirer2.default.prompt([
5262
5302
  {
@@ -5267,7 +5307,7 @@ var remove_default = async (options) => {
5267
5307
  }
5268
5308
  ]);
5269
5309
  if (!confirmAnswer.confirm) {
5270
- console.log(import_chalk4.default.yellow("Operation cancelled"));
5310
+ console.log(import_chalk5.default.yellow("Operation cancelled"));
5271
5311
  return;
5272
5312
  }
5273
5313
  const answer = await import_inquirer2.default.prompt([
@@ -5290,7 +5330,7 @@ var remove_default = async (options) => {
5290
5330
  if (answer.input) {
5291
5331
  const parsedInput = parseInput(answer.input.trim());
5292
5332
  if (!parsedInput) {
5293
- console.log(import_chalk4.default.red("Invalid input format"));
5333
+ console.log(import_chalk5.default.red("Invalid input format"));
5294
5334
  return;
5295
5335
  }
5296
5336
  const finalConfirm = await import_inquirer2.default.prompt([
@@ -5302,37 +5342,38 @@ var remove_default = async (options) => {
5302
5342
  }
5303
5343
  ]);
5304
5344
  if (!finalConfirm.confirm) {
5305
- console.log(import_chalk4.default.yellow("Operation cancelled"));
5345
+ console.log(import_chalk5.default.yellow("Operation cancelled"));
5306
5346
  return;
5307
5347
  }
5308
5348
  try {
5309
5349
  const success = await removeFromIpfs(parsedInput.value, parsedInput.type);
5310
5350
  if (success) {
5311
5351
  console.log(
5312
- import_chalk4.default.cyan(
5352
+ import_chalk5.default.cyan(
5313
5353
  import_figlet2.default.textSync("Successful", { horizontalLayout: "full" })
5314
5354
  )
5315
5355
  );
5316
5356
  }
5317
5357
  } catch (error) {
5318
- console.error(import_chalk4.default.red(`Error: ${error.message}`));
5358
+ console.error(import_chalk5.default.red(`Error: ${error.message}`));
5319
5359
  }
5320
5360
  }
5321
5361
  } catch (error) {
5322
- console.error(import_chalk4.default.red(`Error executing remove command: ${error.message}`));
5362
+ console.error(import_chalk5.default.red(`Error executing remove command: ${error.message}`));
5323
5363
  console.error(error.stack);
5324
5364
  }
5325
5365
  };
5326
5366
 
5327
5367
  // bin/index.ts
5328
5368
  import_dotenv.default.config();
5369
+ checkNodeVersion();
5329
5370
  function showBanner() {
5330
5371
  console.log(
5331
- import_chalk5.default.cyan(
5372
+ import_chalk6.default.cyan(
5332
5373
  import_figlet3.default.textSync("Pinme", { horizontalLayout: "full" })
5333
5374
  )
5334
5375
  );
5335
- console.log(import_chalk5.default.cyan("A command-line tool for uploading files to IPFS\n"));
5376
+ console.log(import_chalk6.default.cyan("A command-line tool for uploading files to IPFS\n"));
5336
5377
  }
5337
5378
  var program = new import_commander.Command();
5338
5379
  program.name("pinme").version(version).option("-v, --version", "output the current version");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinme",
3
- "version": "1.1.4-alpha.1",
3
+ "version": "1.1.4-alpha.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },