-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- feat(cli) add the
malagu.webpack.sourceMaploaderExclude
property …
…to ignore the warning message that the source map cannot be loaded - feat(cli) build and release code also generates the `malagu.yml` file to the `.malagu` directory, which can be ignored by the `codeUri` property of the function. The default is to ignore the upload of the `malagu.yml` file to prevent some private information Give way - feat(fc-adapter) adds the `codeUri` property configuration to the function, and the default value is to ignore the upload of the `malagu.yml` file - feat(scf-adapter) adds the `codeUri` property configuration to the function, and the default value is to ignore the upload of the `malagu.yml` file - feat(puppeteer) add @malagu/puppeteer component - feat(cli) add `puppeteer` application template - feat(mvc) adds the file view `FileView` to facilitate the implementation of file download related APIs. It also provides a simplified decorator `@File()`, and also provides `@Text()`, `@Json()` , `@Html()` decorator simplifies the ability to use different types of views
- Loading branch information
1 parent
e5780b3
commit 073c8a4
Showing
50 changed files
with
997 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
dev-packages/cli/templates/backend-app/src/home-controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
dev-packages/cli/templates/database-app/src/home-controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
dev-packages/cli/templates/puppeteer/.github/workflows/deploy.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Malagu Deploy | ||
|
||
on: push | ||
|
||
jobs: | ||
malagu-deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: '12' | ||
- uses: bahmutov/npm-install@v1 | ||
- run: npm run lint --if-present | ||
- run: npm test | ||
- if: ${{ github.ref == 'refs/heads/master' }} | ||
env: ${{ secrets }} | ||
run: npx malagu deploy -m prod | ||
- if: ${{ github.ref == 'refs/heads/pre' }} | ||
env: ${{ secrets }} | ||
run: npx malagu deploy -m pre | ||
- if: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/pre' }} | ||
env: ${{ secrets }} | ||
run: npx malagu deploy -m test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.DS_Store | ||
node_modules | ||
dist | ||
lib | ||
.malagu | ||
.env | ||
*.log | ||
.idea | ||
.metadata | ||
*.iml | ||
jdt.ls-java-project | ||
lerna-debug.log | ||
.nyc_output | ||
coverage | ||
errorShots | ||
.browser_modules | ||
**/docs/api | ||
package-backup.json | ||
.history | ||
.Trash-* | ||
packages/plugin/typedoc | ||
plugins | ||
.local-chromium |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "pwa-node", | ||
"request": "launch", | ||
"name": "malagu serve", | ||
"program": "${workspaceRoot}/node_modules/@malagu/cli/bin/malagu", | ||
"args": [ "serve" ], | ||
"cwd": "${workspaceFolder}", | ||
"sourceMaps": true, | ||
"env": { | ||
"NODE_ENV": "development" | ||
}, | ||
"smartStep": true, | ||
"internalConsoleOptions": "openOnSessionStart", | ||
"outputCapture": "std" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# 开发说明 | ||
|
||
## 安装依赖 | ||
|
||
以下使用 yarn 工具来说明,你也可以使用 npm。 | ||
|
||
```bash | ||
# 通过 malagu init 初始化应用的时候已经自动安装了依赖,所以你只需要安装你额外需要的依赖即可 | ||
|
||
$ yarn add xxxx | ||
``` | ||
|
||
## 本地运行 | ||
|
||
```shell | ||
# 启动本地服务,端口默认 3000 | ||
# 在终端中会输出本地服务的 URL 链接 | ||
|
||
$ yarn start # 或者执行 malagu serve 命令 | ||
``` | ||
|
||
## 构建部署 | ||
|
||
模板默认提供了四套隔离环境:本地(local)、测试(test)、预发(pre)、线上(prod)。每个环境对于这一个 malagu 配置文件(可选),类似 malagu-test.yml。而 malagu.yml 文件一般用于放所有环境的公共配置。第一次部署的时候可能会提示你填写相关云厂商 ak 信息。如果是 Vercel 云平台的模板,会提示你需要登录到 Vercel 平台。你也可以在项目通过 .env 提供云厂商的 ak 信息。 | ||
|
||
```bash | ||
|
||
$ yarn deploy # 部署到测试环境 | ||
$ yarn deploy:test # 部署到测试环境 | ||
$ yarn deploy:pre # 部署到预发环境 | ||
$ yarn deploy:prod # 部署到线上环境 | ||
|
||
``` | ||
|
||
## 关于 Malagu Framework | ||
|
||
Malagu 是基于 TypeScript 的 Serverless First、组件化、平台无关的渐进式应用框架。 | ||
|
||
|
||
### 特征 | ||
|
||
- 约定大于配置,零配置,开箱即用 | ||
- TypeScript 版 Spring Boot | ||
- Serverless First | ||
- 平台不锁定 | ||
- 支持前后端一体化,前端框架不锁定 | ||
- 支持微服务 | ||
- 组件化,渐进式 | ||
- 命令行工具插件化 | ||
- 依赖注入 | ||
- 面向切面编程(AOP) | ||
- 集成了流行的 ORM 框架,使用装饰器声明式事务管理 | ||
- 支持 OIDC 认证 | ||
- 支持 OAuth2 授权 | ||
- 使用 rxjs 管理状态 | ||
- 提供 REST 和 RPC 两种接口风格 | ||
|
||
Malagu 名字由来:在我的家乡,谐音“吗啦咕”是小石头的意思,小石头堆砌起来可以建成高楼大厦、道路桥梁,而 Malagu 组件编排可以实现千变万化的应用。 | ||
|
||
### 快速开始 | ||
|
||
```bash | ||
# 安装命令行工具 | ||
npm install -g yarn | ||
npm install -g @malagu/cli | ||
|
||
# 初始化 | ||
malagu init project-name | ||
cd project-name # 进入项目根目录 | ||
|
||
# 运行 | ||
malagu serve | ||
|
||
# 部署 | ||
malagu deploy | ||
``` | ||
|
||
### 文档 | ||
|
||
- [介绍](https://www.yuque.com/cellbang/malagu/puw7p0) | ||
- [快速开始](https://www.yuque.com/cellbang/malagu/qmq79k) | ||
- [命令行工具](https://www.yuque.com/cellbang/malagu/xbfpir) | ||
- [控制器](https://www.yuque.com/cellbang/malagu/cbgl7g) | ||
- [数据库操作](https://www.yuque.com/cellbang/malagu/ztbcwq) | ||
- [微服务](https://www.yuque.com/cellbang/malagu/wtiy6s) | ||
- [认证与授权](https://www.yuque.com/cellbang/malagu/qhl0km) | ||
- [云平台适配](https://www.yuque.com/cellbang/malagu/hh1mng) | ||
- [依赖注入](https://www.yuque.com/cellbang/malagu/fw025h) | ||
- [组件设计](https://www.yuque.com/cellbang/malagu/qaqomw) | ||
- [前端架构](https://www.yuque.com/cellbang/malagu/vl9wbw) | ||
- [React 开发](https://www.yuque.com/cellbang/malagu/fum7u8) | ||
- [前后端一体化开发](https://www.yuque.com/cellbang/malagu/fi6lxi) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
targets: | ||
- backend | ||
malagu: | ||
puppeteer: | ||
bucket: headless-lib # 指定存放 headless 相关二进制的 oss 的 Bucket 名称 headless-lib | ||
object: headless-lib.tar.gz # 指定存放 headless 相关二进制的 oss 的 objeck 名称,默认 headless-lib.tar.gz | ||
accessKeyId: xxxxxxxxxxxxxxxxxxxxxxxx # 指定能够访问存放 headless 相关二进制 accessKeyId,至少具有读该 Object 的权限 | ||
accessKeySecret: xxxxxxxxxxxxxxxxxxxxxx | ||
region: oss-cn-hangzhou # 指定存放 headless 相关二进制的 oss 的地域,建议与应用部署的地域一致 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "puppeteer", | ||
"keywords": [ | ||
"malagu-component" | ||
], | ||
"version": "0.0.0", | ||
"license": "MIT", | ||
"files": [ | ||
"lib", | ||
"src" | ||
], | ||
"dependencies": { | ||
"@malagu/mvc": "latest", | ||
"@malagu/puppeteer": "latest", | ||
"@malagu/fc-adapter": "latest" | ||
}, | ||
"devDependencies": { | ||
"@malagu/cli": "latest", | ||
"rimraf": "^2.6.3" | ||
}, | ||
"scripts": { | ||
"clean": "rimraf lib dist .malagu", | ||
"build": "malagu build", | ||
"start": "malagu serve", | ||
"deploy": "malagu deploy -m test", | ||
"deploy:test": "malagu deploy -m test", | ||
"deploy:pre": "malagu deploy -m pre", | ||
"deploy:prod": "malagu deploy -m prod" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
dev-packages/cli/templates/puppeteer/src/home-controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Controller, Get, Text } from '@malagu/mvc/lib/node'; | ||
|
||
@Controller() | ||
export class HomeController { | ||
|
||
@Get() | ||
@Text() | ||
home(): string { | ||
return 'Welcome to Malagu'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import './home-controller'; | ||
import './puppeteer-controller'; | ||
import { autoBind } from '@malagu/core'; | ||
|
||
export default autoBind(); |
26 changes: 26 additions & 0 deletions
26
dev-packages/cli/templates/puppeteer/src/puppeteer-controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Autowired } from '@malagu/core'; | ||
import { Context } from '@malagu/web/lib/node'; | ||
import { Controller, Get, Query, File } from '@malagu/mvc/lib/node'; | ||
import { BrowserProvider } from '@malagu/puppeteer'; | ||
|
||
@Controller() | ||
export class PuppeteerController { | ||
|
||
@Autowired(BrowserProvider) | ||
protected readonly browserProvider: BrowserProvider; | ||
|
||
@Get('screenshot') | ||
@File() | ||
async screenshot(@Query('url') url?: string) { | ||
const response = Context.getResponse(); | ||
response.attachment('download.png'); | ||
const browser = await this.browserProvider.provide(); | ||
const page = await browser.newPage(); | ||
try { | ||
await page.goto(url || 'https://baidu.com', { waitUntil: 'networkidle0' }); | ||
return await page.screenshot(); | ||
} finally { | ||
await page.close(); | ||
} | ||
} | ||
} |
Oops, something went wrong.