Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ jobs:
path: |
node_modules
.eslintcache
.tsbuildinfo
key: ${{ runner.os }}-${{ hashFiles('package.json', 'pnpm-lock.yaml') }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pnpm install --frozen-lockfile
- name: Type Check
run: pnpm typecheck
- name: Lint
run: pnpm lint -f github-annotations
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ npm-debug.log
.Trashes
*.env
.eslintcache
.tsbuildinfo
.idea
16 changes: 13 additions & 3 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ import prettier from 'eslint-config-prettier';

export default tseslint.config(
{
ignores: ['docs/**', 'dist/**', 'node_modules/**', 'coverage/**', '*.mjs', '**/*.js'],
ignores: [
'docs/**',
'dist/**',
'node_modules/**',
'coverage/**',
'*.mjs',
'**/*.js',
],
},
eslint.configs.recommended,
...tseslint.configs.recommended,
Expand All @@ -18,7 +25,10 @@ export default tseslint.config(
'@typescript-eslint/no-explicit-any': 'off',
'no-constant-condition': ['error', { checkLoops: false }],
// Make sure variables marked with _ are ignored (ex. _varName)
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-unused-vars': [
'warn',
{ argsIgnorePattern: '^_' },
],
'@typescript-eslint/ban-ts-comment': [
'error',
{
Expand Down Expand Up @@ -47,5 +57,5 @@ export default tseslint.config(
},
],
},
}
},
);
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@types/ora": "^1.3.4",
"@types/prompts": "^2.0.11",
"@types/rimraf": "^2.0.2",
"@types/semver": "^7.7.1",
"@types/shell-quote": "^1.6.0",
"@types/tar": "^4.0.0",
"@types/tmp": "^0.0.33",
Expand Down Expand Up @@ -68,6 +69,7 @@
"string-length": "3.1.0",
"tar": "7.5.7",
"tmp": "0.2.4",
"tslib": "^2.8.1",
"typescript": "^5.7.2",
"typescript-eslint": "^8.18.2",
"vitest": "^3.0.2",
Expand Down
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/__mocks__/fs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { vi } from 'vitest';

// Import the actual fs module using require to avoid circular mock issues
// eslint-disable-next-line @typescript-eslint/no-require-imports
const actualFs = require('fs') as typeof import('fs');

// Mock existsSync to return true by default
Expand Down Expand Up @@ -104,4 +103,4 @@ export const readv = actualFs.readv;
export default {
...actualFs,
existsSync,
};
} as typeof actualFs;
1 change: 0 additions & 1 deletion src/__tests__/prepare-dry-run.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { resolve, join } from 'path';
import { mkdtemp, rm, writeFile, readFile, mkdir, chmod } from 'fs/promises';
import { existsSync } from 'fs';
import { tmpdir } from 'os';
// eslint-disable-next-line no-restricted-imports, no-restricted-syntax -- Test file needs direct git access for setup/verification
import simpleGit from 'simple-git';

const execFileAsync = promisify(execFile);
Expand Down
7 changes: 3 additions & 4 deletions src/artifact_providers/__tests__/base.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi, type Mock, type MockInstance, type Mocked, type MockedFunction } from 'vitest';
import { parseFilterOptions, RawFilterOptions } from '../base';

describe('parseFilterOptions', () => {
Expand Down Expand Up @@ -29,12 +28,12 @@ describe('parseFilterOptions', () => {
const parsedFilters = parseFilterOptions(rawFilters);

expect(parsedFilters.includeNames).toStrictEqual(
includeNames && /include/
includeNames && /include/,
);

expect(parsedFilters.excludeNames).toStrictEqual(
excludeNames && /exclude/
excludeNames && /exclude/,
);
}
},
);
});
22 changes: 10 additions & 12 deletions src/commands/__tests__/prepare.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { vi, describe, test, expect, beforeEach, type Mock } from 'vitest';
import { join as pathJoin } from 'path';
import { spawnProcess } from '../../utils/system';
import { runPreReleaseCommand, checkVersionOrPart } from '../prepare';

