chore: detach app version

This commit is contained in:
Fu Diwei
2026-01-06 19:17:46 +08:00
committed by RHQYZ
parent 1b390dd004
commit e53b813cfd
50 changed files with 199 additions and 130 deletions
-5
View File
@@ -30,7 +30,6 @@ jobs:
- name: Build UI
run: |
echo "VITE_APP_VERSION=${GITHUB_REF#refs/tags/}" > ./ui/.env
npm --prefix=./ui ci
npm --prefix=./ui run build
@@ -85,10 +84,6 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# - name: Inject tag version of UI
# run: |
# echo "VITE_APP_VERSION=${GITHUB_REF#refs/tags/}" > ./ui/.env
- name: Download UI build artifacts
uses: actions/download-artifact@v6
with:
-5
View File
@@ -29,7 +29,6 @@ jobs:
- name: Build UI
run: |
echo "VITE_APP_VERSION=${GITHUB_REF#refs/tags/}" > ./ui/.env
npm --prefix=./ui ci
npm --prefix=./ui run build
@@ -84,10 +83,6 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# - name: Inject tag version of UI
# run: |
# echo "VITE_APP_VERSION=${GITHUB_REF#refs/tags/}" > ./ui/.env
- name: Download UI build artifacts
uses: actions/download-artifact@v6
with:
-1
View File
@@ -21,7 +21,6 @@ jobs:
- name: Build UI
run: |
echo "VITE_APP_VERSION=${GITHUB_REF#refs/tags/}" > ./ui/.env
npm --prefix=./ui ci
npm --prefix=./ui run build
+3 -2
View File
@@ -12,6 +12,7 @@ import (
"github.com/pocketbase/pocketbase/core"
"github.com/spf13/cobra"
"github.com/certimate-go/certimate/internal/app"
"github.com/certimate-go/certimate/internal/certacme"
"github.com/certimate-go/certimate/internal/tools/mproc"
)
@@ -27,7 +28,7 @@ func NewInternalCommand(app core.App) *cobra.Command {
return command
}
func internalCertApplyCommand(app core.App) *cobra.Command {
func internalCertApplyCommand(_ core.App) *cobra.Command {
var flagInput string
var flagOutput string
var flagError string
@@ -61,7 +62,7 @@ func internalCertApplyCommand(app core.App) *cobra.Command {
legolog.Logger = log.New(os.Stdout, "", 0)
client, err := certacme.NewACMEClientWithAccount(params.Account, func(c *lego.Config) error {
c.UserAgent = "certimate"
c.UserAgent = app.AppUserAgent
c.Certificate.KeyType = params.Request.PrivateKeyType
c.Certificate.DisableCommonName = params.Request.NoCommonName
return nil
+6 -4
View File
@@ -14,6 +14,8 @@ import (
"golang.org/x/sys/windows/svc"
"golang.org/x/sys/windows/svc/eventlog"
"golang.org/x/sys/windows/svc/mgr"
"github.com/certimate-go/certimate/internal/app"
)
const winscName = "certimate"
@@ -32,7 +34,7 @@ func NewWinscCommand(app core.App) *cobra.Command {
return command
}
func winscInstallCommand(app core.App) *cobra.Command {
func winscInstallCommand(_ core.App) *cobra.Command {
command := &cobra.Command{
Use: "install [args...]",
Example: "winsc install",
@@ -53,7 +55,7 @@ func winscInstallCommand(app core.App) *cobra.Command {
defer manager.Disconnect()
config := mgr.Config{
DisplayName: "Certimate",
DisplayName: app.AppName,
Description: "https://github.com/certimate-go/certimate",
StartType: mgr.StartAutomatic,
}
@@ -79,7 +81,7 @@ func winscInstallCommand(app core.App) *cobra.Command {
return command
}
func winscUninstallCommand(app core.App) *cobra.Command {
func winscUninstallCommand(_ core.App) *cobra.Command {
command := &cobra.Command{
Use: "uninstall",
Example: "winsc uninstall",
@@ -122,7 +124,7 @@ func winscUninstallCommand(app core.App) *cobra.Command {
return command
}
func winscStartCommand(app core.App) *cobra.Command {
func winscStartCommand(_ core.App) *cobra.Command {
command := &cobra.Command{
Use: "start",
Example: "winsc start",
+5 -55
View File
@@ -1,57 +1,7 @@
package app
package app
import (
"log/slog"
"sync"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/core"
const (
AppName = "Certimate"
AppVersion = "0.4.13-dev"
AppUserAgent = AppName + "/" + AppVersion
)
var (
instance core.App
intanceOnce sync.Once
)
func GetApp() core.App {
intanceOnce.Do(func() {
pb := pocketbase.NewWithConfig(pocketbase.Config{
HideStartBanner: true,
})
pb.RootCmd.Flags().MarkHidden("encryptionEnv")
pb.RootCmd.Flags().MarkHidden("queryTimeout")
pb.OnBootstrap().BindFunc(func(e *core.BootstrapEvent) error {
err := e.Next()
if err != nil {
return err
}
settings := pb.Settings()
if !settings.Batch.Enabled {
settings.Batch.Enabled = true
settings.Batch.MaxRequests = 1000
settings.Batch.Timeout = 30
if err := pb.Save(settings); err != nil {
return err
}
}
return nil
})
instance = pb
})
return instance
}
func GetDB() dbx.Builder {
return GetApp().DB()
}
func GetLogger() *slog.Logger {
return GetApp().Logger()
}
+57
View File
@@ -0,0 +1,57 @@
package app
import (
"log/slog"
"sync"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/core"
)
var (
instance core.App
intanceOnce sync.Once
)
func GetApp() core.App {
intanceOnce.Do(func() {
pb := pocketbase.NewWithConfig(pocketbase.Config{
HideStartBanner: true,
})
pb.RootCmd.Flags().MarkHidden("encryptionEnv")
pb.RootCmd.Flags().MarkHidden("queryTimeout")
pb.OnBootstrap().BindFunc(func(e *core.BootstrapEvent) error {
err := e.Next()
if err != nil {
return err
}
settings := pb.Settings()
if !settings.Batch.Enabled {
settings.Batch.Enabled = true
settings.Batch.MaxRequests = 1000
settings.Batch.Timeout = 30
if err := pb.Save(settings); err != nil {
return err
}
}
return nil
})
instance = pb
})
return instance
}
func GetDB() dbx.Builder {
return GetApp().DB()
}
func GetLogger() *slog.Logger {
return GetApp().Logger()
}
@@ -412,7 +412,7 @@ func (ne *bizApplyNodeExecutor) executeObtain(execCtx *NodeExecutionContext, nod
// 初始化 ACME 客户端
legolog.Logger = certacme.NewLegoLogger(app.GetLogger())
legoClient, err := certacme.NewACMEClientWithAccount(legoUser, func(c *lego.Config) error {
c.UserAgent = "certimate"
c.UserAgent = app.AppUserAgent
c.Certificate.KeyType = legoKeyType
c.Certificate.DisableCommonName = obtainReq.NoCommonName
return nil
@@ -11,6 +11,7 @@ import (
"strings"
"time"
"github.com/certimate-go/certimate/internal/app"
"github.com/certimate-go/certimate/internal/repository"
xcertx509 "github.com/certimate-go/certimate/pkg/utils/cert/x509"
xhttp "github.com/certimate-go/certimate/pkg/utils/http"
@@ -139,7 +140,7 @@ func (ne *bizMonitorNodeExecutor) tryRetrievePeerCertificates(execCtx *NodeExecu
}
req.Header.Set("Host", domain)
req.Header.Set("User-Agent", "certimate")
req.Header.Set("User-Agent", app.AppUserAgent)
resp, err := client.Do(req)
if err != nil {
err = fmt.Errorf("failed to send http request: %w", err)
@@ -15,6 +15,7 @@ import (
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
"github.com/certimate-go/certimate/pkg/core/notifier"
)
@@ -40,7 +41,7 @@ func NewNotifier(config *NotifierConfig) (*Notifier, error) {
client := resty.New().
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
if config.Secret != "" {
timestamp := fmt.Sprintf("%d", time.Now().UnixMilli())
@@ -8,6 +8,7 @@ import (
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
"github.com/certimate-go/certimate/pkg/core/notifier"
)
@@ -34,7 +35,7 @@ func NewNotifier(config *NotifierConfig) (*Notifier, error) {
client := resty.New().
SetHeader("Authorization", fmt.Sprintf("Bot %s", config.BotToken)).
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate")
SetHeader("User-Agent", app.AppUserAgent)
return &Notifier{
config: config,
@@ -14,6 +14,7 @@ import (
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
"github.com/certimate-go/certimate/pkg/core/notifier"
)
@@ -39,7 +40,7 @@ func NewNotifier(config *NotifierConfig) (*Notifier, error) {
client := resty.New().
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate")
SetHeader("User-Agent", app.AppUserAgent)
return &Notifier{
config: config,
@@ -9,6 +9,7 @@ import (
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
"github.com/certimate-go/certimate/pkg/core/notifier"
)
@@ -38,7 +39,7 @@ func NewNotifier(config *NotifierConfig) (*Notifier, error) {
client := resty.New().
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate")
SetHeader("User-Agent", app.AppUserAgent)
return &Notifier{
config: config,
@@ -8,6 +8,7 @@ import (
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
"github.com/certimate-go/certimate/pkg/core/notifier"
)
@@ -34,7 +35,7 @@ func NewNotifier(config *NotifierConfig) (*Notifier, error) {
client := resty.New().
SetHeader("Authorization", fmt.Sprintf("Bearer %s", config.BotToken)).
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate")
SetHeader("User-Agent", app.AppUserAgent)
return &Notifier{
config: config,
@@ -8,6 +8,7 @@ import (
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
"github.com/certimate-go/certimate/pkg/core/notifier"
)
@@ -33,7 +34,7 @@ func NewNotifier(config *NotifierConfig) (*Notifier, error) {
client := resty.New().
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate")
SetHeader("User-Agent", app.AppUserAgent)
return &Notifier{
config: config,
@@ -10,6 +10,7 @@ import (
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
"github.com/certimate-go/certimate/pkg/core/notifier"
)
@@ -33,7 +34,7 @@ func NewNotifier(config *NotifierConfig) (*Notifier, error) {
client := resty.New().
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate")
SetHeader("User-Agent", app.AppUserAgent)
return &Notifier{
config: config,
+3 -1
View File
@@ -12,6 +12,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -33,7 +35,7 @@ func NewClient(serverUrl, apiKey string) (*Client, error) {
SetBaseURL(strings.TrimRight(serverUrl, "/")+"/api/v1").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
timestamp := fmt.Sprintf("%d", time.Now().Unix())
tokenMd5 := md5.Sum([]byte("1panel" + apiKey + timestamp))
+3 -1
View File
@@ -12,6 +12,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -33,7 +35,7 @@ func NewClient(serverUrl, apiKey string) (*Client, error) {
SetBaseURL(strings.TrimRight(serverUrl, "/")+"/api/v2").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
timestamp := fmt.Sprintf("%d", time.Now().Unix())
tokenMd5 := md5.Sum([]byte("1panel" + apiKey + timestamp))
+3 -1
View File
@@ -9,6 +9,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -30,7 +32,7 @@ func NewClient(apiKey, apiSecret string) (*Client, error) {
SetBaseURL("https://www.51dns.com/api").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate")
SetHeader("User-Agent", app.AppUserAgent)
return &Client{
apiKey: apiKey,
+3 -1
View File
@@ -6,6 +6,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -21,7 +23,7 @@ func NewClient(apiToken string) (*Client, error) {
SetBaseURL("https://cdn.api.baishan.com").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetQueryParam("token", apiToken)
return &Client{client}, nil
+3 -1
View File
@@ -12,6 +12,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -35,7 +37,7 @@ func NewClient(serverUrl, apiKey string) (*Client, error) {
SetBaseURL(strings.TrimRight(serverUrl, "/")).
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/x-www-form-urlencoded").
SetHeader("User-Agent", "certimate")
SetHeader("User-Agent", app.AppUserAgent)
return &Client{
apiKey: apiKey,
+3 -1
View File
@@ -13,6 +13,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -36,7 +38,7 @@ func NewClient(serverUrl, apiKey string) (*Client, error) {
SetBaseURL(strings.TrimRight(serverUrl, "/")).
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/x-www-form-urlencoded").
SetHeader("User-Agent", "certimate")
SetHeader("User-Agent", app.AppUserAgent)
return &Client{
apiKey: apiKey,
+3 -1
View File
@@ -12,6 +12,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -33,7 +35,7 @@ func NewClient(serverUrl, apiKey string) (*Client, error) {
SetBaseURL(strings.TrimRight(serverUrl, "/")+"/api").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
timestamp := fmt.Sprintf("%d", time.Now().Unix())
keyMd5 := md5.Sum([]byte(apiKey))
+3 -1
View File
@@ -5,6 +5,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -20,7 +22,7 @@ func NewClient(apiToken string) (*Client, error) {
SetBaseURL("https://api.bunny.net").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetHeader("AccessKey", apiToken)
return &Client{client}, nil
+3 -1
View File
@@ -6,6 +6,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -21,7 +23,7 @@ func NewClient(apiToken string) (*Client, error) {
SetBaseURL("https://api.cachefly.com/api/2.5").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetHeader("X-CF-Authorization", "Bearer "+apiToken)
return &Client{client}, nil
+3 -1
View File
@@ -9,6 +9,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -33,7 +35,7 @@ func NewClient(serverUrl, apiKey, apiSecret string) (*Client, error) {
SetBaseURL(strings.TrimRight(serverUrl, "/")+"/v1").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetHeader("API-Key", apiKey).
SetHeader("API-Secret", apiSecret)
+3 -1
View File
@@ -9,6 +9,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -33,7 +35,7 @@ func NewClient(serverUrl string, username, apiToken string) (*Client, error) {
SetBaseURL(strings.TrimRight(serverUrl, "/")+"/execute").
SetHeader("Accept", "application/json").
SetHeader("Authorization", fmt.Sprintf("cpanel %s:%s", username, apiToken)).
SetHeader("User-Agent", "certimate")
SetHeader("User-Agent", app.AppUserAgent)
return &Client{client}, nil
}
+3 -1
View File
@@ -14,6 +14,8 @@ import (
"github.com/go-resty/resty/v2"
"github.com/pocketbase/pocketbase/tools/security"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -38,7 +40,7 @@ func NewClient(endpoint, accessKeyId, secretAccessKey string) (*Client, error) {
SetBaseURL(endpoint).
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
// 生成时间戳及流水号
now := time.Now()
+6 -4
View File
@@ -15,6 +15,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -59,12 +61,12 @@ func NewClient(username, password string) (*Client, error) {
client.serverlessClient = resty.New().
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate")
SetHeader("User-Agent", app.AppUserAgent)
client.apiClient = resty.New().
SetBaseURL("https://unicloud-api.dcloud.net.cn/unicloud/api").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
if client.apiUserToken != "" {
req.Header.Set("Token", client.apiUserToken)
@@ -86,12 +88,12 @@ func (c *Client) buildServerlessClientInfo(appId string) (_clientInfo map[string
"PLATFORM": "web",
"OS": strings.ToUpper(runtime.GOOS),
"APPID": appId,
"DEVICEID": "certimate",
"DEVICEID": app.AppName,
"LOCALE": "zh-Hans",
"osName": runtime.GOOS,
"appId": appId,
"appName": "uniCloud",
"deviceId": "certimate",
"deviceId": app.AppName,
"deviceType": "pc",
"uniPlatform": "web",
"uniCompilerVersion": "4.45",
+3 -1
View File
@@ -7,6 +7,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -22,7 +24,7 @@ func NewClient(apiKey string) (*Client, error) {
SetBaseURL("https://api.dnsexit.com").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
req.Header.Set("apikey", apiKey)
+3 -1
View File
@@ -6,6 +6,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -25,7 +27,7 @@ func NewClient(apiId, apiSecret string) (*Client, error) {
SetBasicAuth(apiId, apiSecret).
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate")
SetHeader("User-Agent", app.AppUserAgent)
return &Client{client}, nil
}
+3 -1
View File
@@ -11,6 +11,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -29,7 +31,7 @@ func NewClient(accessKey, secretKey string) (*Client, error) {
SetBaseURL("https://api.dogecloud.com").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetPreRequestHook(func(ctx *resty.Client, req *http.Request) error {
requestUrl := req.URL.Path
requestQuery := req.URL.Query().Encode()
+3 -1
View File
@@ -9,6 +9,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -30,7 +32,7 @@ func NewClient(serverUrl string, apiKey string) (*Client, error) {
SetBaseURL(strings.TrimRight(serverUrl, "/")+"/api").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetHeader("X-Api-Key", apiKey)
return &Client{client}, nil
+3 -1
View File
@@ -11,6 +11,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -54,7 +56,7 @@ func NewClient(serverUrl, apiRole, accessKeyId, accessKey string) (*Client, erro
SetBaseURL(strings.TrimRight(serverUrl, "/")).
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
if client.accessToken != "" {
req.Header.Set("X-Cloud-Access-Token", client.accessToken)
+3 -1
View File
@@ -10,6 +10,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -31,7 +33,7 @@ func NewClient(appId, appKey string) (*Client, error) {
SetBaseURL("https://api.gname.com").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/x-www-form-urlencoded").
SetHeader("User-Agent", "certimate")
SetHeader("User-Agent", app.AppUserAgent)
return &Client{
appId: appId,
+3 -1
View File
@@ -11,6 +11,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -54,7 +56,7 @@ func NewClient(serverUrl, apiRole, accessKeyId, accessKey string) (*Client, erro
SetBaseURL(strings.TrimRight(serverUrl, "/")).
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
if client.accessToken != "" {
req.Header.Set("X-Edge-Access-Token", client.accessToken)
+3 -1
View File
@@ -11,6 +11,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -43,7 +45,7 @@ func NewClient(serverUrl, username, password string) (*Client, error) {
}
client.client = resty.New().
SetBaseURL(strings.TrimRight(serverUrl, "/")+"/prod-api").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
if client.accessToken != "" {
req.Header.Set("Authorization", "Bearer "+client.accessToken)
+3 -1
View File
@@ -11,6 +11,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -45,7 +47,7 @@ func NewClient(serverUrl, username, password string) (*Client, error) {
SetBaseURL(strings.TrimRight(serverUrl, "/")+"/prod-api").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
if client.accessToken != "" {
req.Header.Set("Authorization", "Bearer "+client.accessToken)
+3 -1
View File
@@ -6,6 +6,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -22,7 +24,7 @@ func NewClient(apiToken string) (*Client, error) {
SetHeader("Accept", "application/json").
SetHeader("Authorization", "Bearer "+apiToken).
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate")
SetHeader("User-Agent", app.AppUserAgent)
return &Client{client}, nil
}
+4 -2
View File
@@ -11,6 +11,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -45,7 +47,7 @@ func NewClient(serverUrl, identity, secret string) (*Client, error) {
SetBaseURL(strings.TrimRight(serverUrl, "/")+"/api").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
if client.jwtToken != "" {
req.Header.Set("Authorization", "Bearer "+client.jwtToken)
@@ -75,7 +77,7 @@ func NewClientWithJwtToken(serverUrl, jwtToken string) (*Client, error) {
SetBaseURL(strings.TrimRight(serverUrl, "/")+"/api").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
if client.jwtToken != "" {
req.Header.Set("Authorization", "Bearer "+client.jwtToken)
+3 -1
View File
@@ -11,6 +11,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -30,7 +32,7 @@ func NewClient(accessKeyId, secretAccessKey string) (*Client, error) {
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("Host", "api.routewize.com").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
// 生成时间
date := time.Now().UTC().Format(time.RFC1123)
+3 -1
View File
@@ -6,6 +6,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -21,7 +23,7 @@ func NewClient(apiKey string) (*Client, error) {
SetBaseURL("https://api.v2.rainyun.com").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetHeader("X-API-Key", apiKey)
return &Client{client}, nil
+3 -1
View File
@@ -15,6 +15,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -39,7 +41,7 @@ func NewClient(serverUrl string, accessTokenId int64, accessToken string) (*Clie
SetBaseURL(strings.TrimRight(serverUrl, "/")+"/api").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
var body []byte
var err error
+3 -1
View File
@@ -9,6 +9,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -30,7 +32,7 @@ func NewClient(serverUrl, apiToken string) (*Client, error) {
SetBaseURL(strings.TrimRight(serverUrl, "/")).
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetHeader("X-SLCE-API-TOKEN", apiToken)
return &Client{client}, nil
+3 -1
View File
@@ -9,6 +9,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -37,7 +39,7 @@ func NewClient(username, password string) (*Client, error) {
SetBaseURL("https://console.upyun.com").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
if client.loginCookie != "" {
req.Header.Set("Cookie", client.loginCookie)
+3 -1
View File
@@ -14,6 +14,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -36,7 +38,7 @@ func NewClient(accessKey, secretKey string) (*Client, error) {
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("Host", "open.chinanetcenter.com").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
// Step 1: Get request method
method := req.Method
+3 -1
View File
@@ -12,6 +12,8 @@ import (
"time"
"github.com/go-resty/resty/v2"
"github.com/certimate-go/certimate/internal/app"
)
type Client struct {
@@ -30,7 +32,7 @@ func NewClient(agentId, appSecret string) (*Client, error) {
SetBaseURL("https://apiv2.xinnet.com/api").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetHeader("User-Agent", app.AppUserAgent).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
// 生成时间戳
timestamp := time.Now().UTC().Format("20060102T150405Z")
@@ -232,7 +232,7 @@ const AccessConfigFormFieldsProviderWebhook = ({ usage = "none" }: AccessConfigF
menu={{
items: [
{
key: "certimate",
key: "common",
label: t("access.form.webhook_preset_data.common"),
onClick: handlePresetDataForDeploymentClick,
},
+1 -1
View File
@@ -1,7 +1,7 @@
import i18next from "i18next";
// fallback policy: .env > git tag > "v0.0.0-dev"
export const APP_VERSION: string = import.meta.env.VITE_APP_VERSION || __APP_VERSION__ || "v0.0.0-dev";
export const APP_VERSION: string = "v" + (__APP_VERSION__ || "0.0.0-dev").replace(/^v/, "");
export const APP_REPO_URL = "https://github.com/certimate-go/certimate";
export const APP_DOWNLOAD_URL = APP_REPO_URL + "/releases";
+12 -12
View File
@@ -1,11 +1,10 @@
import { type SpawnSyncReturns, execFileSync } from "node:child_process";
import path from "node:path";
import tailwindcssPlugin from "@tailwindcss/vite";
import legacyPlugin from "@vitejs/plugin-legacy";
import reactPlugin from "@vitejs/plugin-react";
import fs from "fs-extra";
import { type Plugin, defineConfig, loadEnv } from "vite";
import { type Plugin, defineConfig } from "vite";
const preserveFilesPlugin = (filesToPreserve: string[]): Plugin => {
return {
@@ -34,18 +33,19 @@ const preserveFilesPlugin = (filesToPreserve: string[]): Plugin => {
};
};
export default defineConfig(({ mode }) => {
const envs = loadEnv(mode, process.cwd());
export default defineConfig(() => {
let appVersion = undefined;
if (!envs?.VITE_APP_VERSION) {
try {
appVersion = execFileSync("git", ["describe", "--match", "v[0-9]*", "--tags", "--abbrev=8"], {
stdio: [],
})?.toString();
} catch (error) {
const err = error as SpawnSyncReturns<Buffer>;
console.warn("failed to get version number through git", err?.stderr?.toString());
try {
const content = fs.readFileSync(path.resolve(__dirname, "../internal/app/app.go"), "utf-8");
const matches = content.match(/AppVersion\s+=\s+"(.+?)"/);
if (matches) {
appVersion = matches[1];
console.info("[certimate] AppVersion is " + appVersion);
} else {
throw new Error("AppVersion not found in '/internal/app/app.go'");
}
} catch (err) {
throw new Error("Could not read app version: " + (err as Error).message);
}
return {