everything-dev 1.27.0 → 1.28.1
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/cli/infra.cjs +1 -1
- package/dist/cli/infra.mjs +1 -1
- package/dist/cli/init.cjs +34 -9
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.d.cts +2 -1
- package/dist/cli/init.d.cts.map +1 -1
- package/dist/cli/init.d.mts +2 -1
- package/dist/cli/init.d.mts.map +1 -1
- package/dist/cli/init.mjs +34 -9
- package/dist/cli/init.mjs.map +1 -1
- package/dist/cli/prompts.cjs +28 -24
- package/dist/cli/prompts.cjs.map +1 -1
- package/dist/cli/prompts.mjs +27 -24
- package/dist/cli/prompts.mjs.map +1 -1
- package/dist/cli/sync.cjs +40 -3
- package/dist/cli/sync.cjs.map +1 -1
- package/dist/cli/sync.mjs +40 -3
- package/dist/cli/sync.mjs.map +1 -1
- package/dist/cli.cjs +187 -12
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +186 -11
- package/dist/cli.mjs.map +1 -1
- package/dist/config.cjs +1 -0
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +1 -0
- package/dist/config.mjs.map +1 -1
- package/dist/contract.cjs +1 -1
- package/dist/contract.cjs.map +1 -1
- package/dist/contract.d.cts +38 -34
- package/dist/contract.d.cts.map +1 -1
- package/dist/contract.d.mts +38 -34
- package/dist/contract.d.mts.map +1 -1
- package/dist/contract.mjs +1 -0
- package/dist/contract.mjs.map +1 -1
- package/dist/dev-session.cjs +0 -1
- package/dist/dev-session.mjs +1 -1
- package/dist/index.cjs +0 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +0 -1
- package/dist/near-cli.cjs +1 -1
- package/dist/near-cli.mjs +1 -1
- package/dist/orchestrator.cjs +1 -1
- package/dist/orchestrator.mjs +1 -1
- package/dist/plugin.cjs +183 -151
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +67 -34
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +66 -34
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +173 -142
- package/dist/plugin.mjs.map +1 -1
- package/dist/service-descriptor.d.cts +34 -0
- package/dist/service-descriptor.d.cts.map +1 -0
- package/dist/service-descriptor.d.mts +36 -0
- package/dist/service-descriptor.d.mts.map +1 -0
- package/dist/types.d.cts +2 -2
- package/dist/types.d.mts +2 -2
- package/dist/utils/run.cjs +9 -20
- package/dist/utils/run.cjs.map +1 -1
- package/dist/utils/run.mjs +9 -20
- package/dist/utils/run.mjs.map +1 -1
- package/package.json +2 -2
- package/src/api-contract.ts +0 -623
- package/src/app.ts +0 -193
- package/src/cli/catalog.ts +0 -49
- package/src/cli/framework-version.ts +0 -61
- package/src/cli/help.ts +0 -13
- package/src/cli/infra.ts +0 -190
- package/src/cli/init.ts +0 -1145
- package/src/cli/parse.ts +0 -147
- package/src/cli/prompts.ts +0 -135
- package/src/cli/snapshot.ts +0 -46
- package/src/cli/status.ts +0 -99
- package/src/cli/sync.ts +0 -429
- package/src/cli/timing.ts +0 -63
- package/src/cli/upgrade.ts +0 -869
- package/src/cli.ts +0 -516
- package/src/components/dev-view.tsx +0 -352
- package/src/components/streaming-view.ts +0 -177
- package/src/config.ts +0 -893
- package/src/contract.meta.ts +0 -140
- package/src/contract.ts +0 -326
- package/src/dev-logs.ts +0 -92
- package/src/dev-session.ts +0 -283
- package/src/fastkv.ts +0 -181
- package/src/index.ts +0 -8
- package/src/integrity.ts +0 -138
- package/src/internal/manifest-normalizer.ts +0 -290
- package/src/merge.ts +0 -187
- package/src/mf.ts +0 -147
- package/src/near-cli.ts +0 -259
- package/src/network.ts +0 -3
- package/src/orchestrator.ts +0 -493
- package/src/plugin.ts +0 -1799
- package/src/sdk.ts +0 -14
- package/src/service-descriptor.ts +0 -281
- package/src/shared.ts +0 -249
- package/src/sidebar.ts +0 -140
- package/src/types.ts +0 -330
- package/src/ui/head.ts +0 -83
- package/src/ui/index.ts +0 -5
- package/src/ui/metadata.ts +0 -95
- package/src/ui/router.ts +0 -88
- package/src/ui/runtime.ts +0 -42
- package/src/ui/types.ts +0 -65
- package/src/utils/banner.ts +0 -21
- package/src/utils/linkify.ts +0 -11
- package/src/utils/path-match.ts +0 -16
- package/src/utils/run.ts +0 -31
- package/src/utils/save-config.ts +0 -20
- package/src/utils/theme.ts +0 -39
package/dist/plugin.mjs
CHANGED
|
@@ -3,32 +3,68 @@ import { getNetworkIdForAccount } from "./network.mjs";
|
|
|
3
3
|
import { buildRuntimePluginsForConfig, findConfigPath, getHostDevelopmentPort, getProjectRoot, loadConfig, resolveLocalDevelopmentPath, writeResolvedConfig } from "./config.mjs";
|
|
4
4
|
import { createPlugin, z } from "./sdk.mjs";
|
|
5
5
|
import { bosContract } from "./contract.mjs";
|
|
6
|
+
import { writePluginSidebarGen } from "./sidebar.mjs";
|
|
7
|
+
import { computeSriHashForUrl } from "./integrity.mjs";
|
|
6
8
|
import { syncApiContractBridge } from "./api-contract.mjs";
|
|
7
9
|
import { buildRuntimeConfig, detectLocalPackages, prepareDevelopmentRuntimeConfig } from "./app.mjs";
|
|
8
10
|
import { ensureEnvFile, writeGeneratedInfra } from "./cli/infra.mjs";
|
|
9
11
|
import { saveBosConfig } from "./utils/save-config.mjs";
|
|
10
|
-
import { buildInitPatterns, copyFilteredFiles, detectGitRemoteUrl, fetchParentConfig, generateDatabaseMigrations, personalizeConfig, removeInitLockfile, resolveSourceDir, runBunInstall,
|
|
11
|
-
import { promptInitOptions } from "./cli/prompts.mjs";
|
|
12
|
+
import { buildInitPatterns, copyFilteredFiles, detectGitRemoteUrl, fetchParentConfig, generateDatabaseMigrations, personalizeConfig, removeInitLockfile, resolveSourceDir, runBunInstall, runTypesGen, scaffoldMinimalProject, stripOrphanedWorkspacesFromLockfile, writeInitSnapshot } from "./cli/init.mjs";
|
|
12
13
|
import { getStatus } from "./cli/status.mjs";
|
|
13
14
|
import { syncTemplate } from "./cli/sync.mjs";
|
|
14
|
-
import { timePhase } from "./cli/timing.mjs";
|
|
15
15
|
import { upgradeTemplate } from "./cli/upgrade.mjs";
|
|
16
|
-
import { computeSriHashForUrl } from "./integrity.mjs";
|
|
17
16
|
import { addFunctionCallAccessKey, ensureNearCli, executeTransaction } from "./near-cli.mjs";
|
|
18
17
|
import { buildDescription, buildServiceDescriptorMap } from "./service-descriptor.mjs";
|
|
19
18
|
import { syncAndGenerateSharedUi } from "./shared.mjs";
|
|
20
|
-
import { writePluginSidebarGen } from "./sidebar.mjs";
|
|
21
19
|
import { run } from "./utils/run.mjs";
|
|
22
|
-
import { colors } from "./utils/theme.mjs";
|
|
23
20
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
24
21
|
import { basename, dirname, join, resolve } from "node:path";
|
|
22
|
+
import { EventEmitter } from "node:events";
|
|
23
|
+
import { access, readFile } from "node:fs/promises";
|
|
25
24
|
import process from "node:process";
|
|
26
|
-
import * as p from "@clack/prompts";
|
|
27
25
|
import { Effect } from "effect";
|
|
28
26
|
|
|
29
27
|
//#region src/plugin.ts
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
const pluginEvents = new EventEmitter();
|
|
29
|
+
let pendingSession = null;
|
|
30
|
+
let pendingStartSummary = null;
|
|
31
|
+
function consumeDevSession() {
|
|
32
|
+
const data = pendingSession;
|
|
33
|
+
const summary = pendingStartSummary;
|
|
34
|
+
pendingSession = null;
|
|
35
|
+
pendingStartSummary = null;
|
|
36
|
+
if (!data) return null;
|
|
37
|
+
return summary ? {
|
|
38
|
+
...data,
|
|
39
|
+
summary
|
|
40
|
+
} : data;
|
|
41
|
+
}
|
|
42
|
+
async function timePhase(timings, name, fn) {
|
|
43
|
+
pluginEvents.emit("progress", {
|
|
44
|
+
phase: name,
|
|
45
|
+
status: "running"
|
|
46
|
+
});
|
|
47
|
+
const startedAt = Date.now();
|
|
48
|
+
try {
|
|
49
|
+
const result = await fn();
|
|
50
|
+
timings.push({
|
|
51
|
+
name,
|
|
52
|
+
durationMs: Date.now() - startedAt
|
|
53
|
+
});
|
|
54
|
+
pluginEvents.emit("progress", {
|
|
55
|
+
phase: name,
|
|
56
|
+
status: "done",
|
|
57
|
+
durationMs: Date.now() - startedAt
|
|
58
|
+
});
|
|
59
|
+
return result;
|
|
60
|
+
} catch (error) {
|
|
61
|
+
pluginEvents.emit("progress", {
|
|
62
|
+
phase: name,
|
|
63
|
+
status: "error",
|
|
64
|
+
durationMs: Date.now() - startedAt
|
|
65
|
+
});
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
32
68
|
}
|
|
33
69
|
const buildCommands = {
|
|
34
70
|
host: {
|
|
@@ -61,6 +97,17 @@ function buildConfigResult(bosConfig) {
|
|
|
61
97
|
remotes: packages.filter((name) => name !== "host")
|
|
62
98
|
};
|
|
63
99
|
}
|
|
100
|
+
async function fileExists(path) {
|
|
101
|
+
try {
|
|
102
|
+
await access(path);
|
|
103
|
+
return true;
|
|
104
|
+
} catch {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async function readJsonFile(path) {
|
|
109
|
+
return JSON.parse(await readFile(path, "utf8"));
|
|
110
|
+
}
|
|
64
111
|
function resolveWorkspaceTarget(key, bosConfig, runtimeConfig, configDir) {
|
|
65
112
|
if (bosConfig?.app && key in bosConfig.app) {
|
|
66
113
|
const appEntry = bosConfig.app[key];
|
|
@@ -156,10 +203,8 @@ function extractPublishedUrl(output) {
|
|
|
156
203
|
return match[match.length - 1] ?? null;
|
|
157
204
|
}
|
|
158
205
|
async function buildEveryPluginQuietly(cwd) {
|
|
159
|
-
|
|
160
|
-
if (
|
|
161
|
-
const distPath = `${cwd}/packages/every-plugin/dist/build/rspack/plugin.mjs`;
|
|
162
|
-
if (await Bun.file(distPath).exists()) return;
|
|
206
|
+
if (!await fileExists(`${`${cwd}/packages/every-plugin`}/package.json`)) return;
|
|
207
|
+
if (await fileExists(`${cwd}/packages/every-plugin/dist/build/rspack/plugin.mjs`)) return;
|
|
163
208
|
const result = await run("bun", [
|
|
164
209
|
"run",
|
|
165
210
|
"--cwd",
|
|
@@ -178,10 +223,8 @@ async function buildEveryPluginQuietly(cwd) {
|
|
|
178
223
|
throw new Error(`bun run --cwd packages/every-plugin build failed with exit code ${result.exitCode}`);
|
|
179
224
|
}
|
|
180
225
|
async function buildEverythingDevQuietly(cwd) {
|
|
181
|
-
|
|
182
|
-
if (
|
|
183
|
-
const distPath = `${cwd}/packages/everything-dev/dist/index.mjs`;
|
|
184
|
-
if (await Bun.file(distPath).exists()) return;
|
|
226
|
+
if (!await fileExists(`${`${cwd}/packages/everything-dev`}/package.json`)) return;
|
|
227
|
+
if (await fileExists(`${cwd}/packages/everything-dev/dist/index.mjs`)) return;
|
|
185
228
|
const result = await run("bun", [
|
|
186
229
|
"run",
|
|
187
230
|
"--cwd",
|
|
@@ -220,7 +263,7 @@ async function buildWorkspaceTargets(opts) {
|
|
|
220
263
|
skipped.push(target);
|
|
221
264
|
continue;
|
|
222
265
|
}
|
|
223
|
-
if (await
|
|
266
|
+
if (await fileExists(`${resolved.path}/package.json`)) existing.push(resolved);
|
|
224
267
|
else skipped.push(target);
|
|
225
268
|
}
|
|
226
269
|
if (existing.length === 0) return {
|
|
@@ -248,7 +291,7 @@ async function buildWorkspaceTargets(opts) {
|
|
|
248
291
|
] : existing;
|
|
249
292
|
const built = [];
|
|
250
293
|
for (const resolved of orderedExisting) {
|
|
251
|
-
const pkgJson =
|
|
294
|
+
const pkgJson = await readJsonFile(`${resolved.path}/package.json`);
|
|
252
295
|
const buildConfig = opts.deploy && pkgJson.scripts?.deploy ? {
|
|
253
296
|
cmd: "bun",
|
|
254
297
|
args: ["run", "deploy"]
|
|
@@ -374,12 +417,12 @@ var plugin_default = createPlugin({
|
|
|
374
417
|
error: `Plugin '${input.key}' does not have a local development path`
|
|
375
418
|
};
|
|
376
419
|
const pkgPath = join(localPath, "package.json");
|
|
377
|
-
if (!await
|
|
420
|
+
if (!await fileExists(pkgPath)) return {
|
|
378
421
|
status: "error",
|
|
379
422
|
key: input.key,
|
|
380
423
|
error: `Missing package.json at ${localPath}`
|
|
381
424
|
};
|
|
382
|
-
const pkgJson = await
|
|
425
|
+
const pkgJson = await readJsonFile(pkgPath);
|
|
383
426
|
const script = pkgJson.scripts?.deploy ? "deploy" : "build";
|
|
384
427
|
const { stdout, stderr, exitCode } = await run("bun", ["run", script], {
|
|
385
428
|
cwd: localPath,
|
|
@@ -435,6 +478,10 @@ var plugin_default = createPlugin({
|
|
|
435
478
|
}),
|
|
436
479
|
dev: builder.dev.handler(async ({ input }) => {
|
|
437
480
|
ensureEnvFile(deps.configDir);
|
|
481
|
+
pluginEvents.emit("progress", {
|
|
482
|
+
phase: "config",
|
|
483
|
+
status: "running"
|
|
484
|
+
});
|
|
438
485
|
const localPackages = detectLocalPackages(deps.bosConfig ?? void 0, deps.runtimeConfig ?? void 0);
|
|
439
486
|
const hostSource = localPackages.includes("host") ? parseSourceMode(input.host, "local") : "remote";
|
|
440
487
|
const uiSource = localPackages.includes("ui") ? parseSourceMode(input.ui, "local") : "remote";
|
|
@@ -447,9 +494,41 @@ var plugin_default = createPlugin({
|
|
|
447
494
|
hostMode: hostSource,
|
|
448
495
|
bosConfig: deps.bosConfig ?? void 0,
|
|
449
496
|
extendsChain: []
|
|
450
|
-
})).catalogChanged)
|
|
451
|
-
|
|
497
|
+
})).catalogChanged) {
|
|
498
|
+
pluginEvents.emit("progress", {
|
|
499
|
+
phase: "install",
|
|
500
|
+
status: "running"
|
|
501
|
+
});
|
|
502
|
+
await run("bun", ["install"], { cwd: deps.configDir });
|
|
503
|
+
pluginEvents.emit("progress", {
|
|
504
|
+
phase: "install",
|
|
505
|
+
status: "done"
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
if (apiSource === "local" && !proxy || localPackages.some((pkg) => pkg.startsWith("plugin:"))) {
|
|
509
|
+
pluginEvents.emit("progress", {
|
|
510
|
+
phase: "build plugin",
|
|
511
|
+
status: "running"
|
|
512
|
+
});
|
|
513
|
+
await buildEveryPluginQuietly(deps.configDir);
|
|
514
|
+
pluginEvents.emit("progress", {
|
|
515
|
+
phase: "build plugin",
|
|
516
|
+
status: "done"
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
pluginEvents.emit("progress", {
|
|
520
|
+
phase: "build",
|
|
521
|
+
status: "running"
|
|
522
|
+
});
|
|
452
523
|
await buildEverythingDevQuietly(deps.configDir);
|
|
524
|
+
pluginEvents.emit("progress", {
|
|
525
|
+
phase: "build",
|
|
526
|
+
status: "done"
|
|
527
|
+
});
|
|
528
|
+
pluginEvents.emit("progress", {
|
|
529
|
+
phase: "config",
|
|
530
|
+
status: "done"
|
|
531
|
+
});
|
|
453
532
|
const refreshed = await loadConfig({ cwd: deps.configDir });
|
|
454
533
|
deps.bosConfig = refreshed?.config ?? deps.bosConfig;
|
|
455
534
|
deps.runtimeConfig = refreshed?.runtime ?? deps.runtimeConfig;
|
|
@@ -497,8 +576,11 @@ var plugin_default = createPlugin({
|
|
|
497
576
|
port: runtimeConfig.host.port,
|
|
498
577
|
interactive: input.interactive
|
|
499
578
|
};
|
|
500
|
-
|
|
501
|
-
|
|
579
|
+
pendingSession = {
|
|
580
|
+
orchestrator,
|
|
581
|
+
services,
|
|
582
|
+
runtimeConfig
|
|
583
|
+
};
|
|
502
584
|
return {
|
|
503
585
|
status: "started",
|
|
504
586
|
description: orchestrator.description,
|
|
@@ -507,6 +589,10 @@ var plugin_default = createPlugin({
|
|
|
507
589
|
}),
|
|
508
590
|
start: builder.start.handler(async ({ input }) => {
|
|
509
591
|
ensureEnvFile(deps.configDir);
|
|
592
|
+
pluginEvents.emit("progress", {
|
|
593
|
+
phase: "config",
|
|
594
|
+
status: "running"
|
|
595
|
+
});
|
|
510
596
|
const account = input.account ?? process.env.BOS_ACCOUNT;
|
|
511
597
|
const domain = input.domain ?? process.env.BOS_GATEWAY;
|
|
512
598
|
let config = null;
|
|
@@ -541,10 +627,18 @@ var plugin_default = createPlugin({
|
|
|
541
627
|
env: "production",
|
|
542
628
|
plugins: runtimePlugins
|
|
543
629
|
});
|
|
630
|
+
pluginEvents.emit("progress", {
|
|
631
|
+
phase: "generate artifacts",
|
|
632
|
+
status: "running"
|
|
633
|
+
});
|
|
544
634
|
await generateCodeArtifacts(deps.configDir, config, {
|
|
545
635
|
env: "production",
|
|
546
636
|
runtimeConfig
|
|
547
637
|
});
|
|
638
|
+
pluginEvents.emit("progress", {
|
|
639
|
+
phase: "generate artifacts",
|
|
640
|
+
status: "done"
|
|
641
|
+
});
|
|
548
642
|
const productionEnv = {};
|
|
549
643
|
const warnings = [];
|
|
550
644
|
if (!process.env.CORS_ORIGIN && config.domain) {
|
|
@@ -564,32 +658,40 @@ var plugin_default = createPlugin({
|
|
|
564
658
|
if (missingSecrets.length > 0) warnings.push(`Missing ${missingSecrets.length} secret(s): ${missingSecrets.join(", ")}`);
|
|
565
659
|
const services = buildServiceDescriptorMap(runtimeConfig);
|
|
566
660
|
const stagingEnvVars = isStaging ? { BOS_GATEWAY: config.staging?.domain ?? config.domain ?? "" } : {};
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
661
|
+
const summary = {
|
|
662
|
+
configSource: remoteConfig ? `bos://${account}/${domain}` : findConfigPath() ?? "bos.config.json",
|
|
663
|
+
configSourceHttp: remoteConfig && account && domain ? buildRegistryConfigUrl(account, domain) : void 0,
|
|
664
|
+
account: config.account,
|
|
665
|
+
domain: config.domain ?? void 0,
|
|
666
|
+
modules: {
|
|
667
|
+
host: runtimeConfig.host.remoteUrl ?? runtimeConfig.host.url ?? "local",
|
|
668
|
+
ui: runtimeConfig.ui.url ?? "local",
|
|
669
|
+
api: runtimeConfig.api.url ?? "local",
|
|
670
|
+
auth: runtimeConfig.auth?.url ?? void 0
|
|
671
|
+
},
|
|
672
|
+
warnings
|
|
673
|
+
};
|
|
674
|
+
pendingSession = {
|
|
675
|
+
orchestrator: {
|
|
676
|
+
packages: ["host"],
|
|
677
|
+
env: {
|
|
678
|
+
NODE_ENV: "production",
|
|
679
|
+
...productionEnv,
|
|
680
|
+
...stagingEnvVars
|
|
681
|
+
},
|
|
682
|
+
description: `${isStaging ? "Staging" : "Production"} Mode (${config.account})`,
|
|
683
|
+
port,
|
|
684
|
+
interactive: input.interactive,
|
|
685
|
+
noLogs: true
|
|
585
686
|
},
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
interactive: input.interactive,
|
|
589
|
-
noLogs: true
|
|
687
|
+
services,
|
|
688
|
+
runtimeConfig
|
|
590
689
|
};
|
|
591
|
-
|
|
592
|
-
|
|
690
|
+
pendingStartSummary = summary;
|
|
691
|
+
pluginEvents.emit("progress", {
|
|
692
|
+
phase: "config",
|
|
693
|
+
status: "done"
|
|
694
|
+
});
|
|
593
695
|
return {
|
|
594
696
|
status: "running",
|
|
595
697
|
url: `http://localhost:${port}`
|
|
@@ -779,8 +881,8 @@ var plugin_default = createPlugin({
|
|
|
779
881
|
let extendsAccount = "";
|
|
780
882
|
let extendsGateway = "";
|
|
781
883
|
let directory = input.directory;
|
|
782
|
-
|
|
783
|
-
|
|
884
|
+
const account = input.account;
|
|
885
|
+
const domain = input.domain;
|
|
784
886
|
let overrides = input.overrides;
|
|
785
887
|
let plugins = input.plugins;
|
|
786
888
|
if (input.extends) {
|
|
@@ -792,77 +894,22 @@ var plugin_default = createPlugin({
|
|
|
792
894
|
}
|
|
793
895
|
extendsAccount = extendsAccount || "dev.everything.near";
|
|
794
896
|
extendsGateway = extendsGateway || "everything.dev";
|
|
795
|
-
const s = p.spinner();
|
|
796
|
-
s.start("Initializing project");
|
|
797
897
|
let parentPluginKeys = [];
|
|
798
898
|
let parentConfig = null;
|
|
799
899
|
try {
|
|
800
|
-
parentConfig = await timePhase(timings, "parent config", () => fetchParentConfig(extendsAccount, extendsGateway)
|
|
900
|
+
parentConfig = await timePhase(timings, "parent config", () => fetchParentConfig(extendsAccount, extendsGateway));
|
|
801
901
|
if (parentConfig?.plugins && typeof parentConfig.plugins === "object") parentPluginKeys = Object.keys(parentConfig.plugins);
|
|
802
902
|
} catch {}
|
|
803
|
-
if (!input.noInteractive) {
|
|
804
|
-
s.stop("Config fetched");
|
|
805
|
-
const initialExtendsAccount = extendsAccount;
|
|
806
|
-
const initialExtendsGateway = extendsGateway;
|
|
807
|
-
const prompted = await promptInitOptions({
|
|
808
|
-
extends: `bos://${extendsAccount}/${extendsGateway}`,
|
|
809
|
-
directory,
|
|
810
|
-
account,
|
|
811
|
-
domain,
|
|
812
|
-
plugins,
|
|
813
|
-
overrides,
|
|
814
|
-
parentPluginKeys
|
|
815
|
-
});
|
|
816
|
-
extendsAccount = prompted.extendsAccount;
|
|
817
|
-
extendsGateway = prompted.extendsGateway;
|
|
818
|
-
directory = prompted.directory;
|
|
819
|
-
account = prompted.account;
|
|
820
|
-
domain = prompted.domain;
|
|
821
|
-
plugins = prompted.plugins;
|
|
822
|
-
overrides = prompted.overrides;
|
|
823
|
-
if (!parentConfig || prompted.extendsAccount !== initialExtendsAccount || prompted.extendsGateway !== initialExtendsGateway) {
|
|
824
|
-
try {
|
|
825
|
-
parentConfig = await timePhase(timings, "parent config", () => fetchParentConfig(prompted.extendsAccount, prompted.extendsGateway), s);
|
|
826
|
-
if (parentConfig?.plugins && typeof parentConfig.plugins === "object") parentPluginKeys = Object.keys(parentConfig.plugins);
|
|
827
|
-
else parentPluginKeys = [];
|
|
828
|
-
} catch {
|
|
829
|
-
return {
|
|
830
|
-
status: "error",
|
|
831
|
-
directory,
|
|
832
|
-
extendsRef: `bos://${prompted.extendsAccount}/${prompted.extendsGateway}`,
|
|
833
|
-
account,
|
|
834
|
-
domain,
|
|
835
|
-
extends: `bos://${prompted.extendsAccount}/${prompted.extendsGateway}`,
|
|
836
|
-
plugins,
|
|
837
|
-
overrides,
|
|
838
|
-
filesCopied: 0,
|
|
839
|
-
timings,
|
|
840
|
-
error: `No config found at bos://${prompted.extendsAccount}/${prompted.extendsGateway} — are you sure this is the right parent?`
|
|
841
|
-
};
|
|
842
|
-
}
|
|
843
|
-
s.stop("Config fetched");
|
|
844
|
-
}
|
|
845
|
-
if (typeof parentConfig?.title === "string" && parentConfig.title.trim() && typeof parentConfig.description === "string" && parentConfig.description.trim()) {
|
|
846
|
-
const shouldContinue = await p.confirm({
|
|
847
|
-
message: `You will be extending ${parentConfig.title} - ${parentConfig.description}. Continue?`,
|
|
848
|
-
initialValue: true
|
|
849
|
-
});
|
|
850
|
-
if (p.isCancel(shouldContinue) || !shouldContinue) process.exit(0);
|
|
851
|
-
}
|
|
852
|
-
s.start("Setting up project");
|
|
853
|
-
}
|
|
854
903
|
overrides = overrides?.length ? overrides : ["ui", "api"];
|
|
855
|
-
if (overrides.includes("plugins") &&
|
|
904
|
+
if (overrides.includes("plugins") && plugins === void 0) plugins = parentPluginKeys;
|
|
856
905
|
plugins = plugins ?? [];
|
|
857
906
|
directory = directory || domain || extendsGateway;
|
|
858
907
|
const targetDir = resolve(directory);
|
|
859
908
|
const extendsRef = `bos://${extendsAccount}/${extendsGateway}`;
|
|
860
|
-
if (overrides.includes("plugins") && !plugins.length) {}
|
|
861
909
|
const repository = await detectGitRemoteUrl(process.cwd()).catch(() => void 0) ?? parentConfig?.repository;
|
|
862
910
|
if (!parentConfig) try {
|
|
863
|
-
parentConfig = await timePhase(timings, "parent config", () => fetchParentConfig(extendsAccount, extendsGateway)
|
|
911
|
+
parentConfig = await timePhase(timings, "parent config", () => fetchParentConfig(extendsAccount, extendsGateway));
|
|
864
912
|
} catch {
|
|
865
|
-
s.stop("Failed");
|
|
866
913
|
return {
|
|
867
914
|
status: "error",
|
|
868
915
|
directory,
|
|
@@ -881,7 +928,7 @@ var plugin_default = createPlugin({
|
|
|
881
928
|
extendsAccount,
|
|
882
929
|
extendsGateway,
|
|
883
930
|
source: input.source
|
|
884
|
-
})
|
|
931
|
+
}));
|
|
885
932
|
parentConfig = resolvedParentConfig;
|
|
886
933
|
const isMinimalScaffold = sourceDir === "";
|
|
887
934
|
try {
|
|
@@ -897,7 +944,7 @@ var plugin_default = createPlugin({
|
|
|
897
944
|
repository,
|
|
898
945
|
title: parentConfig?.title,
|
|
899
946
|
description: parentConfig?.description
|
|
900
|
-
})
|
|
947
|
+
}));
|
|
901
948
|
await timePhase(timings, "personalize config", () => personalizeConfig(targetDir, {
|
|
902
949
|
extendsAccount,
|
|
903
950
|
extendsGateway,
|
|
@@ -911,13 +958,13 @@ var plugin_default = createPlugin({
|
|
|
911
958
|
description: parentConfig?.description,
|
|
912
959
|
testnet: parentConfig?.testnet,
|
|
913
960
|
staging: parentConfig?.staging
|
|
914
|
-
})
|
|
961
|
+
}));
|
|
915
962
|
} else {
|
|
916
963
|
const patterns = buildInitPatterns(overrides, plugins);
|
|
917
964
|
filesCopied = await timePhase(timings, "copy files", () => copyFilteredFiles(sourceDir, targetDir, patterns, {
|
|
918
965
|
overrides,
|
|
919
966
|
plugins
|
|
920
|
-
})
|
|
967
|
+
}));
|
|
921
968
|
await timePhase(timings, "personalize config", () => personalizeConfig(targetDir, {
|
|
922
969
|
extendsAccount,
|
|
923
970
|
extendsGateway,
|
|
@@ -931,45 +978,28 @@ var plugin_default = createPlugin({
|
|
|
931
978
|
description: parentConfig?.description,
|
|
932
979
|
testnet: parentConfig?.testnet,
|
|
933
980
|
staging: parentConfig?.staging
|
|
934
|
-
})
|
|
981
|
+
}));
|
|
935
982
|
await timePhase(timings, "write snapshot", () => writeInitSnapshot(targetDir, extendsAccount, extendsGateway, sourceDir, patterns, {
|
|
936
983
|
overrides,
|
|
937
984
|
plugins
|
|
938
|
-
})
|
|
985
|
+
}));
|
|
939
986
|
}
|
|
940
987
|
const lockfilePath = join(targetDir, "bun.lock");
|
|
941
988
|
stripOrphanedWorkspacesFromLockfile(lockfilePath, computeAllowedWorkspaces(overrides, plugins));
|
|
942
989
|
removeInitLockfile(lockfilePath);
|
|
943
|
-
const initConfig = await timePhase(timings, "resolve config", () => loadConfig({ cwd: targetDir })
|
|
990
|
+
const initConfig = await timePhase(timings, "resolve config", () => loadConfig({ cwd: targetDir }));
|
|
944
991
|
if (initConfig?.runtime) await timePhase(timings, "generate env/docker", async () => {
|
|
945
992
|
writeGeneratedInfra(targetDir, initConfig.runtime);
|
|
946
|
-
}
|
|
993
|
+
});
|
|
947
994
|
await timePhase(timings, "create env file", async () => {
|
|
948
995
|
ensureEnvFile(targetDir);
|
|
949
|
-
}
|
|
996
|
+
});
|
|
950
997
|
if (!input.noInstall) {
|
|
951
|
-
await timePhase(timings, "install dependencies", () => runBunInstall(targetDir
|
|
952
|
-
await timePhase(timings, "generate types", () => runTypesGen(targetDir
|
|
953
|
-
await timePhase(timings, "generate migrations", () => generateDatabaseMigrations(targetDir)
|
|
954
|
-
}
|
|
955
|
-
if (input.noInstall && initConfig?.config) await timePhase(timings, "generate code artifacts", () => generateCodeArtifacts(targetDir, initConfig.config), s);
|
|
956
|
-
s.stop("Project initialized");
|
|
957
|
-
if (!input.noInteractive) {
|
|
958
|
-
if (await p.confirm({
|
|
959
|
-
message: "Run docker compose up -d --wait?",
|
|
960
|
-
initialValue: true
|
|
961
|
-
}) === true) {
|
|
962
|
-
const dockerSpinner = p.spinner();
|
|
963
|
-
dockerSpinner.start("Starting Docker services");
|
|
964
|
-
try {
|
|
965
|
-
await timePhase(timings, "docker compose up", () => runDockerComposeUp(targetDir));
|
|
966
|
-
dockerSpinner.stop("Docker services ready");
|
|
967
|
-
} catch (error) {
|
|
968
|
-
dockerSpinner.stop("Docker services not started");
|
|
969
|
-
p.log.warn(`docker compose up -d --wait failed: ${error instanceof Error ? error.message : error}`);
|
|
970
|
-
}
|
|
971
|
-
}
|
|
998
|
+
await timePhase(timings, "install dependencies", () => runBunInstall(targetDir));
|
|
999
|
+
await timePhase(timings, "generate types", () => runTypesGen(targetDir));
|
|
1000
|
+
await timePhase(timings, "generate migrations", () => generateDatabaseMigrations(targetDir));
|
|
972
1001
|
}
|
|
1002
|
+
if (input.noInstall && initConfig?.config) await timePhase(timings, "generate code artifacts", () => generateCodeArtifacts(targetDir, initConfig.config));
|
|
973
1003
|
return {
|
|
974
1004
|
status: "initialized",
|
|
975
1005
|
directory,
|
|
@@ -980,7 +1010,8 @@ var plugin_default = createPlugin({
|
|
|
980
1010
|
plugins,
|
|
981
1011
|
overrides,
|
|
982
1012
|
filesCopied,
|
|
983
|
-
timings
|
|
1013
|
+
timings,
|
|
1014
|
+
targetDir
|
|
984
1015
|
};
|
|
985
1016
|
} finally {
|
|
986
1017
|
await cleanup();
|
|
@@ -1155,10 +1186,10 @@ function computeAllowedWorkspaces(overrides, plugins) {
|
|
|
1155
1186
|
if (section === "ui") workspaces.push("ui");
|
|
1156
1187
|
if (section === "api") workspaces.push("api");
|
|
1157
1188
|
}
|
|
1158
|
-
if (plugins
|
|
1189
|
+
if (plugins && plugins.length > 0) workspaces.push("plugins/*");
|
|
1159
1190
|
return workspaces;
|
|
1160
1191
|
}
|
|
1161
1192
|
|
|
1162
1193
|
//#endregion
|
|
1163
|
-
export { plugin_default as default };
|
|
1194
|
+
export { consumeDevSession, plugin_default as default, pluginEvents };
|
|
1164
1195
|
//# sourceMappingURL=plugin.mjs.map
|