-
Notifications
You must be signed in to change notification settings - Fork 0
Wave/3 full interactive mode #4
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,7 +16,17 @@ import { | |||||||||||||
| values, | ||||||||||||||
| } from './index.js'; | ||||||||||||||
| import { cleanInstallations, showInstallations } from './installations.js'; | ||||||||||||||
| import { startInteractive } from './interactive.js'; | ||||||||||||||
| import { | ||||||||||||||
| handleAdd, | ||||||||||||||
| handleInstallations, | ||||||||||||||
| handlePublish, | ||||||||||||||
| handleRemove, | ||||||||||||||
| handleRestore, | ||||||||||||||
| handleRetreat, | ||||||||||||||
| handleUpdate, | ||||||||||||||
| handleUpdateAll, | ||||||||||||||
| startInteractive, | ||||||||||||||
| } from './interactive.js'; | ||||||||||||||
| import { publishPackageWatch } from './publish.js'; | ||||||||||||||
| import type { PublishPackageOptions } from './publish.js'; | ||||||||||||||
| import { readRcConfig } from './rc.js'; | ||||||||||||||
|
|
@@ -89,12 +99,25 @@ const commands = [ | |||||||||||||
| 'help', | ||||||||||||||
| ]; | ||||||||||||||
|
|
||||||||||||||
| const isTTY = process.stdin.isTTY && process.stdout.isTTY; | ||||||||||||||
|
|
||||||||||||||
| const shouldRunInteractive = (argv: any, positionalArgsCount = 0) => { | ||||||||||||||
| if (argv.interactive !== undefined) return !!argv.interactive; | ||||||||||||||
| return isTTY && argv._.length <= positionalArgsCount; | ||||||||||||||
| }; | ||||||||||||||
|
|
||||||||||||||
| if (process.argv.length <= 2) { | ||||||||||||||
| await startInteractive(); | ||||||||||||||
| } else { | ||||||||||||||
| /* tslint:disable-next-line */ | ||||||||||||||
| const argv = await yargs(process.argv.slice(2)) | ||||||||||||||
| .usage(`${cliCommand} [command] [options] [package1 [package2...]]`) | ||||||||||||||
| .version(getVersionMessage()) | ||||||||||||||
| .alias('v', 'version') | ||||||||||||||
| .option('interactive', { | ||||||||||||||
| type: 'boolean', | ||||||||||||||
| describe: 'Run in interactive mode', | ||||||||||||||
| }) | ||||||||||||||
| .coerce('store-folder', (folder: string) => { | ||||||||||||||
| if (!devlinkGlobal.devlinkStoreMainDir) { | ||||||||||||||
| devlinkGlobal.devlinkStoreMainDir = resolve(folder); | ||||||||||||||
|
|
@@ -119,12 +142,17 @@ if (process.argv.length <= 2) { | |||||||||||||
| .boolean(['push', 'watch'].concat(publishFlags)); | ||||||||||||||
| }, | ||||||||||||||
| handler: async (argv) => { | ||||||||||||||
| const options = getPublishOptions(argv); | ||||||||||||||
| if (argv.watch) { | ||||||||||||||
| await publishPackageWatch(options); | ||||||||||||||
| } else { | ||||||||||||||
| await publishPackage(options); | ||||||||||||||
| await publishPackageWatch(getPublishOptions(argv)); | ||||||||||||||
| return; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| if (shouldRunInteractive(argv, 1)) { | ||||||||||||||
| await handlePublish(); | ||||||||||||||
| return; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| await publishPackage(getPublishOptions(argv)); | ||||||||||||||
| }, | ||||||||||||||
| }) | ||||||||||||||
| .command({ | ||||||||||||||
|
|
@@ -150,6 +178,10 @@ if (process.argv.length <= 2) { | |||||||||||||
| builder: (y) => y.boolean(['dry']), | ||||||||||||||
| handler: async (argv) => { | ||||||||||||||
| const action = argv._[1]; | ||||||||||||||
| if (shouldRunInteractive(argv, 1)) { | ||||||||||||||
| await handleInstallations(); | ||||||||||||||
| return; | ||||||||||||||
| } | ||||||||||||||
| const packages = argv._.slice(2) as string[]; | ||||||||||||||
| switch (action) { | ||||||||||||||
| case 'show': | ||||||||||||||
|
|
@@ -179,7 +211,31 @@ if (process.argv.length <= 2) { | |||||||||||||
| .help(true); | ||||||||||||||
| }, | ||||||||||||||
| handler: async (argv) => { | ||||||||||||||
| await addPackages(argv._.slice(1) as string[], { | ||||||||||||||
| const packages = argv._.slice(1) as string[]; | ||||||||||||||
| const hasFlags = | ||||||||||||||
| argv.dev || | ||||||||||||||
| argv.link || | ||||||||||||||
| argv.restore || | ||||||||||||||
| argv.pure || | ||||||||||||||
| argv.workspace || | ||||||||||||||
| argv.update || | ||||||||||||||
| argv.upgrade; | ||||||||||||||
|
|
||||||||||||||
| if (shouldRunInteractive(argv, 1) && !hasFlags) { | ||||||||||||||
| await handleAdd(); | ||||||||||||||
| return; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| if ( | ||||||||||||||
| packages.length === 1 && | ||||||||||||||
| !hasFlags && | ||||||||||||||
| shouldRunInteractive(argv, 2) | ||||||||||||||
| ) { | ||||||||||||||
| await handleAdd(packages[0]); | ||||||||||||||
| return; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| await addPackages(packages, { | ||||||||||||||
| dev: !!argv.dev, | ||||||||||||||
| linkDep: !!argv.link, | ||||||||||||||
| restore: !!argv.restore, | ||||||||||||||
|
|
@@ -200,7 +256,12 @@ if (process.argv.length <= 2) { | |||||||||||||
| .help(true); | ||||||||||||||
| }, | ||||||||||||||
| handler: async (argv) => { | ||||||||||||||
| await updatePackages(argv._.slice(1) as string[], { | ||||||||||||||
| const packages = argv._.slice(1) as string[]; | ||||||||||||||
| if (packages.length === 0 && shouldRunInteractive(argv, 1)) { | ||||||||||||||
| await handleUpdate(); | ||||||||||||||
|
||||||||||||||
| await handleUpdate(); | |
| if (process.stdout.isTTY && process.stdin.isTTY) { | |
| await handleUpdate(); | |
| } else { | |
| await updateAllPackages(process.cwd()); | |
| } |
Copilot
AI
Apr 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using process.argv.length to decide between interactive vs non-interactive makes behavior depend on unrelated global flags (e.g. devlink update-all --quiet will skip the interactive flow). Prefer deciding based on the parsed argv for this command (e.g. argv._.length) or an explicit --interactive/--no-interactive option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
devlink publishis run with flags but no positional args (e.g.devlink publish --watch), this branch always invokes the interactive handler and ignores the provided flags. Consider only falling back tohandlePublish()when there are no extra CLI tokens after the command (or when an explicit--interactiveflag is set), and otherwise keep the existing non-interactive behavior.