From e7f941cfe64fb8675d0d6981195f767349887950 Mon Sep 17 00:00:00 2001 From: rsonghuster Date: Fri, 8 Nov 2024 17:10:09 +0800 Subject: [PATCH] remove artifact --- __tests__/e2e/artifact/code/index.py | 2 - __tests__/e2e/artifact/s.yaml | 25 --- __tests__/e2e/artifact/s2.yaml | 24 --- __tests__/e2e/ci.sh | 7 - __tests__/e2e/custom-domain/s2.yaml | 2 +- __tests__/e2e/nodejs/code/package-lock.json | 131 --------------- __tests__/e2e/nodejs/s.yaml | 51 +++--- package-lock.json | 100 +++++------- package.json | 9 +- src/interface/index.ts | 1 - src/schema.json | 3 - src/subCommands/deploy/impl/function.ts | 171 +------------------- src/subCommands/deploy/index.ts | 6 +- src/subCommands/info/index.ts | 3 - src/subCommands/plan/index.ts | 1 - src/subCommands/remove/index.ts | 41 +---- 16 files changed, 77 insertions(+), 500 deletions(-) delete mode 100644 __tests__/e2e/artifact/code/index.py delete mode 100644 __tests__/e2e/artifact/s.yaml delete mode 100644 __tests__/e2e/artifact/s2.yaml delete mode 100644 __tests__/e2e/nodejs/code/package-lock.json diff --git a/__tests__/e2e/artifact/code/index.py b/__tests__/e2e/artifact/code/index.py deleted file mode 100644 index 8c03624..0000000 --- a/__tests__/e2e/artifact/code/index.py +++ /dev/null @@ -1,2 +0,0 @@ -def handler(event, context): - return "hello wolrd!\n" diff --git a/__tests__/e2e/artifact/s.yaml b/__tests__/e2e/artifact/s.yaml deleted file mode 100644 index dbc9c82..0000000 --- a/__tests__/e2e/artifact/s.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# ------------------------------------ -# 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 -# 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ -# 有问题快来钉钉群问一下吧:33947367 -# ------------------------------------ -edition: 3.0.0 -name: hello-world-app -access: "quanxi" - -vars: - region: ${env('REGION', 'cn-huhehaote')} - -resources: - hello_world: - component: ${env('fc_component_version', path('../../../'))} - props: - region: ${vars.region} - functionName: "test-devs-artifact" - description: 'hello world by serverless devs' - runtime: "python3.10" - code: ./code - artifact: test-devs-artifact-1001 - handler: index.handler - memorySize: 128 - timeout: 40 diff --git a/__tests__/e2e/artifact/s2.yaml b/__tests__/e2e/artifact/s2.yaml deleted file mode 100644 index b3f4c12..0000000 --- a/__tests__/e2e/artifact/s2.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# ------------------------------------ -# 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 -# 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ -# 有问题快来钉钉群问一下吧:33947367 -# ------------------------------------ -edition: 3.0.0 -name: hello-world-app -access: "quanxi" - -vars: - region: ${env('REGION', 'cn-huhehaote')} - -resources: - hello_world: - component: ${env('fc_component_version', path('../../../'))} - props: - region: ${vars.region} - functionName: "test-devs-artifact-2" - description: 'hello world by serverless devs' - runtime: "python3.10" - artifact: test-devs-artifact-1001 - handler: index.handler - memorySize: 128 - timeout: 40 diff --git a/__tests__/e2e/ci.sh b/__tests__/e2e/ci.sh index 5c19801..748034e 100755 --- a/__tests__/e2e/ci.sh +++ b/__tests__/e2e/ci.sh @@ -20,13 +20,6 @@ s info -t s2.yaml s remove -y -t s2.yaml cd .. -# echo "test artifact" -# cd artifact -# s deploy -y -# s invoke -# s info -# s remove -y - # s deploy -y -t s2.yaml # s invoke -t s2.yaml # s info -t s2.yaml diff --git a/__tests__/e2e/custom-domain/s2.yaml b/__tests__/e2e/custom-domain/s2.yaml index d58d112..10a0bd2 100644 --- a/__tests__/e2e/custom-domain/s2.yaml +++ b/__tests__/e2e/custom-domain/s2.yaml @@ -3,7 +3,7 @@ name: hello-world-app access: "quanxi" vars: - region: ${env('REGION', 'cn-huhehaote')} + region: 'cn-huhehaote' resources: hello_world_1: diff --git a/__tests__/e2e/nodejs/code/package-lock.json b/__tests__/e2e/nodejs/code/package-lock.json deleted file mode 100644 index 00ea0a2..0000000 --- a/__tests__/e2e/nodejs/code/package-lock.json +++ /dev/null @@ -1,131 +0,0 @@ -{ - "name": "code", - "version": "1.0.0", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "name": "code", - "version": "1.0.0", - "license": "ISC", - "dependencies": { - "chalk": "^4.1.0" - } - }, - "node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "license": "MIT", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "license": "MIT", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "license": "MIT" - }, - "node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "license": "MIT", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - } - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "requires": { - "has-flag": "^4.0.0" - } - } - } -} diff --git a/__tests__/e2e/nodejs/s.yaml b/__tests__/e2e/nodejs/s.yaml index 8b11261..9a48048 100644 --- a/__tests__/e2e/nodejs/s.yaml +++ b/__tests__/e2e/nodejs/s.yaml @@ -15,7 +15,7 @@ resources: code: ./code handler: event.handler memorySize: 128 - timeout: 30 + timeout: 60 instanceLifecycleConfig: initializer: handler: event.initializer @@ -28,29 +28,36 @@ resources: onSuccess: destination: acs:fc:${vars.region}::functions/serverless-devs-ci-async-invoke-config-succ maxAsyncEventAgeInSeconds: 360 - maxAsyncRetryAttempts: 3 + maxAsyncRetryAttempts: 1 asyncTask: true qualifier: LATEST - # provisionConfig: - # target: 1 - # alwaysAllocateCPU: false - # alwaysAllocateGPU: false - # scheduledActions: - # - name: scheduled-actions - # startTime: '2023-08-15T02:04:00.000Z' - # endTime: '2033-08-15T03:04:00.000Z' - # target: 1 - # scheduleExpression: cron(0 0 4 * * *) - # timeZone: '' - # targetTrackingPolicies: - # - name: target-tracking-policies - # startTime: '2023-08-15T02:05:00.000Z' - # endTime: '2033-08-15T02:55:00.000Z' - # metricType: ProvisionedConcurrencyUtilization - # metricTarget: 0.6 - # minCapacity: 1 - # maxCapacity: 3 + provisionConfig: + target: 1 + alwaysAllocateCPU: false + alwaysAllocateGPU: false + scheduledActions: + - name: scheduled-actions + startTime: '2023-08-15T02:04:00.000Z' + endTime: '2033-08-15T03:04:00.000Z' + target: 1 + scheduleExpression: cron(0 0 4 * * *) + timeZone: '' + # targetTrackingPolicies: + # - name: target-tracking-policies + # startTime: '2023-08-15T02:05:00.000Z' + # endTime: '2033-08-15T02:55:00.000Z' + # metricType: ProvisionedConcurrencyUtilization + # metricTarget: 0.6 + # minCapacity: 1 + # maxCapacity: 3 concurrencyConfig: - reservedConcurrency: 3 \ No newline at end of file + reservedConcurrency: 1 + + customDomain: + domainName: auto + protocol: HTTP + route: + path: /* + qualifier: LATEST \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 02e5f3d..a7637dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,9 +10,8 @@ "hasInstallScript": true, "license": "ISC", "dependencies": { - "@alicloud/devs20230714": "^1.0.1", "@alicloud/fc2": "^2.6.6", - "@alicloud/fc20230330": "^4.1.3", + "@alicloud/fc20230330": "^4.1.4", "@alicloud/pop-core": "^1.7.13", "@serverless-cd/srm-aliyun-pop-core": "^0.0.7-beta.16", "@serverless-cd/srm-aliyun-ram20150501": "^0.0.2-beta.9", @@ -45,10 +44,10 @@ "devDependencies": { "@serverless-devs/component-interface": "^0.0.6", "@serverless-devs/logger": "^0.0.5", - "@types/jest": "^29.5.12", + "@types/jest": "^29.5.14", "@types/lodash": "^4.17.1", "@types/node": "^20.12.11", - "@vercel/ncc": "^0.38.1", + "@vercel/ncc": "^0.38.2", "f2elint": "^2.2.1", "jest": "^29.7.0", "patch-package": "^8.0.0", @@ -70,9 +69,9 @@ } }, "node_modules/@alicloud/credentials": { - "version": "2.3.0", - "resolved": "https://registry.npmmirror.com/@alicloud/credentials/-/credentials-2.3.0.tgz", - "integrity": "sha512-x0vf/m1BzkqYXAj2Hkd22O35josx5P4VCzq/9EvTBjA7aGLX/P6JDz7QVp+gnhLjPJyvwAbErvJRYq4gIo4IMA==", + "version": "2.4.0", + "resolved": "https://registry.npmmirror.com/@alicloud/credentials/-/credentials-2.4.0.tgz", + "integrity": "sha512-TeAyiXnqv9ZudpeMMHbGah5Gyey8Rr9i7hydesyT07zYwBAOd+yWfR6dnFH8e3l1LfRbZU/AQ+6j0DsmfIQ+KQ==", "dependencies": { "@alicloud/tea-typescript": "^1.5.3", "httpx": "^2.2.0", @@ -135,19 +134,6 @@ "@alicloud/tea-typescript": "^1.5.1" } }, - "node_modules/@alicloud/devs20230714": { - "version": "1.0.4", - "resolved": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/@alicloud/devs20230714/-/@alicloud/devs20230714-1.0.4.tgz", - "integrity": "sha512-CW4jgz14jQYNMmskMxOjLdHkv9V2n4j2c8NiKa4S1O8S0WYkWIObcJTe07kdWHdIlDRR/bR3vwZaylwC7VSbNA==", - "license": "Apache-2.0", - "dependencies": { - "@alicloud/endpoint-util": "^0.0.1", - "@alicloud/openapi-client": "^0.4.11", - "@alicloud/openapi-util": "^0.3.2", - "@alicloud/tea-typescript": "^1.7.1", - "@alicloud/tea-util": "^1.4.9" - } - }, "node_modules/@alicloud/endpoint-util": { "version": "0.0.1", "resolved": "https://registry.npmmirror.com/@alicloud/endpoint-util/-/endpoint-util-0.0.1.tgz", @@ -185,12 +171,12 @@ } }, "node_modules/@alicloud/fc20230330": { - "version": "4.1.3", - "resolved": "https://registry.npmmirror.com/@alicloud/fc20230330/-/fc20230330-4.1.3.tgz", - "integrity": "sha512-/CDrzZ98kRtSTmuylWXCZKilOYI7UEFh4BX3MzwseD0Y8Erq6abhPMSCfVXGmlNzxh1KgQSBNZ/FG1RW39tO8w==", + "version": "4.1.4", + "resolved": "https://registry.npmmirror.com/@alicloud/fc20230330/-/fc20230330-4.1.4.tgz", + "integrity": "sha512-a6tUL1eX4TmPHT5e/l335k0yD3a3PYD1CG68GjZ89H11FDALvbMTFH9CPtaVbNAeb1lcS57uVVbXGP/jR8poNw==", "dependencies": { "@alicloud/endpoint-util": "^0.0.1", - "@alicloud/openapi-client": "^0.4.11", + "@alicloud/openapi-client": "^0.4.12", "@alicloud/openapi-util": "^0.3.2", "@alicloud/tea-typescript": "^1.7.1", "@alicloud/tea-util": "^1.4.9" @@ -247,11 +233,11 @@ } }, "node_modules/@alicloud/openapi-client": { - "version": "0.4.11", - "resolved": "https://registry.npmmirror.com/@alicloud/openapi-client/-/openapi-client-0.4.11.tgz", - "integrity": "sha512-WEDGbfSx4Lcjj7ij3fv+6HBDua3l0tMGott6jaFO+pI42ctTJlK/y/AcyjFGwrf1UCQneauI2gEo6+5hHbv4Bg==", + "version": "0.4.12", + "resolved": "https://registry.npmmirror.com/@alicloud/openapi-client/-/openapi-client-0.4.12.tgz", + "integrity": "sha512-WuKfFqwY3/+wuNawzfJAirNA00XDI7fm9fUhWK7siGZEh0R2XJR0Y54MLW7WWItX06fAghUvnDhKWZH3AgN+yg==", "dependencies": { - "@alicloud/credentials": "^2", + "@alicloud/credentials": "^2.3.1", "@alicloud/gateway-spi": "^0.0.8", "@alicloud/openapi-util": "^0.3.2", "@alicloud/tea-typescript": "^1.7.1", @@ -2677,9 +2663,9 @@ } }, "node_modules/@types/jest": { - "version": "29.5.12", - "resolved": "https://registry.npmmirror.com/@types/jest/-/jest-29.5.12.tgz", - "integrity": "sha512-eDC8bTvT/QhYdxJAulQikueigY5AsdBRH2yDKW3yveW7svY3+DzN84/2NUgkw10RTiJbWqZrTtoGVdYlvFJdLw==", + "version": "29.5.14", + "resolved": "https://registry.npmmirror.com/@types/jest/-/jest-29.5.14.tgz", + "integrity": "sha512-ZN+4sdnLUbo8EVvVc2ao0GFW6oVrQRPn4K2lglySj7APvSrgzxHiNNK99us4WDMi57xxA2yggblIAMNhXOotLQ==", "dev": true, "dependencies": { "expect": "^29.0.0", @@ -3146,9 +3132,9 @@ } }, "node_modules/@vercel/ncc": { - "version": "0.38.1", - "resolved": "https://registry.npmmirror.com/@vercel/ncc/-/ncc-0.38.1.tgz", - "integrity": "sha512-IBBb+iI2NLu4VQn3Vwldyi2QwaXt5+hTyh58ggAMoCGE6DJmPvwL3KPBWcJl1m9LYPChBLE980Jw+CS4Wokqxw==", + "version": "0.38.2", + "resolved": "https://registry.npmmirror.com/@vercel/ncc/-/ncc-0.38.2.tgz", + "integrity": "sha512-3yel3jaxUg9pHBv4+KeC9qlbdZPug+UMtUOlhvpDYCMSgcNSrS2Hv1LoqMsOV7hf2lYscx+BESfJOIla1WsmMQ==", "dev": true, "bin": { "ncc": "dist/ncc/cli.js" @@ -13571,9 +13557,9 @@ "dev": true }, "@alicloud/credentials": { - "version": "2.3.0", - "resolved": "https://registry.npmmirror.com/@alicloud/credentials/-/credentials-2.3.0.tgz", - "integrity": "sha512-x0vf/m1BzkqYXAj2Hkd22O35josx5P4VCzq/9EvTBjA7aGLX/P6JDz7QVp+gnhLjPJyvwAbErvJRYq4gIo4IMA==", + "version": "2.4.0", + "resolved": "https://registry.npmmirror.com/@alicloud/credentials/-/credentials-2.4.0.tgz", + "integrity": "sha512-TeAyiXnqv9ZudpeMMHbGah5Gyey8Rr9i7hydesyT07zYwBAOd+yWfR6dnFH8e3l1LfRbZU/AQ+6j0DsmfIQ+KQ==", "requires": { "@alicloud/tea-typescript": "^1.5.3", "httpx": "^2.2.0", @@ -13638,18 +13624,6 @@ "@alicloud/tea-typescript": "^1.5.1" } }, - "@alicloud/devs20230714": { - "version": "1.0.4", - "resolved": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/@alicloud/devs20230714/-/@alicloud/devs20230714-1.0.4.tgz", - "integrity": "sha512-CW4jgz14jQYNMmskMxOjLdHkv9V2n4j2c8NiKa4S1O8S0WYkWIObcJTe07kdWHdIlDRR/bR3vwZaylwC7VSbNA==", - "requires": { - "@alicloud/endpoint-util": "^0.0.1", - "@alicloud/openapi-client": "^0.4.11", - "@alicloud/openapi-util": "^0.3.2", - "@alicloud/tea-typescript": "^1.7.1", - "@alicloud/tea-util": "^1.4.9" - } - }, "@alicloud/endpoint-util": { "version": "0.0.1", "resolved": "https://registry.npmmirror.com/@alicloud/endpoint-util/-/endpoint-util-0.0.1.tgz", @@ -13689,12 +13663,12 @@ } }, "@alicloud/fc20230330": { - "version": "4.1.3", - "resolved": "https://registry.npmmirror.com/@alicloud/fc20230330/-/fc20230330-4.1.3.tgz", - "integrity": "sha512-/CDrzZ98kRtSTmuylWXCZKilOYI7UEFh4BX3MzwseD0Y8Erq6abhPMSCfVXGmlNzxh1KgQSBNZ/FG1RW39tO8w==", + "version": "4.1.4", + "resolved": "https://registry.npmmirror.com/@alicloud/fc20230330/-/fc20230330-4.1.4.tgz", + "integrity": "sha512-a6tUL1eX4TmPHT5e/l335k0yD3a3PYD1CG68GjZ89H11FDALvbMTFH9CPtaVbNAeb1lcS57uVVbXGP/jR8poNw==", "requires": { "@alicloud/endpoint-util": "^0.0.1", - "@alicloud/openapi-client": "^0.4.11", + "@alicloud/openapi-client": "^0.4.12", "@alicloud/openapi-util": "^0.3.2", "@alicloud/tea-typescript": "^1.7.1", "@alicloud/tea-util": "^1.4.9" @@ -13753,11 +13727,11 @@ } }, "@alicloud/openapi-client": { - "version": "0.4.11", - "resolved": "https://registry.npmmirror.com/@alicloud/openapi-client/-/openapi-client-0.4.11.tgz", - "integrity": "sha512-WEDGbfSx4Lcjj7ij3fv+6HBDua3l0tMGott6jaFO+pI42ctTJlK/y/AcyjFGwrf1UCQneauI2gEo6+5hHbv4Bg==", + "version": "0.4.12", + "resolved": "https://registry.npmmirror.com/@alicloud/openapi-client/-/openapi-client-0.4.12.tgz", + "integrity": "sha512-WuKfFqwY3/+wuNawzfJAirNA00XDI7fm9fUhWK7siGZEh0R2XJR0Y54MLW7WWItX06fAghUvnDhKWZH3AgN+yg==", "requires": { - "@alicloud/credentials": "^2", + "@alicloud/credentials": "^2.3.1", "@alicloud/gateway-spi": "^0.0.8", "@alicloud/openapi-util": "^0.3.2", "@alicloud/tea-typescript": "^1.7.1", @@ -15767,9 +15741,9 @@ } }, "@types/jest": { - "version": "29.5.12", - "resolved": "https://registry.npmmirror.com/@types/jest/-/jest-29.5.12.tgz", - "integrity": "sha512-eDC8bTvT/QhYdxJAulQikueigY5AsdBRH2yDKW3yveW7svY3+DzN84/2NUgkw10RTiJbWqZrTtoGVdYlvFJdLw==", + "version": "29.5.14", + "resolved": "https://registry.npmmirror.com/@types/jest/-/jest-29.5.14.tgz", + "integrity": "sha512-ZN+4sdnLUbo8EVvVc2ao0GFW6oVrQRPn4K2lglySj7APvSrgzxHiNNK99us4WDMi57xxA2yggblIAMNhXOotLQ==", "dev": true, "requires": { "expect": "^29.0.0", @@ -16129,9 +16103,9 @@ } }, "@vercel/ncc": { - "version": "0.38.1", - "resolved": "https://registry.npmmirror.com/@vercel/ncc/-/ncc-0.38.1.tgz", - "integrity": "sha512-IBBb+iI2NLu4VQn3Vwldyi2QwaXt5+hTyh58ggAMoCGE6DJmPvwL3KPBWcJl1m9LYPChBLE980Jw+CS4Wokqxw==", + "version": "0.38.2", + "resolved": "https://registry.npmmirror.com/@vercel/ncc/-/ncc-0.38.2.tgz", + "integrity": "sha512-3yel3jaxUg9pHBv4+KeC9qlbdZPug+UMtUOlhvpDYCMSgcNSrS2Hv1LoqMsOV7hf2lYscx+BESfJOIla1WsmMQ==", "dev": true }, "@yarnpkg/lockfile": { diff --git a/package.json b/package.json index 4c208f2..6b91565 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,8 @@ "author": "", "license": "ISC", "dependencies": { - "@alicloud/devs20230714": "^1.0.1", "@alicloud/fc2": "^2.6.6", - "@alicloud/fc20230330": "^4.1.3", + "@alicloud/fc20230330": "^4.1.4", "@alicloud/pop-core": "^1.7.13", "@serverless-cd/srm-aliyun-pop-core": "^0.0.7-beta.16", "@serverless-cd/srm-aliyun-ram20150501": "^0.0.2-beta.9", @@ -57,10 +56,10 @@ "devDependencies": { "@serverless-devs/component-interface": "^0.0.6", "@serverless-devs/logger": "^0.0.5", - "@types/jest": "^29.5.12", + "@types/jest": "^29.5.14", "@types/lodash": "^4.17.1", "@types/node": "^20.12.11", - "@vercel/ncc": "^0.38.1", + "@vercel/ncc": "^0.38.2", "f2elint": "^2.2.1", "jest": "^29.7.0", "patch-package": "^8.0.0", @@ -72,7 +71,7 @@ "typescript-json-schema": "^0.64.0" }, "resolutions": { - "@alicloud/devs20230714": { + "@alicloud/sls20191023": { "registry": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/" } } diff --git a/src/interface/index.ts b/src/interface/index.ts index cfa8cd0..3bc6825 100644 --- a/src/interface/index.ts +++ b/src/interface/index.ts @@ -12,7 +12,6 @@ export * from './async_invoke_config'; export interface IProps extends IFunction { region: IRegion; - artifact?: string; triggers?: ITrigger[]; asyncInvokeConfig?: IAsyncInvokeConfig; endpoint?: string; diff --git a/src/schema.json b/src/schema.json index 00c5a70..45163d4 100644 --- a/src/schema.json +++ b/src/schema.json @@ -969,9 +969,6 @@ } }, "properties": { - "artifact": { - "type": "string" - }, "asyncInvokeConfig": { "$ref": "#/definitions/IAsyncInvokeConfig" }, diff --git a/src/subCommands/deploy/impl/function.ts b/src/subCommands/deploy/impl/function.ts index 5d8eceb..bd72bae 100644 --- a/src/subCommands/deploy/impl/function.ts +++ b/src/subCommands/deploy/impl/function.ts @@ -1,8 +1,6 @@ import _ from 'lodash'; import { diffConvertYaml } from '@serverless-devs/diff'; import inquirer from 'inquirer'; -import tmpDir from 'temp-dir'; -import { v4 as uuidV4 } from 'uuid'; import fs from 'fs'; import assert from 'assert'; import path from 'path'; @@ -12,11 +10,7 @@ import { getRootHome } from '@serverless-devs/utils'; import logger from '../../../logger'; import { IFunction, IInputs } from '../../../interface'; -import { - FC_CLIENT_CONNECT_TIMEOUT, - FC_CLIENT_READ_TIMEOUT, - FC_RESOURCES_EMPTY_CONFIG, -} from '../../../default/config'; +import { FC_RESOURCES_EMPTY_CONFIG } from '../../../default/config'; import Acr from '../../../resources/acr'; import Sls from '../../../resources/sls'; import { RamClient } from '../../../resources/ram'; @@ -24,31 +18,24 @@ import FC, { GetApiType } from '../../../resources/fc'; import VPC_NAS from '../../../resources/vpc-nas'; import Base from './base'; import { ICredentials } from '@serverless-devs/component-interface'; -import { calculateCRC64, getFileSize, downloadFile } from '../../../utils'; -import Devs20230714, * as $Devs20230714 from '@alicloud/devs20230714'; -import * as $OpenApi from '@alicloud/openapi-client'; -import axios from 'axios'; -import OSS from 'ali-oss'; +import { calculateCRC64, getFileSize } from '../../../utils'; type IType = 'code' | 'config' | boolean; interface IOpts { type?: IType; yes?: boolean; skipPush?: boolean; - putArtifact?: boolean; } export default class Service extends Base { readonly type?: IType; readonly skipPush?: boolean = false; - putArtifact?: boolean = false; remote?: any; local: IFunction; createResource: Record = {}; acr: Acr; codeChecksum: string; - devsClient: Devs20230714; constructor(inputs: IInputs, opts: IOpts) { super(inputs, opts.yes); @@ -66,22 +53,14 @@ export default class Service extends Base { _.unset(this.local, 'triggers'); _.unset(this.local, 'asyncInvokeConfig'); _.unset(this.local, 'vpcBinding'); - _.unset(this.local, 'artifact'); _.unset(this.local, 'customDomain'); _.unset(this.local, 'provisionConfig'); _.unset(this.local, 'concurrencyConfig'); - - if (_.isEmpty(this.inputs.props.code) && this.inputs.props.artifact) { - this.putArtifact = false; - } - if (this.inputs.props.code && this.inputs.props.artifact) { - this.putArtifact = true; - } } // 准备动作 async before() { - const { AccountID: accountID } = await this.inputs.getCredential(); + await this.inputs.getCredential(); try { const r = await this.fcSdk.getFunction(this.local.functionName, GetApiType.simple); this.codeChecksum = _.get(r, 'codeChecksum', ''); @@ -102,25 +81,6 @@ export default class Service extends Base { const { local, remote } = await FC.replaceFunctionConfig(this.local, this.remote); this.local = local; this.remote = remote; - if (_.isEmpty(this.inputs.props.code) && this.inputs.props.artifact) { - await this.initDevsClient(); - const { artifact } = this.inputs.props; - let artifactName = ''; - if (artifact.split('/').length > 1) { - artifactName = artifact.split('/')[1].split('@')[0]; - } else { - artifactName = artifact.split('@')[0]; - } - const downPath: string = path.join(tmpDir, `${artifactName}_${accountID}_${uuidV4()}.zip`); - this.local.code = downPath; - if (_.includes(artifactName, '@')) { - artifactName = artifactName.split('@')[0]; - } - - const downloadArtifact = await this.devsClient.fetchArtifactDownloadUrl(artifactName); - const downloadUrl = downloadArtifact?.body?.url; - await downloadFile(downloadUrl, downPath); - } await this._plan(); } @@ -157,13 +117,7 @@ export default class Service extends Base { slsAuto: !_.isEmpty(this.createResource.sls), type: this.type, }); - - let artifact = {}; - if (this.putArtifact) { - artifact = await this.deployArtifact(); - } - - return { artifact }; + return this.needDeploy; } private _getAcr() { @@ -485,121 +439,4 @@ nasConfig: 'Variable must contain only strings', ); } - - // eslint-disable-next-line @typescript-eslint/member-ordering - public async deployArtifact() { - const { runtime, functionName } = this.inputs.props; - if (!FC.isCustomContainerRuntime(runtime)) { - const { artifact } = this.inputs.props; - let artifactName = ''; - if (artifact.split('/').length > 1) { - artifactName = artifact.split('/')[1].split('@')[0]; - } else { - artifactName = artifact.split('@')[0]; - } - logger.info(`putArtifact ${artifactName}`); - await this.initDevsClient(); - const { url } = await this.fcSdk.getFunctionCode(functionName, 'LATEST'); - // const truncateString = (s: string) => (s.length > 64 ? s.substring(0, 64) : s); - // const artifactName = truncateString(`${functionName}_${region}`); - - const downloadDir: string = path.join(tmpDir, 'artifacts'); - if (!fs.existsSync(downloadDir)) { - fs.mkdirSync(downloadDir); - } - const zipFile = path.join(downloadDir, `${artifactName}_${uuidV4()}.zip`); - - logger.debug(`download ${url} to ${zipFile}`); - await downloadFile(url, zipFile); - - const resp = await this.devsClient.fetchArtifactTempBucketToken(); - logger.debug(JSON.stringify(resp.body)); - const { credentials, ossRegion, ossBucketName, ossObjectName } = resp.body; - let ossEndpoint = 'https://oss-accelerate.aliyuncs.com'; - if (ossRegion.endsWith(process.env.FC_REGION)) { - ossEndpoint = `oss-${process.env.FC_REGION}-internal.aliyuncs.com`; - } - const ossClient = new OSS({ - endpoint: ossEndpoint, - accessKeyId: credentials.accessKeyId, - accessKeySecret: credentials.accessKeySecret, - stsToken: credentials.securityToken, - bucket: ossBucketName, - timeout: '600000', // 10min - refreshSTSToken: async () => { - const refreshToken = await axios.get('https://127.0.0.1/sts'); - return { - accessKeyId: refreshToken.data.credentials.AccessKeyId, - accessKeySecret: refreshToken.data.credentials.AccessKeySecret, - stsToken: refreshToken.data.credentials.SecurityToken, - }; - }, - }); - const r = await (ossClient as any).put(ossObjectName, zipFile); - logger.debug(JSON.stringify(r)); - - const ossUri = `oss://${ossRegion.substring(4)}/${ossBucketName}/${ossObjectName}`; - const input = new $Devs20230714.Artifact({ - name: artifactName, - description: 'artifact create by serverless-devs artifact command', - spec: new $Devs20230714.ArtifactSpec({ - uri: ossUri, - type: 'fc', - runtime, - }), - }); - logger.debug('create artifact...'); - try { - const createArtifactRequest = new $Devs20230714.CreateArtifactRequest({ body: input }); - const r2 = await this.devsClient.createArtifact(createArtifactRequest); - logger.debug(JSON.stringify(r2.body)); - const { arn, checksum } = r2.body.status; - return { - artifact: `${arn}@${checksum}`, - }; - } catch (error) { - if (error.message.includes('ArtifactAlreadyExists')) { - logger.debug('update artifact...'); - const putArtifactRequest = new $Devs20230714.PutArtifactRequest({ - body: input, - force: true, - }); - const r3 = await this.devsClient.putArtifact(artifactName, putArtifactRequest); - logger.debug(JSON.stringify(r3.body)); - const { arn, checksum } = r3.body.status; - return { - artifact: `${arn}@${checksum}`, - }; - } else { - logger.error(error.message); - throw error; - } - } - } - logger.info('skip putArtifact because custom container runtime'); - return {}; - } - - private async initDevsClient() { - const { - AccessKeyID: accessKeyId, - AccessKeySecret: accessKeySecret, - SecurityToken: securityToken, - } = await this.inputs.getCredential(); - const config = new $OpenApi.Config({ - accessKeyId, - accessKeySecret, - securityToken, - readTimeout: FC_CLIENT_READ_TIMEOUT, - connectTimeout: FC_CLIENT_CONNECT_TIMEOUT, - }); - config.endpoint = 'devs.cn-hangzhou.aliyuncs.com'; - if (process.env.ARTIFACT_ENDPOINT) { - config.endpoint = process.env.ARTIFACT_ENDPOINT; - } - if (process.env.artifact_endpoint) { - config.endpoint = process.env.artifact_endpoint; - } - this.devsClient = new Devs20230714(config); - } } diff --git a/src/subCommands/deploy/index.ts b/src/subCommands/deploy/index.ts index 7cf0904..26216b7 100644 --- a/src/subCommands/deploy/index.ts +++ b/src/subCommands/deploy/index.ts @@ -92,11 +92,7 @@ export default class Deploy { const info = new Info(this.inputs); info.setGetApiType(GetApiType.simpleUnsupported); const result = await info.run(); - const { artifact } = run1; - if (_.isEmpty(artifact)) { - return result; - } - const mergedObj = Object.assign({}, result, artifact); + const mergedObj = Object.assign({}, result); logger.debug(`mergedObj = ${JSON.stringify(mergedObj, null, 2)}`); return mergedObj; } diff --git a/src/subCommands/info/index.ts b/src/subCommands/info/index.ts index 4135b7a..3101f92 100644 --- a/src/subCommands/info/index.ts +++ b/src/subCommands/info/index.ts @@ -49,9 +49,6 @@ export default class Info { async run() { const functionConfig = await this.getFunction(); - if (this.inputs.props.artifact) { - functionConfig.artifact = `${this.inputs.props.artifact}@${functionConfig.codeChecksum}`; - } const triggers = await this.getTriggers(); const asyncInvokeConfig = await this.getAsyncInvokeConfig(); const vpcBindingConfig = await this.getVpcBing(); diff --git a/src/subCommands/plan/index.ts b/src/subCommands/plan/index.ts index 3f98a32..6fee3a6 100644 --- a/src/subCommands/plan/index.ts +++ b/src/subCommands/plan/index.ts @@ -110,7 +110,6 @@ export default class Plan { _.unset(local, 'asyncInvokeConfig'); _.unset(local, 'endpoint'); _.unset(local, 'vpcBinding'); - _.unset(local, 'artifact'); _.unset(local, 'customDomain'); _.unset(local, 'provisionConfig'); _.unset(local, 'concurrencyConfig'); diff --git a/src/subCommands/remove/index.ts b/src/subCommands/remove/index.ts index 4ed1e16..aec3b55 100644 --- a/src/subCommands/remove/index.ts +++ b/src/subCommands/remove/index.ts @@ -10,9 +10,6 @@ import { promptForConfirmOrDetails, sleep, transformCustomDomainProps } from '.. import loadComponent from '@serverless-devs/load-component'; import { IInputs as _IInputs } from '@serverless-devs/component-interface'; import { FC3_DOMAIN_COMPONENT_NAME } from '../../constant'; -import Devs20230714 from '@alicloud/devs20230714'; -import * as $OpenApi from '@alicloud/openapi-client'; -import { FC_CLIENT_CONNECT_TIMEOUT, FC_CLIENT_READ_TIMEOUT } from '../../default/config'; export default class Remove { private region: IRegion; @@ -98,22 +95,9 @@ export default class Remove { } try { await this.removeAsyncInvokeConfig(); + await this.removeCustomDomain(); await this.removeTrigger(); await this.removeFunction(); - await this.removeCustomDomain(); - - if (this.inputs.props.artifact) { - const devsClient = await this.initDevsClient(); - const { artifact } = this.inputs.props; - let artifactName = ''; - if (artifact.split('/').length > 1) { - artifactName = artifact.split('/')[1].split('@')[0]; - } else { - artifactName = artifact.split('@')[0]; - } - logger.info(`try delete artifact ${artifactName}`); - devsClient.deleteArtifact(artifactName); - } } catch (ex) { logger.error(`remove error: ${ex.message}`); } @@ -503,27 +487,4 @@ export default class Remove { logger.warn(`removeCustomDomain error: ${error}`); } } - - private async initDevsClient() { - const { - AccessKeyID: accessKeyId, - AccessKeySecret: accessKeySecret, - SecurityToken: securityToken, - } = await this.inputs.getCredential(); - const config = new $OpenApi.Config({ - accessKeyId, - accessKeySecret, - securityToken, - readTimeout: FC_CLIENT_READ_TIMEOUT, - connectTimeout: FC_CLIENT_CONNECT_TIMEOUT, - }); - config.endpoint = 'devs.cn-hangzhou.aliyuncs.com'; - if (process.env.ARTIFACT_ENDPOINT) { - config.endpoint = process.env.ARTIFACT_ENDPOINT; - } - if (process.env.artifact_endpoint) { - config.endpoint = process.env.artifact_endpoint; - } - return new Devs20230714(config); - } }