Skip to content

Commit

Permalink
add outDir param to the cli
Browse files Browse the repository at this point in the history
  • Loading branch information
shairez committed Nov 11, 2024
1 parent 9ecfa4c commit df9e2e7
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/tiny-pants-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@builder.io/qwik': minor
---

FEAT: add monorepo support to the `qwik add` command by adding an `outDir` param
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions e2e/qwik-cli-e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!**

Expand All @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 9 additions & 3 deletions packages/qwik/src/cli/add/run-add-interactive.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions packages/qwik/src/cli/add/update-files.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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()) {
Expand Down
1 change: 1 addition & 0 deletions packages/qwik/src/cli/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface UpdateAppOptions {
rootDir: string;
integration: string;
installDeps?: boolean;
outDir?: string;
}

export interface UpdateAppResult {
Expand Down

0 comments on commit df9e2e7

Please sign in to comment.