MCPcopy Index your code
hub / github.com/Waishnav/devspace / runInit

Function runInit

src/cli.ts:80–167  ·  view source on GitHub ↗
({ force }: { force: boolean })

Source from the content-addressed store, hash-verified

78}
79
80async function runInit({ force }: { force: boolean }): Promise<void> {
81 const files = loadDevspaceFiles();
82 if (!force && files.configExists && files.authExists) {
83 prompts.log.info(`DevSpace is already configured at ${files.dir}`);
84 prompts.log.info("Run `devspace init --force` to update it.");
85 return;
86 }
87
88 try {
89 prompts.intro("DevSpace setup");
90
91 const defaultRoots = files.config.allowedRoots?.join(", ") || process.cwd();
92 const rootsAnswer = await textPrompt({
93 message: `Where are your projects located? Press Enter to use ${defaultRoots}`,
94 placeholder: defaultRoots,
95 defaultValue: defaultRoots,
96 validate: (value) => value?.trim() ? undefined : "Enter at least one project root.",
97 });
98 const allowedRoots = rootsAnswer
99 .split(",")
100 .map((root) => resolve(expandHomePath(root.trim())))
101 .filter(Boolean);
102
103 const defaultPort = String(files.config.port ?? 7676);
104 const portAnswer = await textPrompt({
105 message: `Which local port should DevSpace use? Press Enter to use ${defaultPort}`,
106 placeholder: defaultPort,
107 defaultValue: defaultPort,
108 validate: validatePort,
109 });
110 const port = Number(portAnswer);
111
112 prompts.note(
113 [
114 "DevSpace needs a public base URL so ChatGPT or Claude can reach this MCP server.",
115 "Create a tunnel or reverse proxy with Cloudflare Tunnel, ngrok, Pinggy, Tailscale Funnel, or your own HTTPS proxy.",
116 "Paste the public origin here, without /mcp.",
117 "",
118 "Example: https://your-tunnel-host.example.com",
119 ].join("\n"),
120 "Public URL required",
121 );
122 const publicBaseUrl = normalizePublicBaseUrl(await textPrompt({
123 message: files.config.publicBaseUrl
124 ? `What is the public base URL? Press Enter to keep ${files.config.publicBaseUrl}`
125 : "What is the public base URL?",
126 placeholder: files.config.publicBaseUrl ?? "https://your-tunnel-host.example.com",
127 defaultValue: files.config.publicBaseUrl ?? "",
128 validate: validateRequiredPublicBaseUrl,
129 }));
130
131 const config: DevspaceUserConfig = {
132 host: files.config.host ?? "127.0.0.1",
133 port,
134 allowedRoots,
135 publicBaseUrl,
136 };
137 const auth = {

Callers 2

mainFunction · 0.85
ensureConfiguredFunction · 0.85

Calls 7

loadDevspaceFilesFunction · 0.85
textPromptFunction · 0.85
expandHomePathFunction · 0.85
normalizePublicBaseUrlFunction · 0.85
generateOwnerTokenFunction · 0.85
writeDevspaceConfigFunction · 0.85
writeDevspaceAuthFunction · 0.85

Tested by

no test coverage detected