mirror of
https://github.com/certimate-go/certimate.git
synced 2026-09-24 23:10:13 +08:00
Merge pull request #960 from fudiwei/dev
This commit is contained in:
@@ -14,7 +14,34 @@ on:
|
||||
default: "latest"
|
||||
|
||||
jobs:
|
||||
prepare-ui:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22.19.0
|
||||
|
||||
- name: Build UI
|
||||
run: |
|
||||
echo "VITE_APP_VERSION=${GITHUB_REF#refs/tags/}" > ./ui/.env
|
||||
npm --prefix=./ui ci
|
||||
npm --prefix=./ui run build
|
||||
|
||||
- name: Upload UI build artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ui-build
|
||||
path: ./ui/dist
|
||||
retention-days: 1
|
||||
|
||||
build-and-push:
|
||||
needs: prepare-ui
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -52,15 +79,22 @@ 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: 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@v4
|
||||
with:
|
||||
name: ui-build
|
||||
path: ./ui/dist
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
# file: ./Dockerfile
|
||||
file: ./Dockerfile.gh
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
|
||||
@@ -77,9 +77,9 @@ 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: 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@v4
|
||||
@@ -91,6 +91,7 @@ jobs:
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
# file: ./Dockerfile.gh
|
||||
file: ./Dockerfile.gh
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
push: true
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,44 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
superusers, err := app.FindCollectionByNameOrId(core.CollectionNameSuperusers)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
records, err := app.FindAllRecords(superusers)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(records) == 0 {
|
||||
envUsername := strings.TrimSpace(os.Getenv("CERTIMATE_ADMIN_USERNAME"))
|
||||
if envUsername == "" {
|
||||
envUsername = "admin@certimate.fun"
|
||||
}
|
||||
|
||||
envPassword := strings.TrimSpace(os.Getenv("CERTIMATE_ADMIN_PASSWORD"))
|
||||
if envPassword == "" {
|
||||
envPassword = "1234567890"
|
||||
}
|
||||
|
||||
record := core.NewRecord(superusers)
|
||||
record.Set("email", envUsername)
|
||||
record.Set("password", envPassword)
|
||||
return app.Save(record)
|
||||
}
|
||||
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
tracer := NewTracer("(v0.3)1740050400")
|
||||
tracer.Printf("go ...")
|
||||
|
||||
// update collection `certificate`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("4szxr9x43tpj6np")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := collection.Fields.AddMarshaledJSONAt(4, []byte(`{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "plmambpz",
|
||||
"max": 100000,
|
||||
"min": 0,
|
||||
"name": "certificate",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := collection.Fields.AddMarshaledJSONAt(5, []byte(`{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "49qvwxcg",
|
||||
"max": 100000,
|
||||
"min": 0,
|
||||
"name": "privateKey",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := collection.Fields.AddMarshaledJSONAt(7, []byte(`{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "agt7n5bb",
|
||||
"max": 100000,
|
||||
"min": 0,
|
||||
"name": "issuerCertificate",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
// update collection `workflow`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("tovyif5ax6j62ur")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := collection.Fields.AddMarshaledJSONAt(6, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "awlphkfe",
|
||||
"maxSize": 5000000,
|
||||
"name": "content",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := collection.Fields.AddMarshaledJSONAt(7, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "g9ohkk5o",
|
||||
"maxSize": 5000000,
|
||||
"name": "draft",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
// update collection `workflow_output`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("bqnxb95f2cooowp")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := collection.Fields.AddMarshaledJSONAt(4, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "c2rm9omj",
|
||||
"maxSize": 5000000,
|
||||
"name": "node",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
tracer.Printf("done")
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,359 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
tracer := NewTracer("(v0.3)1742209200")
|
||||
tracer.Printf("go ...")
|
||||
|
||||
// create collection `workflow_logs`
|
||||
{
|
||||
jsonData := `{
|
||||
"createRule": null,
|
||||
"deleteRule": null,
|
||||
"fields": [
|
||||
{
|
||||
"autogeneratePattern": "[a-z0-9]{15}",
|
||||
"hidden": false,
|
||||
"id": "text3208210256",
|
||||
"max": 15,
|
||||
"min": 15,
|
||||
"name": "id",
|
||||
"pattern": "^[a-z0-9]+$",
|
||||
"presentable": false,
|
||||
"primaryKey": true,
|
||||
"required": true,
|
||||
"system": true,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"cascadeDelete": true,
|
||||
"collectionId": "tovyif5ax6j62ur",
|
||||
"hidden": false,
|
||||
"id": "relation3371272342",
|
||||
"maxSelect": 1,
|
||||
"minSelect": 0,
|
||||
"name": "workflowId",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "relation"
|
||||
},
|
||||
{
|
||||
"cascadeDelete": true,
|
||||
"collectionId": "qjp8lygssgwyqyz",
|
||||
"hidden": false,
|
||||
"id": "relation821863227",
|
||||
"maxSelect": 1,
|
||||
"minSelect": 0,
|
||||
"name": "runId",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "relation"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text157423495",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "nodeId",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text3227511481",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "nodeName",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "number2782324286",
|
||||
"max": null,
|
||||
"min": null,
|
||||
"name": "timestamp",
|
||||
"onlyInt": false,
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2599078931",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "level",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text3065852031",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "message",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "json2918445923",
|
||||
"maxSize": 0,
|
||||
"name": "data",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate2990389176",
|
||||
"name": "created",
|
||||
"onCreate": true,
|
||||
"onUpdate": false,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
}
|
||||
],
|
||||
"id": "pbc_1682296116",
|
||||
"indexes": [
|
||||
"CREATE INDEX ` + "`" + `idx_IOlpy6XuJ2` + "`" + ` ON ` + "`" + `workflow_logs` + "`" + ` (` + "`" + `workflowId` + "`" + `)",
|
||||
"CREATE INDEX ` + "`" + `idx_qVlTb2yl7v` + "`" + ` ON ` + "`" + `workflow_logs` + "`" + ` (` + "`" + `runId` + "`" + `)"
|
||||
],
|
||||
"listRule": null,
|
||||
"name": "workflow_logs",
|
||||
"system": false,
|
||||
"type": "base",
|
||||
"updateRule": null,
|
||||
"viewRule": null
|
||||
}`
|
||||
|
||||
collection := &core.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' created", collection.Name)
|
||||
}
|
||||
|
||||
// migrate data
|
||||
{
|
||||
workflowRuns, err := app.FindAllRecords("workflow_run")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, workflowRun := range workflowRuns {
|
||||
type dWorkflowRunLogRecord struct {
|
||||
Time string `json:"time"`
|
||||
Level string `json:"level"`
|
||||
Content string `json:"content"`
|
||||
Error string `json:"error"`
|
||||
}
|
||||
type dWorkflowRunLog struct {
|
||||
NodeId string `json:"nodeId"`
|
||||
NodeName string `json:"nodeName"`
|
||||
Records []dWorkflowRunLogRecord `json:"records"`
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
logs := make([]dWorkflowRunLog, 0)
|
||||
if err := workflowRun.UnmarshalJSONField("logs", &logs); err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("workflow_logs")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, log := range logs {
|
||||
for _, logRecord := range log.Records {
|
||||
record := core.NewRecord(collection)
|
||||
createdAt, _ := time.Parse(time.RFC3339, logRecord.Time)
|
||||
record.Set("workflowId", workflowRun.Get("workflowId"))
|
||||
record.Set("runId", workflowRun.Get("id"))
|
||||
record.Set("nodeId", log.NodeId)
|
||||
record.Set("nodeName", log.NodeName)
|
||||
record.Set("timestamp", createdAt.UnixMilli())
|
||||
record.Set("level", logRecord.Level)
|
||||
record.Set("message", strings.TrimSpace(logRecord.Content+" "+logRecord.Error))
|
||||
record.Set("created", createdAt)
|
||||
if err := app.Save(record); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("record #%s in collection '%s' updated", record.Id, collection.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update collection `workflow_run`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("workflow_run")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := collection.Fields.AddMarshaledJSONAt(6, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "json772177811",
|
||||
"maxSize": 5000000,
|
||||
"name": "detail",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
// migrate data
|
||||
{
|
||||
workflowRuns, err := app.FindAllRecords("workflow_run")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
workflowOutputs, err := app.FindAllRecords("workflow_output")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
type dWorkflowNode struct {
|
||||
Id string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Name string `json:"name"`
|
||||
Config map[string]any `json:"config,omitempty"`
|
||||
Inputs []map[string]any `json:"inputs,omitempty"`
|
||||
Outputs []map[string]any `json:"outputs,omitempty"`
|
||||
Next *dWorkflowNode `json:"next,omitempty"`
|
||||
Branches []*dWorkflowNode `json:"branches,omitempty"`
|
||||
Validated bool `json:"validated,omitempty"`
|
||||
}
|
||||
|
||||
for _, workflowRun := range workflowRuns {
|
||||
node := &dWorkflowNode{}
|
||||
for _, workflowOutput := range workflowOutputs {
|
||||
if workflowOutput.GetString("runId") != workflowRun.Get("id") {
|
||||
continue
|
||||
}
|
||||
|
||||
if err := workflowOutput.UnmarshalJSONField("node", node); err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if node.Type != "apply" {
|
||||
node = &dWorkflowNode{}
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if node.Id == "" {
|
||||
workflow, _ := app.FindRecordById("workflow", workflowRun.GetString("workflowId"))
|
||||
if workflow != nil {
|
||||
workflowRun.Set("detail", workflow.Get("content"))
|
||||
} else {
|
||||
workflowRun.Set("detail", make(map[string]any))
|
||||
}
|
||||
} else {
|
||||
workflow, _ := app.FindRecordById("workflow", workflowRun.GetString("workflowId"))
|
||||
if workflow != nil {
|
||||
rootNode := &dWorkflowNode{}
|
||||
if err := workflow.UnmarshalJSONField("content", rootNode); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rootNode.Next = node
|
||||
workflowRun.Set("detail", rootNode)
|
||||
} else {
|
||||
rootNode := &dWorkflowNode{
|
||||
Id: core.GenerateDefaultRandomId(),
|
||||
Type: "start",
|
||||
Name: "开始",
|
||||
Config: map[string]any{
|
||||
"trigger": "manual",
|
||||
},
|
||||
Next: node,
|
||||
Validated: true,
|
||||
}
|
||||
workflowRun.Set("detail", rootNode)
|
||||
}
|
||||
}
|
||||
|
||||
if err := app.Save(workflowRun); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("record #%s in collection '%s' updated", workflowRun.Id, workflowRun.Collection().Name)
|
||||
}
|
||||
}
|
||||
|
||||
// update collection `workflow_run`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("workflow_run")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.Fields.RemoveByName("logs")
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
tracer.Printf("done")
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
tracer := NewTracer("(v0.3)1742392800")
|
||||
tracer.Printf("go ...")
|
||||
|
||||
// update collection `access`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("4yzbv8urny5ja1e")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := collection.Fields.AddMarshaledJSONAt(2, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "hwy7m03o",
|
||||
"maxSelect": 1,
|
||||
"name": "provider",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "select",
|
||||
"values": [
|
||||
"1panel",
|
||||
"acmehttpreq",
|
||||
"akamai",
|
||||
"aliyun",
|
||||
"aws",
|
||||
"azure",
|
||||
"baiducloud",
|
||||
"baishan",
|
||||
"baotapanel",
|
||||
"byteplus",
|
||||
"cachefly",
|
||||
"cdnfly",
|
||||
"cloudflare",
|
||||
"cloudns",
|
||||
"cmcccloud",
|
||||
"ctcccloud",
|
||||
"cucccloud",
|
||||
"dnsla",
|
||||
"dogecloud",
|
||||
"dynv6",
|
||||
"edgio",
|
||||
"fastly",
|
||||
"gname",
|
||||
"gcore",
|
||||
"godaddy",
|
||||
"goedge",
|
||||
"huaweicloud",
|
||||
"jdcloud",
|
||||
"k8s",
|
||||
"local",
|
||||
"namecheap",
|
||||
"namedotcom",
|
||||
"namesilo",
|
||||
"ns1",
|
||||
"powerdns",
|
||||
"qiniu",
|
||||
"qingcloud",
|
||||
"rainyun",
|
||||
"safeline",
|
||||
"ssh",
|
||||
"tencentcloud",
|
||||
"ucloud",
|
||||
"upyun",
|
||||
"volcengine",
|
||||
"webhook",
|
||||
"westcn"
|
||||
]
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
tracer.Printf("done")
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
tracer := NewTracer("(v0.3)1742644800")
|
||||
tracer.Printf("go ...")
|
||||
|
||||
// update collection `workflow_run`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("qjp8lygssgwyqyz")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(7, []byte(`{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "hvebkuxw",
|
||||
"max": 20000,
|
||||
"min": 0,
|
||||
"name": "error",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
// update collection `workflow_output`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("bqnxb95f2cooowp")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(5, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "he4cceqb",
|
||||
"maxSize": 5000000,
|
||||
"name": "outputs",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
// update collection `workflow_logs`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("pbc_1682296116")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(7, []byte(`{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text3065852031",
|
||||
"max": 20000,
|
||||
"min": 0,
|
||||
"name": "message",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(8, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "json2918445923",
|
||||
"maxSize": 5000000,
|
||||
"name": "data",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
// update collection `access`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("4yzbv8urny5ja1e")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(2, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "hwy7m03o",
|
||||
"maxSelect": 1,
|
||||
"name": "provider",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "select",
|
||||
"values": [
|
||||
"1panel",
|
||||
"acmehttpreq",
|
||||
"akamai",
|
||||
"aliyun",
|
||||
"aws",
|
||||
"azure",
|
||||
"baiducloud",
|
||||
"baishan",
|
||||
"baotapanel",
|
||||
"byteplus",
|
||||
"cachefly",
|
||||
"cdnfly",
|
||||
"cloudflare",
|
||||
"cloudns",
|
||||
"cmcccloud",
|
||||
"ctcccloud",
|
||||
"cucccloud",
|
||||
"desec",
|
||||
"dnsla",
|
||||
"dogecloud",
|
||||
"dynv6",
|
||||
"edgio",
|
||||
"fastly",
|
||||
"gname",
|
||||
"gcore",
|
||||
"godaddy",
|
||||
"goedge",
|
||||
"huaweicloud",
|
||||
"jdcloud",
|
||||
"k8s",
|
||||
"local",
|
||||
"namecheap",
|
||||
"namedotcom",
|
||||
"namesilo",
|
||||
"ns1",
|
||||
"porkbun",
|
||||
"powerdns",
|
||||
"qiniu",
|
||||
"qingcloud",
|
||||
"rainyun",
|
||||
"safeline",
|
||||
"ssh",
|
||||
"tencentcloud",
|
||||
"ucloud",
|
||||
"upyun",
|
||||
"vercel",
|
||||
"volcengine",
|
||||
"webhook",
|
||||
"westcn"
|
||||
]
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
tracer.Printf("done")
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,182 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
tracer := NewTracer("(v0.3)1743264000")
|
||||
tracer.Printf("go ...")
|
||||
|
||||
// update collection `settings`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("dy6ccjb60spfy6p")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
records, err := app.FindRecordsByFilter(collection, "name='sslProvider'", "-created", 1, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(records) == 1 {
|
||||
record := records[0]
|
||||
|
||||
content := make(map[string]any)
|
||||
if err := record.UnmarshalJSONField("content", &content); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if provider, ok := content["provider"]; ok {
|
||||
if providerStr, ok := provider.(string); ok {
|
||||
if providerStr == "letsencrypt_staging" {
|
||||
content["provider"] = "letsencryptstaging"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if config, ok := content["config"]; ok {
|
||||
if configMap, ok := config.(map[string]any); ok {
|
||||
if _, ok := configMap["letsencrypt_staging"]; ok {
|
||||
configMap["letsencryptstaging"] = configMap["letsencrypt_staging"]
|
||||
delete(configMap, "letsencrypt_staging")
|
||||
}
|
||||
if _, ok := configMap["gts"]; ok {
|
||||
configMap["googletrustservices"] = configMap["gts"]
|
||||
delete(configMap, "gts")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
record.Set("content", content)
|
||||
if err := app.Save(record); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("record #%s in collection '%s' updated", record.Id, collection.Name)
|
||||
}
|
||||
}
|
||||
|
||||
// update collection `access`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("4yzbv8urny5ja1e")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := collection.Fields.AddMarshaledJSONAt(2, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "hwy7m03o",
|
||||
"maxSelect": 1,
|
||||
"name": "provider",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "select",
|
||||
"values": [
|
||||
"1panel",
|
||||
"acmehttpreq",
|
||||
"akamai",
|
||||
"aliyun",
|
||||
"aws",
|
||||
"azure",
|
||||
"baiducloud",
|
||||
"baishan",
|
||||
"baotapanel",
|
||||
"byteplus",
|
||||
"buypass",
|
||||
"cachefly",
|
||||
"cdnfly",
|
||||
"cloudflare",
|
||||
"cloudns",
|
||||
"cmcccloud",
|
||||
"ctcccloud",
|
||||
"cucccloud",
|
||||
"desec",
|
||||
"dnsla",
|
||||
"dogecloud",
|
||||
"dynv6",
|
||||
"edgio",
|
||||
"fastly",
|
||||
"gname",
|
||||
"gcore",
|
||||
"godaddy",
|
||||
"goedge",
|
||||
"googletrustservices",
|
||||
"huaweicloud",
|
||||
"jdcloud",
|
||||
"k8s",
|
||||
"letsencrypt",
|
||||
"letsencryptstaging",
|
||||
"local",
|
||||
"namecheap",
|
||||
"namedotcom",
|
||||
"namesilo",
|
||||
"ns1",
|
||||
"porkbun",
|
||||
"powerdns",
|
||||
"qiniu",
|
||||
"qingcloud",
|
||||
"rainyun",
|
||||
"safeline",
|
||||
"ssh",
|
||||
"sslcom",
|
||||
"tencentcloud",
|
||||
"ucloud",
|
||||
"upyun",
|
||||
"vercel",
|
||||
"volcengine",
|
||||
"webhook",
|
||||
"westcn",
|
||||
"zerossl"
|
||||
]
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
// update collection `acme_accounts`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("012d7abbod1hwvr")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
records, err := app.FindRecordsByFilter(collection, "ca='letsencrypt_staging' || ca='gts'", "-created", 0, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, record := range records {
|
||||
ca := record.GetString("ca")
|
||||
if ca == "letsencrypt_staging" {
|
||||
record.Set("ca", "letsencryptstaging")
|
||||
} else if ca == "gts" {
|
||||
record.Set("ca", "googletrustservices")
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
|
||||
if err := app.Save(record); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("record #%s in collection '%s' updated", record.Id, collection.Name)
|
||||
}
|
||||
}
|
||||
|
||||
tracer.Printf("done")
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
tracer := NewTracer("(v0.3)1744192800")
|
||||
tracer.Printf("go ...")
|
||||
|
||||
// update collection `access`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("4yzbv8urny5ja1e")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := collection.Fields.AddMarshaledJSONAt(2, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "hwy7m03o",
|
||||
"maxSelect": 1,
|
||||
"name": "provider",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "select",
|
||||
"values": [
|
||||
"1panel",
|
||||
"acmehttpreq",
|
||||
"akamai",
|
||||
"aliyun",
|
||||
"aws",
|
||||
"azure",
|
||||
"baiducloud",
|
||||
"baishan",
|
||||
"baotapanel",
|
||||
"byteplus",
|
||||
"buypass",
|
||||
"cachefly",
|
||||
"cdnfly",
|
||||
"cloudflare",
|
||||
"cloudns",
|
||||
"cmcccloud",
|
||||
"ctcccloud",
|
||||
"cucccloud",
|
||||
"desec",
|
||||
"dnsla",
|
||||
"dogecloud",
|
||||
"dynv6",
|
||||
"edgio",
|
||||
"fastly",
|
||||
"gname",
|
||||
"gcore",
|
||||
"godaddy",
|
||||
"goedge",
|
||||
"googletrustservices",
|
||||
"huaweicloud",
|
||||
"jdcloud",
|
||||
"k8s",
|
||||
"letsencrypt",
|
||||
"letsencryptstaging",
|
||||
"local",
|
||||
"namecheap",
|
||||
"namedotcom",
|
||||
"namesilo",
|
||||
"ns1",
|
||||
"porkbun",
|
||||
"powerdns",
|
||||
"qiniu",
|
||||
"qingcloud",
|
||||
"rainyun",
|
||||
"safeline",
|
||||
"ssh",
|
||||
"sslcom",
|
||||
"tencentcloud",
|
||||
"ucloud",
|
||||
"upyun",
|
||||
"vercel",
|
||||
"volcengine",
|
||||
"wangsu",
|
||||
"webhook",
|
||||
"westcn",
|
||||
"zerossl"
|
||||
]
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
tracer.Printf("done")
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
tracer := NewTracer("(v0.3)1744459000")
|
||||
tracer.Printf("go ...")
|
||||
|
||||
// update collection `access`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("4yzbv8urny5ja1e")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := collection.Fields.AddMarshaledJSONAt(2, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "hwy7m03o",
|
||||
"maxSelect": 1,
|
||||
"name": "provider",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "select",
|
||||
"values": [
|
||||
"1panel",
|
||||
"acmehttpreq",
|
||||
"akamai",
|
||||
"aliyun",
|
||||
"aws",
|
||||
"azure",
|
||||
"baiducloud",
|
||||
"baishan",
|
||||
"baotapanel",
|
||||
"bunny",
|
||||
"byteplus",
|
||||
"buypass",
|
||||
"cachefly",
|
||||
"cdnfly",
|
||||
"cloudflare",
|
||||
"cloudns",
|
||||
"cmcccloud",
|
||||
"ctcccloud",
|
||||
"cucccloud",
|
||||
"desec",
|
||||
"dnsla",
|
||||
"dogecloud",
|
||||
"dynv6",
|
||||
"edgio",
|
||||
"fastly",
|
||||
"gname",
|
||||
"gcore",
|
||||
"godaddy",
|
||||
"goedge",
|
||||
"googletrustservices",
|
||||
"huaweicloud",
|
||||
"jdcloud",
|
||||
"k8s",
|
||||
"letsencrypt",
|
||||
"letsencryptstaging",
|
||||
"local",
|
||||
"namecheap",
|
||||
"namedotcom",
|
||||
"namesilo",
|
||||
"ns1",
|
||||
"porkbun",
|
||||
"powerdns",
|
||||
"qiniu",
|
||||
"qingcloud",
|
||||
"rainyun",
|
||||
"safeline",
|
||||
"ssh",
|
||||
"sslcom",
|
||||
"tencentcloud",
|
||||
"ucloud",
|
||||
"upyun",
|
||||
"vercel",
|
||||
"volcengine",
|
||||
"wangsu",
|
||||
"webhook",
|
||||
"westcn",
|
||||
"zerossl"
|
||||
]
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
tracer.Printf("done")
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
tracer := NewTracer("(v0.3)1745308800")
|
||||
tracer.Printf("go ...")
|
||||
|
||||
// update collection `access`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("4yzbv8urny5ja1e")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add temp field `providerTmp`
|
||||
if err := collection.Fields.AddMarshaledJSONAt(3, []byte(`{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2024822322",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "providerTmp",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// copy `provider` to `providerTmp`
|
||||
if _, err := app.DB().NewQuery("UPDATE access SET providerTmp = provider").Execute(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove old field `provider`
|
||||
collection.Fields.RemoveById("hwy7m03o")
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"indexes": [
|
||||
"CREATE INDEX `+"`"+`idx_wkoST0j`+"`"+` ON `+"`"+`access`+"`"+` (`+"`"+`name`+"`"+`)"
|
||||
]
|
||||
}`), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// rename field `providerTmp` to `provider`
|
||||
if err := collection.Fields.AddMarshaledJSONAt(2, []byte(`{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2024822322",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "provider",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// rebuild indexes
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"indexes": [
|
||||
"CREATE INDEX `+"`"+`idx_wkoST0j`+"`"+` ON `+"`"+`access`+"`"+` (`+"`"+`name`+"`"+`)",
|
||||
"CREATE INDEX `+"`"+`idx_frh0JT1Aqx`+"`"+` ON `+"`"+`access`+"`"+` (`+"`"+`provider`+"`"+`)"
|
||||
]
|
||||
}`), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
tracer.Printf("done")
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
tracer := NewTracer("(v0.3)1745726400")
|
||||
tracer.Printf("go ...")
|
||||
|
||||
// update collection `access`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("4yzbv8urny5ja1e")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := collection.Fields.AddMarshaledJSONAt(4, []byte(`{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2859962647",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "reserve",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
// migrate data
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("4yzbv8urny5ja1e")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
records, err := app.FindAllRecords(collection)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, record := range records {
|
||||
changed := false
|
||||
|
||||
if record.GetString("provider") == "buypass" {
|
||||
record.Set("reserve", "ca")
|
||||
changed = true
|
||||
} else if record.GetString("provider") == "googletrustservices" {
|
||||
record.Set("reserve", "ca")
|
||||
changed = true
|
||||
} else if record.GetString("provider") == "sslcom" {
|
||||
record.Set("reserve", "ca")
|
||||
changed = true
|
||||
} else if record.GetString("provider") == "zerossl" {
|
||||
record.Set("reserve", "ca")
|
||||
changed = true
|
||||
}
|
||||
|
||||
if record.GetString("provider") == "webhook" {
|
||||
config := make(map[string]any)
|
||||
if err := record.UnmarshalJSONField("config", &config); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
config["method"] = "POST"
|
||||
config["headers"] = "Content-Type: application/json"
|
||||
record.Set("config", config)
|
||||
changed = true
|
||||
}
|
||||
|
||||
if changed {
|
||||
if err := app.Save(record); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("record #%s in collection '%s' updated", record.Id, collection.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tracer.Printf("done")
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
tracer := NewTracer("(v0.3)1747314000")
|
||||
tracer.Printf("go ...")
|
||||
|
||||
// migrate data
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("4yzbv8urny5ja1e")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
records, err := app.FindAllRecords(collection)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, record := range records {
|
||||
changed := false
|
||||
|
||||
if record.GetString("provider") == "goedge" {
|
||||
config := make(map[string]any)
|
||||
if err := record.UnmarshalJSONField("config", &config); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
config["apiRole"] = "user"
|
||||
record.Set("config", config)
|
||||
changed = true
|
||||
}
|
||||
|
||||
if changed {
|
||||
if err := app.Save(record); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("record #%s in collection '%s' updated", record.Id, collection.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tracer.Printf("done")
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
tracer := NewTracer("(v0.3)1747389600")
|
||||
tracer.Printf("go ...")
|
||||
|
||||
// update collection `certificate`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("4szxr9x43tpj6np")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := collection.Fields.AddMarshaledJSONAt(6, []byte(`{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text2910474005",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "issuerOrg",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
// migrate data
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("4yzbv8urny5ja1e")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
records, err := app.FindAllRecords(collection)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, record := range records {
|
||||
changed := false
|
||||
|
||||
if record.GetString("provider") == "1panel" {
|
||||
config := make(map[string]any)
|
||||
if err := record.UnmarshalJSONField("config", &config); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
config["apiVersion"] = "v1"
|
||||
record.Set("config", config)
|
||||
changed = true
|
||||
}
|
||||
|
||||
if changed {
|
||||
if err := app.Save(record); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("record #%s in collection '%s' updated", record.Id, collection.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tracer.Printf("done")
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"slices"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
tracer := NewTracer("(v0.3)1748178000")
|
||||
tracer.Printf("go ...")
|
||||
|
||||
// migrate data
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("4yzbv8urny5ja1e")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
records, err := app.FindAllRecords(collection)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
providersToUpdate := []string{
|
||||
"1panel",
|
||||
"baotapanel",
|
||||
"baotawaf",
|
||||
"cdnfly",
|
||||
"flexcdn",
|
||||
"goedge",
|
||||
"lecdn",
|
||||
"powerdns",
|
||||
"proxmoxve",
|
||||
"ratpanel",
|
||||
"safeline",
|
||||
}
|
||||
for _, record := range records {
|
||||
changed := false
|
||||
|
||||
if slices.Contains(providersToUpdate, record.GetString("provider")) {
|
||||
config := make(map[string]any)
|
||||
if err := record.UnmarshalJSONField("config", &config); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if config["apiUrl"] != nil {
|
||||
config["serverUrl"] = config["apiUrl"]
|
||||
delete(config, "apiUrl")
|
||||
record.Set("config", config)
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
|
||||
if changed {
|
||||
if err := app.Save(record); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("record #%s in collection '%s' updated", record.Id, collection.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tracer.Printf("done")
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
tracer := NewTracer("(v0.3)1748228400")
|
||||
tracer.Printf("go ...")
|
||||
|
||||
// update collection `certificate`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("4szxr9x43tpj6np")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(14, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "bool810050391",
|
||||
"name": "acmeRenewed",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "bool"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
tracer.Printf("done")
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
tracer := NewTracer("(v0.3)1748959200")
|
||||
tracer.Printf("go ...")
|
||||
|
||||
// migrate data
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("4yzbv8urny5ja1e")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
records, err := app.FindAllRecords(collection)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, record := range records {
|
||||
changed := false
|
||||
|
||||
if record.GetString("provider") == "ssh" {
|
||||
config := make(map[string]any)
|
||||
if err := record.UnmarshalJSONField("config", &config); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if config["authMethod"] == nil || config["authMethod"] == "" {
|
||||
if config["key"] != nil && config["key"] != "" {
|
||||
config["authMethod"] = "key"
|
||||
} else if config["password"] != nil && config["password"] != "" {
|
||||
config["authMethod"] = "password"
|
||||
} else {
|
||||
config["authMethod"] = "none"
|
||||
}
|
||||
record.Set("config", config)
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
|
||||
if changed {
|
||||
if err := app.Save(record); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("record #%s in collection '%s' updated", record.Id, collection.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tracer.Printf("done")
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
tracer := NewTracer("(v0.3)1750687200")
|
||||
tracer.Printf("go ...")
|
||||
|
||||
// update collection `workflow_run`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("qjp8lygssgwyqyz")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update collection data
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"indexes": [
|
||||
"CREATE INDEX `+"`"+`idx_7ZpfjTFsD2`+"`"+` ON `+"`"+`workflow_run`+"`"+` (`+"`"+`workflowId`+"`"+`)"
|
||||
]
|
||||
}`), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
// update collection `workflow_output`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("bqnxb95f2cooowp")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update collection data
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"indexes": [
|
||||
"CREATE INDEX `+"`"+`idx_BYoQPsz4my`+"`"+` ON `+"`"+`workflow_output`+"`"+` (`+"`"+`workflowId`+"`"+`)",
|
||||
"CREATE INDEX `+"`"+`idx_O9zxLETuxJ`+"`"+` ON `+"`"+`workflow_output`+"`"+` (`+"`"+`runId`+"`"+`)",
|
||||
"CREATE INDEX `+"`"+`idx_luac8Ul34G`+"`"+` ON `+"`"+`workflow_output`+"`"+` (`+"`"+`nodeId`+"`"+`)"
|
||||
]
|
||||
}`), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
// update collection `workflow_logs`
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("pbc_1682296116")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update collection data
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"indexes": [
|
||||
"CREATE INDEX `+"`"+`idx_IOlpy6XuJ2`+"`"+` ON `+"`"+`workflow_logs`+"`"+` (`+"`"+`workflowId`+"`"+`)",
|
||||
"CREATE INDEX `+"`"+`idx_qVlTb2yl7v`+"`"+` ON `+"`"+`workflow_logs`+"`"+` (`+"`"+`runId`+"`"+`)",
|
||||
"CREATE INDEX `+"`"+`idx_UL4tdCXNlA`+"`"+` ON `+"`"+`workflow_logs`+"`"+` (`+"`"+`nodeId`+"`"+`)"
|
||||
]
|
||||
}`), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
tracer.Printf("done")
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
tracer := NewTracer("(v0.3)1751961600")
|
||||
tracer.Printf("go ...")
|
||||
|
||||
// migrate data
|
||||
{
|
||||
workflows, err := app.FindAllRecords("workflow")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
type dWorkflowNode struct {
|
||||
Id string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Name string `json:"name"`
|
||||
Config map[string]any `json:"config,omitempty"`
|
||||
Inputs []map[string]any `json:"inputs,omitempty"`
|
||||
Outputs []map[string]any `json:"outputs,omitempty"`
|
||||
Next *dWorkflowNode `json:"next,omitempty"`
|
||||
Branches []*dWorkflowNode `json:"branches,omitempty"`
|
||||
Validated bool `json:"validated,omitempty"`
|
||||
}
|
||||
|
||||
deepChangeFn := func(node *dWorkflowNode) bool {
|
||||
stack := []*dWorkflowNode{node}
|
||||
|
||||
for len(stack) > 0 {
|
||||
current := stack[len(stack)-1]
|
||||
stack = stack[:len(stack)-1]
|
||||
|
||||
if current.Type == "deploy" {
|
||||
configMap := current.Config
|
||||
if configMap != nil {
|
||||
if provider, ok := configMap["provider"]; ok {
|
||||
if provider.(string) == "tencentcloud-eo" {
|
||||
if providerConfig, ok := configMap["providerConfig"]; ok {
|
||||
if providerConfigMap, ok := providerConfig.(map[string]any); ok {
|
||||
if _, ok := providerConfigMap["domain"]; ok {
|
||||
providerConfigMap["domains"] = providerConfigMap["domain"]
|
||||
delete(providerConfigMap, "domain")
|
||||
configMap["providerConfig"] = providerConfigMap
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if current.Next != nil {
|
||||
stack = append(stack, current.Next)
|
||||
}
|
||||
|
||||
if current.Branches != nil {
|
||||
for i := len(current.Branches) - 1; i >= 0; i-- {
|
||||
stack = append(stack, current.Branches[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
for _, workflow := range workflows {
|
||||
changed := false
|
||||
|
||||
rootNodeContent := &dWorkflowNode{}
|
||||
if err := workflow.UnmarshalJSONField("content", rootNodeContent); err != nil {
|
||||
return err
|
||||
} else {
|
||||
if deepChangeFn(rootNodeContent) {
|
||||
workflow.Set("content", rootNodeContent)
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
|
||||
rootNodeDraft := &dWorkflowNode{}
|
||||
if err := workflow.UnmarshalJSONField("draft", rootNodeDraft); err != nil {
|
||||
return err
|
||||
} else {
|
||||
if deepChangeFn(rootNodeDraft) {
|
||||
workflow.Set("draft", rootNodeDraft)
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
|
||||
if changed {
|
||||
err = app.Save(workflow)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("record #%s in collection '%s' updated", workflow.Id, workflow.Collection().Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tracer.Printf("done")
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -21,8 +23,10 @@ func init() {
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("dy6ccjb60spfy6p")
|
||||
if err != nil {
|
||||
return err
|
||||
} else if collection != nil {
|
||||
if !errors.Is(err, sql.ErrNoRows) {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if _, err := app.DB().NewQuery("DELETE FROM settings WHERE name = 'notifyChannels'").Execute(); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -44,10 +48,11 @@ func init() {
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("012d7abbod1hwvr")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := collection.Fields.AddMarshaledJSONAt(5, []byte(`{
|
||||
if !errors.Is(err, sql.ErrNoRows) {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := collection.Fields.AddMarshaledJSONAt(5, []byte(`{
|
||||
"exceptDomains": null,
|
||||
"hidden": false,
|
||||
"id": "url2424532088",
|
||||
@@ -58,10 +63,10 @@ func init() {
|
||||
"system": false,
|
||||
"type": "url"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
if err := collection.Fields.AddMarshaledJSONAt(6, []byte(`{
|
||||
if err := collection.Fields.AddMarshaledJSONAt(6, []byte(`{
|
||||
"exceptDomains": null,
|
||||
"hidden": false,
|
||||
"id": "url3632694140",
|
||||
@@ -72,10 +77,10 @@ func init() {
|
||||
"system": false,
|
||||
"type": "url"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
if err := collection.Fields.AddMarshaledJSONAt(3, []byte(`{
|
||||
if err := collection.Fields.AddMarshaledJSONAt(3, []byte(`{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "genxqtii",
|
||||
@@ -89,10 +94,10 @@ func init() {
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
if err := collection.Fields.AddMarshaledJSONAt(4, []byte(`{
|
||||
if err := collection.Fields.AddMarshaledJSONAt(4, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "1aoia909",
|
||||
"maxSize": 2000000,
|
||||
@@ -102,93 +107,94 @@ func init() {
|
||||
"system": false,
|
||||
"type": "json"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
records, err := app.FindAllRecords(collection)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, record := range records {
|
||||
changed := false
|
||||
deleted := false
|
||||
|
||||
resource := make(map[string]any)
|
||||
if err := record.UnmarshalJSONField("acmeAccount", &resource); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, ok := resource["body"]; ok {
|
||||
record.Set("acmeAcctUrl", resource["uri"].(string))
|
||||
record.Set("acmeAccount", resource["body"].(map[string]any))
|
||||
changed = true
|
||||
if err := app.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ca := record.GetString("ca")
|
||||
if strings.Contains(ca, "#") {
|
||||
record.Set("ca", strings.Split(ca, "#")[0])
|
||||
if access, err := app.FindRecordById("access", strings.Split(ca, "#")[1]); err != nil {
|
||||
deleted = true
|
||||
records, err := app.FindAllRecords(collection)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, record := range records {
|
||||
changed := false
|
||||
deleted := false
|
||||
|
||||
resource := make(map[string]any)
|
||||
if err := record.UnmarshalJSONField("acmeAccount", &resource); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, ok := resource["body"]; ok {
|
||||
record.Set("acmeAcctUrl", resource["uri"].(string))
|
||||
record.Set("acmeAccount", resource["body"].(map[string]any))
|
||||
changed = true
|
||||
}
|
||||
|
||||
ca := record.GetString("ca")
|
||||
if strings.Contains(ca, "#") {
|
||||
record.Set("ca", strings.Split(ca, "#")[0])
|
||||
if access, err := app.FindRecordById("access", strings.Split(ca, "#")[1]); err != nil {
|
||||
deleted = true
|
||||
} else {
|
||||
switch access.GetString("provider") {
|
||||
case "buypass":
|
||||
record.Set("acmeDirUrl", "https://api.buypass.com/acme/directory")
|
||||
changed = true
|
||||
|
||||
case "googletrustservices":
|
||||
record.Set("acmeDirUrl", "https://dv.acme-v02.api.pki.goog/directory")
|
||||
changed = true
|
||||
|
||||
case "sslcom":
|
||||
record.Set("acmeDirUrl", "https://acme.ssl.com/sslcom-dv-rsa")
|
||||
changed = true
|
||||
|
||||
case "zerossl":
|
||||
record.Set("acmeDirUrl", "https://acme.zerossl.com/v2/DV90")
|
||||
changed = true
|
||||
|
||||
case "acmeca":
|
||||
accessConfig := make(map[string]any)
|
||||
access.UnmarshalJSONField("config", &accessConfig)
|
||||
record.Set("acmeDirUrl", accessConfig["endpoint"].(string))
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch access.GetString("provider") {
|
||||
case "buypass":
|
||||
record.Set("acmeDirUrl", "https://api.buypass.com/acme/directory")
|
||||
switch ca {
|
||||
case "letsencrypt":
|
||||
record.Set("acmeDirUrl", "https://acme-v02.api.letsencrypt.org/directory")
|
||||
changed = true
|
||||
|
||||
case "googletrustservices":
|
||||
record.Set("acmeDirUrl", "https://dv.acme-v02.api.pki.goog/directory")
|
||||
changed = true
|
||||
|
||||
case "sslcom":
|
||||
record.Set("acmeDirUrl", "https://acme.ssl.com/sslcom-dv-rsa")
|
||||
changed = true
|
||||
|
||||
case "zerossl":
|
||||
record.Set("acmeDirUrl", "https://acme.zerossl.com/v2/DV90")
|
||||
changed = true
|
||||
|
||||
case "acmeca":
|
||||
accessConfig := make(map[string]any)
|
||||
access.UnmarshalJSONField("config", &accessConfig)
|
||||
record.Set("acmeDirUrl", accessConfig["endpoint"].(string))
|
||||
case "letsencryptstaging":
|
||||
record.Set("acmeDirUrl", "https://acme-staging-v02.api.letsencrypt.org/directory")
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch ca {
|
||||
case "letsencrypt":
|
||||
record.Set("acmeDirUrl", "https://acme-v02.api.letsencrypt.org/directory")
|
||||
changed = true
|
||||
|
||||
case "letsencryptstaging":
|
||||
record.Set("acmeDirUrl", "https://acme-staging-v02.api.letsencrypt.org/directory")
|
||||
changed = true
|
||||
if changed {
|
||||
if err := app.Save(record); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("record #%s in collection '%s' updated", record.Id, collection.Name)
|
||||
}
|
||||
|
||||
if deleted {
|
||||
if err := app.Delete(record); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("record #%s in collection '%s' deleted", record.Id, collection.Name)
|
||||
}
|
||||
}
|
||||
|
||||
if changed {
|
||||
if err := app.Save(record); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("record #%s in collection '%s' updated", record.Id, collection.Name)
|
||||
}
|
||||
|
||||
if deleted {
|
||||
if err := app.Delete(record); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tracer.Printf("record #%s in collection '%s' deleted", record.Id, collection.Name)
|
||||
}
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
tracer.Printf("collection '%s' updated", collection.Name)
|
||||
}
|
||||
|
||||
// update collection `access`
|
||||
@@ -198,8 +204,10 @@ func init() {
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("4yzbv8urny5ja1e")
|
||||
if err != nil {
|
||||
return err
|
||||
} else if collection != nil {
|
||||
if !errors.Is(err, sql.ErrNoRows) {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if _, err := app.DB().NewQuery("UPDATE access SET reserve = 'notif' WHERE reserve = 'notification'").Execute(); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -316,8 +324,10 @@ func init() {
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("4szxr9x43tpj6np")
|
||||
if err != nil {
|
||||
return err
|
||||
} else if collection != nil {
|
||||
if !errors.Is(err, sql.ErrNoRows) {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := collection.Fields.AddMarshaledJSONAt(1, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "by9hetqi",
|
||||
@@ -447,8 +457,10 @@ func init() {
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("tovyif5ax6j62ur")
|
||||
if err != nil {
|
||||
return err
|
||||
} else if collection != nil {
|
||||
if !errors.Is(err, sql.ErrNoRows) {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := collection.Fields.AddMarshaledJSONAt(3, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "vqoajwjq",
|
||||
@@ -615,8 +627,10 @@ func init() {
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("qjp8lygssgwyqyz")
|
||||
if err != nil {
|
||||
return err
|
||||
} else if collection != nil {
|
||||
if !errors.Is(err, sql.ErrNoRows) {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := collection.Fields.AddMarshaledJSONAt(1, []byte(`{
|
||||
"cascadeDelete": true,
|
||||
"collectionId": "tovyif5ax6j62ur",
|
||||
@@ -746,8 +760,10 @@ func init() {
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("bqnxb95f2cooowp")
|
||||
if err != nil {
|
||||
return err
|
||||
} else if collection != nil {
|
||||
if !errors.Is(err, sql.ErrNoRows) {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"indexes": [
|
||||
"CREATE INDEX `+"`"+`idx_BYoQPsz4my`+"`"+` ON `+"`"+`workflow_output`+"`"+` (`+"`"+`workflowRef`+"`"+`)",
|
||||
@@ -819,8 +835,10 @@ func init() {
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("pbc_1682296116")
|
||||
if err != nil {
|
||||
return err
|
||||
} else if collection != nil {
|
||||
if !errors.Is(err, sql.ErrNoRows) {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if field := collection.Fields.GetByName("level"); field != nil && field.Type() == "text" {
|
||||
if _, err := app.DB().NewQuery("UPDATE workflow_logs SET level = '-4' WHERE level = 'DEBUG'").Execute(); err != nil {
|
||||
return err
|
||||
@@ -1172,8 +1190,10 @@ func init() {
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("tovyif5ax6j62ur")
|
||||
if err != nil {
|
||||
return err
|
||||
} else if collection != nil {
|
||||
if !errors.Is(err, sql.ErrNoRows) {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
records, err := app.FindAllRecords(collection)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -1233,8 +1253,10 @@ func init() {
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("qjp8lygssgwyqyz")
|
||||
if err != nil {
|
||||
return err
|
||||
} else if collection != nil {
|
||||
if !errors.Is(err, sql.ErrNoRows) {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
records, err := app.FindAllRecords(collection)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -1277,8 +1299,10 @@ func init() {
|
||||
{
|
||||
collection, err := app.FindCollectionByNameOrId("bqnxb95f2cooowp")
|
||||
if err != nil {
|
||||
return err
|
||||
} else if collection != nil {
|
||||
if !errors.Is(err, sql.ErrNoRows) {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
records, err := app.FindAllRecords(collection)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,14 +11,10 @@ export interface AppDocumentLinkButtonProps {
|
||||
}
|
||||
|
||||
const AppDocumentLinkButton = ({ className, style, showIcon = true }: AppDocumentLinkButtonProps) => {
|
||||
const { i18n, t } = useTranslation();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleDocumentClick = () => {
|
||||
if (i18n.language.startsWith("en")) {
|
||||
window.open(APP_DOCUMENT_URL + "/en/", "_blank");
|
||||
} else {
|
||||
window.open(APP_DOCUMENT_URL, "_blank");
|
||||
}
|
||||
window.open(APP_DOCUMENT_URL, "_blank");
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
+13
-5
@@ -1,8 +1,16 @@
|
||||
export const APP_REPO_URL = "https://github.com/certimate-go/certimate";
|
||||
|
||||
export const APP_DOWNLOAD_URL = APP_REPO_URL + "/releases";
|
||||
|
||||
export const APP_DOCUMENT_URL = "https://docs.certimate.me";
|
||||
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_REPO_URL = "https://github.com/certimate-go/certimate";
|
||||
export const APP_DOWNLOAD_URL = APP_REPO_URL + "/releases";
|
||||
export let APP_DOCUMENT_URL = "https://docs.certimate.me";
|
||||
|
||||
i18next.on("languageChanged", (language) => {
|
||||
if (language.startsWith("zh")) {
|
||||
APP_DOCUMENT_URL = "https://docs.certimate.me";
|
||||
} else {
|
||||
APP_DOCUMENT_URL = "https://docs.certimate.me/en/";
|
||||
}
|
||||
});
|
||||
|
||||
@@ -57,5 +57,17 @@
|
||||
"settings.diagnostics.workflow_dispatcher.title": "Workflow dispatcher",
|
||||
"settings.diagnostics.workflow_dispatcher.statistics.concurrency": "Concurrency",
|
||||
"settings.diagnostics.workflow_dispatcher.statistics.pending": "Pending",
|
||||
"settings.diagnostics.workflow_dispatcher.statistics.processing": "Processing"
|
||||
"settings.diagnostics.workflow_dispatcher.statistics.processing": "Processing",
|
||||
|
||||
"settings.about.tab": "About",
|
||||
"settings.about.version.new": "New version available",
|
||||
"settings.about.socials.document": "Documentation",
|
||||
"settings.about.socials.github": "GitHub",
|
||||
"settings.about.socials.telegram": "Telegram",
|
||||
"settings.about.socials.donate": "Donate",
|
||||
"settings.about.feedback.title": "Help us improve Certimate",
|
||||
"settings.about.feedback.subtitle": "Tell us how to make Certimate work better for you.",
|
||||
"settings.about.feedback.button": "Give feedback",
|
||||
"settings.about.contributors.title": "Contributors",
|
||||
"settings.about.contributors.tips": "Thanks to all the people who have contributed to this project."
|
||||
}
|
||||
|
||||
@@ -57,5 +57,17 @@
|
||||
"settings.diagnostics.workflow_dispatcher.title": "工作流调度器",
|
||||
"settings.diagnostics.workflow_dispatcher.statistics.concurrency": "最大并发",
|
||||
"settings.diagnostics.workflow_dispatcher.statistics.pending": "等待运行",
|
||||
"settings.diagnostics.workflow_dispatcher.statistics.processing": "运行中"
|
||||
"settings.diagnostics.workflow_dispatcher.statistics.processing": "运行中",
|
||||
|
||||
"settings.about.tab": "关于",
|
||||
"settings.about.version.new": "有新版本可更新",
|
||||
"settings.about.socials.document": "文档",
|
||||
"settings.about.socials.github": "GitHub",
|
||||
"settings.about.socials.telegram": "Telegram",
|
||||
"settings.about.socials.donate": "捐赠",
|
||||
"settings.about.feedback.title": "帮助我们改进 Certimate",
|
||||
"settings.about.feedback.subtitle": "告诉我们如何让 Certimate 为你更好地服务。",
|
||||
"settings.about.feedback.button": "意见反馈",
|
||||
"settings.about.contributors.title": "贡献者",
|
||||
"settings.about.contributors.tips": "感谢所有贡献者对本项目做出的贡献。"
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import { isBrowserHappy } from "@/utils/browser";
|
||||
const ConsoleLayout = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const { i18n, t } = useTranslation();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { token: themeToken } = theme.useToken();
|
||||
|
||||
@@ -40,11 +40,7 @@ const ConsoleLayout = () => {
|
||||
};
|
||||
|
||||
const handleDocumentClick = () => {
|
||||
if (i18n.language.startsWith("zh")) {
|
||||
window.open(APP_DOCUMENT_URL, "_blank");
|
||||
} else {
|
||||
window.open(APP_DOCUMENT_URL + "/en/", "_blank");
|
||||
}
|
||||
window.open(APP_DOCUMENT_URL, "_blank");
|
||||
};
|
||||
|
||||
const handleGitHubClick = () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Outlet, useLocation, useNavigate } from "react-router-dom";
|
||||
import { IconBracketsAngle, IconDatabaseCog, IconPalette, IconPlugConnected, IconUserShield } from "@tabler/icons-react";
|
||||
import { IconBracketsAngle, IconDatabaseCog, IconInfoCircle, IconPalette, IconPlugConnected, IconUserShield } from "@tabler/icons-react";
|
||||
import { Menu } from "antd";
|
||||
|
||||
const Settings = () => {
|
||||
@@ -16,6 +16,7 @@ const Settings = () => {
|
||||
["ssl-provider", "settings.sslprovider.tab", <IconPlugConnected size="1em" />],
|
||||
["persistence", "settings.persistence.tab", <IconDatabaseCog size="1em" />],
|
||||
["diagnostics", "settings.diagnostics.tab", <IconBracketsAngle size="1em" />],
|
||||
["about", "settings.about.tab", <IconInfoCircle size="1em" />],
|
||||
] satisfies [string, string, React.ReactElement][];
|
||||
const [menuKey, setMenuKey] = useState<string>(() => location.pathname.split("/")[2]);
|
||||
useEffect(() => {
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { IconBook, IconBrandGithub, IconBrandTelegram, IconCoin, IconMessageChatbot } from "@tabler/icons-react";
|
||||
import { Badge, Button, Divider, List, Tooltip, Typography } from "antd";
|
||||
|
||||
import { APP_DOCUMENT_URL, APP_DOWNLOAD_URL, APP_REPO_URL, APP_VERSION } from "@/domain/app";
|
||||
import { useVersionChecker } from "@/hooks";
|
||||
|
||||
const SettingsAbout = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { hasUpdate } = useVersionChecker();
|
||||
|
||||
const handleDownloadClick = () => {
|
||||
window.open(APP_DOWNLOAD_URL, "_blank");
|
||||
};
|
||||
|
||||
const handleDocumentClick = () => {
|
||||
window.open(APP_DOCUMENT_URL, "_blank");
|
||||
};
|
||||
|
||||
const handleGithubClick = () => {
|
||||
window.open(APP_REPO_URL, "_blank");
|
||||
};
|
||||
|
||||
const handleTelegramClick = () => {
|
||||
window.open("https://t.me/+ZXphsppxUg41YmVl", "_blank");
|
||||
};
|
||||
|
||||
const handleDonateClick = () => {
|
||||
window.open("https://profile.ikit.fun/sponsors/", "_blank");
|
||||
};
|
||||
|
||||
const handleFeedbackClick = () => {
|
||||
window.open(APP_REPO_URL + "/issues", "_blank");
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2>Certimate</h2>
|
||||
<div className="mb-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<Typography.Text type="secondary">Version: {APP_VERSION}</Typography.Text>
|
||||
<Badge className="cursor-pointer" count={hasUpdate ? t("settings.about.version.new") : void 0} onClick={handleDownloadClick} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="mb-2 flex flex-wrap items-center gap-2">
|
||||
<Tooltip title={t("settings.about.socials.document")}>
|
||||
<Button type="text" icon={<IconBook size="1.5em" onClick={handleDocumentClick} />} />
|
||||
</Tooltip>
|
||||
<Tooltip title={t("settings.about.socials.github")}>
|
||||
<Button type="text" icon={<IconBrandGithub size="1.5em" onClick={handleGithubClick} />} />
|
||||
</Tooltip>
|
||||
<Tooltip title={t("settings.about.socials.telegram")}>
|
||||
<Button type="text" icon={<IconBrandTelegram size="1.5em" onClick={handleTelegramClick} />} />
|
||||
</Tooltip>
|
||||
<Tooltip title={t("settings.about.socials.donate")}>
|
||||
<Button type="text" icon={<IconCoin size="1.5em" onClick={handleDonateClick} />} />
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
<Divider />
|
||||
|
||||
<h2>{t("settings.about.contributors.title")}</h2>
|
||||
<div className="mb-4">
|
||||
<Typography.Text type="secondary">{t("settings.about.contributors.tips")}</Typography.Text>
|
||||
</div>
|
||||
<div className="mb-2">
|
||||
<img className="max-w-full" src="https://contrib.rocks/image?repo=certimate-go/certimate" alt="Contributors" />
|
||||
</div>
|
||||
|
||||
<Divider />
|
||||
|
||||
<div className="md:max-w-160">
|
||||
<List bordered>
|
||||
<List.Item extra={<Button onClick={handleFeedbackClick}>{t("settings.about.feedback.button")}</Button>}>
|
||||
<List.Item.Meta
|
||||
avatar={<IconMessageChatbot size="1.5em" />}
|
||||
title={t("settings.about.feedback.title")}
|
||||
description={t("settings.about.feedback.subtitle")}
|
||||
/>
|
||||
</List.Item>
|
||||
</List>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default SettingsAbout;
|
||||
@@ -306,7 +306,7 @@ const SettingsDiagnosticsWorkflowDispatcher = ({ className, style }: { className
|
||||
type Statistics = Awaited<ReturnType<typeof getWorkflowStats>>["data"];
|
||||
const [statistics, setStatistics] = useState<Statistics>();
|
||||
|
||||
const { loading } = useRequest(
|
||||
const { loading, cancel } = useRequest(
|
||||
() => {
|
||||
return getWorkflowStats();
|
||||
},
|
||||
@@ -318,6 +318,11 @@ const SettingsDiagnosticsWorkflowDispatcher = ({ className, style }: { className
|
||||
onSuccess: (res) => {
|
||||
setStatistics(res.data);
|
||||
},
|
||||
onError: () => {
|
||||
if (!statistics) {
|
||||
cancel();
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ export const getPocketBase = () => {
|
||||
pb.afterSend = (res, data) => {
|
||||
if (res.status === 401 && pb.authStore?.isValid) {
|
||||
pb.authStore.clear();
|
||||
location.reload();
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -9,6 +9,7 @@ import Dashboard from "@/pages/dashboard/Dashboard";
|
||||
import ErrorLayout from "@/pages/ErrorLayout";
|
||||
import Login from "@/pages/login/Login";
|
||||
import Settings from "@/pages/settings/Settings";
|
||||
import SettingsAbout from "@/pages/settings/SettingsAbout";
|
||||
import SettingsAccount from "@/pages/settings/SettingsAccount";
|
||||
import SettingsAppearance from "@/pages/settings/SettingsAppearance";
|
||||
import SettingsDiagnostics from "@/pages/settings/SettingsDiagnostics";
|
||||
@@ -87,6 +88,10 @@ export const router = createHashRouter([
|
||||
path: "/settings/diagnostics",
|
||||
element: <SettingsDiagnostics />,
|
||||
},
|
||||
{
|
||||
path: "/settings/about",
|
||||
element: <SettingsAbout />,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user