everything-dev 1.16.3 → 1.19.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.
Files changed (83) hide show
  1. package/dist/cli/init.cjs +167 -87
  2. package/dist/cli/init.cjs.map +1 -1
  3. package/dist/cli/init.d.cts +14 -2
  4. package/dist/cli/init.d.cts.map +1 -1
  5. package/dist/cli/init.d.mts +14 -2
  6. package/dist/cli/init.d.mts.map +1 -1
  7. package/dist/cli/init.mjs +166 -88
  8. package/dist/cli/init.mjs.map +1 -1
  9. package/dist/cli/prompts.cjs +12 -14
  10. package/dist/cli/prompts.cjs.map +1 -1
  11. package/dist/cli/prompts.mjs +12 -14
  12. package/dist/cli/prompts.mjs.map +1 -1
  13. package/dist/cli/sync.cjs +3 -5
  14. package/dist/cli/sync.cjs.map +1 -1
  15. package/dist/cli/sync.mjs +3 -5
  16. package/dist/cli/sync.mjs.map +1 -1
  17. package/dist/cli/upgrade.cjs +214 -2
  18. package/dist/cli/upgrade.cjs.map +1 -1
  19. package/dist/cli/upgrade.mjs +214 -2
  20. package/dist/cli/upgrade.mjs.map +1 -1
  21. package/dist/config.cjs +125 -74
  22. package/dist/config.cjs.map +1 -1
  23. package/dist/config.d.cts +9 -2
  24. package/dist/config.d.cts.map +1 -1
  25. package/dist/config.d.mts +9 -2
  26. package/dist/config.d.mts.map +1 -1
  27. package/dist/config.mjs +126 -76
  28. package/dist/config.mjs.map +1 -1
  29. package/dist/contract.cjs +1 -4
  30. package/dist/contract.cjs.map +1 -1
  31. package/dist/contract.d.cts +40 -22
  32. package/dist/contract.d.cts.map +1 -1
  33. package/dist/contract.d.mts +40 -22
  34. package/dist/contract.d.mts.map +1 -1
  35. package/dist/contract.meta.cjs +5 -5
  36. package/dist/contract.meta.cjs.map +1 -1
  37. package/dist/contract.meta.d.cts +9 -9
  38. package/dist/contract.meta.d.mts +9 -9
  39. package/dist/contract.meta.mjs +5 -5
  40. package/dist/contract.meta.mjs.map +1 -1
  41. package/dist/contract.mjs +1 -4
  42. package/dist/contract.mjs.map +1 -1
  43. package/dist/index.cjs +2 -0
  44. package/dist/index.d.cts +3 -3
  45. package/dist/index.d.mts +3 -3
  46. package/dist/index.mjs +3 -3
  47. package/dist/merge.cjs +1 -0
  48. package/dist/merge.mjs +1 -1
  49. package/dist/plugin.cjs +70 -114
  50. package/dist/plugin.cjs.map +1 -1
  51. package/dist/plugin.d.cts +38 -17
  52. package/dist/plugin.d.cts.map +1 -1
  53. package/dist/plugin.d.mts +38 -17
  54. package/dist/plugin.d.mts.map +1 -1
  55. package/dist/plugin.mjs +71 -115
  56. package/dist/plugin.mjs.map +1 -1
  57. package/dist/sidebar.cjs +6 -14
  58. package/dist/sidebar.cjs.map +1 -1
  59. package/dist/sidebar.d.cts +3 -3
  60. package/dist/sidebar.d.cts.map +1 -1
  61. package/dist/sidebar.d.mts +3 -3
  62. package/dist/sidebar.d.mts.map +1 -1
  63. package/dist/sidebar.mjs +6 -14
  64. package/dist/sidebar.mjs.map +1 -1
  65. package/dist/types.cjs +10 -16
  66. package/dist/types.cjs.map +1 -1
  67. package/dist/types.d.cts +56 -12
  68. package/dist/types.d.cts.map +1 -1
  69. package/dist/types.d.mts +56 -12
  70. package/dist/types.d.mts.map +1 -1
  71. package/dist/types.mjs +10 -17
  72. package/dist/types.mjs.map +1 -1
  73. package/package.json +1 -1
  74. package/src/cli/init.ts +225 -131
  75. package/src/cli/prompts.ts +17 -22
  76. package/src/cli/sync.ts +5 -8
  77. package/src/cli/upgrade.ts +326 -2
  78. package/src/config.ts +250 -107
  79. package/src/contract.meta.ts +6 -8
  80. package/src/contract.ts +1 -4
  81. package/src/plugin.ts +120 -183
  82. package/src/sidebar.ts +9 -31
  83. package/src/types.ts +10 -15
