mirror of
https://github.com/larksuite/cli.git
synced 2026-08-03 08:32:46 +08:00
* feat(apps): read LARKSUITE_CLI_AGENT env var and pass app_source in +create
* feat(apps): add queryAppMeta shared function for app_type/arch_type lookup
* feat(apps): skip scaffold for legacy html apps, pass app_type/arch_type for arch_type=4 html in +init
* feat(apps): add zip packaging for arch_type=4 html publish path
* feat(apps): add TOS upload path for arch_type=4 html in +html-publish with arch_type-based routing
* refactor(apps): replace appMeta struct with queryAppType string for simpler routing
* refactor(apps): simplify to source_agent in +create, unified scaffold in +init, revert html-publish changes
* feat(apps): add --source-path flag to +init for existing source file incorporation
* fix(apps): align queryAppType with actual API path and response structure
* refactor(apps): use appInfo struct to parse GET /apps/{id} response
* test(apps): add full_stack scaffold test case
* feat(apps): surface sync field in +release-create response
* refactor(apps): remove --template flag from +init, derive template from queryAppType with full_stack fallback
* style(apps): fix gofmt formatting in apps_init.go
* test(apps): improve coverage for sync field, queryAppType, and scaffoldInitArgs
* chore(apps): pin miaoda-cli to alpha version 0.1.20-alpha.dd573f8
* feat(apps): add modern_html enum and pass --app-type instead of --template to miaoda-cli
* chore: add global PPE headers for testing (x-use-ppe, x-tt-env)
* feat(apps): add TOS upload path in +html-publish for modern_html, add --tos-path to +release-create
* feat(apps): unify html-publish output structure with app_id for both html and modern_html
* fix(apps): use newFileTransferClient for TOS presigned upload to satisfy forbidigo lint
* test(apps): add coverage for runHTMLPublishTOS success, errors, and upload failures
* fix(apps): change pre_release API method from POST to GET
* fix(apps): adapt pre_release response from map to list<KV> format
* fix(apps): use PUT method and Content-Length for TOS presigned upload
* fix(apps): use tos_path instead of tosPath in release-create request body
* chore(apps): add npmmirror registry for npx miaoda-cli, fix TOS upload test to expect PUT
* refactor(apps): use envvars.AgentName() for source_agent in +create
* feat(apps): integrate release-create into html-publish for modern_html, auto-detect modern_html from doubao agent env
* refactor(apps): remove --tos-path flag from +release-create (now internal to html-publish)
* refactor(apps): remove app_id from html-publish output, update skill doc
* docs(apps): update html-publish description to reflect dual return values
* refactor(apps): remove doubao app_type conversion in +create, let server decide via source_agent
* feat(apps): skip env-pull for modern_html apps in +init
* test(apps): add tests for modern_html env-pull skip in +init
* refactor(apps): introduce appTypePolicy for init control points (skipInstall, skipEnvPull, skipSkillsSync)
* feat(apps): add init step timing and default git config for +init
* feat(apps): add +get shortcut to fetch single app detail by app_id
* chore(apps): remove init step timing (not ready for production)
* test(apps): add coverage for +get shortcut
* chore: remove PPE headers and revert miaoda-cli to @latest for production
* refactor(apps): extract shared prepareHTMLPublishTarball, fix stale comments, simplify queryAppType
* fix(apps): update html-publish dry-run desc, remove hardcoded API path
* fix(apps): use rctx.IO().ErrOut instead of os.Stderr, remove unused appInfo struct
* fix(apps): restore dry-run API path output for E2E compatibility
* refactor(apps): move --source-path control char validation to Validate for dry-run coverage
* fix(apps): update stale --template comments to --app-type in init tests
* test(apps): explicitly unset agent env var for test isolation
77 lines
2.7 KiB
Go
77 lines
2.7 KiB
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package apps
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io"
|
|
"strings"
|
|
|
|
"github.com/larksuite/cli/internal/validate"
|
|
"github.com/larksuite/cli/shortcuts/common"
|
|
)
|
|
|
|
// AppsReleaseCreate creates a release for an app.
|
|
var AppsReleaseCreate = common.Shortcut{
|
|
Service: appsService,
|
|
Command: "+release-create",
|
|
Description: "Create a release for an app (returns release_id for status polling)",
|
|
Risk: "write",
|
|
Tips: []string{
|
|
"Example: lark-cli apps +release-create --app-id <app_id>",
|
|
"Example: lark-cli apps +release-create --app-id <app_id> --branch sprint/default --dry-run",
|
|
},
|
|
Scopes: []string{"spark:app:write"},
|
|
AuthTypes: []string{"user"},
|
|
HasFormat: true,
|
|
Flags: []common.Flag{
|
|
{Name: "app-id", Desc: "app ID", Required: true},
|
|
{Name: "branch", Desc: "release branch (server uses default if omitted)"},
|
|
},
|
|
Validate: func(ctx context.Context, rctx *common.RuntimeContext) error {
|
|
if strings.TrimSpace(rctx.Str("app-id")) == "" {
|
|
return appsValidationParamError("--app-id", "--app-id is required")
|
|
}
|
|
return nil
|
|
},
|
|
DryRun: func(ctx context.Context, rctx *common.RuntimeContext) *common.DryRunAPI {
|
|
appID := strings.TrimSpace(rctx.Str("app-id"))
|
|
branch := strings.TrimSpace(rctx.Str("branch"))
|
|
dry := common.NewDryRunAPI()
|
|
dry.POST(fmt.Sprintf(releaseCreatePath, validate.EncodePathSegment(appID))).
|
|
Desc("Create a release").
|
|
Body(buildPublishBody(branch))
|
|
return dry
|
|
},
|
|
Execute: func(ctx context.Context, rctx *common.RuntimeContext) error {
|
|
appID := strings.TrimSpace(rctx.Str("app-id"))
|
|
branch := strings.TrimSpace(rctx.Str("branch"))
|
|
path := fmt.Sprintf(releaseCreatePath, validate.EncodePathSegment(appID))
|
|
data, err := rctx.CallAPITyped("POST", path, nil, buildPublishBody(branch))
|
|
if err != nil {
|
|
return withAppsHint(err, "if the push was rejected (non-fast-forward), sync first with `git pull --rebase origin sprint/default` then retry; inspect the failure via `lark-cli apps +release-get --app-id "+appID+" --release-id <release_id>`")
|
|
}
|
|
out := map[string]interface{}{
|
|
"release_id": common.GetString(data, "release_id"),
|
|
"status": common.GetString(data, "status"),
|
|
"sync": common.GetBool(data, "sync"),
|
|
}
|
|
rctx.OutFormat(out, nil, func(w io.Writer) {
|
|
fmt.Fprintf(w, "release_id: %s\nstatus: %s\nsync: %v\n", out["release_id"], out["status"], out["sync"])
|
|
})
|
|
return nil
|
|
},
|
|
}
|
|
|
|
// buildPublishBody builds the create-release request body. app_id is in the
|
|
// path, not the body. branch is included only when non-empty.
|
|
func buildPublishBody(branch string) map[string]interface{} {
|
|
body := map[string]interface{}{}
|
|
if branch != "" {
|
|
body["branch"] = branch
|
|
}
|
|
return body
|
|
}
|