Skip to content

Commit

Permalink
move packages up a dir, kill packages directory
Browse files Browse the repository at this point in the history
  • Loading branch information
david-crespo committed May 4, 2024
1 parent 0ecd8aa commit 91bbb7e
Show file tree
Hide file tree
Showing 37 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/update-api-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: "18"
- working-directory: "./packages/openapi-gen-ts"
- working-directory: "./oxide-openapi-gen-ts"
run: 'npm install'
- run: ./tools/gen.sh
- uses: EndBug/add-and-commit@v9
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: "18"
- working-directory: "./packages/openapi-gen-ts"
- working-directory: "./oxide-openapi-gen-ts"
run: npm install
- name: Generate client
run: "./tools/gen.sh"
- name: Typecheck
working-directory: "./packages/openapi-gen-ts"
working-directory: "./oxide-openapi-gen-ts"
run: npm run tsc
- name: Lint
working-directory: "./packages/openapi-gen-ts"
working-directory: "./oxide-openapi-gen-ts"
run: npm run lint
- name: Test
working-directory: "./packages/openapi-gen-ts"
working-directory: "./oxide-openapi-gen-ts"
run: npm test run
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ any other specs and is unlikely to handle them well.

|Package| Description|
|---|---|
| [`@oxide/openapi-gen-ts`](./packages/openapi-gen-ts) | TypeScript OpenAPI client generator |
| [`@oxide/api`](./packages/api) | The client generated for the Omicron commit specified in `OMICRON_VERSION` |
| [`@oxide/openapi-gen-ts`](./oxide-openapi-gen-ts) | TypeScript OpenAPI client generator |
| [`@oxide/api`](./oxide-api) | The client generated for the Omicron commit specified in `OMICRON_VERSION` |

## Using the API client

See the [README](./package/api/README.md) for the `@oxide/api` package.
See the [README](./oxide-api/README.md) for the `@oxide/api` package.

## Contributing

Expand Down
13 changes: 8 additions & 5 deletions packages/api/README.md → oxide-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,17 @@ const result = await api.methods.projectList({})

if (result.type === "success") {
console.log(result.data.items.map((p) => p.name))
} else if (result.type === "error") {
console.log(result.data.errorCode)
console.log(result.data.message)
} else { // result.type === client_error
console.log(result.error)
}
```

## How does it all work?

### Methods

### Request bodies

### Responses: `ApiResult<T>`

## Other stuff in the package

Most likely nobody but us wants this, and we should take it out of the npm package.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ one, so writing one was easier than existing generators made it look.
./tools/gen.sh
```

The TypeScript client code will be written to `packages/api/src`.
The TypeScript client code will be written to `oxide-api/src`.

## Publishing to npm

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"scripts": {
"build": "tsup-node && mkdir -p dist/static/ && cp src/client/static/util.ts dist/static/ && cp src/client/static/http-client.ts dist/static/",
"lint": "eslint .",
"pretest": "../../tools/gen.sh",
"pretest": "../tools/gen.sh",
"test": "vitest",
"test:ui": "vitest --ui",
"tsc": "tsc"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tools/gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ set -o pipefail

ROOT_DIR="$(dirname "$0")/.."
OMICRON_SHA=$(cat "$ROOT_DIR/OMICRON_VERSION")
DEST_DIR="$ROOT_DIR/packages/api/src"
DEST_DIR="$ROOT_DIR/oxide-api/src"

SPEC_URL="https://raw.githubusercontent.com/oxidecomputer/omicron/$OMICRON_SHA/openapi/nexus.json"
SPEC_FILE="./spec.json"

# TODO: we could get rid of this DL if a test didn't rely on it
curl --fail "$SPEC_URL" -o $SPEC_FILE

npx tsx "$ROOT_DIR/packages/openapi-gen-ts/src/index.ts" $SPEC_FILE $DEST_DIR
npx tsx "$ROOT_DIR/oxide-openapi-gen-ts/src/index.ts" $SPEC_FILE $DEST_DIR
npx prettier --write --log-level error "$DEST_DIR"

0 comments on commit 91bbb7e

Please sign in to comment.