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