| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 18b8db7 commit ede9458
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,7 +47,6 @@ jobs: | |||
| 47 | 47 | with: | |
| 48 | 48 | version: latest | |
| 49 | 49 | args: --timeout=5m | |
| 50 | - continue-on-error: true | ||
| 51 | 50 | ||
| 52 | 51 | validate-goreleaser: | |
| 53 | 52 | name: Validate GoReleaser | |
@@ -70,4 +69,3 @@ jobs: | |||
| 70 | 69 | distribution: goreleaser | |
| 71 | 70 | version: latest | |
| 72 | 71 | args: check | |
| 73 | - continue-on-error: true | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,8 +9,8 @@ import ( | |||
| 9 | 9 | ||
| 10 | 10 | "github.com/spf13/cobra" | |
| 11 | 11 | ||
| 12 | - "github.com/AndroidPoet/playconsole-cli/internal/cli" | ||
| 13 | 12 | "github.com/AndroidPoet/playconsole-cli/internal/api" | |
| 13 | + "github.com/AndroidPoet/playconsole-cli/internal/cli" | ||
| 14 | 14 | "github.com/AndroidPoet/playconsole-cli/internal/output" | |
| 15 | 15 | ) | |
| 16 | 16 | ||
@@ -136,9 +136,9 @@ func init() { | |||
| 136 | 136 | ||
| 137 | 137 | // ImageInfo represents image information | |
| 138 | 138 | type ImageInfo struct { | |
| 139 | - ID string `json:"id"` | ||
| 140 | - URL string `json:"url,omitempty"` | ||
| 141 | - SHA1 string `json:"sha1,omitempty"` | ||
| 139 | + ID string `json:"id"` | ||
| 140 | + URL string `json:"url,omitempty"` | ||
| 141 | + SHA1 string `json:"sha1,omitempty"` | ||
| 142 | 142 | SHA256 string `json:"sha256,omitempty"` | |
| 143 | 143 | } | |
| 144 | 144 | ||
@@ -180,9 +180,9 @@ func runList(cmd *cobra.Command, args []string) error { | |||
| 180 | 180 | result := make([]ImageInfo, 0, len(images.Images)) | |
| 181 | 181 | for _, img := range images.Images { | |
| 182 | 182 | result = append(result, ImageInfo{ | |
| 183 | - ID: img.Id, | ||
| 184 | - URL: img.Url, | ||
| 185 | - SHA1: img.Sha1, | ||
| 183 | + ID: img.Id, | ||
| 184 | + URL: img.Url, | ||
| 185 | + SHA1: img.Sha1, | ||
| 186 | 186 | SHA256: img.Sha256, | |
| 187 | 187 | }) | |
| 188 | 188 | } | |
@@ -249,8 +249,8 @@ func runUpload(cmd *cobra.Command, args []string) error { | |||
| 249 | 249 | ||
| 250 | 250 | output.PrintSuccess("Image uploaded: %s", image.Image.Id) | |
| 251 | 251 | return output.Print(ImageInfo{ | |
| 252 | - ID: image.Image.Id, | ||
| 253 | - SHA1: image.Image.Sha1, | ||
| 252 | + ID: image.Image.Id, | ||
| 253 | + SHA1: image.Image.Sha1, | ||
| 254 | 254 | SHA256: image.Image.Sha256, | |
| 255 | 255 | }) | |
| 256 | 256 | } | |
@@ -372,6 +372,8 @@ func runSync(cmd *cobra.Command, args []string) error { | |||
| 372 | 372 | ||
| 373 | 373 | ctx := edit.Context() | |
| 374 | 374 | uploaded := 0 | |
| 375 | + changed := false | ||
| 376 | + failures := make([]string, 0) | ||
| 375 | 377 | ||
| 376 | 378 | // Walk directory: locale/imageType/files | |
| 377 | 379 | locales, err := os.ReadDir(absDir) | |
@@ -405,46 +407,61 @@ func runSync(cmd *cobra.Command, args []string) error { | |||
| 405 | 407 | typeDir := filepath.Join(localeDir, typeName) | |
| 406 | 408 | files, err := os.ReadDir(typeDir) | |
| 407 | 409 | if err != nil { | |
| 410 | + failures = append(failures, fmt.Sprintf("%s/%s: %v", localeName, typeName, err)) | ||
| 408 | 411 | continue | |
| 409 | 412 | } | |
| 410 | 413 | ||
| 414 | + localFiles := make([]string, 0) | ||
| 411 | 415 | for _, fileEntry := range files { | |
| 412 | 416 | if fileEntry.IsDir() { | |
| 413 | 417 | continue | |
| 414 | 418 | } | |
| 415 | 419 | ||
| 416 | - filePath := filepath.Join(typeDir, fileEntry.Name()) | ||
| 417 | 420 | ext := strings.ToLower(filepath.Ext(fileEntry.Name())) | |
| 418 | 421 | if ext != ".png" && ext != ".jpg" && ext != ".jpeg" { | |
| 419 | 422 | continue | |
| 420 | 423 | } | |
| 421 | 424 | ||
| 422 | - if cli.IsDryRun() { | ||
| 423 | - output.PrintInfo("Dry run: would upload %s to %s/%s", fileEntry.Name(), localeName, typeName) | ||
| 424 | - continue | ||
| 425 | - } | ||
| 425 | + localFiles = append(localFiles, filepath.Join(typeDir, fileEntry.Name())) | ||
| 426 | + } | ||
| 426 | 427 | ||
| 427 | - file, err := os.Open(filePath) | ||
| 428 | + if cli.IsDryRun() { | ||
| 429 | + output.PrintInfo("Dry run: would replace %s/%s with %d image(s)", localeName, typeName, len(localFiles)) | ||
| 430 | + continue | ||
| 431 | + } | ||
| 432 | + | ||
| 433 | + if _, err := edit.Images().Deleteall(client.GetPackageName(), edit.ID(), localeName, typeName).Context(ctx).Do(); err != nil { | ||
| 434 | + failures = append(failures, fmt.Sprintf("%s/%s: failed to clear existing images: %v", localeName, typeName, err)) | ||
| 435 | + continue | ||
| 436 | + } | ||
| 437 | + changed = true | ||
| 438 | + | ||
| 439 | + for _, localFile := range localFiles { | ||
| 440 | + file, err := os.Open(localFile) | ||
| 428 | 441 | if err != nil { | |
| 429 | - output.PrintWarning("Failed to open %s: %v", filePath, err) | ||
| 442 | + failures = append(failures, fmt.Sprintf("%s/%s/%s: %v", localeName, typeName, filepath.Base(localFile), err)) | ||
| 430 | 443 | continue | |
| 431 | 444 | } | |
| 432 | 445 | ||
| 433 | 446 | _, err = edit.Images().Upload(client.GetPackageName(), edit.ID(), localeName, typeName).Media(file).Context(ctx).Do() | |
| 434 | 447 | file.Close() | |
| 435 | 448 | ||
| 436 | 449 | if err != nil { | |
| 437 | - output.PrintWarning("Failed to upload %s: %v", fileEntry.Name(), err) | ||
| 450 | + failures = append(failures, fmt.Sprintf("%s/%s/%s: %v", localeName, typeName, filepath.Base(localFile), err)) | ||
| 438 | 451 | continue | |
| 439 | 452 | } | |
| 440 | 453 | ||
| 441 | - output.PrintInfo("Uploaded: %s/%s/%s", localeName, typeName, fileEntry.Name()) | ||
| 454 | + output.PrintInfo("Uploaded: %s/%s/%s", localeName, typeName, filepath.Base(localFile)) | ||
| 442 | 455 | uploaded++ | |
| 443 | 456 | } | |
| 444 | 457 | } | |
| 445 | 458 | } | |
| 446 | 459 | ||
| 447 | - if !cli.IsDryRun() && uploaded > 0 { | ||
| 460 | + if len(failures) > 0 { | ||
| 461 | + return fmt.Errorf("image sync aborted; no changes committed. Failures: %s", strings.Join(failures, "; ")) | ||
| 462 | + } | ||
| 463 | + | ||
| 464 | + if !cli.IsDryRun() && changed { | ||
| 448 | 465 | if err := edit.Commit(); err != nil { | |
| 449 | 466 | return err | |
| 450 | 467 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,13 +4,14 @@ import ( | |||
| 4 | 4 | "fmt" | |
| 5 | 5 | "os" | |
| 6 | 6 | "path/filepath" | |
| 7 | + "strings" | ||
| 7 | 8 | "time" | |
| 8 | 9 | ||
| 9 | 10 | "github.com/spf13/cobra" | |
| 10 | 11 | "google.golang.org/api/androidpublisher/v3" | |
| 11 | 12 | ||
| 12 | - "github.com/AndroidPoet/playconsole-cli/internal/cli" | ||
| 13 | 13 | "github.com/AndroidPoet/playconsole-cli/internal/api" | |
| 14 | + "github.com/AndroidPoet/playconsole-cli/internal/cli" | ||
| 14 | 15 | "github.com/AndroidPoet/playconsole-cli/internal/output" | |
| 15 | 16 | ) | |
| 16 | 17 | ||
@@ -59,12 +60,12 @@ Expected structure (fastlane-compatible): | |||
| 59 | 60 | } | |
| 60 | 61 | ||
| 61 | 62 | var ( | |
| 62 | - locale string | ||
| 63 | - title string | ||
| 64 | - shortDesc string | ||
| 65 | - fullDesc string | ||
| 66 | - fullDescFile string | ||
| 67 | - syncDir string | ||
| 63 | + locale string | ||
| 64 | + title string | ||
| 65 | + shortDesc string | ||
| 66 | + fullDesc string | ||
| 67 | + fullDescFile string | ||
| 68 | + syncDir string | ||
| 68 | 69 | ) | |
| 69 | 70 | ||
| 70 | 71 | func init() { | |
@@ -275,6 +276,7 @@ func runSync(cmd *cobra.Command, args []string) error { | |||
| 275 | 276 | ||
| 276 | 277 | ctx := edit.Context() | |
| 277 | 278 | updated := 0 | |
| 279 | + failures := make([]string, 0) | ||
| 278 | 280 | ||
| 279 | 281 | for _, entry := range entries { | |
| 280 | 282 | if !entry.IsDir() { | |
@@ -315,14 +317,18 @@ func runSync(cmd *cobra.Command, args []string) error { | |||
| 315 | 317 | ||
| 316 | 318 | _, err := edit.Listings().Update(client.GetPackageName(), edit.ID(), localeName, listing).Context(ctx).Do() | |
| 317 | 319 | if err != nil { | |
| 318 | - output.PrintWarning("Failed to update locale '%s': %v", localeName, err) | ||
| 320 | + failures = append(failures, fmt.Sprintf("%s: %v", localeName, err)) | ||
| 319 | 321 | continue | |
| 320 | 322 | } | |
| 321 | 323 | ||
| 322 | 324 | output.PrintInfo("Updated: %s", localeName) | |
| 323 | 325 | updated++ | |
| 324 | 326 | } | |
| 325 | 327 | ||
| 328 | + if len(failures) > 0 { | ||
| 329 | + return fmt.Errorf("listing sync aborted; no changes committed. Failures: %s", strings.Join(failures, "; ")) | ||
| 330 | + } | ||
| 331 | + | ||
| 326 | 332 | if !cli.IsDryRun() && updated > 0 { | |
| 327 | 333 | if err := edit.Commit(); err != nil { | |
| 328 | 334 | return err | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,7 +41,7 @@ Design Philosophy: | |||
| 41 | 41 | • JSON-first output for automation | |
| 42 | 42 | • Explicit flags over cryptic shortcuts | |
| 43 | 43 | • No interactive prompts | |
| 44 | - • Clean exit codes (0=success, 1=error, 2=validation)`, | ||
| 44 | + • Clean non-zero exits on failure`, | ||
| 45 | 45 | SilenceUsage: true, | |
| 46 | 46 | SilenceErrors: true, | |
| 47 | 47 | PersistentPreRunE: func(cmd *cobra.Command, args []string) error { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments