Skip to content

Commit b505b9a

Browse files
committed
Use devServerScript and devServerPort
1 parent 05e712d commit b505b9a

File tree

3 files changed

+124
-12
lines changed

3 files changed

+124
-12
lines changed

__snapshots__/readme.spec.js.snap

+114-4
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Dependencies are locked with \`yarn.lock\`; please use \`yarn\` rather than \`np
134134
135135
## Running
136136
137-
- Run \`yarn start\`
137+
- Run \`yarn web\`
138138
139139
## Unit Tests
140140
@@ -171,7 +171,7 @@ Dependencies are locked with \`yarn.lock\`; please use \`yarn\` rather than \`np
171171
172172
## Running
173173
174-
- Run \`yarn start\`
174+
- Run \`yarn web\`
175175
176176
## E2E Tests
177177
@@ -204,7 +204,7 @@ Dependencies are locked with \`yarn.lock\`; please use \`yarn\` rather than \`np
204204
205205
## Running
206206
207-
- Run \`yarn start\`
207+
- Run \`yarn web\`
208208
209209
## Unit Tests
210210
@@ -236,7 +236,7 @@ Dependencies are locked with \`yarn.lock\`; please use \`yarn\` rather than \`np
236236
237237
## Running
238238
239-
- Run \`yarn start\`
239+
- Run \`yarn web\`
240240
"
241241
`;
242242

@@ -504,3 +504,113 @@ Dependencies are locked with \`yarn.lock\`; please use \`yarn\` rather than \`np
504504
- In another terminal, run \`yarn android\` or \`yarn ios\`
505505
"
506506
`;
507+
508+
exports[`getReadmeContents vite allows returning a readme with both unit testing and cypress 1`] = `
509+
"# My Project
510+
511+
Describe your project here.
512+
513+
## Requirements
514+
515+
- [Node](https://nodejs.org)
516+
- [Yarn 1.x](https://classic.yarnpkg.com/lang/en/)
517+
518+
## Installation
519+
520+
- Clone the repo
521+
- Run \`yarn install\`
522+
523+
Dependencies are locked with \`yarn.lock\`; please use \`yarn\` rather than \`npm\` for installing.
524+
525+
## Running
526+
527+
- Run \`yarn dev\`
528+
529+
## Unit Tests
530+
531+
- Run \`yarn test\`
532+
533+
## E2E Tests
534+
535+
- Run the app
536+
- In another terminal, run \`yarn cypress\`
537+
"
538+
`;
539+
540+
exports[`getReadmeContents vite allows returning a readme with cypress 1`] = `
541+
"# My Project
542+
543+
Describe your project here.
544+
545+
## Requirements
546+
547+
- [Node](https://nodejs.org)
548+
- [Yarn 1.x](https://classic.yarnpkg.com/lang/en/)
549+
550+
## Installation
551+
552+
- Clone the repo
553+
- Run \`yarn install\`
554+
555+
Dependencies are locked with \`yarn.lock\`; please use \`yarn\` rather than \`npm\` for installing.
556+
557+
## Running
558+
559+
- Run \`yarn dev\`
560+
561+
## E2E Tests
562+
563+
- Run the app
564+
- In another terminal, run \`yarn cypress\`
565+
"
566+
`;
567+
568+
exports[`getReadmeContents vite allows returning a readme with unit testing 1`] = `
569+
"# My Project
570+
571+
Describe your project here.
572+
573+
## Requirements
574+
575+
- [Node](https://nodejs.org)
576+
- [Yarn 1.x](https://classic.yarnpkg.com/lang/en/)
577+
578+
## Installation
579+
580+
- Clone the repo
581+
- Run \`yarn install\`
582+
583+
Dependencies are locked with \`yarn.lock\`; please use \`yarn\` rather than \`npm\` for installing.
584+
585+
## Running
586+
587+
- Run \`yarn dev\`
588+
589+
## Unit Tests
590+
591+
- Run \`yarn test\`
592+
"
593+
`;
594+
595+
exports[`getReadmeContents vite allows returning a readme without any testing 1`] = `
596+
"# My Project
597+
598+
Describe your project here.
599+
600+
## Requirements
601+
602+
- [Node](https://nodejs.org)
603+
- [Yarn 1.x](https://classic.yarnpkg.com/lang/en/)
604+
605+
## Installation
606+
607+
- Clone the repo
608+
- Run \`yarn install\`
609+
610+
Dependencies are locked with \`yarn.lock\`; please use \`yarn\` rather than \`npm\` for installing.
611+
612+
## Running
613+
614+
- Run \`yarn dev\`
615+
"
616+
`;

readme.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ${
4343
answers.framework === 'rn'
4444
? `- In one terminal, run \`yarn start\`
4545
- In another terminal, run \`yarn android\` or \`yarn ios\``
46-
: `- Run \`yarn ${answers.framework === 'next' ? 'dev' : 'start'}\``
46+
: `- Run \`yarn ${framework.devServerScript ?? 'start'}\``
4747
}
4848
`
4949
)}${includeIf(

script.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function initializeCra(answers) {
4242
});
4343
});
4444

45-
addCypress(answers, {port: 3000});
45+
addCypress(answers);
4646

4747
group('Configure linting and formatting', () => {
4848
addNpmPackages({
@@ -116,7 +116,7 @@ function initializeDocusaurus(answers) {
116116
console.log('TODO: UNIT TESTING');
117117
}
118118

119-
addCypress(answers, {port: 3000});
119+
addCypress(answers);
120120

121121
group('Configure linting and formatting', () => {
122122
addNpmPackages({
@@ -353,7 +353,7 @@ async function initializeExpo(answers) {
353353
});
354354
}
355355

356-
addCypress(answers, {port: 19006});
356+
addCypress(answers);
357357

358358
group('Configure linting and formatting', () => {
359359
addNpmPackages({
@@ -461,7 +461,7 @@ function initializeNext(answers) {
461461
});
462462
}
463463

464-
addCypress(answers, {port: 3000});
464+
addCypress(answers);
465465

466466
group('Configure linting and formatting', () => {
467467
addNpmPackages({
@@ -953,7 +953,9 @@ async function initializeRN(answers) {
953953
writeDetoxGitHubActionsConfig(answers);
954954
}
955955

956-
function addCypress(answers, {port}) {
956+
function addCypress(answers, {cjs}) {
957+
const framework = FRAMEWORKS.find(f => f.value === answers.framework);
958+
957959
if (answers.cypress) {
958960
group('Add Cypress', () => {
959961
addNpmPackages({
@@ -962,14 +964,14 @@ function addCypress(answers, {port}) {
962964
});
963965
setScript('cypress', 'cypress open');
964966
writeFile(
965-
'cypress.config.js',
967+
`cypress.config.${cjs ? 'c' : ''}js`,
966968
dedent`
967969
const {defineConfig} = require('cypress');
968970
969971
module.exports = defineConfig({
970972
video: false,
971973
e2e: {
972-
baseUrl: 'http://localhost:${port}',
974+
baseUrl: 'http://localhost:${framework.devServerPort}',
973975
},
974976
});
975977
`

0 commit comments

Comments
 (0)