Skip to content

Commit

Permalink
feat: add global options deprecation warnings
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

As part of ac31f01 global options which are only relevant to some commands have been moved to those specific commands.

This left some users confused, because this was done without warning or major version change. This change seeks to remedy this, by adding deprecation warnings as well as triggering a major version bump.
  • Loading branch information
ComradeVanti committed Oct 14, 2024
1 parent 17506a2 commit ba866bb
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ const verboseOpt = new Option(

const colorOpt = new Option("--no-color", "disable color").default(true);

const registryDeprecatedOpt = new Option("-r, --registry <url>")
.argParser(() => true)
.default(false)
.hideHelp(true);

const chdirDeprecatedOpt = new Option("-c, --chdir <path>")
.argParser(() => true)
.default(false)
.hideHelp(true);

/**
* Makes the openupm cli app with the given dependencies.
* @param fetchPackument IO function for fetching registry packuments.
Expand All @@ -52,7 +62,9 @@ export function makeOpenupmCli(
const program = createCommand()
.version(module.exports.version)
.addOption(verboseOpt)
.addOption(colorOpt);
.addOption(colorOpt)
.addOption(chdirDeprecatedOpt)
.addOption(registryDeprecatedOpt);

program.on("option:verbose", function () {
const verbose = program.opts().verbose;
Expand All @@ -68,6 +80,24 @@ export function makeOpenupmCli(
}
});

program.on(`option:${chdirDeprecatedOpt.name()}`, function () {
log.warn(
"",
`--chdir/-c is no longer supported as a global option!
Instead, you should add it to the specific command you are running.
Example: openupm add --chdir /some/path com.my.package`
);
});

program.on(`option:${registryDeprecatedOpt.name()}`, function () {
log.warn(
"",
`--registry/-r is no longer supported as a global option!
Instead, you should add it to the specific command you are running.
Example: openupm add -r https://packages.my-registry.com com.my.package`
);
});

program.addCommand(
makeAddCmd(
fetchCheckUrlExists,
Expand Down

0 comments on commit ba866bb

Please sign in to comment.