Expand Down Expand Up @@ -34,7 +33,7 @@ describe('runPreReleaseCommand', () => {
CRAFT_NEW_VERSION: newVersion,
CRAFT_OLD_VERSION: oldVersion,
},
}
},
);
});

Expand All @@ -57,7 +56,7 @@ describe('runPreReleaseCommand', () => {
CRAFT_NEW_VERSION: newVersion,
CRAFT_OLD_VERSION: oldVersion,
},
}
},
);
});
});
Expand All @@ -71,8 +70,8 @@ describe('checkVersionOrPart', () => {
{
newVersion: v,
},
null
)
null,
),
).toBe(true);
}
});
Expand All @@ -83,8 +82,8 @@ describe('checkVersionOrPart', () => {
{
newVersion: 'auto',
},
null
)
null,
),
).toBe(true);
});

Expand All @@ -96,8 +95,8 @@ describe('checkVersionOrPart', () => {
{
newVersion: bumpType,
},
null
)
null,
),
).toBe(true);
}
});
Expand All @@ -110,8 +109,7 @@ describe('checkVersionOrPart', () => {
},
{
v: 'v2.3.3',
e:
'Invalid version or version part specified: "v2.3.3". Removing the "v" prefix will likely fix the issue',
e: 'Invalid version or version part specified: "v2.3.3". Removing the "v" prefix will likely fix the issue',
},
];
for (const t of invalidVersions) {
Expand All @@ -120,7 +118,7 @@ describe('checkVersionOrPart', () => {
{
newVersion: t.v,
},
null
null,
);
};
expect(fn).toThrow(t.e);
Expand Down
4 changes: 3 additions & 1 deletion src/commands/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,9 @@ export async function publishMain(argv: PublishOptions): Promise<any> {
// finishes then as nothing relies on the removal of this file.
safeFs
.unlink(publishStateFile)
.catch(err => logger.trace("Couldn't remove publish state file: ", err));
.catch((err: unknown) =>
logger.trace("Couldn't remove publish state file: ", err),
);
logger.success(`Version ${newVersion} has been published!`);
} else {
const msg = [
Expand Down
6 changes: 3 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export function getVersioningPolicy(): VersioningPolicy {

// Use explicitly configured policy if available
if (config.versioning?.policy) {
return config.versioning.policy;
return config.versioning.policy as VersioningPolicy;
}

// Default based on minVersion
Expand Down Expand Up @@ -332,7 +332,7 @@ export async function getGlobalGitHubConfig(
export function getGitTagPrefix(): string {
const targets = getConfiguration().targets || [];
const githubTarget = targets.find(target => target.name === 'github');
return githubTarget?.tagPrefix || '';
return (githubTarget?.tagPrefix as string | undefined) || '';
}

/**
Expand Down Expand Up @@ -438,7 +438,7 @@ export function getChangelogConfig(): NormalizedChangelogConfig {
logger.warn(
'The "changelogPolicy" option is deprecated. Please use "changelog.policy" instead.',
);
policy = config.changelogPolicy;
policy = config.changelogPolicy as ChangelogPolicy;
}

// Handle changelog config
Expand Down
14 changes: 14 additions & 0 deletions src/schemas/project_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ export const TargetConfigSchema = z

export type TargetConfig = z.infer<typeof TargetConfigSchema>;

/**
* Utility type for strongly-typed target configurations.
* Combines base TargetConfig fields with target-specific fields.
*
* @example
* interface BrewConfigFields {
* tap?: string;
* template: string;
* }
* const config = this.config as TypedTargetConfig<BrewConfigFields>;
*/
export type TypedTargetConfig<T extends Record<string, unknown>> =
TargetConfig & T;

/**
* Which service should be used for status checks
*/
Expand Down
12 changes: 3 additions & 9 deletions src/targets/__tests__/awsLambda.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
vi,
type Mock,
type MockInstance,
type Mocked,
type MockedFunction,
} from 'vitest';
import { vi } from 'vitest';
import { NoneArtifactProvider } from '../../artifact_providers/none';
import { ConfigurationError } from '../../utils/errors';
import { AwsLambdaLayerTarget } from '../awsLambdaLayer';
Expand Down Expand Up @@ -118,7 +112,7 @@ describe('project config parameters', () => {
awsTarget.getArtifactsForRevision =
getArtifactsFailingMock.bind(AwsLambdaLayerTarget);
await awsTarget.publish('', ''); // Should break the mocked function.
fail('Should not reach here');
expect.fail('Should not reach here');
} catch (error) {
expect(new RegExp(failingTestErrorMsg).test(error.message)).toBe(true);
}
Expand Down Expand Up @@ -250,7 +244,7 @@ describe('publish', () => {
// This should proceed to call getArtifactsForRevision for a pre-release
try {
await awsTarget.publish('1.0.0-alpha.1', 'revision');
} catch (error) {
} catch {
// Expected to fail at a later stage, but getArtifactsForRevision should be called
}

Expand Down
16 changes: 8 additions & 8 deletions src/targets/__tests__/commitOnGitRepository.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { vi, type Mock, type MockInstance, type Mocked, type MockedFunction } from 'vitest';
import { vi } from 'vitest';
import { pushArchiveToGitRepository } from '../commitOnGitRepository';
import childProcess from 'child_process';

Expand Down Expand Up @@ -36,26 +36,26 @@ test('Basic commit-on-git-repository functionality', async () => {

expect(mockClone).toHaveBeenCalledWith(
'https://github.com/getsentry/sentry-deno',
expect.any(String)
expect.any(String),
);
expect(mockCheckout).toHaveBeenCalledWith('main');
expect(mockRaw).toHaveBeenCalledWith('rm', '-r', '.');
expect(execSyncSpy).toHaveBeenCalledWith(
'tar -zxvf /tmp/my-archive.tgz --strip-components 1',
expect.objectContaining({ cwd: expect.any(String) })
expect.objectContaining({ cwd: expect.any(String) }),
);
expect(mockRaw).toHaveBeenCalledWith('add', '--all');
expect(mockCommit).toHaveBeenCalledWith('release: 1.2.3');
expect(mockAddTag).toHaveBeenCalledWith('1.2.3');
expect(mockRaw).toHaveBeenCalledWith(
'push',
'https://github.com/getsentry/sentry-deno',
'--force'
'--force',
);
expect(mockRaw).toHaveBeenCalledWith(
'push',
'https://github.com/getsentry/sentry-deno',
'--tags'
'--tags',
);
});

Expand Down Expand Up @@ -88,19 +88,19 @@ describe('With authentication', () => {

expect(mockClone).toHaveBeenCalledWith(
'https://test-token@github.com/getsentry/sentry-deno',
expect.any(String)
expect.any(String),
);

expect(mockRaw).toHaveBeenCalledWith(
'push',
'https://test-token@github.com/getsentry/sentry-deno',
'--force'
'--force',
);

expect(mockRaw).toHaveBeenCalledWith(
'push',
'https://test-token@github.com/getsentry/sentry-deno',
'--tags'
'--tags',
);
});
});
4 changes: 2 additions & 2 deletions src/targets/__tests__/crates.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { vi, type Mock, type MockInstance, type Mocked, type MockedFunction } from 'vitest';
import { vi } from 'vitest';
import { CrateDependency, CratePackage, CratesTarget } from '../crates';
import { NoneArtifactProvider } from '../../artifact_providers/none';

Expand Down Expand Up @@ -38,7 +38,7 @@ describe('getPublishOrder', () => {
noDevDeps: true,
},
new NoneArtifactProvider(),
{ owner: 'getsentry', repo: 'craft' }
{ owner: 'getsentry', repo: 'craft' },
);

test('sorts crate packages properly', () => {
Expand Down
Loading
Loading