Skip to content

Commit

Permalink
feat(react): add minimal flag
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi committed Nov 28, 2022
1 parent 3c60da7 commit 3d1ee7b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/generated/packages/react.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@
"enum": ["vite", "webpack"],
"x-prompt": "Which bundler do you want to use to build the application?",
"default": "webpack"
},
"minimal": {
"description": "Generate a React app with a minimal setup, no separate tests files.",
"type": "boolean",
"default": false
}
},
"required": [],
Expand Down Expand Up @@ -439,6 +444,11 @@
"description": "Do not add dependencies to `package.json`.",
"type": "boolean",
"default": false
},
"minimal": {
"description": "Create a React library with a minimal setup, no separate tests files.",
"type": "boolean",
"default": false
}
},
"required": ["name"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export function normalizeOptions(
normalized.unitTestRunner ??
(normalized.bundler === 'vite' ? 'vitest' : 'jest');
normalized.e2eTestRunner = normalized.e2eTestRunner ?? 'cypress';
normalized.inSourceTests = normalized.minimal || normalized.inSourceTests;
normalized.devServerPort ??= findFreePort(host);

return normalized;
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/generators/application/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface Schema {
skipPackageJson?: boolean;
rootProject?: boolean;
bundler?: 'webpack' | 'vite';
minimal?: boolean;
}

export interface NormalizedSchema extends Schema {
Expand Down
5 changes: 5 additions & 0 deletions packages/react/src/generators/application/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@
"enum": ["vite", "webpack"],
"x-prompt": "Which bundler do you want to use to build the application?",
"default": "webpack"
},
"minimal": {
"description": "Generate a React app with a minimal setup, no separate tests files.",
"type": "boolean",
"default": false
}
},
"required": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export function normalizeOptions(
normalized.unitTestRunner ??
(normalized.bundler === 'vite' ? 'vitest' : 'jest');

normalized.inSourceTests === normalized.minimal || normalized.inSourceTests;

if (options.appProject) {
const appProjectConfig = getProjects(host).get(options.appProject);

Expand Down
1 change: 1 addition & 0 deletions packages/react/src/generators/library/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ export interface Schema {
style: SupportedStyles;
tags?: string;
unitTestRunner?: 'jest' | 'vitest' | 'none';
minimal?: boolean;
}
5 changes: 5 additions & 0 deletions packages/react/src/generators/library/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@
"description": "Do not add dependencies to `package.json`.",
"type": "boolean",
"default": false
},
"minimal": {
"description": "Create a React library with a minimal setup, no separate tests files.",
"type": "boolean",
"default": false
}
},
"required": ["name"]
Expand Down

0 comments on commit 3d1ee7b

Please sign in to comment.