Skip to content

Commit

Permalink
chore: renaming src/cmds to src/commands
Browse files Browse the repository at this point in the history
  • Loading branch information
erunion committed Nov 17, 2024
1 parent b3b14e3 commit f0b4ecd
Show file tree
Hide file tree
Showing 53 changed files with 53 additions and 53 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ act -j simple

### Usage of `console`

As you'll learn in our commands logic (see [`bin/run.js`](bin/run.js) and the [`src/cmds`](src/cmds) directory), we wrap our command outputs in resolved/rejected [`Promise` objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) and use [`bin/run.js`](bin/run.js) file to log the results to the console and return the correct status code. This is so we can write more resilient tests, ensure that the proper exit codes are being returned, and make debugging easier.
As you'll learn in our commands logic (see [`bin/run.js`](bin/run.js) and the [`src/commands`](src/commands) directory), we wrap our command outputs in resolved/rejected [`Promise` objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) and use [`bin/run.js`](bin/run.js) file to log the results to the console and return the correct status code. This is so we can write more resilient tests, ensure that the proper exit codes are being returned, and make debugging easier.

When writing command logic, avoid using `console` statements (and correspondingly, avoid mocking `console` statements in tests) when possible.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import nock from 'nock';
import { describe, beforeAll, beforeEach, afterEach, it, expect } from 'vitest';

import Command from '../../../src/cmds/categories/create.js';
import Command from '../../../src/commands/categories/create.js';
import getAPIMock, { getAPIMockWithVersionHeader } from '../../helpers/get-api-mock.js';
import { runCommand } from '../../helpers/setup-oclif-config.js';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import nock from 'nock';
import { describe, beforeAll, beforeEach, afterEach, it, expect } from 'vitest';

import Command from '../../../src/cmds/categories/index.js';
import Command from '../../../src/commands/categories/index.js';
import getAPIMock, { getAPIMockWithVersionHeader } from '../../helpers/get-api-mock.js';
import { runCommand } from '../../helpers/setup-oclif-config.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import frontMatter from 'gray-matter';
import nock from 'nock';
import { describe, beforeAll, afterAll, beforeEach, it, expect } from 'vitest';

import Command from '../../../src/cmds/changelogs.js';
import Command from '../../../src/commands/changelogs.js';
import APIError from '../../../src/lib/apiError.js';
import getAPIMock from '../../helpers/get-api-mock.js';
import hashFileContents from '../../helpers/hash-file-contents.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import frontMatter from 'gray-matter';
import nock from 'nock';
import { describe, beforeAll, afterAll, beforeEach, it, expect } from 'vitest';

import Command from '../../../src/cmds/changelogs.js';
import Command from '../../../src/commands/changelogs.js';
import APIError from '../../../src/lib/apiError.js';
import getAPIMock from '../../helpers/get-api-mock.js';
import hashFileContents from '../../helpers/hash-file-contents.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import frontMatter from 'gray-matter';
import nock from 'nock';
import { describe, beforeAll, afterAll, beforeEach, it, expect } from 'vitest';

import Command from '../../../src/cmds/custompages.js';
import Command from '../../../src/commands/custompages.js';
import APIError from '../../../src/lib/apiError.js';
import getAPIMock from '../../helpers/get-api-mock.js';
import hashFileContents from '../../helpers/hash-file-contents.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import frontMatter from 'gray-matter';
import nock from 'nock';
import { describe, beforeAll, afterAll, beforeEach, it, expect } from 'vitest';

import Command from '../../../src/cmds/custompages.js';
import Command from '../../../src/commands/custompages.js';
import APIError from '../../../src/lib/apiError.js';
import getAPIMock from '../../helpers/get-api-mock.js';
import hashFileContents from '../../helpers/hash-file-contents.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import nock from 'nock';
import prompts from 'prompts';
import { describe, beforeAll, afterAll, beforeEach, afterEach, it, expect, vi, type MockInstance } from 'vitest';

