Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Command Improvements #3

Merged
merged 2 commits into from
Oct 28, 2024
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
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