Skip to content

Commit 41e04a8

Browse files
committed
Merge branch 'master' of github.com:aliyun/fun
2 parents c5bec61 + 3ddfa9d commit 41e04a8

51 files changed

Lines changed: 1654 additions & 41 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.DS_Store

6 KB
Binary file not shown.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ examples/local/java8/target/*
8080

8181
output
8282
.oss_cfg
83+
8384
*.pyc
8485
*.iml
85-
*.class
86+
*.class
87+
.DS_Store

README-zh.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@
1212

1313
## 开始使用
1414

15-
我们准备了一系列教程,助您更快上手:
15+
Fun 作为一个命令行工具,内置了多个子命令,比如 config、local、deploy 等。
1616

17-
- [安装教程](https://github.com/aliyun/fun/blob/master/docs/usage/installation-zh.md):介绍了如何在 macOS、Linux 或者 Windows 上安装 Fun。
17+
其中,config 子命令可以用来配置 fun,local 子命令可以用来本地运行调试函数,deploy 子命令可以将资源发布到线上。
18+
19+
为了让您尽快上手,我们准备了一系列教程:
20+
21+
- [安装教程](https://github.com/aliyun/fun/blob/master/docs/usage/installation-zh.md):介绍了如何在 Mac、Linux 或者 Windows 上安装 Fun。
1822
- [使用](https://github.com/aliyun/fun/blob/master/docs/usage/getting_started-zh.md):通过一个简单的示例介绍了 Fun 的基本用法。
1923
- **本地运行与调试**:关于如何本地运行、调试函数,以及介绍排查 bug 技巧的系列文章。
2024
- [开发函数计算的正确姿势 —— 使用 Fun Local 本地运行与调试](https://yq.aliyun.com/articles/672623):介绍了 Fun Local 基本用法。
@@ -33,7 +37,9 @@
3337
- [函数计算](https://www.aliyun.com/product/fc)
3438
- [API Gateway](https://www.aliyun.com/product/apigateway)
3539
- [Fun 发布 2.0 新版本啦](https://yq.aliyun.com/articles/604490)
40+
- [函数计算工具链新成员 —— Fun Local 发布啦](https://yq.aliyun.com/articles/672656)
3641
- [三十分钟快速搭建 serverless 网盘服务](https://yq.aliyun.com/articles/613780)
42+
- [Fc Docker](https://github.com/aliyun/fc-docker)
3743

3844
## 开源许可
3945

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ If you want to use the old syntax, please refer to [README.md](https://github.co
1212

1313
## Get Started
1414

15+
As a command-line tool, Fun has built-in subcommands such as config, local, deploy, and so on.
16+
17+
The config subcommand can be used to configure fun, the local subcommand can be used to run the debugging function locally, and the deploy subcommand can publish your resources.
18+
1519
We have prepared a series of tutorials to help you use the Fun tool more easily:
1620

17-
- [installation.md](dhttps://github.com/aliyun/fun/blob/master/docs/usage/installation.md): Learn how to install Fun on macOS, Linux or Windows.
18-
- [getting_started](https://github.com/aliyun/fun/blob/master/docs/usage/getting_started.md): The basic usage of Fun is introduced with a simple example.
21+
- [Installation](https://github.com/aliyun/fun/blob/master/docs/usage/installation.md): Learn how to install Fun on Mac, Linux or Windows.
22+
- [Getting Started](https://github.com/aliyun/fun/blob/master/docs/usage/getting_started.md): The basic usage of Fun is introduced with a simple example.
1923
- **Running and debugging locally**: A series on how to run locally, debug functions, and tips on troubleshooting related issues.
2024
- [开发函数计算的正确姿势 —— 使用 Fun Local 本地运行与调试](https://yq.aliyun.com/articles/672623): Introduced the basic usage of Fun Local.
2125
- [开发函数计算的正确姿势 —— 爬虫](https://yq.aliyun.com/articles/672624): How to use the Fun tool to develop a Serverless application from scratch.
@@ -29,7 +33,9 @@ We have prepared a series of tutorials to help you use the Fun tool more easily:
2933
- [函数计算](https://www.aliyun.com/product/fc)
3034
- [API Gateway](https://www.aliyun.com/product/apigateway)
3135
- [Fun 发布 2.0 新版本啦](https://yq.aliyun.com/articles/604490)
36+
- [函数计算工具链新成员 —— Fun Local 发布啦](https://yq.aliyun.com/articles/672656)
3237
- [三十分钟快速搭建 serverless 网盘服务](https://yq.aliyun.com/articles/613780)
38+
- [Fc Docker](https://github.com/aliyun/fc-docker)
3339

3440
## License
3541

bin/fun-init.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env node
2+
3+
/* eslint-disable quotes */
4+
5+
'use strict';
6+
7+
const program = require('commander');
8+
9+
const examples =
10+
`
11+
Examples:
12+
13+
$ fun init
14+
$ fun init helloworld-nodejs8
15+
$ fun init foo/bar
16+
$ fun init gh:foo/bar
17+
$ fun init gl:foo/bar
18+
$ fun init bb:foo/bar
19+
$ fun init github:foo/bar
20+
$ fun init gitlab:foo/bar
21+
$ fun init bitbucket:foo/bar
22+
$ fun init git+ssh://git@github.com/foo/bar.git
23+
$ fun init hg+ssh://hg@bitbucket.org/bar/foo
24+
$ fun init git@github.com:foo/bar.git
25+
$ fun init https://github.com/foo/bar.git
26+
$ fun init /path/foo/bar
27+
$ fun init -n fun-app -V foo=bar /path/foo/bar
28+
`;
29+
30+
const parseVars = (val, vars) => {
31+
/*
32+
* Key-value pairs, separated by equal signs
33+
* keys can only contain letters, numbers, and underscores
34+
* values can be any character
35+
*/
36+
const group = val.match(/(^[a-zA-Z_][a-zA-Z\d_]*)=(.*)/);
37+
vars = vars || {};
38+
if (group) {
39+
vars[group[1]] = group[2];
40+
}
41+
return vars;
42+
};
43+
44+
program
45+
.name('fun init')
46+
.usage('[options] [location]')
47+
.description('Initializes a new fun project.')
48+
.option('-o, --output-dir [path]', 'where to output the initialized app into', '.')
49+
.option('-n, --name [name]', 'name of your project to be generated as a folder', 'fun-app')
50+
.option('--no-input [noInput]', 'disable prompting and accept default values defined template config')
51+
.option('-V, --var [vars]', 'template variable', parseVars)
52+
.on('--help', () => {
53+
console.log(examples);
54+
})
55+
.parse(process.argv);
56+
57+
const context = {
58+
name: program.name,
59+
outputDir: program.outputDir,
60+
input: program.input,
61+
vars: program.var || {}
62+
};
63+
64+
if (program.args.length > 0) {
65+
context.location = program.args[0];
66+
}
67+
68+
require('../lib/commands/init')(context).catch(require('../lib/exception-handler'));

