hot-updater 0.6.2 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -16116,7 +16116,12 @@ var __webpack_exports__ = {};
16116
16116
  title: `📦 Uploading to Storage (${storagePlugin.name})`,
16117
16117
  task: async ()=>{
16118
16118
  if (!bundleId) throw new Error("Bundle ID not found");
16119
- ({ fileUrl } = await storagePlugin.uploadBundle(bundleId, bundlePath));
16119
+ try {
16120
+ ({ fileUrl } = await storagePlugin.uploadBundle(bundleId, bundlePath));
16121
+ } catch (e) {
16122
+ if (e instanceof Error) prompts_namespaceObject.log.error(e.message);
16123
+ throw new Error("Failed to upload bundle to storage");
16124
+ }
16120
16125
  return `✅ Upload Complete (${storagePlugin.name})`;
16121
16126
  }
16122
16127
  },
@@ -16124,18 +16129,23 @@ var __webpack_exports__ = {};
16124
16129
  title: `📦 Updating Database (${databasePlugin.name})`,
16125
16130
  task: async ()=>{
16126
16131
  if (!bundleId) throw new Error("Bundle ID not found");
16127
- await databasePlugin.appendBundle({
16128
- shouldForceUpdate: options.forceUpdate,
16129
- platform,
16130
- fileUrl,
16131
- fileHash,
16132
- gitCommitHash,
16133
- message: gitMessage,
16134
- targetAppVersion,
16135
- id: bundleId,
16136
- enabled: true
16137
- });
16138
- await databasePlugin.commitBundle();
16132
+ try {
16133
+ await databasePlugin.appendBundle({
16134
+ shouldForceUpdate: options.forceUpdate,
16135
+ platform,
16136
+ fileUrl,
16137
+ fileHash,
16138
+ gitCommitHash,
16139
+ message: gitMessage,
16140
+ targetAppVersion,
16141
+ id: bundleId,
16142
+ enabled: true
16143
+ });
16144
+ await databasePlugin.commitBundle();
16145
+ } catch (e) {
16146
+ if (e instanceof Error) prompts_namespaceObject.log.error(e.message);
16147
+ throw new Error("Failed to update database");
16148
+ }
16139
16149
  await databasePlugin.onUnmount?.();
16140
16150
  await promises_default().rm(bundlePath);
16141
16151
  return `✅ Update Complete (${databasePlugin.name})`;
@@ -22502,7 +22512,7 @@ function App() {
22502
22512
  export default HotUpdater.wrap({
22503
22513
  source: "%%source%%",
22504
22514
  })(App);`;
22505
- const deployWorker = async (oauth_token, { d1DatabaseId, d1DatabaseName })=>{
22515
+ const deployWorker = async (oauth_token, accountId, { d1DatabaseId, d1DatabaseName })=>{
22506
22516
  const workerPath = require.resolve("@hot-updater/cloudflare/worker");
22507
22517
  const workerDir = external_path_default().dirname(workerPath);
22508
22518
  const { tmpDir, removeTmpDir } = await (0, plugin_core_namespaceObject.copyDirToTmp)(workerDir);
@@ -22520,7 +22530,8 @@ export default HotUpdater.wrap({
22520
22530
  const wrangler = await createWrangler({
22521
22531
  stdio: "inherit",
22522
22532
  cloudflareApiToken: oauth_token,
22523
- cwd: tmpDir
22533
+ cwd: tmpDir,
22534
+ accountId: accountId
22524
22535
  });
22525
22536
  await wrangler("d1", "migrations", "apply", d1DatabaseName, "--remote");
22526
22537
  const workerName = await prompts_namespaceObject.text({
@@ -22564,17 +22575,22 @@ export default HotUpdater.wrap({
22564
22575
  });
22565
22576
  const createKey = `create/${Math.random().toString(36).substring(2, 15)}`;
22566
22577
  const accounts = [];
22567
- await prompts_namespaceObject.tasks([
22568
- {
22569
- title: "Checking Account List...",
22570
- task: async ()=>{
22571
- accounts.push(...(await cf.accounts.list()).result.map((account)=>({
22572
- id: account.id,
22573
- name: account.name
22574
- })));
22578
+ try {
22579
+ await prompts_namespaceObject.tasks([
22580
+ {
22581
+ title: "Checking Account List...",
22582
+ task: async ()=>{
22583
+ accounts.push(...(await cf.accounts.list()).result.map((account)=>({
22584
+ id: account.id,
22585
+ name: account.name
22586
+ })));
22587
+ }
22575
22588
  }
22576
- }
22577
- ]);
22589
+ ]);
22590
+ } catch (e) {
22591
+ if (e instanceof Error) prompts_namespaceObject.log.error(e.message);
22592
+ throw e;
22593
+ }
22578
22594
  const accountId = await prompts_namespaceObject.select({
22579
22595
  message: "Account List",
22580
22596
  options: accounts.map((account)=>({
@@ -22591,19 +22607,24 @@ export default HotUpdater.wrap({
22591
22607
  if (!apiToken) prompts_namespaceObject.log.warn("Skipping API Token. You can set it later in .env HOT_UPDATER_CLOUDFLARE_API_TOKEN file.");
22592
22608
  if (prompts_namespaceObject.isCancel(apiToken)) process.exit(1);
22593
22609
  const availableBuckets = [];
22594
- await prompts_namespaceObject.tasks([
22595
- {
22596
- title: "Checking R2 Buckets...",
22597
- task: async ()=>{
22598
- const buckets = (await cf.r2.buckets.list({
22599
- account_id: accountId
22600
- })).buckets ?? [];
22601
- availableBuckets.push(...buckets.filter((bucket)=>bucket.name).map((bucket)=>({
22602
- name: bucket.name
22603
- })));
22610
+ try {
22611
+ await prompts_namespaceObject.tasks([
22612
+ {
22613
+ title: "Checking R2 Buckets...",
22614
+ task: async ()=>{
22615
+ const buckets = (await cf.r2.buckets.list({
22616
+ account_id: accountId
22617
+ })).buckets ?? [];
22618
+ availableBuckets.push(...buckets.filter((bucket)=>bucket.name).map((bucket)=>({
22619
+ name: bucket.name
22620
+ })));
22621
+ }
22604
22622
  }
22605
- }
22606
- ]);
22623
+ ]);
22624
+ } catch (e) {
22625
+ if (e instanceof Error) prompts_namespaceObject.log.error(e.message);
22626
+ throw e;
22627
+ }
22607
22628
  let selectedBucketName = await prompts_namespaceObject.select({
22608
22629
  message: "R2 List",
22609
22630
  options: [
@@ -22634,32 +22655,42 @@ export default HotUpdater.wrap({
22634
22655
  const domains = await cf.r2.buckets.domains.managed.list(selectedBucketName, {
22635
22656
  account_id: accountId
22636
22657
  });
22637
- if (!domains.enabled) await prompts_namespaceObject.tasks([
22638
- {
22639
- title: "Making R2 bucket publicly accessible...",
22640
- task: async ()=>{
22641
- await cf.r2.buckets.domains.managed.update(selectedBucketName, {
22642
- account_id: accountId,
22643
- enabled: true
22644
- });
22658
+ if (!domains.enabled) try {
22659
+ await prompts_namespaceObject.tasks([
22660
+ {
22661
+ title: "Making R2 bucket publicly accessible...",
22662
+ task: async ()=>{
22663
+ await cf.r2.buckets.domains.managed.update(selectedBucketName, {
22664
+ account_id: accountId,
22665
+ enabled: true
22666
+ });
22667
+ }
22645
22668
  }
22646
- }
22647
- ]);
22669
+ ]);
22670
+ } catch (e) {
22671
+ if (e instanceof Error) prompts_namespaceObject.log.error(e.message);
22672
+ throw e;
22673
+ }
22648
22674
  const availableD1List = [];
22649
- await prompts_namespaceObject.tasks([
22650
- {
22651
- title: "Checking D1 List...",
22652
- task: async ()=>{
22653
- const d1List = (await cf.d1.database.list({
22654
- account_id: accountId
22655
- })).result ?? [];
22656
- availableD1List.push(...d1List.filter((d1)=>d1.name || d1.uuid).map((d1)=>({
22657
- name: d1.name,
22658
- uuid: d1.uuid
22659
- })));
22675
+ try {
22676
+ await prompts_namespaceObject.tasks([
22677
+ {
22678
+ title: "Checking D1 List...",
22679
+ task: async ()=>{
22680
+ const d1List = (await cf.d1.database.list({
22681
+ account_id: accountId
22682
+ })).result ?? [];
22683
+ availableD1List.push(...d1List.filter((d1)=>d1.name || d1.uuid).map((d1)=>({
22684
+ name: d1.name,
22685
+ uuid: d1.uuid
22686
+ })));
22687
+ }
22660
22688
  }
22661
- }
22662
- ]);
22689
+ ]);
22690
+ } catch (e) {
22691
+ if (e instanceof Error) prompts_namespaceObject.log.error(e.message);
22692
+ throw e;
22693
+ }
22663
22694
  let selectedD1DatabaseId = await prompts_namespaceObject.select({
22664
22695
  message: "D1 List",
22665
22696
  options: [
@@ -22696,7 +22727,7 @@ export default HotUpdater.wrap({
22696
22727
  const subdomains = await cf.workers.subdomains.get({
22697
22728
  account_id: accountId
22698
22729
  });
22699
- const workerName = await deployWorker(auth.oauth_token, {
22730
+ const workerName = await deployWorker(auth.oauth_token, accountId, {
22700
22731
  d1DatabaseId: selectedD1DatabaseId,
22701
22732
  d1DatabaseName
22702
22733
  });
package/dist/index.js CHANGED
@@ -16015,7 +16015,12 @@ const deploy = async (options)=>{
16015
16015
  title: `📦 Uploading to Storage (${storagePlugin.name})`,
16016
16016
  task: async ()=>{
16017
16017
  if (!bundleId) throw new Error("Bundle ID not found");
16018
- ({ fileUrl } = await storagePlugin.uploadBundle(bundleId, bundlePath));
16018
+ try {
16019
+ ({ fileUrl } = await storagePlugin.uploadBundle(bundleId, bundlePath));
16020
+ } catch (e) {
16021
+ if (e instanceof Error) __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.log.error(e.message);
16022
+ throw new Error("Failed to upload bundle to storage");
16023
+ }
16019
16024
  return `✅ Upload Complete (${storagePlugin.name})`;
16020
16025
  }
16021
16026
  },
@@ -16023,18 +16028,23 @@ const deploy = async (options)=>{
16023
16028
  title: `📦 Updating Database (${databasePlugin.name})`,
16024
16029
  task: async ()=>{
16025
16030
  if (!bundleId) throw new Error("Bundle ID not found");
16026
- await databasePlugin.appendBundle({
16027
- shouldForceUpdate: options.forceUpdate,
16028
- platform,
16029
- fileUrl,
16030
- fileHash,
16031
- gitCommitHash,
16032
- message: gitMessage,
16033
- targetAppVersion,
16034
- id: bundleId,
16035
- enabled: true
16036
- });
16037
- await databasePlugin.commitBundle();
16031
+ try {
16032
+ await databasePlugin.appendBundle({
16033
+ shouldForceUpdate: options.forceUpdate,
16034
+ platform,
16035
+ fileUrl,
16036
+ fileHash,
16037
+ gitCommitHash,
16038
+ message: gitMessage,
16039
+ targetAppVersion,
16040
+ id: bundleId,
16041
+ enabled: true
16042
+ });
16043
+ await databasePlugin.commitBundle();
16044
+ } catch (e) {
16045
+ if (e instanceof Error) __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.log.error(e.message);
16046
+ throw new Error("Failed to update database");
16047
+ }
16038
16048
  await databasePlugin.onUnmount?.();
16039
16049
  await __WEBPACK_EXTERNAL_MODULE_fs_promises_400951f8__["default"].rm(bundlePath);
16040
16050
  return `✅ Update Complete (${databasePlugin.name})`;
@@ -22395,7 +22405,7 @@ function App() {
22395
22405
  export default HotUpdater.wrap({
22396
22406
  source: "%%source%%",
22397
22407
  })(App);`;
22398
- const deployWorker = async (oauth_token, { d1DatabaseId, d1DatabaseName })=>{
22408
+ const deployWorker = async (oauth_token, accountId, { d1DatabaseId, d1DatabaseName })=>{
22399
22409
  const workerPath = require.resolve("@hot-updater/cloudflare/worker");
22400
22410
  const workerDir = external_path_["default"].dirname(workerPath);
22401
22411
  const { tmpDir, removeTmpDir } = await (0, __WEBPACK_EXTERNAL_MODULE__hot_updater_plugin_core_40c1c502__.copyDirToTmp)(workerDir);
@@ -22413,7 +22423,8 @@ const deployWorker = async (oauth_token, { d1DatabaseId, d1DatabaseName })=>{
22413
22423
  const wrangler = await createWrangler({
22414
22424
  stdio: "inherit",
22415
22425
  cloudflareApiToken: oauth_token,
22416
- cwd: tmpDir
22426
+ cwd: tmpDir,
22427
+ accountId: accountId
22417
22428
  });
22418
22429
  await wrangler("d1", "migrations", "apply", d1DatabaseName, "--remote");
22419
22430
  const workerName = await __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.text({
@@ -22457,17 +22468,22 @@ const initCloudflareD1R2Worker = async ()=>{
22457
22468
  });
22458
22469
  const createKey = `create/${Math.random().toString(36).substring(2, 15)}`;
22459
22470
  const accounts = [];
22460
- await __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.tasks([
22461
- {
22462
- title: "Checking Account List...",
22463
- task: async ()=>{
22464
- accounts.push(...(await cf.accounts.list()).result.map((account)=>({
22465
- id: account.id,
22466
- name: account.name
22467
- })));
22471
+ try {
22472
+ await __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.tasks([
22473
+ {
22474
+ title: "Checking Account List...",
22475
+ task: async ()=>{
22476
+ accounts.push(...(await cf.accounts.list()).result.map((account)=>({
22477
+ id: account.id,
22478
+ name: account.name
22479
+ })));
22480
+ }
22468
22481
  }
22469
- }
22470
- ]);
22482
+ ]);
22483
+ } catch (e) {
22484
+ if (e instanceof Error) __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.log.error(e.message);
22485
+ throw e;
22486
+ }
22471
22487
  const accountId = await __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.select({
22472
22488
  message: "Account List",
22473
22489
  options: accounts.map((account)=>({
@@ -22484,19 +22500,24 @@ const initCloudflareD1R2Worker = async ()=>{
22484
22500
  if (!apiToken) __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.log.warn("Skipping API Token. You can set it later in .env HOT_UPDATER_CLOUDFLARE_API_TOKEN file.");
22485
22501
  if (__WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.isCancel(apiToken)) process.exit(1);
22486
22502
  const availableBuckets = [];
22487
- await __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.tasks([
22488
- {
22489
- title: "Checking R2 Buckets...",
22490
- task: async ()=>{
22491
- const buckets = (await cf.r2.buckets.list({
22492
- account_id: accountId
22493
- })).buckets ?? [];
22494
- availableBuckets.push(...buckets.filter((bucket)=>bucket.name).map((bucket)=>({
22495
- name: bucket.name
22496
- })));
22503
+ try {
22504
+ await __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.tasks([
22505
+ {
22506
+ title: "Checking R2 Buckets...",
22507
+ task: async ()=>{
22508
+ const buckets = (await cf.r2.buckets.list({
22509
+ account_id: accountId
22510
+ })).buckets ?? [];
22511
+ availableBuckets.push(...buckets.filter((bucket)=>bucket.name).map((bucket)=>({
22512
+ name: bucket.name
22513
+ })));
22514
+ }
22497
22515
  }
22498
- }
22499
- ]);
22516
+ ]);
22517
+ } catch (e) {
22518
+ if (e instanceof Error) __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.log.error(e.message);
22519
+ throw e;
22520
+ }
22500
22521
  let selectedBucketName = await __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.select({
22501
22522
  message: "R2 List",
22502
22523
  options: [
@@ -22527,32 +22548,42 @@ const initCloudflareD1R2Worker = async ()=>{
22527
22548
  const domains = await cf.r2.buckets.domains.managed.list(selectedBucketName, {
22528
22549
  account_id: accountId
22529
22550
  });
22530
- if (!domains.enabled) await __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.tasks([
22531
- {
22532
- title: "Making R2 bucket publicly accessible...",
22533
- task: async ()=>{
22534
- await cf.r2.buckets.domains.managed.update(selectedBucketName, {
22535
- account_id: accountId,
22536
- enabled: true
22537
- });
22551
+ if (!domains.enabled) try {
22552
+ await __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.tasks([
22553
+ {
22554
+ title: "Making R2 bucket publicly accessible...",
22555
+ task: async ()=>{
22556
+ await cf.r2.buckets.domains.managed.update(selectedBucketName, {
22557
+ account_id: accountId,
22558
+ enabled: true
22559
+ });
22560
+ }
22538
22561
  }
22539
- }
22540
- ]);
22562
+ ]);
22563
+ } catch (e) {
22564
+ if (e instanceof Error) __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.log.error(e.message);
22565
+ throw e;
22566
+ }
22541
22567
  const availableD1List = [];
22542
- await __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.tasks([
22543
- {
22544
- title: "Checking D1 List...",
22545
- task: async ()=>{
22546
- const d1List = (await cf.d1.database.list({
22547
- account_id: accountId
22548
- })).result ?? [];
22549
- availableD1List.push(...d1List.filter((d1)=>d1.name || d1.uuid).map((d1)=>({
22550
- name: d1.name,
22551
- uuid: d1.uuid
22552
- })));
22568
+ try {
22569
+ await __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.tasks([
22570
+ {
22571
+ title: "Checking D1 List...",
22572
+ task: async ()=>{
22573
+ const d1List = (await cf.d1.database.list({
22574
+ account_id: accountId
22575
+ })).result ?? [];
22576
+ availableD1List.push(...d1List.filter((d1)=>d1.name || d1.uuid).map((d1)=>({
22577
+ name: d1.name,
22578
+ uuid: d1.uuid
22579
+ })));
22580
+ }
22553
22581
  }
22554
- }
22555
- ]);
22582
+ ]);
22583
+ } catch (e) {
22584
+ if (e instanceof Error) __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.log.error(e.message);
22585
+ throw e;
22586
+ }
22556
22587
  let selectedD1DatabaseId = await __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.select({
22557
22588
  message: "D1 List",
22558
22589
  options: [
@@ -22589,7 +22620,7 @@ const initCloudflareD1R2Worker = async ()=>{
22589
22620
  const subdomains = await cf.workers.subdomains.get({
22590
22621
  account_id: accountId
22591
22622
  });
22592
- const workerName = await deployWorker(auth.oauth_token, {
22623
+ const workerName = await deployWorker(auth.oauth_token, accountId, {
22593
22624
  d1DatabaseId: selectedD1DatabaseId,
22594
22625
  d1DatabaseName
22595
22626
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hot-updater",
3
3
  "type": "module",
4
- "version": "0.6.2",
4
+ "version": "0.6.4",
5
5
  "bin": {
6
6
  "hot-updater": "./dist/index.js"
7
7
  },
@@ -49,9 +49,9 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@clack/prompts": "^0.9.0",
52
- "@hot-updater/console": "0.6.2",
53
- "@hot-updater/core": "0.6.2",
54
- "@hot-updater/plugin-core": "0.6.2",
52
+ "@hot-updater/console": "0.6.4",
53
+ "@hot-updater/core": "0.6.4",
54
+ "@hot-updater/plugin-core": "0.6.4",
55
55
  "commander": "^11.1.0",
56
56
  "cosmiconfig": "^9.0.0",
57
57
  "cosmiconfig-typescript-loader": "^5.0.0"