Skip to content

Commit

Permalink
Merge branch 'next' into terrell/cx-364-create-a-warning-in-rdme-when…
Browse files Browse the repository at this point in the history
…-someone-works-with-a-postman
  • Loading branch information
t-tullis committed Sep 26, 2023
2 parents bee66b8 + 136dc80 commit ca069d7
Show file tree
Hide file tree
Showing 126 changed files with 5,085 additions and 14,932 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
coverage/
dist/
!.alexrc.js
exe/
14 changes: 9 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"extends": ["@readme/eslint-config", "@readme/eslint-config/typescript"],
"extends": ["@readme/eslint-config", "@readme/eslint-config/typescript", "@readme/eslint-config/esm"],
"root": true,
"parserOptions": {
"ecmaVersion": 2020
},
"overrides": [
{
"files": ["bin/*.js"],
Expand All @@ -12,6 +9,13 @@
}
}
],
"env": {
"es2021": true,
"node": true
},
"parserOptions": {
"sourceType": "module"
},
"rules": {
"@typescript-eslint/ban-types": [
"error",
Expand All @@ -37,7 +41,7 @@
* console.log() calls, hurting our ability to write resilient tests and easily debug issues.
*
* We should be returning Promise-wrapped values in our main command functions
* so we can write robust tests and take advantage of `bin/rdme`,
* so we can write robust tests and take advantage of `bin/rdme.js`,
* which we use for printing function outputs and returning correct exit codes.
*
* Furthermore, we should also be using our custom loggers (see src/lib/logger.js)
Expand Down
16 changes: 2 additions & 14 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,7 @@ updates:
prefix: chore(deps)
prefix-development: chore(deps-dev)
ignore:
# All of these packages are now ESM-only and can't be used here without a rewrite.
- dependency-name: chalk
versions:
- '>= 5'
- dependency-name: configstore
versions:
- '>= 6'
- dependency-name: node-fetch
versions:
- '>= 3'
- dependency-name: open
versions:
- '>= 9'
# See https://github.com/sindresorhus/ora/issues/229
- dependency-name: ora
versions:
- '>= 6'
- '>= 7'
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ jobs:
fail-fast: false
matrix:
node-version:
- 14
- 16
- 18
- 20

Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Log in to the Container registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
Expand All @@ -71,3 +71,10 @@ jobs:
NPM_CONFIG_PROVENANCE: 'true'
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release

- name: Sync changes back to next
if: ${{ github.ref }} == 'refs/heads/main'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.RELEASE_GH_TOKEN }}
branch: next
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.env
coverage/
dist/
.env
exe/
node_modules/
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ __tests__/
.github/
.husky/
.prettier*
bin/*.js
bin/**
coverage/
packages/
vitest.*
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lockfile-version=2
lockfile-version=3
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ __tests__/__fixtures__/invalid-json/yikes.json
CHANGELOG.md
coverage/
dist/
exe/
66 changes: 66 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,69 @@
# [9.0.0-next.5](https://github.com/readmeio/rdme/compare/v9.0.0-next.4...v9.0.0-next.5) (2023-09-15)


### Features

* **versions:** flag parity with API, copy fixes ([#906](https://github.com/readmeio/rdme/issues/906)) ([d424d9f](https://github.com/readmeio/rdme/commit/d424d9feef8bcb55f4a2a25fca19d25ad7b7e697))


### BREAKING CHANGES

* **versions:** this flips the `isPublic` flag to `hidden`.

# [9.0.0-next.4](https://github.com/readmeio/rdme/compare/v9.0.0-next.3...v9.0.0-next.4) (2023-09-15)


### chore

* type fixes for tests ([#903](https://github.com/readmeio/rdme/issues/903)) ([d423b4c](https://github.com/readmeio/rdme/commit/d423b4ceb15f5726bb5efed22a4a9cd6e5dfa9f9))


### BREAKING CHANGES

* removes several deprecated commands

* chore: knip cleanup

* chore: type fixes for tests

# [9.0.0-next.3](https://github.com/readmeio/rdme/compare/v9.0.0-next.2...v9.0.0-next.3) (2023-09-14)


### Code Refactoring

* remove `oas`, `swagger`, `docs:edit` ([#902](https://github.com/readmeio/rdme/issues/902)) ([9107d15](https://github.com/readmeio/rdme/commit/9107d15770532de98156b7407c7f274ba7ea28cf))


### BREAKING CHANGES

* removes several deprecated commands

# [9.0.0-next.2](https://github.com/readmeio/rdme/compare/v9.0.0-next.1...v9.0.0-next.2) (2023-09-14)


### Bug Fixes

* hide `ExperimentalWarning` ([#901](https://github.com/readmeio/rdme/issues/901)) ([f9b5679](https://github.com/readmeio/rdme/commit/f9b56798ca4e30b18db932051ddab5dce35c49b5))

# [9.0.0-next.1](https://github.com/readmeio/rdme/compare/v8.7.0-next.3...v9.0.0-next.1) (2023-09-14)


### Features

* support node 18 and up ([#900](https://github.com/readmeio/rdme/issues/900)) ([a217904](https://github.com/readmeio/rdme/commit/a2179048bd7d76d9177df0848b56c524eff50b13))


### BREAKING CHANGES

* Node.js >= 18 required

# [8.7.0-next.3](https://github.com/readmeio/rdme/compare/v8.7.0-next.2...v8.7.0-next.3) (2023-09-14)


### Features

* convert to ESM (breaking change) ([#856](https://github.com/readmeio/rdme/issues/856)) ([84b8571](https://github.com/readmeio/rdme/commit/84b8571a31c442288d47c07c57524eae643f9f13)), closes [/www.stefanjudis.com/snippets/how-to-import-json-files-in-es-modules-node-js/#option-1](https://github.com//www.stefanjudis.com/snippets/how-to-import-json-files-in-es-modules-node-js//issues/option-1) [1#L228](https://github.com/1/issues/L228)

# [8.7.0-next.2](https://github.com/readmeio/rdme/compare/v8.7.0-next.1...v8.7.0-next.2) (2023-09-13)


Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

## Running Shell Commands Locally 🐚

To run test commands from within the repository, run the build and then run your commands from the root of the repository and use `./bin/rdme` instead of `rdme` so it properly points to the command executable, like so:
To run test commands from within the repository, run the build and then run your commands from the root of the repository and use `./bin/rdme.js` instead of `rdme` so it properly points to the command executable, like so:

```sh
npm run build
./bin/rdme openapi:validate __tests__/__fixtures__/ref-oas/petstore.json
./bin/rdme.js openapi:validate __tests__/__fixtures__/ref-oas/petstore.json
```

If you need to debug commands quicker and re-building TS everytime is becoming cumbersome, you can use the debug command, like so:
Expand Down Expand Up @@ -70,7 +70,7 @@ act -j simple

### Usage of `console`

As you'll learn in our commands logic (see [`bin/rdme`](bin/rdme) 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/rdme`](bin/rdme) 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/rdme.js`](bin/rdme.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/rdme.js`](bin/rdme.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
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM node:16-alpine as builder
FROM node:18-alpine as builder

COPY . /rdme

RUN cd /rdme && npm ci && npm run build && npx pkg@5 . --target host --out-path exe
RUN cd /rdme && npm ci && npm run build:exe

FROM alpine:3.14

Expand Down
18 changes: 6 additions & 12 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,25 @@ Nearly all of our release process is automated. In this section, we discuss ever
When code is merged into the `main` or `next` branches, a release workflow (powered by [`semantic-release`](https://github.com/semantic-release/semantic-release)) automatically kicks off that does the following:

- All commit messages since the last release are analyzed to determine whether or not the new changes warrant a new release (i.e., if the changes are features or fixes as opposed to smaller housekeeping changes) 🧐
- Based on the changes, the version is bumped in [`package.json`](./package.json) with a new git tag 🏷️ For example, say the current version is `8.5.1` and the commit history includes a new feature. This would result in a minor semver bump, which would produce the following tags:
- Based on the changes, the version is bumped in [`package.json`](./package.json) and the [`action.yml`](./action.yml) with a new git tag 🏷️ For example, say the current version is `8.5.1` and the commit history includes a new feature. This would result in a minor semver bump, which would produce the following tags:
- A release tag like `v8.6.0` if on the `main` branch
- A prerelease tag like `v8.6.0-next.1` if on the `next` branch
- A changelog is generated and appended to [`CHANGELOG.md`](./CHANGELOG.md) 🪵
- A build commit (like [this](https://github.com/readmeio/rdme/commit/533a2db50b39c3b6130b3af07bebaed38218db4c)) is created with the updated `package*.json` and `CHANGELOG.md` files 🆕
- A new Docker image is built with the latest code and release metadata and pushed to [the GitHub Container Registry](https://github.com/readmeio/rdme/pkgs/container/rdme) 🐳
- A couple duplicated tags are created for the current commit so our users can refer to them differently in their GitHub Actions (e.g., `8.6.0`, `v8`) 🔖
- The new commit and tags are pushed to GitHub 📌
- The new version is published to the `npm` registry 🚀 The package [distribution tag](https://docs.npmjs.com/adding-dist-tags-to-packages) will depend on which branch is being pushed to:
- If on the `main` branch, a version is pushed on the main distribution tag (a.k.a. `latest`, which is used when someone runs `npm i rdme` with no other specifiers).
- If on the `next` branch, the prerelease distribution tag (a.k.a. [`next`](https://www.npmjs.com/package/rdme/v/next)) is updated.
- A [GitHub release is created](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository#creating-a-release) for the tag (in draft form) 🐙
- If on the `main` branch, the new changes are backported to the `next` branch so both branches remain in sync 🔄

## One more thing ☝️

> [!NOTE]
> The steps in this section are only required if you're building an actual release and not a prelease (i.e., changes are being merged into the `main` branch).
> This section is only required if you're building an actual release and not a prelease (i.e., changes are being merged into the `main` branch).
While nearly all of our release process is automated, there are a couple quick steps remaining:
While nearly all of our release process is automated, there's one more step left before we call it a day — writing up and publishing [the GitHub release](https://github.com/readmeio/rdme/releases)! The automation creates a GitHub release in a draft state, but it needs to be published so the latest version is surfaced to folks that discover our tool via [the GitHub Marketplace listing](https://github.com/marketplace/actions/rdme-sync-to-readme).

1. **Backport the changes in the `main` branch back into `next`** 🔙 you can do so by running the following:

```sh
git checkout next
git merge main
git push
```

2. **Fluff out the GitHub release and publish it** ✍️ the GitHub release is currently in draft form but it needs to be published so the latest version is surfaced to folks that discover our tool via [the GitHub Marketplace listing](https://github.com/marketplace/actions/rdme-sync-to-readme). I like to summarize the changes and note any highlights in a blurb above the auto-generated release notes. These release links are nice for sharing with customers, on socials, etc.
I like to summarize the changes and note any highlights in a blurb above the auto-generated release notes. These release links are nice for sharing with customers, on socials, etc. and because of the way that GitHub's algorithm works, they present a great opportunity for our developer tools to get more visibility — so definitely worth putting a little thought and care into these!
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ The following examples use JSON files, but `rdme` supports API Definitions that
`rdme openapi` locates your API definition (if [you don't supply one](#omitting-the-file-path)), validates it, and then syncs it to your API reference on ReadMe.

> [!NOTE]
> The `rdme openapi` command supports both OpenAPI and Swagger API definitions. The `rdme swagger` command is an alias for `rdme openapi` and is deprecated.
> The `rdme openapi` command supports both OpenAPI and Swagger API definitions.
If you wish to programmatically access any of this script's results (such as the API definition ID or the link to the corresponding docs in your dashboard), supply the `--raw` flag and the command will return a JSON output.

Expand Down Expand Up @@ -395,7 +395,7 @@ If you wish to automate the process of creating a new project version, and not h
For example, the following command contains all the flags to bypass the CLI prompts:

```sh
rdme versions:create <version> --fork={version-fork} --main={true|false} --beta={true|false} --deprecated={true|false} --isPublic={true|false}
rdme versions:create <version> --fork={version-fork} --main={true|false} --beta={true|false} --deprecated={true|false} --hidden={true|false}
```

See `rdme versions:create --help` for a full list of flags.
Expand Down
4 changes: 2 additions & 2 deletions __tests__/bin.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { exec } from 'child_process';
import { exec } from 'node:child_process';

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

Expand All @@ -7,7 +7,7 @@ describe('bin', () => {
expect.assertions(1);

await new Promise(resolve => {
exec(`node ${__dirname}/../bin/rdme`, (error, stdout) => {
exec(`node ${__dirname}/../bin/rdme.js`, (error, stdout) => {
expect(stdout).toContain('a utility for interacting with ReadMe');
resolve(true);
});
Expand Down
6 changes: 4 additions & 2 deletions __tests__/cmds/categories/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import nock from 'nock';
import prompts from 'prompts';
import { describe, beforeAll, afterEach, it, expect, vi } from 'vitest';

import CategoriesCreateCommand from '../../../src/cmds/categories/create';
import getAPIMock, { getAPIMockWithVersionHeader } from '../../helpers/get-api-mock';
import CategoriesCreateCommand from '../../../src/cmds/categories/create.js';
import getAPIMock, { getAPIMockWithVersionHeader } from '../../helpers/get-api-mock.js';

const categoriesCreate = new CategoriesCreateCommand();

Expand All @@ -20,12 +20,14 @@ describe('rdme categories:create', () => {
it('should prompt for login if no API key provided', async () => {
const consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => {});
prompts.inject(['this-is-not-an-email', 'password', 'subdomain']);
// @ts-expect-error deliberately passing in bad data
await expect(categoriesCreate.run({})).rejects.toStrictEqual(new Error('You must provide a valid email address.'));
consoleInfoSpy.mockRestore();
});

it('should error in CI if no API key provided', async () => {
process.env.TEST_RDME_CI = 'true';
// @ts-expect-error deliberately passing in bad data
await expect(categoriesCreate.run({})).rejects.toStrictEqual(
new Error('No project API key provided. Please use `--key`.'),
);
Expand Down
6 changes: 4 additions & 2 deletions __tests__/cmds/categories/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import nock from 'nock';
import prompts from 'prompts';
import { describe, beforeAll, afterEach, it, expect, vi } from 'vitest';

import CategoriesCommand from '../../../src/cmds/categories';
import getAPIMock, { getAPIMockWithVersionHeader } from '../../helpers/get-api-mock';
import CategoriesCommand from '../../../src/cmds/categories/index.js';
import getAPIMock, { getAPIMockWithVersionHeader } from '../../helpers/get-api-mock.js';

const categories = new CategoriesCommand();

Expand All @@ -20,12 +20,14 @@ describe('rdme categories', () => {
it('should prompt for login if no API key provided', async () => {
const consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => {});
prompts.inject(['this-is-not-an-email', 'password', 'subdomain']);
// @ts-expect-error deliberately passing in bad data
await expect(categories.run({})).rejects.toStrictEqual(new Error('You must provide a valid email address.'));
consoleInfoSpy.mockRestore();
});

it('should error in CI if no API key provided', async () => {
process.env.TEST_RDME_CI = 'true';
// @ts-expect-error deliberately passing in bad data
await expect(categories.run({})).rejects.toStrictEqual(
new Error('No project API key provided. Please use `--key`.'),
);
Expand Down
14 changes: 8 additions & 6 deletions __tests__/cmds/changelogs/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import fs from 'fs';
import path from 'path';
import fs from 'node:fs';
import path from 'node:path';

import chalk from 'chalk';
import frontMatter from 'gray-matter';
import nock from 'nock';
import prompts from 'prompts';
import { describe, beforeAll, afterAll, beforeEach, it, expect, vi } from 'vitest';

import ChangelogsCommand from '../../../src/cmds/changelogs';
import APIError from '../../../src/lib/apiError';
import getAPIMock from '../../helpers/get-api-mock';
import hashFileContents from '../../helpers/hash-file-contents';
import ChangelogsCommand from '../../../src/cmds/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';

const changelogs = new ChangelogsCommand();

Expand All @@ -28,12 +28,14 @@ describe('rdme changelogs', () => {
it('should prompt for login if no API key provided', async () => {
const consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => {});
prompts.inject(['this-is-not-an-email', 'password', 'subdomain']);
// @ts-expect-error deliberately passing in bad data
await expect(changelogs.run({})).rejects.toStrictEqual(new Error('You must provide a valid email address.'));
consoleInfoSpy.mockRestore();
});

it('should error in CI if no API key provided', async () => {
process.env.TEST_RDME_CI = 'true';
// @ts-expect-error deliberately passing in bad data
await expect(changelogs.run({})).rejects.toStrictEqual(
new Error('No project API key provided. Please use `--key`.'),
);
Expand Down
Loading

0 comments on commit ca069d7

Please sign in to comment.