Skip to content

Commit

Permalink
feat: support privacy policy
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeuoly committed Dec 27, 2024
1 parent f2ff1ab commit 80f4d1c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmd/commandline/plugin/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/langgenius/dify-plugin-daemon/internal/types/entities/manifest_entities"
"github.com/langgenius/dify-plugin-daemon/internal/types/entities/plugin_entities"
"github.com/langgenius/dify-plugin-daemon/internal/utils/log"
"github.com/langgenius/dify-plugin-daemon/internal/utils/parser"
)

//go:embed templates/python/icon.svg
Expand Down Expand Up @@ -148,7 +149,8 @@ func (m model) createPlugin() {
Memory: 1024 * 1024 * 256, // 256MB
Permission: &permission,
},
Label: plugin_entities.NewI18nObject(m.subMenus[SUB_MENU_KEY_PROFILE].(profile).Name()),
Label: plugin_entities.NewI18nObject(m.subMenus[SUB_MENU_KEY_PROFILE].(profile).Name()),
Privacy: parser.ToPtr("PRIVACY.md"),
},
}

Expand Down Expand Up @@ -240,6 +242,12 @@ func (m model) createPlugin() {
return
}

// create PRIVACY.md
if err := writeFile(filepath.Join(pluginDir, "PRIVACY.md"), string(PRIVACY)); err != nil {
log.Error("failed to write PRIVACY file: %s", err)
return
}

err = createPythonEnvironment(
pluginDir,
manifest.Meta.Runner.Entrypoint,
Expand Down
3 changes: 3 additions & 0 deletions cmd/commandline/plugin/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ var README []byte

//go:embed templates/.env.example
var ENV_EXAMPLE []byte

//go:embed templates/PRIVACY.md
var PRIVACY []byte
3 changes: 3 additions & 0 deletions cmd/commandline/plugin/templates/PRIVACY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Privacy

!!! Please fill in the privacy policy of the plugin.
5 changes: 5 additions & 0 deletions cmd/commandline/plugin/templates/python/GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,8 @@ dify-plugin plugin package ./ROOT_DIRECTORY_OF_YOUR_PLUGIN
```

you will get a `plugin.difypkg` file, that's all, you can submit it to the Marketplace now, look forward to your Plugin being listed!
## User Privacy Policy
Please fill in the privacy policy of the plugin if you want to make it published on the Marketplace, refer to [PRIVACY.md](PRIVACY.md) for more details.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ type PluginDeclarationWithoutAdvancedFields struct {
Meta PluginMeta `json:"meta" yaml:"meta,omitempty" validate:"required"`
Tags []manifest_entities.PluginTag `json:"tags" yaml:"tags,omitempty" validate:"omitempty,dive,plugin_tag,max=128"`
CreatedAt time.Time `json:"created_at" yaml:"created_at,omitempty" validate:"required"`
Privacy *string `json:"privacy,omitempty" yaml:"privacy,omitempty" validate:"omitempty"`
}

func (p *PluginDeclarationWithoutAdvancedFields) UnmarshalJSON(data []byte) error {
Expand Down

0 comments on commit 80f4d1c

Please sign in to comment.