everything-dev 0.1.2 → 0.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "everything-dev",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
package/src/lib/nova.ts CHANGED
@@ -20,7 +20,7 @@ export interface UploadResult {
20
20
 
21
21
  export const getNovaConfig = Effect.gen(function* () {
22
22
  const accountId = process.env.NOVA_ACCOUNT_ID;
23
- const sessionToken = process.env.NOVA_SESSION_TOKEN;
23
+ const sessionToken = process.env.NOVA_API_KEY;
24
24
 
25
25
  if (!accountId || !sessionToken) {
26
26
  return yield* Effect.fail(
@@ -46,7 +46,7 @@ export function getSecretsGroupId(nearAccount: string): string {
46
46
  export const registerSecretsGroup = (
47
47
  nova: NovaSdk,
48
48
  nearAccount: string,
49
- gatewayAccount: string
49
+ novaAccount: string
50
50
  ) =>
51
51
  Effect.gen(function* () {
52
52
  const groupId = getSecretsGroupId(nearAccount);
@@ -57,8 +57,8 @@ export const registerSecretsGroup = (
57
57
  });
58
58
 
59
59
  yield* Effect.tryPromise({
60
- try: () => nova.addGroupMember(groupId, gatewayAccount),
61
- catch: (e) => new Error(`Failed to add gateway to NOVA group: ${e}`),
60
+ try: () => nova.addGroupMember(groupId, novaAccount),
61
+ catch: (e) => new Error(`Failed to add gateway Nova account to group: ${e}`),
62
62
  });
63
63
 
64
64
  return groupId;
@@ -150,7 +150,7 @@ export function filterSecretsToRequired(
150
150
  }
151
151
 
152
152
  export function hasNovaCredentials(): boolean {
153
- return !!(process.env.NOVA_ACCOUNT_ID && process.env.NOVA_SESSION_TOKEN);
153
+ return !!(process.env.NOVA_ACCOUNT_ID && process.env.NOVA_API_KEY);
154
154
  }
155
155
 
156
156
  function getBosEnvPath(): string {
@@ -182,8 +182,8 @@ export const saveNovaCredentials = (accountId: string, sessionToken: string) =>
182
182
  if (trimmed.startsWith("NOVA_ACCOUNT_ID=")) {
183
183
  newLines.push(`NOVA_ACCOUNT_ID=${accountId}`);
184
184
  foundAccountId = true;
185
- } else if (trimmed.startsWith("NOVA_SESSION_TOKEN=")) {
186
- newLines.push(`NOVA_SESSION_TOKEN=${sessionToken}`);
185
+ } else if (trimmed.startsWith("NOVA_API_KEY=")) {
186
+ newLines.push(`NOVA_API_KEY=${sessionToken}`);
187
187
  foundSessionToken = true;
188
188
  } else {
189
189
  newLines.push(line);
@@ -198,7 +198,7 @@ export const saveNovaCredentials = (accountId: string, sessionToken: string) =>
198
198
  }
199
199
 
200
200
  if (!foundSessionToken) {
201
- newLines.push(`NOVA_SESSION_TOKEN=${sessionToken}`);
201
+ newLines.push(`NOVA_API_KEY=${sessionToken}`);
202
202
  }
203
203
 
204
204
  yield* Effect.tryPromise({
@@ -207,7 +207,7 @@ export const saveNovaCredentials = (accountId: string, sessionToken: string) =>
207
207
  });
208
208
 
209
209
  process.env.NOVA_ACCOUNT_ID = accountId;
210
- process.env.NOVA_SESSION_TOKEN = sessionToken;
210
+ process.env.NOVA_API_KEY = sessionToken;
211
211
  });
212
212
 
213
213
  export const removeNovaCredentials = Effect.gen(function* () {
@@ -226,7 +226,7 @@ export const removeNovaCredentials = Effect.gen(function* () {
226
226
  const lines = content.split("\n");
227
227
  const newLines = lines.filter((line) => {
228
228
  const trimmed = line.trim();
229
- return !trimmed.startsWith("NOVA_ACCOUNT_ID=") && !trimmed.startsWith("NOVA_SESSION_TOKEN=");
229
+ return !trimmed.startsWith("NOVA_ACCOUNT_ID=") && !trimmed.startsWith("NOVA_API_KEY=");
230
230
  });
231
231
 
232
232
  yield* Effect.tryPromise({
@@ -235,7 +235,7 @@ export const removeNovaCredentials = Effect.gen(function* () {
235
235
  });
236
236
 
237
237
  delete process.env.NOVA_ACCOUNT_ID;
238
- delete process.env.NOVA_SESSION_TOKEN;
238
+ delete process.env.NOVA_API_KEY;
239
239
  });
240
240
 
241
241
  export const verifyNovaCredentials = (accountId: string, sessionToken: string) =>
@@ -117,6 +117,46 @@ const detectStatus = (
117
117
  return null;
118
118
  };
119
119
 
120
+ const killProcessTree = (pid: number) =>
121
+ Effect.gen(function* () {
122
+ const killSignal = (signal: NodeJS.Signals) =>
123
+ Effect.try({
124
+ try: () => {
125
+ process.kill(-pid, signal);
126
+ },
127
+ catch: () => null,
128
+ }).pipe(Effect.ignore);
129
+
130
+ const killDirect = (signal: NodeJS.Signals) =>
131
+ Effect.try({
132
+ try: () => {
133
+ process.kill(pid, signal);
134
+ },
135
+ catch: () => null,
136
+ }).pipe(Effect.ignore);
137
+
138
+ const isRunning = () =>
139
+ Effect.try({
140
+ try: () => {
141
+ process.kill(pid, 0);
142
+ return true;
143
+ },
144
+ catch: () => false,
145
+ });
146
+
147
+ yield* killSignal("SIGTERM");
148
+ yield* killDirect("SIGTERM");
149
+
150
+ yield* Effect.sleep("200 millis");
151
+
152
+ const stillRunning = yield* isRunning();
153
+ if (stillRunning) {
154
+ yield* killSignal("SIGKILL");
155
+ yield* killDirect("SIGKILL");
156
+ yield* Effect.sleep("100 millis");
157
+ }
158
+ });
159
+
120
160
  export const spawnDevProcess = (
121
161
  config: DevProcess,
122
162
  callbacks: ProcessCallbacks
@@ -181,11 +221,16 @@ export const spawnDevProcess = (
181
221
  name: config.name,
182
222
  pid: proc.pid,
183
223
  kill: async () => {
184
- proc.kill("SIGTERM");
185
- await new Promise((r) => setTimeout(r, 100));
186
- try {
187
- proc.kill("SIGKILL");
188
- } catch { }
224
+ const pid = proc.pid;
225
+ if (pid) {
226
+ await Effect.runPromise(killProcessTree(pid));
227
+ } else {
228
+ proc.kill("SIGTERM");
229
+ await new Promise((r) => setTimeout(r, 100));
230
+ try {
231
+ proc.kill("SIGKILL");
232
+ } catch { }
233
+ }
189
234
  },
190
235
  waitForReady: Deferred.await(readyDeferred),
191
236
  waitForExit: Effect.gen(function* () {
package/src/plugin.ts CHANGED
@@ -756,7 +756,12 @@ export default createPlugin({
756
756
  const novaConfig = yield* getNovaConfig;
757
757
  const nova = createNovaClient(novaConfig);
758
758
 
759
- yield* registerSecretsGroup(nova, fullAccount, parentAccount);
759
+ const gatewayNovaAccount = bosConfig.gateway?.nova?.account;
760
+ if (!gatewayNovaAccount) {
761
+ return yield* Effect.fail(new Error("gateway.nova.account is required for secrets registration"));
762
+ }
763
+
764
+ yield* registerSecretsGroup(nova, fullAccount, gatewayNovaAccount);
760
765
 
761
766
  return {
762
767
  status: "registered" as const,
@@ -1101,7 +1106,7 @@ export default createPlugin({
1101
1106
 
1102
1107
  try {
1103
1108
  const gatewayDomain = getGatewayDomain(bosConfig);
1104
- const gatewayAccount = bosConfig.account;
1109
+ const gatewayAccount = bosConfig.gateway?.account || bosConfig.account;
1105
1110
 
1106
1111
  const wranglerContent = await Bun.file(wranglerPath).text();
1107
1112
 
package/src/types.ts CHANGED
@@ -30,9 +30,16 @@ export const RemoteConfigSchema = z.object({
30
30
  });
31
31
  export type RemoteConfig = z.infer<typeof RemoteConfigSchema>;
32
32
 
33
+ export const NovaConfigSchema = z.object({
34
+ account: z.string(),
35
+ });
36
+ export type NovaConfig = z.infer<typeof NovaConfigSchema>;
37
+
33
38
  export const GatewayConfigSchema = z.object({
34
39
  development: z.string(),
35
40
  production: z.string(),
41
+ account: z.string().optional(),
42
+ nova: NovaConfigSchema.optional(),
36
43
  });
37
44
  export type GatewayConfig = z.infer<typeof GatewayConfigSchema>;
38
45
 
@@ -54,6 +61,7 @@ export type SyncConfig = z.infer<typeof SyncConfigSchema>;
54
61
  export const BosConfigSchema = z.object({
55
62
  account: z.string(),
56
63
  testnet: z.string().optional(),
64
+ nova: NovaConfigSchema.optional(),
57
65
  gateway: GatewayConfigSchema,
58
66
  template: z.string().optional(),
59
67
  cli: z.object({