diff --git a/packages/cli/src/commands/init.ts b/packages/cli/src/commands/init.ts index fe509a1..b37c047 100644 --- a/packages/cli/src/commands/init.ts +++ b/packages/cli/src/commands/init.ts @@ -47,22 +47,7 @@ export async function initCommand(): Promise { const externalsTspPath = resolve(typelexDir, "externals.tsp"); console.log("Initializing typelex project...\n"); - - // Prompt for namespace - let namespace = await promptNamespace(); - - // Validate namespace format - while (!namespace.endsWith(".*")) { - console.error(`Error: namespace must end with .*`); - console.error(`Got: ${namespace}\n`); - namespace = await promptNamespace(); - } - - // Remove the .* suffix for use in template - const namespacePrefix = namespace.slice(0, -2); - - // Install dependencies first - console.log("\nInstalling dependencies...\n"); + console.log("Installing dependencies...\n"); // Detect package manager let packageManager = "npm"; @@ -105,6 +90,19 @@ export async function initCommand(): Promise { }); }); + // Prompt for namespace after successful installation + let namespace = await promptNamespace(); + + // Validate namespace format + while (!namespace.endsWith(".*")) { + console.error(`Error: namespace must end with .*`); + console.error(`Got: ${namespace}\n`); + namespace = await promptNamespace(); + } + + // Remove the .* suffix for use in template + const namespacePrefix = namespace.slice(0, -2); + // Create typelex directory await mkdir(typelexDir, { recursive: true });