1{ lib, buildGoModule, fetchFromGitHub, installShellFiles, stdenv }:
2
3buildGoModule rec {
4 pname = "stripe-cli";
5 version = "1.14.7";
6
7 src = fetchFromGitHub {
8 owner = "stripe";
9 repo = pname;
10 rev = "v${version}";
11 hash = "sha256-cyN23Ry60veMBXX97oYGxUmyaktM0tdWxAapD8RN+RQ=";
12 };
13 vendorHash = "sha256-DYA6cu2KzEBZ4wsT7wjcdY1endQQOZlj2aOwu6iGLew=";
14
15 nativeBuildInputs = [ installShellFiles ];
16
17 ldflags = [
18 "-s"
19 "-w"
20 "-X github.com/stripe/stripe-cli/pkg/version.Version=${version}"
21 ];
22
23 preCheck = ''
24 # the tests expect the Version ldflag not to be set
25 unset ldflags
26
27 # requires internet access
28 rm pkg/cmd/plugin_cmds_test.go
29 rm pkg/cmd/resources_test.go
30 rm pkg/cmd/root_test.go
31
32 # TODO: no clue why it's broken (1.14.7), remove for now.
33 rm pkg/login/client_login_test.go
34 rm pkg/git/editor_test.go
35 rm pkg/rpcservice/sample_create_test.go
36 '' + lib.optionalString (
37 # delete plugin tests on all platforms but exact matches
38 # https://github.com/stripe/stripe-cli/issues/850
39 ! lib.lists.any
40 (platform: lib.meta.platformMatch stdenv.hostPlatform platform)
41 [ "x86_64-linux" "x86_64-darwin" ]
42 ) ''
43 rm pkg/plugins/plugin_test.go
44 '';
45
46 postInstall = ''
47 installShellCompletion --cmd stripe \
48 --bash <($out/bin/stripe completion --write-to-stdout --shell bash) \
49 --zsh <($out/bin/stripe completion --write-to-stdout --shell zsh)
50 '';
51
52 doInstallCheck = true;
53 installCheckPhase = ''
54 runHook preInstallCheck
55 $out/bin/stripe --help
56 $out/bin/stripe --version | grep "${version}"
57 runHook postInstallCheck
58 '';
59
60 meta = with lib; {
61 homepage = "https://stripe.com/docs/stripe-cli";
62 changelog = "https://github.com/stripe/stripe-cli/releases/tag/v${version}";
63 description = "A command-line tool for Stripe";
64 longDescription = ''
65 The Stripe CLI helps you build, test, and manage your Stripe integration
66 right from the terminal.
67
68 With the CLI, you can:
69 Securely test webhooks without relying on 3rd party software
70 Trigger webhook events or resend events for easy testing
71 Tail your API request logs in real-time
72 Create, retrieve, update, or delete API objects.
73 '';
74 license = with licenses; [ asl20 ];
75 maintainers = with maintainers; [ RaghavSood jk ];
76 mainProgram = "stripe";
77 };
78}