Skip to content
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

Auto-compile linked plugins #650

Merged
merged 4 commits into from
Mar 8, 2023
Merged

Conversation

mdonnalley
Copy link
Contributor

@mdonnalley mdonnalley commented Mar 7, 2023

Register ts-node for linked plugins so that developers don't have to compile their plugin before running it

More context: forcedotcom/cli#1664
@W-12652231@

Testing

  • yarn link @oclif/core in sfdx-cli
  • cd to oclif/plugin-plugins
    • run sfdx plugins link
    • run rm -rf lib/
  • cd to sfdx-cli
    • bin/dev plugins
    • bin/run plugins
    • bin/dev version
    • bin/run version
  • cd to oclif/plugin-plugins
    • run yarn build
  • cd to sfdx-cli
    • bin/dev plugins
    • bin/run plugins
    • bin/dev version
    • bin/run version

@cristiand391
Copy link
Member

cristiand391 commented Mar 8, 2023

QA notes:

✅ plugin compiled by ts-node (rmrf lib, updated command, see update after running it)
✅ oclif/ts-node ignores lib folder in plugin (re-compiles at runtime even if I already ran tsc before.)
✅ JS plugin (no tsconfig file), running command just throws not found.

ts-node:
I added some code to print paths in oclif/core to see what ts-node was loading it, see results:

  1. ts-node as plugin devDep
    plugin-commands has ts-node as a [devDep](https://github.com/oclif/plugin-commands/blob/main/package.json#L29.
    when loading ts-node, oclif uses the ts-node in the plugin's node_modules folder:
➜  sfdx-cli git:(main) ✗ ./bin/run commands
ROOT: /Users/cdominguez/code/gh/oclif/plugin-commands
__dirname: /Users/cdominguez/code/gh/oclif/core/lib/config
tsNodePath: /Users/cdominguez/code/gh/oclif/plugin-commands/node_modules/ts-node/dist/index.js
 Command                                    Summary
...
  1. plugin doesn't have ts-node dep
    For this I used plugin-plugins, removed ts-node from devDeps and then linked it.
    oclif loads ts-node from @oclif/core:
➜  sfdx-cli git:(main) ✗ ./bin/run plugins
ROOT: /Users/cdominguez/code/gh/oclif/plugin-plugins
__dirname: /Users/cdominguez/code/gh/oclif/core/lib/config
tsNodePath: /Users/cdominguez/code/gh/oclif/core/node_modules/ts-node/dist/index.js
@oclif/plugin-plugins 2.3.2 (link) /Users/cdominguez/code/gh/oclif/plugin-plugins

✅ Works on Windows, in the debug logs I can see ts-node gets a valid win path to the linked plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants