generated from salesforcecli/plugin-template-sf
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move some field command fn into their own files
- Loading branch information
Showing
6 changed files
with
97 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2023, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
import input from '@inquirer/input'; | ||
import { Messages } from '@salesforce/core'; | ||
import { integerValidation } from '../functions.js'; | ||
|
||
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); | ||
export const messages = Messages.loadMessages('@salesforce/plugin-sobject', 'generate.field'); | ||
|
||
export const precisionPrompt = async (type: string, scale: number | undefined): Promise<number | undefined> => | ||
type === 'Number' || type === 'Currency' | ||
? Number( | ||
await input({ | ||
message: messages.getMessage('prompts.precision'), | ||
validate: integerValidation({ min: 1, max: 18 - (scale ?? 0) }), | ||
default: (18 - (scale ?? 0)).toString(), | ||
}) | ||
) | ||
: undefined; | ||
export const scalePrompt = async (type: string): Promise<number | undefined> => | ||
type === 'Number' || type === 'Currency' || type === 'Location' | ||
? Number( | ||
await input({ | ||
message: messages.getMessage('prompts.scale'), | ||
validate: integerValidation({ min: 0, max: 18 }), | ||
default: '0', | ||
}) | ||
) | ||
: undefined; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (c) 2023, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
import input from '@inquirer/input'; | ||
import { integerValidation } from '../functions.js'; | ||
|
||
const MAX_LONG_TEXT_LENGTH = 131072; | ||
const MAX_TEXT_LENGTH = 255; | ||
|
||
export const lengthPrompt = async (type: string): Promise<number | undefined> => | ||
type === 'Text' | ||
? Number( | ||
await input({ | ||
message: `Length (max ${MAX_TEXT_LENGTH})`, | ||
default: MAX_TEXT_LENGTH.toString(), | ||
validate: integerValidation({ min: 1, max: MAX_TEXT_LENGTH }), | ||
}) | ||
) | ||
: type === 'Html' || type === 'LongTextArea' | ||
? Number( | ||
await input({ | ||
message: `Length (max ${MAX_LONG_TEXT_LENGTH})`, | ||
default: MAX_LONG_TEXT_LENGTH.toString(), | ||
validate: integerValidation({ min: 1, max: MAX_LONG_TEXT_LENGTH }), | ||
}) | ||
) | ||
: undefined; | ||
|
||
export const visibleLinePrompt = async (type: string): Promise<number | undefined> => | ||
type === 'Html' || type === 'LongTextArea' | ||
? Number( | ||
await input({ | ||
message: 'Visible Lines', | ||
validate: integerValidation({ min: 1, max: 1000 }), | ||
default: '5', | ||
}) | ||
) | ||
: undefined; |