feat: init repo

This commit is contained in:
wss-git 2021-06-01 15:29:39 +08:00
commit fbc7d762df
35 changed files with 4643 additions and 0 deletions

36
.github/workflows/registry-publish.yml vendored Normal file
View File

@ -0,0 +1,36 @@
name: publish package to serverless-hub
on:
release:
types: [created]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- uses: actions/setup-node@v1
with:
node-version: 12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install requests
- name: NPM install
run: |
npm install --production
- name: Add publish file
run: |
wget https://serverless-registry.oss-cn-hangzhou.aliyuncs.com/publish-file/python3/hub-publish.py
ls
- name: Publish package
env:
publish_token: ${{ secrets.alibaba_registry_publish_token }}
run: |
ls
python hub-publish.py

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
node_modules
.s
.DS_Store
package-lock.json

8
.prettierrc.js Normal file
View File

@ -0,0 +1,8 @@
module.exports = {
printWidth: 150,
tabWidth: 2,
semi: true,
singleQuote: true,
trailingComma: 'all',
arrowParens: 'always',
};

7
.signore Normal file
View File

@ -0,0 +1,7 @@
node_modules
.s
tsconfig.json
LICENSE
package-lok.json
.prettierrc.js
.gitignore

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 Serverless Devs
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

1
README.md Normal file
View File

@ -0,0 +1 @@
## 组件说明

2660
doc/assets/css/main.css Normal file

File diff suppressed because it is too large Load Diff

BIN
doc/assets/images/icons.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 855 B

248
doc/assets/js/main.js Normal file

File diff suppressed because one or more lines are too long

1
doc/assets/js/search.js Normal file
View File

