Skip to content

Commit

Permalink
Repo cleanup and devcontainer cleanup (#58)
Browse files Browse the repository at this point in the history
* Doing some repo cleanup and devcontainer cleanup.

* Updating README and adding some tweaks to justfile.
  • Loading branch information
kevinswiber authored Sep 15, 2023
1 parent 6fdd00b commit ad5eb9b
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 13 deletions.
7 changes: 6 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@ RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
RUN apt-get update && apt-get install nodejs -y

RUN rustup target install wasm32-unknown-unknown

USER vscode
RUN cargo install wasm-pack
RUN cargo install wasm-bindgen-cli
RUN cargo install wasm-opt
RUN cargo install wasm-pack
RUN cargo install just
7 changes: 2 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"name": "Rust",
"name": "postman2openapi",
"dockerFile": "Dockerfile",
"postCreateCommand": "rustc --version",
"runArgs": [
"--network=host"
]
"postCreateCommand": "rustc --version && echo \"node $(node --version)\" && just --version",
}
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/pkg
/nodejs
/target
/web/node_modules
/web/dist
/web/node_modules
/web/wasm
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Convert Postman collections to OpenAPI definitions.
- [Installation](#installation-1)
- [Usage](#usage-1)
- [JavaScript API](#javascript-api)
- [Build](#build)
- [License](#license)

## CLI
Expand Down Expand Up @@ -95,6 +96,24 @@ console.log(JSON.stringify(openapi, null, 2));
- collection - An object representing the Postman collection.
- _returns_ - an OpenAPI definition as a JavaScript object.

## Build

Note: A [Dev Container](https://containers.dev/) is included for convenience.

To take advantage of build recipes, install [just](https://github.com/casey/just#packages).

### `just build`

Builds all projects.

### `just test`

Runs all lint checks (`cargo fmt --check`, `cargo clippy`) and runs all tests, including tests for `wasm32-unknown-unknown` targets (Node.js, Chrome, Firefox).

### `just start-web`

Builds the WebAssembly project and starts a local version of the [postman2openapi site](https://kevinswiber.github.io/postman2openapi/).

## License

Apache License 2.0 (Apache-2.0)
6 changes: 5 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ build-web:
wasm-pack build --release --out-dir ./web/wasm --target bundler
npm install --prefix ./web
npm run build --prefix ./web
build-nodejs:
wasm-pack build --release --out-dir ./nodejs --target nodejs

fmt-check:
cargo fmt --check --all
clippy:
cargo clippy -- -D warnings

test: build test-lib test-unit test-integration test-wasm-node test-wasm-chrome test-wasm-firefox
test: build fmt-check clippy test-lib test-unit test-integration test-wasm-node test-wasm-chrome test-wasm-firefox

test-lib:
cargo test --lib
Expand Down
2 changes: 1 addition & 1 deletion web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"main": "index.js",
"private": true,
"scripts": {
"build": "rimraf dist ../pkg && NODE_OPTIONS=--openssl-legacy-provider webpack --config webpack.config.js --mode production",
"start": "rimraf dist ../pkg && NODE_OPTIONS=--openssl-legacy-provider webpack-dev-server --mode development",
"build": "rimraf dist wasm && NODE_OPTIONS=--openssl-legacy-provider webpack --config webpack.config.js --mode production",
"start": "rimraf dist wasm && NODE_OPTIONS=--openssl-legacy-provider webpack-dev-server --mode development",
"test": "cargo test && wasm-pack test --headless"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion web/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
new CopyWebpackPlugin([path.resolve(__dirname, 'static')]),
new WasmPackPlugin({
crateDirectory: path.resolve(__dirname, '..'),
outDir: path.resolve(__dirname, '..', 'pkg'),
outDir: path.resolve(__dirname, 'wasm'),
}),
],
module: {
Expand Down

0 comments on commit ad5eb9b

Please sign in to comment.