Skip to content
Merged
92 changes: 46 additions & 46 deletions command-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,55 +1,79 @@
[
{
"alias": ["force:analytics:template:create"],
"command": "analytics:generate:template",
"alias": ["force:analytics:template:create", "analytics:generate:template"],
"command": "template:generate:analytics:template",
"flagAliases": ["apiversion", "outputdir", "templatename"],
"flagChars": ["d", "n"],
"flags": ["api-version", "flags-dir", "json", "loglevel", "name", "output-dir"],
"plugin": "@salesforce/plugin-templates"
},
{
"alias": ["force:lightning:app:create"],
"command": "lightning:generate:app",
"alias": ["force:apex:class:create", "apex:generate:class"],
"command": "template:generate:apex:class",
"flagAliases": ["apiversion", "classname", "outputdir"],
"flagChars": ["d", "n", "t"],
"flags": ["api-version", "flags-dir", "json", "loglevel", "name", "output-dir", "template"],
"plugin": "@salesforce/plugin-templates"
},
{
"alias": ["force:apex:trigger:create", "apex:generate:trigger"],
"command": "template:generate:apex:trigger",
"flagAliases": ["apiversion", "outputdir", "triggerevents", "triggername"],
"flagChars": ["d", "e", "n", "s", "t"],
"flags": ["api-version", "event", "flags-dir", "json", "loglevel", "name", "output-dir", "sobject", "template"],
"plugin": "@salesforce/plugin-templates"
},
{
"alias": [],
"command": "template:generate:digital-experience:site",
"flagAliases": [],
"flagChars": ["d", "e", "n", "o", "p", "t"],
"flags": ["admin-email", "flags-dir", "json", "name", "output-dir", "target-org", "template", "url-path-prefix"],
"plugin": "@salesforce/plugin-templates"
},
{
"alias": ["force:lightning:app:create", "lightning:generate:app"],
"command": "template:generate:lightning:app",
"flagAliases": ["apiversion", "appname", "outputdir"],
"flagChars": ["d", "i", "n", "t"],
"flags": ["api-version", "flags-dir", "internal", "json", "loglevel", "name", "output-dir", "template"],
"plugin": "@salesforce/plugin-templates"
},
{
"alias": ["force:lightning:component:create"],
"command": "lightning:generate:component",
"alias": ["force:lightning:component:create", "lightning:generate:component"],
"command": "template:generate:lightning:component",
"flagAliases": ["apiversion", "componentname", "outputdir"],
"flagChars": ["d", "i", "n", "t"],
"flags": ["api-version", "flags-dir", "internal", "json", "loglevel", "name", "output-dir", "template", "type"],
"plugin": "@salesforce/plugin-templates"
},
{
"alias": ["force:lightning:event:create"],
"command": "lightning:generate:event",
"alias": ["force:lightning:event:create", "lightning:generate:event"],
"command": "template:generate:lightning:event",
"flagAliases": ["apiversion", "eventname", "outputdir"],
"flagChars": ["d", "i", "n", "t"],
"flags": ["api-version", "flags-dir", "internal", "json", "loglevel", "name", "output-dir", "template"],
"plugin": "@salesforce/plugin-templates"
},
{
"alias": ["force:lightning:interface:create"],
"command": "lightning:generate:interface",
"alias": ["force:lightning:interface:create", "lightning:generate:interface"],
"command": "template:generate:lightning:interface",
"flagAliases": ["apiversion", "interfacename", "outputdir"],
"flagChars": ["d", "i", "n", "t"],
"flags": ["api-version", "flags-dir", "internal", "json", "loglevel", "name", "output-dir", "template"],
"plugin": "@salesforce/plugin-templates"
},
{
"alias": ["force:lightning:test:create"],
"command": "lightning:generate:test",
"alias": ["force:lightning:test:create", "lightning:generate:test"],
"command": "template:generate:lightning:test",
"flagAliases": ["apiversion", "outputdir", "testname"],
"flagChars": ["d", "i", "n", "t"],
"flags": ["api-version", "flags-dir", "internal", "json", "loglevel", "name", "output-dir", "template"],
"plugin": "@salesforce/plugin-templates"
},
{
"alias": ["force:project:create"],
"command": "project:generate",
"alias": ["force:project:create", "project:generate"],
"command": "template:generate:project",
"flagAliases": ["defaultpackagedir", "loginurl", "outputdir", "projectname"],
"flagChars": ["d", "l", "n", "p", "s", "t", "x"],
"flags": [
Expand All @@ -68,56 +92,32 @@
"plugin": "@salesforce/plugin-templates"
},
{
"alias": ["force:staticresource:create"],
"command": "static-resource:generate",
"alias": ["force:staticresource:create", "static-resource:generate"],
"command": "template:generate:static-resource",
"flagAliases": ["apiversion", "contenttype", "outputdir", "resourcename"],
"flagChars": ["d", "n"],
"flags": ["api-version", "flags-dir", "json", "loglevel", "name", "output-dir", "type"],
"plugin": "@salesforce/plugin-templates"
},
{
"alias": ["force:apex:class:create", "apex:generate:class"],
"command": "template:generate:apex:class",
"flagAliases": ["apiversion", "classname", "outputdir"],
"flagChars": ["d", "n", "t"],
"flags": ["api-version", "flags-dir", "json", "loglevel", "name", "output-dir", "template"],
"plugin": "@salesforce/plugin-templates"
},
{
"alias": ["force:apex:trigger:create", "apex:generate:trigger"],
"command": "template:generate:apex:trigger",
"flagAliases": ["apiversion", "outputdir", "triggerevents", "triggername"],
"flagChars": ["d", "e", "n", "s", "t"],
"flags": ["api-version", "event", "flags-dir", "json", "loglevel", "name", "output-dir", "sobject", "template"],
"plugin": "@salesforce/plugin-templates"
},
{
"alias": [],
"command": "template:generate:digital-experience:site",
"flagAliases": [],
"flagChars": ["d", "n", "p", "e", "o", "t"],
"flags": ["flags-dir", "json", "name", "output-dir", "url-path-prefix", "admin-email", "target-org", "template"],
"plugin": "@salesforce/plugin-templates"
},
{
"alias": ["force:visualforce:component:create"],
"command": "visualforce:generate:component",
"alias": ["force:visualforce:component:create", "visualforce:generate:component"],
"command": "template:generate:visualforce:component",
"flagAliases": ["apiversion", "componentname", "outputdir"],
"flagChars": ["d", "l", "n", "t"],
"flags": ["api-version", "flags-dir", "json", "label", "loglevel", "name", "output-dir", "template"],
"plugin": "@salesforce/plugin-templates"
},
{
"alias": ["force:visualforce:page:create"],
"command": "visualforce:generate:page",
"alias": ["force:visualforce:page:create", "visualforce:generate:page"],
"command": "template:generate:visualforce:page",
"flagAliases": ["apiversion", "outputdir", "pagename"],
"flagChars": ["d", "l", "n", "t"],
"flags": ["api-version", "flags-dir", "json", "label", "loglevel", "name", "output-dir", "template"],
"plugin": "@salesforce/plugin-templates"
},
{
"alias": [],
"command": "webapp:generate",
"alias": ["webapp:generate"],
"command": "template:generate:webapp",
"flagAliases": [],
"flagChars": ["d", "l", "n", "t"],
"flags": ["api-version", "flags-dir", "json", "label", "name", "output-dir", "template"],
Expand Down
50 changes: 18 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,49 +52,35 @@
"@salesforce/plugin-settings"
],
"topics": {
"analytics": {
"external": true,
"description": "Work with analytics assets.",
"subtopics": {
"generate": {
"description": "Create analytics templates."
}
}
},
"lightning": {
"description": "Work with Lightning Web and Aura components.",
"external": true,
"subtopics": {
"generate": {
"description": "Create LWC and Aura components and associated metadata."
}
}
},
"project": {
"description": "Work with projects, such as deploy and retrieve metadata."
},
"visualforce": {
"description": "Work with Visualforce components.",
"subtopics": {
"generate": {
"description": "Create a Visualforce page or component."
}
}
},
"static-resource": {
"description": "Work with static resources."
},
"template": {
"description": "Collection of Salesforce templates.",
"subtopics": {
"generate": {
"description": "Use a Salesforce template to generate local files.",
"subtopics": {
"analytics": {
"description": "Create analytics templates."
},
"apex": {
"description": "Create an apex class or trigger."
},
"digital-experience": {
"description": "Create a Digital Experience site."
},
"lightning": {
"description": "Create LWC and Aura components and associated metadata."
},
"project": {
"description": "Work with projects, such as deploy and retrieve metadata."
},
"static-resource": {
"description": "Work with static resources."
},
"visualforce": {
"description": "Create a visualforce page or component."
},
"webapp": {
"description": "Create a web application."
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand, Ux } from '@salesforce/sf-plugins-core';
import { Messages } from '@salesforce/core';
import { AnalyticsTemplateOptions, CreateOutput, TemplateType } from '@salesforce/templates';
import { getCustomTemplates, runGenerator } from '../../../utils/templateCommand.js';
import { outputDirFlag } from '../../../utils/flags.js';
import { getCustomTemplates, runGenerator } from '../../../../utils/templateCommand.js';
import { outputDirFlag } from '../../../../utils/flags.js';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-templates', 'analyticsTemplate');
export default class AnalyticsTemplate extends SfCommand<CreateOutput> {
public static readonly examples = messages.getMessages('examples');
public static readonly summary = messages.getMessage('summary');
public static readonly description = messages.getMessage('description');
public static readonly aliases = ['force:analytics:template:create'];
public static readonly aliases = ['force:analytics:template:create', 'analytics generate template'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, lets use : in all the aliases. Note that you can still call analytics generate template and this alias will work.

Suggested change
public static readonly aliases = ['force:analytics:template:create', 'analytics generate template'];
public static readonly aliases = ['force:analytics:template:create', 'analytics:generate:template'];

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the other aliases that were added

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it throw an error: the Salesforce CLI will match the command words in any order, so this alias is unnecessary. when I tried to do analytics:gnerate:template ,unless I add eslint-disable-next-line. :(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh funny. I think you just found an far edge case. Here is the linting rule: https://github.com/salesforcecli/eslint-plugin-sf-plugin/blob/19bb3dcbeab9d0427a64030e3fae4cc135810d96/src/rules/no-unnecessary-aliases.ts#L43-L44

I think this is complaining because of the every checks. The new command is:
template generate analytics template
and the alias (after splitting on a :) would be
analytics generate template
The linting rule doesn't noticed that the word template is in there twice, only that is matches

I confirmed that the alias does work locally so it's not an issue 🤷

public static readonly deprecateAliases = true;
public static readonly flags = {
'output-dir': outputDirFlag,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand, Ux } fro
import { CreateOutput, LightningAppOptions, TemplateType } from '@salesforce/templates';
import { CreateUtil } from '@salesforce/templates/lib/utils/index.js';
import { Messages } from '@salesforce/core';
import { getCustomTemplates, runGenerator } from '../../../utils/templateCommand.js';
import { internalFlag, outputDirFlagLightning } from '../../../utils/flags.js';
import { getCustomTemplates, runGenerator } from '../../../../utils/templateCommand.js';
import { internalFlag, outputDirFlagLightning } from '../../../../utils/flags.js';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const lightningCommonMessages = Messages.loadMessages('@salesforce/plugin-templates', 'lightning');
Expand All @@ -22,7 +22,7 @@ export default class LightningApp extends SfCommand<CreateOutput> {
public static readonly summary = lightningCommonMessages.getMessage('summary', [BUNDLE_TYPE]);
public static readonly description = lightningCommonMessages.getMessage('description', [BUNDLE_TYPE]);
public static readonly examples = lightningAppMessages.getMessages('examples');
public static readonly aliases = ['force:lightning:app:create'];
public static readonly aliases = ['force:lightning:app:create', 'lightning:generate:app'];
public static readonly deprecateAliases = true;
public static readonly flags = {
name: Flags.string({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand, Ux } from '@salesforce/sf-plugins-core';
import { CreateOutput, LightningComponentOptions, TemplateType } from '@salesforce/templates';
import { Messages } from '@salesforce/core';
import { getCustomTemplates, runGenerator } from '../../../utils/templateCommand.js';
import { internalFlag, outputDirFlagLightning } from '../../../utils/flags.js';
import { getCustomTemplates, runGenerator } from '../../../../utils/templateCommand.js';
import { internalFlag, outputDirFlagLightning } from '../../../../utils/flags.js';
const BUNDLE_TYPE = 'Component';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
Expand All @@ -21,7 +21,7 @@ export default class LightningComponent extends SfCommand<CreateOutput> {
public static readonly summary = messages.getMessage('summary');
public static readonly description = messages.getMessage('description');
public static readonly examples = messages.getMessages('examples');
public static readonly aliases = ['force:lightning:component:create'];
public static readonly aliases = ['force:lightning:component:create', 'lightning:generate:component'];
public static readonly deprecateAliases = true;
public static readonly flags = {
name: Flags.string({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand, Ux } fro
import { CreateOutput, LightningEventOptions, TemplateType } from '@salesforce/templates';
import { CreateUtil } from '@salesforce/templates/lib/utils/index.js';
import { Messages } from '@salesforce/core';
import { getCustomTemplates, runGenerator } from '../../../utils/templateCommand.js';
import { internalFlag, outputDirFlagLightning } from '../../../utils/flags.js';
import { getCustomTemplates, runGenerator } from '../../../../utils/templateCommand.js';
import { internalFlag, outputDirFlagLightning } from '../../../../utils/flags.js';
const lightningEventFileSuffix = /.evt$/;
const BUNDLE_TYPE = 'Event';

Expand All @@ -23,7 +23,7 @@ export default class LightningEvent extends SfCommand<CreateOutput> {
public static readonly summary = lightningCommon.getMessage('summary', [BUNDLE_TYPE]);
public static readonly description = lightningCommon.getMessage('description', [BUNDLE_TYPE]);
public static readonly examples = messages.getMessages('examples');
public static readonly aliases = ['force:lightning:event:create'];
public static readonly aliases = ['force:lightning:event:create', 'lightning:generate:event'];
public static readonly deprecateAliases = true;
public static readonly flags = {
name: Flags.string({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand, Ux } fro
import { CreateOutput, LightningInterfaceOptions, TemplateType } from '@salesforce/templates';
import { CreateUtil } from '@salesforce/templates/lib/utils/index.js';
import { Messages } from '@salesforce/core';
import { getCustomTemplates, runGenerator } from '../../../utils/templateCommand.js';
import { internalFlag, outputDirFlagLightning } from '../../../utils/flags.js';
import { getCustomTemplates, runGenerator } from '../../../../utils/templateCommand.js';
import { internalFlag, outputDirFlagLightning } from '../../../../utils/flags.js';
const lightningInterfaceFileSuffix = /.intf$/;
const BUNDLE_TYPE = 'Interface';

Expand All @@ -22,7 +22,7 @@ export default class LightningInterface extends SfCommand<CreateOutput> {
public static readonly summary = lightningCommon.getMessage('summary', [BUNDLE_TYPE]);
public static readonly description = lightningCommon.getMessage('description', [BUNDLE_TYPE]);
public static readonly examples = messages.getMessages('examples');
public static readonly aliases = ['force:lightning:interface:create'];
public static readonly aliases = ['force:lightning:interface:create', 'lightning:generate:interface'];
public static readonly deprecateAliases = true;
public static readonly flags = {
name: Flags.string({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { Flags, loglevel, SfCommand, orgApiVersionFlagWithDeprecations, Ux } fro
import { CreateOutput, LightningTestOptions, TemplateType } from '@salesforce/templates';
import { CreateUtil } from '@salesforce/templates/lib/utils/index.js';
import { Messages } from '@salesforce/core';
import { getCustomTemplates, runGenerator } from '../../../utils/templateCommand.js';
import { internalFlag, outputDirFlagLightning } from '../../../utils/flags.js';
import { getCustomTemplates, runGenerator } from '../../../../utils/templateCommand.js';
import { internalFlag, outputDirFlagLightning } from '../../../../utils/flags.js';
const lightningTestFileSuffix = /.resource$/;

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
Expand All @@ -20,7 +20,7 @@ export default class LightningTest extends SfCommand<CreateOutput> {
public static readonly summary = messages.getMessage('summary');
public static readonly description = messages.getMessage('description');
public static readonly examples = messages.getMessages('examples');
public static readonly aliases = ['force:lightning:test:create'];
public static readonly aliases = ['force:lightning:test:create', 'lightning:generate:test'];
public static readonly deprecateAliases = true;
public static readonly flags = {
name: Flags.string({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
import { Flags, loglevel, SfCommand, Ux } from '@salesforce/sf-plugins-core';
import { CreateOutput, ProjectOptions, TemplateType } from '@salesforce/templates';
import { Messages } from '@salesforce/core';
import { getCustomTemplates, runGenerator } from '../../utils/templateCommand.js';
import { outputDirFlag } from '../../utils/flags.js';
import { getCustomTemplates, runGenerator } from '../../../../utils/templateCommand.js';
import { outputDirFlag } from '../../../../utils/flags.js';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-templates', 'project');
export default class Project extends SfCommand<CreateOutput> {
public static readonly summary = messages.getMessage('summary');
public static readonly description = messages.getMessage('description');
public static readonly examples = messages.getMessages('examples');
public static readonly aliases = ['force:project:create'];
public static readonly aliases = ['force:project:create', 'project:generate'];
public static readonly deprecateAliases = true;
public static readonly flags = {
name: Flags.string({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand, Ux } from '@salesforce/sf-plugins-core';
import { CreateOutput, StaticResourceOptions, TemplateType } from '@salesforce/templates';
import { Messages } from '@salesforce/core';
import { outputDirFlag } from '../../utils/flags.js';
import { getCustomTemplates, runGenerator } from '../../utils/templateCommand.js';
import { outputDirFlag } from '../../../../utils/flags.js';
import { getCustomTemplates, runGenerator } from '../../../../utils/templateCommand.js';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-templates', 'staticResource');
export default class StaticResource extends SfCommand<CreateOutput> {
public static readonly summary = messages.getMessage('summary');
public static readonly description = messages.getMessage('description');
public static readonly examples = messages.getMessages('examples');
public static readonly aliases = ['force:staticresource:create'];
public static readonly aliases = ['force:staticresource:create', 'static-resource:generate'];
public static readonly deprecateAliases = true;
public static readonly flags = {
name: Flags.string({
Expand Down
Loading