diff --git a/README.md b/README.md index 68396f0b..1d256e24 100644 --- a/README.md +++ b/README.md @@ -93,11 +93,11 @@ git clone git@github.com:salesforcecli/plugin-template-sf yarn && yarn build ``` -To use your plugin, run using the local `./bin/dev` or `./bin/dev.cmd` file. +To use your plugin, run using the local `./bin/dev.js` or `./bin/dev.cmd` file. ```bash # Run using local run file. -./bin/dev hello world +./bin/dev.js hello world ``` There should be no differences when running via the Salesforce CLI or using the local run file. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine. diff --git a/src/commands/schema/generate/field.ts b/src/commands/schema/generate/field.ts index e2ef4f0d..7471a948 100644 --- a/src/commands/schema/generate/field.ts +++ b/src/commands/schema/generate/field.ts @@ -4,8 +4,8 @@ * 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 fs from 'node:fs'; -import path, {dirname} from 'node:path'; +import fs from 'node:fs'; +import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { SfCommand, Flags } from '@salesforce/sf-plugins-core'; import { Messages } from '@salesforce/core'; @@ -22,7 +22,7 @@ import { import { relationshipFieldPrompts } from '../../../shared/prompts/relationshipField.js'; import { isObjectsFolder, labelValidation } from '../../../shared/flags.js'; -Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url))); +Messages.importMessagesDirectory(path.dirname(fileURLToPath(import.meta.url))); const messages = Messages.loadMessages('@salesforce/plugin-sobject', 'generate.field'); const MAX_LONG_TEXT_LENGTH = 131072; diff --git a/src/shared/prompts/prompts.ts b/src/shared/prompts/prompts.ts index a2f92ee6..18b8f85c 100644 --- a/src/shared/prompts/prompts.ts +++ b/src/shared/prompts/prompts.ts @@ -4,12 +4,12 @@ * 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 {dirname} from 'node:path'; -import {fileURLToPath} from 'node:url'; +import { dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; import { NamedPackageDir } from '@salesforce/core'; import { ValueSet, CustomValue } from 'jsforce/api/metadata'; import { Messages } from '@salesforce/core'; -import {ListQuestion, prompt, Question} from 'inquirer'; +import inquirer from 'inquirer'; import { getDirectoriesThatContainObjects, getObjectDirectories } from '../fs.js'; Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url))); @@ -28,21 +28,21 @@ const getSuffix = (objectType: ObjectType): string => { return '__e'; } }; -export const directoryPrompt = async (packageDirs: NamedPackageDir[]): Promise => ({ +export const directoryPrompt = async (packageDirs: NamedPackageDir[]): Promise => ({ type: 'list', message: messages.getMessage('directory'), name: 'directory', choices: await getDirectoriesThatContainObjects(packageDirs.map((pd) => pd.path)), }); -export const pluralPrompt = (label: string): Question => ({ +export const pluralPrompt = (label: string): inquirer.Question => ({ type: 'input', message: messages.getMessage('pluralLabel'), name: 'pluralLabel', default: `${label}s`, }); -export const apiNamePrompt = (label: string, objectType: ObjectType): Question => ({ +export const apiNamePrompt = (label: string, objectType: ObjectType): inquirer.Question => ({ type: 'input', message: messages.getMessage('apiName'), name: 'fullName', @@ -57,7 +57,7 @@ export const descriptionPrompt = { }; /** Ask about the name/type for the Name field, with a followup for AutoNumber format if AutoNumber is chosen */ -export const namePrompts = (label: string): Array => [ +export const namePrompts = (label: string): Array => [ { type: 'input', message: messages.getMessage('nameFieldPrompts.label'), @@ -83,12 +83,13 @@ export const namePrompts = (label: string): Array => [ * * @param packageDirs * @param name The "name" property of the Inquirer answer object. Supports use of the question for multiple scenarios + * @param message */ export const objectPrompt = async ( packageDirs: NamedPackageDir[], name: 'object' | 'referenceTo' = 'object', message = messages.getMessage('object') -): Promise => ({ +): Promise => ({ type: 'list', message, name, @@ -114,7 +115,7 @@ export const picklistPrompts = async (): Promise while (keepAsking) { // the very definition of needing a loop for an await // eslint-disable-next-line no-await-in-loop - const response = await prompt<{ picklistValue: string }>({ + const response = await inquirer.prompt<{ picklistValue: string }>({ type: 'input', name: 'picklistValue', validate: (input: string) => (output.find((v) => v.fullName === input) ? `${input} already exists` : true), diff --git a/src/shared/prompts/relationshipField.ts b/src/shared/prompts/relationshipField.ts index 97688aab..80d8265f 100644 --- a/src/shared/prompts/relationshipField.ts +++ b/src/shared/prompts/relationshipField.ts @@ -4,12 +4,12 @@ * 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 path, {dirname} from 'node:path'; -import {fileURLToPath} from 'node:url'; +import path, { dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; import { NamedPackageDir } from '@salesforce/core'; -import { prompt } from 'inquirer'; import { CustomField } from 'jsforce/api/metadata'; import { Messages } from '@salesforce/core'; +import inquirer from 'inquirer'; import { getObjectXmlByFolderAsJson } from '../fs.js'; import { objectPrompt, makeNameApiCompatible } from './prompts.js'; @@ -37,7 +37,7 @@ export const relationshipFieldPrompts = async ({ childObjectFolderPath: string; }): Promise => { const childObjectXml = await getObjectXmlByFolderAsJson(childObjectFolderPath); - const response = await prompt([ + const response = await inquirer.prompt([ // prompt the user to select from objects in local source await objectPrompt(packageDirs, 'referenceTo', messages.getMessage('objectPrompt')), {