Skip to content

Commit f5fe096

Browse files
committed
feat(load-application): add support for number type prompts
- Add getNumberDefaultValue function to handle number type defaults - Update prompt generation to use getNumberDefaultValue for number type items - Bump version to 0.0.16-beta.3 Signed-off-by: zxypro1 <[email protected]>
1 parent 41a1157 commit f5fe096

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

packages/load-application/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@serverless-devs/load-application",
3-
"version": "0.0.16-beta.2",
3+
"version": "0.0.16-beta.3",
44
"description": "load application for serverless-devs",
55
"main": "lib/index.js",
66
"scripts": {

packages/load-application/src/utils/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ export const getDefaultValue = (value: any) => {
3434
return replace(value, RANDOM_PATTERN, randomId());
3535
};
3636

37+
export const getNumberDefaultValue = (value: any) => {
38+
if (typeof value !== 'number') return;
39+
return value;
40+
};
41+
3742
export const getSecretManager = () => {
3843
const secretManager = SecretManager.getInstance();
3944
return secretManager;

packages/load-application/src/v3.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { isEmpty, includes, split, get, has, set, sortBy, map, concat, keys, sta
88
import axios from 'axios';
99
import parse from './parse';
1010
import { IOptions } from './types';
11-
import { getInputs, getUrlWithLatest, getUrlWithVersion, getAllCredential, getDefaultValue, getSecretManager } from './utils';
11+
import { getInputs, getUrlWithLatest, getUrlWithVersion, getAllCredential, getDefaultValue, getSecretManager, getNumberDefaultValue } from './utils';
1212
import YAML from 'yaml';
1313
import inquirer from 'inquirer';
1414
import chalk from 'chalk';
@@ -338,6 +338,16 @@ class LoadApplication {
338338
default: getDefaultValue(item.default),
339339
validate,
340340
});
341+
} else if (item.type === 'number') {
342+
// number类型
343+
promptList.push({
344+
type: 'input',
345+
message: item.title,
346+
name,
347+
prefix,
348+
default: getNumberDefaultValue(item.default),
349+
validate,
350+
});
341351
}
342352
}
343353
return { promptList, tmpResult };

0 commit comments

Comments
 (0)