Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/serverless docs #153

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .template/frame/api/app/.jzero.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ gen:
{{ if or (has "serverless" .Features) (has "serverless_core" .Features) }}before:
- gorename {{ .Module }}/server {{ .Module }}/internal{{ end }}
after:
{{ if has "serverless" .Features }}- gorename {{ .Module }}/internal {{ .Module }}/server{{ end }}
{{ if or (has "serverless" .Features) (has "serverless_core" .Features) }}- gorename {{ .Module }}/internal {{ .Module }}/server{{ end }}
- jzero gen swagger

split-api-types-dir: true
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* 将 jzero 应用部署在 [Vercel](https://vercel.com), [模板仓库分支](https://github.com/jzero-io/templates/tree/api-vercel), [代码示例](https://github.com/jaronnie/go-serverless-vercel)
* 基于 git change 生成代码, 极大提升大型项目开发体验
* 基于 jzero 的[后台管理系统](https://github.com/jzero-io/jzero-admin), [演示地址1-部署在vercel](https://admin.jzero.io), [演示地址2-部署在阿里云函数计算](https://jzero-admin.jaronnie.com)
* 基于 jzero 的 [serverless](https://docs.jzero.io/guide/serverless.html) 特性, 实现多模块解藕, 在编译阶段实现第三方模块的自动依赖注入

中文 | [ENGLISH](README-EN.md)

Expand Down
7 changes: 1 addition & 6 deletions cmd/serverless.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ Copyright © 2024 jaronnie <[email protected]>
package cmd

import (
"os"
"path/filepath"

"github.com/spf13/cobra"

"github.com/jzero-io/jzero/config"
Expand Down Expand Up @@ -59,14 +56,12 @@ var serverlessDeleteCmd = &cobra.Command{
}

func init() {
wd, _ := os.Getwd()

rootCmd.AddCommand(serverlessCmd)
serverlessCmd.AddCommand(serverlessBuildCmd)
serverlessCmd.AddCommand(serverlessDeleteCmd)
serverlessCmd.AddCommand(serverlessNewCmd)

serverlessCmd.PersistentFlags().StringP("home", "", filepath.Join(wd, ".template"), "set templates path")
serverlessCmd.PersistentFlags().StringP("home", "", "", "set templates path")
serverlessNewCmd.Flags().BoolP("core", "", false, "is core serverless")
serverlessNewCmd.Flags().StringP("module", "m", "", "set go module")
serverlessNewCmd.Flags().StringP("remote", "r", "https://github.com/jzero-io/templates", "remote templates repo")
Expand Down
2 changes: 1 addition & 1 deletion docs/src/guide/new.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ docker run --rm -v ${PWD}:/app ghcr.io/jzero-io/jzero:latest new your_project --
```
:::

## 场景五: 命令行项目
## 场景四: 命令行项目

:::tip
基于 [cobra](https://github.com/spf13/cobra) 构建命令行项目
Expand Down
33 changes: 33 additions & 0 deletions docs/src/guide/serverless.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: serverless
icon: catppuccin:serverless
order: 3.5
---

## 新建 core 核心模块

```shell
jzero serverless new core --core
cd core
jzero gen
go mod tidy
```

## 新建业务模块

```shell
cd core
jzero serverless new b1
cd plugins/b1
jzero gen
go mod tidy
```

## 构建 serverless

```shell
cd core
jzero serverless build

go run main.go server
```
2 changes: 1 addition & 1 deletion docs/src/guide/template.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: 模版
title: 模版特性
icon: vscode-icons:folder-type-template
star: true
order: 5.3
Expand Down
Loading