@hot-updater/vercel 1.2.0-rc.5 → 1.2.0-rc.50

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.d.cts CHANGED
@@ -1,14 +1,15 @@
1
- import { StorageAdapterWith } from "@hot-updater/plugin-core";
1
+ import { Lazy, StorageAdapterWith } from "@hot-updater/plugin-core";
2
2
  import { PostgresConfig, postgres } from "@hot-updater/postgres";
3
3
  //#region src/vercelBlobStorage.d.ts
4
4
  interface VercelBlobStorageConfig {
5
5
  /**
6
6
  * The Blob store's read-write token, `vercel_blob_rw_<storeId>_<secret>`:
7
7
  * the `BLOB_READ_WRITE_TOKEN` Vercel adds to a project the store connects
8
- * to. Or a function that returns it, such as one that reads it with
9
- * `secretEnv`: called on first use, so a config loads without the token.
8
+ * to. Or a function that returns it, such as `secret("<name>")` in
9
+ * `hot-updater.config.ts`: called on first use, so a config loads without
10
+ * the token.
10
11
  */
11
- token: string | (() => string | Promise<string>);
12
+ token: Lazy<string>;
12
13
  /** Base path where bundles will be stored in the store. */
13
14
  basePath?: string;
14
15
  /**
package/dist/index.d.mts CHANGED
@@ -1,14 +1,15 @@
1
- import { StorageAdapterWith } from "@hot-updater/plugin-core";
1
+ import { Lazy, StorageAdapterWith } from "@hot-updater/plugin-core";
2
2
  import { PostgresConfig, postgres } from "@hot-updater/postgres";
3
3
  //#region src/vercelBlobStorage.d.ts
4
4
  interface VercelBlobStorageConfig {
5
5
  /**
6
6
  * The Blob store's read-write token, `vercel_blob_rw_<storeId>_<secret>`:
7
7
  * the `BLOB_READ_WRITE_TOKEN` Vercel adds to a project the store connects
8
- * to. Or a function that returns it, such as one that reads it with
9
- * `secretEnv`: called on first use, so a config loads without the token.
8
+ * to. Or a function that returns it, such as `secret("<name>")` in
9
+ * `hot-updater.config.ts`: called on first use, so a config loads without
10
+ * the token.
10
11
  */
11
- token: string | (() => string | Promise<string>);
12
+ token: Lazy<string>;
12
13
  /** Base path where bundles will be stored in the store. */
13
14
  basePath?: string;
14
15
  /**
@@ -6268,29 +6268,30 @@ createExeca(mapScriptAsync, {}, deepScriptOptions, setScriptSync);
6268
6268
  const { sendMessage, getOneMessage, getEachMessage, getCancelSignal } = getIpcExport();
6269
6269
  //#endregion
6270
6270
  //#region iac/configTemplate.ts
6271
- const getConfigScaffold = (build, { secretEnv } = { secretEnv: false }) => {
6272
- const read = (reader, name) => secretEnv ? `async () =>
6273
- (await ${reader}()).${name}` : `process.env.${name}!`;
6274
- const storageConfig = {
6271
+ /**
6272
+ * The config init and the agent scaffold write: the Blob token and the
6273
+ * database URL are read with `secret()`, from the environment and
6274
+ * `.env.hotupdater`, then the config's `secrets` adapter.
6275
+ */
6276
+ const getConfigScaffold = (build) => {
6277
+ const builder = new _hot_updater_cli_tools.ConfigBuilder().setBuildType(build).setStorage({
6275
6278
  imports: [{
6276
6279
  pkg: "@hot-updater/vercel",
6277
6280
  named: ["vercelBlobStorage"]
6278
6281
  }],
6279
6282
  configString: `vercelBlobStorage({
6280
- token: ${read("storageSecrets", "HOT_UPDATER_VERCEL_BLOB_READ_WRITE_TOKEN")},
6281
- })`
6282
- };
6283
- const databaseConfig = {
6283
+ token: secret("HOT_UPDATER_VERCEL_BLOB_READ_WRITE_TOKEN"),
6284
+ })`,
6285
+ removedOptions: ["access"]
6286
+ }).setDatabase({
6284
6287
  imports: [{
6285
6288
  pkg: "@hot-updater/vercel",
6286
6289
  named: ["postgres"]
6287
6290
  }],
6288
6291
  configString: `postgres({
6289
- connectionString: ${read("databaseSecrets", "HOT_UPDATER_VERCEL_DATABASE_URL")},
6292
+ connectionString: secret("HOT_UPDATER_VERCEL_DATABASE_URL"),
6290
6293
  })`
6291
- };
6292
- const helperStatements = secretEnv ? [(0, _hot_updater_cli_tools.secretEnvHelper)("storageSecrets", ["HOT_UPDATER_VERCEL_BLOB_READ_WRITE_TOKEN"]), (0, _hot_updater_cli_tools.secretEnvHelper)("databaseSecrets", ["HOT_UPDATER_VERCEL_DATABASE_URL"])] : [];
6293
- const builder = new _hot_updater_cli_tools.ConfigBuilder().setBuildType(build).setStorage(storageConfig).setDatabase(databaseConfig).setPlugins({
6294
+ }).setPlugins({
6294
6295
  imports: [{
6295
6296
  pkg: "hot-updater/plugins",
6296
6297
  named: [
@@ -6300,12 +6301,11 @@ const getConfigScaffold = (build, { secretEnv } = { secretEnv: false }) => {
6300
6301
  ]
6301
6302
  }],
6302
6303
  configString: "[apiKeys(), insights(), remoteConfig()]"
6303
- });
6304
- if (secretEnv) builder.addImport({
6304
+ }).addImport({
6305
6305
  pkg: "hot-updater",
6306
- named: ["secretEnv"]
6307
- }).setIntermediateCode(helperStatements.map(({ code }) => code).join("\n\n"));
6308
- return (0, _hot_updater_cli_tools.createHotUpdaterConfigScaffoldFromBuilder)(builder, { helperStatements });
6306
+ named: ["secret"]
6307
+ });
6308
+ return (0, _hot_updater_cli_tools.createHotUpdaterConfigScaffoldFromBuilder)(builder);
6309
6309
  };
6310
6310
  //#endregion
6311
6311
  //#region iac/init/index.ts
@@ -7019,7 +7019,7 @@ const runInit = async ({ build, envFile, secretsEnv }) => {
7019
7019
  const initEnvSources = await (0, _hot_updater_cli_tools.readHotUpdaterInitEnv)(cwd, envFile, secretsEnv);
7020
7020
  const { managedEnv } = initEnvSources;
7021
7021
  const initInputEnv = (0, _hot_updater_cli_tools.getHotUpdaterInitInputEnv)(initEnvSources, nonInteractive);
7022
- const saved = Object.fromEntries(Object.entries(inputs).map(([name, input]) => [name, initInputEnv[input.envKey]?.trim() || void 0]));
7022
+ const saved = (0, _hot_updater_cli_tools.resolveInitProviderInputs)(initInputEnv, initProvider);
7023
7023
  const token = await resolveVercelToken({
7024
7024
  cwd,
7025
7025
  nonInteractive,
@@ -7144,7 +7144,7 @@ const runInit = async ({ build, envFile, secretsEnv }) => {
7144
7144
  await database.dispose?.();
7145
7145
  }
7146
7146
  _hot_updater_cli_tools.p.log.success("Generated '.env.hotupdater' file with Vercel settings.");
7147
- await (0, _hot_updater_cli_tools.writeHotUpdaterFiles)(getConfigScaffold(build, { secretEnv: true }), {
7147
+ await (0, _hot_updater_cli_tools.writeHotUpdaterFiles)(getConfigScaffold(build), {
7148
7148
  cwd,
7149
7149
  settings: "Vercel"
7150
7150
  });
@@ -7153,8 +7153,7 @@ const runInit = async ({ build, envFile, secretsEnv }) => {
7153
7153
  ...credential === void 0 ? {} : { credential },
7154
7154
  clientPlugins: server.clientPlugins
7155
7155
  });
7156
- _hot_updater_cli_tools.p.log.message(`Next step: ${(0, _hot_updater_cli_tools.link)("https://hot-updater.dev/docs/managed/vercel#step-3-add-hotupdater-to-your-project")}`);
7157
- _hot_updater_cli_tools.p.log.success("Done! 🎉");
7156
+ return { nextSteps: [(0, _hot_updater_cli_tools.link)("https://hot-updater.dev/docs/managed/vercel#step-3-add-hotupdater-to-your-project")] };
7158
7157
  };
7159
7158
  //#endregion
7160
7159
  exports.VERCEL_FUNCTION_CONFIG = VERCEL_FUNCTION_CONFIG;
@@ -1,4 +1,4 @@
1
- import { RunInitOptions } from "@hot-updater/cli-tools";
1
+ import { RunInitOptions, RunInitResult } from "@hot-updater/cli-tools";
2
2
  //#region iac/init/index.d.ts
3
3
  declare const initProvider: {
4
4
  readonly label: "Vercel Blob + Functions + Postgres";
@@ -87,6 +87,6 @@ declare const VERCEL_FUNCTION_CONFIG: {
87
87
  };
88
88
  //#endregion
89
89
  //#region iac/index.d.ts
90
- declare const runInit: ({ build, envFile, secretsEnv }: RunInitOptions) => Promise<void>;
90
+ declare const runInit: ({ build, envFile, secretsEnv }: RunInitOptions) => Promise<RunInitResult>;
91
91
  //#endregion
92
92
  export { VERCEL_FUNCTION_CONFIG, initProvider, runInit };
@@ -1,4 +1,4 @@
1
- import { RunInitOptions } from "@hot-updater/cli-tools";
1
+ import { RunInitOptions, RunInitResult } from "@hot-updater/cli-tools";
2
2
  //#region iac/init/index.d.ts
3
3
  declare const initProvider: {
4
4
  readonly label: "Vercel Blob + Functions + Postgres";
@@ -87,6 +87,6 @@ declare const VERCEL_FUNCTION_CONFIG: {
87
87
  };
88
88
  //#endregion
89
89
  //#region iac/index.d.ts
90
- declare const runInit: ({ build, envFile, secretsEnv }: RunInitOptions) => Promise<void>;
90
+ declare const runInit: ({ build, envFile, secretsEnv }: RunInitOptions) => Promise<RunInitResult>;
91
91
  //#endregion
92
92
  export { VERCEL_FUNCTION_CONFIG, initProvider, runInit };
@@ -2,7 +2,7 @@ import { createRequire } from "node:module";
2
2
  import fs from "fs/promises";
3
3
  import os from "os";
4
4
  import path from "path";
5
- import { ConfigBuilder, InitError, LegacyInfrastructureError, assembleServer, assertInfrastructureGenerationPayload, confirmInitInputPersistence, createHotUpdaterConfigScaffoldFromBuilder, createMigrator, getCwd, getHotUpdaterInitInputEnv, getInitProviderEnvVars, getInitProviderTextPromptValues, link, makeEnv, p, printAppSetup, provisionClientCredential, readHotUpdaterInitEnv, secretEnvHelper, shouldAutoSelectOnlyInitResource, writeHotUpdaterFiles } from "@hot-updater/cli-tools";
5
+ import { ConfigBuilder, InitError, LegacyInfrastructureError, assembleServer, assertInfrastructureGenerationPayload, confirmInitInputPersistence, createHotUpdaterConfigScaffoldFromBuilder, createMigrator, getCwd, getHotUpdaterInitInputEnv, getInitProviderEnvVars, getInitProviderTextPromptValues, link, makeEnv, p, printAppSetup, provisionClientCredential, readHotUpdaterInitEnv, resolveInitProviderInputs, shouldAutoSelectOnlyInitResource, writeHotUpdaterFiles } from "@hot-updater/cli-tools";
6
6
  import { postgres } from "@hot-updater/postgres";
7
7
  import { apiKeys, insights, remoteConfig } from "@hot-updater/server/plugins";
8
8
  import { fileURLToPath } from "node:url";
@@ -6262,29 +6262,30 @@ createExeca(mapScriptAsync, {}, deepScriptOptions, setScriptSync);
6262
6262
  const { sendMessage, getOneMessage, getEachMessage, getCancelSignal } = getIpcExport();
6263
6263
  //#endregion
6264
6264
  //#region iac/configTemplate.ts
6265
- const getConfigScaffold = (build, { secretEnv } = { secretEnv: false }) => {
6266
- const read = (reader, name) => secretEnv ? `async () =>
6267
- (await ${reader}()).${name}` : `process.env.${name}!`;
6268
- const storageConfig = {
6265
+ /**
6266
+ * The config init and the agent scaffold write: the Blob token and the
6267
+ * database URL are read with `secret()`, from the environment and
6268
+ * `.env.hotupdater`, then the config's `secrets` adapter.
6269
+ */
6270
+ const getConfigScaffold = (build) => {
6271
+ const builder = new ConfigBuilder().setBuildType(build).setStorage({
6269
6272
  imports: [{
6270
6273
  pkg: "@hot-updater/vercel",
6271
6274
  named: ["vercelBlobStorage"]
6272
6275
  }],
6273
6276
  configString: `vercelBlobStorage({
6274
- token: ${read("storageSecrets", "HOT_UPDATER_VERCEL_BLOB_READ_WRITE_TOKEN")},
6275
- })`
6276
- };
6277
- const databaseConfig = {
6277
+ token: secret("HOT_UPDATER_VERCEL_BLOB_READ_WRITE_TOKEN"),
6278
+ })`,
6279
+ removedOptions: ["access"]
6280
+ }).setDatabase({
6278
6281
  imports: [{
6279
6282
  pkg: "@hot-updater/vercel",
6280
6283
  named: ["postgres"]
6281
6284
  }],
6282
6285
  configString: `postgres({
6283
- connectionString: ${read("databaseSecrets", "HOT_UPDATER_VERCEL_DATABASE_URL")},
6286
+ connectionString: secret("HOT_UPDATER_VERCEL_DATABASE_URL"),
6284
6287
  })`
6285
- };
6286
- const helperStatements = secretEnv ? [secretEnvHelper("storageSecrets", ["HOT_UPDATER_VERCEL_BLOB_READ_WRITE_TOKEN"]), secretEnvHelper("databaseSecrets", ["HOT_UPDATER_VERCEL_DATABASE_URL"])] : [];
6287
- const builder = new ConfigBuilder().setBuildType(build).setStorage(storageConfig).setDatabase(databaseConfig).setPlugins({
6288
+ }).setPlugins({
6288
6289
  imports: [{
6289
6290
  pkg: "hot-updater/plugins",
6290
6291
  named: [
@@ -6294,12 +6295,11 @@ const getConfigScaffold = (build, { secretEnv } = { secretEnv: false }) => {
6294
6295
  ]
6295
6296
  }],
6296
6297
  configString: "[apiKeys(), insights(), remoteConfig()]"
6297
- });
6298
- if (secretEnv) builder.addImport({
6298
+ }).addImport({
6299
6299
  pkg: "hot-updater",
6300
- named: ["secretEnv"]
6301
- }).setIntermediateCode(helperStatements.map(({ code }) => code).join("\n\n"));
6302
- return createHotUpdaterConfigScaffoldFromBuilder(builder, { helperStatements });
6300
+ named: ["secret"]
6301
+ });
6302
+ return createHotUpdaterConfigScaffoldFromBuilder(builder);
6303
6303
  };
