Skip to content

Commit d412a04

Browse files
authored
feat(docs): add guides alias (#647)
* feat: create guides aliases * test: alias tests * docs: make OAS category name more generic * docs: rename docs header * chore: rearrange categories * docs: update headings, add alias docs
1 parent 7552501 commit d412a04

File tree

9 files changed

+109
-11
lines changed

9 files changed

+109
-11
lines changed

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ rdme openapi:reduce [path-to-file.json]
193193

194194
The command will ask you a couple questions about how you wish to reduce the file and then do so. And as with the `openapi` command, you can also [omit the file path](#omitting-the-file-path).
195195

196-
### Docs
196+
### Docs (a.k.a. Guides)
197197

198198
The Markdown files will require YAML front matter with certain ReadMe documentation attributes. Check out [our docs](https://docs.readme.com/docs/rdme#markdown-file-setup) for more info on setting up your front matter.
199199

@@ -203,6 +203,12 @@ Passing in a path to a directory will also sync any Markdown files that are loca
203203
rdme docs [path] --version={project-version}
204204
```
205205

206+
This command also has an alias called `guides`:
207+
208+
```
209+
rdme guides [path] --version={project-version}
210+
```
211+
206212
This command also has a dry run mode, which can be useful for initial setup and debugging. You can read more about dry run mode [in our docs](https://docs.readme.com/docs/rdme#dry-run-mode).
207213

208214
#### Prune
@@ -213,7 +219,13 @@ If you wish to delete documents from ReadMe that are no longer present in your l
213219
rdme docs:prune path-to-directory-of-markdown
214220
```
215221

216-
### Changelogs
222+
This command also has an alias called `guides:prune`:
223+
224+
```sh
225+
rdme guides:prune path-to-directory-of-markdown
226+
```
227+
228+
### Changelog
217229

218230
The Markdown files will require YAML front matter with certain ReadMe documentation attributes. Check out [our docs](https://docs.readme.com/docs/rdme#markdown-file-setup) for more info on setting up your front matter.
219231

__tests__/cmds/docs/index.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import nock from 'nock';
88
import prompts from 'prompts';
99

1010
import DocsCommand from '../../../src/cmds/docs';
11+
import GuidesCommand from '../../../src/cmds/guides';
1112
import APIError from '../../../src/lib/apiError';
1213
import getAPIMock, { getAPIMockWithVersionHeader } from '../../helpers/get-api-mock';
1314
import { after, before } from '../../helpers/get-gha-setup';
1415
import hashFileContents from '../../helpers/hash-file-contents';
1516

1617
const docs = new DocsCommand();
18+
const guides = new GuidesCommand();
1719

1820
const fixturesBaseDir = '__fixtures__/docs';
1921
const fullFixturesDir = `${__dirname}./../../${fixturesBaseDir}`;
@@ -626,3 +628,19 @@ describe('rdme docs', () => {
626628
});
627629
});
628630
});
631+
632+
describe('rdme guides', () => {
633+
beforeAll(() => nock.disableNetConnect());
634+
635+
afterAll(() => nock.cleanAll());
636+
637+
it('should error if no path provided', async () => {
638+
const versionMock = getAPIMock().get(`/api/v1/version/${version}`).basicAuth({ user: key }).reply(200, { version });
639+
640+
await expect(guides.run({ key, version: '1.0.0' })).rejects.toStrictEqual(
641+
new Error('No path provided. Usage `rdme guides <path> [options]`.')
642+
);
643+
644+
versionMock.done();
645+
});
646+
});

__tests__/cmds/docs/prune.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import nock from 'nock';
22
import prompts from 'prompts';
33

44
import DocsPruneCommand from '../../../src/cmds/docs/prune';
5+
import GuidesPruneCommand from '../../../src/cmds/guides/prune';
56
import getAPIMock, { getAPIMockWithVersionHeader } from '../../helpers/get-api-mock';
67

78
const docsPrune = new DocsPruneCommand();
9+
const guidesPrune = new GuidesPruneCommand();
810

911
const fixturesBaseDir = '__fixtures__/docs';
1012

@@ -118,3 +120,15 @@ describe('rdme docs:prune', () => {
118120
versionMock.done();
119121
});
120122
});
123+
124+
describe('rdme guides:prune', () => {
125+
beforeAll(() => nock.disableNetConnect());
126+
127+
afterAll(() => nock.cleanAll());
128+
129+
it('should error if no folder provided', () => {
130+
return expect(guidesPrune.run({ key, version: '1.0.0' })).rejects.toStrictEqual(
131+
new Error('No folder provided. Usage `rdme guides:prune <folder> [options]`.')
132+
);
133+
});
134+
});

