-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8db6408
commit 1d0c275
Showing
206 changed files
with
10,065 additions
and
20,435 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,23 @@ | ||
ARG VARIANT="3.9" | ||
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} | ||
# syntax=docker/dockerfile:1 | ||
FROM debian:bookworm-slim AS stainless | ||
|
||
USER vscode | ||
RUN apt-get update && apt-get install -y \ | ||
nodejs \ | ||
npm \ | ||
yarnpkg \ | ||
&& apt-get clean autoclean | ||
|
||
RUN curl -sSf https://rye-up.com/get | RYE_VERSION="0.24.0" RYE_INSTALL_OPTION="--yes" bash | ||
ENV PATH=/home/vscode/.rye/shims:$PATH | ||
# Ensure UTF-8 encoding | ||
ENV LANG=C.UTF-8 | ||
ENV LC_ALL=C.UTF-8 | ||
|
||
RUN echo "[[ -d .venv ]] && source .venv/bin/activate" >> /home/vscode/.bashrc | ||
# Yarn | ||
RUN ln -sf /usr/bin/yarnpkg /usr/bin/yarn | ||
|
||
WORKDIR /workspace | ||
|
||
COPY package.json yarn.lock /workspace/ | ||
|
||
RUN yarn install | ||
|
||
COPY . /workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['@typescript-eslint', 'unused-imports', 'prettier'], | ||
rules: { | ||
'no-unused-vars': 'off', | ||
'prettier/prettier': 'error', | ||
'unused-imports/no-unused-imports': 'error', | ||
}, | ||
root: true, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# This workflow is triggered when a GitHub release is created. | ||
# It can also be run manually to re-publish to NPM in case it failed for some reason. | ||
# You can run this workflow by navigating to https://www.github.com/vvonchain/case-filing-api/actions/workflows/publish-npm.yml | ||
name: Publish NPM | ||
on: | ||
workflow_dispatch: | ||
|
||
release: | ||
types: [published] | ||
|
||
jobs: | ||
publish: | ||
name: publish | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Install dependencies | ||
run: | | ||
yarn install | ||
- name: Publish to NPM | ||
run: | | ||
bash ./bin/publish-npm | ||
env: | ||
NPM_TOKEN: ${{ secrets.CASE_FILING_API_NPM_TOKEN || secrets.NPM_TOKEN }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
.vscode | ||
_dev | ||
|
||
__pycache__ | ||
.mypy_cache | ||
|
||
node_modules | ||
yarn-error.log | ||
codegen.log | ||
dist | ||
/deno | ||
/*.tgz | ||
.idea/ | ||
|
||
.venv | ||
.idea | ||
|
||
.env | ||
.envrc | ||
codegen.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CHANGELOG.md | ||
/ecosystem-tests/*/** | ||
/node_modules | ||
/deno | ||
|
||
# don't format tsc output, will break source maps | ||
/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"arrowParens": "always", | ||
"experimentalTernaries": true, | ||
"printWidth": 110, | ||
"singleQuote": true, | ||
"trailingComma": "all" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
".": "0.0.1-alpha.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,38 @@ | ||
## Setting up the environment | ||
|
||
### With Rye | ||
This repository uses [`yarn@v1`](https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable). | ||
Other package managers may work but are not officially supported for development. | ||
|
||
We use [Rye](https://rye-up.com/) to manage dependencies so we highly recommend [installing it](https://rye-up.com/guide/installation/) as it will automatically provision a Python environment with the expected Python version. | ||
To set up the repository, run: | ||
|
||
After installing Rye, you'll just have to run this command: | ||
|
||
```sh | ||
$ rye sync --all-features | ||
``` | ||
|
||
You can then run scripts using `rye run python script.py` or by activating the virtual environment: | ||
|
||
```sh | ||
$ rye shell | ||
# or manually activate - https://docs.python.org/3/library/venv.html#how-venvs-work | ||
$ source .venv/bin/activate | ||
|
||
# now you can omit the `rye run` prefix | ||
$ python script.py | ||
```bash | ||
yarn | ||
yarn build | ||
``` | ||
|
||
### Without Rye | ||
|
||
Alternatively if you don't want to install `Rye`, you can stick with the standard `pip` setup by ensuring you have the Python version specified in `.python-version`, create a virtual environment however you desire and then install dependencies using this command: | ||
|
||
```sh | ||
$ pip install -r requirements-dev.lock | ||
``` | ||
This will install all the required dependencies and build output files to `dist/`. | ||
|
||
## Modifying/Adding code | ||
|
||
Most of the SDK is generated code, and any modified code will be overridden on the next generation. The | ||
`src/case_filing_api/lib/` and `examples/` directories are exceptions and will never be overridden. | ||
`src/lib/` and `examples/` directories are exceptions and will never be overridden. | ||
|
||
## Adding and running examples | ||
|
||
All files in the `examples/` directory are not modified by the Stainless generator and can be freely edited or | ||
added to. | ||
|
||
```bash | ||
# add an example to examples/<your-example>.py | ||
// add an example to examples/<your-example>.ts | ||
|
||
#!/usr/bin/env -S rye run python | ||
#!/usr/bin/env -S npm run tsn -T | ||
… | ||
``` | ||
|
||
``` | ||
chmod +x examples/<your-example>.py | ||
chmod +x examples/<your-example>.ts | ||
# run the example against your api | ||
./examples/<your-example>.py | ||
yarn tsn -T examples/<your-example>.ts | ||
``` | ||
|
||
## Using the repository from source | ||
|
@@ -59,67 +42,66 @@ If you’d like to use the repository from source, you can either install from g | |
To install via git: | ||
|
||
```bash | ||
pip install git+ssh://[email protected]/vvonchain/case-filing-api.git | ||
npm install git+ssh://[email protected]:vvonchain/case-filing-api.git | ||
``` | ||
|
||
Alternatively, you can build from source and install the wheel file: | ||
|
||
Building this package will create two files in the `dist/` directory, a `.tar.gz` containing the source files and a `.whl` that can be used to install the package efficiently. | ||
|
||
To create a distributable version of the library, all you have to do is run this command: | ||
Alternatively, to link a local copy of the repo: | ||
|
||
```bash | ||
rye build | ||
# or | ||
python -m build | ||
``` | ||
|
||
Then to install: | ||
|
||
```sh | ||
pip install ./path-to-wheel-file.whl | ||
# Clone | ||
git clone https://www.github.com/vvonchain/case-filing-api | ||
cd case-filing-api | ||
|
||
# With yarn | ||
yarn link | ||
cd ../my-package | ||
yarn link case-filing-api | ||
|
||
# With pnpm | ||
pnpm link --global | ||
cd ../my-package | ||
pnpm link -—global case-filing-api | ||
``` | ||
|
||
## Running tests | ||
|
||
Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests. | ||
|
||
```bash | ||
# you will need npm installed | ||
npx prism mock path/to/your/openapi.yml | ||
``` | ||
|
||
```bash | ||
rye run pytest | ||
yarn run test | ||
``` | ||
|
||
## Linting and formatting | ||
|
||
This repository uses [ruff](https://github.com/astral-sh/ruff) and | ||
[black](https://github.com/psf/black) to format the code in the repository. | ||
This repository uses [prettier](https://www.npmjs.com/package/prettier) and | ||
[eslint](https://www.npmjs.com/package/eslint) to format the code in the repository. | ||
|
||
To lint: | ||
|
||
```bash | ||
rye run lint | ||
yarn lint | ||
``` | ||
|
||
To format and fix all ruff issues automatically: | ||
To format and fix all lint issues automatically: | ||
|
||
```bash | ||
rye run format | ||
yarn fix | ||
``` | ||
|
||
## Publishing and releases | ||
|
||
Changes made to this repository via the automated release PR pipeline should publish to PyPI automatically. If | ||
Changes made to this repository via the automated release PR pipeline should publish to npm automatically. If | ||
the changes aren't made through the automated pipeline, you may want to make releases manually. | ||
|
||
### Publish with a GitHub workflow | ||
|
||
You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/vvonchain/case-filing-api/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up. | ||
You can release to package managers by using [the `Publish NPM` GitHub action](https://www.github.com/vvonchain/case-filing-api/actions/workflows/publish-npm.yml). This requires a setup organization or repository secret to be set up. | ||
|
||
### Publish manually | ||
|
||
If you need to manually release a package, you can run the `bin/publish-pypi` script with a `PYPI_TOKEN` set on | ||
If you need to manually release a package, you can run the `bin/publish-npm` script with an `NPM_TOKEN` set on | ||
the environment. |
Oops, something went wrong.