From 61f65107f2242246937e7dcb5005d0e2b8314148 Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Tue, 3 Feb 2026 11:31:50 +0100 Subject: [PATCH] feat: standardize NPM scripts across monorepo via @mintel/cli enhancement --- apps/sample-website/package.json | 14 +++++- packages/cli/src/index.ts | 84 +++++++++++++++++++++++++++++++- 2 files changed, 94 insertions(+), 4 deletions(-) diff --git a/apps/sample-website/package.json b/apps/sample-website/package.json index f64b7e9..182dd4d 100644 --- a/apps/sample-website/package.json +++ b/apps/sample-website/package.json @@ -4,11 +4,21 @@ "private": true, "type": "module", "scripts": { - "dev": "next dev", + "dev": "mintel dev", + "dev:local": "mintel dev --local", "build": "next build", "start": "next start", "lint": "next lint", - "test": "vitest run" + "typecheck": "tsc --noEmit", + "test": "vitest run --passWithNoTests", + "directus:bootstrap": "mintel directus bootstrap", + "directus:push:testing": "mintel directus sync push testing", + "directus:pull:testing": "mintel directus sync pull testing", + "directus:push:staging": "mintel directus sync push staging", + "directus:pull:staging": "mintel directus sync pull staging", + "directus:push:prod": "mintel directus sync push production", + "directus:pull:prod": "mintel directus sync pull production", + "pagespeed:test": "mintel pagespeed" }, "dependencies": { "@mintel/next-utils": "workspace:*", diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 68d6c67..a353b78 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -10,7 +10,76 @@ const program = new Command(); program .name("mintel") .description("CLI for Mintel monorepo management") - .version("1.0.0"); + .version("1.0.1"); + +program + .command("dev") + .description("Start the development environment (Docker stack)") + .option("-l, --local", "Run Next.js locally instead of in Docker") + .action(async (options) => { + const { execSync } = await import("child_process"); + console.log(chalk.blue("🚀 Starting Development Environment...")); + + if (options.local) { + console.log(chalk.cyan("Running Next.js locally...")); + execSync("next dev", { stdio: "inherit" }); + } else { + console.log(chalk.cyan("Starting Docker stack (App, Directus, DB)...")); + // Ensure network exists + try { + execSync("docker network create infra", { stdio: "ignore" }); + } catch (e) {} + + console.log( + chalk.yellow(` +📱 App: http://localhost:3000 +🗄️ CMS: http://localhost:8055/admin +🚦 Traefik: http://localhost:8080 +`), + ); + execSync( + "docker-compose down --remove-orphans && docker-compose up app directus directus-db", + { stdio: "inherit" }, + ); + } + }); + +const directus = program + .command("directus") + .description("Directus management commands"); + +directus + .command("bootstrap") + .description("Setup Directus branding and settings") + .action(async () => { + const { execSync } = await import("child_process"); + console.log(chalk.blue("🎨 Bootstrapping Directus...")); + execSync("npx tsx --env-file=.env scripts/setup-directus.ts", { + stdio: "inherit", + }); + }); + +directus + .command("sync ") + .description("Sync Directus data (push/pull) for a specific environment") + .action(async (action, env) => { + const { execSync } = await import("child_process"); + console.log( + chalk.blue(`📥 Executing Directus sync: ${action} -> ${env}...`), + ); + execSync(`./scripts/sync-directus.sh ${action} ${env}`, { + stdio: "inherit", + }); + }); + +program + .command("pagespeed") + .description("Run PageSpeed (Lighthouse) tests") + .action(async () => { + const { execSync } = await import("child_process"); + console.log(chalk.blue("⚡ Running PageSpeed tests...")); + execSync("npx tsx ./scripts/pagespeed-sitemap.ts", { stdio: "inherit" }); + }); program .command("init ") @@ -34,10 +103,21 @@ program private: true, type: "module", scripts: { - dev: "next dev", + dev: "mintel dev", + "dev:local": "mintel dev --local", build: "next build", start: "next start", lint: "next lint", + typecheck: "tsc --noEmit", + test: "vitest run --passWithNoTests", + "directus:bootstrap": "mintel directus bootstrap", + "directus:push:testing": "mintel directus sync push testing", + "directus:pull:testing": "mintel directus sync pull testing", + "directus:push:staging": "mintel directus sync push staging", + "directus:pull:staging": "mintel directus sync pull staging", + "directus:push:prod": "mintel directus sync push production", + "directus:pull:prod": "mintel directus sync pull production", + "pagespeed:test": "mintel pagespeed", }, dependencies: { next: "15.1.6",