package/dist/plugin.d.mts CHANGED
@@ -93,15 +93,13 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
93
93
  production: z.ZodOptional<z.ZodString>;
94
94
  staging: z.ZodOptional<z.ZodString>;
95
95
  }, z.core.$strip>]>>;
96
+ name: z.ZodOptional<z.ZodString>;
96
97
  development: z.ZodOptional<z.ZodString>;
97
98
  production: z.ZodOptional<z.ZodString>;
98
99
  integrity: z.ZodOptional<z.ZodString>;
99
- name: z.ZodOptional<z.ZodString>;
100
- version: z.ZodOptional<z.ZodString>;
101
100
  proxy: z.ZodOptional<z.ZodString>;
102
101
  variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
103
102
  secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
104
- routes: z.ZodOptional<z.ZodArray<z.ZodString>>;
105
103
  sidebar: z.ZodOptional<z.ZodArray<z.ZodObject<{
106
104
  icon: z.ZodString;
107
105
  label: z.ZodString;
@@ -112,6 +110,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
112
110
  admin: "admin";
113
111
  }>>;
114
112
  }, z.core.$strip>>>;
113
+ routes: z.ZodOptional<z.ZodArray<z.ZodString>>;
114
+ version: z.ZodOptional<z.ZodString>;
115
115
  app: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
116
116
  shared: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{
117
117
  version: z.ZodString;
@@ -139,7 +139,12 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
139
139
  ssrIntegrity: z.ZodOptional<z.ZodString>;
140
140
  }, z.core.$strip>;
141
141
  api: z.ZodObject<{
142
- name: z.ZodString;
142
+ extends: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
143
+ development: z.ZodOptional<z.ZodString>;
144
+ production: z.ZodOptional<z.ZodString>;
145
+ staging: z.ZodOptional<z.ZodString>;
146
+ }, z.core.$strip>]>>;
147
+ name: z.ZodOptional<z.ZodString>;
143
148
  development: z.ZodOptional<z.ZodString>;
144
149
  production: z.ZodOptional<z.ZodString>;
145
150
  integrity: z.ZodOptional<z.ZodString>;
@@ -156,9 +161,15 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
156
161
  admin: "admin";
157
162
  }>>;
158
163
  }, z.core.$strip>>>;
164
+ routes: z.ZodOptional<z.ZodArray<z.ZodString>>;
159
165
  }, z.core.$strip>;
160
166
  auth: z.ZodOptional<z.ZodObject<{
161
- name: z.ZodString;
167
+ extends: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
168
+ development: z.ZodOptional<z.ZodString>;
169
+ production: z.ZodOptional<z.ZodString>;
170
+ staging: z.ZodOptional<z.ZodString>;
171
+ }, z.core.$strip>]>>;
172
+ name: z.ZodOptional<z.ZodString>;
162
173
  development: z.ZodOptional<z.ZodString>;
163
174
  production: z.ZodOptional<z.ZodString>;
164
175
  integrity: z.ZodOptional<z.ZodString>;
@@ -175,6 +186,7 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
175
186
  admin: "admin";
176
187
  }>>;
177
188
  }, z.core.$strip>>>;
189
+ routes: z.ZodOptional<z.ZodArray<z.ZodString>>;
178
190
  }, z.core.$strip>>;
179
191
  }, z.core.$strip>;
180
192
  }, z.core.$strip>>;
@@ -247,8 +259,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
247
259
  dryRun: z.ZodDefault<z.ZodBoolean>;
248
260
  packages: z.ZodDefault<z.ZodString>;
