-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: support URL rewriting and manifest-based updates #2581
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
Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ef62370
feat: add URL rewrite extension contract
Tantanz20020918 1b3806f
feat: apply URL rewriting in transport
Tantanz20020918 1d6b582
feat: rewrite fixed external command URLs
Tantanz20020918 fcdc0b7
feat: rewrite generated CLI URLs
Tantanz20020918 ee8793e
fix: synchronize rewritten request host
Tantanz20020918 0fe36b4
feat: add manifest-based distribution updates
Tantanz20020918 8633440
test: use generic pnpm permission path
Tantanz20020918 95318be
test: construct URL userinfo at runtime
Tantanz20020918 e1a8d9f
refactor: simplify URL rewrite handling
Tantanz20020918 e50ca75
refactor: consolidate manifest distribution flow
Tantanz20020918 34d7456
fix: tighten distribution extension boundaries
Tantanz20020918 679a463
refactor: streamline distribution update tests
Tantanz20020918 7d2ba6e
fix: harden distribution update recovery
Tantanz20020918 bcce865
test: use approved URL rewrite fixture
Tantanz20020918 5bf546f
fix: allow manifest extension fields
Tantanz20020918 547f70b
test: cover distribution update paths
Tantanz20020918 5facf15
fix: improve distribution update resilience
Tantanz20020918 b9cc86d
fix: preserve rollback error causes
Tantanz20020918 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| // Copyright (c) 2026 Lark Technologies Pte. Ltd. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| package cmdupdate | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
|
|
||
| "github.com/larksuite/cli/errs" | ||
| "github.com/larksuite/cli/internal/distribution" | ||
| "github.com/larksuite/cli/internal/output" | ||
| ) | ||
|
|
||
| func runManifestUpdate(ctx context.Context, opts *UpdateOptions, manifestURL string) error { | ||
| streams := opts.Factory.IOStreams | ||
| current := currentVersion() | ||
| manifest, err := distribution.FetchManifest(ctx, manifestURL) | ||
| if err != nil { | ||
| return reportDistributionError(opts, err) | ||
| } | ||
| target := manifest.Version | ||
| if opts.Check { | ||
| return reportManifestStatus(opts, current, target, true) | ||
| } | ||
| if !opts.Force && target == current { | ||
| return reportManifestStatus(opts, current, target, false) | ||
| } | ||
| if !opts.JSON { | ||
| fmt.Fprintf(streams.ErrOut, "Updating lark-cli %s %s %s from the configured distribution ...\n", current, symArrow(), target) | ||
| } | ||
| if err := distribution.Install(ctx, manifest, distribution.InstallOptions{}); err != nil { | ||
| return reportDistributionError(opts, err) | ||
| } | ||
| if opts.JSON { | ||
| output.PrintJson(streams.Out, map[string]interface{}{ | ||
| "ok": true, "source": "manifest", | ||
| "previous_version": current, "current_version": target, "target_version": target, | ||
| "action": "updated", "skills_action": "synced", | ||
| "message": fmt.Sprintf("lark-cli updated from %s to %s", current, target), | ||
| }) | ||
| return nil | ||
| } | ||
| fmt.Fprintf(streams.ErrOut, "\n%s Successfully updated lark-cli and Skills from %s to %s\n", symOK(), current, target) | ||
| return nil | ||
| } | ||
|
|
||
| func reportManifestStatus(opts *UpdateOptions, current, target string, check bool) error { | ||
| streams := opts.Factory.IOStreams | ||
| action := "already_up_to_date" | ||
| message := fmt.Sprintf("lark-cli %s matches the configured target", current) | ||
| if current != target { | ||
| action = "update_available" | ||
| message = fmt.Sprintf("lark-cli %s %s configured target %s", current, symArrow(), target) | ||
| } | ||
| if opts.JSON { | ||
| result := map[string]interface{}{ | ||
| "ok": true, "source": "manifest", | ||
| "previous_version": current, "current_version": current, "target_version": target, | ||
| "action": action, "message": message, | ||
| } | ||
| if check { | ||
| result["auto_update"] = true | ||
| } | ||
| output.PrintJson(streams.Out, result) | ||
| return nil | ||
| } | ||
| if current == target { | ||
| fmt.Fprintf(streams.ErrOut, "%s %s\n", symOK(), message) | ||
| } else { | ||
| fmt.Fprintf(streams.ErrOut, "Configured target: %s %s %s\n\nRun `lark-cli update` to install.\n", current, symArrow(), target) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func reportDistributionError(opts *UpdateOptions, typed errs.TypedError) error { | ||
| errType := "update_error" | ||
| if problem, ok := errs.ProblemOf(typed); ok && problem.Category == errs.CategoryNetwork { | ||
| errType = "network" | ||
| } | ||
| return reportError(opts, opts.Factory.IOStreams, errType, typed) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.