import Command from '../../../src/cmds/docs/index.js';
import Command from '../../../src/commands/docs/index.js';
import APIError from '../../../src/lib/apiError.js';
import getAPIMock, { getAPIMockWithVersionHeader } from '../../helpers/get-api-mock.js';
import { after, before } from '../../helpers/get-gha-setup.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import frontMatter from 'gray-matter';
import nock from 'nock';
import { describe, beforeAll, beforeEach, afterAll, it, expect } from 'vitest';

import Command from '../../../src/cmds/docs/index.js';
import Command from '../../../src/commands/docs/index.js';
import getAPIMock, { getAPIMockWithVersionHeader } from '../../helpers/get-api-mock.js';
import hashFileContents from '../../helpers/hash-file-contents.js';
import { runCommand } from '../../helpers/setup-oclif-config.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import nock from 'nock';
import prompts from 'prompts';
import { describe, beforeAll, beforeEach, afterAll, it, expect } from 'vitest';

import Command from '../../../src/cmds/docs/prune.js';
import Command from '../../../src/commands/docs/prune.js';
import getAPIMock, { getAPIMockWithVersionHeader } from '../../helpers/get-api-mock.js';
import { runCommand } from '../../helpers/setup-oclif-config.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import frontMatter from 'gray-matter';
import nock from 'nock';
import { describe, beforeAll, afterAll, beforeEach, afterEach, it, expect } from 'vitest';

import Command from '../../../src/cmds/docs/index.js';
import Command from '../../../src/commands/docs/index.js';
import APIError from '../../../src/lib/apiError.js';
import getAPIMock, { getAPIMockWithVersionHeader } from '../../helpers/get-api-mock.js';
import hashFileContents from '../../helpers/hash-file-contents.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import nock from 'nock';
import prompts from 'prompts';
import { describe, beforeAll, beforeEach, afterAll, afterEach, it, expect } from 'vitest';

import Command from '../../src/cmds/login.js';
import Command from '../../src/commands/login.js';
import APIError from '../../src/lib/apiError.js';
import configStore from '../../src/lib/configstore.js';
import getAPIMock from '../helpers/get-api-mock.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, afterEach, beforeEach, it, expect } from 'vitest';

import pkg from '../../package.json';
import Command from '../../src/cmds/logout.js';
import Command from '../../src/commands/logout.js';
import configStore from '../../src/lib/configstore.js';
import { runCommand } from '../helpers/setup-oclif-config.js';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Version } from '../../src/cmds/versions/index.js';
import type { Version } from '../../src/commands/versions/index.js';

import chalk from 'chalk';
import { describe, afterEach, beforeEach, it, expect } from 'vitest';

import pkg from '../../package.json';
import Command from '../../src/cmds/open.js';
import Command from '../../src/commands/open.js';
import configStore from '../../src/lib/configstore.js';
import getAPIMock from '../helpers/get-api-mock.js';
import { runCommand } from '../helpers/setup-oclif-config.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from 'node:fs';
import prompts from 'prompts';
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';

import Command from '../../../src/cmds/openapi/convert.js';
import Command from '../../../src/commands/openapi/convert.js';
import { runCommand } from '../../helpers/setup-oclif-config.js';

const successfulConversion = () => 'Your API definition has been converted and bundled and saved to output.json!';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import nock from 'nock';
import prompts from 'prompts';
import { describe, beforeAll, beforeEach, afterEach, it, expect, vi, type MockInstance } from 'vitest';

import Command from '../../../src/cmds/openapi/index.js';
import Command from '../../../src/commands/openapi/index.js';
import APIError from '../../../src/lib/apiError.js';
import config from '../../../src/lib/config.js';
import petstoreWeird from '../../__fixtures__/petstore-simple-weird-version.json' with { type: 'json' };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import assert from 'node:assert';

import { describe, it, expect, beforeEach } from 'vitest';