bin/fun.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ program
2020
// The commander will try to search the executables in the directory of the entry script
2121
// (like ./examples/pm) with the name program-command.
2222
.command('config', 'configure the fun')
23+
.command('init', 'initialize a new fun project')
2324
.command('build', 'build the dependencies')
2425
.command('local', 'run your serverless application locally')
2526
.command('validate', 'validate a fun template')
@@ -38,4 +39,4 @@ program.on('command:*', (cmds) => {
3839
}
3940
});
4041

41-
program.parse(process.argv);
42+
program.parse(process.argv);

docs/usage/getting_started-zh.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,28 @@ fun 配置方式的优先级按以下顺序依次递减:
9494
- .env
9595
- 环境变量
9696
- ~/.fcli/config.yaml
97+
98+
### .funignore
99+
100+
在 template.yml 所在的目录放置一个 .funignore 文件,打包 zip 文件的时候可以排除掉 .funignore 内描述的文件或者文件夹。 例如:
101+
102+
```
103+
# Logs
104+
logs/
105+
*.log
106+
107+
# Dependency directories
108+
node_modules/
109+
!bb/node_modules
110+
```
111+
112+
打包时会忽略 logs/ 目录 、*.log 文件。所有层级的 node_modules/ 目录会被忽略,但是 bb/node_modules 会被保留。
113+
114+
.funignore 遵从 .gitignore 的语法。
115+
116+
## 更多示例
117+
118+
下面有更多的示例:
119+
120+
- https://github.com/aliyun/fun/tree/master/examples
121+
- [十分钟上线-在函数计算上部署基于django开发的个人博客系统](https://yq.aliyun.com/articles/603249?spm=a2c4e.11153959.teamhomeleft.26.115948f26ECqbQ)

docs/usage/getting_started.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,24 @@ The priority of the fun configuration is decremented in the following order:
9898
- environment variables
9999
- ~/.fcli/config.yaml
100100

101+
### .funignore
102+
103+
Create a .funignore file in the same directory as template.yml. When packaging the zip file, you can exclude the files or folders described in .funignore. such as:
104+
105+
```
106+
# Logs
107+
logs/
108+
*.log
109+
110+
# Dependency directories
111+
node_modules/
112+
!bb/node_modules
113+
```
114+
115+
The logs/ directory and *.log files are ignored when packaging. The node_modules/ directory of all levels will be ignored, but bb/node_modules is preserved.
116+
117+
.funignore follows the syntax of .gitignore.
118+
101119
## More examples
102120

103121
You can find more complex examples here:

docs/usage/installation-zh.md

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,40 @@
1-
# Installation
1+
# 安装
22

3+
本地使用 Fun 时,如果需要在本地运行、调试函数,则需要使用 fun local 子命令.
34

4-
fun 是一个 Node.js 编写的命令行工具,但它也能支持 Python,Java 等环境的部署操作。安装它的方式是通过 npm:
5+
使用 fun local 子命令就需要预先安装 docker。如果不要求在本地运行、调试函数,则不需要安装 docker。
6+
7+
## Docker
8+
9+
### 安装 Docker
10+
11+
#### Mac 安装 docker
12+
13+
可以参考官方[教程](https://store.docker.com/editions/community/docker-ce-desktop-mac?tab=description)
14+
15+
如果遇到网络问题,可以下载阿里云提供的 [Docker For Mac](http://mirrors.aliyun.com/docker-toolbox/mac/docker-for-mac/stable/)
16+
17+
### Windows 安装 docker
18+
19+
可以参考官方[教程](https://store.docker.com/editions/community/docker-ce-desktop-windows)
20+
21+
如果遇到网络问题,可以下载阿里云提供的 [Docker For Windows](http://mirrors.aliyun.com/docker-toolbox/windows/docker-for-windows/stable/)
22+
23+
### Linux 安装 docker
24+
25+
可以参考官方[教程](https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-using-the-repository)
26+
27+
如果遇到网络问题,可以通过阿里云 Docker CE 镜像源站[下载](https://yq.aliyun.com/articles/110806)
28+
29+
### 配置镜像加速器
30+
31+
安装好 docker 之后,就可以使用 docker 下载镜像了。如果遇到网络问题,推荐配置 aliyun [镜像加速器](https://yq.aliyun.com/articles/29941)
32+
33+
## 安装 Fun
34+
35+
### 通过 npm 安装 Fun
36+
37+
安装它的方式是通过 npm:
538

639
```shell
740
$ npm install @alicloud/fun -g
@@ -27,4 +60,19 @@ $ fun -h
2760
validate [options] Validate a fun template
2861
deploy Deploy a project to AliCloud
2962
build Build the dependencies
30-
```
63+
```
64+
65+
### 直接下载 Fun 二进制运行程序
66+
67+
打开 [releases](https://github.com/aliyun/fun/releases) 页面,在最新的版本中选择一个对应平台的 release 压缩包链接,点击即可直接下载。
68+
69+
下载到本地后,解压,即可直接使用。
70+
71+
### 通过 homebrew 安装 Fun
72+
73+
对于 Mac 系统,还可以选择使用 homebrew 安装 Fun。
74+
75+
```
76+
brew tap vangie/formula
77+
brew install fun
78+
```

docs/usage/installation.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,40 @@
11
# Installation
22

3-
Fun is a command line tool developed for Node.js, however it also support Python, Java or other runtime enviroments. It can be installed by [npm](https://www.npmjs.com/):
3+
When using Fun, if you need to run and debug function locally, you need to use the fun local subcommand.
4+
5+
Fun local subcommand depend on docker.
6+
7+
If you don't want to run and debug function locally, docker is not required.
8+
9+
## Docker
10+
11+
### Install Docker
12+
13+
#### Install Docker On Mac
14+
15+
You can refer to the official [Tutorial](https://store.docker.com/editions/community/docker-ce-desktop-mac?tab=description).
16+
17+
If you encounter network problems, you can download [Docker For Mac](http://mirrors.aliyun.com/docker-toolbox/mac/docker-for-mac/stable/) provided by Alibaba Cloud.
18+
19+
#### Install Docker On Windows
20+
21+
You can refer to the official [Tutorial](https://store.docker.com/editions/community/docker-ce-desktop-windows).
22+
23+
If you encounter network problems, you can download [Docker For Windows](http://mirrors.aliyun.com/docker-toolbox/windows/docker-for-windows/stable/) provided by Alibaba Cloud.
24+
25+
#### Install Docker On Linux
26+
27+
You can refer to the official [Tutorial](https://docs.docker.com/install/linux/docker-ce/ubuntu).
28+
29+
If you encounter network problems, you can use Alibaba Cloud Docker CE mirror to download. please refer to this [tutorial](https://yq.aliyun.com/articles/110806).
30+
31+
### Configuring Docker Registry Mirror
32+
33+
Once docker is installed, you can use docker to download the image. If you encounter network problems, it is recommended to configure aliyun [Registry Mirror](https://yq.aliyun.com/articles/29941).
34+
35+
## Install Fun Using Npm
36+
37+
Fun could be installed by [npm](https://www.npmjs.com/):
438

539
```shell
640
$ npm install @alicloud/fun -g
@@ -27,3 +61,18 @@ $ fun
2761
deploy Deploy a project to AliCloud
2862
build Build the dependencies
2963
```
64+
65+
## Install Fun by Downloading The Latest Binary
66+
67+
Open the [Releases](https://github.com/aliyun/fun/releases) page, click a link of the corresponding platform to download the Fun zip package.
68+
69+
After downloading, unzip it and use it directly.
70+
71+
## Install Fun Using Homebrew
72+
73+
For Mac, you can also install Fun using homebrew.
74+
75+
```
76+
brew tap vangie/formula
77+
brew install fun
78+
```

0 commit comments

Comments
 (0)