249
261
  network: z.ZodOptional<z.ZodEnum<{
250
- testnet: "testnet";
251
262
  mainnet: "mainnet";
263
+ testnet: "testnet";
252
264
  }>>;
253
265
  privateKey: z.ZodOptional<z.ZodString>;
254
266
  }, z.core.$strip>, z.ZodObject<{
@@ -272,8 +284,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
272
284
  }>;
273
285
  account: z.ZodString;
274
286
  network: z.ZodEnum<{
275
- testnet: "testnet";
276
287
  mainnet: "mainnet";
288
+ testnet: "testnet";
277
289
  }>;
278
290
  contract: z.ZodString;
279
291
  allowance: z.ZodString;
@@ -284,8 +296,6 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
284
296
  }, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
285
297
  init: ContractProcedure<z.ZodObject<{
286
298
  extends: z.ZodOptional<z.ZodString>;
287
- extendsAccount: z.ZodOptional<z.ZodString>;
288
- extendsGateway: z.ZodOptional<z.ZodString>;
289
299
  directory: z.ZodOptional<z.ZodString>;
290
300
  account: z.ZodOptional<z.ZodString>;
291
301
  domain: z.ZodOptional<z.ZodString>;
@@ -300,8 +310,7 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
300
310
  initialized: "initialized";
301
311
  }>;
302
312
  directory: z.ZodString;
303
- extendsAccount: z.ZodString;
304
- extendsGateway: z.ZodString;
313
+ extendsRef: z.ZodString;
305
314
  account: z.ZodOptional<z.ZodString>;
306
315
  domain: z.ZodOptional<z.ZodString>;
307
316
  extends: z.ZodString;
@@ -429,7 +438,12 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
429
438
  ssrIntegrity?: string | undefined;
430
439
  };
431
440
  api: {
432
- name: string;
441
+ extends?: string | {
442
+ development?: string | undefined;
443
+ production?: string | undefined;
444
+ staging?: string | undefined;
445
+ } | undefined;
446
+ name?: string | undefined;
433
447
  development?: string | undefined;
434
448
  production?: string | undefined;
435
449
  integrity?: string | undefined;
@@ -442,9 +456,15 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
442
456
  to?: string | undefined;
443
457
  roleRequired?: "anon" | "member" | "admin" | undefined;
444
458
  }[] | undefined;
459
+ routes?: string[] | undefined;
445
460
  };
446
461
  auth?: {
447
- name: string;
462
+ extends?: string | {
463
+ development?: string | undefined;
464
+ production?: string | undefined;
465
+ staging?: string | undefined;
466
+ } | undefined;
467
+ name?: string | undefined;
448
468
  development?: string | undefined;
449
469
  production?: string | undefined;
450
470
  integrity?: string | undefined;
@@ -457,6 +477,7 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
457
477
  to?: string | undefined;
458
478
  roleRequired?: "anon" | "member" | "admin" | undefined;
459
479
  }[] | undefined;
480
+ routes?: string[] | undefined;
460
481
  } | undefined;
461
482
  };
462
483
  extends?: string | {
@@ -486,21 +507,21 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
486
507
  production?: string | undefined;
487
508
  staging?: string | undefined;
488
509
  } | undefined;
510
+ name?: string | undefined;
489
511
  development?: string | undefined;
490
512
  production?: string | undefined;
491
513
  integrity?: string | undefined;
492
- name?: string | undefined;
493
- version?: string | undefined;
494
514
  proxy?: string | undefined;
495
515
  variables?: Record<string, string> | undefined;
496
516
  secrets?: string[] | undefined;
497
- routes?: string[] | undefined;
498
517
  sidebar?: {
499
518
  icon: string;
500
519
  label: string;
501
520
  to?: string | undefined;
502
521
  roleRequired?: "anon" | "member" | "admin" | undefined;
503
522
  }[] | undefined;
523
+ routes?: string[] | undefined;
524
+ version?: string | undefined;
504
525
  app?: Record<string, unknown> | undefined;
