-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Implement devcenter open and preview commands in oclif v4 #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
michaelmalave
wants to merge
11
commits into
feat/ruby-to-typescript
Choose a base branch
from
feat/ruby-to-typescript-1
base: feat/ruby-to-typescript
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
01c246f
Introduce Node 22 TypeScript Heroku plugin with shared libs and devce…
michaelmalave 917153f
updating test coverage in this PR
michaelmalave b75416e
updating to use netrc-parser for heroku api tokens matching expected …
michaelmalave d68b7af
Fix heroku-api-auth tests on Windows matching netrc-parser
michaelmalave c7828ec
Add test/helpers/netrc-path.ts for _netrc/.netrc in windows tests
michaelmalave 1cd94c5
Add --debug on devcenter:preview so HTTP/file-watch chatter goes thro…
michaelmalave 2628be5
Update package.json
michaelmalave 991fcbd
adopt heroku-cli-test-utils, replace --debug flags with debug package…
michaelmalave b145c57
Replace legacy Ruby gem README with standard oclif plugin format and …
michaelmalave 95e15d1
Replace Ruby bin script with oclif bin files and remove custom PLUGIN…
michaelmalave eb4ee69
Move preview test to commands/devcenter/, remove oclif.manifest.json …
michaelmalave File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| name: CI Test Suite | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| node_version: ['22.x', '24.x'] | ||
| os: [ubuntu-latest, macos-latest, windows-latest] | ||
| fail-fast: false | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Use Node.js ${{ matrix.node_version }} | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node_version }} | ||
| cache: npm | ||
| - name: Install dependencies | ||
| run: npm ci | ||
| - name: Unit tests and lint | ||
| run: npm test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "require": [ | ||
| "./test/init.mjs", | ||
| "tsx" | ||
| ], | ||
| "watch-extensions": ["ts"], | ||
| "recursive": true, | ||
| "reporter": "spec", | ||
| "timeout": 15000, | ||
| "node-option": ["import=tsx/esm"] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,57 +1,101 @@ | ||
| # Dev Center CLI | ||
| # @heroku-cli/heroku-cli-plugin-devcenter | ||
|
|
||
| CLI to interact with Heroku's Dev Center | ||
| Heroku CLI plugin to interact with Heroku Dev Center | ||
|
|
||
| [](https://npmjs.org/package/@heroku-cli/heroku-cli-plugin-devcenter) | ||
| [](https://github.com/heroku/devcenter-cli/blob/main/LICENSE.txt) | ||
|
|
||
| ## Installation | ||
|
|
||
| $ gem install devcenter | ||
| ```bash | ||
| heroku plugins:install @heroku-cli/heroku-cli-plugin-devcenter | ||
| ``` | ||
|
|
||
| <!-- usage --> | ||
|
michaelmalave marked this conversation as resolved.
|
||
| ```sh-session | ||
| $ npm install -g @heroku-cli/heroku-cli-plugin-devcenter | ||
| $ heroku COMMAND | ||
| running command... | ||
| $ heroku (--version) | ||
| @heroku-cli/heroku-cli-plugin-devcenter/1.3.1 darwin-arm64 node-v24.14.0 | ||
| $ heroku --help [COMMAND] | ||
| USAGE | ||
| $ heroku COMMAND | ||
| ... | ||
| ``` | ||
| <!-- usagestop --> | ||
|
|
||
| ## Commands | ||
|
|
||
| ## Usage | ||
| <!-- commands --> | ||
| * [`heroku devcenter:open SLUG`](#heroku-devcenteropen-slug) | ||
| * [`heroku devcenter:preview SLUG`](#heroku-devcenterpreview-slug) | ||
|
|
||
| ### Open a published article | ||
| ## `heroku devcenter:open SLUG` | ||
|
|
||
| $ devcenter open error-pages | ||
| open a published Dev Center article in your browser | ||
|
|
||
| ### Save a local copy of an article | ||
| ``` | ||
| USAGE | ||
| $ heroku devcenter:open SLUG [--prompt] | ||
|
|
||
| You can pull an article from its slug | ||
| ARGUMENTS | ||
| SLUG article slug (e.g. ps for https://devcenter.heroku.com/articles/ps) | ||
|
|
||
| $ devcenter pull article-slug | ||
| GLOBAL FLAGS | ||
| --prompt interactively prompt for command arguments and flags | ||
|
|
||
| or from its URL: | ||
| DESCRIPTION | ||
| open a published Dev Center article in your browser | ||
| ``` | ||
|
|
||
| $ devcenter pull https://devcenter.heroku.com/articles/article-slug | ||
| _See code: [src/commands/devcenter/open.ts](https://github.com/heroku/devcenter-cli/blob/v1.3.1/src/commands/devcenter/open.ts)_ | ||
|
|
||
| This will save an `article-slug.md` text file in your local directory. The file includes some metadata (article title and id) followed by the article content in markdown format. You can edit both the title and the content, but **never overwrite the article id**. | ||
| ## `heroku devcenter:preview SLUG` | ||
|
|
||
| ### Preview a local copy of an article | ||
| preview a local Dev Center article in the browser with live reload | ||
|
|
||
| $ devcenter preview dynos | ||
| ``` | ||
| USAGE | ||
| $ heroku devcenter:preview SLUG [--prompt] [--host <value>] [--port <value>] | ||
|
|
||
| This will open a preview in your default browser and get it refreshed when you save the file. You can specify `--port` and `--host` options to customize the preview web server. | ||
| ARGUMENTS | ||
| SLUG article slug (local <slug>.md file) | ||
|
|
||
| ### Update an article in Dev Center from a local file | ||
| FLAGS | ||
| --host=<value> [default: 127.0.0.1] bind host for the preview server | ||
| --port=<value> [default: 3000] port for the preview server | ||
|
|
||
| $ devcenter push dynos | ||
| GLOBAL FLAGS | ||
| --prompt interactively prompt for command arguments and flags | ||
|
|
||
| This will save the title and content from your local article in Dev Center, using your Heroku credentials from `~/.netrc`, which you can set by doing `heroku auth:login`. | ||
| DESCRIPTION | ||
| preview a local Dev Center article in the browser with live reload | ||
| ``` | ||
|
|
||
| ### Help | ||
| _See code: [src/commands/devcenter/preview.ts](https://github.com/heroku/devcenter-cli/blob/v1.3.1/src/commands/devcenter/preview.ts)_ | ||
| <!-- commandsstop --> | ||
|
|
||
| Get available commands | ||
| ## Development | ||
|
|
||
| $ devcenter help | ||
| TypeScript code lives under `src/` with tests under `test/`. With Node 22+, run `npm install` and `npm test`. | ||
|
|
||
| Get help about a specific command | ||
| If you have a Dev Center instance, you can point your CLI to it by setting the `DEVCENTER_BASE_URL` environment variable: | ||
|
|
||
| $ devcenter help pull | ||
| ```bash | ||
| export DEVCENTER_BASE_URL=http://localhost:3000 | ||
| ``` | ||
|
|
||
| ### Development | ||
| Verbose logging uses the [`debug`](https://www.npmjs.com/package/debug) package: | ||
|
|
||
| If you have a Dev Center instance, you can point your CLI to it by setting the `DEVCENTER_BASE_URL` env. var (e.g: `export DEVCENTER_BASE_URL=http://localhost:3000`). | ||
| ```bash | ||
| DEBUG=devcenter:open heroku devcenter:open my-article | ||
| DEBUG=devcenter:preview heroku devcenter:preview my-article | ||
| DEBUG=devcenter:* heroku devcenter:open my-article | ||
| ``` | ||
|
|
||
| ## License | ||
|
|
||
| See LICENSE.txt file. | ||
| See [LICENSE.txt](LICENSE.txt) file. | ||
|
|
||
| The `preview` command uses the [Font Awesome](http://fontawesome.io/) vector icons, which have their own [License](https://github.com/FortAwesome/Font-Awesome#license). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/usr/bin/env -S node --loader ts-node/esm --disable-warning=ExperimentalWarning | ||
|
|
||
| import {execute} from '@oclif/core' | ||
|
|
||
| await execute({development: true, dir: import.meta.url}) |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| @echo off | ||
| node "%~dp0\run.js" %* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| import {execute} from '@oclif/core' | ||
|
|
||
| await execute({dir: import.meta.url}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import herokuEslintConfig from '@heroku-cli/test-utils/eslint-config' | ||
|
|
||
| export default [...herokuEslintConfig] | ||
|
michaelmalave marked this conversation as resolved.
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.