-
-
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.
* cp fc-plugin to fc3-plugin * run bootstrap * feat(fc3-plugin): update to fc api v3 * fix(fc3-plugin): typo
- Loading branch information
1 parent
b56c982
commit a0cb0f2
Showing
20 changed files
with
1,050 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** @type {import('eslint').Linter.Config} */ | ||
module.exports = { | ||
extends: [ | ||
require.resolve('@malagu/component/configs/build.eslintrc.json') | ||
], | ||
parserOptions: { | ||
tsconfigRootDir: __dirname, | ||
project: 'compile.tsconfig.json' | ||
} | ||
}; |
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 @@ | ||
# Malagu - FC3 Plugin Component |
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,22 @@ | ||
{ | ||
"extends": "@malagu/component/configs/base.tsconfig.json", | ||
"compilerOptions": { | ||
"composite": true, | ||
"rootDir": "src", | ||
"outDir": "lib" | ||
}, | ||
"include": [ | ||
"src" | ||
], | ||
"references": [ | ||
{ | ||
"path": "../cloud-plugin/compile.tsconfig.json" | ||
}, | ||
{ | ||
"path": "../code-loader-plugin/compile.tsconfig.json" | ||
}, | ||
{ | ||
"path": "../../dev-packages/cli-common/compile.tsconfig.json" | ||
} | ||
] | ||
} |
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 @@ | ||
malagu: | ||
cloud: | ||
function: | ||
runtime: custom | ||
bootstrap: "${ startCommand ?: 'node backend/index.js'}" | ||
trigger: | ||
name: ${malagu.cloud.function.name}-${malagu.cloud.alias.name} | ||
qualifier: ${malagu.cloud.alias.name} | ||
triggerType: http | ||
triggerConfig: | ||
authType: anonymous | ||
methods: [GET, POST, PUT, DELETE, HEAD, PATCH] | ||
customDomain: | ||
name: ${env.MALAGU_DOMAIN || 'auto'} | ||
protocol: HTTP | ||
certConfig: | ||
# certName: xxx | ||
privateKey: "${ env.SSL_KEY ?: 'ssl/domain.key'}" | ||
certificate: "${ env.SSL_PEM ?: 'ssl/domain.pem'}" | ||
routeConfig: | ||
routes: | ||
- path: '/*' | ||
qualifier: ${malagu.cloud.alias.name} |
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,15 @@ | ||
malagu: | ||
cloud: | ||
function: | ||
runtime: nodejs14 | ||
trigger: | ||
name: ${malagu.cloud.function.name}-${malagu.cloud.alias.name}-mns_topic | ||
qualifier: ${malagu.cloud.alias.name} | ||
triggerType: mns_topic | ||
# invocationRole: acs:ram::123456:role/app-mns-role | ||
# sourceARN: acs:mns:cn-hangzhou:123456:/topics/test | ||
triggerConfig: | ||
# topicName: test-topic | ||
notifyContentFormat: JSON | ||
notifyStrategy: BACKOFF_RETRY | ||
# filterTag: foo |
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 @@ | ||
mode: "${currentMode|toObjects[.item in [ 'http', 'api-gateway', 'sample-http', 'timer', 'mns-topic', 'event']]|suffix('-mode') || 'http-mode'}" | ||
malagu: | ||
cloud: | ||
secure: true | ||
internal: false | ||
timeout: 600000 | ||
function: | ||
instanceConcurrency: 10 | ||
withoutCodeLimit: true |
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,22 @@ | ||
malagu: | ||
cloud: | ||
function: | ||
runtime: nodejs14 | ||
trigger: | ||
name: ${malagu.cloud.function.name}-${malagu.cloud.alias.name} | ||
qualifier: ${malagu.cloud.alias.name} | ||
triggerType: http | ||
triggerConfig: | ||
authType: anonymous | ||
methods: [GET, POST, PUT, DELETE, HEAD, PATCH] | ||
customDomain: | ||
name: ${env.MALAGU_DOMAIN || 'auto'} | ||
protocol: HTTP | ||
certConfig: | ||
# certName: xxx | ||
privateKey: "${ env.SSL_KEY ?: 'ssl/domain.key'}" | ||
certificate: "${ env.SSL_PEM ?: 'ssl/domain.pem'}" | ||
routeConfig: | ||
routes: | ||
- path: '/*' | ||
functionName: ${malagu.cloud.function.name} |
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,13 @@ | ||
malagu: | ||
cloud: | ||
function: | ||
runtime: nodejs14 | ||
trigger: | ||
name: ${malagu.cloud.function.name}-${malagu.cloud.alias.name}-timer | ||
qualifier: ${malagu.cloud.alias.name} | ||
triggerType: timer | ||
triggerConfig: | ||
payload: malagu-timer | ||
cronExpression: 0 */1 * * * * # every minute | ||
enable: true | ||
|
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 @@ | ||
malagu: | ||
cloud: | ||
name: alibaba cloud | ||
profilePath: alibaba/profile.yml | ||
regions: | ||
- cn-qingdao | ||
- cn-beijing | ||
- cn-zhangjiakou | ||
- cn-hangzhou | ||
- cn-shanghai | ||
- cn-shenzhen | ||
- cn-huhehaote | ||
- cn-hongkong | ||
- ap-southeast-1 | ||
- ap-southeast-2 | ||
- ap-northeast-1 | ||
- us-west-1 | ||
- us-east-1 | ||
- eu-central-1 | ||
- ap-south-1 |
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,54 @@ | ||
{ | ||
"name": "@malagu/fc3-plugin", | ||
"version": "2.49.12", | ||
"description": "", | ||
"dependencies": { | ||
"@alicloud/fc20230330": "^3.0.2", | ||
"@alicloud/openapi-client": "^0.4.6", | ||
"@alicloud/tea-util": "^1.4.7", | ||
"@malagu/cli-common": "2.49.12", | ||
"@malagu/cloud-plugin": "2.49.12", | ||
"@malagu/code-loader-plugin": "2.49.12", | ||
"axios": "^0.26.1", | ||
"chalk": "^4.1.0", | ||
"fs-extra": "^11.1.1", | ||
"jszip": "^3.7.1" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"keywords": [ | ||
"malagu-component", | ||
"malagu-plugin" | ||
], | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/cellbang/malagu.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/cellbang/malagu/issues" | ||
}, | ||
"homepage": "https://github.com/cellbang/malagu", | ||
"files": [ | ||
"lib", | ||
"src", | ||
"malagu.yml", | ||
"malagu-remote.yml", | ||
"malagu-http-mode.yml", | ||
"malagu-sample-http-mode.yml", | ||
"malagu-timer-mode.yml", | ||
"malagu-mns-topic-mode.yml" | ||
], | ||
"scripts": { | ||
"lint": "malagu-component lint", | ||
"build": "malagu-component build", | ||
"watch": "malagu-component watch", | ||
"clean": "malagu-component clean", | ||
"test": "malagu-component test:js" | ||
}, | ||
"devDependencies": { | ||
"@malagu/component": "2.49.12" | ||
}, | ||
"gitHead": "bbf636b21ea1a347affcc05a5f6f58b35bedef6d" | ||
} |
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,49 @@ | ||
import axios from 'axios'; | ||
const DOMAIN = 'http://domain.devsapp.net'; | ||
|
||
export interface Params { | ||
type: string; | ||
user: string; | ||
region: string; | ||
function: string; | ||
token?: string; | ||
} | ||
|
||
function checkRs(rs: any) { | ||
if (rs.Status !== 'Success') { | ||
throw new Error(rs.Body); | ||
} | ||
} | ||
|
||
function parseParams(params: Params) { | ||
const parsedParams = new URLSearchParams(); | ||
parsedParams.append('type', params.type); | ||
parsedParams.append('region', params.region); | ||
parsedParams.append('user', params.user); | ||
parsedParams.append('function', params.function); | ||
if (params.token) { | ||
parsedParams.append('token', params.token); | ||
} | ||
return parsedParams; | ||
} | ||
|
||
function getCommonHeaders() { | ||
return { 'Content-Type': 'application/x-www-form-urlencoded' }; | ||
} | ||
|
||
export async function token(params: Params) { | ||
const { data } = await axios.post(`${DOMAIN}/token`, parseParams(params), { headers: getCommonHeaders() }); | ||
checkRs(data.Response); | ||
return data.Response; | ||
} | ||
|
||
export async function domain(params: Params) { | ||
const { data } = await axios.post(`${DOMAIN}/domain`, parseParams(params), { headers: getCommonHeaders() }); | ||
checkRs(data.Response); | ||
return data.Response; | ||
} | ||
|
||
export async function verify(params: Params) { | ||
const { data } = await axios.post(`${DOMAIN}/verify`, parseParams(params), { headers: getCommonHeaders() }); | ||
return data.Response; | ||
} |
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,19 @@ | ||
import { BuildContext, PathUtil } from '@malagu/cli-common'; | ||
import { join } from 'path'; | ||
import { writeFile, ensureDir } from 'fs-extra'; | ||
import { CloudUtils } from '@malagu/cloud-plugin'; | ||
import { getCodeRootDir } from '@malagu/code-loader-plugin'; | ||
|
||
export default async (context: BuildContext) => { | ||
const { cfg } = context; | ||
const config = CloudUtils.getConfiguration(cfg); | ||
const codeRootDir = getCodeRootDir(PathUtil.getProjectDistPath(), config.function.codeUri); | ||
await ensureDir(codeRootDir); | ||
if (config.function?.runtime === 'custom') { | ||
const destDir = join(codeRootDir, 'bootstrap'); | ||
const bootstrap = config.function.bootstrap; | ||
await writeFile(destDir, `#!/bin/bash\n${bootstrap}`, { mode: 0o755 }); | ||
} | ||
delete config.function.bootstrap; | ||
|
||
}; |
Oops, something went wrong.