@ -0,0 +1 @@
window.searchData = {"kinds":{"128":"Class","512":"Constructor","1024":"Property","2048":"Method"},"rows":[{"id":0,"kind":128,"name":"default","url":"classes/default.html","classes":"tsd-kind-class"},{"id":1,"kind":512,"name":"constructor","url":"classes/default.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-overwrite","parent":"default"},{"id":2,"kind":2048,"name":"report","url":"classes/default.html#report","classes":"tsd-kind-method tsd-parent-kind-class","parent":"default"},{"id":3,"kind":2048,"name":"startExpress","url":"classes/default.html#startexpress","classes":"tsd-kind-method tsd-parent-kind-class","parent":"default"},{"id":4,"kind":2048,"name":"handlerInputs","url":"classes/default.html#handlerinputs","classes":"tsd-kind-method tsd-parent-kind-class","parent":"default"},{"id":5,"kind":2048,"name":"start","url":"classes/default.html#start","classes":"tsd-kind-method tsd-parent-kind-class","parent":"default"},{"id":6,"kind":2048,"name":"invoke","url":"classes/default.html#invoke","classes":"tsd-kind-method tsd-parent-kind-class","parent":"default"},{"id":7,"kind":1024,"name":"client","url":"classes/default.html#client","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected","parent":"default"},{"id":8,"kind":1024,"name":"inputs","url":"classes/default.html#inputs","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected","parent":"default"},{"id":9,"kind":2048,"name":"__getBasePath","url":"classes/default.html#__getbasepath","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"default"},{"id":10,"kind":2048,"name":"__doc","url":"classes/default.html#__doc","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"default"}],"index":{"version":"2.3.9","fields":["name","parent"],"fieldVectors":[["name/0",[0,0.426]],["parent/0",[]],["name/1",[1,20.794]],["parent/1",[0,0.041]],["name/2",[2,20.794]],["parent/2",[0,0.041]],["name/3",[3,20.794]],["parent/3",[0,0.041]],["name/4",[4,20.794]],["parent/4",[0,0.041]],["name/5",[5,20.794]],["parent/5",[0,0.041]],["name/6",[6,20.794]],["parent/6",[0,0.041]],["name/7",[7,20.794]],["parent/7",[0,0.041]],["name/8",[8,20.794]],["parent/8",[0,0.041]],["name/9",[9,20.794]],["parent/9",[0,0.041]],["name/10",[10,20.794]],["parent/10",[0,0.041]]],"invertedIndex":[["__doc",{"_index":10,"name":{"10":{}},"parent":{}}],["__getbasepath",{"_index":9,"name":{"9":{}},"parent":{}}],["client",{"_index":7,"name":{"7":{}},"parent":{}}],["constructor",{"_index":1,"name":{"1":{}},"parent":{}}],["default",{"_index":0,"name":{"0":{}},"parent":{"1":{},"2":{},"3":{},"4":{},"5":{},"6":{},"7":{},"8":{},"9":{},"10":{}}}],["handlerinputs",{"_index":4,"name":{"4":{}},"parent":{}}],["inputs",{"_index":8,"name":{"8":{}},"parent":{}}],["invoke",{"_index":6,"name":{"6":{}},"parent":{}}],["report",{"_index":2,"name":{"2":{}},"parent":{}}],["start",{"_index":5,"name":{"5":{}},"parent":{}}],["startexpress",{"_index":3,"name":{"3":{}},"parent":{}}]],"pipeline":[]}}

416
doc/classes/default.html Normal file
View File

@ -0,0 +1,416 @@
<!doctype html>
<html class="default no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>default | fc-local-invoke</title>
<meta name="description" content="Documentation for fc-local-invoke">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../assets/css/main.css">
<script async src="../assets/js/search.js" id="search-script"></script>
</head>
<body>
<header>
<div class="tsd-page-toolbar">
<div class="container">
<div class="table-wrap">
<div class="table-cell" id="tsd-search" data-index="../assets/js/search.json" data-base="..">
<div class="field">
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
<input id="tsd-search-field" type="text" />
</div>
<ul class="results">
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li>
</ul>
<a href="../index.html" class="title">fc-local-invoke</a>
</div>
<div class="table-cell" id="tsd-widgets">
<div id="tsd-filter">
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
<div class="tsd-filter-group">
<div class="tsd-select" id="tsd-filter-visibility">
<span class="tsd-select-label">All</span>
<ul class="tsd-select-list">
<li data-value="public">Public</li>
<li data-value="protected">Public/Protected</li>
<li data-value="private" class="selected">All</li>
</ul>
</div>
<input type="checkbox" id="tsd-filter-inherited" checked />
<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
<input type="checkbox" id="tsd-filter-externals" checked />
<label class="tsd-widget" for="tsd-filter-externals">Externals</label>
</div>
</div>
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
</div>
</div>
</div>
</div>
<div class="tsd-page-title">
<div class="container">
<ul class="tsd-breadcrumb">
<li>
<a href="../modules.html">fc-local-invoke</a>
</li>
<li>
<a href="default.html">default</a>
</li>
</ul>
<h1>Class default</h1>
</div>
</div>
</header>
<div class="container container-main">
<div class="row">
<div class="col-8 col-content">
<section class="tsd-panel tsd-hierarchy">
<h3>Hierarchy</h3>
<ul class="tsd-hierarchy">
<li>
<span class="tsd-signature-type">BaseComponent</span>
<ul class="tsd-hierarchy">
<li>
<span class="target">default</span>
</li>
</ul>
</li>
</ul>
</section>
<section class="tsd-panel-group tsd-index-group">
<h2>Index</h2>
<section class="tsd-panel tsd-index-panel">
<div class="tsd-index-content">
<section class="tsd-index-section ">
<h3>Constructors</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-constructor tsd-parent-kind-class tsd-is-overwrite"><a href="default.html#constructor" class="tsd-kind-icon">constructor</a></li>
</ul>
</section>
<section class="tsd-index-section tsd-is-inherited tsd-is-private-protected">
<h3>Properties</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected"><a href="default.html#client" class="tsd-kind-icon">client</a></li>
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected"><a href="default.html#inputs" class="tsd-kind-icon">inputs</a></li>
</ul>
</section>
<section class="tsd-index-section ">
<h3>Methods</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><a href="default.html#__doc" class="tsd-kind-icon">__doc</a></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><a href="default.html#__getbasepath" class="tsd-kind-icon">__get<wbr>Base<wbr>Path</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="default.html#handlerinputs" class="tsd-kind-icon">handler<wbr>Inputs</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="default.html#invoke" class="tsd-kind-icon">invoke</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="default.html#report" class="tsd-kind-icon">report</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="default.html#start" class="tsd-kind-icon">start</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="default.html#startexpress" class="tsd-kind-icon">start<wbr>Express</a></li>
</ul>
</section>
</div>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Constructors</h2>
<section class="tsd-panel tsd-member tsd-kind-constructor tsd-parent-kind-class tsd-is-overwrite">
<a name="constructor" class="tsd-anchor"></a>
<h3>constructor</h3>
<ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-class tsd-is-overwrite">
<li class="tsd-signature tsd-kind-icon">new default<span class="tsd-signature-symbol">(</span>props<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="default.html" class="tsd-signature-type" data-tsd-kind="Class">default</a></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<p>Overrides BaseComponent.constructor</p>
<ul>
<li>Defined in index.ts:28</li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>props: <span class="tsd-signature-type">any</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <a href="default.html" class="tsd-signature-type" data-tsd-kind="Class">default</a></h4>
</li>
</ul>
</section>
</section>
<section class="tsd-panel-group tsd-member-group tsd-is-inherited tsd-is-private-protected">
<h2>Properties</h2>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected">
<a name="client" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagProtected">Protected</span> client</h3>
<div class="tsd-signature tsd-kind-icon">client<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">any</span></div>
<aside class="tsd-sources">
<p>Inherited from BaseComponent.client</p>
<ul>
<li>Defined in common/base.ts:9</li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected">
<a name="inputs" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagProtected">Protected</span> inputs</h3>
<div class="tsd-signature tsd-kind-icon">inputs<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">any</span></div>
<aside class="tsd-sources">
<p>Inherited from BaseComponent.inputs</p>
</aside>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Methods</h2>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited">
<a name="__doc" class="tsd-anchor"></a>
<h3>__doc</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited">
<li class="tsd-signature tsd-kind-icon">__doc<span class="tsd-signature-symbol">(</span>projectName<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<p>Inherited from BaseComponent.__doc</p>
<ul>
<li>Defined in common/base.ts:34</li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> projectName: <span class="tsd-signature-type">string</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited">
<a name="__getbasepath" class="tsd-anchor"></a>
<h3>__get<wbr>Base<wbr>Path</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited">
<li class="tsd-signature tsd-kind-icon">__get<wbr>Base<wbr>Path<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<p>Inherited from BaseComponent.__getBasePath</p>
<ul>
<li>Defined in common/base.ts:21</li>
</ul>
</aside>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="handlerinputs" class="tsd-anchor"></a>
<h3>handler<wbr>Inputs</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">handler<wbr>Inputs<span class="tsd-signature-symbol">(</span>inputs<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">InputProps</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in index.ts:56</li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>inputs: <span class="tsd-signature-type">InputProps</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="invoke" class="tsd-anchor"></a>
<h3>invoke</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">invoke<span class="tsd-signature-symbol">(</span>inputs<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">InputProps</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in index.ts:197</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>event 函数本地调试</p>
</div>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>inputs: <span class="tsd-signature-type">InputProps</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="report" class="tsd-anchor"></a>
<h3>report</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">report<span class="tsd-signature-symbol">(</span>componentName<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, command<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, accountID<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span>, access<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in index.ts:33</li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>componentName: <span class="tsd-signature-type">string</span></h5>
</li>
<li>
<h5>command: <span class="tsd-signature-type">string</span></h5>
</li>
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> accountID: <span class="tsd-signature-type">string</span></h5>
</li>
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> access: <span class="tsd-signature-type">string</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="start" class="tsd-anchor"></a>
<h3>start</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">start<span class="tsd-signature-symbol">(</span>inputs<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">InputProps</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in index.ts:109</li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>http 函数本地调试</p>
</div>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>inputs: <span class="tsd-signature-type">InputProps</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="startexpress" class="tsd-anchor"></a>
<h3>start<wbr>Express</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">start<wbr>Express<span class="tsd-signature-symbol">(</span>app<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in index.ts:46</li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>app: <span class="tsd-signature-type">any</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
</li>
</ul>
</section>
</section>
</div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav class="tsd-navigation primary">
<ul>
<li class=" ">
<a href="../modules.html">Exports</a>
</li>
</ul>
</nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
</ul>
<ul class="current">
<li class="current tsd-kind-class">
<a href="default.html" class="tsd-kind-icon">default</a>
<ul>
<li class=" tsd-kind-constructor tsd-parent-kind-class tsd-is-overwrite">
<a href="default.html#constructor" class="tsd-kind-icon">constructor</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected">
<a href="default.html#client" class="tsd-kind-icon">client</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected">
<a href="default.html#inputs" class="tsd-kind-icon">inputs</a>
</li>
<li class=" tsd-kind-method tsd-parent-kind-class tsd-is-inherited">
<a href="default.html#__doc" class="tsd-kind-icon">__doc</a>
</li>
<li class=" tsd-kind-method tsd-parent-kind-class tsd-is-inherited">
<a href="default.html#__getbasepath" class="tsd-kind-icon">__get<wbr>Base<wbr>Path</a>
</li>
<li class=" tsd-kind-method tsd-parent-kind-class">
<a href="default.html#handlerinputs" class="tsd-kind-icon">handler<wbr>Inputs</a>
</li>
<li class=" tsd-kind-method tsd-parent-kind-class">
<a href="default.html#invoke" class="tsd-kind-icon">invoke</a>
</li>
<li class=" tsd-kind-method tsd-parent-kind-class">
<a href="default.html#report" class="tsd-kind-icon">report</a>
</li>
<li class=" tsd-kind-method tsd-parent-kind-class">
<a href="default.html#start" class="tsd-kind-icon">start</a>
</li>
<li class=" tsd-kind-method tsd-parent-kind-class">
<a href="default.html#startexpress" class="tsd-kind-icon">start<wbr>Express</a>
</li>
</ul>
</li>
</ul>
<ul class="after-current">
</ul>
</nav>
</div>
</div>
</div>
<footer class="with-border-bottom">
<div class="container">
<h2>Legend</h2>
<div class="tsd-legend-group">
<ul class="tsd-legend">
<li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li>
<li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited method</span></li>
</ul>
</div>
</div>
</footer>
<div class="container tsd-generator">
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
</div>
<div class="overlay"></div>
<script src="../assets/js/main.js"></script>
</body>
</html>

521
doc/doc.json Normal file
View File

@ -0,0 +1,521 @@
{
"id": 0,
"name": "fc-local-invoke",
"kind": 0,
"kindString": "Project",
"flags": {},
"originalName": "",
"children": [
{
"id": 1,
"name": "default",
"kind": 128,
"kindString": "Class",
"flags": {},
"children": [
{
"id": 2,
"name": "constructor",
"kind": 512,
"kindString": "Constructor",
"flags": {},
"signatures": [
{
"id": 3,
"name": "new default",
"kind": 16384,
"kindString": "Constructor signature",
"flags": {},
"parameters": [
{
"id": 4,
"name": "props",
"kind": 32768,
"kindString": "Parameter",
"flags": {},
"type": {
"type": "intrinsic",
"name": "any"
}
}
],
"type": {
"type": "reference",
"id": 1,
"name": "default"
},
"overwrites": {
"type": "reference",
"name": "BaseComponent.constructor"
}
}
],
"overwrites": {
"type": "reference",
"name": "BaseComponent.constructor"
}
},
{
"id": 23,
"name": "client",
"kind": 1024,
"kindString": "Property",
"flags": {
"isProtected": true
},
"sources": [
{
"fileName": "common/base.ts",
"line": 9,
"character": 20
}
],
"type": {
"type": "intrinsic",
"name": "any"
},
"inheritedFrom": {
"type": "reference",
"name": "BaseComponent.client"
}
},
{
"id": 24,
"name": "inputs",
"kind": 1024,
"kindString": "Property",
"flags": {
"isProtected": true
},
"type": {
"type": "intrinsic",
"name": "any"
},
"inheritedFrom": {
"type": "reference",
"name": "BaseComponent.inputs"
}
},
{
"id": 27,
"name": "__doc",
"kind": 2048,
"kindString": "Method",
"flags": {},
"sources": [
{
"fileName": "common/base.ts",
"line": 34,
"character": 9
}
],
"signatures": [
{
"id": 28,
"name": "__doc",
"kind": 4096,
"kindString": "Call signature",
"flags": {},
"parameters": [
{
"id": 29,
"name": "projectName",
"kind": 32768,
"kindString": "Parameter",
"flags": {
"isOptional": true
},
"type": {
"type": "intrinsic",
"name": "string"
}
}
],
"type": {
"type": "intrinsic",
"name": "string"
},
"inheritedFrom": {
"type": "reference",
"name": "BaseComponent.__doc"
}
}
],
"inheritedFrom": {
"type": "reference",
"name": "BaseComponent.__doc"
}
},
{
"id": 25,
"name": "__getBasePath",
"kind": 2048,
"kindString": "Method",
"flags": {},
"sources": [
{
"fileName": "common/base.ts",
"line": 21,
"character": 17
}
],
"signatures": [
{
"id": 26,
"name": "__getBasePath",
"kind": 4096,
"kindString": "Call signature",
"flags": {},
"type": {
"type": "intrinsic",
"name": "string"
},
"inheritedFrom": {
"type": "reference",
"name": "BaseComponent.__getBasePath"
}
}
],
"inheritedFrom": {
"type": "reference",
"name": "BaseComponent.__getBasePath"
}
},
{
"id": 14,
"name": "handlerInputs",
"kind": 2048,
"kindString": "Method",
"flags": {},
"sources": [
{
"fileName": "index.ts",
"line": 56,
"character": 21
}
],
"signatures": [
{
"id": 15,
"name": "handlerInputs",
"kind": 4096,
"kindString": "Call signature",
"flags": {},
"parameters": [
{
"id": 16,
"name": "inputs",
"kind": 32768,
"kindString": "Parameter",
"flags": {},
"type": {
"type": "reference",
"name": "InputProps"
}
}
],
"type": {
"type": "reference",
"typeArguments": [
{
"type": "intrinsic",
"name": "any"
}
],
"name": "Promise"
}
}
]
},
{
"id": 20,
"name": "invoke",
"kind": 2048,
"kindString": "Method",
"flags": {
"isPublic": true
},
"sources": [
{
"fileName": "index.ts",
"line": 197,
"character": 21
}
],
"signatures": [
{
"id": 21,
"name": "invoke",
"kind": 4096,
"kindString": "Call signature",
"flags": {},
"comment": {
"shortText": "event 函数本地调试",
"returns": "\n"
},
"parameters": [
{
"id": 22,
"name": "inputs",
"kind": 32768,
"kindString": "Parameter",
"flags": {},
"comment": {},
"type": {
"type": "reference",
"name": "InputProps"
}
}
],
"type": {
"type": "reference",
"typeArguments": [
{
"type": "intrinsic",
"name": "any"
}
],
"name": "Promise"
}
}
]
},
{
"id": 5,
"name": "report",
"kind": 2048,
"kindString": "Method",
"flags": {},
"sources": [
{
"fileName": "index.ts",
"line": 33,
"character": 14
}
],
"signatures": [
{
"id": 6,
"name": "report",
"kind": 4096,
"kindString": "Call signature",
"flags": {},
"parameters": [
{
"id": 7,
"name": "componentName",
"kind": 32768,
"kindString": "Parameter",
"flags": {},
"type": {
"type": "intrinsic",
"name": "string"
}
},
{
"id": 8,
"name": "command",
"kind": 32768,
"kindString": "Parameter",
"flags": {},
"type": {
"type": "intrinsic",
"name": "string"
}
},
{
"id": 9,
"name": "accountID",
"kind": 32768,
"kindString": "Parameter",
"flags": {
"isOptional": true
},
"type": {
"type": "intrinsic",
"name": "string"
}
},
{
"id": 10,
"name": "access",
"kind": 32768,
"kindString": "Parameter",
"flags": {
"isOptional": true
},
"type": {
"type": "intrinsic",
"name": "string"
}
}
],
"type": {
"type": "reference",
"typeArguments": [
{
"type": "intrinsic",
"name": "void"
}
],
"name": "Promise"
}
}
]
},
{
"id": 17,
"name": "start",
"kind": 2048,
"kindString": "Method",
"flags": {
"isPublic": true
},
"sources": [
{
"fileName": "index.ts",
"line": 109,
"character": 20
}
],
"signatures": [
{
"id": 18,
"name": "start",
"kind": 4096,
"kindString": "Call signature",
"flags": {},
"comment": {
"shortText": "http 函数本地调试",
"returns": "\n"
},
"parameters": [
{
"id": 19,
"name": "inputs",
"kind": 32768,
"kindString": "Parameter",
"flags": {},
"comment": {},
"type": {
"type": "reference",
"name": "InputProps"
}
}
],
"type": {
"type": "reference",
"typeArguments": [
{
"type": "intrinsic",
"name": "any"
}
],
"name": "Promise"
}
}
]
},
{
"id": 11,
"name": "startExpress",
"kind": 2048,
"kindString": "Method",
"flags": {},
"sources": [
{
"fileName": "index.ts",
"line": 46,
"character": 14
}
],
"signatures": [
{
"id": 12,
"name": "startExpress",
"kind": 4096,
"kindString": "Call signature",
"flags": {},
"parameters": [
{
"id": 13,
"name": "app",
"kind": 32768,
"kindString": "Parameter",
"flags": {},
"type": {
"type": "intrinsic",
"name": "any"
}
}
],
"type": {
"type": "intrinsic",
"name": "void"
}
}
]
}
],
"groups": [
{
"title": "Constructors",
"kind": 512,
"children": [
2
]
},
{
"title": "Properties",
"kind": 1024,
"children": [
23,
24
]
},
{
"title": "Methods",
"kind": 2048,
"children": [
27,
25,
14,
20,
5,
17,
11
]
}
],
"sources": [
{
"fileName": "index.ts",
"line": 28,
"character": 43
}
],
"extendedTypes": [
{
"type": "reference",
"name": "BaseComponent"
}
]
}
],
"groups": [
{
"title": "Classes",
"kind": 128,
"children": [
1
]
}
],
"sources": [
{
"fileName": "index.ts",
"line": 1,
"character": 0
}
]
}

132
doc/index.html Normal file
View File

@ -0,0 +1,132 @@
<!doctype html>
<html class="default no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>fc-local-invoke</title>
<meta name="description" content="Documentation for fc-local-invoke">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="assets/css/main.css">
<script async src="assets/js/search.js" id="search-script"></script>
</head>
<body>
<header>
<div class="tsd-page-toolbar">
<div class="container">
<div class="table-wrap">
<div class="table-cell" id="tsd-search" data-index="assets/js/search.json" data-base=".">
<div class="field">
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
<input id="tsd-search-field" type="text" />
</div>
<ul class="results">
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li>
</ul>
<a href="index.html" class="title">fc-local-invoke</a>
</div>
<div class="table-cell" id="tsd-widgets">
<div id="tsd-filter">
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
<div class="tsd-filter-group">
<div class="tsd-select" id="tsd-filter-visibility">
<span class="tsd-select-label">All</span>
<ul class="tsd-select-list">
<li data-value="public">Public</li>
<li data-value="protected">Public/Protected</li>
<li data-value="private" class="selected">All</li>
</ul>
</div>
<input type="checkbox" id="tsd-filter-inherited" checked />
<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
<input type="checkbox" id="tsd-filter-externals" checked />
<label class="tsd-widget" for="tsd-filter-externals">Externals</label>
</div>
</div>
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
</div>
</div>
</div>
</div>
<div class="tsd-page-title">
<div class="container">
<h1>fc-local-invoke</h1>
</div>
</div>
</header>
<div class="container container-main">
<div class="row">
<div class="col-8 col-content">
<div class="tsd-panel tsd-typography">
<a href="#组件说明" id="组件说明" style="color: inherit; text-decoration: none;">
<h2>组件说明</h2>
</a>
<p>fc-local-invoke 组件用于本地调试 FC 函数。</p>
<a href="#使用场景" id="使用场景" style="color: inherit; text-decoration: none;">
<h2>使用场景</h2>
</a>
<p>本地调试。</p>
<a href="#具体用法" id="具体用法" style="color: inherit; text-decoration: none;">
<h2>具体用法</h2>
</a>
<a href="#http-函数" id="http-函数" style="color: inherit; text-decoration: none;">
<h3>http 函数</h3>
</a>
<pre><code><span style="color: #001080">$</span><span style="color: #000000"> </span><span style="color: #001080">s</span><span style="color: #000000"> </span><span style="color: #001080">start</span><span style="color: #000000"> &lt;[</span><span style="color: #001080">customDomainName</span><span style="color: #000000">/]</span><span style="color: #001080">path</span><span style="color: #000000">&gt;</span>
</code></pre>
<p>本地启动成功后访问返回的 url 即可访问服务。</p>
<a href="#event-函数" id="event-函数" style="color: inherit; text-decoration: none;">
<h3>event 函数</h3>
</a>
<pre><code><span style="color: #001080">$</span><span style="color: #000000"> </span><span style="color: #001080">s</span><span style="color: #000000"> </span><span style="color: #001080">invoke</span><span style="color: #000000"> --</span><span style="color: #001080">mode</span><span style="color: #000000"> [</span><span style="color: #001080">api</span><span style="color: #000000">/</span><span style="color: #001080">normal</span><span style="color: #000000">/</span><span style="color: #001080">server</span><span style="color: #000000">]</span>
</code></pre>
<p>上述指令能够本地调试 event 函数,有三种启动模式:</p>
<ul>
<li><p>api 模式: 启动服务供本地 InvokeFunction API 或者 SDK 进行调用,详情请参见 <a href="https://help.aliyun.com/document_detail/191156.htm?spm=a2c4g.11186623.2.23.965d559fCBpJrO#doc-api-58601-InvokeFunction">invokeFunction</a><a href="https://help.aliyun.com/document_detail/53277.htm?spm=a2c4g.11186623.2.7.393e2a26lkwxgo#concept-2260089">SDK 列表</a></p>
</li>
<li><p>normal 模式: 本地通过容器调用 event 函数返回结果后,立刻关闭容器,此模式为默认模式。</p>
</li>
<li><p>server 模式: 本地启动一个容器,然后在新开的 terminal 窗口执行 normal 模式的 invoke 指令,则会复用该容器。</p>
</li>
</ul>
</div>
</div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav class="tsd-navigation primary">
<ul>
<li class=" ">
<a href="modules.html">Exports</a>
</li>
</ul>
</nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
<li class=" tsd-kind-class">
<a href="classes/default.html" class="tsd-kind-icon">default</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<footer class="with-border-bottom">
<div class="container">
<h2>Legend</h2>
<div class="tsd-legend-group">
<ul class="tsd-legend">
<li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li>
<li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited method</span></li>
</ul>
</div>
</div>
</footer>
<div class="container tsd-generator">
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
</div>
<div class="overlay"></div>
<script src="assets/js/main.js"></script>
</body>
</html>

112
doc/modules.html Normal file
View File

@ -0,0 +1,112 @@
<!doctype html>
<html class="default no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>fc-local-invoke</title>
<meta name="description" content="Documentation for fc-local-invoke">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="assets/css/main.css">
<script async src="assets/js/search.js" id="search-script"></script>
</head>
<body>
<header>
<div class="tsd-page-toolbar">
<div class="container">
<div class="table-wrap">
<div class="table-cell" id="tsd-search" data-index="assets/js/search.json" data-base=".">
<div class="field">
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
<input id="tsd-search-field" type="text" />
</div>
<ul class="results">
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li>
</ul>
<a href="index.html" class="title">fc-local-invoke</a>
</div>
<div class="table-cell" id="tsd-widgets">
<div id="tsd-filter">
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
<div class="tsd-filter-group">
<div class="tsd-select" id="tsd-filter-visibility">
<span class="tsd-select-label">All</span>
<ul class="tsd-select-list">
<li data-value="public">Public</li>
<li data-value="protected">Public/Protected</li>
<li data-value="private" class="selected">All</li>
</ul>
</div>
<input type="checkbox" id="tsd-filter-inherited" checked />
<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
<input type="checkbox" id="tsd-filter-externals" checked />
<label class="tsd-widget" for="tsd-filter-externals">Externals</label>
</div>
</div>
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
</div>
</div>
</div>
</div>
<div class="tsd-page-title">
<div class="container">
<h1>fc-local-invoke</h1>
</div>
</div>
</header>
<div class="container container-main">
<div class="row">
<div class="col-8 col-content">
<section class="tsd-panel-group tsd-index-group">
<h2>Index</h2>
<section class="tsd-panel tsd-index-panel">
<div class="tsd-index-content">
<section class="tsd-index-section ">
<h3>Classes</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-class"><a href="classes/default.html" class="tsd-kind-icon">default</a></li>
</ul>
</section>
</div>
</section>
</section>
</div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav class="tsd-navigation primary">
<ul>
<li class="current ">
<a href="modules.html">Exports</a>
</li>
</ul>
</nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
<li class=" tsd-kind-class">
<a href="classes/default.html" class="tsd-kind-icon">default</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<footer class="with-border-bottom">
<div class="container">
<h2>Legend</h2>
<div class="tsd-legend-group">
<ul class="tsd-legend">
<li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li>
<li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited method</span></li>
</ul>
</div>
</div>
</footer>
<div class="container tsd-generator">
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
</div>
<div class="overlay"></div>
<script src="assets/js/main.js"></script>
</body>
</html>

View File

@ -0,0 +1,29 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId>
<artifactId>event-java</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>event-java</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.aliyun.fc.runtime</groupId>
<artifactId>fc-java-core</artifactId>
<version>1.3.0</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.test.skip>true</maven.test.skip>
</properties>
</project>

View File

@ -0,0 +1,26 @@
package example;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import com.aliyun.fc.runtime.Context;
import com.aliyun.fc.runtime.StreamRequestHandler;
import com.aliyun.fc.runtime.FunctionInitializer;
/**
* Hello world!
*
*/
public class App implements StreamRequestHandler, FunctionInitializer {
public void initialize(Context context) throws IOException {
//TODO
}
@Override
public void handleRequest(
InputStream inputStream, OutputStream outputStream, Context context) throws IOException {
outputStream.write(new String("hello world\n").getBytes());
}
}

View File

@ -0,0 +1,25 @@
edition: 1.0.0 # 命令行YAML规范版本遵循语义化版本Semantic Versioning规范
name: fcDeployApp # 项目名称
access: default # 秘钥别名
services:
fc-deploy-test: # 服务名称
component: ${path(../..)}
props: # 组件的属性值
region: cn-shanghai
service:
name: demo
description: demo for fc-deploy component
internetAccess: true
function:
name: test-function
description: this is a test
runtime: java11
codeUri: ./code
handler: example.App::handleRequest
memorySize: 128
timeout: 60
instanceConcurrency: 1
instanceType: e1
environmentVariables:
testEnv: true

View File

@ -0,0 +1,6 @@
module.exports.handler = function(event, context, callback) {
console.log(event.toString());
// console.dir(context);
console.log('hello world11111');
callback(null, 'hello world');
};

View File

@ -0,0 +1,4 @@
{
"key": 123,
"mm": "gg"
}

View File

@ -0,0 +1,25 @@
edition: 1.0.0 # 命令行YAML规范版本遵循语义化版本Semantic Versioning规范
name: fcDeployApp # 项目名称
access: default # 秘钥别名
services:
fc-deploy-test: # 服务名称
component: ${path(../..)}
props: # 组件的属性值
region: cn-shanghai
service:
name: demo
description: demo for fc-deploy component
internetAccess: true
function:
name: test-function
description: this is a test
runtime: nodejs10
codeUri: ./code
handler: index.handler
memorySize: 128
timeout: 60
instanceConcurrency: 1
instanceType: e1
environmentVariables:
testEnv: true

View File

@ -0,0 +1,34 @@
const getRawBody = require('raw-body');
module.exports.handler = function (request, response, context) {
// get requset header
const reqHeader = request.headers;
let headerStr = ' ';
for (const key in reqHeader) {
headerStr += `${key }:${ reqHeader[key] } `;
}
// get request info
const { url } = request;
const { path } = request;
const { queries } = request;
let queryStr = '';
for (const param in queries) {
queryStr += `${param }=${ queries[param] } `;
}
const { method } = request;
const { clientIP } = request;
// get request body
getRawBody(request, (err, data) => {
const body = data;
// you can deal with your own logic here
// set response
const respBody = new Buffer(`requestHeader:${ headerStr }\n` + `url: ${ url }\n` + `path: ${ path }\n` + `queries: ${ queryStr }\n` + `method: ${ method }\n` + `clientIP: ${ clientIP }\n` + `body: ${ body }\n`);
response.setStatusCode(200);
response.setHeader('content-type', 'application/json');
response.send(respBody);
});
};

View File

@ -0,0 +1,47 @@
edition: 1.0.0 # 命令行YAML规范版本遵循语义化版本Semantic Versioning规范
name: fcDeployApp # 项目名称
access: default # 秘钥别名
services:
fc-deploy-test: # 服务名称
component: ${path(../..)}
props: # 组件的属性值
region: cn-shanghai
service:
name: qianfeng-fc-deploy-service
description: demo for fc-deploy component
internetAccess: true
function:
name: test-function
description: this is a test
runtime: nodejs10
codeUri: ./code
handler: index.handler
memorySize: 128
timeout: 60
instanceConcurrency: 1
instanceType: e1
environmentVariables:
testEnv: true
triggers:
- name: httpTrigger
type: http
config:
authType: anonymous
methods:
- GET
- POST
customDomains:
- domainName: auto
protocol: HTTP # HTTP 或 HTTP,HTTPS
routeConfigs:
- path: /*
serviceName: qianfeng-fc-deploy-service
functionName: test-function
methods:
- GET
- POST
# certConfig:
# certName: xxx
# certificate: xxx
# privateKey: xxx

8
example/main.ts Normal file
View File

@ -0,0 +1,8 @@
const a = [
{a: 1, b:2},
{a: 2, b:3},
{a: 1, b:111},
]
const b = a.filter((aa) => aa.a === 1);
console.log(b);

13
example/s.yaml Normal file
View File

@ -0,0 +1,13 @@
edition: 1.0.0 # 命令行YAML规范版本遵循语义化版本Semantic Versioning规范
name: compoent-test # 项目名称
vars: # [全局变量,提供给各个服务使用]
logo: https://image.aliyun.com/xxxx.png
domain: xxxx.yyy.com
services:
component-test: # 服务名称
component: ${path(..)} # 这里引入的是相对路径正式配置替换成你自己的component名称即可
props:
name: ${component-test2.props.name}
otherInput: ${component-test2.output.hello}
envshow: ${env(USER)}

3
locales/en.json Normal file
View File

@ -0,0 +1,3 @@
{
"deploy test": "deploy test"
}

4
locales/zh.json Normal file
View File

@ -0,0 +1,4 @@
{
"deploy test": "部署测试"
}

48
package.json Normal file
View File

@ -0,0 +1,48 @@
{
"name": "fc-remote-invoke",
"version": "0.0.1",
"description": "This is a component demo for Serverless Devs Tool ",
"keywords": [
"Serverless",
"Framework",
"Serverless-Devs",
"Serverless-Tool",
"Function Compute"
],
"homepage": "https://www.serverless-devs.com",
"author": "Serverless-Devs",
"contributors": [],
"license": "MIT",
"main": "./lib/index.js",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/ServerlessTool/express-alibaba"
},
"scripts": {
"start": "npm run watch",
"watch": "npm run doc && tsc -w",
"publish": "npm run build && s cli platform publish",
"build": "tsc",
"postbuild": "npm run doc",
"doc": "npx typedoc src/index.ts --json doc/doc.json --out doc"
},
"dependencies": {
"@alicloud/fc2": "^2.2.2",
"@serverless-devs/core": "^0.0.*",
"i18n": "^0.13.2",
"lodash.get": "^4.4.2"
},
"devDependencies": {
"@types/lodash": "^4.14.168",
"@types/node": "^14.0.23",
"@typescript-eslint/eslint-plugin": "^3.10.0",
"@typescript-eslint/parser": "^3.10.0",
"eslint": "^7.7.0",
"ts-node": "^8.10.2",
"typedoc": "^0.20.35",
"typescript": "^3.9.7"
}
}

10
publish.yaml Normal file
View File

@ -0,0 +1,10 @@
Type: Component
Name: fc-remote-invoke
Provider:
- 其它
Version: 0.0.1
Description: 初始化component模板
HomePage: https://www.serverless-devs.com
Tags: #标签详情
- 模板
Category: 其它

43
src/common/i18n.ts Normal file
View File

@ -0,0 +1,43 @@
import os from 'os';
import fs from 'fs';
import path from 'path';
import yaml from 'js-yaml';
import { I18n } from 'i18n';
export function getConfig(key: string): any {
const profile = getProfileFile();
return profile[key];
}
export function getProfileFile() {
let profileResult = {}
try {
const profileFilePath = getDefaultProfilePath();
profileResult = yaml.load(fs.readFileSync(profileFilePath, 'utf8')) || {};
} catch (e) {
console.log(e);
}
return profileResult;
}
export function getDefaultProfilePath(): string {
return path.join(os.homedir(), '.s', 'set-config.yml');
}
const i18n = new I18n({
locales: ['en', 'zh'],
directory: path.join(__dirname, '..', '..', 'locales'),
});
const locale = getConfig('locale');
if (locale) {
i18n.setLocale(locale);
} else {
i18n.setLocale('en');
}
export default i18n;

37
src/common/logger.ts Normal file
View File

@ -0,0 +1,37 @@
import i18n from './i18n';
import { Logger } from '@serverless-devs/core';
export default class ComponentLogger {
static CONTENT = 'FC-REMOTE-INVOKE';
static setContent(content) {
ComponentLogger.CONTENT = content;
}
static log(m, color?: 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'whiteBright' | 'gray') {
Logger.log(i18n.__(m) || m, color);
}
static info(m) {
Logger.info(ComponentLogger.CONTENT, i18n.__(m) || m);
}
static debug(m) {
Logger.debug(ComponentLogger.CONTENT, i18n.__(m) || m);
}
static error(m) {
Logger.error(ComponentLogger.CONTENT, i18n.__(m) || m);
}
static warning(m) {
Logger.warn(ComponentLogger.CONTENT, i18n.__(m) || m);
}
static success(m) {
Logger.log(i18n.__(m) || m, 'green');
}
}

75
src/index.ts Normal file
View File

@ -0,0 +1,75 @@
import logger from './common/logger';
import _ from 'lodash';
import * as core from '@serverless-devs/core';
export default class FcRemoteInvoke {
async report(componentName: string, command: string, accountID?: string, access?: string): Promise<void> {
let uid: string = accountID;
if (_.isEmpty(accountID)) {
const credentials = await core.getCredential(access);
uid = credentials.AccountID;
}
core.reportComponent(componentName, {
command,
uid,
});
}
async handlerInputs(inputs): Promise<any> {
const project = inputs?.project;
const properties = inputs?.props;
const access: string = project?.access;
const appName: string = inputs?.appName;
const credentials = await core.getCredential(access);
// 去除 args 的行首以及行尾的空格
const args: string = inputs?.args.replace(/(^\s*)|(\s*$)/g, '');
const curPath: any = inputs?.path;
const projectName: string = project?.projectName;
const { region } = properties;
if (args?.includes('help')) {
return {
region,
credentials,
curPath,
args,
access,
};
}
return {};
}
/**
* event
* @param inputs
* @returns
*/
public async invoke(inputs): Promise<any> {
const {
args,
credentials
} = await this.handlerInputs(inputs);
await this.report('fc-remote-invoke', 'invoke', credentials?.AccountID);
const parsedArgs: {[key: string]: any} = core.commandParse({ args }, {
boolean: ['debug'],
alias: { 'help': 'h',
'config': 'c',
'mode': 'm',
'event': 'e',
'event-file': 'f',
'event-stdin': 's',
'debug-port': 'd'
}
});
const argsData: any = parsedArgs?.data || {};
if (argsData.help) {
// TODO: help info
return;
}
return {};
}
}

38
tsconfig.json Normal file
View File

@ -0,0 +1,38 @@
{
"compileOnSave": true,
"compilerOptions": {
"esModuleInterop": true,
"resolveJsonModule": true,
"lib": [
"es2015",
"dom",
"es6"
],
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"inlineSourceMap": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"stripInternal": true,
"pretty": false,
"declaration": true,
"typeRoots": [
"./typings",
"./node_modules/@types"
],
"rootDir": "src",
"outDir": "lib"
},
"exclude": [
"**/node_modules/**",
"dist",
"test"
],
"include": [
"./src/**/*.ts",
"src/**/*.json"
]
}