6304
6304
  //#endregion
6305
6305
  //#region iac/init/index.ts
@@ -7013,7 +7013,7 @@ const runInit = async ({ build, envFile, secretsEnv }) => {
7013
7013
  const initEnvSources = await readHotUpdaterInitEnv(cwd, envFile, secretsEnv);
7014
7014
  const { managedEnv } = initEnvSources;
7015
7015
  const initInputEnv = getHotUpdaterInitInputEnv(initEnvSources, nonInteractive);
7016
- const saved = Object.fromEntries(Object.entries(inputs).map(([name, input]) => [name, initInputEnv[input.envKey]?.trim() || void 0]));
7016
+ const saved = resolveInitProviderInputs(initInputEnv, initProvider);
7017
7017
  const token = await resolveVercelToken({
7018
7018
  cwd,
7019
7019
  nonInteractive,
@@ -7138,7 +7138,7 @@ const runInit = async ({ build, envFile, secretsEnv }) => {
7138
7138
  await database.dispose?.();
7139
7139
  }
7140
7140
  p.log.success("Generated '.env.hotupdater' file with Vercel settings.");
7141
- await writeHotUpdaterFiles(getConfigScaffold(build, { secretEnv: true }), {
7141
+ await writeHotUpdaterFiles(getConfigScaffold(build), {
7142
7142
  cwd,
7143
7143
  settings: "Vercel"
7144
7144
  });
@@ -7147,8 +7147,7 @@ const runInit = async ({ build, envFile, secretsEnv }) => {
7147
7147
  ...credential === void 0 ? {} : { credential },
7148
7148
  clientPlugins: server.clientPlugins
7149
7149
  });
7150
- p.log.message(`Next step: ${link("https://hot-updater.dev/docs/managed/vercel#step-3-add-hotupdater-to-your-project")}`);
7151
- p.log.success("Done! 🎉");
7150
+ return { nextSteps: [link("https://hot-updater.dev/docs/managed/vercel#step-3-add-hotupdater-to-your-project")] };
7152
7151
  };
7153
7152
  //#endregion
7154
7153
  export { VERCEL_FUNCTION_CONFIG, initProvider, runInit };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/vercel",
3
3
  "type": "module",
4
- "version": "1.2.0-rc.5",
4
+ "version": "1.2.0-rc.50",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.mjs",
@@ -41,11 +41,11 @@
41
41
  "@vercel/cli-auth": "0.3.10",
42
42
  "@vercel/cli-config": "0.3.1",
43
43
  "pg": "8.13.1",
44
- "@hot-updater/cli-tools": "1.2.0-rc.5",
45
- "@hot-updater/plugin-core": "1.2.0-rc.5",
46
- "@hot-updater/postgres": "1.2.0-rc.5",
47
- "@hot-updater/protocol": "1.2.0-rc.5",
48
- "@hot-updater/server": "1.2.0-rc.5"
44
+ "@hot-updater/cli-tools": "1.2.0-rc.50",
45
+ "@hot-updater/plugin-core": "1.2.0-rc.50",
46
+ "@hot-updater/postgres": "1.2.0-rc.50",
47
+ "@hot-updater/protocol": "1.2.0-rc.50",
48
+ "@hot-updater/server": "1.2.0-rc.50"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/node": "^20",
@@ -54,7 +54,7 @@
54
54
  "execa": "9.5.2",
55
55
  "kysely": "0.28.17",
56
56
  "vitest": "4.1.4",
57
- "@hot-updater/test-utils": "1.2.0-rc.5"
57
+ "@hot-updater/test-utils": "1.2.0-rc.50"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "tsdown",