From 0303f80bcbce1d0b594690cb8b6fc6d8e3550644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=83=E9=A3=8E?= Date: Tue, 27 Apr 2021 11:41:16 +0800 Subject: [PATCH 1/2] update service and function schema --- CHANGELOG.md | 12 + package-lock.json | 248 +++++++++--------- package.json | 2 +- .../schema/ros/ALIYUN-FC-Function.json | 12 + .../schema/ros/ALIYUN-FC-Service.json | 3 + src/language-service/schema/rosSchema.ts | 36 ++- src/schema/constants.ts | 4 + src/schema/schema.ts | 5 + 8 files changed, 203 insertions(+), 119 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a3a92d..ecb3c49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ 所有对 "Aliyun Serverless" 插件的更改都将记录在这个文件中。 +## 1.27.17 - 2021-04-27 + +### Fixed + +1. 修复无法显示工作流的问题。 + +### Added + +1. Service schema 中增加 TracingConfig 字段 +2. Function schema 中增加 InstanceLifecycleConfig 字段 +3. Function ros schema 中增加 InstanceType、CustomContainerConfig、CAPort 以及 AsyncConfiguration 字段 + ## 1.27.16 - 2020-12-04 ### Fixed diff --git a/package-lock.json b/package-lock.json index c316229..aea52f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "aliyun-serverless", - "version": "1.27.16", + "version": "1.27.17", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -540,6 +540,12 @@ "defer-to-connect": "^1.0.1" } }, + "@tootallnate/once": { + "version": "1.1.2", + "resolved": "https://registry.npm.taobao.org/@tootallnate/once/download/@tootallnate/once-1.1.2.tgz", + "integrity": "sha1-zLkURTYBeaBOf+av94wA/8Hur4I=", + "dev": true + }, "@types/decompress": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/@types/decompress/-/decompress-4.2.3.tgz", @@ -1242,12 +1248,6 @@ "concat-map": "0.0.1" } }, - "browser-stdout": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", - "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", - "dev": true - }, "buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", @@ -3349,12 +3349,6 @@ "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=" }, - "growl": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", - "dev": true - }, "har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", @@ -4386,82 +4380,6 @@ "minimist": "0.0.8" } }, - "mocha": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-4.1.0.tgz", - "integrity": "sha512-0RVnjg1HJsXY2YFDoTNzcc1NKhYuXKRrBAG2gDygmJJA136Cs2QlRliZG1mA0ap7cuaT30mw16luAeln+4RiNA==", - "dev": true, - "requires": { - "browser-stdout": "1.3.0", - "commander": "2.11.0", - "debug": "3.1.0", - "diff": "3.3.1", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", - "growl": "1.10.3", - "he": "1.1.1", - "mkdirp": "0.5.1", - "supports-color": "4.4.0" - }, - "dependencies": { - "commander": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", - "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", - "dev": true - }, - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "diff": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.3.1.tgz", - "integrity": "sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww==", - "dev": true - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "has-flag": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", - "dev": true - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "supports-color": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", - "dev": true, - "requires": { - "has-flag": "^2.0.0" - } - } - } - }, "moment": { "version": "2.24.0", "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", @@ -5250,12 +5168,6 @@ "strict-uri-encode": "^1.0.0" } }, - "querystringify": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.1.tgz", - "integrity": "sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA==", - "dev": true - }, "range-parser": { "version": "1.2.1", "resolved": "https://registry.npm.taobao.org/range-parser/download/range-parser-1.2.1.tgz", @@ -5404,12 +5316,6 @@ "integrity": "sha1-5UBLgVV+91225JxacgBIk/4D4WI=", "dev": true }, - "requires-port": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=", - "dev": true - }, "resolve": { "version": "1.11.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.11.0.tgz", @@ -6481,16 +6387,6 @@ "punycode": "^2.1.0" } }, - "url-parse": { - "version": "1.4.7", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz", - "integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==", - "dev": true, - "requires": { - "querystringify": "^2.1.1", - "requires-port": "^1.0.0" - } - }, "url-parse-lax": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz", @@ -6616,18 +6512,136 @@ } }, "vscode": { - "version": "1.1.34", - "resolved": "https://registry.npmjs.org/vscode/-/vscode-1.1.34.tgz", - "integrity": "sha512-GuT3tCT2N5Qp26VG4C+iGmWMgg/MuqtY5G5TSOT3U/X6pgjM9LFulJEeqpyf6gdzpI4VyU3ZN/lWPo54UFPuQg==", + "version": "1.1.37", + "resolved": "https://registry.npm.taobao.org/vscode/download/vscode-1.1.37.tgz", + "integrity": "sha1-wqdwvuS7P/92Xityx7zIE7imuwo=", "dev": true, "requires": { "glob": "^7.1.2", - "mocha": "^4.0.1", - "request": "^2.88.0", + "http-proxy-agent": "^4.0.1", + "https-proxy-agent": "^5.0.0", + "mocha": "^5.2.0", "semver": "^5.4.1", "source-map-support": "^0.5.0", - "url-parse": "^1.4.4", "vscode-test": "^0.4.1" + }, + "dependencies": { + "agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npm.taobao.org/agent-base/download/agent-base-6.0.2.tgz?cache=0&sync_timestamp=1603479872755&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fagent-base%2Fdownload%2Fagent-base-6.0.2.tgz", + "integrity": "sha1-Sf/1hXfP7j83F2/qtMIuAPhtf3c=", + "dev": true, + "requires": { + "debug": "4" + } + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npm.taobao.org/browser-stdout/download/browser-stdout-1.3.1.tgz", + "integrity": "sha1-uqVZ7hTO1zRSIputcyZGfGH6vWA=", + "dev": true + }, + "commander": { + "version": "2.15.1", + "resolved": "https://registry.npm.taobao.org/commander/download/commander-2.15.1.tgz?cache=0&sync_timestamp=1616364009866&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcommander%2Fdownload%2Fcommander-2.15.1.tgz", + "integrity": "sha1-30boZ9D8Kuxmo0ZitAapzK//Ww8=", + "dev": true + }, + "debug": { + "version": "4.3.1", + "resolved": "https://registry.npm.taobao.org/debug/download/debug-4.3.1.tgz?cache=0&sync_timestamp=1607566580543&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdebug%2Fdownload%2Fdebug-4.3.1.tgz", + "integrity": "sha1-8NIpxQXgxtjEmsVT0bE9wYP2su4=", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npm.taobao.org/growl/download/growl-1.10.5.tgz", + "integrity": "sha1-8nNdwig2dPpnR4sQGBBZNVw2nl4=", + "dev": true + }, + "http-proxy-agent": { + "version": "4.0.1", + "resolved": "https://registry.npm.taobao.org/http-proxy-agent/download/http-proxy-agent-4.0.1.tgz", + "integrity": "sha1-ioyO9/WTLM+VPClsqCkblap0qjo=", + "dev": true, + "requires": { + "@tootallnate/once": "1", + "agent-base": "6", + "debug": "4" + } + }, + "https-proxy-agent": { + "version": "5.0.0", + "resolved": "https://registry.npm.taobao.org/https-proxy-agent/download/https-proxy-agent-5.0.0.tgz", + "integrity": "sha1-4qkFQqu2inYuCghQ9sntrf2FBrI=", + "dev": true, + "requires": { + "agent-base": "6", + "debug": "4" + } + }, + "mocha": { + "version": "5.2.0", + "resolved": "https://registry.npm.taobao.org/mocha/download/mocha-5.2.0.tgz?cache=0&sync_timestamp=1615538684891&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fmocha%2Fdownload%2Fmocha-5.2.0.tgz", + "integrity": "sha1-bYrlCPWRZ/lA8rWzxKYSrlDJCuY=", + "dev": true, + "requires": { + "browser-stdout": "1.3.1", + "commander": "2.15.1", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.5", + "he": "1.1.1", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "supports-color": "5.4.0" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npm.taobao.org/debug/download/debug-3.1.0.tgz?cache=0&sync_timestamp=1607566580543&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdebug%2Fdownload%2Fdebug-3.1.0.tgz", + "integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npm.taobao.org/glob/download/glob-7.1.2.tgz", + "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npm.taobao.org/ms/download/ms-2.0.0.tgz?cache=0&sync_timestamp=1607433905701&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fms%2Fdownload%2Fms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npm.taobao.org/supports-color/download/supports-color-5.4.0.tgz?cache=0&sync_timestamp=1618560959124&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsupports-color%2Fdownload%2Fsupports-color-5.4.0.tgz", + "integrity": "sha1-HGszdALCE3YF7+GfEP7DkPb6q1Q=", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } } }, "vscode-languageserver-types": { diff --git a/package.json b/package.json index bf01af2..a51362d 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "publisher": "aliyun", "icon": "media/aliyun-serverless-extension.png", "description": "Aliyun Function Compute extension. Lets you develop your serverless application of Aliyun within VSCode.", - "version": "1.27.16", + "version": "1.27.17", "engines": { "vscode": "^1.31.0" }, diff --git a/src/language-service/schema/ros/ALIYUN-FC-Function.json b/src/language-service/schema/ros/ALIYUN-FC-Function.json index 22b3ccc..97aafb7 100644 --- a/src/language-service/schema/ros/ALIYUN-FC-Function.json +++ b/src/language-service/schema/ros/ALIYUN-FC-Function.json @@ -46,6 +46,18 @@ }, "Code": { "type": "object" + }, + "InstanceType": { + "type": "string" + }, + "CustomContainerConfig": { + "type": "object" + }, + "CAPort": { + "type": "integer" + }, + "AsyncConfiguration": { + "type": "object" } }, "required": [ diff --git a/src/language-service/schema/ros/ALIYUN-FC-Service.json b/src/language-service/schema/ros/ALIYUN-FC-Service.json index 28dbcbf..6d48a8b 100644 --- a/src/language-service/schema/ros/ALIYUN-FC-Service.json +++ b/src/language-service/schema/ros/ALIYUN-FC-Service.json @@ -31,6 +31,9 @@ }, "LogConfig": { "type": "object" + }, + "TracingConfig": { + "type": "string" } }, "required": [ diff --git a/src/language-service/schema/rosSchema.ts b/src/language-service/schema/rosSchema.ts index 0f578a2..e667cdd 100644 --- a/src/language-service/schema/rosSchema.ts +++ b/src/language-service/schema/rosSchema.ts @@ -68,6 +68,13 @@ export const rosSchema = { "InternetAccess": { "type": "boolean" }, + "TracingConfig": { + "type": "string", + "enum": [ + "Enable", + "Disable" + ] + }, "VpcConfig": { "oneOf": [ { "type": "string" }, @@ -259,7 +266,34 @@ export const rosSchema = { }, "InstanceConcurrency": { "type": "integer" - } + }, + "InstanceLifecycleConfig": { + "type": "object", + "properties": { + "PreFreeze": { + "type": "object", + "properties": { + "Handler": { + "type": "string" + }, + "Timeout": { + "type": "integer" + } + } + }, + "PreStop": { + "type": "object", + "properties": { + "Handler": { + "type": "string" + }, + "Timeout": { + "type": "integer" + } + } + } + } + }, }, "required": (data: any) => { if (data.Runtime && data.Runtime.value === "custom-container") { diff --git a/src/schema/constants.ts b/src/schema/constants.ts index e66f328..23ca1b8 100644 --- a/src/schema/constants.ts +++ b/src/schema/constants.ts @@ -150,6 +150,10 @@ export const MEMORYSIZE_INSERT_TEXT = "MemorySize: ${1|" + SUPPORTED_MEMORYSIZES.join(",") + "|}" +export const TRACINGCONFIG_INSERT_TEXT = + "TracingConfig: ${1|" + + "Enable, Disable" + + "|}" export const TIMER_TRIGGER_INSERT_TEXT = "${1:timeTrigger}:\n" + " Type: Timer\n" + diff --git a/src/schema/schema.ts b/src/schema/schema.ts index d9b8cf9..73af8f8 100644 --- a/src/schema/schema.ts +++ b/src/schema/schema.ts @@ -52,6 +52,7 @@ import { CDN_TRIGGER_INSERT_TEXT, MEMORYSIZE_INSERT_TEXT, FLOW_INSERT_TEXT, + TRACINGCONFIG_INSERT_TEXT } from './constants'; // TODO: schema 的进一步定义 @@ -214,6 +215,7 @@ const functionSchema = { 'InitializationTimeout': {}, 'EnvironmentVariables': {}, 'InstanceConcurrency': {}, + 'InstanceLifecycleConfig': {} } }, }, @@ -264,6 +266,9 @@ const serviceSchema = { 'LogConfig': logConfigSchema, 'NasConfig': nasConfigSchema, 'Description': {}, + 'TracingConfig': { + insertText: TRACINGCONFIG_INSERT_TEXT + }, }, }, [ALIYUN_SERVERLESS_FUNCTION_TYPE]: functionSchema, From 5f3ff5de134277f16c4de903f1dddb2c1bba1ce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=83=E9=A3=8E?= Date: Tue, 27 Apr 2021 14:12:50 +0800 Subject: [PATCH 2/2] lint code --- src/commands/createFunction.ts | 15 ++++++++----- src/services/FunService.ts | 32 +++++++++++++-------------- src/utils/file.ts | 40 +++++++++++++++++----------------- src/utils/fun.ts | 10 ++++----- src/utils/runtime.ts | 10 ++++----- 5 files changed, 56 insertions(+), 51 deletions(-) diff --git a/src/commands/createFunction.ts b/src/commands/createFunction.ts index 941338d..cfd0036 100644 --- a/src/commands/createFunction.ts +++ b/src/commands/createFunction.ts @@ -6,7 +6,11 @@ import { getSupportedRuntimes, isSupportedRuntime, isNodejs, isPython } from '.. import { serverlessCommands, serverlessConfigs } from '../utils/constants'; import { isNotEmpty, checkExistsWithTimeout } from '../utils/file'; import { createCodeFile, isCustomRuntime } from '../utils/runtime'; -import { getSupportedCustomRuntimeTemplates, isSupportedCustomRuntimeTemplates, createCustomRuntimeCodeFile } from '../utils/runtime'; +import { + getSupportedCustomRuntimeTemplates, + isSupportedCustomRuntimeTemplates, + createCustomRuntimeCodeFile +} from '../utils/runtime'; import { recordPageView } from '../utils/visitor'; import { ServiceResource } from '../models/resource'; import { TemplateService } from '../services/TemplateService'; @@ -37,7 +41,8 @@ async function process(context: vscode.ExtensionContext, serviceName: string, te label: 'HTTP', description: 'HTTP Trigger', }]; - const customRuntimeTemplates: vscode.QuickPickItem[] = getSupportedCustomRuntimeTemplates().map(label => { label }); + const customRuntimeTemplates: vscode.QuickPickItem[] = + getSupportedCustomRuntimeTemplates().map(label => { label }); const runtimes: vscode.QuickPickItem[] = getSupportedRuntimes().map(label => { label }); @@ -162,9 +167,9 @@ async function process(context: vscode.ExtensionContext, serviceName: string, te async function validateCreateFuncionState(state: State): Promise { const functionTypes = ['NORMAL', 'HTTP']; if (!state || !state.serviceName - || !state.functionName + || !state.functionName || (!isCustomRuntime(state.runtime) && !functionTypes.includes(state.type)) - || !isSupportedRuntime(state.runtime) + || !isSupportedRuntime(state.runtime) || (isCustomRuntime(state.runtime) && !isSupportedCustomRuntimeTemplates(state.functionTemplate))) { return false; } @@ -194,7 +199,7 @@ async function process(context: vscode.ExtensionContext, serviceName: string, te await createCodeFile(type, runtime, codeUriPath); } } - + const state = await collectFuncInfo(); if (!await validateCreateFuncionState(state)) { return; diff --git a/src/services/FunService.ts b/src/services/FunService.ts index 70aa6a6..44220e5 100644 --- a/src/services/FunService.ts +++ b/src/services/FunService.ts @@ -8,7 +8,7 @@ import { serverlessConfigs } from '../utils/constants'; import { isSupportedCustomRuntimeTemplates, isSupportedSystemRuntimeTemplates } from '../utils/runtime' export class FunService { - constructor (private templatePath: string) { + constructor(private templatePath: string) { } @@ -40,7 +40,7 @@ export class FunService { }); } - deploy(serviceName?: string, functionName? :string) { + deploy(serviceName?: string, functionName?: string) { const terminal = terminalService.getFunctionComputeTerminal(path.dirname(this.templatePath)); const assumeYes = vscode.workspace.getConfiguration().get(serverlessConfigs.ALIYUN_FC_FUN_DEPLOY_ASSUMEYES) ? '-y' : ''; @@ -55,7 +55,7 @@ export class FunService { } syncNas(serviceName: string, mountDir: string) { - const terminal = terminalService.getFunctionComputeTerminal(path.dirname(this.templatePath)); + const terminal = terminalService.getFunctionComputeTerminal(path.dirname(this.templatePath)); getFunBin().then(funBin => { const command = `${funBin} nas sync -s ${serviceName} -m ${mountDir}`; terminal.sendText(command); @@ -64,7 +64,7 @@ export class FunService { } localInvoke(serviceName: string, functionName: string, eventFilePath: string, reuse: boolean) { - const terminal = terminalService.getFunctionComputeTerminal(path.dirname(this.templatePath)); + const terminal = terminalService.getFunctionComputeTerminal(path.dirname(this.templatePath)); getFunBin().then(funBin => { const command = `${funBin} local invoke ${serviceName}/${functionName} -e ${this.escapeSpace(eventFilePath)} ` @@ -77,13 +77,13 @@ export class FunService { localInvokeDebug(serviceName: string, functionName: string, debugPort: string, eventFilePath: string, reuse: boolean): vscode.Terminal { - const terminal = terminalService.getFunctionComputeTerminal(path.dirname(this.templatePath)); + const terminal = terminalService.getFunctionComputeTerminal(path.dirname(this.templatePath)); getFunBin().then(funBin => { /* eslint-disable max-len */ const command = - `${funBin} local invoke ${serviceName}/${functionName} -d ${debugPort} -e ${this.escapeSpace(eventFilePath)} ` - + - (reuse ? '' : '--no-reuse'); + `${funBin} local invoke ${serviceName}/${functionName} -d ${debugPort} -e ${this.escapeSpace(eventFilePath)} ` + + + (reuse ? '' : '--no-reuse'); terminal.sendText(command); terminal.show(); }) @@ -138,7 +138,7 @@ export class FunService { } remoteInvokeWithEventFilePath(serviceName: string, functionName: string, eventFilePath: string) { - const terminal = terminalService.getFunctionComputeTerminal(path.dirname(this.templatePath)); + const terminal = terminalService.getFunctionComputeTerminal(path.dirname(this.templatePath)); getFunBin().then(funBin => { const command = `${funBin} invoke ${serviceName}/${functionName} -f ${this.escapeSpace(eventFilePath)}`; @@ -148,7 +148,7 @@ export class FunService { } remoteInvokeWithStdin(serviceName: string, functionName: string) { - const terminal = terminalService.getFunctionComputeTerminal(path.dirname(this.templatePath)); + const terminal = terminalService.getFunctionComputeTerminal(path.dirname(this.templatePath)); getFunBin().then(funBin => { const command = `${funBin} invoke ${serviceName}/${functionName} -s`; @@ -163,13 +163,13 @@ export class FunService { } private validateInitTemplates(template: string): boolean { - const runtimes = + const runtimes = ['nodejs8', 'nodejs6', 'python3', 'python2.7', 'java8', 'php7.2', 'custom-golang', - 'custom-springboot', 'custom-golang', 'custom-fsharp', 'custom-dart', 'custom-lua', - 'custom-powershell', 'custom-ruby', 'custom-rust', 'custom-typescript', 'custom-cpp']; - const templates = - [ 'http-trigger-spring-boot', 'http-trigger-node-puppeteer'] - return runtimes.includes(template) || templates.includes(template) ; + 'custom-springboot', 'custom-golang', 'custom-fsharp', 'custom-dart', 'custom-lua', + 'custom-powershell', 'custom-ruby', 'custom-rust', 'custom-typescript', 'custom-cpp']; + const templates = + ['http-trigger-spring-boot', 'http-trigger-node-puppeteer'] + return runtimes.includes(template) || templates.includes(template); } private escapeSpace(str: string): string { diff --git a/src/utils/file.ts b/src/utils/file.ts index 9fbf524..aa6f6ec 100644 --- a/src/utils/file.ts +++ b/src/utils/file.ts @@ -78,27 +78,27 @@ export const createLaunchFile = createFileRecursively(`{ export function checkExistsWithTimeout(filePath: string, timeout: number) { return new Promise(function (resolve, reject) { - var timer = setTimeout(function () { - watcher.close(); - reject(new Error('File did not exists and was not created during the timeout.')); - }, timeout); + var timer = setTimeout(function () { + watcher.close(); + reject(new Error('File did not exists and was not created during the timeout.')); + }, timeout); - fs.access(filePath, fs.constants.R_OK, function (err) { - if (!err) { - clearTimeout(timer); - watcher.close(); - resolve(); - } - }); + fs.access(filePath, fs.constants.R_OK, function (err) { + if (!err) { + clearTimeout(timer); + watcher.close(); + resolve(); + } + }); - var dir = path.dirname(filePath); - var basename = path.basename(filePath); - var watcher = fs.watch(dir, function (eventType, filename) { - if (eventType === 'rename' && filename === basename) { - clearTimeout(timer); - watcher.close(); - resolve(); - } - }); + var dir = path.dirname(filePath); + var basename = path.basename(filePath); + var watcher = fs.watch(dir, function (eventType, filename) { + if (eventType === 'rename' && filename === basename) { + clearTimeout(timer); + watcher.close(); + resolve(); + } + }); }); } diff --git a/src/utils/fun.ts b/src/utils/fun.ts index 989ef9d..17cfb1f 100644 --- a/src/utils/fun.ts +++ b/src/utils/fun.ts @@ -4,7 +4,7 @@ import * as os from 'os'; import * as fs from 'fs'; import * as download from 'download'; import * as unzipper from 'unzipper'; -import { cpUtils } from './cpUtils'; +import { cpUtils } from './cpUtils'; import { createFile, isPathExists, createDirectory } from './file'; import { ext } from '../extensionVariables'; @@ -12,7 +12,7 @@ const { dependencies } = require('../../package.json'); const FUN_VERSION = dependencies['@alicloud/fun'] || '3.0.1'; abstract class FunExecutorGenerator { - async generate(): Promise { + async generate(): Promise { if (!this.exists() || await this.needUpdate()) { await this.doGenerate(); } @@ -42,7 +42,7 @@ class PosixFunExecutorGenerator extends FunExecutorGenerator { const funPath = this.getFunPath(); const actualFunEntryPath = path.resolve(ext.context.extensionPath, 'node_modules', '@alicloud', 'fun', 'bin', 'fun.js'); - try { + try { const electronPath = await cpUtils.executeCommand(undefined, undefined, `${funPath}`, '--electron-path'); const funEntryPath = await cpUtils.executeCommand(undefined, undefined, `${funPath}`, '--fun-path'); return process.argv0 !== electronPath.trim() || actualFunEntryPath !== funEntryPath.trim(); @@ -70,7 +70,7 @@ class PosixFunExecutorGenerator extends FunExecutorGenerator { fs.chmodSync(funPath, 0o755); } catch (err) { vscode.window.showErrorMessage(err.message); - throw(err); + throw (err); } return true; @@ -122,7 +122,7 @@ class WindowsFunExecutorGenerator extends FunExecutorGenerator { }); }).catch(err => { vscode.window.showErrorMessage(err.message); - throw(err); + throw (err); }); return true; } diff --git a/src/utils/runtime.ts b/src/utils/runtime.ts index fb7883c..a7868e6 100644 --- a/src/utils/runtime.ts +++ b/src/utils/runtime.ts @@ -10,7 +10,7 @@ const cp = util.promisify(ncp); const supportedRuntimes = ['nodejs6', 'nodejs8', 'nodejs10', 'nodejs12', 'python2.7', 'python3', 'php7.2', 'java8', 'dotnetcore2.1', 'custom']; - const types = ['NORMAL', 'HTTP']; +const types = ['NORMAL', 'HTTP']; const supportedSystemRuntimeTemplates = ['event-nodejs12', 'event-nodejs10', 'event-nodejs8', 'event-nodejs6', 'event-python3', @@ -218,7 +218,7 @@ export function createPythonHelloWorldIndexFile(ph: string): boolean { const srcPath = path.join(__dirname, '..', '..', 'templates', 'python-helloworld', 'index.py'); fs.copyFileSync(srcPath, ph); return true; - } catch(err) { + } catch (err) { return false; } } @@ -228,7 +228,7 @@ export function createPythonHttpIndexFile(ph: string): boolean { const srcPath = path.join(__dirname, '..', '..', 'templates', 'python-http', 'index.py'); fs.copyFileSync(srcPath, ph); return true; - } catch(err) { + } catch (err) { return false; } } @@ -238,7 +238,7 @@ export function createPhpHelloWorldIndexFile(ph: string): boolean { const srcPath = path.join(__dirname, '..', '..', 'templates', 'php-helloworld', 'index.php'); fs.copyFileSync(srcPath, ph); return true; - } catch(err) { + } catch (err) { return false; } } @@ -248,7 +248,7 @@ export function createPhpHttpIndexFile(ph: string): boolean { const srcPath = path.join(__dirname, '..', '..', 'templates', 'php-http', 'index.php'); fs.copyFileSync(srcPath, ph); return true; - } catch(err) { + } catch (err) { return false; } }