everything-dev 1.20.0 → 1.21.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 +138 -74
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.d.cts +9 -5
- package/dist/cli/init.d.cts.map +1 -1
- package/dist/cli/init.d.mts +9 -5
- package/dist/cli/init.d.mts.map +1 -1
- package/dist/cli/init.mjs +138 -75
- 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 +37 -8
- package/dist/contract.d.cts.map +1 -1
- package/dist/contract.d.mts +37 -8
- 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/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 +24 -12
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +16 -5
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +16 -5
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +25 -13
- package/dist/plugin.mjs.map +1 -1
- package/dist/types.d.cts +2 -2
- package/dist/types.d.mts +2 -2
- package/package.json +1 -1
- package/src/cli/init.ts +215 -89
- 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/plugin.ts +41 -18
package/dist/cli/init.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OverrideSection } from "../contract.cjs";
|
|
1
2
|
import { BosConfig, BosConfigInput } from "../types.cjs";
|
|
2
3
|
|
|
3
4
|
//#region src/cli/init.d.ts
|
|
@@ -17,12 +18,13 @@ declare function resolveRepositoryViaExtendsChain(extendsAccount: string, extend
|
|
|
17
18
|
repository: string;
|
|
18
19
|
config: BosConfig;
|
|
19
20
|
} | null>;
|
|
21
|
+
declare function detectGitRemoteUrl(directory: string): Promise<string | undefined>;
|
|
20
22
|
declare function downloadTarball(repoUrl: string): Promise<{
|
|
21
23
|
dir: string;
|
|
22
24
|
cleanup: () => Promise<void>;
|
|
23
25
|
}>;
|
|
24
26
|
declare function copyFilteredFiles(sourceDir: string, destination: string, patterns: string[], options: {
|
|
25
|
-
|
|
27
|
+
overrides: OverrideSection[];
|
|
26
28
|
plugins?: string[];
|
|
27
29
|
pluginRoutes?: Record<string, string[]>;
|
|
28
30
|
}): Promise<number>;
|
|
@@ -32,13 +34,14 @@ declare function personalizeConfig(destination: string, opts: {
|
|
|
32
34
|
account?: string;
|
|
33
35
|
domain?: string;
|
|
34
36
|
plugins?: string[];
|
|
37
|
+
overrides: OverrideSection[];
|
|
35
38
|
pluginRoutes?: Record<string, string[]>;
|
|
36
39
|
workspaceOpts?: {
|
|
37
40
|
localOverrides?: boolean;
|
|
38
41
|
sourceDir?: string;
|
|
39
42
|
};
|
|
40
43
|
mode?: "init" | "sync";
|
|
41
|
-
|
|
44
|
+
repository?: string;
|
|
42
45
|
}): Promise<void>;
|
|
43
46
|
declare function runBunInstall(destination: string): Promise<void>;
|
|
44
47
|
declare function runTypesGen(destination: string): Promise<void>;
|
|
@@ -49,15 +52,16 @@ declare function scaffoldMinimalProject(destination: string, parentConfig: BosCo
|
|
|
49
52
|
account?: string;
|
|
50
53
|
domain?: string;
|
|
51
54
|
plugins?: string[];
|
|
52
|
-
|
|
55
|
+
overrides: OverrideSection[];
|
|
56
|
+
repository?: string;
|
|
53
57
|
}): Promise<number>;
|
|
54
58
|
declare function writeInitSnapshot(destination: string, extendsAccount: string, extendsGateway: string, sourceDir: string, patterns: string[], options: {
|
|
55
|
-
|
|
59
|
+
overrides: OverrideSection[];
|
|
56
60
|
plugins?: string[];
|
|
57
61
|
pluginRoutes?: Record<string, string[]>;
|
|
58
62
|
}): Promise<void>;
|
|
59
63
|
declare function generateDatabaseMigrations(destination: string): Promise<void>;
|
|
60
64
|
declare function execCommand(command: string, args: string[], cwd?: string): Promise<void>;
|
|
61
65
|
//#endregion
|
|
62
|
-
export { copyFilteredFiles, downloadTarball, execCommand, fetchParentConfig, generateDatabaseMigrations, personalizeConfig, readTemplatekeep, resolveRepositoryViaExtendsChain, resolveSourceDir, runBunInstall, runDockerComposeUp, runTypesGen, scaffoldMinimalProject, writeInitSnapshot };
|
|
66
|
+
export { copyFilteredFiles, detectGitRemoteUrl, downloadTarball, execCommand, fetchParentConfig, generateDatabaseMigrations, personalizeConfig, readTemplatekeep, resolveRepositoryViaExtendsChain, resolveSourceDir, runBunInstall, runDockerComposeUp, runTypesGen, scaffoldMinimalProject, writeInitSnapshot };
|
|
63
67
|
//# sourceMappingURL=init.d.cts.map
|
package/dist/cli/init.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.cts","names":[],"sources":["../../src/cli/init.ts"],"mappings":"
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,MAAA;EACA,OAAA;EACA,SAAA,EAAW,eAAA;EACX,UAAA;AAAA,IAED,OAAA;AAAA,iBAuJmB,iBAAA,CACpB,WAAA,UACA,cAAA,UACA,cAAA,UACA,SAAA,UACA,QAAA,YACA,OAAA;EACE,SAAA,EAAW,eAAA;EACX,OAAA;EACA,YAAA,GAAe,MAAA;AAAA,IAEhB,OAAA;AAAA,iBA8EmB,0BAAA,CAA2B,WAAA,WAAsB,OAAA;AAAA,iBAuBjD,WAAA,CAAY,OAAA,UAAiB,IAAA,YAAgB,GAAA,YAAe,OAAA"}
|
package/dist/cli/init.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OverrideSection } from "../contract.mjs";
|
|
1
2
|
import { BosConfig, BosConfigInput } from "../types.mjs";
|
|
2
3
|
|
|
3
4
|
//#region src/cli/init.d.ts
|
|
@@ -17,12 +18,13 @@ declare function resolveRepositoryViaExtendsChain(extendsAccount: string, extend
|
|
|
17
18
|
repository: string;
|
|
18
19
|
config: BosConfig;
|
|
19
20
|
} | null>;
|
|
21
|
+
declare function detectGitRemoteUrl(directory: string): Promise<string | undefined>;
|
|
20
22
|
declare function downloadTarball(repoUrl: string): Promise<{
|
|
21
23
|
dir: string;
|
|
22
24
|
cleanup: () => Promise<void>;
|
|
23
25
|
}>;
|
|
24
26
|
declare function copyFilteredFiles(sourceDir: string, destination: string, patterns: string[], options: {
|
|
25
|
-
|
|
27
|
+
overrides: OverrideSection[];
|
|
26
28
|
plugins?: string[];
|
|
27
29
|
pluginRoutes?: Record<string, string[]>;
|
|
28
30
|
}): Promise<number>;
|
|
@@ -32,13 +34,14 @@ declare function personalizeConfig(destination: string, opts: {
|
|
|
32
34
|
account?: string;
|
|
33
35
|
domain?: string;
|
|
34
36
|
plugins?: string[];
|
|
37
|
+
overrides: OverrideSection[];
|
|
35
38
|
pluginRoutes?: Record<string, string[]>;
|
|
36
39
|
workspaceOpts?: {
|
|
37
40
|
localOverrides?: boolean;
|
|
38
41
|
sourceDir?: string;
|
|
39
42
|
};
|
|
40
43
|
mode?: "init" | "sync";
|
|
41
|
-
|
|
44
|
+
repository?: string;
|
|
42
45
|
}): Promise<void>;
|
|
43
46
|
declare function runBunInstall(destination: string): Promise<void>;
|
|
44
47
|
declare function runTypesGen(destination: string): Promise<void>;
|
|
@@ -49,15 +52,16 @@ declare function scaffoldMinimalProject(destination: string, parentConfig: BosCo
|
|
|
49
52
|
account?: string;
|
|
50
53
|
domain?: string;
|
|
51
54
|
plugins?: string[];
|
|
52
|
-
|
|
55
|
+
overrides: OverrideSection[];
|
|
56
|
+
repository?: string;
|
|
53
57
|
}): Promise<number>;
|
|
54
58
|
declare function writeInitSnapshot(destination: string, extendsAccount: string, extendsGateway: string, sourceDir: string, patterns: string[], options: {
|
|
55
|
-
|
|
59
|
+
overrides: OverrideSection[];
|
|
56
60
|
plugins?: string[];
|
|
57
61
|
pluginRoutes?: Record<string, string[]>;
|
|
58
62
|
}): Promise<void>;
|
|
59
63
|
declare function generateDatabaseMigrations(destination: string): Promise<void>;
|
|
60
64
|
declare function execCommand(command: string, args: string[], cwd?: string): Promise<void>;
|
|
61
65
|
//#endregion
|
|
62
|
-
export { copyFilteredFiles, downloadTarball, execCommand, fetchParentConfig, generateDatabaseMigrations, personalizeConfig, readTemplatekeep, resolveRepositoryViaExtendsChain, resolveSourceDir, runBunInstall, runDockerComposeUp, runTypesGen, scaffoldMinimalProject, writeInitSnapshot };
|
|
66
|
+
export { copyFilteredFiles, detectGitRemoteUrl, downloadTarball, execCommand, fetchParentConfig, generateDatabaseMigrations, personalizeConfig, readTemplatekeep, resolveRepositoryViaExtendsChain, resolveSourceDir, runBunInstall, runDockerComposeUp, runTypesGen, scaffoldMinimalProject, writeInitSnapshot };
|
|
63
67
|
//# sourceMappingURL=init.d.mts.map
|
package/dist/cli/init.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.mts","names":[],"sources":["../../src/cli/init.ts"],"mapp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;EACA,MAAA;EACA,OAAA;EACA,SAAA,EAAW,eAAA;EACX,UAAA;AAAA,IAED,OAAA;AAAA,iBAuJmB,iBAAA,CACpB,WAAA,UACA,cAAA,UACA,cAAA,UACA,SAAA,UACA,QAAA,YACA,OAAA;EACE,SAAA,EAAW,eAAA;EACX,OAAA;EACA,YAAA,GAAe,MAAA;AAAA,IAEhB,OAAA;AAAA,iBA8EmB,0BAAA,CAA2B,WAAA,WAAsB,OAAA;AAAA,iBAuBjD,WAAA,CAAY,OAAA,UAAiB,IAAA,YAAgB,GAAA,YAAe,OAAA"}
|
package/dist/cli/init.mjs
CHANGED
|
@@ -14,6 +14,12 @@ import { glob } from "glob";
|
|
|
14
14
|
|
|
15
15
|
//#region src/cli/init.ts
|
|
16
16
|
const require = createRequire(import.meta.url);
|
|
17
|
+
const OVERRIDE_WORKSPACE_MAP = {
|
|
18
|
+
ui: ["ui"],
|
|
19
|
+
api: ["api"],
|
|
20
|
+
host: ["host"],
|
|
21
|
+
plugins: []
|
|
22
|
+
};
|
|
17
23
|
async function resolveSourceDir(opts) {
|
|
18
24
|
if (opts.source) {
|
|
19
25
|
const sourceDir = resolve(opts.source);
|
|
@@ -79,6 +85,30 @@ async function resolveRepositoryViaExtendsChain(extendsAccount, extendsGateway,
|
|
|
79
85
|
return null;
|
|
80
86
|
}
|
|
81
87
|
}
|
|
88
|
+
async function detectGitRemoteUrl(directory) {
|
|
89
|
+
try {
|
|
90
|
+
const { stdout } = await execa("git", [
|
|
91
|
+
"remote",
|
|
92
|
+
"get-url",
|
|
93
|
+
"origin"
|
|
94
|
+
], {
|
|
95
|
+
cwd: directory,
|
|
96
|
+
stdio: "pipe"
|
|
97
|
+
});
|
|
98
|
+
const url = stdout.trim();
|
|
99
|
+
if (!url) return void 0;
|
|
100
|
+
return normalizeGitUrl(url);
|
|
101
|
+
} catch {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function normalizeGitUrl(url) {
|
|
106
|
+
const sshMatch = url.match(/^git@github\.com:([^/]+)\/([^/]+?)(?:\.git)?$/);
|
|
107
|
+
if (sshMatch) return `https://github.com/${sshMatch[1]}/${sshMatch[2]}`;
|
|
108
|
+
const httpsMatch = url.match(/^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?(?:\/.*)?$/);
|
|
109
|
+
if (httpsMatch) return `https://github.com/${httpsMatch[1]}/${httpsMatch[2]}`;
|
|
110
|
+
return url.endsWith(".git") ? url.slice(0, -4) : url;
|
|
111
|
+
}
|
|
82
112
|
async function downloadTarball(repoUrl) {
|
|
83
113
|
const parsed = parseGitHubUrl(repoUrl);
|
|
84
114
|
if (!parsed) throw new Error(`Cannot parse repository URL: ${repoUrl}`);
|
|
@@ -152,9 +182,20 @@ function parseGitHubUrl(url) {
|
|
|
152
182
|
};
|
|
153
183
|
return null;
|
|
154
184
|
}
|
|
185
|
+
function filterPatternsByOverrides(patterns, overrides, _plugins) {
|
|
186
|
+
const has = (section) => overrides.includes(section);
|
|
187
|
+
let filtered = [...patterns];
|
|
188
|
+
if (!has("host")) filtered = filtered.filter((p) => !p.startsWith("host/") && p !== "host/**");
|
|
189
|
+
if (!has("ui")) filtered = filtered.filter((p) => !p.startsWith("ui/") && p !== "ui/**");
|
|
190
|
+
if (!has("api")) filtered = filtered.filter((p) => !p.startsWith("api/") && p !== "api/**");
|
|
191
|
+
if (!has("plugins")) filtered = filtered.filter((p) => !p.startsWith("plugins/") && p !== "plugins/**");
|
|
192
|
+
return filtered;
|
|
193
|
+
}
|
|
155
194
|
async function copyFilteredFiles(sourceDir, destination, patterns, options) {
|
|
156
195
|
if (patterns.length === 0) return 0;
|
|
157
|
-
const
|
|
196
|
+
const has = (section) => options.overrides.includes(section);
|
|
197
|
+
const effectivePatterns = filterPatternsByOverrides(patterns, options.overrides, options.plugins);
|
|
198
|
+
if (has("host") && !effectivePatterns.some((p) => p.startsWith("host/") || p === "host/**")) effectivePatterns.push("host/**");
|
|
158
199
|
const excludedRoutePatterns = [];
|
|
159
200
|
if (options.pluginRoutes) {
|
|
160
201
|
for (const [pluginKey, routePatterns] of Object.entries(options.pluginRoutes)) if (!(options.plugins?.includes(pluginKey) ?? true)) excludedRoutePatterns.push(...routePatterns);
|
|
@@ -203,45 +244,52 @@ async function copyFilteredFiles(sourceDir, destination, patterns, options) {
|
|
|
203
244
|
}
|
|
204
245
|
return count;
|
|
205
246
|
}
|
|
247
|
+
function stripProductionFields(entry) {
|
|
248
|
+
delete entry.production;
|
|
249
|
+
delete entry.integrity;
|
|
250
|
+
delete entry.ssr;
|
|
251
|
+
delete entry.ssrIntegrity;
|
|
252
|
+
}
|
|
206
253
|
async function personalizeConfig(destination, opts) {
|
|
207
254
|
const isInit = opts.mode !== "sync";
|
|
255
|
+
const has = (section) => opts.overrides.includes(section);
|
|
208
256
|
const configPath = join(destination, "bos.config.json");
|
|
209
257
|
if (existsSync(configPath)) {
|
|
210
258
|
const config = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
211
259
|
config.extends = `bos://${opts.extendsAccount}/${opts.extendsGateway}`;
|
|
212
260
|
if (opts.account) config.account = opts.account;
|
|
213
261
|
if (opts.domain) config.domain = opts.domain;
|
|
262
|
+
if (opts.repository) config.repository = opts.repository;
|
|
214
263
|
if (isInit && config.app && typeof config.app === "object") {
|
|
215
264
|
const app = config.app;
|
|
216
265
|
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;
|
|
266
|
+
if (!has(entryKey) && (entryKey === "host" || entryKey === "ui" || entryKey === "api" || entryKey === "auth")) {
|
|
267
|
+
delete app[entryKey];
|
|
268
|
+
continue;
|
|
224
269
|
}
|
|
270
|
+
const entry = app[entryKey];
|
|
271
|
+
if (entry && typeof entry === "object") stripProductionFields(entry);
|
|
225
272
|
}
|
|
226
273
|
}
|
|
227
|
-
if (
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
274
|
+
if (has("plugins")) {
|
|
275
|
+
if (config.plugins && typeof config.plugins === "object") {
|
|
276
|
+
const plugins = config.plugins;
|
|
277
|
+
if (opts.plugins !== void 0) {
|
|
278
|
+
for (const pluginKey of Object.keys(plugins)) if (!opts.plugins.includes(pluginKey)) delete plugins[pluginKey];
|
|
279
|
+
}
|
|
280
|
+
for (const pluginKey of Object.keys(plugins)) {
|
|
281
|
+
const plugin = plugins[pluginKey];
|
|
282
|
+
let pluginObj;
|
|
283
|
+
if (typeof plugin === "string") {
|
|
284
|
+
pluginObj = { extends: plugin };
|
|
285
|
+
plugins[pluginKey] = pluginObj;
|
|
286
|
+
} else if (plugin && typeof plugin === "object") pluginObj = { ...plugin };
|
|
287
|
+
else continue;
|
|
288
|
+
stripProductionFields(pluginObj);
|
|
289
|
+
}
|
|
290
|
+
if (Object.keys(plugins).length === 0) config.plugins = {};
|
|
242
291
|
}
|
|
243
|
-
|
|
244
|
-
}
|
|
292
|
+
} else delete config.plugins;
|
|
245
293
|
await saveBosConfig(destination, config);
|
|
246
294
|
}
|
|
247
295
|
const pkgPath = join(destination, "package.json");
|
|
@@ -251,10 +299,10 @@ async function personalizeConfig(destination, opts) {
|
|
|
251
299
|
const ws = pkg.workspaces;
|
|
252
300
|
if (Array.isArray(ws.packages)) ws.packages = ws.packages.filter((p) => {
|
|
253
301
|
if (p.startsWith("packages/")) return false;
|
|
254
|
-
if (p === "host") return
|
|
255
|
-
if (p === "plugins/*") return (opts.plugins?.length ?? 0) > 0;
|
|
302
|
+
if (p === "host") return has("host");
|
|
303
|
+
if (p === "plugins/*") return has("plugins") && (opts.plugins?.length ?? 0) > 0;
|
|
256
304
|
const pluginMatch = p.match(/^plugins\/([^/]+)/);
|
|
257
|
-
if (pluginMatch) return opts.plugins?.includes(pluginMatch[1]) ?? true;
|
|
305
|
+
if (pluginMatch) return has("plugins") && (opts.plugins?.includes(pluginMatch[1]) ?? true);
|
|
258
306
|
return true;
|
|
259
307
|
});
|
|
260
308
|
}
|
|
@@ -275,7 +323,7 @@ async function personalizeConfig(destination, opts) {
|
|
|
275
323
|
scripts["types:gen"] = "node_modules/.bin/bos types gen";
|
|
276
324
|
if (scripts.typecheck) {
|
|
277
325
|
scripts.typecheck = scripts.typecheck.replace("bun run types:gen && ", "").replace(/bun run --cwd packages\/everything-dev typecheck & ?/, "");
|
|
278
|
-
if (!
|
|
326
|
+
if (!has("host")) scripts.typecheck = scripts.typecheck.replace(/bun run --cwd host tsc --noEmit & ?/, "");
|
|
279
327
|
}
|
|
280
328
|
}
|
|
281
329
|
if (pkg.devDependencies && typeof pkg.devDependencies === "object") {
|
|
@@ -313,19 +361,25 @@ async function personalizeConfig(destination, opts) {
|
|
|
313
361
|
}
|
|
314
362
|
}
|
|
315
363
|
await resolveWorkspaceRefs(destination, opts.workspaceOpts);
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
364
|
+
if (has("ui")) {
|
|
365
|
+
const genContractPath = join(destination, "ui", "src", "lib", "api-types.gen.ts");
|
|
366
|
+
if (!existsSync(genContractPath)) {
|
|
367
|
+
mkdirSync(dirname(genContractPath), { recursive: true });
|
|
368
|
+
writeFileSync(genContractPath, `export type ApiContract = Record<string, never>;\n`);
|
|
369
|
+
}
|
|
320
370
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
371
|
+
if (has("api")) {
|
|
372
|
+
const pluginsClientGenPath = join(destination, "api", "src", "lib", "plugins-types.gen.ts");
|
|
373
|
+
if (!existsSync(pluginsClientGenPath)) {
|
|
374
|
+
mkdirSync(dirname(pluginsClientGenPath), { recursive: true });
|
|
375
|
+
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`);
|
|
376
|
+
}
|
|
325
377
|
}
|
|
326
378
|
const authTypesContent = generateAuthTypesTemplate();
|
|
327
|
-
const authTypesPaths = [
|
|
328
|
-
if (
|
|
379
|
+
const authTypesPaths = [];
|
|
380
|
+
if (has("ui")) authTypesPaths.push(join(destination, "ui", "src", "lib", "auth-types.gen.ts"));
|
|
381
|
+
if (has("api")) authTypesPaths.push(join(destination, "api", "src", "lib", "auth-types.gen.ts"));
|
|
382
|
+
if (has("host") && existsSync(join(destination, "host", "src"))) authTypesPaths.push(join(destination, "host", "src", "lib", "auth-types.gen.ts"));
|
|
329
383
|
for (const authTypesGenPath of authTypesPaths) if (!existsSync(authTypesGenPath)) {
|
|
330
384
|
mkdirSync(dirname(authTypesGenPath), { recursive: true });
|
|
331
385
|
writeFileSync(authTypesGenPath, authTypesContent);
|
|
@@ -401,57 +455,51 @@ const WORKSPACE_LOCAL_PATHS = {
|
|
|
401
455
|
};
|
|
402
456
|
async function scaffoldMinimalProject(destination, parentConfig, opts) {
|
|
403
457
|
mkdirSync(destination, { recursive: true });
|
|
458
|
+
const has = (section) => opts.overrides.includes(section);
|
|
404
459
|
const config = {
|
|
405
460
|
extends: `bos://${opts.extendsAccount}/${opts.extendsGateway}`,
|
|
406
461
|
account: opts.account || opts.extendsAccount,
|
|
407
|
-
...opts.domain ? { domain: opts.domain } : {}
|
|
462
|
+
...opts.domain ? { domain: opts.domain } : {},
|
|
463
|
+
...opts.repository ? { repository: opts.repository } : {}
|
|
408
464
|
};
|
|
409
465
|
if (parentConfig.app && typeof parentConfig.app === "object") {
|
|
410
466
|
const app = {};
|
|
411
467
|
const parentApp = parentConfig.app;
|
|
412
|
-
if (parentApp.host) {
|
|
468
|
+
if (has("host") && parentApp.host) {
|
|
413
469
|
app.host = { ...parentApp.host };
|
|
414
|
-
|
|
415
|
-
delete host.production;
|
|
416
|
-
delete host.integrity;
|
|
470
|
+
stripProductionFields(app.host);
|
|
417
471
|
}
|
|
418
|
-
if (parentApp.ui) {
|
|
472
|
+
if (has("ui") && parentApp.ui) {
|
|
419
473
|
app.ui = { ...parentApp.ui };
|
|
420
|
-
|
|
421
|
-
delete ui.production;
|
|
422
|
-
delete ui.integrity;
|
|
423
|
-
delete ui.ssr;
|
|
424
|
-
delete ui.ssrIntegrity;
|
|
474
|
+
stripProductionFields(app.ui);
|
|
425
475
|
}
|
|
426
|
-
if (parentApp.api) {
|
|
476
|
+
if (has("api") && parentApp.api) {
|
|
427
477
|
app.api = { ...parentApp.api };
|
|
428
|
-
|
|
429
|
-
delete api.production;
|
|
430
|
-
delete api.integrity;
|
|
478
|
+
stripProductionFields(app.api);
|
|
431
479
|
}
|
|
432
|
-
if (parentApp.auth) {
|
|
480
|
+
if (has("plugins") && parentApp.auth) {
|
|
433
481
|
app.auth = { ...parentApp.auth };
|
|
434
|
-
|
|
435
|
-
delete auth.production;
|
|
436
|
-
delete auth.integrity;
|
|
482
|
+
stripProductionFields(app.auth);
|
|
437
483
|
}
|
|
438
|
-
config.app = app;
|
|
484
|
+
if (Object.keys(app).length > 0) config.app = app;
|
|
439
485
|
}
|
|
440
|
-
if (opts.plugins && opts.plugins.length > 0 && parentConfig.plugins) {
|
|
486
|
+
if (has("plugins") && opts.plugins && opts.plugins.length > 0 && parentConfig.plugins) {
|
|
441
487
|
const plugins = {};
|
|
442
488
|
for (const key of opts.plugins) {
|
|
443
489
|
const parentPlugin = parentConfig.plugins?.[key];
|
|
444
490
|
if (parentPlugin) if (typeof parentPlugin === "string") plugins[key] = { extends: parentPlugin };
|
|
445
491
|
else {
|
|
446
492
|
const pluginCopy = { ...parentPlugin };
|
|
447
|
-
|
|
448
|
-
delete pluginCopy.integrity;
|
|
493
|
+
stripProductionFields(pluginCopy);
|
|
449
494
|
plugins[key] = pluginCopy;
|
|
450
495
|
}
|
|
451
496
|
}
|
|
452
497
|
config.plugins = plugins;
|
|
453
498
|
}
|
|
454
499
|
await saveBosConfig(destination, config);
|
|
500
|
+
const workspacePackages = [];
|
|
501
|
+
for (const section of opts.overrides) workspacePackages.push(...OVERRIDE_WORKSPACE_MAP[section]);
|
|
502
|
+
if (has("plugins") && opts.plugins) for (const plugin of opts.plugins) workspacePackages.push(`plugins/${plugin}`);
|
|
455
503
|
const pkg = {
|
|
456
504
|
name: opts.domain || opts.extendsGateway,
|
|
457
505
|
private: true,
|
|
@@ -474,12 +522,12 @@ async function scaffoldMinimalProject(destination, parentConfig, opts) {
|
|
|
474
522
|
},
|
|
475
523
|
devDependencies: {},
|
|
476
524
|
workspaces: {
|
|
477
|
-
packages:
|
|
525
|
+
packages: workspacePackages,
|
|
478
526
|
catalog: {}
|
|
479
527
|
}
|
|
480
528
|
};
|
|
481
529
|
writeFileSync(join(destination, "package.json"), `${JSON.stringify(pkg, null, 2)}\n`);
|
|
482
|
-
const envExample = generateEnvExample(parentConfig);
|
|
530
|
+
const envExample = generateEnvExample(parentConfig, opts.overrides);
|
|
483
531
|
if (envExample) writeFileSync(join(destination, ".env.example"), envExample);
|
|
484
532
|
writeFileSync(join(destination, ".gitignore"), generateGitignore());
|
|
485
533
|
return 4;
|
|
@@ -514,7 +562,9 @@ async function resolveWorkspaceRefs(destination, options) {
|
|
|
514
562
|
}
|
|
515
563
|
}
|
|
516
564
|
async function writeInitSnapshot(destination, extendsAccount, extendsGateway, sourceDir, patterns, options) {
|
|
517
|
-
const effectivePatterns =
|
|
565
|
+
const effectivePatterns = filterPatternsByOverrides(patterns, options.overrides, options.plugins);
|
|
566
|
+
const has = (section) => options.overrides.includes(section);
|
|
567
|
+
if (has("host") && !effectivePatterns.some((p) => p.startsWith("host/") || p === "host/**")) effectivePatterns.push("host/**");
|
|
518
568
|
const excludedRoutePatterns = [];
|
|
519
569
|
if (options.pluginRoutes) {
|
|
520
570
|
for (const [pluginKey, routePatterns] of Object.entries(options.pluginRoutes)) if (!(options.plugins?.includes(pluginKey) ?? true)) excludedRoutePatterns.push(...routePatterns);
|
|
@@ -587,17 +637,30 @@ async function execCommand(command, args, cwd) {
|
|
|
587
637
|
stdio: "pipe"
|
|
588
638
|
});
|
|
589
639
|
}
|
|
590
|
-
function generateEnvExample(config) {
|
|
640
|
+
function generateEnvExample(config, overrides) {
|
|
641
|
+
const has = (section) => overrides.includes(section);
|
|
591
642
|
const lines = ["# Environment variables"];
|
|
592
|
-
const collectSecrets = (obj, prefix = "") => {
|
|
593
|
-
for (const [key, value] of Object.entries(obj))
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
643
|
+
const collectSecrets = (obj, includeSection, prefix = "") => {
|
|
644
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
645
|
+
if (!includeSection) continue;
|
|
646
|
+
if (key === "secrets" && Array.isArray(value)) {
|
|
647
|
+
for (const secret of value) if (typeof secret === "string") lines.push(`${secret}=`);
|
|
648
|
+
} else if (key === "variables" && isPlainObject(value)) {
|
|
649
|
+
for (const [varKey, varVal] of Object.entries(value)) if (typeof varVal === "string") lines.push(`${varKey}=${varVal}`);
|
|
650
|
+
} else if (isPlainObject(value) && key !== "extends") collectSecrets(value, includeSection, `${prefix}${key}.`);
|
|
651
|
+
}
|
|
598
652
|
};
|
|
599
|
-
if (config.app && typeof config.app === "object")
|
|
600
|
-
|
|
653
|
+
if (config.app && typeof config.app === "object") {
|
|
654
|
+
const app = config.app;
|
|
655
|
+
collectSecrets(app, has("host"), "host.");
|
|
656
|
+
collectSecrets(app, has("ui"), "ui.");
|
|
657
|
+
collectSecrets(app, has("api"), "api.");
|
|
658
|
+
collectSecrets(app, has("plugins"), "auth.");
|
|
659
|
+
}
|
|
660
|
+
if (has("plugins") && config.plugins && typeof config.plugins === "object") {
|
|
661
|
+
for (const [pluginKey, pluginVal] of Object.entries(config.plugins)) if (isPlainObject(pluginVal)) collectSecrets(pluginVal, true);
|
|
662
|
+
else if (typeof pluginVal === "string") lines.push(`# Plugin '${pluginKey}' extends ${pluginVal}`);
|
|
663
|
+
}
|
|
601
664
|
lines.push("BETTER_AUTH_SECRET=generate-a-secret-here");
|
|
602
665
|
return `${lines.join("\n")}\n`;
|
|
603
666
|
}
|
|
@@ -615,5 +678,5 @@ dist/
|
|
|
615
678
|
}
|
|
616
679
|
|
|
617
680
|
//#endregion
|
|
618
|
-
export { copyFilteredFiles, downloadTarball, execCommand, fetchParentConfig, generateDatabaseMigrations, personalizeConfig, readTemplatekeep, resolveRepositoryViaExtendsChain, resolveSourceDir, runBunInstall, runDockerComposeUp, runTypesGen, scaffoldMinimalProject, writeInitSnapshot };
|
|
681
|
+
export { copyFilteredFiles, detectGitRemoteUrl, downloadTarball, execCommand, fetchParentConfig, generateDatabaseMigrations, personalizeConfig, readTemplatekeep, resolveRepositoryViaExtendsChain, resolveSourceDir, runBunInstall, runDockerComposeUp, runTypesGen, scaffoldMinimalProject, writeInitSnapshot };
|
|
619
682
|
//# sourceMappingURL=init.mjs.map
|