diff --git a/.changeset/tiny-pants-scream.md b/.changeset/tiny-pants-scream.md new file mode 100644 index 00000000000..84a0bc831a8 --- /dev/null +++ b/.changeset/tiny-pants-scream.md @@ -0,0 +1,5 @@ +--- +'@builder.io/qwik': minor +--- + +FEAT: add monorepo support to the `qwik add` command by adding an `outDir` param diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6206f86e163..b739db82458 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -764,7 +764,7 @@ jobs: - run: pnpm install --frozen-lockfile - name: CLI E2E Tests - run: pnpm run test.e2e-cli + run: pnpm run test.e2e.cli ########### LINT PACKAGES ############ lint-package: diff --git a/e2e/qwik-cli-e2e/README.md b/e2e/qwik-cli-e2e/README.md index 959a75de13a..3320cf62cd1 100644 --- a/e2e/qwik-cli-e2e/README.md +++ b/e2e/qwik-cli-e2e/README.md @@ -4,7 +4,7 @@ This package provides isolated E2E tests by generating a new application with lo ## Description -Tests can be invoked by running `pnpm run test.e2e-cli`. +Tests can be invoked by running `pnpm run test.e2e.cli`. **Note that running E2E tests requires the workspace projects to be prebuilt manually!** @@ -16,8 +16,8 @@ E2E project does the following internally: - By default `outputDir` is an auto-generated one using `tmp` npm package. The application that is created here will be removed after the test is executed - It is possible to install into custom folder using environment variable `TEMP_E2E_PATH`. Here's how the command would look like in this case: - - with absolute path `TEMP_E2E_PATH=/Users/name/projects/tests pnpm run test.e2e-cli` - - with path relative to the qwik workspace `TEMP_E2E_PATH=temp/e2e-folder pnpm run test.e2e-cli` + - with absolute path `TEMP_E2E_PATH=/Users/name/projects/tests pnpm run test.e2e.cli` + - with path relative to the qwik workspace `TEMP_E2E_PATH=temp/e2e-folder pnpm run test.e2e.cli` Note that provided folder should exist. If custom path is used, generated application will not be removed after the test completes, which is helpful for debugging. diff --git a/package.json b/package.json index 211229e78b0..db2982dc590 100644 --- a/package.json +++ b/package.json @@ -241,7 +241,7 @@ "start": "concurrently \"npm:build.watch\" \"npm:tsc.watch\" -n build,tsc -c green,cyan", "test": "pnpm build.full && pnpm test.unit && pnpm test.e2e", "test.e2e": "pnpm test.e2e.chromium && pnpm test.e2e.webkit", - "test.e2e-cli": "pnpm --filter qwik-cli-e2e e2e", + "test.e2e.cli": "pnpm --filter qwik-cli-e2e e2e", "test.e2e.chromium": "playwright test starters --browser=chromium --config starters/playwright.config.ts", "test.e2e.chromium.debug": "PWDEBUG=1 playwright test starters --browser=chromium --config starters/playwright.config.ts", "test.e2e.city": "playwright test starters/e2e/qwikcity --browser=chromium --config starters/playwright.config.ts", diff --git a/packages/qwik/src/cli/add/run-add-interactive.ts b/packages/qwik/src/cli/add/run-add-interactive.ts index 41a38dd0a2c..96918ebe4da 100644 --- a/packages/qwik/src/cli/add/run-add-interactive.ts +++ b/packages/qwik/src/cli/add/run-add-interactive.ts @@ -1,6 +1,6 @@ import { intro, isCancel, log, outro, select, spinner } from '@clack/prompts'; import { bgBlue, bgMagenta, blue, bold, cyan, magenta } from 'kleur/colors'; -import type { IntegrationData, UpdateAppResult } from '../types'; +import type { IntegrationData, UpdateAppOptions, UpdateAppResult } from '../types'; import { loadIntegrations, sortIntegrationsAndReturnAsClackOptions } from '../utils/integrations'; import { bye, getPackageManager, note, panic, printHeader } from '../utils/utils'; @@ -62,11 +62,17 @@ export async function runAddInteractive(app: AppCommand, id: string | undefined) runInstall = true; } - const result = await updateApp(pkgManager, { + const updateAppOptions: UpdateAppOptions = { rootDir: app.rootDir, integration: integration.id, installDeps: runInstall, - }); + }; + const outDir = app.getArg('outDir'); + if (outDir) { + updateAppOptions.outDir = outDir; + } + + const result = await updateApp(pkgManager, updateAppOptions); if (app.getArg('skipConfirmation') !== 'true') { await logUpdateAppResult(pkgManager, result); diff --git a/packages/qwik/src/cli/add/update-files.ts b/packages/qwik/src/cli/add/update-files.ts index 29a9009cbe1..403ccdc247b 100644 --- a/packages/qwik/src/cli/add/update-files.ts +++ b/packages/qwik/src/cli/add/update-files.ts @@ -1,6 +1,6 @@ import fs from 'node:fs'; -import type { FsUpdates, UpdateAppOptions } from '../types'; import { extname, join } from 'node:path'; +import type { FsUpdates, UpdateAppOptions } from '../types'; import { getPackageManager } from '../utils/utils'; export async function mergeIntegrationDir( @@ -15,7 +15,8 @@ export async function mergeIntegrationDir( const destName = itemName === 'gitignore' ? '.gitignore' : itemName; const ext = extname(destName); const srcChildPath = join(srcDir, itemName); - const destChildPath = join(destDir, destName); + const subDir = opts.outDir ? opts.outDir : ''; + const destChildPath = join(destDir, subDir, destName); const s = await fs.promises.stat(srcChildPath); if (s.isDirectory()) { diff --git a/packages/qwik/src/cli/types.ts b/packages/qwik/src/cli/types.ts index e1043da2394..09711bf5392 100644 --- a/packages/qwik/src/cli/types.ts +++ b/packages/qwik/src/cli/types.ts @@ -14,6 +14,7 @@ export interface UpdateAppOptions { rootDir: string; integration: string; installDeps?: boolean; + outDir?: string; } export interface UpdateAppResult {