Skip to content

feat: support rc files - #1067

Merged
mdonnalley merged 2 commits into
prerelease/betafrom
mdonnalley/rc-files
May 6, 2024
Merged

mdonnalley merged 2 commits into
prerelease/betafrom
mdonnalley/rc-files

Conversation

@mdonnalley

@mdonnalley mdonnalley commented Apr 26, 2024 •

Copy link
Copy Markdown
Contributor

Use cosmiconfig to support rc files, which will allow consumers to use an rc file to configure oclif instead of using the package.json.

Important to note that oclif will still be dependent on the package.json to get the name, version, and dependencies

The following files are supported:

.oclifrc
.oclifrc.json
.oclifrc.yaml
.oclifrc.yml
.oclifrc.js
.oclifrc.ts
.oclifrc.mjs
.oclifrc.cjs
oclif.config.js
oclif.config.ts
oclif.config.mjs
oclif.config.cjs

@W-15470586@

Comment thread src/util/read-pjson.ts
'oclif.config.js',
'oclif.config.ts',
'oclif.config.mjs',
'oclif.config.cjs',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a good use-case to support so many filetypes here? I feel like just supporting .oclifrc.json would be plenty. Then we could get rid off the cosmicconfig package.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

js and ts files offer several benefits:

  • comments
  • dynamically set props
  • use types

Comment thread src/util/read-pjson.ts Outdated
debug(`found oclif config for ${path}: %O`, result)
return {
...pjson,
oclif: result?.config ?? pjson.oclif ?? {},

@iowillhoit iowillhoit May 6, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like we will ever return pjson.oclif here since it is returned above if it is found:

https://github.com/oclif/core/pull/1067/files#diff-95320f174fd506effb1c83bdcba5ef9c13283100095e90620a3a4ecb68e62165R24-R28

Comment thread src/util/read-pjson.ts Outdated
const debug = makeDebug('read-pjson')

/**
* Read the package.json file from a given path and merge with the config found by cosmiconfig.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is slightly misleading. It makes it sound like we are merging pjson.oclif config with with additional config discovered by cosmicconfig.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think "merge" as in, "put an oclif prop in the package.json"... I'll clarify it

@iowillhoit

Copy link
Copy Markdown
Contributor

In my initial attempt to use a stand-alone config file, i copied the entire "oclif: {}" object out of my package.json and it would not work. I then looked at the code and saw that i needed to remove the "oclif" key and just use the values. We should make sure an example is documented.

@iowillhoit

Copy link
Copy Markdown
Contributor

QA NOTES

QA looks good

  • 🟢 package.json config is used if it exists
  • 🟢 Works with .oclifrc
  • 🟢 Works with .oclifrc.json
  • 🟢 .oclifrc.mjs
    • export default {
  • 🟢 oclif.config.mjs
    • export default {
  • 🟢 .oclifrc.ts
    • export default {
  • 🟢 oclif.config.ts
    • export default {
  • 🟢 .oclifrc.cjs
    • module.exports = {
  • 🟢 oclif.config.cjs
    • module.exports = {
  • 🟢 oclif.config.js
    • export default {
    • module.exports = {
  • 🟢 .oclifrc.js
    • export default {
    • module.exports = {
  • 🟢 .oclifrc.yaml
  • 🟢 .oclifrc.yml
    • For yaml:
bin: oclif-cli-rc
dirname: oclif-cli-rc
commands: ./dist/commands
plugins:
  - "@oclif/plugin-help"
  - "@oclif/plugin-plugins"
topicSeparator: " "
topics:
  hello:
    description: "Say hello to the world and others"

@mdonnalley
mdonnalley merged commit 6af9c71 into prerelease/beta May 6, 2024
@mdonnalley
mdonnalley deleted the mdonnalley/rc-files branch May 6, 2024 20:09
mdonnalley added a commit that referenced this pull request Jun 4, 2024
* chore: bump major version

* feat: slimmer ux (#1056)

* chore: bump major version

* feat: slimmer ux module

* test: no fancy-tests

* chore(release): 4.0.0-v4.0 [skip ci]

* chore: code review

* chore(release): 4.0.0-v4.1 [skip ci]

* chore(release): 4.0.0-beta.1 [skip ci]

* chore: remove duplicate dep

* test: windows unit tests

* test: windows unit tests

---------

Co-authored-by: svc-cli-bot <Svc_cli_bot@salesforce.com>

* chore(release): 4.0.0-beta.2 [skip ci]

* feat: add customizable logger

* feat: remove native error logger

* fix: cache child loggers

* chore(release): 4.0.0-beta.3 [skip ci]

* chore(release): 4.0.0-beta.4 [skip ci]

* feat: support rc files (#1067)

* feat: support rc files

* chore: code review

* chore(release): 4.0.0-beta.5 [skip ci]

* chore(release): 4.0.0-beta.6 [skip ci]

* fix: revert ignoreDuplicates in warn

* chore(release): 4.0.0-beta.7 [skip ci]

* feat: improved types and top-level exports (#1076)

* feat: improved PJSON type

* feat: enable exactOptionalPropertyTypes

* feat: theme can be object or file path

* feat: support target and identifier for helpClass

* chore: add jsdocs to Configuration type

* fix: add back scope to pjson type

* feat: top level exports

* fix: simplify ux export

* chore: cleanup

* feat: export logger too

* chore(release): 4.0.0-beta.8 [skip ci]

* feat: remove baseFlags

* test: use oclif/test v4 and improve test coverage

* fix: clarify types

* test: use default sinon sandbox

* test: use new major of oclif/test

* test: add interop test for core v3

* test: skip spinner test on windows

* chore: code review

* chore(release): 4.0.0-beta.9 [skip ci]

* fix: restore baseFlags support (#1085)

* chore(release): 4.0.0-beta.10 [skip ci]

* fix: improve types and ProdOnlyCache

* chore(release): 4.0.0-beta.11 [skip ci]

* fix: update hook type

* chore(release): 4.0.0-beta.12 [skip ci]

* fix: allow empty ux.stdout

* chore(release): 4.0.0-beta.13 [skip ci]

* chore: add ux README

* fix: check supports-color in colorize

* chore(release): 4.0.0-beta.14 [skip ci]

* feat: support tsx for runtime transpilation

* chore(release): 4.0.0-beta.15 [skip ci]

* chore(release): 4.0.0-beta.16 [skip ci]

---------

Co-authored-by: svc-cli-bot <Svc_cli_bot@salesforce.com>
Co-authored-by: Steve Hetzel <shetzel@salesforce.com>
Co-authored-by: Willie Ruemmele <willieruemmele@gmail.com>
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