Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ etherscan version
Install the CLI globally:

```sh
npm install -g @etherscan/etherscan
npm install -g @etherscan/cli
etherscan version
```

Or run it once without keeping a global installation:

```sh
npx @etherscan/etherscan version
npx @etherscan/cli version
```

The npm package downloads the matching native release archive and verifies its SHA-256 checksum during installation. Lifecycle scripts must be enabled.
Expand Down Expand Up @@ -393,7 +393,7 @@ Update through the same channel used to install the CLI:
| Installation channel | Update command |
| --- | --- |
| Homebrew | `brew upgrade etherscan/etherscan-cli/etherscan` |
| npm | `npm install -g @etherscan/etherscan@latest` |
| npm | `npm install -g @etherscan/cli@latest` |
| macOS/Linux or Windows installer script | `etherscan update` |
| Go | `go install github.com/etherscan/etherscan-cli/cmd/etherscan@latest` |
| Manual release archive | Download and verify the new archive from [GitHub Releases](https://github.com/etherscan/etherscan-cli/releases/latest) |
Expand Down
6 changes: 3 additions & 3 deletions internal/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,15 +604,15 @@ func updateCommand(info BuildInfo, updates updateManager) *cobra.Command {
detectedMethod := updates.DetectMethod()
if detectedMethod == updater.MethodNPM {
fmt.Fprintln(cmd.OutOrStdout(), "This installation is managed by npm. Run:")
fmt.Fprintln(cmd.OutOrStdout(), " npm install -g @etherscan/etherscan@latest")
fmt.Fprintln(cmd.OutOrStdout(), " npm install -g @etherscan/cli@latest")
return nil
}
if method == "" {
method = detectedMethod
}
if method == updater.MethodNPM {
fmt.Fprintln(cmd.OutOrStdout(), "This installation is managed by npm. Run:")
fmt.Fprintln(cmd.OutOrStdout(), " npm install -g @etherscan/etherscan@latest")
fmt.Fprintln(cmd.OutOrStdout(), " npm install -g @etherscan/cli@latest")
return nil
}
fmt.Fprintf(cmd.OutOrStdout(), "Updating Etherscan CLI %s -> %s using %s...\n", result.Current, result.Latest, method)
Expand Down Expand Up @@ -656,7 +656,7 @@ func offerUpdate(ctx context.Context, updates updateManager, current string, in
method := updates.DetectMethod()
if method == updater.MethodNPM {
fmt.Fprintln(out, "This installation is managed by npm. Run:")
fmt.Fprintln(out, " npm install -g @etherscan/etherscan@latest")
fmt.Fprintln(out, " npm install -g @etherscan/cli@latest")
return true, nil
}
fmt.Fprintf(out, "Updating with %s...\n", method)
Expand Down
6 changes: 3 additions & 3 deletions internal/cli/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestOfferUpdateChoices(t *testing.T) {
if err != nil || !exit || manager.upgradedVersion != "" {
t.Fatalf("unexpected result: exit=%v err=%v manager=%+v", exit, err, manager)
}
if !strings.Contains(out.String(), "npm install -g @etherscan/etherscan@latest") {
if !strings.Contains(out.String(), "npm install -g @etherscan/cli@latest") {
t.Fatalf("output = %q, want npm install instruction", out.String())
}
})
Expand Down Expand Up @@ -126,7 +126,7 @@ func TestUpdateCommandShowsNPMInstruction(t *testing.T) {
if manager.upgradedVersion != "" {
t.Fatalf("npm update invoked updater: %+v", manager)
}
if !strings.Contains(out.String(), "npm install -g @etherscan/etherscan@latest") {
if !strings.Contains(out.String(), "npm install -g @etherscan/cli@latest") {
t.Fatalf("output = %q, want npm install instruction", out.String())
}
}
Expand All @@ -147,7 +147,7 @@ func TestUpdateCommandCannotForceScriptForNPMInstallation(t *testing.T) {
if manager.upgradedVersion != "" {
t.Fatalf("npm update invoked forced script updater: %+v", manager)
}
if !strings.Contains(out.String(), "npm install -g @etherscan/etherscan@latest") {
if !strings.Contains(out.String(), "npm install -g @etherscan/cli@latest") {
t.Fatalf("output = %q, want npm install instruction", out.String())
}
}
4 changes: 2 additions & 2 deletions internal/updater/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (s *Service) DetectMethod() string {
executable = resolved
}
normalized := strings.ToLower(filepath.ToSlash(executable))
if strings.Contains(normalized, "/node_modules/@etherscan/etherscan/") {
if strings.Contains(normalized, "/node_modules/@etherscan/cli/") {
return MethodNPM
}
if strings.Contains(normalized, "/cellar/etherscan/") || strings.Contains(normalized, "/linuxbrew/.linuxbrew/cellar/etherscan/") {
Expand Down Expand Up @@ -62,7 +62,7 @@ func (s *Service) Upgrade(ctx context.Context, method, version string, stdout, s
return false, fmt.Errorf("unsupported update method %q (use homebrew, npm, or script)", method)
}
if method == MethodNPM {
return false, fmt.Errorf("npm manages this installation; run npm install -g @etherscan/etherscan@latest")
return false, fmt.Errorf("npm manages this installation; run npm install -g @etherscan/cli@latest")
}
if method == MethodHomebrew {
if _, err := s.lookPath()("brew"); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/updater/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestDetectMethod(t *testing.T) {
t.Fatalf("DetectMethod() = %q, want %q", got, MethodScript)
}
service.Executable = func() (string, error) {
return filepath.Join(string(filepath.Separator), "usr", "lib", "node_modules", "@etherscan", "etherscan", "vendor", "etherscan"), nil
return filepath.Join(string(filepath.Separator), "usr", "lib", "node_modules", "@etherscan", "cli", "vendor", "etherscan"), nil
}
if got := service.DetectMethod(); got != MethodNPM {
t.Fatalf("DetectMethod() = %q, want %q", got, MethodNPM)
Expand All @@ -39,7 +39,7 @@ func TestDetectMethod(t *testing.T) {
func TestNPMUpgradeReturnsPackageManagerInstruction(t *testing.T) {
service := NewService()
_, err := service.Upgrade(context.Background(), MethodNPM, "1.2.0", &bytes.Buffer{}, &bytes.Buffer{})
if err == nil || !strings.Contains(err.Error(), "npm install -g @etherscan/etherscan@latest") {
if err == nil || !strings.Contains(err.Error(), "npm install -g @etherscan/cli@latest") {
t.Fatalf("Upgrade() error = %v, want npm install instruction", err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion npm/bin/etherscan.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const executable = path.join(
if (!fs.existsSync(executable)) {
console.error(
"Etherscan CLI is not installed in this npm package. " +
"Reinstall @etherscan/etherscan without --ignore-scripts.",
"Reinstall @etherscan/cli without --ignore-scripts.",
);
process.exit(1);
}
Expand Down
2 changes: 1 addition & 1 deletion npm/prepublish-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ try {
throw new Error(`invalid release version: ${packageInfo.version}`);
}
} catch (error) {
console.error(`Refusing to publish @etherscan/etherscan: ${error.message}`);
console.error(`Refusing to publish @etherscan/cli: ${error.message}`);
process.exit(1);
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@etherscan/etherscan",
"name": "@etherscan/cli",
"version": "0.0.0-development",
"description": "Command-line client and interactive explorer for the Etherscan V2 API",
"license": "MIT",
Expand Down