Skip to content

Commit

Permalink
refactor!: move from apidoc to apidoc-light
Browse files Browse the repository at this point in the history
* cli, docs option removed
* apidocBuild, light only allows dryRun
* index, remove express served docs path
  • Loading branch information
cdcabrera committed Oct 15, 2024
1 parent d4bb02e commit 83e0f26
Show file tree
Hide file tree
Showing 8 changed files with 534 additions and 1,405 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ NPM install...
Usage: mock [options]
Options:
-d, --docs Output directory used to compile apidocs [default: "./.docs"]
-p, --port Set mock port [default: 8000]
-s, --silent Silence apiDoc's output warnings, errors
[boolean] [default: true]
Expand All @@ -56,8 +55,6 @@ NPM install...
```

Then follow the guide for [apidoc](http://apidocjs.com/). From there run the NPM script, and open [localhost:5000/[PATH TO API ENDPOINT]](http://localhost:5000/).

It's recommended you make sure to `.gitignore` the `.docs` directory that gets generated for `apidocs`.

### Or roll with a container setup, maybe?
Since `apidoc-mock` now runs locally we consider our `Dockerfile` to be less of a focus and now in maintenance mode.
Expand Down Expand Up @@ -130,8 +127,6 @@ The `apidoc-mock` image comes preloaded with a "hello/world" example...
1. Next
#### Using a NPM script setup
Then, make sure to `.gitignore` the `.docs` directory that gets generated for `apidocs`.
Then, setup your NPM scripts
```js
"scripts": {
Expand Down
16 changes: 3 additions & 13 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,12 @@ const { apiDocMock, OPTIONS } = require('../src');
/**
* Setup yargs
*/
const { docs, port, silent, watch } = yargs
const { port, silent, watch } = yargs
.usage('Create a mock server from apiDoc comments.\n\nUsage: mock [options]')
.help('help')
.alias('h', 'help')
.version('version', packageJson.version)
.alias('v', 'version')
.option('d', {
alias: 'docs',
default: './.docs',
describe: 'Output directory used to compile apidocs',
requiresArg: true,
type: 'string'
})
.option('p', {
alias: 'port',
default: 8000,
Expand All @@ -48,25 +41,22 @@ const { docs, port, silent, watch } = yargs
/**
* Set global OPTIONS
*
* @type {{silent, docsPath: string, port: number, watchPath: string[]}}
* @type {{silent, port: number, watchPath: string[]}}
* @private
*/
OPTIONS._set = {
port,
silent,
watchPath: function () {
return watch?.map(val => join(this.contextPath || '', val))?.filter(val => (existsSync(val) && val) || false) || [];
},
docsPath: function () {
return join(this.contextPath || '', docs);
}
};

/**
* If testing stop here, otherwise continue.
*/
if (process.env.NODE_ENV === 'test') {
process.stdout.write(JSON.stringify({ docs, port, silent, watch }));
process.stdout.write(JSON.stringify({ port, silent, watch }));
} else {
apiDocMock();

Expand Down
Loading

0 comments on commit 83e0f26

Please sign in to comment.