-
Notifications
You must be signed in to change notification settings - Fork 349
feat(cli): add option to include functional test suite #806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@bigcommerce/create-catalyst": minor | ||
| --- | ||
|
|
||
| Adds an option to include the functional test suite as part of the create command. Defaults to false. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import chalk from 'chalk'; | ||
| import { readFile, writeFile } from 'fs/promises'; | ||
| import { copySync, ensureDir, readJsonSync, removeSync, writeJsonSync } from 'fs-extra/esm'; | ||
| import { downloadTemplate } from 'giget'; | ||
| import merge from 'lodash.merge'; | ||
|
|
@@ -9,11 +10,13 @@ import { spinner } from './spinner'; | |
|
|
||
| export const cloneCatalyst = async ({ | ||
| codeEditor, | ||
| includeFunctionalTests, | ||
| projectDir, | ||
| projectName, | ||
| ghRef = 'main', | ||
| }: { | ||
| codeEditor: string; | ||
| includeFunctionalTests: boolean; | ||
| projectDir: string; | ||
| projectName: string; | ||
| ghRef?: string; | ||
|
|
@@ -93,6 +96,11 @@ export const cloneCatalyst = async ({ | |
| delete packageJson.devDependencies['react-dom']; // will go away | ||
| delete packageJson.devDependencies['@bigcommerce/eslint-config-catalyst']; | ||
|
|
||
| if (!includeFunctionalTests) { | ||
| delete packageJson.devDependencies['@faker-js/faker']; | ||
| delete packageJson.devDependencies['@playwright/test']; | ||
| } | ||
|
|
||
| writeJsonSync(join(projectDir, 'package.json'), packageJson, { spaces: 2 }); | ||
|
|
||
| const tsConfigJson = z | ||
|
|
@@ -108,6 +116,7 @@ export const cloneCatalyst = async ({ | |
| .passthrough(), | ||
| }) | ||
| .passthrough(), | ||
| include: z.array(z.string()).optional(), | ||
| }) | ||
| .passthrough() | ||
| .parse( | ||
|
|
@@ -123,7 +132,24 @@ export const cloneCatalyst = async ({ | |
|
|
||
| tsConfigJson.compilerOptions.paths['@bigcommerce/components/*'] = ['./components/ui/*']; | ||
|
|
||
| if (!includeFunctionalTests) { | ||
| tsConfigJson.include = tsConfigJson.include?.filter( | ||
| (include) => !['tests/**/*', 'playwright.config.ts'].includes(include), | ||
| ); | ||
| } | ||
|
|
||
| writeJsonSync(join(projectDir, 'tsconfig.json'), tsConfigJson, { spaces: 2 }); | ||
|
|
||
| if (!includeFunctionalTests) { | ||
| const eslint = (await readFile(join(projectDir, '.eslintrc.cjs'), { encoding: 'utf-8' })) | ||
| .replace(/['"]\/playwright-report\/\*\*['"],?/, '') | ||
| .replace(/['"]\/test-results\/\*\*['"],?/, ''); | ||
|
Comment on lines
145
to
146
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using regex instead as it could be multi-lined. Pretty sure
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| await writeFile(join(projectDir, '.eslintrc.cjs'), eslint); | ||
|
|
||
| removeSync(join(projectDir, 'tests')); | ||
| removeSync(join(projectDir, 'playwright.config.ts')); | ||
| } | ||
|
|
||
| removeSync(join(projectDir, 'tmp')); | ||
| }; | ||

Uh oh!
There was an error while loading. Please reload this page.