func-cli-nodejs-v4 4.0.4764
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +392 -0
- package/assets/azure-functions-logo-color-raster.png +0 -0
- package/lib/copy-metadata.js +10 -0
- package/lib/install.js +101 -0
- package/lib/main.js +21 -0
- package/npm-shrinkwrap.json +822 -0
- package/package.json +39 -0
package/README.md
ADDED
@@ -0,0 +1,392 @@
|
|
1
|
+
![Azure Functions Logo](https://raw.githubusercontent.com/Azure/azure-functions-cli/master/src/Azure.Functions.Cli/npm/assets/azure-functions-logo-color-raster.png)
|
2
|
+
|
3
|
+
|Branch|Status|
|
4
|
+
|---|---|
|
5
|
+
|v4.x|[![Build status](https://azfunc.visualstudio.com/Azure%20Functions/_apis/build/status/azure-functions-core-tools?branchName=v4.x)](https://azfunc.visualstudio.com/Azure%20Functions/_build/latest?definitionId=11&branchName=v4.x)|
|
6
|
+
|v3.x|[![Build status](https://azfunc.visualstudio.com/Azure%20Functions/_apis/build/status/azure-functions-core-tools?branchName=v3.x)](https://azfunc.visualstudio.com/Azure%20Functions/_build/latest?definitionId=11&branchName=v3.x)|
|
7
|
+
|dev|[![Build Status](https://azfunc.visualstudio.com/Azure%20Functions/_apis/build/status/azure-functions-core-tools?branchName=dev)](https://azfunc.visualstudio.com/Azure%20Functions/_build/latest?definitionId=11&branchName=dev)
|
8
|
+
|v1.x|[![Build status](https://azfunc.visualstudio.com/Azure%20Functions/_apis/build/status/azure-functions-core-tools?branchName=v1.x)](https://azfunc.visualstudio.com/Azure%20Functions/_build/latest?definitionId=11&branchName=v1.x)|
|
9
|
+
|
10
|
+
# Azure Functions Core Tools
|
11
|
+
|
12
|
+
The Azure Functions Core Tools provide a local development experience for creating, developing, testing, running, and debugging Azure Functions.
|
13
|
+
|
14
|
+
## Versions
|
15
|
+
|
16
|
+
**v1** (v1.x branch): Requires .NET 4.7.1 Windows Only
|
17
|
+
|
18
|
+
**v2** (dev branch): Self-contained cross-platform package
|
19
|
+
|
20
|
+
**v3**: (v3.x branch): Self-contained cross-platform package
|
21
|
+
|
22
|
+
**v4**: (v4.x branch): Self-contained cross-platform package **(recommended)**
|
23
|
+
|
24
|
+
## Installing
|
25
|
+
|
26
|
+
### Windows
|
27
|
+
|
28
|
+
#### To download and install with MSI:
|
29
|
+
|
30
|
+
##### v4
|
31
|
+
|
32
|
+
- [Windows 64-bit](https://go.microsoft.com/fwlink/?linkid=2174087) (VS Code debugging requires 64-bit)
|
33
|
+
- [Windows 32-bit](https://go.microsoft.com/fwlink/?linkid=2174159)
|
34
|
+
|
35
|
+
##### v3
|
36
|
+
|
37
|
+
- [Windows 64-bit](https://go.microsoft.com/fwlink/?linkid=2135274) (VS Code debugging requires 64-bit)
|
38
|
+
- [Windows 32-bit](https://go.microsoft.com/fwlink/?linkid=2135275)
|
39
|
+
|
40
|
+
#### To install with npm:
|
41
|
+
|
42
|
+
##### v4
|
43
|
+
```bash
|
44
|
+
npm i -g azure-functions-core-tools@4 --unsafe-perm true
|
45
|
+
```
|
46
|
+
|
47
|
+
##### v3
|
48
|
+
```bash
|
49
|
+
npm i -g azure-functions-core-tools@3 --unsafe-perm true
|
50
|
+
```
|
51
|
+
|
52
|
+
##### v2
|
53
|
+
```bash
|
54
|
+
npm i -g azure-functions-core-tools@2 --unsafe-perm true
|
55
|
+
```
|
56
|
+
|
57
|
+
#### To install with chocolatey:
|
58
|
+
|
59
|
+
##### v4
|
60
|
+
```bash
|
61
|
+
choco install azure-functions-core-tools
|
62
|
+
```
|
63
|
+
|
64
|
+
##### v3
|
65
|
+
```bash
|
66
|
+
choco install azure-functions-core-tools-3
|
67
|
+
```
|
68
|
+
|
69
|
+
*Notice: To debug functions under vscode, the 64-bit version is required*
|
70
|
+
```bash
|
71
|
+
choco install azure-functions-core-tools-3 --params "'/x64'"
|
72
|
+
```
|
73
|
+
|
74
|
+
##### v2
|
75
|
+
```bash
|
76
|
+
choco install azure-functions-core-tools-2
|
77
|
+
```
|
78
|
+
|
79
|
+
#### To install with winget:
|
80
|
+
|
81
|
+
##### v4
|
82
|
+
|
83
|
+
```bash
|
84
|
+
winget install Microsoft.AzureFunctionsCoreTools
|
85
|
+
```
|
86
|
+
|
87
|
+
##### v3
|
88
|
+
|
89
|
+
```bash
|
90
|
+
winget install Microsoft.AzureFunctionsCoreTools -v 3.0.3904
|
91
|
+
```
|
92
|
+
|
93
|
+
### Mac
|
94
|
+
|
95
|
+
#### Homebrew:
|
96
|
+
|
97
|
+
##### v4
|
98
|
+
|
99
|
+
```bash
|
100
|
+
brew tap azure/functions
|
101
|
+
brew install azure-functions-core-tools@4
|
102
|
+
```
|
103
|
+
|
104
|
+
##### v3
|
105
|
+
```bash
|
106
|
+
brew tap azure/functions
|
107
|
+
brew install azure-functions-core-tools@3
|
108
|
+
```
|
109
|
+
|
110
|
+
##### v2
|
111
|
+
```bash
|
112
|
+
brew tap azure/functions
|
113
|
+
brew install azure-functions-core-tools@2
|
114
|
+
```
|
115
|
+
|
116
|
+
Homebrew allows side by side installation of v2 and v3, you can switch between the versions using
|
117
|
+
```bash
|
118
|
+
brew link --overwrite azure-functions-core-tools@3
|
119
|
+
```
|
120
|
+
|
121
|
+
|
122
|
+
### Linux
|
123
|
+
|
124
|
+
#### 1. Set up package feed
|
125
|
+
|
126
|
+
##### Ubuntu 20.04
|
127
|
+
|
128
|
+
```bash
|
129
|
+
wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
|
130
|
+
sudo dpkg -i packages-microsoft-prod.deb
|
131
|
+
```
|
132
|
+
|
133
|
+
##### Ubuntu 19.04
|
134
|
+
|
135
|
+
```bash
|
136
|
+
wget -q https://packages.microsoft.com/config/ubuntu/19.04/packages-microsoft-prod.deb
|
137
|
+
sudo dpkg -i packages-microsoft-prod.deb
|
138
|
+
```
|
139
|
+
|
140
|
+
##### Ubuntu 18.10
|
141
|
+
|
142
|
+
```bash
|
143
|
+
wget -q https://packages.microsoft.com/config/ubuntu/18.10/packages-microsoft-prod.deb
|
144
|
+
sudo dpkg -i packages-microsoft-prod.deb
|
145
|
+
```
|
146
|
+
|
147
|
+
##### Ubuntu 18.04
|
148
|
+
|
149
|
+
```bash
|
150
|
+
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
|
151
|
+
sudo dpkg -i packages-microsoft-prod.deb
|
152
|
+
```
|
153
|
+
|
154
|
+
##### Ubuntu 16.04 / Linux Mint 18
|
155
|
+
|
156
|
+
```bash
|
157
|
+
wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
|
158
|
+
sudo dpkg -i packages-microsoft-prod.deb
|
159
|
+
```
|
160
|
+
|
161
|
+
##### Debian 9 / 10
|
162
|
+
|
163
|
+
```bash
|
164
|
+
# set to 9 or 10
|
165
|
+
DEBIAN_VERSION=10
|
166
|
+
|
167
|
+
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
|
168
|
+
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
|
169
|
+
wget -q https://packages.microsoft.com/config/debian/$DEBIAN_VERSION/prod.list
|
170
|
+
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
|
171
|
+
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
|
172
|
+
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list
|
173
|
+
```
|
174
|
+
|
175
|
+
#### 2. Install
|
176
|
+
|
177
|
+
##### v4
|
178
|
+
```bash
|
179
|
+
sudo apt-get update
|
180
|
+
sudo apt-get install azure-functions-core-tools-4
|
181
|
+
```
|
182
|
+
|
183
|
+
##### v3
|
184
|
+
```bash
|
185
|
+
sudo apt-get update
|
186
|
+
sudo apt-get install azure-functions-core-tools-3
|
187
|
+
```
|
188
|
+
|
189
|
+
##### v2
|
190
|
+
```bash
|
191
|
+
sudo apt-get update
|
192
|
+
sudo apt-get install azure-functions-core-tools-2
|
193
|
+
```
|
194
|
+
|
195
|
+
#### Other Linux Distributions
|
196
|
+
|
197
|
+
1. Download latest release
|
198
|
+
|
199
|
+
Download the latest release for your platform from [here](https://github.com/Azure/azure-functions-core-tools/releases).
|
200
|
+
|
201
|
+
2. Unzip release zip
|
202
|
+
|
203
|
+
Using your preferred tool, unzip the downloaded release. To unzip into an `azure-functions-cli` directory using the `unzip` tool, run this command from the directory containing the downloaded release zip:
|
204
|
+
|
205
|
+
```bash
|
206
|
+
unzip -d azure-functions-cli Azure.Functions.Cli.linux-x64.*.zip
|
207
|
+
```
|
208
|
+
|
209
|
+
3. Make the `func` command executable
|
210
|
+
|
211
|
+
Zip files do not maintain the executable bit on binaries. So, you'll need to make the `func` binary, as well as `gozip` (used by func during packaging) executables. Assuming you used the instructions above to unzip:
|
212
|
+
|
213
|
+
```bash
|
214
|
+
cd azure-functions-cli
|
215
|
+
chmod +x func
|
216
|
+
chmod +x gozip
|
217
|
+
./func
|
218
|
+
```
|
219
|
+
|
220
|
+
4. Optionally add `func` to your `$PATH`
|
221
|
+
|
222
|
+
To execute the `func` command without specifying the full path to the binary, add its directory to your `$PATH` environment variable. Assuming you're still following along from above:
|
223
|
+
|
224
|
+
```bash
|
225
|
+
export PATH=`pwd`:$PATH
|
226
|
+
func
|
227
|
+
```
|
228
|
+
|
229
|
+
[Code and test Azure Functions locally](https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local)
|
230
|
+
|
231
|
+
**NOTE**: npm can be used on all platforms. On unix platforms, you may need to specify `--unsafe-perm` if you are running npm with sudo. That's due to npm behavior of post install script.
|
232
|
+
|
233
|
+
## Getting Started on Kubernetes
|
234
|
+
|
235
|
+
Using the Core Tools, you can easily configure a Kubernetes cluster and run Azure Functions on it.
|
236
|
+
|
237
|
+
### Prerequisites
|
238
|
+
|
239
|
+
* [Docker](https://docs.docker.com/install/)
|
240
|
+
* [Kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
|
241
|
+
|
242
|
+
### Installing Kubernetes scalers
|
243
|
+
|
244
|
+
This deploys [KEDA](https://github.com/kedacore/keda) to your cluster which allows you to deploy your functions in a scale-to-zero by default for non-http scenarios only.
|
245
|
+
|
246
|
+
```bash
|
247
|
+
func kubernetes install --namespace {namespace}
|
248
|
+
```
|
249
|
+
|
250
|
+
**KEDA:** Handles monitoring polling event sources currently QueueTrigger and ServiceBusTrigger.
|
251
|
+
|
252
|
+
### Deploy to Kubernetes
|
253
|
+
|
254
|
+
**First make sure you have Dockerfile for your project.** You can generate one using
|
255
|
+
```bash
|
256
|
+
func init --docker # or --docker-only (for existing projects)
|
257
|
+
```
|
258
|
+
Then to deploy to kubernetes
|
259
|
+
|
260
|
+
```bash
|
261
|
+
func kubernetes deploy \
|
262
|
+
--name myfunction \
|
263
|
+
--namespace functions-ns \
|
264
|
+
--registry <docker-hub-id or registry-server>
|
265
|
+
```
|
266
|
+
|
267
|
+
This will build the current `Dockerfile` and push the image to the registry specified, then deploys a `Secret`, `Deployment`, and `ScaledObject`. If your functions have httpTrigger, you'll get an additional `Deployment` and `Service`.
|
268
|
+
|
269
|
+
### Deploy using a private registry
|
270
|
+
|
271
|
+
```bash
|
272
|
+
func kubernetes deploy --name myfunction --registry <docker-hub-id or registry-server> --pull-secret <registry auth secret>
|
273
|
+
|
274
|
+
```
|
275
|
+
|
276
|
+
### Deploy a function to Knative
|
277
|
+
|
278
|
+
#### Prerequisites
|
279
|
+
|
280
|
+
* [Knative](https://github.com/knative/docs/tree/master/docs/install)
|
281
|
+
|
282
|
+
Deploying Azure Functions to knative is supported with the ```--platform knative``` flag.
|
283
|
+
The Core Tools CLI identifies non HTTP trigger functions and annotates the knative manifest with the the ```minScale``` annotation to opt out of scale-to-zero.
|
284
|
+
|
285
|
+
```bash
|
286
|
+
func deploy --platform knative --name myfunction --registry <docker-hub-id or registry-server>
|
287
|
+
```
|
288
|
+
|
289
|
+
### Deploying a function to AKS using ACR
|
290
|
+
Using the configuration options an Azure Function app can also be deployed to a [AKS](https://azure.microsoft.com/en-us/services/kubernetes-service/) (Azure Kubernetes Service) Kubernetes cluster and use [ACR](https://azure.microsoft.com/en-us/services/container-registry/) as the registry server. Do all of the following *before* you run the deployment command.
|
291
|
+
|
292
|
+
#### Create a AKS cluster
|
293
|
+
You can create an AKS cluster using the [Azure Portal](https://docs.microsoft.com/en-us/azure/aks/kubernetes-walkthrough-portal) or using [Azure CLI](https://docs.microsoft.com/en-us/azure/aks/kubernetes-walkthrough).
|
294
|
+
|
295
|
+
Once your AKS cluster is created make sure that you can access it using kubectl. To make kubectl run in the context of your cluster, configure a connection using the command below.
|
296
|
+
```azurecli
|
297
|
+
az aks get-credentials \
|
298
|
+
--name FunctionsCluster \
|
299
|
+
--resource-group <resource-group-name>
|
300
|
+
```
|
301
|
+
|
302
|
+
To verify the connection to your cluster run the following command
|
303
|
+
```bash
|
304
|
+
> kubectl get nodes
|
305
|
+
|
306
|
+
NAME STATUS ROLES AGE VERSION
|
307
|
+
aks-agentpool-20257154-0 Ready agent 1d v1.11.5
|
308
|
+
aks-agentpool-20257154-1 Ready agent 1d v1.11.5
|
309
|
+
aks-agentpool-20257154-2 Ready agent 1d v1.11.5
|
310
|
+
```
|
311
|
+
#### Create a ACR Registry
|
312
|
+
An ACR instance can be created using the Azure Portal or the [Azure CLI](https://docs.microsoft.com/en-us/azure/container-registry/container-registry-get-started-azure-cli#create-a-container-registry)
|
313
|
+
|
314
|
+
#### Login to the ACR Registry
|
315
|
+
Before pushing and pulling container images, you must log in to the ACR instance.
|
316
|
+
|
317
|
+
```azurecli
|
318
|
+
az acr login --name <acrName>
|
319
|
+
```
|
320
|
+
|
321
|
+
#### Give the AKS cluster access to the ACR Registry
|
322
|
+
The AKS cluster needs access to the ACR Registry to pull the container. Azure creates a service principal to support cluster operability with other Azure resources. This can be used for authentication with an ACR registry. See here for how to grant the right access here: [Authenticate with Azure Container Registry from Azure Kubernetes Service](https://docs.microsoft.com/en-us/azure/container-registry/container-registry-auth-aks)
|
323
|
+
|
324
|
+
#### Run the deployment
|
325
|
+
The deployment will build the docker container and upload the container image to your referenced ACR instance (Note: Specify the ACR Login Server in the --registry parameter this is usually of the form <container_registry_name>.azurecr.io) and then your AKS cluster will use that as a source to obtain the container and deploy it.
|
326
|
+
|
327
|
+
```bash
|
328
|
+
func kubernetes deploy --name myfunction --registry <acr-registry-loginserver>
|
329
|
+
```
|
330
|
+
|
331
|
+
If the deployment is successful, you should see this:
|
332
|
+
|
333
|
+
Function deployed successfully!
|
334
|
+
Function IP: 40.121.21.192
|
335
|
+
|
336
|
+
#### Verifying your deployment
|
337
|
+
You can verify your deployment by using the Kubernetes web dashboard. To start the Kubernetes dashboard, use the [az aks browse](https://docs.microsoft.com/en-us/cli/azure/aks?view=azure-cli-latest#az-aks-browse) command.
|
338
|
+
|
339
|
+
```azurecli
|
340
|
+
az aks browse --resource-group myResourceGroup --name myAKSCluster
|
341
|
+
```
|
342
|
+
In the Kubernetes dashboard look for the namespace "azure-functions" and make sure that a pod has been deployed sucessfully with your container.
|
343
|
+
|
344
|
+
### Deploying Azure Functions with Virtual-Kubelet
|
345
|
+
|
346
|
+
Azure Functions running on Kubernetes can take advantage of true serverless containers model by getting deployed to different providers of [Virtual Kubelet](https://github.com/virtual-kubelet/virtual-kubelet), such as Azure Container Instances.<br>
|
347
|
+
|
348
|
+
Functions deployed to Kubernetes already contain all the tolerations needed to be schedulable to Virtual Kubelet nodes.
|
349
|
+
All you need to do is to set up VKubelet on your Kubernetes cluster:
|
350
|
+
|
351
|
+
* [Install VKubelet with ACI](https://github.com/virtual-kubelet/azure-aci)
|
352
|
+
|
353
|
+
* [Install VKubelet with ACI on AKS](https://docs.microsoft.com/en-us/cli/azure/aks?view=azure-cli-latest#az-aks-install-connector)
|
354
|
+
|
355
|
+
*Important note:*
|
356
|
+
Virtual Kubelet does not currently allow for Kubernetes Services to route external traffic to pods.
|
357
|
+
This means that HTTP triggered functions will not receive traffic running on a VKubelet provider (including ACI).
|
358
|
+
|
359
|
+
A good usage scenario for using functions with VKubelet would be with event triggered / time triggered functions that do not rely on external HTTP traffic.
|
360
|
+
|
361
|
+
## Known Issues:
|
362
|
+
|
363
|
+
`func extensions` command require the `dotnet` cli to be installed and on your path. This requirement is tracked [here](https://github.com/Azure/azure-functions-core-tools/issues/367). You can install .NET Core for your platform from https://www.microsoft.com/net/download/
|
364
|
+
|
365
|
+
## Default Directories
|
366
|
+
|
367
|
+
* `CurrentDirectory`: is the default directory the functions runtime looks for functions in.
|
368
|
+
* `%TMP%\LogFiles\Application\Functions`: is the default directory for logs. It mirrors the logs directory on Azure as well.
|
369
|
+
|
370
|
+
## Telemetry
|
371
|
+
|
372
|
+
The Azure Functions Core tools collect usage data in order to help us improve your experience.
|
373
|
+
The data is anonymous and doesn't include any user specific or personal information. The data is collected by Microsoft.
|
374
|
+
|
375
|
+
You can opt-out of telemetry by setting the `FUNCTIONS_CORE_TOOLS_TELEMETRY_OPTOUT` environment variable to '1' or 'true' using your favorite shell.
|
376
|
+
|
377
|
+
[Microsoft privacy statement](https://privacy.microsoft.com/en-US/privacystatement)
|
378
|
+
|
379
|
+
## License
|
380
|
+
|
381
|
+
This project is under the benevolent umbrella of the [.NET Foundation](http://www.dotnetfoundation.org/) and is licensed under [the MIT License](LICENSE)
|
382
|
+
|
383
|
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
384
|
+
|
385
|
+
## Contact Us
|
386
|
+
|
387
|
+
For questions on Azure Functions or the tools, you can ask questions here:
|
388
|
+
|
389
|
+
- [Azure Functions Q&A Forum](https://docs.microsoft.com/en-us/answers/topics/azure-functions.html)
|
390
|
+
- [Azure-Functions tag on StackOverflow](http://stackoverflow.com/questions/tagged/azure-functions)
|
391
|
+
|
392
|
+
File bugs at [Azure Functions Core Tools repo on GitHub](https://github.com/Azure/azure-functions-core-tools/issues).
|
Binary file
|
@@ -0,0 +1,10 @@
|
|
1
|
+
const fs = require('fs');
|
2
|
+
const path = require('path');
|
3
|
+
|
4
|
+
const readMeSrc = path.resolve(__dirname, '..', '..', '..', '..', 'README.md');
|
5
|
+
const readMeDest = path.resolve(__dirname, '..', 'README.md');
|
6
|
+
|
7
|
+
fs.copyFile(readMeSrc, readMeDest, (err) => {
|
8
|
+
if (err) throw err;
|
9
|
+
console.log('Copied README.md from the project root.');
|
10
|
+
});
|
package/lib/install.js
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
#! /usr/bin/env node
|
2
|
+
|
3
|
+
const unzipper = require('unzipper');
|
4
|
+
const url = require('url');
|
5
|
+
const HttpsProxyAgent = require('https-proxy-agent');
|
6
|
+
const https = require('https');
|
7
|
+
const version = require('../package.json').version;
|
8
|
+
const chalk = require('chalk');
|
9
|
+
const path = require('path');
|
10
|
+
const fs = require('fs');
|
11
|
+
const rimraf = require('rimraf');
|
12
|
+
const glob = require('glob');
|
13
|
+
const execSync = require('child_process').execSync;
|
14
|
+
const ProgressBar = require('progress');
|
15
|
+
const os = require('os');
|
16
|
+
|
17
|
+
function getPath() {
|
18
|
+
const bin = path.resolve(path.join(path.dirname(__filename), '..', 'bin'));
|
19
|
+
if (fs.existsSync(bin)) {
|
20
|
+
rimraf.sync(bin);
|
21
|
+
}
|
22
|
+
return bin
|
23
|
+
}
|
24
|
+
|
25
|
+
let platform = '';
|
26
|
+
|
27
|
+
if (os.platform() === 'win32') {
|
28
|
+
platform = 'win-x64';
|
29
|
+
} else if (os.platform() === 'darwin') {
|
30
|
+
if (os.arch() === 'arm64') {
|
31
|
+
platform = 'osx-arm64';
|
32
|
+
} else {
|
33
|
+
platform = 'osx-x64';
|
34
|
+
}
|
35
|
+
} else if (os.platform() === 'linux') {
|
36
|
+
platform = 'linux-x64';
|
37
|
+
} else {
|
38
|
+
throw Error('platform ' + os.platform() + ' isn\'t supported');
|
39
|
+
}
|
40
|
+
|
41
|
+
const endpoint = 'https://azfuncnodev4.blob.core.windows.net/public/' + version + '/Azure.Functions.Cli.' + platform + '.' + version + '.zip';
|
42
|
+
console.log('attempting to GET %j', endpoint);
|
43
|
+
const options = url.parse(endpoint);
|
44
|
+
// npm config preceed system environment
|
45
|
+
// https://github.com/npm/npm/blob/19397ad523434656af3d3765e80e22d7e6305f48/lib/config/reg-client.js#L7-L8
|
46
|
+
// https://github.com/request/request/blob/b12a6245d9acdb1e13c6486d427801e123fdafae/lib/getProxyFromURI.js#L66-L71
|
47
|
+
const proxy = process.env.npm_config_https_proxy ||
|
48
|
+
process.env.npm_config_proxy ||
|
49
|
+
process.env.HTTPS_PROXY ||
|
50
|
+
process.env.https_proxy ||
|
51
|
+
process.env.HTTP_PROXY ||
|
52
|
+
process.env.http_proxy;
|
53
|
+
|
54
|
+
const telemetryInfo = os.EOL
|
55
|
+
+ 'Telemetry' + os.EOL
|
56
|
+
+ '---------' + os.EOL
|
57
|
+
+ 'The Azure Functions Core tools collect usage data in order to help us improve your experience. ' + os.EOL
|
58
|
+
+ 'The data is anonymous and doesn\'t include any user specific or personal information. The data is collected by Microsoft.' + os.EOL
|
59
|
+
+ os.EOL
|
60
|
+
+ 'You can opt-out of telemetry by setting the FUNCTIONS_CORE_TOOLS_TELEMETRY_OPTOUT environment variable to \'1\' or \'true\' using your favorite shell.' + os.EOL
|
61
|
+
|
62
|
+
if (proxy) {
|
63
|
+
console.log('using proxy server %j', proxy);
|
64
|
+
options.agent = new HttpsProxyAgent(proxy);
|
65
|
+
}
|
66
|
+
|
67
|
+
https.get(options, response => {
|
68
|
+
|
69
|
+
const bar = new ProgressBar('[:bar] Downloading Azure Functions Core Tools', {
|
70
|
+
total: Number(response.headers['content-length']),
|
71
|
+
width: 18
|
72
|
+
});
|
73
|
+
|
74
|
+
if (response.statusCode === 200) {
|
75
|
+
const installPath = getPath();
|
76
|
+
response.on('data', data => bar.tick(data.length));
|
77
|
+
const unzipStream = unzipper.Extract({ path: installPath })
|
78
|
+
.on('close', () => {
|
79
|
+
try {
|
80
|
+
fs.closeSync(fs.openSync(`${installPath}/telemetryDefaultOn.sentinel`, 'w'))
|
81
|
+
console.log(telemetryInfo)
|
82
|
+
}
|
83
|
+
catch (err) {
|
84
|
+
// That's alright.
|
85
|
+
}
|
86
|
+
if (os.platform() === 'linux' || os.platform() === 'darwin') {
|
87
|
+
fs.chmodSync(`${installPath}/func`, 0o755);
|
88
|
+
fs.chmodSync(`${installPath}/gozip`, 0o755);
|
89
|
+
}
|
90
|
+
});
|
91
|
+
response.pipe(unzipStream);
|
92
|
+
} else {
|
93
|
+
console.error(chalk.red('Error downloading zip file from ' + endpoint));
|
94
|
+
console.error(chalk.red('Expected: 200, Actual: ' + response.statusCode));
|
95
|
+
process.exit(1);
|
96
|
+
}
|
97
|
+
})
|
98
|
+
.on('error', err => {
|
99
|
+
console.error(chalk.red(err));
|
100
|
+
process.exit(1);
|
101
|
+
});
|
package/lib/main.js
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#! /usr/bin/env node
|
2
|
+
|
3
|
+
const path = require('path');
|
4
|
+
const fs = require('fs');
|
5
|
+
const spawn = require('child_process').spawn;
|
6
|
+
const fork = require('child_process').fork;
|
7
|
+
const commandExists = require('command-exists');
|
8
|
+
const args = process.argv;
|
9
|
+
|
10
|
+
function main() {
|
11
|
+
const bin = path.resolve(path.join(path.dirname(__filename), '..', 'bin'));
|
12
|
+
const funcProc = spawn(bin + '/func', args.slice(2), {
|
13
|
+
stdio: [process.stdin, process.stdout, process.stderr, 'pipe']
|
14
|
+
});
|
15
|
+
|
16
|
+
funcProc.on('exit', code => {
|
17
|
+
process.exit(code);
|
18
|
+
});
|
19
|
+
}
|
20
|
+
|
21
|
+
main();
|