@hot-updater/aws 0.29.4 → 0.29.6

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.
@@ -22,8 +22,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  enumerable: true
23
23
  }) : target, mod));
24
24
  //#endregion
25
- let fs = require("fs");
26
- fs = __toESM(fs);
27
25
  let _aws_sdk_credential_providers = require("@aws-sdk/credential-providers");
28
26
  let _hot_updater_cli_tools = require("@hot-updater/cli-tools");
29
27
  let node_url = require("node:url");
@@ -826,7 +824,7 @@ const handleCommand = (filePath, rawArguments, rawOptions) => {
826
824
  var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
827
825
  module.exports = isexe;
828
826
  isexe.sync = sync;
829
- var fs$5 = require("fs");
827
+ var fs$3 = require("fs");
830
828
  function checkPathExt(path, options) {
831
829
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
832
830
  if (!pathext) return true;
@@ -843,12 +841,12 @@ var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
843
841
  return checkPathExt(path, options);
844
842
  }
845
843
  function isexe(path, options, cb) {
846
- fs$5.stat(path, function(er, stat) {
844
+ fs$3.stat(path, function(er, stat) {
847
845
  cb(er, er ? false : checkStat(stat, path, options));
848
846
  });
849
847
  }
850
848
  function sync(path, options) {
851
- return checkStat(fs$5.statSync(path), path, options);
849
+ return checkStat(fs$3.statSync(path), path, options);
852
850
  }
853
851
  }));
854
852
  //#endregion
