Skip to content
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

fix: snapshot generation #383

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions scripts/snapshot.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ const featureFlags = [
'playwright',
'nightwatch'
]
const featureFlagsDenylist = [['cypress', 'playwright', 'nightwatch']]
const featureFlagsDenylist = [
['cypress', 'playwright'],
['playwright', 'nightwatch'],
['cypress', 'nightwatch'],
['cypress', 'playwright', 'nightwatch']
]

// The following code & comments are generated by GitHub CoPilot.
function fullCombination(arr) {
Expand Down Expand Up @@ -51,12 +56,6 @@ function fullCombination(arr) {
let flagCombinations = fullCombination(featureFlags)
flagCombinations.push(['default'])

// Filter out combinations that are not allowed
flagCombinations = flagCombinations.filter(
(combination) =>
!featureFlagsDenylist.some((denylist) => denylist.every((flag) => combination.includes(flag)))
)

// `--with-tests` are equivalent of `--vitest --cypress`
// Previously it means `--cypress` without `--vitest`.
// Here we generate the snapshots only for the sake of easier comparison with older templates.
Expand All @@ -70,14 +69,26 @@ withTestsFlags.push(['with-tests'])
flagCombinations.push(...withTestsFlags)

const playgroundDir = path.resolve(__dirname, '../playground/')
const bin = path.posix.relative('../playground/', '../outfile.cjs')

cd(playgroundDir)

// remove all previous combinations
for (const flags of flagCombinations) {
const projectName = flags.join('-')

console.log(`Removing previously generated project ${projectName}`)
fs.rmSync(projectName, { recursive: true, force: true })
}

// Filter out combinations that are not allowed
flagCombinations = flagCombinations.filter(
(combination) =>
!featureFlagsDenylist.some((denylist) => denylist.every((flag) => combination.includes(flag)))
)

const bin = path.posix.relative('../playground/', '../outfile.cjs')

for (const flags of flagCombinations) {
const projectName = flags.join('-')

console.log(`Creating project ${projectName}`)
await $`node ${[bin, projectName, ...flags.map((flag) => `--${flag}`), '--force']}`
Expand Down