Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Commit 8f57f0b

Browse files
committed
add function source limit
1 parent b0d25e8 commit 8f57f0b

8 files changed

Lines changed: 42 additions & 6 deletions

File tree

lib/commands/env/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ commander_1.default
3333
item.Status === 'NORMAL' ? '正常' : '不可用'
3434
]);
3535
utils_1.printCliTable(head, tableData);
36-
const unavalibleEnv = data.find(item => item.Status === 'UNAVAILABLE');
37-
if (unavalibleEnv) {
38-
logger_1.warnLog(`您的环境中存在不可用的环境:[${unavalibleEnv.EnvId}],请留意!`);
36+
const unavailableEnv = data.find(item => item.Status === 'UNAVAILABLE');
37+
if (unavailableEnv) {
38+
logger_1.warnLog(`您的环境中存在不可用的环境:[${unavailableEnv.EnvId}],请留意!`);
3939
}
4040
});
4141
async function checkEnvAvailability(envId) {

lib/commands/functions/code-update.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@ const ora_1 = __importDefault(require("ora"));
77
const path_1 = __importDefault(require("path"));
88
const error_1 = require("../../error");
99
const function_1 = require("../../function");
10+
const env_1 = require("../../env");
1011
async function codeUpdate(ctx, options) {
1112
const { name, envId, config, functions } = ctx;
13+
const envInfo = await env_1.getEnvInfo(envId);
14+
if (envInfo.Source === 'miniapp') {
15+
throw new error_1.CloudBaseError('无法更新小程序云函数代码!');
16+
}
1217
const { codeSecret } = options;
1318
if (!name) {
1419
throw new error_1.CloudBaseError('请指定函数名称!');

lib/commands/functions/delete.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@ const inquirer_1 = __importDefault(require("inquirer"));
77
const error_1 = require("../../error");
88
const function_1 = require("../../function");
99
const logger_1 = require("../../logger");
10+
const env_1 = require("../../env");
1011
async function deleteFunc(ctx) {
1112
const { name, envId, functions } = ctx;
13+
const envInfo = await env_1.getEnvInfo(envId);
14+
if (envInfo.Source === 'miniapp') {
15+
throw new error_1.CloudBaseError('无法删除小程序云函数!');
16+
}
1217
let isBatchDelete = false;
1318
if (!name) {
1419
const answer = await inquirer_1.default.prompt({

lib/commands/functions/deploy.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@ const path_1 = __importDefault(require("path"));
88
const inquirer_1 = __importDefault(require("inquirer"));
99
const error_1 = require("../../error");
1010
const function_1 = require("../../function");
11+
const env_1 = require("../../env");
1112
async function deploy(ctx, commandOptions) {
1213
const { name, envId, config, functions } = ctx;
14+
const envInfo = await env_1.getEnvInfo(envId);
15+
if (envInfo.Source === 'miniapp') {
16+
throw new error_1.CloudBaseError('无法部署小程序云函数!');
17+
}
1318
const { force, codeSecret } = commandOptions;
1419
let isBatchCreating = false;
1520
if (!name) {

src/commands/env/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ program
3131
])
3232
printCliTable(head, tableData)
3333
// 不可用环境警告
34-
const unavalibleEnv = data.find(item => item.Status === 'UNAVAILABLE')
35-
if (unavalibleEnv) {
34+
const unavailableEnv = data.find(item => item.Status === 'UNAVAILABLE')
35+
if (unavailableEnv) {
3636
warnLog(
37-
`您的环境中存在不可用的环境:[${unavalibleEnv.EnvId}],请留意!`
37+
`您的环境中存在不可用的环境:[${unavailableEnv.EnvId}],请留意!`
3838
)
3939
}
4040
})

src/commands/functions/code-update.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@ import path from 'path'
33
import { FunctionContext } from '../../types'
44
import { CloudBaseError } from '../../error'
55
import { updateFunctionCode } from '../../function'
6+
import { getEnvInfo } from '../../env'
67

78
export async function codeUpdate(ctx: FunctionContext, options) {
89
const { name, envId, config, functions } = ctx
910

11+
const envInfo = await getEnvInfo(envId)
12+
13+
if (envInfo.Source === 'miniapp') {
14+
throw new CloudBaseError('无法更新小程序云函数代码!')
15+
}
16+
1017
const { codeSecret } = options
1118

1219
if (!name) {

src/commands/functions/delete.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@ import { FunctionContext } from '../../types'
44
import { CloudBaseError } from '../../error'
55
import { deleteFunction, batchDeleteFunctions } from '../../function'
66
import { successLog } from '../../logger'
7+
import { getEnvInfo } from '../../env'
78

89
export async function deleteFunc(ctx: FunctionContext) {
910
const { name, envId, functions } = ctx
1011

12+
const envInfo = await getEnvInfo(envId)
13+
14+
if (envInfo.Source === 'miniapp') {
15+
throw new CloudBaseError('无法删除小程序云函数!')
16+
}
17+
1118
let isBatchDelete = false
1219

1320
// 不指定云函数名称,默认删除所有函数

src/commands/functions/deploy.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@ import inquirer from 'inquirer'
44
import { CloudBaseError } from '../../error'
55
import { batchCreateFunctions, createFunction } from '../../function'
66
import { FunctionContext } from '../../types'
7+
import { getEnvInfo } from '../../env'
78

89
export async function deploy(ctx: FunctionContext, commandOptions) {
910
const { name, envId, config, functions } = ctx
1011

12+
const envInfo = await getEnvInfo(envId)
13+
14+
if (envInfo.Source === 'miniapp') {
15+
throw new CloudBaseError('无法部署小程序云函数!')
16+
}
17+
1118
const { force, codeSecret } = commandOptions
1219

1320
let isBatchCreating = false

0 commit comments

Comments
 (0)