Repository navigation
chore(cli): install rn-toolkit plugin on project creation #156
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
fernandatoledo
wants to merge
5
commits into
master
Choose a base branch
from
chore/cli-install-rn-toolkit-plugin
base: master
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.
+74
−105
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fde2d5f
chore(cli): install rn-toolkit plugin on project creation
fernandatoledo c2d1d6a
fix(cli): use exec cwd and portable claude availability check
fernandatoledo f091baf
fix(cli): run claude via execFile to avoid a shell interpreter
fernandatoledo 7b3c787
Merge remote-tracking branch 'origin/master' into chore/cli-install-r…
fernandatoledo faca993
fix(cli): publish install-claude-plugin.js in package files
fernandatoledo 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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,65 @@ | ||
| const { execFile } = require('node:child_process'); | ||
| const { consola } = require('consola'); | ||
|
|
||
| const MARKETPLACE_REPOSITORY = 'rootstrap/rn-claude-toolkit'; | ||
| const MARKETPLACE_NAME = 'rootstrap'; | ||
| const PLUGIN_NAME = 'rn-toolkit'; | ||
|
|
||
| const MANUAL_INSTALL_HINT = | ||
| `claude plugin marketplace add ${MARKETPLACE_REPOSITORY} --scope project && ` + | ||
| `claude plugin install ${PLUGIN_NAME}@${MARKETPLACE_NAME} --scope project`; | ||
|
|
||
| // Quiet variant of execShellCommand: no shell interpreter, and failures here are expected and handled | ||
| const runClaude = (args, options) => | ||
| new Promise((resolve, reject) => { | ||
| execFile('claude', args, options, (error, stdout, stderr) => { | ||
| if (error) { | ||
| reject(error); | ||
| return; | ||
| } | ||
| resolve(stdout || stderr); | ||
| }); | ||
| }); | ||
|
|
||
| const isClaudeCodeAvailable = async () => { | ||
| try { | ||
| await runClaude(['--version']); | ||
| return true; | ||
| } catch { | ||
| return false; | ||
| } | ||
| }; | ||
|
|
||
| const installClaudeToolkit = async (projectName) => { | ||
| if (!(await isClaudeCodeAvailable())) { | ||
| consola.info( | ||
| `Claude Code CLI not found, skipping ${PLUGIN_NAME} plugin installation.\n` + | ||
| ` Install it later from the project root with: ${MANUAL_INSTALL_HINT}` | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| consola.start(`Installing the ${PLUGIN_NAME} Claude Code plugin 🤖`); | ||
| try { | ||
| const options = { cwd: projectName }; | ||
| await runClaude( | ||
| ['plugin', 'marketplace', 'add', MARKETPLACE_REPOSITORY, '--scope', 'project'], | ||
| options | ||
| ); | ||
| await runClaude( | ||
| ['plugin', 'install', `${PLUGIN_NAME}@${MARKETPLACE_NAME}`, '--scope', 'project'], | ||
| options | ||
| ); | ||
| consola.success(`${PLUGIN_NAME} plugin installed`); | ||
| } catch { | ||
| consola.warn( | ||
| `Could not install the ${PLUGIN_NAME} plugin. The marketplace repository is private, ` + | ||
| `so you need git access to ${MARKETPLACE_REPOSITORY} as a member of the Rootstrap org.\n` + | ||
| ` Retry from the project root with: ${MANUAL_INSTALL_HINT}` | ||
| ); | ||
| } | ||
| }; | ||
|
|
||
| module.exports = { | ||
| installClaudeToolkit, | ||
| }; |
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
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.