505
526
  shared?: Record<string, Record<string, {
506
527
  version: string;
@@ -516,7 +537,7 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
516
537
  runtimeConfig: {
517
538
  env: "development" | "production" | "staging";
518
539
  account: string;
519
- networkId: "testnet" | "mainnet";
540
+ networkId: "mainnet" | "testnet";
520
541
  host: {
521
542
  name: string;
522
543
  url: string;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;;cAoDwC,QAAA"}
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;;cAqDwC,QAAA"}
package/dist/plugin.mjs CHANGED
@@ -7,7 +7,7 @@ import { syncApiContractBridge } from "./api-contract.mjs";
7
7
  import { buildRuntimeConfig, detectLocalPackages, prepareDevelopmentRuntimeConfig } from "./app.mjs";
8
8
  import { ensureEnvFile, writeGeneratedInfra } from "./cli/infra.mjs";
9
9
  import { saveBosConfig } from "./utils/save-config.mjs";
10
- import { copyFilteredFiles, fetchParentConfig, generateDatabaseMigrations, personalizeConfig, readTemplatekeep, resolveSourceDir, runBunInstall, runDockerComposeUp, runTypesGen, writeInitSnapshot } from "./cli/init.mjs";
10
+ import { copyFilteredFiles, fetchParentConfig, generateDatabaseMigrations, personalizeConfig, readTemplatekeep, resolveSourceDir, runBunInstall, runDockerComposeUp, runTypesGen, scaffoldMinimalProject, writeInitSnapshot } from "./cli/init.mjs";
11
11
  import { promptInitOptions } from "./cli/prompts.mjs";
12
12
  import { getStatus } from "./cli/status.mjs";
13
13
  import { syncTemplate } from "./cli/sync.mjs";
@@ -134,10 +134,10 @@ function listPluginAttachments(config) {
134
134
  }).sort((a, b) => a.key.localeCompare(b.key));
135
135
  }
136
136
  async function generateCodeArtifacts(configDir, config, opts) {
137
- writePluginSidebarGen(configDir, config);
138
137
  if (opts?.env) writeResolvedConfig(configDir, config, opts.env, opts.extendsChain);
139
138
  const runtimeConfig = opts?.runtimeConfig ?? (await loadConfig({ cwd: configDir }))?.runtime;
140
139
  if (!runtimeConfig) return null;
140
+ writePluginSidebarGen(configDir, runtimeConfig);
141
141
  const bridge = await syncApiContractBridge({
142
142
  configDir,
143
143
  runtimeConfig,
@@ -405,58 +405,20 @@ var plugin_default = createPlugin({
405
405
  const integrity = publishedUrl ? await computeSriHashForUrl(publishedUrl) : null;
406
406
  const version = manifest?.plugin.version ?? pkgJson.version;
407
407
  if (publishedUrl) {
408
- const pluginConfigPath = join(localPath, "bos.config.json");
409
- if (existsSync(pluginConfigPath)) try {
410
- const pluginConfig = JSON.parse(readFileSync(pluginConfigPath, "utf-8"));
411
- if (!pluginConfig.app) pluginConfig.app = {};
412
- const app = pluginConfig.app;
413
- if (!app.api) app.api = {};
414
- const api = app.api;
415
- api.production = publishedUrl;
416
- if (integrity) api.integrity = integrity;
417
- else delete api.integrity;
418
- writeFileSync(pluginConfigPath, `${JSON.stringify(pluginConfig, null, 2)}\n`);
419
- console.log(` ✅ Updated ${pluginConfigPath}: app.api.production`);
420
- } catch (err) {
421
- console.error(` ❌ Failed to update plugin bos.config.json:`, err instanceof Error ? err.message : err);
422
- }
423
- const account = deps.bosConfig.account;
424
- const network = getNetworkIdForAccount(account);
425
- let pluginDomain;
426
- if (existsSync(pluginConfigPath)) try {
427
- const pluginConfig = JSON.parse(readFileSync(pluginConfigPath, "utf-8"));
428
- if (typeof pluginConfig.domain === "string") pluginDomain = pluginConfig.domain;
429
- } catch {}
430
- if (!pluginDomain) pluginDomain = `${input.key}.${deps.bosConfig.domain ?? "everything.dev"}`;
408
+ const rootConfigPath = join(deps.configDir, "bos.config.json");
431
409
  try {
432
- const registryEntries = {};
433
- if (existsSync(pluginConfigPath)) try {
434
- const publishedPluginConfig = JSON.parse(readFileSync(pluginConfigPath, "utf-8"));
435
- delete publishedPluginConfig.development;
436
- registryEntries[`apps/${account}/${pluginDomain}/bos.config.json`] = JSON.stringify(publishedPluginConfig);
437
- } catch {}
438
- if (Object.keys(registryEntries).length > 0) {
439
- const payload = JSON.stringify(registryEntries);
440
- const argsBase64 = Buffer.from(payload).toString("base64");
441
- const privateKey = process.env.NEAR_PRIVATE_KEY || process.env.BOS_NEAR_PRIVATE_KEY;
442
- await Effect.runPromise(ensureNearCli);
443
- try {
444
- await Effect.runPromise(executeTransaction({
445
- account,
446
- contract: getRegistryNamespaceForNetwork(network),
447
- method: "__fastdata_kv",
448
- argsBase64,
449
- network,
450
- privateKey,
451
- gas: "50Tgas",
452
- deposit: "0NEAR"
453
- }));
454
- } catch (registryError) {
455
- if (!extractTransactionHash(registryError)) console.warn(`[publish] Plugin registry write failed: ${registryError instanceof Error ? registryError.message : registryError}`);
456
- }
457
- }
458
- } catch (registryError) {
459
- console.warn(`[publish] Plugin registry write skipped: ${registryError instanceof Error ? registryError.message : registryError}`);
410
+ const rootConfig = JSON.parse(readFileSync(rootConfigPath, "utf-8"));
411
+ if (!rootConfig.plugins || typeof rootConfig.plugins !== "object") rootConfig.plugins = {};
412
+ const plugins = rootConfig.plugins;
413
+ if (!plugins[input.key] || typeof plugins[input.key] !== "object") plugins[input.key] = {};
414
+ const entry = plugins[input.key];
415
+ entry.production = publishedUrl;
416
+ if (integrity) entry.integrity = integrity;
417
+ else delete entry.integrity;
418
+ writeFileSync(rootConfigPath, `${JSON.stringify(rootConfig, null, 2)}\n`);
419
+ console.log(` ✅ Updated bos.config.json: plugins.${input.key}.production`);
420
+ } catch (err) {
421
+ console.error(` ❌ Failed to update bos.config.json:`, err instanceof Error ? err.message : err);
460
422
  }
461
423
  await generateCodeArtifacts(deps.configDir, deps.bosConfig);
462
424
  }
@@ -724,18 +686,6 @@ var plugin_default = createPlugin({
724
686
  }
725
687
  }
726
688
  const registryEntries = { [`apps/${account}/${gateway}/bos.config.json`]: JSON.stringify(publishConfig) };
727
- for (const [pluginKey, pluginEntry] of Object.entries(publishConfig.plugins ?? {})) {
728
- const pluginRef = getPluginRef(pluginEntry);
729
- if (!pluginRef?.development?.startsWith("local:")) continue;
730
- const pluginConfigPath = join(join(deps.configDir, pluginRef.development.slice(6)), "bos.config.json");
731
- if (!existsSync(pluginConfigPath)) continue;
732
- try {
733
- const pluginConfig = JSON.parse(readFileSync(pluginConfigPath, "utf-8"));
734
- const pluginDomain = typeof pluginConfig.domain === "string" ? pluginConfig.domain : `${pluginKey}.${gateway}`;
735
- delete pluginConfig.development;
736
- registryEntries[`apps/${account}/${pluginDomain}/bos.config.json`] = JSON.stringify(pluginConfig);
737
- } catch {}
738
- }
739
689
  const payload = JSON.stringify(registryEntries);
740
690
  const argsBase64 = Buffer.from(payload).toString("base64");
741
691
  const privateKey = input.privateKey || process.env.NEAR_PRIVATE_KEY || process.env.BOS_NEAR_PRIVATE_KEY;
@@ -825,18 +775,18 @@ var plugin_default = createPlugin({
825
775
  init: builder.init.handler(async ({ input }) => {
826
776
  try {
827
777
  const timings = [];
828
- let extendsAccount = input.extendsAccount;
829
- let extendsGateway = input.extendsGateway;
778
+ let extendsAccount = "";
779
+ let extendsGateway = "";
830
780
  let directory = input.directory;
831
781
  let account = input.account;
832
782
  let domain = input.domain;
833
783
  let withHost = input.withHost;
834
784
  let plugins = input.plugins;
835
785
  if (input.extends) {
836
- const match = input.extends.match(/^(?:bos:\/\/)?([^/]+)\/(.+)$/);
786
+ const match = (input.extends.startsWith("bos://") ? input.extends : `bos://${input.extends}`).match(/^bos:\/\/([^/]+)\/(.+)$/);
837
787
  if (match) {
838
- if (!extendsAccount) extendsAccount = match[1];
839
- if (!extendsGateway) extendsGateway = match[2];
788
+ extendsAccount = match[1];
789
+ extendsGateway = match[2];
840
790
  }
841
791
  }
842
792
  extendsAccount = extendsAccount || "dev.everything.near";
@@ -849,9 +799,7 @@ var plugin_default = createPlugin({
849
799
  } catch {}
850
800
  if (!input.noInteractive) {
851
801
  const prompted = await promptInitOptions({
852
- extendsAccount,
853
- extendsGateway,
854
- extends: input.extends,
802
+ extends: `bos://${extendsAccount}/${extendsGateway}`,
855
803
  directory,
856
804
  account,
857
805
  domain,
@@ -870,21 +818,21 @@ var plugin_default = createPlugin({
870
818
  directory = directory || domain || extendsGateway;
871
819
  const targetDir = resolve(directory);
872
820
  plugins = plugins ?? [];
821
+ const extendsRef = `bos://${extendsAccount}/${extendsGateway}`;
873
822
  if (!parentConfig) try {
874
823
  parentConfig = await timePhase(timings, "parent config", () => fetchParentConfig(extendsAccount, extendsGateway));
875
824
  } catch {
876
825
  return {
877
826
  status: "error",
878
827
  directory,
879
- extendsAccount,
880
- extendsGateway,
828
+ extendsRef,
881
829
  account,
882
830
  domain,
883
- extends: `bos://${extendsAccount}/${extendsGateway}`,
831
+ extends: extendsRef,
884
832
  plugins: plugins ?? [],
885
833
  filesCopied: 0,
886
834
  timings,
887
- error: `No config found at bos://${extendsAccount}/${extendsGateway} — are you sure this is the right parent?`
835
+ error: `No config found at ${extendsRef} — are you sure this is the right parent?`
888
836
  };
889
837
  }
890
838
  const { sourceDir, parentConfig: resolvedParentConfig, cleanup } = await timePhase(timings, "template source", () => resolveSourceDir({
@@ -893,47 +841,56 @@ var plugin_default = createPlugin({
893
841
  source: input.source
894
842
  }));
895
843
  parentConfig = resolvedParentConfig;
844
+ const isMinimalScaffold = sourceDir === "";
896
845
  try {
897
- const patterns = await readTemplatekeep(sourceDir);
898
- if (patterns.length === 0) return {
899
- status: "error",
900
- directory,
901
- extendsAccount,
902
- extendsGateway,
903
- account,
904
- domain,
905
- extends: `bos://${extendsAccount}/${extendsGateway}`,
906
- plugins: plugins ?? [],
907
- filesCopied: 0,
908
- error: "No .templatekeep found in template source"
909
- };
910
- const pluginRoutes = {};
911
- if (parentConfig.plugins) for (const [key, entry] of Object.entries(parentConfig.plugins)) {
912
- const entryRef = getPluginRef(entry);
913
- if (entryRef?.routes && entryRef.routes.length > 0) pluginRoutes[key] = entryRef.routes;
914
- }
915
846
  const s = p.spinner();
916
847
  s.start("Setting up project");
917
- const filesCopied = await timePhase(timings, "copy files", () => copyFilteredFiles(sourceDir, targetDir, patterns, {
918
- withHost,
919
- plugins,
920
- pluginRoutes
921
- }));
922
- await timePhase(timings, "personalize config", () => personalizeConfig(targetDir, {
848
+ let filesCopied;
849
+ if (isMinimalScaffold) filesCopied = await timePhase(timings, "scaffold project", () => scaffoldMinimalProject(targetDir, parentConfig, {
923
850
  extendsAccount,
924
851
  extendsGateway,
925
852
  account: account || extendsAccount,
926
- domain: domain || extendsGateway,
853
+ domain,
927
854
  plugins,
928
- pluginRoutes,
929
- workspaceOpts: { sourceDir },
930
855
  withHost
931
856
  }));
932
- await timePhase(timings, "write snapshot", () => writeInitSnapshot(targetDir, extendsAccount, extendsGateway, sourceDir, patterns, {
933
- withHost,
934
- plugins,
935
- pluginRoutes
936
- }));
857
+ else {
858
+ const patterns = await readTemplatekeep(sourceDir);
859
+ if (patterns.length === 0) return {
860
+ status: "error",
861
+ directory,
862
+ extendsRef,
863
+ account,
864
+ domain,
865
+ extends: extendsRef,
866
+ plugins: plugins ?? [],
867
+ filesCopied: 0,
868
+ error: "No .templatekeep found in template source"
869
+ };
870
+ const pluginRoutes = {};
871
+ const parentRuntimePlugins = await buildRuntimePluginsForConfig(parentConfig, sourceDir, "production");
872
+ for (const [key, plugin] of Object.entries(parentRuntimePlugins ?? {})) if (plugin.routes && plugin.routes.length > 0) pluginRoutes[key] = plugin.routes;
873
+ filesCopied = await timePhase(timings, "copy files", () => copyFilteredFiles(sourceDir, targetDir, patterns, {
874
+ withHost,
875
+ plugins,
876
+ pluginRoutes
877
+ }));
878
+ await timePhase(timings, "personalize config", () => personalizeConfig(targetDir, {
879
+ extendsAccount,
880
+ extendsGateway,
881
+ account: account || extendsAccount,
882
+ domain: domain || extendsGateway,
883
+ plugins,
884
+ pluginRoutes,
885
+ workspaceOpts: { sourceDir },
886
+ withHost
887
+ }));
888
+ await timePhase(timings, "write snapshot", () => writeInitSnapshot(targetDir, extendsAccount, extendsGateway, sourceDir, patterns, {
889
+ withHost,
890
+ plugins,
891
+ pluginRoutes
892
+ }));
893
+ }
937
894
  const initConfig = await timePhase(timings, "resolve config", () => loadConfig({ cwd: targetDir }));
938
895
  if (initConfig?.runtime) await timePhase(timings, "generate env/docker", async () => {
939
896
  writeGeneratedInfra(targetDir, initConfig.runtime);
@@ -967,11 +924,10 @@ var plugin_default = createPlugin({
967
924
  return {
968
925
  status: "initialized",
969
926
  directory,
970
- extendsAccount,
971
- extendsGateway,
927
+ extendsRef,
972
928
  account,
973
929
  domain,
974
- extends: `bos://${extendsAccount}/${extendsGateway}`,
930
+ extends: extendsRef,
975
931
  plugins,
976
932
  filesCopied,
977
933
  timings
@@ -980,14 +936,14 @@ var plugin_default = createPlugin({
980
936
  await cleanup();
981
937
  }
982
938
  } catch (error) {
939
+ const extendsRef = input.extends ? input.extends.startsWith("bos://") ? input.extends : `bos://${input.extends}` : "bos://dev.everything.near/everything.dev";
983
940
  return {
984
941
  status: "error",
985
942
  directory: input.directory ?? "",
986
- extendsAccount: input.extendsAccount ?? "",
987
- extendsGateway: input.extendsGateway ?? "",
943
+ extendsRef,
988
944
  account: input.account,
989
945
  domain: input.domain,
990
- extends: input.extendsAccount && input.extendsGateway ? `bos://${input.extendsAccount}/${input.extendsGateway}` : "",
946
+ extends: extendsRef,
991
947
  plugins: input.plugins ?? [],
992
948
  filesCopied: 0,
993
949
  timings: [],