Skip to content

feat: integrate flow-cli into Aliyun CLI#1380

Merged
AllyW merged 5 commits into
masterfrom
feature/aone-84323751-flow-cli
Jul 17, 2026
Merged

feat: integrate flow-cli into Aliyun CLI#1380
AllyW merged 5 commits into
masterfrom
feature/aone-84323751-flow-cli

Conversation

@yndu13

@yndu13 yndu13 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add aliyun flow-cli root command that installs and proxies @flow-step/flow-cli (same pattern as esa-cli)
  • Auto-install via npm into ~/.aliyun/flow-cli-prefix with npmmirror as default registry; forward profile credentials/region
  • Propagate subprocess ExitError via cli.Exit so child exit codes and output are not overwritten by the CLI framework

Mirror esa-cli: npm-install @flow-step/flow-cli into a local prefix,
forward credentials/region, and proxy subcommands. Default registry is
npmmirror per Flow-CLI docs. Compatible additive root command.
关联 Aone: 84323751
@codecov-commenter

codecov-commenter commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.72%. Comparing base (25cd671) to head (daff858).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1380   +/-   ##
=======================================
  Coverage   84.72%   84.72%           
=======================================
  Files          68       68           
  Lines        8869     8870    +1     
=======================================
+ Hits         7514     7515    +1     
  Misses        915      915           
  Partials      440      440           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Avoid wrapping exec.ExitError so aliyun flow-cli keeps the child exit
code and does not print an extra ERROR line over the tool's own output.
@CodeSpaceiiii

Copy link
Copy Markdown
Contributor

@AllyW review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR integrates a new aliyun flow-cli extension command into Aliyun CLI, following the existing “CLI proxy + auto-install” pattern (similar to esa-cli). It installs/proxies @flow-step/flow-cli, forwards Aliyun profile-derived credentials/region to the subprocess, and attempts to preserve the child process’s exit code behavior.

Changes:

  • Register a new flow-cli root subcommand in the main CLI entrypoint.
  • Add a new cliext/flowcli extension that manages Node/npm detection, prefix installation, env propagation, and subprocess execution/exit-code handling.
  • Add unit tests covering command metadata, flag stripping, env preparation, version-check TTL, and exit-code propagation behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
main/main.go Wires flow-cli into the root command’s subcommand list.
cliext/flowcli/main.go Defines the aliyun flow-cli command wrapper (help behavior + exit code propagation path).
cliext/flowcli/flowcli.go Implements install/proxy logic: runtime detection, npm prefix install/update, flag folding/stripping, env forwarding, and subprocess execution.
cliext/flowcli/main_test.go Tests command metadata and the “suppress framework error output when child exits non-zero” path.
cliext/flowcli/flowcli_test.go Tests core helper behavior (paths, node/npm detection, flag stripping, env injection, TTL cache, and exit error type).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cliext/flowcli/flowcli.go Outdated
Comment on lines +83 to +85
if err := c.EnsureNpmAvailable(); err != nil {
return err
}
Comment thread cliext/flowcli/flowcli.go
Comment on lines +181 to +184
func (c *Context) EnsurePrefixAndPackage() error {
if os.Getenv("ALIBABA_CLOUD_FLOW_CLI_EXEC_PATH") != "" {
return nil
}
Comment thread cliext/flowcli/flowcli.go
Comment on lines +297 to +313
a := args[i]
if !strings.HasPrefix(a, "--") {
continue
}
var name, value string
var hasValue bool
if idx := strings.Index(a, "="); idx > 0 {
name = a[2:idx]
value = a[idx+1:]
hasValue = true
} else {
name = a[2:]
}
f := flags.Get(name)
if f == nil || f.Category != "config" {
continue
}
Address review feedback:
- Skip the npm requirement when ALIBABA_CLOUD_FLOW_CLI_EXEC_PATH points at
  an existing binary, so the local-binary escape hatch works without npm.
- Validate the EXEC_PATH override up front and fail with a clear message
  instead of a cryptic exec error later.
- Fold config shorthands (e.g. -p profile, -e endpoint) into the parsed
  flags so credential/region overrides are honored under KeepArgs.
@AllyW
AllyW merged commit 008d664 into master Jul 17, 2026
6 checks passed
@AllyW
AllyW deleted the feature/aone-84323751-flow-cli branch July 17, 2026 06:22
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.

5 participants