@@ -856,14 +854,14 @@ var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
856
854
  var require_mode = /* @__PURE__ */ __commonJSMin(((exports, module) => {
857
855
  module.exports = isexe;
858
856
  isexe.sync = sync;
859
- var fs$4 = require("fs");
857
+ var fs$2 = require("fs");
860
858
  function isexe(path, options, cb) {
861
- fs$4.stat(path, function(er, stat) {
859
+ fs$2.stat(path, function(er, stat) {
862
860
  cb(er, er ? false : checkStat(stat, options));
863
861
  });
864
862
  }
865
863
  function sync(path, options) {
866
- return checkStat(fs$4.statSync(path), options);
864
+ return checkStat(fs$2.statSync(path), options);
867
865
  }
868
866
  function checkStat(stat, options) {
869
867
  return stat.isFile() && checkMode(stat, options);
@@ -1078,16 +1076,16 @@ var require_shebang_command = /* @__PURE__ */ __commonJSMin(((exports, module) =
1078
1076
  //#endregion
1079
1077
  //#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
1080
1078
  var require_readShebang = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1081
- const fs$3 = require("fs");
1079
+ const fs$1 = require("fs");
1082
1080
  const shebangCommand = require_shebang_command();
1083
1081
  function readShebang(command) {
1084
1082
  const size = 150;
1085
1083
  const buffer = Buffer.alloc(size);
1086
1084
  let fd;
1087
1085
  try {
1088
- fd = fs$3.openSync(command, "r");
1089
- fs$3.readSync(fd, buffer, 0, size, 0);
1090
- fs$3.closeSync(fd);
1086
+ fd = fs$1.openSync(command, "r");
1087
+ fs$1.readSync(fd, buffer, 0, size, 0);
1088
+ fs$1.closeSync(fd);
1091
1089
  } catch (e) {}
1092
1090
  return shebangCommand(buffer.toString());
1093
1091
  }
@@ -7327,7 +7325,7 @@ var SSMKeyPairManager = class {
7327
7325
  };
7328
7326
  //#endregion
7329
7327
  //#region iac/templates.ts
7330
- const getConfigTemplate = (build, { profile }) => {
7328
+ const getConfigScaffold = (build, { profile }) => {
7331
7329
  const storageConfig = {
7332
7330
  imports: [{
7333
7331
  pkg: "@hot-updater/aws",
@@ -7345,14 +7343,21 @@ const getConfigTemplate = (build, { profile }) => {
7345
7343
  cloudfrontDistributionId: process.env.HOT_UPDATER_CLOUDFRONT_DISTRIBUTION_ID!,
7346
7344
  })`
7347
7345
  };
7348
- let intermediate = "";
7349
- if (profile) intermediate = `
7346
+ let helperStatements = [];
7347
+ if (profile) helperStatements = [{
7348
+ name: "commonOptions",
7349
+ strategy: "merge-object",
7350
+ code: `
7350
7351
  const commonOptions = {
7351
7352
  bucketName: process.env.HOT_UPDATER_S3_BUCKET_NAME!,
7352
7353
  region: process.env.HOT_UPDATER_S3_REGION!,
7353
7354
  credentials: fromSSO({ profile: process.env.HOT_UPDATER_AWS_PROFILE! }),
7354
- };`.trim();
7355
- else intermediate = `
7355
+ };`.trim()
7356
+ }];
7357
+ else helperStatements = [{
7358
+ name: "commonOptions",
7359
+ strategy: "merge-object",
7360
+ code: `
7356
7361
  const commonOptions = {
7357
7362
  bucketName: process.env.HOT_UPDATER_S3_BUCKET_NAME!,
7358
7363
  region: process.env.HOT_UPDATER_S3_REGION!,
@@ -7360,13 +7365,14 @@ const commonOptions = {
7360
7365
  accessKeyId: process.env.HOT_UPDATER_S3_ACCESS_KEY_ID!,
7361
7366
  secretAccessKey: process.env.HOT_UPDATER_S3_SECRET_ACCESS_KEY!,
7362
7367
  },
7363
- };`.trim();
7364
- const builder = new _hot_updater_cli_tools.ConfigBuilder().setBuildType(build).setStorage(storageConfig).setDatabase(databaseConfig);
7368
+ };`.trim()
7369
+ }];
7370
+ const builder = new _hot_updater_cli_tools.ConfigBuilder().setBuildType(build).setStorage(storageConfig).setDatabase(databaseConfig).setIntermediateCode(helperStatements.map((statement) => statement.code.trim()).join("\n\n"));
7365
7371
  if (profile) builder.addImport({
7366
7372
  pkg: "@aws-sdk/credential-provider-sso",
7367
7373
  named: ["fromSSO"]
7368
7374
  });
7369
- return builder.setIntermediateCode(intermediate).getResult();
7375
+ return (0, _hot_updater_cli_tools.createHotUpdaterConfigScaffoldFromBuilder)(builder, { helperStatements });
7370
7376
  };
7371
7377
  const SOURCE_TEMPLATE = `// Add this to your App.tsx
7372
7378
  import { HotUpdater } from "@hot-updater/react-native";
@@ -7536,7 +7542,7 @@ const runInit = async ({ build }) => {
7536
7542
  distributionId,
7537
7543
  accountId
7538
7544
  });
7539
- await fs.default.promises.writeFile("hot-updater.config.ts", getConfigTemplate(build, { profile: ssoProfile }));
7545
+ const configWriteResult = await (0, _hot_updater_cli_tools.writeHotUpdaterConfig)(getConfigScaffold(build, { profile: ssoProfile }));
7540
7546
  await (0, _hot_updater_cli_tools.makeEnv)({
7541
7547
  HOT_UPDATER_S3_BUCKET_NAME: bucketName,
7542
7548
  HOT_UPDATER_S3_REGION: bucketRegion,
@@ -7555,7 +7561,9 @@ const runInit = async ({ build }) => {
7555
7561
  });
7556
7562
  if (mode === "sso") await (0, _hot_updater_cli_tools.ensureInstallPackages)({ devDependencies: ["@aws-sdk/credential-provider-sso"] });
7557
7563
  _hot_updater_cli_tools.p.log.success("Generated '.env.hotupdater' file with AWS settings.");
7558
- _hot_updater_cli_tools.p.log.success("Generated 'hot-updater.config.ts' file with AWS settings.");
7564
+ if (configWriteResult.status === "created") _hot_updater_cli_tools.p.log.success("Generated 'hot-updater.config.ts' file with AWS settings.");
7565
+ else if (configWriteResult.status === "merged") _hot_updater_cli_tools.p.log.success("Updated 'hot-updater.config.ts' file with AWS settings.");
7566
+ else _hot_updater_cli_tools.p.log.warn(`Kept existing 'hot-updater.config.ts' unchanged: ${configWriteResult.reason}`);
7559
7567
  const sourceUrl = `https://${distributionDomain}/api/check-update`;
7560
7568
  _hot_updater_cli_tools.p.note((0, _hot_updater_cli_tools.transformTemplate)(SOURCE_TEMPLATE, { source: sourceUrl }));
7561
7569
  _hot_updater_cli_tools.p.log.message(`Next step: ${(0, _hot_updater_cli_tools.link)("https://hot-updater.dev/docs/managed/aws#step-4-changeenv-file-optional")}`);
@@ -1,7 +1,6 @@
1
1
  import { createRequire } from "node:module";
2
- import fs from "fs";
3
2
  import { fromSSO } from "@aws-sdk/credential-providers";
4
- import { ConfigBuilder, colors, copyDirToTmp, createZip, ensureInstallPackages, getCwd, link, makeEnv, p, transformEnv, transformTemplate } from "@hot-updater/cli-tools";
3
+ import { ConfigBuilder, colors, copyDirToTmp, createHotUpdaterConfigScaffoldFromBuilder, createZip, ensureInstallPackages, getCwd, link, makeEnv, p, transformEnv, transformTemplate, writeHotUpdaterConfig } from "@hot-updater/cli-tools";
5
4
  import { fileURLToPath } from "node:url";
6
5
  import { ChildProcess, execFile, spawn, spawnSync } from "node:child_process";
7
6
  import { StringDecoder } from "node:string_decoder";
@@ -22,7 +21,7 @@ import crypto from "crypto";
22
21
  import { CloudFront } from "@aws-sdk/client-cloudfront";
23
22
  import { IAM } from "@aws-sdk/client-iam";
24
23
  import { STS } from "@aws-sdk/client-sts";
25
- import fs$1 from "fs/promises";
24
+ import fs from "fs/promises";
26
25
  import { Lambda } from "@aws-sdk/client-lambda";
27
26
  import { CopyObjectCommand, DeleteObjectCommand, GetObjectCommand, ListObjectsV2Command, S3 } from "@aws-sdk/client-s3";
28
27
  import { Upload } from "@aws-sdk/lib-storage";
@@ -820,7 +819,7 @@ const handleCommand = (filePath, rawArguments, rawOptions) => {
820
819
  var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
821
820
  module.exports = isexe;
822
821
  isexe.sync = sync;
823
- var fs$4 = __require("fs");
822
+ var fs$3 = __require("fs");
824
823
  function checkPathExt(path, options) {
825
824
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
826
825
  if (!pathext) return true;
@@ -837,12 +836,12 @@ var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
837
836
  return checkPathExt(path, options);
838
837
  }
839
838
  function isexe(path, options, cb) {
840
- fs$4.stat(path, function(er, stat) {
839
+ fs$3.stat(path, function(er, stat) {
841
840
  cb(er, er ? false : checkStat(stat, path, options));
842
841
  });
843
842
  }
844
843
  function sync(path, options) {
845
- return checkStat(fs$4.statSync(path), path, options);
844
+ return checkStat(fs$3.statSync(path), path, options);
846
845
  }
847
846
  }));
848
847
  //#endregion
@@ -850,14 +849,14 @@ var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
850
849
  var require_mode = /* @__PURE__ */ __commonJSMin(((exports, module) => {
851
850
  module.exports = isexe;
852
851
  isexe.sync = sync;
853
- var fs$3 = __require("fs");
852
+ var fs$2 = __require("fs");
854
853
  function isexe(path, options, cb) {
855
- fs$3.stat(path, function(er, stat) {
854
+ fs$2.stat(path, function(er, stat) {
856
855
  cb(er, er ? false : checkStat(stat, options));
857
856
  });
858
857
  }
859
858
  function sync(path, options) {
860
- return checkStat(fs$3.statSync(path), options);
859
+ return checkStat(fs$2.statSync(path), options);
861
860
  }
862
861
  function checkStat(stat, options) {
863
862
  return stat.isFile() && checkMode(stat, options);
@@ -1072,16 +1071,16 @@ var require_shebang_command = /* @__PURE__ */ __commonJSMin(((exports, module) =
1072
1071
  //#endregion
1073
1072
  //#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
1074
1073
  var require_readShebang = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1075
- const fs$2 = __require("fs");
1074
+ const fs$1 = __require("fs");
1076
1075
  const shebangCommand = require_shebang_command();
1077
1076
  function readShebang(command) {
1078
1077
  const size = 150;
1079
1078
  const buffer = Buffer.alloc(size);
1080
1079
  let fd;
1081
1080
  try {
1082
- fd = fs$2.openSync(command, "r");
1083
- fs$2.readSync(fd, buffer, 0, size, 0);
1084
- fs$2.closeSync(fd);
1081
+ fd = fs$1.openSync(command, "r");
1082
+ fs$1.readSync(fd, buffer, 0, size, 0);
1083
+ fs$1.closeSync(fd);
1085
1084
  } catch (e) {}
1086
1085
  return shebangCommand(buffer.toString());
1087
1086
  }
@@ -6750,7 +6749,7 @@ var LambdaEdgeDeployer = class {
6750
6749
  SSM_REGION: config.ssmRegion,
6751
6750
  S3_BUCKET_NAME: config.bucketName
6752
6751
  });
6753
- await fs$1.writeFile(indexPath, code);
6752
+ await fs.writeFile(indexPath, code);
6754
6753
  const lambdaClient = new Lambda({
6755
6754
  region: "us-east-1",
6756
6755
  credentials: this.credentials
@@ -6784,7 +6783,7 @@ var LambdaEdgeDeployer = class {
6784
6783
  Runtime: "nodejs22.x",
6785
6784
  Role: lambdaRoleArn,
6786
6785
  Handler: "index.handler",
6787
- Code: { ZipFile: await fs$1.readFile(zipFilePath) },
6786
+ Code: { ZipFile: await fs.readFile(zipFilePath) },
6788
6787
  Description: "Hot Updater Lambda@Edge function",
6789
6788
  Publish: true,
6790
6789
  Timeout: 10
@@ -6797,7 +6796,7 @@ var LambdaEdgeDeployer = class {
6797
6796
  message(`Function "${lambdaName}" already exists. Updating function code...`);
6798
6797
  const updateResp = await lambdaClient.updateFunctionCode({
6799
6798
  FunctionName: lambdaName,
6800
- ZipFile: await fs$1.readFile(zipFilePath),
6799
+ ZipFile: await fs.readFile(zipFilePath),
6801
6800
  Publish: true
6802
6801
  });
6803
6802
  message("Waiting for Lambda function update to complete...");
@@ -6829,7 +6828,7 @@ var LambdaEdgeDeployer = class {
6829
6828
  return `Updated Lambda "${lambdaName}" function`;
6830
6829
  } finally {
6831
6830
  removeTmpDir();
6832
- fs$1.rm(zipFilePath, { force: true });
6831
+ fs.rm(zipFilePath, { force: true });
6833
6832
  }
6834
6833
  }
6835
6834
  },
@@ -7321,7 +7320,7 @@ var SSMKeyPairManager = class {
7321
7320
  };
7322
7321
  //#endregion
7323
7322
  //#region iac/templates.ts
7324
- const getConfigTemplate = (build, { profile }) => {
7323
+ const getConfigScaffold = (build, { profile }) => {
7325
7324
  const storageConfig = {
7326
7325
  imports: [{
7327
7326
  pkg: "@hot-updater/aws",
@@ -7339,14 +7338,21 @@ const getConfigTemplate = (build, { profile }) => {
7339
7338
  cloudfrontDistributionId: process.env.HOT_UPDATER_CLOUDFRONT_DISTRIBUTION_ID!,
7340
7339
  })`
7341
7340
  };
7342
- let intermediate = "";
7343
- if (profile) intermediate = `
7341
+ let helperStatements = [];
7342
+ if (profile) helperStatements = [{
7343
+ name: "commonOptions",
7344
+ strategy: "merge-object",
7345
+ code: `
7344
7346
  const commonOptions = {
7345
7347
  bucketName: process.env.HOT_UPDATER_S3_BUCKET_NAME!,
7346
7348
  region: process.env.HOT_UPDATER_S3_REGION!,
7347
7349
  credentials: fromSSO({ profile: process.env.HOT_UPDATER_AWS_PROFILE! }),
7348
- };`.trim();
7349
- else intermediate = `
7350
+ };`.trim()
7351
+ }];
7352
+ else helperStatements = [{
7353
+ name: "commonOptions",
7354
+ strategy: "merge-object",
7355
+ code: `
7350
7356
  const commonOptions = {
7351
7357
  bucketName: process.env.HOT_UPDATER_S3_BUCKET_NAME!,
7352
7358
  region: process.env.HOT_UPDATER_S3_REGION!,
@@ -7354,13 +7360,14 @@ const commonOptions = {
7354
7360
  accessKeyId: process.env.HOT_UPDATER_S3_ACCESS_KEY_ID!,
7355
7361
  secretAccessKey: process.env.HOT_UPDATER_S3_SECRET_ACCESS_KEY!,
7356
7362
  },
7357
- };`.trim();
7358
- const builder = new ConfigBuilder().setBuildType(build).setStorage(storageConfig).setDatabase(databaseConfig);
7363
+ };`.trim()
7364
+ }];
7365
+ const builder = new ConfigBuilder().setBuildType(build).setStorage(storageConfig).setDatabase(databaseConfig).setIntermediateCode(helperStatements.map((statement) => statement.code.trim()).join("\n\n"));
7359
7366
  if (profile) builder.addImport({
7360
7367
  pkg: "@aws-sdk/credential-provider-sso",
7361
7368
  named: ["fromSSO"]
7362
7369
  });
7363
- return builder.setIntermediateCode(intermediate).getResult();
7370
+ return createHotUpdaterConfigScaffoldFromBuilder(builder, { helperStatements });
7364
7371
  };
7365
7372
  const SOURCE_TEMPLATE = `// Add this to your App.tsx
7366
7373
  import { HotUpdater } from "@hot-updater/react-native";
@@ -7530,7 +7537,7 @@ const runInit = async ({ build }) => {
7530
7537
  distributionId,
7531
7538
  accountId
7532
7539
  });
7533
- await fs.promises.writeFile("hot-updater.config.ts", getConfigTemplate(build, { profile: ssoProfile }));
7540
+ const configWriteResult = await writeHotUpdaterConfig(getConfigScaffold(build, { profile: ssoProfile }));
7534
7541
  await makeEnv({
7535
7542
  HOT_UPDATER_S3_BUCKET_NAME: bucketName,
7536
7543
  HOT_UPDATER_S3_REGION: bucketRegion,
@@ -7549,7 +7556,9 @@ const runInit = async ({ build }) => {
7549
7556
  });
7550
7557
  if (mode === "sso") await ensureInstallPackages({ devDependencies: ["@aws-sdk/credential-provider-sso"] });
7551
7558
  p.log.success("Generated '.env.hotupdater' file with AWS settings.");
7552
- p.log.success("Generated 'hot-updater.config.ts' file with AWS settings.");
7559
+ if (configWriteResult.status === "created") p.log.success("Generated 'hot-updater.config.ts' file with AWS settings.");
7560
+ else if (configWriteResult.status === "merged") p.log.success("Updated 'hot-updater.config.ts' file with AWS settings.");
7561
+ else p.log.warn(`Kept existing 'hot-updater.config.ts' unchanged: ${configWriteResult.reason}`);
7553
7562
  const sourceUrl = `https://${distributionDomain}/api/check-update`;
7554
7563
  p.note(transformTemplate(SOURCE_TEMPLATE, { source: sourceUrl }));
7555
7564
  p.log.message(`Next step: ${link("https://hot-updater.dev/docs/managed/aws#step-4-changeenv-file-optional")}`);
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as _$_hot_updater_plugin_core0 from "@hot-updater/plugin-core";
2
- import { StoragePlugin, StoragePluginHooks, StorageResolveContext } from "@hot-updater/plugin-core";
2
+ import { BlobDatabasePluginConfig, StoragePlugin, StoragePluginHooks, StorageResolveContext } from "@hot-updater/plugin-core";
3
3
  import { S3ClientConfig } from "@aws-sdk/client-s3";
4
4
 
5
5
  //#region src/s3Database.d.ts
6
- interface S3DatabaseConfig extends S3ClientConfig {
6
+ interface S3DatabaseConfig extends S3ClientConfig, BlobDatabasePluginConfig {
7
7
  bucketName: string;
8
8
  /**
9
9
  * CloudFront distribution ID used for cache invalidation.
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { S3ClientConfig } from "@aws-sdk/client-s3";
2
2
  import * as _$_hot_updater_plugin_core0 from "@hot-updater/plugin-core";
3
- import { StoragePlugin, StoragePluginHooks, StorageResolveContext } from "@hot-updater/plugin-core";
3
+ import { BlobDatabasePluginConfig, StoragePlugin, StoragePluginHooks, StorageResolveContext } from "@hot-updater/plugin-core";
4
4
 
5
5
  //#region src/s3Database.d.ts
6
- interface S3DatabaseConfig extends S3ClientConfig {
6
+ interface S3DatabaseConfig extends S3ClientConfig, BlobDatabasePluginConfig {
7
7
  bucketName: string;
8
8
  /**
9
9
  * CloudFront distribution ID used for cache invalidation.