everything-dev 1.20.0 → 1.22.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/dist/cli/init.cjs +163 -80
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.d.cts +12 -6
- package/dist/cli/init.d.cts.map +1 -1
- package/dist/cli/init.d.mts +12 -6
- package/dist/cli/init.d.mts.map +1 -1
- package/dist/cli/init.mjs +163 -81
- package/dist/cli/init.mjs.map +1 -1
- package/dist/cli/parse.cjs +9 -0
- package/dist/cli/parse.cjs.map +1 -1
- package/dist/cli/parse.mjs +9 -0
- package/dist/cli/parse.mjs.map +1 -1
- package/dist/cli/prompts.cjs +44 -13
- package/dist/cli/prompts.cjs.map +1 -1
- package/dist/cli/prompts.mjs +44 -13
- package/dist/cli/prompts.mjs.map +1 -1
- package/dist/cli/sync.cjs +6 -0
- package/dist/cli/sync.cjs.map +1 -1
- package/dist/cli/sync.mjs +6 -0
- package/dist/cli/sync.mjs.map +1 -1
- package/dist/cli.cjs +3 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +3 -1
- package/dist/cli.mjs.map +1 -1
- package/dist/contract.cjs +9 -1
- package/dist/contract.cjs.map +1 -1
- package/dist/contract.d.cts +33 -4
- package/dist/contract.d.cts.map +1 -1
- package/dist/contract.d.mts +33 -4
- package/dist/contract.d.mts.map +1 -1
- package/dist/contract.meta.cjs +2 -2
- package/dist/contract.meta.cjs.map +1 -1
- package/dist/contract.meta.d.cts +3 -3
- package/dist/contract.meta.d.mts +3 -3
- package/dist/contract.meta.mjs +2 -2
- package/dist/contract.meta.mjs.map +1 -1
- package/dist/contract.mjs +9 -2
- package/dist/contract.mjs.map +1 -1
- package/dist/fastkv.cjs +4 -1
- package/dist/fastkv.cjs.map +1 -1
- package/dist/fastkv.mjs +4 -1
- package/dist/fastkv.mjs.map +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/plugin.cjs +43 -20
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +13 -2
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +13 -2
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +44 -21
- package/dist/plugin.mjs.map +1 -1
- package/package.json +1 -1
- package/src/cli/init.ts +252 -95
- package/src/cli/parse.ts +17 -0
- package/src/cli/prompts.ts +45 -28
- package/src/cli/sync.ts +1 -0
- package/src/cli.ts +8 -1
- package/src/contract.meta.ts +6 -2
- package/src/contract.ts +5 -1
- package/src/fastkv.ts +6 -1
- package/src/plugin.ts +58 -18
package/dist/cli/init.mjs
CHANGED
|
@@ -14,6 +14,13 @@ import { glob } from "glob";
|
|
|
14
14
|
|
|
15
15
|
//#region src/cli/init.ts
|
|
16
16
|
const require = createRequire(import.meta.url);
|
|
17
|
+
const FRAMEWORK_PACKAGES = ["every-plugin", "everything-dev"];
|
|
18
|
+
const OVERRIDE_WORKSPACE_MAP = {
|
|
19
|
+
ui: ["ui"],
|
|
20
|
+
api: ["api"],
|
|
21
|
+
host: ["host"],
|
|
22
|
+
plugins: []
|
|
23
|
+
};
|
|
17
24
|
async function resolveSourceDir(opts) {
|
|
18
25
|
if (opts.source) {
|
|
19
26
|
const sourceDir = resolve(opts.source);
|
|
@@ -79,6 +86,30 @@ async function resolveRepositoryViaExtendsChain(extendsAccount, extendsGateway,
|
|
|
79
86
|
return null;
|
|
80
87
|
}
|
|
81
88
|
}
|
|
89
|
+
async function detectGitRemoteUrl(directory) {
|
|
90
|
+
try {
|
|
91
|
+
const { stdout } = await execa("git", [
|
|
92
|
+
"remote",
|
|
93
|
+
"get-url",
|
|
94
|
+
"origin"
|
|
95
|
+
], {
|
|
96
|
+
cwd: directory,
|
|
97
|
+
stdio: "pipe"
|
|
98
|
+
});
|
|
99
|
+
const url = stdout.trim();
|
|
100
|
+
if (!url) return void 0;
|
|
101
|
+
return normalizeGitUrl(url);
|
|
102
|
+
} catch {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function normalizeGitUrl(url) {
|
|
107
|
+
const sshMatch = url.match(/^git@github\.com:([^/]+)\/([^/]+?)(?:\.git)?$/);
|
|
108
|
+
if (sshMatch) return `https://github.com/${sshMatch[1]}/${sshMatch[2]}`;
|
|
109
|
+
const httpsMatch = url.match(/^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?(?:\/.*)?$/);
|
|
110
|
+
if (httpsMatch) return `https://github.com/${httpsMatch[1]}/${httpsMatch[2]}`;
|
|
111
|
+
return url.endsWith(".git") ? url.slice(0, -4) : url;
|
|
112
|
+
}
|
|
82
113
|
async function downloadTarball(repoUrl) {
|
|
83
114
|
const parsed = parseGitHubUrl(repoUrl);
|
|
84
115
|
if (!parsed) throw new Error(`Cannot parse repository URL: ${repoUrl}`);
|
|
@@ -152,9 +183,20 @@ function parseGitHubUrl(url) {
|
|
|
152
183
|
};
|
|
153
184
|
return null;
|
|
154
185
|
}
|
|
186
|
+
function filterPatternsByOverrides(patterns, overrides, _plugins) {
|
|
187
|
+
const has = (section) => overrides.includes(section);
|
|
188
|
+
let filtered = [...patterns];
|
|
189
|
+
if (!has("host")) filtered = filtered.filter((p) => !p.startsWith("host/") && p !== "host/**");
|
|
190
|
+
if (!has("ui")) filtered = filtered.filter((p) => !p.startsWith("ui/") && p !== "ui/**");
|
|
191
|
+
if (!has("api")) filtered = filtered.filter((p) => !p.startsWith("api/") && p !== "api/**");
|
|
192
|
+
if (!has("plugins")) filtered = filtered.filter((p) => !p.startsWith("plugins/") && p !== "plugins/**");
|
|
193
|
+
return filtered;
|
|
194
|
+
}
|
|
155
195
|
async function copyFilteredFiles(sourceDir, destination, patterns, options) {
|
|
156
196
|
if (patterns.length === 0) return 0;
|
|
157
|
-
const
|
|
197
|
+
const has = (section) => options.overrides.includes(section);
|
|
198
|
+
const effectivePatterns = filterPatternsByOverrides(patterns, options.overrides, options.plugins);
|
|
199
|
+
if (has("host") && !effectivePatterns.some((p) => p.startsWith("host/") || p === "host/**")) effectivePatterns.push("host/**");
|
|
158
200
|
const excludedRoutePatterns = [];
|
|
159
201
|
if (options.pluginRoutes) {
|
|
160
202
|
for (const [pluginKey, routePatterns] of Object.entries(options.pluginRoutes)) if (!(options.plugins?.includes(pluginKey) ?? true)) excludedRoutePatterns.push(...routePatterns);
|
|
@@ -203,45 +245,52 @@ async function copyFilteredFiles(sourceDir, destination, patterns, options) {
|
|
|
203
245
|
}
|
|
204
246
|
return count;
|
|
205
247
|
}
|
|
248
|
+
function stripProductionFields(entry) {
|
|
249
|
+
delete entry.production;
|
|
250
|
+
delete entry.integrity;
|
|
251
|
+
delete entry.ssr;
|
|
252
|
+
delete entry.ssrIntegrity;
|
|
253
|
+
}
|
|
206
254
|
async function personalizeConfig(destination, opts) {
|
|
207
255
|
const isInit = opts.mode !== "sync";
|
|
256
|
+
const has = (section) => opts.overrides.includes(section);
|
|
208
257
|
const configPath = join(destination, "bos.config.json");
|
|
209
258
|
if (existsSync(configPath)) {
|
|
210
259
|
const config = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
211
260
|
config.extends = `bos://${opts.extendsAccount}/${opts.extendsGateway}`;
|
|
212
261
|
if (opts.account) config.account = opts.account;
|
|
213
262
|
if (opts.domain) config.domain = opts.domain;
|
|
263
|
+
if (opts.repository) config.repository = opts.repository;
|
|
214
264
|
if (isInit && config.app && typeof config.app === "object") {
|
|
215
265
|
const app = config.app;
|
|
216
266
|
for (const entryKey of Object.keys(app)) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
delete e.production;
|
|
221
|
-
delete e.integrity;
|
|
222
|
-
delete e.ssr;
|
|
223
|
-
delete e.ssrIntegrity;
|
|
267
|
+
if (!has(entryKey) && (entryKey === "host" || entryKey === "ui" || entryKey === "api" || entryKey === "auth")) {
|
|
268
|
+
delete app[entryKey];
|
|
269
|
+
continue;
|
|
224
270
|
}
|
|
271
|
+
const entry = app[entryKey];
|
|
272
|
+
if (entry && typeof entry === "object") stripProductionFields(entry);
|
|
225
273
|
}
|
|
226
274
|
}
|
|
227
|
-
if (
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
275
|
+
if (has("plugins")) {
|
|
276
|
+
if (config.plugins && typeof config.plugins === "object") {
|
|
277
|
+
const plugins = config.plugins;
|
|
278
|
+
if (opts.plugins !== void 0) {
|
|
279
|
+
for (const pluginKey of Object.keys(plugins)) if (!opts.plugins.includes(pluginKey)) delete plugins[pluginKey];
|
|
280
|
+
}
|
|
281
|
+
for (const pluginKey of Object.keys(plugins)) {
|
|
282
|
+
const plugin = plugins[pluginKey];
|
|
283
|
+
let pluginObj;
|
|
284
|
+
if (typeof plugin === "string") {
|
|
285
|
+
pluginObj = { extends: plugin };
|
|
286
|
+
plugins[pluginKey] = pluginObj;
|
|
287
|
+
} else if (plugin && typeof plugin === "object") pluginObj = { ...plugin };
|
|
288
|
+
else continue;
|
|
289
|
+
stripProductionFields(pluginObj);
|
|
290
|
+
}
|
|
291
|
+
if (Object.keys(plugins).length === 0) config.plugins = {};
|
|
242
292
|
}
|
|
243
|
-
|
|
244
|
-
}
|
|
293
|
+
} else delete config.plugins;
|
|
245
294
|
await saveBosConfig(destination, config);
|
|
246
295
|
}
|
|
247
296
|
const pkgPath = join(destination, "package.json");
|
|
@@ -251,10 +300,10 @@ async function personalizeConfig(destination, opts) {
|
|
|
251
300
|
const ws = pkg.workspaces;
|
|
252
301
|
if (Array.isArray(ws.packages)) ws.packages = ws.packages.filter((p) => {
|
|
253
302
|
if (p.startsWith("packages/")) return false;
|
|
254
|
-
if (p === "host") return
|
|
255
|
-
if (p === "plugins/*") return (opts.plugins?.length ?? 0) > 0;
|
|
303
|
+
if (p === "host") return has("host");
|
|
304
|
+
if (p === "plugins/*") return has("plugins") && (opts.plugins?.length ?? 0) > 0;
|
|
256
305
|
const pluginMatch = p.match(/^plugins\/([^/]+)/);
|
|
257
|
-
if (pluginMatch) return opts.plugins?.includes(pluginMatch[1]) ?? true;
|
|
306
|
+
if (pluginMatch) return has("plugins") && (opts.plugins?.includes(pluginMatch[1]) ?? true);
|
|
258
307
|
return true;
|
|
259
308
|
});
|
|
260
309
|
}
|
|
@@ -275,7 +324,7 @@ async function personalizeConfig(destination, opts) {
|
|
|
275
324
|
scripts["types:gen"] = "node_modules/.bin/bos types gen";
|
|
276
325
|
if (scripts.typecheck) {
|
|
277
326
|
scripts.typecheck = scripts.typecheck.replace("bun run types:gen && ", "").replace(/bun run --cwd packages\/everything-dev typecheck & ?/, "");
|
|
278
|
-
if (!
|
|
327
|
+
if (!has("host")) scripts.typecheck = scripts.typecheck.replace(/bun run --cwd host tsc --noEmit & ?/, "");
|
|
279
328
|
}
|
|
280
329
|
}
|
|
281
330
|
if (pkg.devDependencies && typeof pkg.devDependencies === "object") {
|
|
@@ -313,19 +362,25 @@ async function personalizeConfig(destination, opts) {
|
|
|
313
362
|
}
|
|
314
363
|
}
|
|
315
364
|
await resolveWorkspaceRefs(destination, opts.workspaceOpts);
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
365
|
+
if (has("ui")) {
|
|
366
|
+
const genContractPath = join(destination, "ui", "src", "lib", "api-types.gen.ts");
|
|
367
|
+
if (!existsSync(genContractPath)) {
|
|
368
|
+
mkdirSync(dirname(genContractPath), { recursive: true });
|
|
369
|
+
writeFileSync(genContractPath, `export type ApiContract = Record<string, never>;\n`);
|
|
370
|
+
}
|
|
320
371
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
372
|
+
if (has("api")) {
|
|
373
|
+
const pluginsClientGenPath = join(destination, "api", "src", "lib", "plugins-types.gen.ts");
|
|
374
|
+
if (!existsSync(pluginsClientGenPath)) {
|
|
375
|
+
mkdirSync(dirname(pluginsClientGenPath), { recursive: true });
|
|
376
|
+
writeFileSync(pluginsClientGenPath, `import type { ContractRouterClient, AnyContractRouter } from "@orpc/contract";\ntype ClientFactory<C extends AnyContractRouter> = (context?: Record<string, unknown>) => ContractRouterClient<C>;\nexport type PluginsClient = Record<string, never>;\n`);
|
|
377
|
+
}
|
|
325
378
|
}
|
|
326
379
|
const authTypesContent = generateAuthTypesTemplate();
|
|
327
|
-
const authTypesPaths = [
|
|
328
|
-
if (
|
|
380
|
+
const authTypesPaths = [];
|
|
381
|
+
if (has("ui")) authTypesPaths.push(join(destination, "ui", "src", "lib", "auth-types.gen.ts"));
|
|
382
|
+
if (has("api")) authTypesPaths.push(join(destination, "api", "src", "lib", "auth-types.gen.ts"));
|
|
383
|
+
if (has("host") && existsSync(join(destination, "host", "src"))) authTypesPaths.push(join(destination, "host", "src", "lib", "auth-types.gen.ts"));
|
|
329
384
|
for (const authTypesGenPath of authTypesPaths) if (!existsSync(authTypesGenPath)) {
|
|
330
385
|
mkdirSync(dirname(authTypesGenPath), { recursive: true });
|
|
331
386
|
writeFileSync(authTypesGenPath, authTypesContent);
|
|
@@ -382,10 +437,10 @@ export interface AuthServices {
|
|
|
382
437
|
`;
|
|
383
438
|
}
|
|
384
439
|
async function runBunInstall(destination) {
|
|
385
|
-
await execCommand("bun", ["install", "--ignore-scripts"], destination);
|
|
440
|
+
await execCommand("bun", ["install", "--ignore-scripts"], destination, { stdio: "inherit" });
|
|
386
441
|
}
|
|
387
442
|
async function runTypesGen(destination) {
|
|
388
|
-
await execCommand("node_modules/.bin/bos", ["types", "gen"], destination);
|
|
443
|
+
await execCommand("node_modules/.bin/bos", ["types", "gen"], destination, { stdio: "inherit" });
|
|
389
444
|
}
|
|
390
445
|
async function runDockerComposeUp(destination) {
|
|
391
446
|
await execCommand("docker", [
|
|
@@ -393,65 +448,69 @@ async function runDockerComposeUp(destination) {
|
|
|
393
448
|
"up",
|
|
394
449
|
"-d",
|
|
395
450
|
"--wait"
|
|
396
|
-
], destination);
|
|
451
|
+
], destination, { stdio: "inherit" });
|
|
397
452
|
}
|
|
398
453
|
const WORKSPACE_LOCAL_PATHS = {
|
|
399
454
|
"everything-dev": "packages/everything-dev",
|
|
400
455
|
"every-plugin": "packages/every-plugin"
|
|
401
456
|
};
|
|
457
|
+
function resolveFrameworkCatalog() {
|
|
458
|
+
const catalog = {};
|
|
459
|
+
for (const packageName of FRAMEWORK_PACKAGES) try {
|
|
460
|
+
const resolved = require.resolve(`${packageName}/package.json`);
|
|
461
|
+
const pkg = JSON.parse(readFileSync(resolved, "utf-8"));
|
|
462
|
+
if (pkg.version) catalog[packageName] = `^${pkg.version}`;
|
|
463
|
+
} catch {}
|
|
464
|
+
return catalog;
|
|
465
|
+
}
|
|
402
466
|
async function scaffoldMinimalProject(destination, parentConfig, opts) {
|
|
403
467
|
mkdirSync(destination, { recursive: true });
|
|
468
|
+
const has = (section) => opts.overrides.includes(section);
|
|
404
469
|
const config = {
|
|
405
470
|
extends: `bos://${opts.extendsAccount}/${opts.extendsGateway}`,
|
|
406
471
|
account: opts.account || opts.extendsAccount,
|
|
407
|
-
...opts.domain ? { domain: opts.domain } : {}
|
|
472
|
+
...opts.domain ? { domain: opts.domain } : {},
|
|
473
|
+
...opts.repository ? { repository: opts.repository } : {}
|
|
408
474
|
};
|
|
409
475
|
if (parentConfig.app && typeof parentConfig.app === "object") {
|
|
410
476
|
const app = {};
|
|
411
477
|
const parentApp = parentConfig.app;
|
|
412
|
-
if (parentApp.host) {
|
|
478
|
+
if (has("host") && parentApp.host) {
|
|
413
479
|
app.host = { ...parentApp.host };
|
|
414
|
-
|
|
415
|
-
delete host.production;
|
|
416
|
-
delete host.integrity;
|
|
480
|
+
stripProductionFields(app.host);
|
|
417
481
|
}
|
|
418
|
-
if (parentApp.ui) {
|
|
482
|
+
if (has("ui") && parentApp.ui) {
|
|
419
483
|
app.ui = { ...parentApp.ui };
|
|
420
|
-
|
|
421
|
-
delete ui.production;
|
|
422
|
-
delete ui.integrity;
|
|
423
|
-
delete ui.ssr;
|
|
424
|
-
delete ui.ssrIntegrity;
|
|
484
|
+
stripProductionFields(app.ui);
|
|
425
485
|
}
|
|
426
|
-
if (parentApp.api) {
|
|
486
|
+
if (has("api") && parentApp.api) {
|
|
427
487
|
app.api = { ...parentApp.api };
|
|
428
|
-
|
|
429
|
-
delete api.production;
|
|
430
|
-
delete api.integrity;
|
|
488
|
+
stripProductionFields(app.api);
|
|
431
489
|
}
|
|
432
|
-
if (parentApp.auth) {
|
|
490
|
+
if (has("plugins") && parentApp.auth) {
|
|
433
491
|
app.auth = { ...parentApp.auth };
|
|
434
|
-
|
|
435
|
-
delete auth.production;
|
|
436
|
-
delete auth.integrity;
|
|
492
|
+
stripProductionFields(app.auth);
|
|
437
493
|
}
|
|
438
|
-
config.app = app;
|
|
494
|
+
if (Object.keys(app).length > 0) config.app = app;
|
|
439
495
|
}
|
|
440
|
-
if (opts.plugins && opts.plugins.length > 0 && parentConfig.plugins) {
|
|
496
|
+
if (has("plugins") && opts.plugins && opts.plugins.length > 0 && parentConfig.plugins) {
|
|
441
497
|
const plugins = {};
|
|
442
498
|
for (const key of opts.plugins) {
|
|
443
499
|
const parentPlugin = parentConfig.plugins?.[key];
|
|
444
500
|
if (parentPlugin) if (typeof parentPlugin === "string") plugins[key] = { extends: parentPlugin };
|
|
445
501
|
else {
|
|
446
502
|
const pluginCopy = { ...parentPlugin };
|
|
447
|
-
|
|
448
|
-
delete pluginCopy.integrity;
|
|
503
|
+
stripProductionFields(pluginCopy);
|
|
449
504
|
plugins[key] = pluginCopy;
|
|
450
505
|
}
|
|
451
506
|
}
|
|
452
507
|
config.plugins = plugins;
|
|
453
508
|
}
|
|
454
509
|
await saveBosConfig(destination, config);
|
|
510
|
+
const workspacePackages = [];
|
|
511
|
+
for (const section of opts.overrides) workspacePackages.push(...OVERRIDE_WORKSPACE_MAP[section]);
|
|
512
|
+
if (has("plugins") && opts.plugins) for (const plugin of opts.plugins) workspacePackages.push(`plugins/${plugin}`);
|
|
513
|
+
const catalog = resolveFrameworkCatalog();
|
|
455
514
|
const pkg = {
|
|
456
515
|
name: opts.domain || opts.extendsGateway,
|
|
457
516
|
private: true,
|
|
@@ -474,12 +533,12 @@ async function scaffoldMinimalProject(destination, parentConfig, opts) {
|
|
|
474
533
|
},
|
|
475
534
|
devDependencies: {},
|
|
476
535
|
workspaces: {
|
|
477
|
-
packages:
|
|
478
|
-
catalog
|
|
536
|
+
packages: workspacePackages,
|
|
537
|
+
catalog
|
|
479
538
|
}
|
|
480
539
|
};
|
|
481
540
|
writeFileSync(join(destination, "package.json"), `${JSON.stringify(pkg, null, 2)}\n`);
|
|
482
|
-
const envExample = generateEnvExample(parentConfig);
|
|
541
|
+
const envExample = generateEnvExample(parentConfig, opts.overrides);
|
|
483
542
|
if (envExample) writeFileSync(join(destination, ".env.example"), envExample);
|
|
484
543
|
writeFileSync(join(destination, ".gitignore"), generateGitignore());
|
|
485
544
|
return 4;
|
|
@@ -514,7 +573,9 @@ async function resolveWorkspaceRefs(destination, options) {
|
|
|
514
573
|
}
|
|
515
574
|
}
|
|
516
575
|
async function writeInitSnapshot(destination, extendsAccount, extendsGateway, sourceDir, patterns, options) {
|
|
517
|
-
const effectivePatterns =
|
|
576
|
+
const effectivePatterns = filterPatternsByOverrides(patterns, options.overrides, options.plugins);
|
|
577
|
+
const has = (section) => options.overrides.includes(section);
|
|
578
|
+
if (has("host") && !effectivePatterns.some((p) => p.startsWith("host/") || p === "host/**")) effectivePatterns.push("host/**");
|
|
518
579
|
const excludedRoutePatterns = [];
|
|
519
580
|
if (options.pluginRoutes) {
|
|
520
581
|
for (const [pluginKey, routePatterns] of Object.entries(options.pluginRoutes)) if (!(options.plugins?.includes(pluginKey) ?? true)) excludedRoutePatterns.push(...routePatterns);
|
|
@@ -581,23 +642,44 @@ async function generateDatabaseMigrations(destination) {
|
|
|
581
642
|
await execCommand("bun", ["run", "db:generate"], join(destination, workspaceDir));
|
|
582
643
|
}
|
|
583
644
|
}
|
|
584
|
-
|
|
645
|
+
const COMMAND_TIMEOUTS = {
|
|
646
|
+
bun: 5 * 6e4,
|
|
647
|
+
docker: 5 * 6e4,
|
|
648
|
+
node_modules: 2 * 6e4,
|
|
649
|
+
tar: 6e4
|
|
650
|
+
};
|
|
651
|
+
async function execCommand(command, args, cwd, options) {
|
|
652
|
+
const timeout = COMMAND_TIMEOUTS[command] ?? 2 * 6e4;
|
|
585
653
|
await execa(command, args, {
|
|
586
654
|
cwd,
|
|
587
|
-
stdio: "pipe"
|
|
655
|
+
stdio: options?.stdio ?? "pipe",
|
|
656
|
+
timeout
|
|
588
657
|
});
|
|
589
658
|
}
|
|
590
|
-
function generateEnvExample(config) {
|
|
659
|
+
function generateEnvExample(config, overrides) {
|
|
660
|
+
const has = (section) => overrides.includes(section);
|
|
591
661
|
const lines = ["# Environment variables"];
|
|
592
|
-
const collectSecrets = (obj, prefix = "") => {
|
|
593
|
-
for (const [key, value] of Object.entries(obj))
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
662
|
+
const collectSecrets = (obj, includeSection, prefix = "") => {
|
|
663
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
664
|
+
if (!includeSection) continue;
|
|
665
|
+
if (key === "secrets" && Array.isArray(value)) {
|
|
666
|
+
for (const secret of value) if (typeof secret === "string") lines.push(`${secret}=`);
|
|
667
|
+
} else if (key === "variables" && isPlainObject(value)) {
|
|
668
|
+
for (const [varKey, varVal] of Object.entries(value)) if (typeof varVal === "string") lines.push(`${varKey}=${varVal}`);
|
|
669
|
+
} else if (isPlainObject(value) && key !== "extends") collectSecrets(value, includeSection, `${prefix}${key}.`);
|
|
670
|
+
}
|
|
598
671
|
};
|
|
599
|
-
if (config.app && typeof config.app === "object")
|
|
600
|
-
|
|
672
|
+
if (config.app && typeof config.app === "object") {
|
|
673
|
+
const app = config.app;
|
|
674
|
+
collectSecrets(app, has("host"), "host.");
|
|
675
|
+
collectSecrets(app, has("ui"), "ui.");
|
|
676
|
+
collectSecrets(app, has("api"), "api.");
|
|
677
|
+
collectSecrets(app, has("plugins"), "auth.");
|
|
678
|
+
}
|
|
679
|
+
if (has("plugins") && config.plugins && typeof config.plugins === "object") {
|
|
680
|
+
for (const [pluginKey, pluginVal] of Object.entries(config.plugins)) if (isPlainObject(pluginVal)) collectSecrets(pluginVal, true);
|
|
681
|
+
else if (typeof pluginVal === "string") lines.push(`# Plugin '${pluginKey}' extends ${pluginVal}`);
|
|
682
|
+
}
|
|
601
683
|
lines.push("BETTER_AUTH_SECRET=generate-a-secret-here");
|
|
602
684
|
return `${lines.join("\n")}\n`;
|
|
603
685
|
}
|
|
@@ -615,5 +697,5 @@ dist/
|
|
|
615
697
|
}
|
|
616
698
|
|
|
617
699
|
//#endregion
|
|
618
|
-
export { copyFilteredFiles, downloadTarball, execCommand, fetchParentConfig, generateDatabaseMigrations, personalizeConfig, readTemplatekeep, resolveRepositoryViaExtendsChain, resolveSourceDir, runBunInstall, runDockerComposeUp, runTypesGen, scaffoldMinimalProject, writeInitSnapshot };
|
|
700
|
+
export { copyFilteredFiles, detectGitRemoteUrl, downloadTarball, execCommand, fetchParentConfig, generateDatabaseMigrations, personalizeConfig, readTemplatekeep, resolveRepositoryViaExtendsChain, resolveSourceDir, runBunInstall, runDockerComposeUp, runTypesGen, scaffoldMinimalProject, writeInitSnapshot };
|
|
619
701
|
//# sourceMappingURL=init.mjs.map
|