From a508e83a9e752d54468b1e1156e27dcd80247c69 Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Mon, 25 Mar 2024 13:04:31 -0600 Subject: [PATCH 1/2] feat: bump sf-plugins-core --- README.md | 196 +++++++++++++++++++++++++++++++++++++++++- command-snapshot.json | 32 +++---- package.json | 2 +- yarn.lock | 16 ++-- 4 files changed, 219 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 58a1b5fc..d08ea2d8 100644 --- a/README.md +++ b/README.md @@ -107,8 +107,200 @@ sf plugins -# Command Topics +- [`sf schema generate field`](#sf-schema-generate-field) +- [`sf schema generate platformevent`](#sf-schema-generate-platformevent) +- [`sf schema generate sobject`](#sf-schema-generate-sobject) +- [`sf schema generate tab`](#sf-schema-generate-tab) -- [`sf schema`](docs/schema.md) - Generate metadata files. +## `sf schema generate field` + +Generate metadata source files for a new custom field on a specified object. + +``` +USAGE + $ sf schema generate field -l [--flags-dir ] [-o ] + +FLAGS + -l, --label= (required) The field's label. + -o, --object= The directory that contains the object's source files. + +GLOBAL FLAGS + --flags-dir= Import flag values from a directory. + +DESCRIPTION + Generate metadata source files for a new custom field on a specified object. + + This command is interactive and must be run in a Salesforce DX project directory. You're required to specify the + field's label with the "--label" flag. The command uses this label to provide intelligent suggestions for other field + properties, such as its API name. + + You can generate a custom field on either a standard object, such as Account, or a custom object. In both cases, the + source files for the object must already exist in your local project before you run this command. If you create a + relationship field, the source files for the parent object must also exist in your local directory. Use the command + "sf metadata retrieve -m CustomObject:" to retrieve source files for both standard and custom objects from + your org. To create a custom object, run the "sf generate metadata sobject" command or use the Object Manager UI in + your Salesforce org. + +ALIASES + $ sf generate metadata field + +EXAMPLES + Create a field with the specified label; the command prompts you for the object: + + $ sf schema generate field --label "My Field" + + Specify the local path to the object's folder: + + $ sf schema generate field --label "My Field" --object force-app/main/default/objects/MyObject__c + +FLAG DESCRIPTIONS + -o, --object= The directory that contains the object's source files. + + The object source files in your local project are grouped in a directoy with the same name as the object. Custom + object names always end in "__c". An example of the object directory for the Account standard object is + "force-app/main/default/objects/Account" An example custom object directory is + "force-app/main/default/objects/MyObject__c" + + If you don't specify this flag, the command prompts you to choose from your local objects. +``` + +_See code: [src/commands/schema/generate/field.ts](https://github.com/salesforcecli/plugin-sobject/blob/1.1.21/src/commands/schema/generate/field.ts)_ + +## `sf schema generate platformevent` + +Generate metadata source files for a new platform event. + +``` +USAGE + $ sf schema generate platformevent -l [--flags-dir ] + +FLAGS + -l, --label= (required) The platform event's label. + +GLOBAL FLAGS + --flags-dir= Import flag values from a directory. + +DESCRIPTION + Generate metadata source files for a new platform event. + + This command is interactive and must be run in a Salesforce DX project directory. You're required to specify the + event's label with the "--label" flag. The command uses this label to provide intelligent suggestions for other event + properties, such as its API name. + +ALIASES + $ sf generate metadata platformevent + +EXAMPLES + Create a platform event with the specified label: + + $ sf schema generate platformevent --label "My Platform Event" +``` + +_See code: [src/commands/schema/generate/platformevent.ts](https://github.com/salesforcecli/plugin-sobject/blob/1.1.21/src/commands/schema/generate/platformevent.ts)_ + +## `sf schema generate sobject` + +Generate metadata source files for a new custom object. + +``` +USAGE + $ sf schema generate sobject -l [--flags-dir ] [-f] + +FLAGS + -f, --use-default-features Enable all optional features without prompting. + -l, --label= (required) The custom object's label. + +GLOBAL FLAGS + --flags-dir= Import flag values from a directory. + +DESCRIPTION + Generate metadata source files for a new custom object. + + This command is interactive and must be run in a Salesforce DX project directory. You're required to specify the + object's label with the "--label" flag. The command uses this label to provide intelligent suggestions for other + object properties, such as its API name and plural label. + + All Salesforce objects are required to have a Name field, so this command also prompts you for the label and type of + the Name field. Run the "sf metadata generate field" command to create additional fields for the object. + + To reduce the number of prompts, use the "--use-default-features" flag to automatically enable some features, such as + reporting and search on the object. + +ALIASES + $ sf generate metadata sobject + +EXAMPLES + Create a custom object with the specified label and be prompted for additional information: + + $ sf schema generate sobject --label "My Object" + + Create a custom object and enable optional features without prompting: + + $ sf schema generate sobject --label "My Object" --use-default-features + +FLAG DESCRIPTIONS + -f, --use-default-features Enable all optional features without prompting. + + Enables these features: + + - Search: Allows users to find the custom object's records when they search, including SOSL. + - Feeds: Enables feed tracking. + - Reports: Allows reporting of the data in the custom object records. + - History: Enables object history tracking. + - Activities: Allows users to associate tasks and scheduled calendar events related to the custom object records. + - Bulk API: With Sharing and Streaming API, classifies the custom object as an Enterprise Application object. + - Sharing: With Bulk API and Streaming API, classifies the custom object as an Enterprise Application object. + - Streaming API: With Bulk API and Sharing, classifies the custom object as an Enterprise Application object. +``` + +_See code: [src/commands/schema/generate/sobject.ts](https://github.com/salesforcecli/plugin-sobject/blob/1.1.21/src/commands/schema/generate/sobject.ts)_ + +## `sf schema generate tab` + +Generate the metadata source files for a new custom tab on a custom object. + +``` +USAGE + $ sf schema generate tab -o -d -i [--json] [--flags-dir ] + +FLAGS + -d, --directory= (required) Path to a "tabs" directory that will contain the source files for your new tab. + -i, --icon= (required) [default: 1] Number from 1 to 100 that specifies the color scheme and icon for the + custom tab. + -o, --object= (required) API name of the custom object you're generating a tab for. + +GLOBAL FLAGS + --flags-dir= Import flag values from a directory. + --json Format output as json. + +DESCRIPTION + Generate the metadata source files for a new custom tab on a custom object. + + Custom tabs let you display custom object data or other web content in Salesforce. Custom tabs appear in Salesforce as + an item in the app’s navigation bar and in the App Launcher. + + This command must be run in a Salesforce DX project directory. You must pass all required information to it with the + required flags. The source files for the custom object for which you're generating a tab don't need to exist in your + local project. + +ALIASES + $ sf generate metadata tab + +EXAMPLES + Create a tab on the `MyObject__c` custom object: + + $ sf schema generate tab --object `MyObject__c` --icon 54 --directory force-app/main/default/tabs + +FLAG DESCRIPTIONS + -i, --icon= Number from 1 to 100 that specifies the color scheme and icon for the custom tab. + + See https://lightningdesignsystem.com/icons/#custom for the available icons. + + -o, --object= API name of the custom object you're generating a tab for. + + The API name for a custom object always ends in `__c`, such as `MyObject__c`. +``` + +_See code: [src/commands/schema/generate/tab.ts](https://github.com/salesforcecli/plugin-sobject/blob/1.1.21/src/commands/schema/generate/tab.ts)_ diff --git a/command-snapshot.json b/command-snapshot.json index 58701f2c..2c785a64 100644 --- a/command-snapshot.json +++ b/command-snapshot.json @@ -1,34 +1,34 @@ [ { - "command": "schema:generate:field", - "plugin": "@salesforce/plugin-sobject", - "flags": ["label", "object"], "alias": ["generate:metadata:field"], + "command": "schema:generate:field", + "flagAliases": [], "flagChars": ["l", "o"], - "flagAliases": [] + "flags": ["flags-dir", "label", "object"], + "plugin": "@salesforce/plugin-sobject" }, { - "command": "schema:generate:platformevent", - "plugin": "@salesforce/plugin-sobject", - "flags": ["label"], "alias": ["generate:metadata:platformevent"], + "command": "schema:generate:platformevent", + "flagAliases": [], "flagChars": ["l"], - "flagAliases": [] + "flags": ["flags-dir", "label"], + "plugin": "@salesforce/plugin-sobject" }, { - "command": "schema:generate:sobject", - "plugin": "@salesforce/plugin-sobject", - "flags": ["label", "use-default-features"], "alias": ["generate:metadata:sobject"], + "command": "schema:generate:sobject", + "flagAliases": [], "flagChars": ["f", "l"], - "flagAliases": [] + "flags": ["flags-dir", "label", "use-default-features"], + "plugin": "@salesforce/plugin-sobject" }, { - "command": "schema:generate:tab", - "plugin": "@salesforce/plugin-sobject", - "flags": ["directory", "icon", "json", "object"], "alias": ["generate:metadata:tab"], + "command": "schema:generate:tab", + "flagAliases": [], "flagChars": ["d", "i", "o"], - "flagAliases": [] + "flags": ["directory", "flags-dir", "icon", "json", "object"], + "plugin": "@salesforce/plugin-sobject" } ] diff --git a/package.json b/package.json index 59d14ae7..f4d00e2c 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "@oclif/core": "^3.25.2", "@salesforce/core": "^6.7.3", "@salesforce/kit": "^3.0.15", - "@salesforce/sf-plugins-core": "^7.1.14", + "@salesforce/sf-plugins-core": "^8.0.1", "fast-glob": "^3.3.2", "fast-xml-parser": "^4.3.6", "js2xmlparser": "^4.0.2" diff --git a/yarn.lock b/yarn.lock index 40ee1551..b4f286e4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1293,7 +1293,7 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@oclif/core@3.26.0", "@oclif/core@^3.15.1", "@oclif/core@^3.19.1", "@oclif/core@^3.19.2", "@oclif/core@^3.19.6", "@oclif/core@^3.21.0", "@oclif/core@^3.23.0", "@oclif/core@^3.25.2": +"@oclif/core@3.26.0", "@oclif/core@^3.15.1", "@oclif/core@^3.19.1", "@oclif/core@^3.19.2", "@oclif/core@^3.21.0", "@oclif/core@^3.23.0", "@oclif/core@^3.25.2": version "3.26.0" resolved "https://registry.yarnpkg.com/@oclif/core/-/core-3.26.0.tgz#959d5e9f13f4ad6a4e98235ad125189df9ee4279" integrity sha512-TpMdfD4tfA2tVVbd4l0PrP02o5KoUXYmudBbTC7CeguDo/GLoprw4uL8cMsaVA26+cbcy7WYtOEydQiHVtJixA== @@ -1390,7 +1390,7 @@ strip-ansi "6.0.1" ts-retry-promise "^0.8.0" -"@salesforce/core@^6.4.1", "@salesforce/core@^6.5.3", "@salesforce/core@^6.6.0", "@salesforce/core@^6.7.0", "@salesforce/core@^6.7.3": +"@salesforce/core@^6.4.1", "@salesforce/core@^6.5.3", "@salesforce/core@^6.7.0", "@salesforce/core@^6.7.3": version "6.7.3" resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-6.7.3.tgz#5d8f30c40ac3cebb898c8e845fe9a067bc729268" integrity sha512-uU+PuZZGXxByhvnXLH1V3eY5P1caw401dIZ/QvhzYxoP/alPLk7dpChnZNJYH5Rw3dc/AhSPw+eg0cvUyjhP1Q== @@ -1496,15 +1496,15 @@ chalk "^4" inquirer "^8.2.5" -"@salesforce/sf-plugins-core@^7.1.14": - version "7.1.14" - resolved "https://registry.yarnpkg.com/@salesforce/sf-plugins-core/-/sf-plugins-core-7.1.14.tgz#5f07316a602b4c5d44c09bc74c294d7df9e2e260" - integrity sha512-KDX9vYDeVOkozRrsjVh4Pvzay++7bWWKmaHtGOwkZrBHb3mVEdCp0ryF0WaDTfaEvgNKn7kiZEDSO7oEhJSzug== +"@salesforce/sf-plugins-core@^8.0.1": + version "8.0.1" + resolved "https://registry.yarnpkg.com/@salesforce/sf-plugins-core/-/sf-plugins-core-8.0.1.tgz#f155cddfd7695aab0d8264848b634b2a91cdbf2c" + integrity sha512-R6SqJ1XqSINSWdZruKtC2SKGnLBh7KbFI7+qS0FYlyPU4IlWoa+AZkGwWvlczuSOumqnlhT95rNKwZTS5rJugA== dependencies: "@inquirer/confirm" "^2.0.17" "@inquirer/password" "^1.1.16" - "@oclif/core" "^3.19.6" - "@salesforce/core" "^6.6.0" + "@oclif/core" "^3.23.0" + "@salesforce/core" "^6.7.3" "@salesforce/kit" "^3.0.15" "@salesforce/ts-types" "^2.0.9" chalk "^5.3.0" From a6468e20455a4b91c81847d8a36c249ea73b7dd2 Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Mon, 25 Mar 2024 13:42:15 -0600 Subject: [PATCH 2/2] chore: format --- src/commands/schema/generate/tab.ts | 4 ++-- test/nuts/fs.nut.ts | 4 ++-- test/shared/flags.test.ts | 4 ++-- test/tsconfig.json | 6 ++---- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/commands/schema/generate/tab.ts b/src/commands/schema/generate/tab.ts index eb678508..29bab804 100644 --- a/src/commands/schema/generate/tab.ts +++ b/src/commands/schema/generate/tab.ts @@ -6,7 +6,7 @@ */ import fs from 'node:fs'; -import path from 'node:path' +import path from 'node:path'; import { SfCommand, Flags } from '@salesforce/sf-plugins-core'; import { Messages } from '@salesforce/core'; @@ -14,7 +14,7 @@ import type { CustomTab } from 'jsforce/api/metadata'; import { isTabsFolder } from '../../../shared/flags.js'; import { convertJsonToXml } from '../../../shared/convert.js'; -Messages.importMessagesDirectoryFromMetaUrl(import.meta.url) +Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); const messages = Messages.loadMessages('@salesforce/plugin-sobject', 'generate.tab'); export type GenerateTabResult = { diff --git a/test/nuts/fs.nut.ts b/test/nuts/fs.nut.ts index cfc79e46..dc63c829 100644 --- a/test/nuts/fs.nut.ts +++ b/test/nuts/fs.nut.ts @@ -5,8 +5,8 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ -import path from 'node:path'; -import fs from 'node:fs'; +import path from 'node:path'; +import fs from 'node:fs'; import { TestSession } from '@salesforce/cli-plugins-testkit'; import { expect } from 'chai'; import { diff --git a/test/shared/flags.test.ts b/test/shared/flags.test.ts index 899e5c2e..79263644 100644 --- a/test/shared/flags.test.ts +++ b/test/shared/flags.test.ts @@ -4,13 +4,13 @@ * 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 {join, sep, resolve} from 'node:path'; +import { join, sep, resolve } from 'node:path'; import { expect } from 'chai'; import { Messages, SfError } from '@salesforce/core'; import { labelValidation, isObjectsFolder, isTabsFolder } from '../../src/shared/flags.js'; -Messages.importMessagesDirectoryFromMetaUrl(import.meta.url) +Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); const messages = Messages.loadMessages('@salesforce/plugin-sobject', 'flags'); describe('flag tests', () => { diff --git a/test/tsconfig.json b/test/tsconfig.json index fde34705..a5f451cf 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -1,9 +1,7 @@ { "extends": "@salesforce/dev-config/tsconfig-test-strict-esm", - "include": [ - "./**/*.ts" - ], + "include": ["./**/*.ts"], "compilerOptions": { "skipLibCheck": true } -} \ No newline at end of file +}