Skip to content

Commit

Permalink
📦 Prepare for npm publishing
Browse files Browse the repository at this point in the history
Updates `package.json` with more package metadata. Changes emit location
to simplify consumption. Extends the README documentation. Includes an
empty `index.js`.
  • Loading branch information
connorjs committed Sep 9, 2023
1 parent f07a49d commit 7d452ac
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dist/
node_modules/
node_modules/
swapi.openapi.yaml
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,43 @@

<!-- End badges -->

## Notes
## About

I created this project to learn about TypeSpec through first-hand usage.

## Getting started

Follow these steps to consume the generated Open API specification for SWAPI.

1. Install this package as a dependency

```sh
npm install -D swapi-typespec
```

2. Reference the generated Open API specification directly.

```sh
./node_modules/swapi-typespec/swapi.openapi.yaml
```

## Developing

### Run scripts

Use `npm run` to list all available scripts. The `release` script executes a
“release build.” The CI build uses this script.

### Directory structure

- [src](./src) contains the TypeSpec (`.tsp`) files

### Notes

- Using `@resource` adds _all_ REST operations. Thus, the spec files explicitly
configure `list` and `read` operations because SWAPI only supports those.

---

[swapi]: https://swapi.dev
[typespec]: https://microsoft.github.io/typespec/
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Not a JS module
export {};
4 changes: 2 additions & 2 deletions package-lock.json

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

28 changes: 27 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
{
"name": "swapi-typespec",
"version": "1.0.0-alpha.0",
"description": "TypeSpec representation of SWAPI: The Star Wars API.",
"version": "1.0.0-prerelease",
"keywords": [
"api",
"openapi",
"openapi3",
"star wars",
"swagger",
"swapi",
"typespec"
],
"homepage": "https://github.com/connorjs/swapi-typespec#readme",
"bugs": {
"url": "https://github.com/connorjs/swapi-typespec/issues"
},
"license": "MIT",
"author": {
"name": "Connor Sullivan",
"email": "dev.connorjs@gmail.com",
"url": "https://github.com/connorjs"
},
"type": "module",
"files": [
"index.js",
"swapi.openapi.yaml"
],
"exports": {
".": "./index.js"
},
"scripts": {
"build": "tsp compile src",
"format": "prettier -l '**/*.{json,md,tsp,yaml,yml}'",
Expand Down
4 changes: 2 additions & 2 deletions tspconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ emit:
- "@typespec/openapi3"
options:
"@typespec/openapi3":
emitter-output-dir: "{project-root}/dist"
emitter-output-dir: "{project-root}" # emit to the root for distribution
omit-unreachable-types: true
output-file: "swapi.openapi.yaml"
output-file: "swapi.openapi.yaml" # matches `files` in `package.json` and is in `.gitignore`

0 comments on commit 7d452ac

Please sign in to comment.