@pippit-dev/cli 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,6 +10,7 @@ matching prebuilt binary for macOS, Linux, or Windows:
10
10
  ```bash
11
11
  npx @pippit-dev/cli@latest install
12
12
  export XYQ_ACCESS_KEY="<access-key>"
13
+ pippit-cli version
13
14
  pippit-cli short-drama +submit-run --message "写一个赛博朋克短剧开头"
14
15
  pippit-cli short-drama +upload-file --path ./story.md
15
16
  pippit-cli short-drama +get-thread --thread-id thread_123 --run-id run_456 --after-seq 0
@@ -23,6 +24,7 @@ Submit a Run task for the short drama scene:
23
24
 
24
25
  ```bash
25
26
  export XYQ_ACCESS_KEY="<access-key>"
27
+ go run . version
26
28
  go run . short-drama +submit-run --message "写一个赛博朋克短剧开头"
27
29
  go run . short-drama +upload-file --path ./story.md
28
30
  go run . short-drama +get-thread --thread-id thread_123 --run-id run_456 --after-seq 0
package/checksums.txt CHANGED
@@ -1,6 +1,6 @@
1
- 3f9cf3a1fabbc3d178c89c3d8044c18d86110faf7d26ffa469930319d13d68e6 pippit-cli-0.0.9-darwin-amd64.tar.gz
2
- 5e14f8ce6034564d9646918e49f8f2d7b6178708518b528c3f95a0af67bd3cd5 pippit-cli-0.0.9-darwin-arm64.tar.gz
3
- 91e90ab17b577b402c7676965b701df7d317b90a2e2b717929bdadce96158a71 pippit-cli-0.0.9-linux-amd64.tar.gz
4
- dad9fe0a930c91c52036290a121d721e7a100e80700b1b90807988a577a79342 pippit-cli-0.0.9-linux-arm64.tar.gz
5
- 62af305df2c5d5b6cfaa615f36cb0f014007ed35df8c4ffdf07b527e09993842 pippit-cli-0.0.9-windows-amd64.zip
6
- c6d40c79e4bf777ad71caba29191a4fc3a25f34f9643157ce08ec270b8d6eb42 pippit-cli-0.0.9-windows-arm64.zip
1
+ 5aca1f46d99e5ab9d748cf14d4cfe5fa68b2d2cb248073db0c92d0de361e5fb8 pippit-cli-0.0.10-darwin-amd64.tar.gz
2
+ b56de7e3bdd202d449ea5658171b52dbde313c1e3f12f999c583a6b321624d11 pippit-cli-0.0.10-darwin-arm64.tar.gz
3
+ b9ddcbd19ffa7aada4c114f7be8b8d6fb870b9a0b9ffed99c0df196ce05658d4 pippit-cli-0.0.10-linux-amd64.tar.gz
4
+ 3b8a11becb6229f22c39e2c86caaa897f4ae9147e0960414c0d763ce00bbdd5b pippit-cli-0.0.10-linux-arm64.tar.gz
5
+ 26a57f485227f9674591ed20536baa281c443b5ac1c26711e064a77d9ebc6174 pippit-cli-0.0.10-windows-amd64.zip
6
+ 8fd4eca3a8977b901d74aa6455293c3c400151e5981491f6d3df1d568781c3eb pippit-cli-0.0.10-windows-arm64.zip
package/cmd/root.go CHANGED
@@ -7,8 +7,10 @@ import (
7
7
  // authcmd "github.com/Pippit-dev/pippit-cli/cmd/auth"
8
8
  "github.com/Pippit-dev/pippit-cli/cmd/short_drama"
9
9
  updatecmd "github.com/Pippit-dev/pippit-cli/cmd/update"
10
+ versioncmd "github.com/Pippit-dev/pippit-cli/cmd/version"
10
11
  "github.com/Pippit-dev/pippit-cli/internal/common"
11
12
  "github.com/Pippit-dev/pippit-cli/internal/config"
13
+ "github.com/Pippit-dev/pippit-cli/internal/version"
12
14
  "github.com/spf13/cobra"
13
15
  )
14
16
 
@@ -28,6 +30,7 @@ func newRootCommand(stdout, stderr io.Writer, runner *common.Runner) *cobra.Comm
28
30
  root := &cobra.Command{
29
31
  Use: "pippit-cli",
30
32
  Short: "Pippit CLI",
33
+ Version: version.Current(),
31
34
  SilenceUsage: true,
32
35
  SilenceErrors: true,
33
36
  }
@@ -36,5 +39,6 @@ func newRootCommand(stdout, stderr io.Writer, runner *common.Runner) *cobra.Comm
36
39
  // root.AddCommand(authcmd.NewCommand(stdout, stderr, runner)) // temporarily disabled; auth is via access key injection
37
40
  root.AddCommand(short_drama.NewCommand(stdout, stderr, runner))
38
41
  root.AddCommand(updatecmd.NewCommand(stdout, stderr))
42
+ root.AddCommand(versioncmd.NewCommand(stdout))
39
43
  return root
40
44
  }
