Skip to content

Commit

Permalink
Merge branch 'develop' into nilabhra-issue-446
Browse files Browse the repository at this point in the history
  • Loading branch information
Nil2000 authored Sep 19, 2024
2 parents 66b08d8 + fb0d6f7 commit 9250b01
Show file tree
Hide file tree
Showing 127 changed files with 7,520 additions and 1,969 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm lint && pnpm format && pnpm test:api && pnpm test:api-client
pnpm lint && pnpm format
28 changes: 25 additions & 3 deletions apps/api/src/workspace-role/service/workspace-role.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ export class WorkspaceRoleService {
include: {
projects: {
select: {
projectId: true
project: {
select: {
id: true,
slug: true,
name: true
}
}
}
}
}
Expand Down Expand Up @@ -228,7 +234,13 @@ export class WorkspaceRoleService {
include: {
projects: {
select: {
projectId: true
project: {
select: {
id: true,
slug: true,
name: true
}
}
}
}
}
Expand Down Expand Up @@ -443,7 +455,17 @@ export class WorkspaceRoleService {
slug: workspaceRoleSlug
},
include: {
projects: true
projects: {
select: {
project: {
select: {
id: true,
slug: true,
name: true
}
}
}
}
}
})) as WorkspaceRoleWithProjects

Expand Down
24 changes: 20 additions & 4 deletions apps/api/src/workspace-role/workspace-role.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,18 @@ describe('Workspace Role Controller Tests', () => {
updatedAt: expect.any(String),
projects: expect.arrayContaining([
{
projectId: projects[0].id
project: {
id: projects[0].id,
name: projects[0].name,
slug: projects[0].slug
}
},
{
projectId: projects[1].id
project: {
id: projects[1].id,
name: projects[1].name,
slug: projects[1].slug
}
}
])
})
Expand Down Expand Up @@ -654,10 +662,18 @@ describe('Workspace Role Controller Tests', () => {
hasAdminAuthority: true,
projects: expect.arrayContaining([
{
projectId: projects[0].id
project: {
id: projects[0].id,
name: projects[0].name,
slug: projects[0].slug
}
},
{
projectId: projects[1].id
project: {
id: projects[1].id,
name: projects[1].name,
slug: projects[1].slug
}
}
])
})
Expand Down
6 changes: 5 additions & 1 deletion apps/api/src/workspace-role/workspace-role.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { Project, WorkspaceRole } from '@prisma/client'

export interface WorkspaceRoleWithProjects extends WorkspaceRole {
projects: {
projectId: Project['id']
project: {
id: Project['id']
name: Project['name']
slug: Project['slug']
}
}[]
}
7 changes: 1 addition & 6 deletions apps/api/src/workspace/service/workspace.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,7 @@ export class WorkspaceService {
description: true,
colorCode: true,
hasAdminAuthority: true,
authorities: true,
projects: {
select: {
id: true
}
}
authorities: true
}
})

Expand Down
7 changes: 7 additions & 0 deletions apps/api/src/workspace/workspace.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,13 @@ describe('Workspace Controller Tests', () => {
expect(body.icon).toEqual(workspace1.icon)
expect(body.workspaceRoles).toBeInstanceOf(Array)
expect(body.projects).toBeInstanceOf(Array)

const exampleWorkspaceRole = body.workspaceRoles[0]
expect(exampleWorkspaceRole).toHaveProperty('name')
expect(exampleWorkspaceRole).toHaveProperty('description')
expect(exampleWorkspaceRole).toHaveProperty('hasAdminAuthority')
expect(exampleWorkspaceRole).toHaveProperty('authorities')
expect(exampleWorkspaceRole).toHaveProperty('colorCode')
})
})

Expand Down
31 changes: 31 additions & 0 deletions apps/cli/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module'
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'standard-with-typescript'
],
root: true,
env: {
node: true,
jest: true
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': ['warn'],
'@typescript-eslint/space-before-function-paren': 'off',
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'space-before-function-paren': 'off'
}
}
12 changes: 9 additions & 3 deletions apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
"description": "CLI for keyshade",
"main": "index.ts",
"private": false,
"type": "module",
"scripts": {
"build": "tsc && tsc-alias",
"start": "node dist/src/index.js",
"dev": "pnpm build && node dist/index.js"
"dev": "pnpm build && node dist/index.js",
"lint": "eslint \"src/**/*.ts\" --fix"
},
"keywords": [],
"author": "",
Expand All @@ -22,8 +24,11 @@
"eccrypto": "^1.1.6",
"figlet": "^1.7.0",
"fs": "0.0.1-security",
"glob": "^11.0.0",
"nodemon": "^3.1.4",
"socket.io-client": "^4.7.5"
"@keyshade/secret-scan": "workspace:*",
"socket.io-client": "^4.7.5",
"typescript": "^5.5.2"
},
"devDependencies": {
"@swc/cli": "^0.4.0",
Expand All @@ -32,6 +37,7 @@
"@types/figlet": "^1.5.8",
"@types/eccrypto": "^1.1.6",
"@types/node": "^20.14.10",
"eslint-config-standard-with-typescript": "^43.0.1"
"eslint-config-standard-with-typescript": "^43.0.1",
"tsup": "^8.1.2"
}
}
28 changes: 23 additions & 5 deletions apps/cli/src/commands/base.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { fetchProfileConfig } from '@/util/configuration'
import { Logger } from '@/util/logger'
import { getDefaultProfile } from '@/util/profile'
import type { Command } from 'commander'
import ControllerInstance from '@/util/controller-instance'

/**
* The base class for all commands. All commands should extend this class.
Expand All @@ -17,6 +18,17 @@ export default abstract class BaseCommand {
protected apiKey: string | null = null
protected baseUrl: string | null = null

// Headers to be used by the API requests
protected headers: Record<string, string> | null = null

/**
* Technically the entrypoint to the entire application. This function
* is used to register the various commands across the entire CLI. The
* function is only called from index.ts to register the commands and
* should not be overridden.
*
* @param program The program to add the command to.
*/
readonly prepare = (program: Command): void => {
const argsCount = this.getArguments().length

Expand Down Expand Up @@ -82,7 +94,7 @@ export default abstract class BaseCommand {
}

getVersion(): string {
return null
return '1'
}

/**
Expand All @@ -102,11 +114,9 @@ export default abstract class BaseCommand {
/**
* The action that the command should take.
* @param data The data passed to the command.
* @param data.options The options passed to the command.
* @param data.args The arguments passed to the command.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
action({ options, args }: CommandActionData): Promise<void> | void {}
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-empty-pattern
action({}: CommandActionData): Promise<void> | void {}

/**
* If the command has subcommands, return them here.
Expand Down Expand Up @@ -154,5 +164,13 @@ export default abstract class BaseCommand {
this.baseUrl = defaultProfile.baseUrl
}
}

// Initialize the header
this.headers = {
'x-keyshade-token': this.apiKey
}

// Initialize Controller Instance
ControllerInstance.initialize(this.baseUrl)
}
}
Loading

0 comments on commit 9250b01

Please sign in to comment.