From a4e0d9d4f678add9d300993a779595e5450738af Mon Sep 17 00:00:00 2001 From: Gabriel Manor Date: Sun, 27 Oct 2024 23:30:07 -0400 Subject: [PATCH 1/2] Run Command Improvements --- source/commands/pdp/run.tsx | 14 ++++++++++++-- source/components/PDPCommand.tsx | 11 +++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/source/commands/pdp/run.tsx b/source/commands/pdp/run.tsx index e0b540f..49a16fa 100644 --- a/source/commands/pdp/run.tsx +++ b/source/commands/pdp/run.tsx @@ -1,11 +1,21 @@ import React from 'react'; import { AuthProvider } from '../../components/AuthProvider.js'; import PDPCommand from '../../components/PDPCommand.js'; +import { type infer as zInfer, number, object } from 'zod'; +import { option } from 'pastel'; -export default function Run() { +export const options = object({ + opa: number().optional().describe(option({ description: 'Expose OPA port from the PDP' })), +}); + +type Props = { + options: zInfer; +}; + +export default function Run({ options: { opa } }: Props) { return ( - + ); } diff --git a/source/components/PDPCommand.tsx b/source/components/PDPCommand.tsx index 7147d34..b51eeb2 100644 --- a/source/components/PDPCommand.tsx +++ b/source/components/PDPCommand.tsx @@ -3,14 +3,17 @@ import { Text } from 'ink'; import Spinner from 'ink-spinner'; import { useAuth } from './AuthProvider.js'; -export default function PDPCommand() { +type Props = { + opa?: number; +}; + +export default function PDPCommand({ opa }: Props) { const { authToken } = useAuth(); return authToken ? ( <> Run the following command from your terminal: - - docker run -p 7766:7000 --env PDP_API_KEY=${authToken} --env - PDP_DEBUG=true permitio/pdp-v2:latest + + docker run -p 7766:7000 {opa ? `-p ${opa}:8181` : ''} --env PDP_API_KEY={authToken} --env PDP_DEBUG=true permitio/pdp-v2:latest ) : ( From 3d3616b8fcfd5f74edcefa5762391181a855fa18 Mon Sep 17 00:00:00 2001 From: Gabriel Manor Date: Sun, 27 Oct 2024 23:31:38 -0400 Subject: [PATCH 2/2] Prettifier --- .github/workflows/node.js.yml | 23 +++++++++++------------ source/commands/pdp/run.tsx | 4 +++- source/components/PDPCommand.tsx | 5 +++-- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 2284b93..2d4499d 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -5,13 +5,12 @@ name: Node.js CI on: push: - branches: [ "main" ] + branches: ['main'] pull_request: - branches: [ "main" ] + branches: ['main'] jobs: build: - runs-on: ubuntu-latest strategy: @@ -20,12 +19,12 @@ jobs: # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - - run: npm ci - - run: npm run build --if-present - - run: npm test + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run build --if-present + - run: npm test diff --git a/source/commands/pdp/run.tsx b/source/commands/pdp/run.tsx index 49a16fa..161aacf 100644 --- a/source/commands/pdp/run.tsx +++ b/source/commands/pdp/run.tsx @@ -5,7 +5,9 @@ import { type infer as zInfer, number, object } from 'zod'; import { option } from 'pastel'; export const options = object({ - opa: number().optional().describe(option({ description: 'Expose OPA port from the PDP' })), + opa: number() + .optional() + .describe(option({ description: 'Expose OPA port from the PDP' })), }); type Props = { diff --git a/source/components/PDPCommand.tsx b/source/components/PDPCommand.tsx index b51eeb2..2604c80 100644 --- a/source/components/PDPCommand.tsx +++ b/source/components/PDPCommand.tsx @@ -12,8 +12,9 @@ export default function PDPCommand({ opa }: Props) { return authToken ? ( <> Run the following command from your terminal: - - docker run -p 7766:7000 {opa ? `-p ${opa}:8181` : ''} --env PDP_API_KEY={authToken} --env PDP_DEBUG=true permitio/pdp-v2:latest + + docker run -p 7766:7000 {opa ? `-p ${opa}:8181` : ''} --env PDP_API_KEY= + {authToken} --env PDP_DEBUG=true permitio/pdp-v2:latest ) : (