dynamodb-reactive 0.7.0 → 0.7.2
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/hub-cli.js +19 -7
- package/package.json +1 -1
package/dist/hub-cli.js
CHANGED
|
@@ -6,9 +6,8 @@ import { parseArgs } from "util";
|
|
|
6
6
|
// src/hub-deploy.ts
|
|
7
7
|
import { spawnSync } from "child_process";
|
|
8
8
|
import { createHmac } from "crypto";
|
|
9
|
-
import {
|
|
9
|
+
import { existsSync, readFileSync, rmSync, writeFileSync } from "fs";
|
|
10
10
|
import { createRequire } from "module";
|
|
11
|
-
import { tmpdir } from "os";
|
|
12
11
|
import path from "path";
|
|
13
12
|
|
|
14
13
|
// ../client/src/cloudflare-hub.ts
|
|
@@ -23,6 +22,7 @@ var HUB_DURABLE_OBJECT = { className: "ReactiveHub", binding: "REACTIVE_HUB" };
|
|
|
23
22
|
// src/hub-deploy.ts
|
|
24
23
|
var HUB_MIGRATION_TAG = "dynamodb-reactive-hub-v1";
|
|
25
24
|
var DEFAULT_COMPATIBILITY_DATE = "2026-09-01";
|
|
25
|
+
var HUB_CONFIG_FILE = ".dynamodb-reactive-hub.wrangler.json";
|
|
26
26
|
function hubWranglerConfig(options) {
|
|
27
27
|
return {
|
|
28
28
|
name: options.name,
|
|
@@ -45,9 +45,23 @@ function hubSecretValues(root, name) {
|
|
|
45
45
|
[HUB_ENV.NOTIFY_SECRET]: derive(`${name}-notify`)
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function wranglerBin() {
|
|
49
49
|
const require2 = createRequire(path.join(process.cwd(), "package.json"));
|
|
50
|
-
|
|
50
|
+
let directory = path.dirname(require2.resolve("wrangler"));
|
|
51
|
+
for (; ; ) {
|
|
52
|
+
const manifestPath = path.join(directory, "package.json");
|
|
53
|
+
if (existsSync(manifestPath)) {
|
|
54
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
55
|
+
const bin = typeof manifest.bin === "string" ? manifest.bin : manifest.bin?.wrangler;
|
|
56
|
+
if (manifest.name === "wrangler" && bin) return path.join(directory, bin);
|
|
57
|
+
}
|
|
58
|
+
const parent = path.dirname(directory);
|
|
59
|
+
if (parent === directory) throw new Error("wrangler is not installed");
|
|
60
|
+
directory = parent;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function wrangler(args, input) {
|
|
64
|
+
const bin = wranglerBin();
|
|
51
65
|
const result = spawnSync(process.execPath, [bin, ...args], {
|
|
52
66
|
stdio: [input === void 0 ? "inherit" : "pipe", "inherit", "inherit"],
|
|
53
67
|
...input === void 0 ? {} : { input }
|
|
@@ -63,15 +77,13 @@ function deployHub(options) {
|
|
|
63
77
|
if (!root) throw new Error(`${options.secretRootEnv} is not set`);
|
|
64
78
|
secrets = hubSecretValues(root, options.name);
|
|
65
79
|
}
|
|
66
|
-
const
|
|
67
|
-
const config = path.join(directory, "wrangler.json");
|
|
80
|
+
const config = path.resolve(HUB_CONFIG_FILE);
|
|
68
81
|
try {
|
|
69
82
|
writeFileSync(config, JSON.stringify(hubWranglerConfig(options), null, 2));
|
|
70
83
|
wrangler(["deploy", "--config", config]);
|
|
71
84
|
if (secrets) wrangler(["secret", "bulk", "--config", config], JSON.stringify(secrets));
|
|
72
85
|
} finally {
|
|
73
86
|
rmSync(config, { force: true });
|
|
74
|
-
rmdirSync(directory);
|
|
75
87
|
}
|
|
76
88
|
}
|
|
77
89
|
|