From 2af4bb044f212727bc60f73f9565ffa7ef6d4174 Mon Sep 17 00:00:00 2001 From: Hamir Mahal Date: Thu, 24 Oct 2024 13:23:17 -0700 Subject: [PATCH 1/2] chore: changes from formatting on save --- src/generator.ts | 8 ++++---- tests/integration.spec.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/generator.ts b/src/generator.ts index d4227e9..929f5a7 100644 --- a/src/generator.ts +++ b/src/generator.ts @@ -13,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import path from 'path'; import fs from 'fs'; +import path from 'path'; -import { prompt } from 'enquirer'; import colors from 'ansi-colors'; +import { prompt } from 'enquirer'; import ini from 'ini'; -import { executeCommands, createFiles, executeTemplate, Command, languageToFileExtension, getFileExtensionCT } from './utils'; import { type PackageManager, determinePackageManager } from './packageManager'; +import { Command, createFiles, executeCommands, executeTemplate, getFileExtensionCT, languageToFileExtension } from './utils'; export type PromptOptions = { testDir: string, @@ -271,7 +271,7 @@ export class Generator { let gitIgnore = ''; if (fs.existsSync(gitIgnorePath)) gitIgnore = fs.readFileSync(gitIgnorePath, 'utf-8').trimEnd() + '\n'; - const valuesToAdd = { + const valuesToAdd = { 'node_modules/': /^node_modules\/?/m, '/test-results/': /^\/?test-results\/?$/m, '/playwright-report/': /^\/playwright-report\/?$/m, diff --git a/tests/integration.spec.ts b/tests/integration.spec.ts index a10c1f7..ae584f6 100644 --- a/tests/integration.spec.ts +++ b/tests/integration.spec.ts @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { test, expect, packageManagerToNpxCommand, assertLockFilesExist } from './baseFixtures'; -import path from 'path'; -import fs from 'fs'; import childProcess from 'child_process'; +import fs from 'fs'; +import path from 'path'; +import { assertLockFilesExist, expect, packageManagerToNpxCommand, test } from './baseFixtures'; const validGitignore = [ 'node_modules/', @@ -120,7 +120,7 @@ test('should not duplicate gitignore entries', async ({ run, dir }) => { test('should install with "npm ci" in GHA when using npm with package-lock enabled', async ({ dir, run, packageManager }) => { test.skip(packageManager !== 'npm'); - + await run([], { installGitHubActions: true, testDir: 'tests', language: 'JavaScript', installPlaywrightDependencies: false, installPlaywrightBrowsers: true }); expect(fs.existsSync(path.join(dir, '.github/workflows/playwright.yml'))).toBeTruthy(); From 3bfd24617cc58d0c599cfc160a6822ad70ac4b5f Mon Sep 17 00:00:00 2001 From: Hamir Mahal Date: Fri, 25 Oct 2024 13:16:47 -0700 Subject: [PATCH 2/2] style: separate addition of `playwright` entries --- src/generator.ts | 7 +++++++ tests/integration.spec.ts | 1 + 2 files changed, 8 insertions(+) diff --git a/src/generator.ts b/src/generator.ts index 929f5a7..427e593 100644 --- a/src/generator.ts +++ b/src/generator.ts @@ -271,6 +271,8 @@ export class Generator { let gitIgnore = ''; if (fs.existsSync(gitIgnorePath)) gitIgnore = fs.readFileSync(gitIgnorePath, 'utf-8').trimEnd() + '\n'; + + let thisIsTheFirstLineWeAreAdding = true; const valuesToAdd = { 'node_modules/': /^node_modules\/?/m, '/test-results/': /^\/?test-results\/?$/m, @@ -280,6 +282,11 @@ export class Generator { }; Object.entries(valuesToAdd).forEach(([value, regex]) => { if (!gitIgnore.match(regex)) { + if (thisIsTheFirstLineWeAreAdding) { + gitIgnore += `\n# Playwright\n`; + thisIsTheFirstLineWeAreAdding = false; + } + gitIgnore += `${value}\n`; } }); diff --git a/tests/integration.spec.ts b/tests/integration.spec.ts index ae584f6..0156561 100644 --- a/tests/integration.spec.ts +++ b/tests/integration.spec.ts @@ -19,6 +19,7 @@ import path from 'path'; import { assertLockFilesExist, expect, packageManagerToNpxCommand, test } from './baseFixtures'; const validGitignore = [ + '# Playwright', 'node_modules/', '/test-results/', '/playwright-report/',