@@ -12,6 +12,7 @@ import (
12
12
 
13
13
  "github.com/Pippit-dev/pippit-cli/internal/common"
14
14
  "github.com/Pippit-dev/pippit-cli/internal/config"
15
+ "github.com/Pippit-dev/pippit-cli/internal/version"
15
16
  "github.com/bytedance/sonic"
16
17
  "github.com/spf13/cobra"
17
18
  )
@@ -90,6 +91,44 @@ func TestRootIncludesUpdateCommand(t *testing.T) {
90
91
  }
91
92
  }
92
93
 
94
+ func TestRootIncludesVersionCommand(t *testing.T) {
95
+ var stdout, stderr bytes.Buffer
96
+ root := NewRootCommand(&stdout, &stderr)
97
+ cmd, _, err := root.Find([]string{"version"})
98
+ if err != nil {
99
+ t.Fatalf("Find(version) error = %v", err)
100
+ }
101
+ if cmd == nil || cmd.Name() != "version" {
102
+ t.Fatalf("Find(version) = %#v, want version command", cmd)
103
+ }
104
+ }
105
+
106
+ func TestVersionCommandPrintsVersion(t *testing.T) {
107
+ var stdout, stderr bytes.Buffer
108
+ root := NewRootCommand(&stdout, &stderr)
109
+ root.SetArgs([]string{"version"})
110
+
111
+ if err := root.Execute(); err != nil {
112
+ t.Fatalf("Execute() error = %v, stderr = %s", err, stderr.String())
113
+ }
114
+ if got := strings.TrimSpace(stdout.String()); got != version.Current() {
115
+ t.Fatalf("version output = %q, want %s", got, version.Current())
116
+ }
117
+ }
118
+
119
+ func TestVersionFlagPrintsVersion(t *testing.T) {
120
+ var stdout, stderr bytes.Buffer
121
+ root := NewRootCommand(&stdout, &stderr)
122
+ root.SetArgs([]string{"--version"})
123
+
124
+ if err := root.Execute(); err != nil {
125
+ t.Fatalf("Execute() error = %v, stderr = %s", err, stderr.String())
126
+ }
127
+ if got := stdout.String(); !strings.Contains(got, version.Current()) {
128
+ t.Fatalf("version flag output = %q, want version", got)
129
+ }
130
+ }
131
+
93
132
  func TestShortDramaSubmitRunRequiresMessage(t *testing.T) {
94
133
  var stdout, stderr bytes.Buffer
95
134
  root := NewRootCommand(&stdout, &stderr)
@@ -0,0 +1,21 @@
1
+ package versioncmd
2
+
3
+ import (
4
+ "fmt"
5
+ "io"
6
+
7
+ "github.com/Pippit-dev/pippit-cli/internal/version"
8
+ "github.com/spf13/cobra"
9
+ )
10
+
11
+ func NewCommand(stdout io.Writer) *cobra.Command {
12
+ return &cobra.Command{
13
+ Use: "version",
14
+ Short: "Print pippit-cli version",
15
+ Args: cobra.NoArgs,
16
+ RunE: func(cmd *cobra.Command, _ []string) error {
17
+ _, err := fmt.Fprintln(stdout, version.Current())
18
+ return err
19
+ },
20
+ }
21
+ }
@@ -0,0 +1,61 @@
1
+ package version
2
+
3
+ import (
4
+ "encoding/json"
5
+ "os"
6
+ "path/filepath"
7
+ "strings"
8
+ )
9
+
10
+ // Version is set by GoReleaser for release binaries.
11
+ var Version = "dev"
12
+
13
+ const packageName = "@pippit-dev/cli"
14
+
15
+ type packageJSON struct {
16
+ Name string `json:"name"`
17
+ Version string `json:"version"`
18
+ }
19
+
20
+ func Current() string {
21
+ if strings.TrimSpace(Version) != "" && Version != "dev" {
22
+ return strings.TrimSpace(Version)
23
+ }
24
+ if version := packageVersionFromWorktree(); version != "" {
25
+ return version
26
+ }
27
+ return Version
28
+ }
29
+
30
+ func packageVersionFromWorktree() string {
31
+ dir, err := os.Getwd()
32
+ if err != nil {
33
+ return ""
34
+ }
35
+ for {
36
+ version := packageVersion(filepath.Join(dir, "package.json"))
37
+ if version != "" {
38
+ return version
39
+ }
40
+ parent := filepath.Dir(dir)
41
+ if parent == dir {
42
+ return ""
43
+ }
44
+ dir = parent
45
+ }
46
+ }
47
+
48
+ func packageVersion(path string) string {
49
+ data, err := os.ReadFile(path)
50
+ if err != nil {
51
+ return ""
52
+ }
53
+ var pkg packageJSON
54
+ if err := json.Unmarshal(data, &pkg); err != nil {
55
+ return ""
56
+ }
57
+ if pkg.Name != packageName {
58
+ return ""
59
+ }
60
+ return strings.TrimSpace(pkg.Version)
61
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pippit-dev/cli",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "Pippit CLI",
5
5
  "bin": {
6
6
  "pippit-cli": "scripts/run.js"