hot-updater 0.12.6 → 0.13.0

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.
@@ -1,2 +1,3 @@
1
1
  import type { PluginObj } from "@babel/core";
2
+ export declare const getChannel: () => string;
2
3
  export default function replaceHotUpdaterBundleId(): PluginObj;
@@ -1,9 +1,59 @@
1
1
  /*! For license information please see babel.js.LICENSE.txt */
2
2
  import __rslib_shim_module__ from 'module';
3
3
  /*#__PURE__*/ import.meta.url;
4
+ import * as __WEBPACK_EXTERNAL_MODULE_tty__ from "tty";
4
5
  import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
5
6
  import * as __WEBPACK_EXTERNAL_MODULE_path__ from "path";
7
+ import * as __WEBPACK_EXTERNAL_MODULE__hot_updater_plugin_core_40c1c502__ from "@hot-updater/plugin-core";
6
8
  var __webpack_modules__ = {
9
+ "../../node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors/picocolors.js": function(module, __unused_webpack_exports, __webpack_require__) {
10
+ let tty = __webpack_require__("tty");
11
+ let isColorSupported = !("NO_COLOR" in process.env || process.argv.includes("--no-color")) && ("FORCE_COLOR" in process.env || process.argv.includes("--color") || "win32" === process.platform || tty.isatty(1) && "dumb" !== process.env.TERM || "CI" in process.env);
12
+ let formatter = (open, close, replace = open)=>(input)=>{
13
+ let string = "" + input;
14
+ let index = string.indexOf(close, open.length);
15
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
16
+ };
17
+ let replaceClose = (string, close, replace, index)=>{
18
+ let start = string.substring(0, index) + replace;
19
+ let end = string.substring(index + close.length);
20
+ let nextIndex = end.indexOf(close);
21
+ return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end;
22
+ };
23
+ let createColors = (enabled = isColorSupported)=>({
24
+ isColorSupported: enabled,
25
+ reset: enabled ? (s)=>`\x1b[0m${s}\x1b[0m` : String,
26
+ bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
27
+ dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
28
+ italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
29
+ underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
30
+ inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
31
+ hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
32
+ strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
33
+ black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
34
+ red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
35
+ green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
36
+ yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
37
+ blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
38
+ magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
39
+ cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
40
+ white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
41
+ gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
42
+ bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
43
+ bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
44
+ bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
45
+ bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
46
+ bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
47
+ bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
48
+ bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
49
+ bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String
50
+ });
51
+ module.exports = createColors();
52
+ module.exports.createColors = createColors;
53
+ },
54
+ tty: function(module) {
55
+ module.exports = __WEBPACK_EXTERNAL_MODULE_tty__;
56
+ },
7
57
  "../../node_modules/.pnpm/@babel+helper-string-parser@7.25.9/node_modules/@babel/helper-string-parser/lib/index.js": function(__unused_webpack_module, exports) {
8
58
  Object.defineProperty(exports, "__esModule", {
9
59
  value: true
@@ -16790,7 +16840,29 @@ function __webpack_require__(moduleId) {
16790
16840
  __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
16791
16841
  return module.exports;
16792
16842
  }
16843
+ (()=>{
16844
+ __webpack_require__.n = (module)=>{
16845
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
16846
+ __webpack_require__.d(getter, {
16847
+ a: getter
16848
+ });
16849
+ return getter;
16850
+ };
16851
+ })();
16852
+ (()=>{
16853
+ __webpack_require__.d = (exports, definition)=>{
16854
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
16855
+ enumerable: true,
16856
+ get: definition[key]
16857
+ });
16858
+ };
16859
+ })();
16860
+ (()=>{
16861
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
16862
+ })();
16793
16863
  var lib = __webpack_require__("../../node_modules/.pnpm/@babel+types@7.26.0/node_modules/@babel/types/lib/index.js");
16864
+ var picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors/picocolors.js");
16865
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
16794
16866
  /**
16795
16867
  * uuidv7: A JavaScript implementation of UUID version 7
16796
16868
  *
@@ -16976,24 +17048,28 @@ class BufferedCryptoRandom {
16976
17048
  let defaultGenerator;
16977
17049
  const uuidv7 = ()=>uuidv7obj().toString();
16978
17050
  const uuidv7obj = ()=>(defaultGenerator || (defaultGenerator = new V7Generator())).generate();
16979
- function replaceHotUpdaterBundleId() {
17051
+ const NIL_UUID = "00000000-0000-0000-0000-000000000000";
17052
+ const getBundleId = ()=>{
16980
17053
  const buildOutDir = process.env["BUILD_OUT_DIR"];
16981
- if (!buildOutDir) return {
16982
- name: "replace-hot-updater-bundle-id",
16983
- visitor: {
16984
- MemberExpression (path) {
16985
- if (lib.isIdentifier(path.node.object, {
16986
- name: "HotUpdater"
16987
- }) && lib.isIdentifier(path.node.property, {
16988
- name: "HOT_UPDATER_BUNDLE_ID"
16989
- })) path.replaceWith(lib.stringLiteral("00000000-0000-0000-0000-000000000000"));
16990
- }
16991
- }
16992
- };
17054
+ if (!buildOutDir) return NIL_UUID;
16993
17055
  const bundleIdPath = __WEBPACK_EXTERNAL_MODULE_path__["default"].join(buildOutDir, "BUNDLE_ID");
16994
17056
  let bundleId = uuidv7();
16995
17057
  if (__WEBPACK_EXTERNAL_MODULE_fs__["default"].existsSync(bundleIdPath)) bundleId = __WEBPACK_EXTERNAL_MODULE_fs__["default"].readFileSync(bundleIdPath, "utf-8");
16996
- else __WEBPACK_EXTERNAL_MODULE_fs__["default"].writeFileSync(bundleIdPath, bundleId);
17058
+ else {
17059
+ __WEBPACK_EXTERNAL_MODULE_fs__["default"].writeFileSync(bundleIdPath, bundleId);
17060
+ console.log(picocolors_default().green(`[HotUpdater] Generated bundle ID: ${bundleId}`));
17061
+ }
17062
+ return bundleId;
17063
+ };
17064
+ const getChannel = ()=>{
17065
+ const envChannel = process.env["HOT_UPDATER_CHANNEL"];
17066
+ if (envChannel) return envChannel;
17067
+ const { releaseChannel } = (0, __WEBPACK_EXTERNAL_MODULE__hot_updater_plugin_core_40c1c502__.loadConfigSync)(null);
17068
+ return releaseChannel;
17069
+ };
17070
+ function replaceHotUpdaterBundleId() {
17071
+ const bundleId = getBundleId();
17072
+ const channel = getChannel();
16997
17073
  return {
16998
17074
  name: "replace-hot-updater-bundle-id",
16999
17075
  visitor: {
@@ -17003,8 +17079,13 @@ function replaceHotUpdaterBundleId() {
17003
17079
  }) && lib.isIdentifier(path.node.property, {
17004
17080
  name: "HOT_UPDATER_BUNDLE_ID"
17005
17081
  })) path.replaceWith(lib.stringLiteral(bundleId));
17082
+ if (lib.isIdentifier(path.node.object, {
17083
+ name: "HotUpdater"
17084
+ }) && lib.isIdentifier(path.node.property, {
17085
+ name: "CHANNEL"
17086
+ })) path.replaceWith(lib.stringLiteral(channel));
17006
17087
  }
17007
17088
  }
17008
17089
  };
17009
17090
  }
17010
- export { replaceHotUpdaterBundleId as default };
17091
+ export { replaceHotUpdaterBundleId as default, getChannel };
@@ -0,0 +1 @@
1
+ export declare const printBanner: () => void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hot-updater",
3
3
  "type": "module",
4
- "version": "0.12.6",
4
+ "version": "0.13.0",
5
5
  "bin": {
6
6
  "hot-updater": "./dist/index.js"
7
7
  },
@@ -48,35 +48,32 @@
48
48
  "access": "public"
49
49
  },
50
50
  "dependencies": {
51
- "@clack/prompts": "^0.9.0",
52
- "@hot-updater/console": "0.12.6",
53
- "@hot-updater/core": "0.12.6",
54
- "@hot-updater/plugin-core": "0.12.6",
51
+ "@clack/prompts": "^0.10.0",
52
+ "@hot-updater/console": "0.13.0",
53
+ "@hot-updater/core": "0.13.0",
54
+ "@hot-updater/plugin-core": "0.13.0",
55
55
  "commander": "^11.1.0",
56
56
  "cosmiconfig": "^9.0.0",
57
57
  "cosmiconfig-typescript-loader": "^5.0.0"
58
58
  },
59
59
  "devDependencies": {
60
- "@babel/parser": "^7.26.9",
61
- "@babel/generator": "^7.26.9",
62
- "@types/babel__generator": "^7.6.8",
63
- "@babel/core": "^7.26.0",
64
- "@babel/traverse": "^7.25.9",
65
- "@babel/types": "^7.26.0",
60
+ "@babel/core": "7.26.0",
61
+ "@babel/traverse": "7.25.9",
62
+ "@babel/types": "7.26.0",
63
+ "@babel/parser": "7.26.9",
64
+ "@babel/generator": "7.26.9",
65
+ "@types/babel__generator": "7.6.8",
66
66
  "@hono/node-server": "^1.13.4",
67
- "@types/babel__core": "^7.20.5",
68
- "@types/babel__traverse": "^7.20.6",
67
+ "@types/babel__core": "7.20.5",
68
+ "@types/babel__traverse": "7.20.6",
69
69
  "@types/connect": "^3.4.38",
70
70
  "@types/cosmiconfig": "^6.0.0",
71
71
  "@types/node": "^22.9.0",
72
72
  "@types/plist": "^3.0.5",
73
73
  "@types/semver": "^7.5.8",
74
- "boxen": "^8.0.1",
75
- "dayjs": "^1.11.13",
76
74
  "es-toolkit": "^1.32.0",
77
75
  "execa": "^9.5.2",
78
76
  "is-port-reachable": "^4.0.0",
79
- "jszip": "^3.10.1",
80
77
  "open": "^10.1.0",
81
78
  "picocolors": "^1.0.0",
82
79
  "plist": "^3.1.0",
@@ -1 +0,0 @@
1
- export declare const getSupabaseEnv: () => Promise<void>;
@@ -1 +0,0 @@
1
- export declare const getPluginEnv: () => Promise<void>;
@@ -1,33 +0,0 @@
1
- import type { BucketLocationConstraint } from "@hot-updater/aws/sdk";
2
- export declare function createOrSelectIamRole({ region, credentials, }: {
3
- region: BucketLocationConstraint;
4
- credentials: {
5
- accessKeyId: string;
6
- secretAccessKey: string;
7
- };
8
- }): Promise<string>;
9
- /**
10
- * Deploy Lambda@Edge function
11
- * - Zip the local ./lambda folder, create a function in us-east-1 region,
12
- * - Publish a new version of the function
13
- */
14
- export declare const deployLambdaEdge: ({ region, bucketName, credentials, lambdaRoleArn, }: {
15
- region: BucketLocationConstraint;
16
- bucketName: string;
17
- credentials: {
18
- accessKeyId: string;
19
- secretAccessKey: string;
20
- };
21
- lambdaRoleArn: string;
22
- }) => Promise<{
23
- lambdaName: string;
24
- functionArn: string;
25
- }>;
26
- export declare const createCloudFrontDistribution: (credentials: {
27
- accessKeyId: string;
28
- secretAccessKey: string;
29
- } | undefined, region: string, bucketName: string, functionArn: string) => Promise<{
30
- distributionId: string;
31
- distributionDomain: string;
32
- }>;
33
- export declare const initAwsS3LambdaEdge: () => Promise<void>;
@@ -1,2 +0,0 @@
1
- import type { BucketLocationConstraint } from "@hot-updater/aws/sdk";
2
- export declare const regionLocationMap: Record<BucketLocationConstraint | "ap-southeast-4" | "ap-southeast-5" | "il-central-1" | "me-central-1", string>;
@@ -1 +0,0 @@
1
- export declare const transformEnv: <T extends Record<string, string>>(code: string, env: T) => Promise<string>;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export declare const initCloudflareD1R2Worker: () => Promise<void>;
@@ -1 +0,0 @@
1
- export declare const initSupabase: () => Promise<void>;
@@ -1,8 +0,0 @@
1
- import type { SupabaseApi } from "@hot-updater/supabase";
2
- export declare const selectOrCreateOrganization: () => Promise<void>;
3
- export declare const selectProject: () => Promise<{
4
- id: string;
5
- name: string;
6
- region: string;
7
- }>;
8
- export declare const selectBucket: (api: SupabaseApi) => Promise<string>;
@@ -1,3 +0,0 @@
1
- export declare const link: (url: string) => string;
2
- export declare const banner: string;
3
- export declare const printBanner: () => void;
@@ -1,5 +0,0 @@
1
- export declare const createZip: ({ outfile, targetDir, excludeExts, }: {
2
- targetDir: string;
3
- outfile: string;
4
- excludeExts?: string[];
5
- }) => Promise<string>;
@@ -1,6 +0,0 @@
1
- type EnvVarValue = string | {
2
- comment: string;
3
- value: string;
4
- };
5
- export declare const makeEnv: (newEnvVars: Record<string, EnvVarValue>, filePath?: string) => Promise<string>;
6
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +0,0 @@
1
- type ExtractPlaceholders<T extends string> = T extends `${infer _Start}%%${infer Key}%%${infer Rest}` ? Key | ExtractPlaceholders<Rest> : never;
2
- type TransformTemplateArgs<T extends string> = {
3
- [Key in ExtractPlaceholders<T>]: string;
4
- };
5
- /**
6
- * Replaces placeholders in the format %%key%% in a template string with values from the values object.
7
- * Uses generic type T to automatically infer placeholder keys from the template string to ensure type safety.
8
- *
9
- * @example
10
- * const str = "Hello %%name%%, you are %%age%% years old."
11
- * const result = transformTemplate(str, { name: "John", age: "20" })
12
- * // Result: "Hello John, you are 20 years old."
13
- */
14
- export declare function transformTemplate<T extends string>(templateString: T, values: TransformTemplateArgs<T>): string;
15
- export {};