-
-
Notifications
You must be signed in to change notification settings - Fork 77
fix(apple): Use project-relative path to gitignore file #982
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| // @ts-expect-error - clack is ESM and TS complains about that. It works though | ||
| import * as clack from '@clack/prompts'; | ||
| import * as fs from 'node:fs'; | ||
| import * as os from 'node:os'; | ||
| import path from 'node:path'; | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest'; | ||
| import { configureSentryCLI } from '../../src/apple/configure-sentry-cli'; | ||
|
|
||
| vi.mock('@clack/prompts', async () => ({ | ||
philprime marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| __esModule: true, | ||
| ...(await vi.importActual<typeof clack>('@clack/prompts')), | ||
| })); | ||
|
|
||
| describe('configureSentryCLI', () => { | ||
| const authToken = 'test'; | ||
| let projectDir: string; | ||
| let rcPath: string; | ||
| let gitignorePath: string; | ||
|
|
||
| beforeEach(() => { | ||
| beforeEach(() => { | ||
| vi.spyOn(clack.log, 'warn').mockImplementation(() => { | ||
| /* empty */ | ||
| }); | ||
| vi.spyOn(clack, 'select').mockResolvedValue(undefined); | ||
| }); | ||
|
|
||
| projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'project')); | ||
| fs.mkdirSync(projectDir, { recursive: true }); | ||
|
|
||
| rcPath = path.join(projectDir, '.sentryclirc'); | ||
| gitignorePath = path.join(projectDir, '.gitignore'); | ||
| }); | ||
|
|
||
| describe('.sentryclirc file not exists', () => { | ||
| it('should create the .sentryclirc file', () => { | ||
| // -- Arrange -- | ||
| // Pre-condition is that the .sentryclirc file does not exist | ||
| expect(fs.existsSync(rcPath)).toBe(false); | ||
|
|
||
| // -- Act -- | ||
| configureSentryCLI({ projectDir, authToken }); | ||
|
|
||
| // -- Assert -- | ||
| expect(fs.existsSync(rcPath)).toBe(true); | ||
| expect(fs.readFileSync(rcPath, 'utf8')).toContain(`token=test`); | ||
| }); | ||
| }); | ||
|
|
||
| describe('.sentryclirc file exists', () => { | ||
| it('should update the .sentryclirc file', () => { | ||
| // -- Arrange -- | ||
| // Pre-condition is that the .sentryclirc file exists | ||
| fs.writeFileSync(rcPath, `token=old`); | ||
|
|
||
| // -- Act -- | ||
| configureSentryCLI({ projectDir, authToken }); | ||
|
|
||
| // -- Assert -- | ||
| expect(fs.readFileSync(rcPath, 'utf8')).toContain(`token=${authToken}`); | ||
| }); | ||
| }); | ||
|
|
||
| describe('.gitignore file not exists', () => { | ||
| it('should create the .gitignore file', () => { | ||
| // -- Arrange -- | ||
| // Pre-condition is that the .gitignore file does not exist | ||
| expect(fs.existsSync(gitignorePath)).toBe(false); | ||
|
|
||
| // -- Act -- | ||
| configureSentryCLI({ projectDir, authToken }); | ||
|
|
||
| // -- Assert -- | ||
| expect(fs.existsSync(gitignorePath)).toBe(true); | ||
| expect(fs.readFileSync(gitignorePath, 'utf8')).toContain('.sentryclirc'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('.gitignore file exists', () => { | ||
| describe("contains '.sentryclirc'", () => { | ||
| it('should not append the .sentryclirc file to the .gitignore file', () => { | ||
| // -- Arrange -- | ||
| // Pre-condition is that the .gitignore file exists and contains '.sentryclirc' | ||
| fs.writeFileSync( | ||
| gitignorePath, | ||
| ` | ||
| # Xcode | ||
| xcuserdata/ | ||
| # Sentry | ||
| .sentryclirc | ||
| `, | ||
| ); | ||
|
|
||
| // -- Act -- | ||
| configureSentryCLI({ projectDir, authToken }); | ||
|
|
||
| // -- Assert -- | ||
| expect(fs.readFileSync(gitignorePath, 'utf8')).toContain( | ||
| '.sentryclirc', | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe("does not contain '.sentryclirc'", () => { | ||
| it('should append the .sentryclirc file to the .gitignore file', () => { | ||
| // -- Arrange -- | ||
| // Pre-condition is that the .gitignore file exists and does not contain '.sentryclirc' | ||
| fs.writeFileSync( | ||
| gitignorePath, | ||
| ` | ||
| # Xcode | ||
| xcuserdata/ | ||
| `, | ||
| ); | ||
|
|
||
| // -- Act -- | ||
| configureSentryCLI({ projectDir, authToken }); | ||
|
|
||
| // -- Assert -- | ||
| expect(fs.readFileSync(gitignorePath, 'utf8')).toBe( | ||
| ` | ||
| # Xcode | ||
| xcuserdata/ | ||
| .sentryclirc | ||
| `, | ||
| ); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.