Skip to content

Commit

Permalink
chore: add pre commit git hook
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszjenek committed Jun 5, 2024
1 parent 538ff6f commit 6daf0e2
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

npm install
npm run lint
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
}
},
"scripts": {
"preinstall": "./scripts/download-humctl.sh",
"preinstall": "./scripts/download-humctl.sh && ./scripts/set-githooks.sh",
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
Expand Down
2 changes: 2 additions & 0 deletions scripts/download-humctl.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh

CLI_VERSION=0.24.0

mkdir -p ./humctl
Expand Down
3 changes: 3 additions & 0 deletions scripts/set-githooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

git config --local core.hooksPath .githooks/
1 change: 1 addition & 0 deletions src/adapters/humctl/HumctlAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export class HumctlAdapter implements IHumctlAdapter {
result = await exec(humctlFilePath, command, {
env: await this.prepareEnvVars(),
});
/* eslint-disable @typescript-eslint/no-explicit-any */
} catch (error: any) {
statusCode = error.code;
result.stderr = error.stderr;
Expand Down
1 change: 1 addition & 0 deletions src/controllers/ValidateScoreFileController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export class ValidateScoreFileController {

private isScoreFile(textDocument: TextDocument): boolean {
try {
/* eslint-disable @typescript-eslint/no-explicit-any */
const loadedYamlDocument: any = yaml.load(textDocument.getText());
if (!(loadedYamlDocument instanceof Object)) {
return false;
Expand Down
1 change: 1 addition & 0 deletions src/errors/IHumanitecExtensionError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface IHumanitecExtensionError {
}

export function isHumanitecExtensionError(
/* eslint-disable @typescript-eslint/no-explicit-any */
error: any
): error is IHumanitecExtensionError {
const isObject = error !== null && typeof error === 'object';
Expand Down
1 change: 1 addition & 0 deletions src/errors/UnexpectedEmptyOutputError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export class UnexpectedEmptyOutputError implements IHumanitecExtensionError {
constructor(
private binaryPath: string,
private command: string[],
/* eslint-disable @typescript-eslint/no-explicit-any */
private options: any
) {}

Expand Down
1 change: 1 addition & 0 deletions src/repos/ApplicationRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class ApplicationRepository implements IApplicationRepository {
const applications: Application[] = [];

const rawApplications = JSON.parse(result.stdout);
/* eslint-disable @typescript-eslint/no-explicit-any */
rawApplications.forEach((rawApplication: any) => {
const application = new Application(
rawApplication['metadata']['id'],
Expand Down
1 change: 1 addition & 0 deletions src/repos/EnvironmentRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class EnvironmentRepository implements IEnvironmentRepository {
const environments: Environment[] = [];

const rawEnvironments = JSON.parse(result.stdout);
/* eslint-disable @typescript-eslint/no-explicit-any */
rawEnvironments.forEach((rawEnvironment: any) => {
const environment = new Environment(
rawEnvironment['metadata']['id'],
Expand Down
1 change: 1 addition & 0 deletions src/repos/OrganizationRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class OrganizationRepository implements IOrganizationRepository {
const organizations: Organization[] = [];

const rawOrganizations = JSON.parse(result.stdout);
/* eslint-disable @typescript-eslint/no-explicit-any */
rawOrganizations.forEach((rawOrganization: any) => {
const organization = new Organization(
rawOrganization['metadata']['id'],
Expand Down
3 changes: 3 additions & 0 deletions src/repos/ResourceTypeRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class ResourceTypeRepository implements IResourceTypeRepository {

const rawResourceTypes = JSON.parse(result.stdout);
const rawResourceType = rawResourceTypes.find(
/* eslint-disable @typescript-eslint/no-explicit-any */
(rawResourceType: any) => rawResourceType['Type'] === type
);
if (!rawResourceType) {
Expand All @@ -40,6 +41,7 @@ export class ResourceTypeRepository implements IResourceTypeRepository {
const resourceTypes: ResourceType[] = [];

const rawResourceTypes = JSON.parse(result.stdout);
/* eslint-disable @typescript-eslint/no-explicit-any */
rawResourceTypes.forEach((rawResourceType: any) => {
const resourceType = new ResourceType(
rawResourceType['Category'],
Expand All @@ -54,6 +56,7 @@ export class ResourceTypeRepository implements IResourceTypeRepository {
}

private resolveVariables(
/* eslint-disable @typescript-eslint/no-explicit-any */
rawVariables: any
): Map<string, ResourceTypeVariable> {
const result = new Map<string, ResourceTypeVariable>();
Expand Down
2 changes: 2 additions & 0 deletions src/repos/SecretRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class SecretRepository implements ISecretRepository {
let configFile: Buffer = Buffer.from([]);
try {
configFile = readFileSync(configPath);
/* eslint-disable @typescript-eslint/no-explicit-any */
} catch (error: any) {
if (error.code && error.code === 'ENOENT') {
console.log(error);
Expand Down Expand Up @@ -51,6 +52,7 @@ export class SecretRepository implements ISecretRepository {
value = '';
}
return value;
/* eslint-disable @typescript-eslint/no-explicit-any */
} catch (error: any) {
if (error.code && error.code === 'ENOENT') {
return '';
Expand Down
2 changes: 2 additions & 0 deletions src/services/LoginService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class LoginService implements ILoginService {
if (response.status !== 200) {
throw new AuthorizationError(await response.text());
}
/* eslint-disable @typescript-eslint/no-explicit-any */
const body: any = await response.json();
if (!body.security_code || !body.verification_url) {
throw new AuthorizationError(await response.text());
Expand All @@ -47,6 +48,7 @@ export class LoginService implements ILoginService {
}
);
if (response.status === 200) {
/* eslint-disable @typescript-eslint/no-explicit-any */
const body: any = await response.json();
if (!body.accepted) {
throw new AuthorizationError(await response.text());
Expand Down
1 change: 1 addition & 0 deletions src/services/ScoreValidationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class ScoreValidationService implements IScoreValidationService {
return validationErrors;
}
const validationRawErrors = JSON.parse(result.stdout);
/* eslint-disable @typescript-eslint/no-explicit-any */
validationRawErrors.forEach((validationRawError: any) => {
validationErrors.push(
new ValidationError(
Expand Down

0 comments on commit 6daf0e2

Please sign in to comment.