everything-dev 1.15.0 → 1.16.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.
package/src/near-cli.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { spawn } from "node:child_process";
2
1
  import { generateKeyPairSync } from "node:crypto";
3
2
  import { Effect } from "effect";
3
+ import { execa } from "execa";
4
4
 
5
5
  export interface NearTransactionConfig {
6
6
  account: string;
@@ -112,49 +112,34 @@ export function generateNearKeyPair(): NearKeyPair {
112
112
 
113
113
  const checkNearCliInstalled = Effect.tryPromise({
114
114
  try: async () => {
115
- return await new Promise<boolean>((resolve) => {
116
- const proc = spawn("near", ["--version"], { stdio: "pipe" });
117
- proc.on("close", (code) => resolve(code === 0));
118
- proc.on("error", () => resolve(false));
119
- });
115
+ try {
116
+ await execa("near", ["--version"], { stdio: "pipe" });
117
+ return true;
118
+ } catch {
119
+ return false;
120
+ }
120
121
  },
121
122
  catch: () => new Error("Failed to check NEAR CLI"),
122
123
  });
123
124
 
124
125
  const installNearCli = Effect.tryPromise({
125
126
  try: async () => {
126
- return await new Promise<void>((resolve, reject) => {
127
- const proc = spawn(
128
- "sh",
129
- ["-c", `curl --proto '=https' --tlsv1.2 -LsSf ${INSTALLER_URL} | sh`],
130
- {
131
- stdio: "inherit",
132
- },
133
- );
134
-
135
- proc.on("close", (code) => {
136
- if (code === 0) resolve();
137
- else reject(new NearCliInstallError(`Installer exited with code ${code}`));
138
- });
139
- proc.on("error", (err) => reject(new NearCliInstallError(err.message)));
127
+ await execa("sh", ["-c", `curl --proto '=https' --tlsv1.2 -LsSf ${INSTALLER_URL} | sh`], {
128
+ stdio: "inherit",
140
129
  });
141
130
  },
142
- catch: (error) => error as Error,
131
+ catch: (error) => {
132
+ if (error instanceof Error && "exitCode" in error) {
133
+ return new NearCliInstallError(
134
+ `Installer exited with code ${(error as { exitCode: number }).exitCode}`,
135
+ );
136
+ }
137
+ return new NearCliInstallError(error instanceof Error ? error.message : String(error));
138
+ },
143
139
  });
144
140
 
145
141
  async function runNearCommand(args: string[]): Promise<void> {
146
- await new Promise<void>((resolve, reject) => {
147
- const proc = spawn("near", args, {
148
- stdio: "inherit",
149
- });
150
-
151
- proc.on("close", (code) => {
152
- if (code === 0) resolve();
153
- else reject(new Error(`near ${args.join(" ")} failed with exit code ${code}`));
154
- });
155
-
156
- proc.on("error", (err) => reject(new Error(err.message)));
157
- });
142
+ await execa("near", args, { stdio: "inherit" });
158
143
  }
159
144
 
160
145
  export const ensureNearCli = Effect.gen(function* () {
@@ -209,43 +194,31 @@ export const executeTransaction = (
209
194
 
210
195
  const output = yield* Effect.tryPromise({
211
196
  try: async () => {
212
- return await new Promise<string>((resolve, reject) => {
213
- const proc = spawn("near", args, { stdio: ["inherit", "pipe", "pipe"] });
214
-
215
- let stdout = "";
216
- let stderr = "";
217
-
218
- proc.stdout?.on("data", (data) => {
219
- const text = data.toString();
220
- stdout += text;
221
- process.stdout.write(text);
222
- });
223
-
224
- proc.stderr?.on("data", (data) => {
225
- const text = data.toString();
226
- stderr += text;
227
- });
228
-
229
- proc.on("close", (code) => {
230
- const combined = `${stdout}\n${stderr}`;
231
- const txHashMatch = combined.match(/Transaction ID:\s*([A-Za-z0-9]+)/i);
232
- const hasCodeDoesNotExist = /CodeDoesNotExist/i.test(combined);
233
- const hasTransactionFailed = /Transaction failed/i.test(combined);
234
- const softSuccess =
235
- Boolean(txHashMatch?.[1]) && hasCodeDoesNotExist && hasTransactionFailed;
236
-
237
- if (code === 0 || softSuccess) {
238
- if (softSuccess) {
239
- console.log(` ${txHashMatch?.[1]} — FastDATA CodeDoesNotExist (expected)`);
240
- }
241
- resolve(combined);
242
- } else {
243
- reject(new NearTransactionError(stderr || `Transaction failed with code ${code}`));
244
- }
245
- });
246
-
247
- proc.on("error", (err) => reject(new NearTransactionError(err.message)));
197
+ const result = await execa("near", args, {
198
+ stdin: "inherit",
199
+ stdout: "pipe",
200
+ stderr: "pipe",
201
+ reject: false,
248
202
  });
203
+
204
+ process.stdout.write(result.stdout);
205
+ const combined = `${result.stdout}\n${result.stderr}`;
206
+ const txHashMatch = combined.match(/Transaction ID:\s*([A-Za-z0-9]+)/i);
207
+ const hasCodeDoesNotExist = /CodeDoesNotExist/i.test(combined);
208
+ const hasTransactionFailed = /Transaction failed/i.test(combined);
209
+ const softSuccess =
210
+ Boolean(txHashMatch?.[1]) && hasCodeDoesNotExist && hasTransactionFailed;
211
+
212
+ if (result.exitCode === 0 || softSuccess) {
213
+ if (softSuccess) {
214
+ console.log(` ${txHashMatch?.[1]} — FastDATA CodeDoesNotExist (expected)`);
215
+ }
216
+ return combined;
217
+ }
218
+
219
+ throw new NearTransactionError(
220
+ result.stderr || `Transaction failed with code ${result.exitCode}`,
221
+ );
249
222
  },
250
223
  catch: (error) => error as Error,
251
224
  });
package/src/plugin.ts CHANGED
@@ -1321,6 +1321,18 @@ export default createPlugin({
1321
1321
  }
1322
1322
  }
1323
1323
 
1324
+ extendsAccount = extendsAccount || "dev.everything.near";
1325
+ extendsGateway = extendsGateway || "everything.dev";
1326
+
1327
+ let parentPluginKeys: string[] = [];
1328
+ let parentConfig: BosConfig | null = null;
1329
+ try {
1330
+ parentConfig = await fetchParentConfig(extendsAccount, extendsGateway);
1331
+ if (parentConfig?.plugins && typeof parentConfig.plugins === "object") {
1332
+ parentPluginKeys = Object.keys(parentConfig.plugins);
1333
+ }
1334
+ } catch {}
1335
+
1324
1336
  if (!input.noInteractive) {
1325
1337
  const prompted = await promptInitOptions({
1326
1338
  extendsAccount,
@@ -1331,6 +1343,7 @@ export default createPlugin({
1331
1343
  domain,
1332
1344
  plugins,
1333
1345
  withHost,
1346
+ parentPluginKeys,
1334
1347
  });
1335
1348
  extendsAccount = prompted.extendsAccount;
1336
1349
  extendsGateway = prompted.extendsGateway;
@@ -1341,34 +1354,40 @@ export default createPlugin({
1341
1354
  plugins = prompted.plugins;
1342
1355
  }
1343
1356
 
1344
- extendsAccount = extendsAccount || "dev.everything.near";
1345
- extendsGateway = extendsGateway || "everything.dev";
1346
1357
  directory = directory || domain || extendsGateway;
1347
- plugins = plugins?.length ? plugins : ["settings"];
1358
+ plugins = plugins ?? [];
1348
1359
 
1349
- try {
1350
- await fetchParentConfig(extendsAccount, extendsGateway);
1351
- } catch {
1352
- return {
1353
- status: "error" as const,
1354
- directory,
1355
- extendsAccount,
1356
- extendsGateway,
1357
- account,
1358
- domain,
1359
- extends: `bos://${extendsAccount}/${extendsGateway}`,
1360
- plugins: plugins ?? [],
1361
- filesCopied: 0,
1362
- error: `No config found at bos://${extendsAccount}/${extendsGateway} — are you sure this is the right parent?`,
1363
- };
1360
+ if (!parentConfig) {
1361
+ try {
1362
+ parentConfig = await fetchParentConfig(extendsAccount, extendsGateway);
1363
+ } catch {
1364
+ return {
1365
+ status: "error" as const,
1366
+ directory,
1367
+ extendsAccount,
1368
+ extendsGateway,
1369
+ account,
1370
+ domain,
1371
+ extends: `bos://${extendsAccount}/${extendsGateway}`,
1372
+ plugins: plugins ?? [],
1373
+ filesCopied: 0,
1374
+ error: `No config found at bos://${extendsAccount}/${extendsGateway} — are you sure this is the right parent?`,
1375
+ };
1376
+ }
1364
1377
  }
1365
1378
 
1366
- const { sourceDir, parentConfig, cleanup } = await resolveSourceDir({
1379
+ const {
1380
+ sourceDir,
1381
+ parentConfig: resolvedParentConfig,
1382
+ cleanup,
1383
+ } = await resolveSourceDir({
1367
1384
  extendsAccount,
1368
1385
  extendsGateway,
1369
1386
  source: input.source,
1370
1387
  });
1371
1388
 
1389
+ parentConfig = resolvedParentConfig;
1390
+
1372
1391
  try {
1373
1392
  const patterns = await readTemplatekeep(sourceDir);
1374
1393
  if (patterns.length === 0) {