__tests__/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ describe('cli', () => {
8989
});
9090

9191
it('should not error with undefined cmd', async () => {
92-
await expect(cli([])).resolves.toContain('Upload OpenAPI/Swagger definitions');
92+
await expect(cli([])).resolves.toContain('OpenAPI / Swagger');
9393
});
9494

9595
it('should add stored apiKey to opts', async () => {

__tests__/lib/__snapshots__/commands.test.ts.snap

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ exports[`utils #listByCategory should list commands by category 1`] = `
5858
"position": 5,
5959
},
6060
],
61-
"description": "Upload OpenAPI/Swagger definitions",
61+
"description": "OpenAPI / Swagger",
6262
},
6363
"categories": {
6464
"commands": [
@@ -119,8 +119,20 @@ exports[`utils #listByCategory should list commands by category 1`] = `
119119
"name": "docs:edit",
120120
"position": 3,
121121
},
122+
{
123+
"description": "Alias for \`rdme docs\`.",
124+
"hidden": false,
125+
"name": "guides",
126+
"position": 3,
127+
},
128+
{
129+
"description": "Alias for \`rdme docs:prune\`.",
130+
"hidden": false,
131+
"name": "guides:prune",
132+
"position": 4,
133+
},
122134
],
123-
"description": "Documentation",
135+
"description": "Docs (a.k.a. Guides)",
124136
},
125137
"utilities": {
126138
"commands": [

src/cmds/guides/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { CommandOptions } from '../../lib/baseCommand';
2+
import type { Options } from '../docs';
3+
4+
import DocsCommand from '../docs';
5+
6+
export default class GuidesCommand extends DocsCommand {
7+
constructor() {
8+
super();
9+
10+
this.command = 'guides';
11+
this.usage = 'guides <path> [options]';
12+
this.description = 'Alias for `rdme docs`.';
13+
this.position = 3;
14+
}
15+
16+
async run(opts: CommandOptions<Options>) {
17+
return super.run(opts);
18+
}
19+
}

src/cmds/guides/prune.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { CommandOptions } from '../../lib/baseCommand';
2+
import type { Options } from '../docs/prune';
3+
4+
import DocsPruneCommand from '../docs/prune';
5+
6+
export default class GuidesPruneCommand extends DocsPruneCommand {
7+
constructor() {
8+
super();
9+
10+
this.command = 'guides:prune';
11+
this.usage = 'guides:prune <folder> [options]';
12+
this.description = 'Alias for `rdme docs:prune`.';
13+
this.position = 4;
14+
}
15+
16+
async run(opts: CommandOptions<Options>) {
17+
return super.run(opts);
18+
}
19+
}

src/cmds/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import CustomPagesCommand from './custompages';
55
import DocsCommand from './docs';
66
import DocsEditCommand from './docs/edit';
77
import DocsPruneCommand from './docs/prune';
8+
import GuidesCommand from './guides';
9+
import GuidesPruneCommand from './guides/prune';
810
import LoginCommand from './login';
911
import LogoutCommand from './logout';
1012
import OASCommand from './oas';
@@ -30,6 +32,8 @@ const commands = {
3032
docs: DocsCommand,
3133
'docs:prune': DocsPruneCommand,
3234
'docs:edit': DocsEditCommand,
35+
guides: GuidesCommand,
36+
'guides:prune': GuidesPruneCommand,
3337

3438
versions: VersionsCommand,
3539
'versions:create': CreateVersionCommand,

src/lib/commands.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ export function getCategories(): Record<
1616
> {
1717
return {
1818
apis: {
19-
description: 'Upload OpenAPI/Swagger definitions',
19+
description: 'OpenAPI / Swagger',
2020
commands: [],
2121
},
2222
docs: {
23-
description: 'Documentation',
23+
description: 'Docs (a.k.a. Guides)',
2424
commands: [],
2525
},
2626
changelogs: {
@@ -31,14 +31,14 @@ export function getCategories(): Record<
3131
description: 'Custom Pages',
3232
commands: [],
3333
},
34-
categories: {
35-
description: 'Categories',
36-
commands: [],
37-
},
3834
versions: {
3935
description: 'Versions',
4036
commands: [],
4137
},
38+
categories: {
39+
description: 'Categories',
40+
commands: [],
41+
},
4242
admin: {
4343
description: 'Administration',
4444
commands: [],

0 commit comments

Comments
 (0)