Skip to content

Commit

Permalink
Merge pull request #3 from permitio/run_command_improvements
Browse files Browse the repository at this point in the history
Run Command Improvements
  • Loading branch information
orweis authored Oct 28, 2024
2 parents 4759b8c + 3d3616b commit e335829
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
23 changes: 11 additions & 12 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
16 changes: 14 additions & 2 deletions source/commands/pdp/run.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
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<typeof options>;
};

export default function Run({ options: { opa } }: Props) {
return (
<AuthProvider>
<PDPCommand />
<PDPCommand opa={opa} />
</AuthProvider>
);
}
12 changes: 8 additions & 4 deletions source/components/PDPCommand.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ 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 ? (
<>
<Text color="green">Run the following command from your terminal:</Text>
<Text>
docker run -p 7766:7000 --env PDP_API_KEY=${authToken} --env
PDP_DEBUG=true permitio/pdp-v2:latest
<Text wrap="end">
docker run -p 7766:7000 {opa ? `-p ${opa}:8181` : ''} --env PDP_API_KEY=
{authToken} --env PDP_DEBUG=true permitio/pdp-v2:latest
</Text>
</>
) : (
Expand Down

0 comments on commit e335829

Please sign in to comment.