Skip to content

Commit 4cb7d6a

Browse files
authored
Merge pull request #17 from lornajane/package-prep
Prepare to publish as a package
2 parents 709e811 + 71c3c4f commit 4cb7d6a

File tree

3 files changed

+25
-18
lines changed

3 files changed

+25
-18
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ Overlays are a way to extend or enhance an existing [OpenAPI description](https:
1414

1515
## Installation
1616

17-
This project isn't published as a package yet, so:
17+
Install the `overlayjs` command from [npm](https://npmjs.com) with the following command:
1818

19-
* Clone this repo
20-
* Run `npm install` to get the dependencies
21-
* Run `npm install -g` to get `overlayjs` as a command
19+
```text
20+
npm install -g openapi-overlay-js
21+
```
2222

23-
> **Pro-tip:** you can also use `node index.js` from the root of the project if you don't want to install a global command.
23+
The `-g` switch installs it globally so you can use the command from anywhere on your system.
24+
25+
> **Pro-tip:** use `node index.js` from the root of the project if you're using the bleeding edge of the project or working on a branch.
2426
2527
## Usage
2628

@@ -32,6 +34,6 @@ See [docs/examples](docs/examples/index.md) for more examples.
3234

3335
## Project status
3436

35-
This project is very much at idea stage but feedback, comments and questions are all very welcome as issues on this repository - and pull requests are also gratefully received. It would be excellent to hear what problem this tool can solve, and how you get on with it. Bonus points if you can share examples (working or broken) of what you tried.
37+
:warning: Project status: alpha
3638

37-
:warning: please be aware that absolutely anything may change at any time, it would probably be safest to pin to a specific commit for now.
39+
This project is very much at an alpha stage but feedback, comments and questions are all very welcome as issues on this repository - and pull requests are also gratefully received. It would be excellent to hear what problem this tool can solve, and how you get on with it. Bonus points if you can share examples (working or broken) of what you tried.

index.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
#!/usr/bin/env node
22
import arg from 'arg'
3+
import fs from 'fs'
34
import { overlayFiles } from './src/overlay.js'
45

56
function showHelp () {
67
console.log('Usage: overlayjs --openapi FILEPATH --overlay FILEPATH')
78
console.log(' use --help to see this help')
89
}
910

11+
// Function to read the version from package.json
12+
function showVersion () {
13+
const packageJsonPath = './package.json'
14+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
15+
console.log(packageJson.version)
16+
}
17+
1018
try {
1119
const args = arg({
1220
'--openapi': String,
1321
'--overlay': String,
22+
'--version': Boolean,
1423
'--help': Boolean
1524
})
1625

17-
if (args['--overlay'] && args['--openapi']) {
18-
const openapiFile = args['--openapi']
19-
const overlayFile = args['--overlay']
20-
const spec = overlayFiles(openapiFile, overlayFile)
21-
console.log(spec)
22-
} else {
23-
showHelp()
26+
if (args['--version']) {
27+
showVersion()
28+
process.exit(0)
2429
}
2530

2631
if (args['--overlay'] && args['--openapi']) {

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "preparse",
3-
"version": "1.0.0",
4-
"description": "",
2+
"name": "openapi-overlays-js",
3+
"version": "0.1.0",
4+
"description": "Tool to apply OpenAPI overlays, built in NodeJS with a command line interface (CLI).",
55
"main": "index.js",
66
"bin": {
77
"overlayjs": "./index.js"
@@ -12,7 +12,7 @@
1212
"fmt": "eslint . --config .eslintrc.json --fix"
1313
},
1414
"type": "module",
15-
"author": "",
15+
"author": "Lorna Mitchell <[email protected]>",
1616
"license": "Apache2",
1717
"dependencies": {
1818
"@stoplight/yaml": "^4.2.3",

0 commit comments

Comments
 (0)