import Command from '../../../src/cmds/openapi/inspect.js';
import Command from '../../../src/commands/openapi/inspect.js';
import { runCommand } from '../../helpers/setup-oclif-config.js';

describe('rdme openapi:inspect', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import chalk from 'chalk';
import prompts from 'prompts';
import { describe, beforeEach, afterEach, it, expect, vi, type MockInstance } from 'vitest';

import Command from '../../../src/cmds/openapi/reduce.js';
import Command from '../../../src/commands/openapi/reduce.js';
import { runCommand } from '../../helpers/setup-oclif-config.js';

const successfulReduction = () => 'Your reduced API definition has been saved to output.json! 🤏';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import chalk from 'chalk';
import prompts from 'prompts';
import { describe, beforeEach, afterEach, it, expect, vi, type MockInstance } from 'vitest';

import Command from '../../../src/cmds/openapi/validate.js';
import Command from '../../../src/commands/openapi/validate.js';
import { after, before } from '../../helpers/get-gha-setup.js';
import { runCommand } from '../../helpers/setup-oclif-config.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import nock from 'nock';
import prompts from 'prompts';
import { describe, beforeAll, beforeEach, afterEach, it, expect } from 'vitest';

import Command from '../../../src/cmds/versions/create.js';
import Command from '../../../src/commands/versions/create.js';
import APIError from '../../../src/lib/apiError.js';
import getAPIMock from '../../helpers/get-api-mock.js';
import { runCommand } from '../../helpers/setup-oclif-config.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import nock from 'nock';
import { describe, beforeAll, beforeEach, afterEach, it, expect } from 'vitest';

import Command from '../../../src/cmds/versions/delete.js';
import Command from '../../../src/commands/versions/delete.js';
import APIError from '../../../src/lib/apiError.js';
import getAPIMock from '../../helpers/get-api-mock.js';
import { runCommand } from '../../helpers/setup-oclif-config.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Version } from '../../../src/cmds/versions/index.js';
import type { Version } from '../../../src/commands/versions/index.js';

import nock from 'nock';
import { describe, beforeAll, beforeEach, afterEach, it, expect } from 'vitest';

import Command from '../../../src/cmds/versions/index.js';
import Command from '../../../src/commands/versions/index.js';
import getAPIMock from '../../helpers/get-api-mock.js';
import { runCommand } from '../../helpers/setup-oclif-config.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import nock from 'nock';
import prompts from 'prompts';
import { describe, beforeAll, beforeEach, afterEach, it, expect } from 'vitest';

import Command from '../../../src/cmds/versions/update.js';
import Command from '../../../src/commands/versions/update.js';
import APIError from '../../../src/lib/apiError.js';
import getAPIMock from '../../helpers/get-api-mock.js';
import { runCommand } from '../../helpers/setup-oclif-config.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, afterEach, it, expect, beforeEach } from 'vitest';

import pkg from '../../package.json';
import Command from '../../src/cmds/whoami.js';
import Command from '../../src/commands/whoami.js';
import configStore from '../../src/lib/configstore.js';
import { runCommand } from '../helpers/setup-oclif-config.js';

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
"description": "Sync or prune Guides pages in your ReadMe developer hub."
},
"openapi": {
"description": "Manage your API definition. Supports OpenAPI, Swagger, Postman."
"description": "Manage your API definition. Supports OpenAPI, Swagger, and Postman."
},
"versions": {
"description": "Manage your documentation versions."
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 19 additions & 19 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import CategoriesCreateCommand from './cmds/categories/create.js';
import CategoriesCommand from './cmds/categories/index.js';
import ChangelogsCommand from './cmds/changelogs.js';
import CustomPagesCommand from './cmds/custompages.js';
import DocsCommand from './cmds/docs/index.js';
import DocsPruneCommand from './cmds/docs/prune.js';
import LoginCommand from './cmds/login.js';
import LogoutCommand from './cmds/logout.js';
import OpenCommand from './cmds/open.js';
import OpenAPIConvertCommand from './cmds/openapi/convert.js';
import OpenAPICommand from './cmds/openapi/index.js';
import OpenAPIInspectCommand from './cmds/openapi/inspect.js';
import OpenAPIReduceCommand from './cmds/openapi/reduce.js';
import OpenAPIValidateCommand from './cmds/openapi/validate.js';
import CreateVersionCommand from './cmds/versions/create.js';
import DeleteVersionCommand from './cmds/versions/delete.js';
import VersionsCommand from './cmds/versions/index.js';
import UpdateVersionCommand from './cmds/versions/update.js';
import WhoAmICommand from './cmds/whoami.js';
import CategoriesCreateCommand from './commands/categories/create.js';
import CategoriesCommand from './commands/categories/index.js';
import ChangelogsCommand from './commands/changelogs.js';
import CustomPagesCommand from './commands/custompages.js';
import DocsCommand from './commands/docs/index.js';
import DocsPruneCommand from './commands/docs/prune.js';
import LoginCommand from './commands/login.js';
import LogoutCommand from './commands/logout.js';
import OpenCommand from './commands/open.js';
import OpenAPIConvertCommand from './commands/openapi/convert.js';
import OpenAPICommand from './commands/openapi/index.js';
import OpenAPIInspectCommand from './commands/openapi/inspect.js';
import OpenAPIReduceCommand from './commands/openapi/reduce.js';
import OpenAPIValidateCommand from './commands/openapi/validate.js';
import CreateVersionCommand from './commands/versions/create.js';
import DeleteVersionCommand from './commands/versions/delete.js';
import VersionsCommand from './commands/versions/index.js';
import UpdateVersionCommand from './commands/versions/update.js';
import WhoAmICommand from './commands/whoami.js';

export { default as createGHA } from './lib/hooks/createGHA.js';
export { default as prerun } from './lib/hooks/prerun.js';
Expand Down
4 changes: 2 additions & 2 deletions src/lib/createGHA/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function getKey(args: CommandFlag, opts: ParsedOpts): string | false {
/**
* Constructs the command string that we pass into the workflow file.
*/
function constructCmdString(commandId: string, args: CommandArg, flags: CommandFlag, opts: ParsedOpts): string {
function constructCommandString(commandId: string, args: CommandArg, flags: CommandFlag, opts: ParsedOpts): string {
const argsString = Object.keys(args)
.map(arg => {
return opts[arg];
Expand Down Expand Up @@ -264,7 +264,7 @@ export default async function createGHA(
branch,
cleanCommand: cleanFileName(commandId),
command: commandId,
commandString: constructCmdString(commandId, args, flags, parsedOpts),
commandString: constructCommandString(commandId, args, flags, parsedOpts),
rdmeVersion: `v${majorPkgVersion}`,
timestamp: new Date().toISOString(),
};
Expand Down
2 changes: 1 addition & 1 deletion src/lib/prompts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Version } from '../cmds/versions/index.js';
import type { Version } from '../commands/versions/index.js';
import type { Choice, PromptObject } from 'prompts';

import parse from 'parse-link-header';
Expand Down
6 changes: 3 additions & 3 deletions src/lib/syncDocsPath.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ReadDocMetadata } from './readDoc.js';
import type ChangelogsCommand from '../cmds/changelogs.js';
import type CustomPagesCommand from '../cmds/custompages.js';
import type DocsCommand from '../cmds/docs/index.js';
import type ChangelogsCommand from '../commands/changelogs.js';
import type CustomPagesCommand from '../commands/custompages.js';
import type DocsCommand from '../commands/docs/index.js';

import fs from 'node:fs/promises';
import path from 'node:path';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/versionSelect.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { APIErrorResponse } from './apiError.js';
import type { Version } from '../cmds/versions/index.js';
import type { Version } from '../commands/versions/index.js';

import APIError from './apiError.js';
import isCI from './isCI.js';
Expand Down

0 comments on commit f0b4ecd

Please sign in to comment.