Skip to content

Commit

Permalink
Merge pull request #281 from salesforcecli/wr/esm
Browse files Browse the repository at this point in the history
ESM plugin-templates
  • Loading branch information
mshanemc authored Nov 14, 2023
2 parents 3f713b6 + 43224a5 commit 9ec90fb
Show file tree
Hide file tree
Showing 41 changed files with 1,485 additions and 1,640 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.cjs/
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ node_modules

oclif.manifest.json
.sfdx
.sf
.sf
oclif.lock
File renamed without changes.
11 changes: 8 additions & 3 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"require": "ts-node/register,source-map-support/register",
"require": [
"ts-node/register"
],
"watch-extensions": "ts",
"recursive": true,
"reporter": "spec",
"timeout": 5000
}
"timeout": 5000,
"node-option": [
"loader=ts-node/esm"
]
}
21 changes: 0 additions & 21 deletions bin/dev

This file was deleted.

2 changes: 1 addition & 1 deletion bin/dev.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@echo off

node "%~dp0\dev" %*
node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*
8 changes: 8 additions & 0 deletions bin/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning
// eslint-disable-next-line node/shebang
async function main() {
const {execute} = await import('@oclif/core')
await execute({development: true, dir: import.meta.url})
}

await main()
5 changes: 0 additions & 5 deletions bin/run

This file was deleted.

9 changes: 9 additions & 0 deletions bin/run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env node

// eslint-disable-next-line node/shebang
async function main() {
const {execute} = await import('@oclif/core')
await execute({dir: import.meta.url})
}

await main()
File renamed without changes.
58 changes: 29 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
{
"name": "@salesforce/plugin-templates",
"description": "Commands to create metadata from a default or custom template",
"version": "55.5.19",
"main": "lib/index.js",
"version": "56.0.0",
"author": "Salesforce",
"bugs": "https://github.com/salesforcecli/plugin-templates/issues",
"dependencies": {
"@oclif/core": "^2.15.0",
"@oclif/core": "^3.11.0",
"@salesforce/core": "^5.3.20",
"@salesforce/sf-plugins-core": "^3.1.23",
"@salesforce/sf-plugins-core": "^4.1.2",
"@salesforce/templates": "^59.0.1",
"tslib": "^2",
"yeoman-environment": "^3.19.3",
"yeoman-generator": "^5.10.0"
"yeoman-environment": "^3",
"yeoman-generator": "^5"
},
"devDependencies": {
"@oclif/plugin-command-snapshot": "^4.0.16",
"@salesforce/cli-plugins-testkit": "^4.4.12",
"@salesforce/dev-scripts": "^6.0.3",
"@oclif/plugin-command-snapshot": "^5.0.2",
"@salesforce/cli-plugins-testkit": "^5.0.4",
"@salesforce/dev-scripts": "^6.0.4",
"@salesforce/plugin-command-reference": "^3.0.46",
"@salesforce/plugin-settings": "^1.4.37",
"@salesforce/ts-sinon": "^1.4.19",
"@swc/core": "^1.3.96",
"@types/yeoman-assert": "^3.1.4",
"@types/yeoman-environment": "^2.10.9",
"@types/yeoman-generator": "^5.2.13",
"eslint-plugin-sf-plugin": "^1.16.14",
"oclif": "^3.17.2",
"eslint-plugin-sf-plugin": "^1.16.15",
"oclif": "^4.0.3",
"shx": "^0.3.4",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
Expand All @@ -37,12 +32,12 @@
"keywords": [
"force",
"salesforce",
"sfdx",
"salesforcecli",
"sfdx-plugin",
"sf",
"sf-plugin",
"templates",
"sf"
"sfdx",
"sfdx-plugin",
"templates"
],
"license": "BSD-3-Clause",
"files": [
Expand All @@ -51,14 +46,15 @@
"/lib",
"/messages",
"/npm-shrinkwrap.json",
"/oclif.manifest.json"
"/oclif.manifest.json",
"/oclif.lock"
],
"oclif": {
"commands": "./lib/commands",
"additionalHelpFlags": [
"-h"
],
"bin": "sfdx",
"bin": "sf",
"devPlugins": [
"@oclif/plugin-command-snapshot",
"@salesforce/plugin-command-reference",
Expand Down Expand Up @@ -105,25 +101,27 @@
"static-resource": {
"description": "Work with static resources."
}
}
},
"flexibleTaxonomy": true,
"topicSeparator": " "
},
"engines": {
"node": ">=16.0.0"
"node": ">=18.0.0"
},
"repository": "salesforcecli/plugin-templates",
"scripts": {
"build": "wireit",
"clean": "sf-clean",
"clean-all": "sf-clean all",
"clean:lib": "shx rm -rf lib && shx rm -rf coverage && shx rm -rf .nyc_output && shx rm -f oclif.manifest.json",
"clean:lib": "shx rm -rf lib && shx rm -rf coverage && shx rm -rf .nyc_output && shx rm -f oclif.manifest.json oclif.lock",
"compile": "wireit",
"docs": "sf-docs",
"format": "wireit",
"lint": "wireit",
"lint:fix": "eslint 'src/**/*.ts' 'test/**/*.ts' --fix",
"manifest:generate": "oclif manifest",
"manifest:remove": "shx rm -f oclif.manifest.json",
"postpack": "shx rm -f oclif.manifest.json",
"postpack": "shx rm -f oclif.manifest.json oclif.lock",
"prepack": "sf-prepack",
"prepare": "sf-install",
"test": "wireit",
Expand Down Expand Up @@ -218,7 +216,7 @@
"output": []
},
"test:command-reference": {
"command": "\"./bin/dev\" commandreference:generate --erroronwarnings",
"command": "ts-node \"./bin/dev.js\" commandreference:generate --erroronwarnings",
"files": [
"src/**/*.ts",
"messages/**",
Expand All @@ -229,7 +227,7 @@
]
},
"test:deprecation-policy": {
"command": "\"./bin/dev\" snapshot:compare",
"command": "ts-node \"./bin/dev.js\" snapshot:compare",
"files": [
"src/**/*.ts"
],
Expand All @@ -239,12 +237,14 @@
]
},
"test:json-schema": {
"command": "\"./bin/dev\" schema:compare",
"command": "ts-node \"./bin/dev.js\" schema:compare",
"files": [
"src/**/*.ts",
"schemas"
],
"output": []
}
}
},
"exports": "./lib/index.js",
"type": "module"
}
10 changes: 6 additions & 4 deletions src/commands/analytics/generate/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
* 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 { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand, Ux } from '@salesforce/sf-plugins-core';
import { Messages } from '@salesforce/core';
import AnalyticsTemplateGenerator from '@salesforce/templates/lib/generators/analyticsTemplateGenerator';
import AnalyticsTemplateGenerator from '@salesforce/templates/lib/generators/analyticsTemplateGenerator.js';
import { AnalyticsTemplateOptions, CreateOutput } from '@salesforce/templates';
import { getCustomTemplates, runGenerator } from '../../../utils/templateCommand';
import { outputDirFlag } from '../../../utils/flags';
import { getCustomTemplates, runGenerator } from '../../../utils/templateCommand.js';
import { outputDirFlag } from '../../../utils/flags.js';

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectory(dirname(fileURLToPath(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');
Expand Down
12 changes: 7 additions & 5 deletions src/commands/apex/generate/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
* 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 { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand, Ux } from '@salesforce/sf-plugins-core';
import { ApexClassOptions, CreateOutput } from '@salesforce/templates';
import ApexClassGenerator from '@salesforce/templates/lib/generators/apexClassGenerator';
import { CreateUtil } from '@salesforce/templates/lib/utils';
import ApexClassGenerator from '@salesforce/templates/lib/generators/apexClassGenerator.js';
import { CreateUtil } from '@salesforce/templates/lib/utils/index.js';
import { Messages } from '@salesforce/core';
import { runGenerator, getCustomTemplates } from '../../../utils/templateCommand';
import { outputDirFlag } from '../../../utils/flags';
import { runGenerator, getCustomTemplates } from '../../../utils/templateCommand.js';
import { outputDirFlag } from '../../../utils/flags.js';

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));
const messages = Messages.loadMessages('@salesforce/plugin-templates', 'apexClass');
const commonMessages = Messages.loadMessages('@salesforce/plugin-templates', 'messages');
const apexClassFileSuffix = /.cls$/;
Expand Down
12 changes: 7 additions & 5 deletions src/commands/apex/generate/trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +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 { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import {
arrayWithDeprecation,
Flags,
Expand All @@ -13,13 +15,13 @@ import {
Ux,
} from '@salesforce/sf-plugins-core';
import { ApexTriggerOptions, CreateOutput } from '@salesforce/templates';
import ApexTriggerGenerator from '@salesforce/templates/lib/generators/apexTriggerGenerator';
import { CreateUtil } from '@salesforce/templates/lib/utils';
import ApexTriggerGenerator from '@salesforce/templates/lib/generators/apexTriggerGenerator.js';
import { CreateUtil } from '@salesforce/templates/lib/utils/index.js';
import { Messages } from '@salesforce/core';
import { getCustomTemplates, runGenerator } from '../../../utils/templateCommand';
import { outputDirFlag } from '../../../utils/flags';
import { getCustomTemplates, runGenerator } from '../../../utils/templateCommand.js';
import { outputDirFlag } from '../../../utils/flags.js';

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));
const apexTriggerFileSuffix = /.trigger$/;
const commonMessages = Messages.loadMessages('@salesforce/plugin-templates', 'messages');
const messages = Messages.loadMessages('@salesforce/plugin-templates', 'apexTrigger');
Expand Down
12 changes: 7 additions & 5 deletions src/commands/lightning/generate/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
* 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 { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand, Ux } from '@salesforce/sf-plugins-core';
import { CreateOutput, LightningAppOptions } from '@salesforce/templates';
import LightningAppGenerator from '@salesforce/templates/lib/generators/lightningAppGenerator';
import { CreateUtil } from '@salesforce/templates/lib/utils';
import LightningAppGenerator from '@salesforce/templates/lib/generators/lightningAppGenerator.js';
import { CreateUtil } from '@salesforce/templates/lib/utils/index.js';
import { Messages } from '@salesforce/core';
import { getCustomTemplates, runGenerator } from '../../../utils/templateCommand';
import { internalFlag, outputDirFlagLightning } from '../../../utils/flags';
import { getCustomTemplates, runGenerator } from '../../../utils/templateCommand.js';
import { internalFlag, outputDirFlagLightning } from '../../../utils/flags.js';

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));
const lightningCommonMessages = Messages.loadMessages('@salesforce/plugin-templates', 'lightning');
const lightningAppMessages = Messages.loadMessages('@salesforce/plugin-templates', 'lightningApp');
const lightningAppFileSuffix = /.app$/;
Expand Down
11 changes: 6 additions & 5 deletions src/commands/lightning/generate/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@

// tslint:disable:no-unused-expression

import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand, Ux } from '@salesforce/sf-plugins-core';
import { CreateOutput, LightningComponentOptions } from '@salesforce/templates';
import LightningComponentGenerator from '@salesforce/templates/lib/generators/lightningComponentGenerator';
import LightningComponentGenerator from '@salesforce/templates/lib/generators/lightningComponentGenerator.js';
import { Messages } from '@salesforce/core';
import { getCustomTemplates, runGenerator } from '../../../utils/templateCommand';
import { internalFlag, outputDirFlagLightning } from '../../../utils/flags';

import { getCustomTemplates, runGenerator } from '../../../utils/templateCommand.js';
import { internalFlag, outputDirFlagLightning } from '../../../utils/flags.js';
const BUNDLE_TYPE = 'Component';

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));
const messages = Messages.loadMessages('@salesforce/plugin-templates', 'lightningCmp');
const lightningCommon = Messages.loadMessages('@salesforce/plugin-templates', 'lightning');
export default class LightningComponent extends SfCommand<CreateOutput> {
Expand Down
13 changes: 7 additions & 6 deletions src/commands/lightning/generate/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
* 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 { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand, Ux } from '@salesforce/sf-plugins-core';
import { CreateOutput, LightningEventOptions } from '@salesforce/templates';
import LightningEventGenerator from '@salesforce/templates/lib/generators/lightningEventGenerator';
import { CreateUtil } from '@salesforce/templates/lib/utils';
import LightningEventGenerator from '@salesforce/templates/lib/generators/lightningEventGenerator.js';
import { CreateUtil } from '@salesforce/templates/lib/utils/index.js';
import { Messages } from '@salesforce/core';
import { getCustomTemplates, runGenerator } from '../../../utils/templateCommand';
import { internalFlag, outputDirFlagLightning } from '../../../utils/flags';

import { getCustomTemplates, runGenerator } from '../../../utils/templateCommand.js';
import { internalFlag, outputDirFlagLightning } from '../../../utils/flags.js';
const lightningEventFileSuffix = /.evt$/;
const BUNDLE_TYPE = 'Event';

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));

const messages = Messages.loadMessages('@salesforce/plugin-templates', 'lightningEvent');
const lightningCommon = Messages.loadMessages('@salesforce/plugin-templates', 'lightning');
Expand Down
12 changes: 7 additions & 5 deletions src/commands/lightning/generate/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
* 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 { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand, Ux } from '@salesforce/sf-plugins-core';
import { CreateOutput, LightningInterfaceOptions } from '@salesforce/templates';
import LightningInterfaceGenerator from '@salesforce/templates/lib/generators/lightningInterfaceGenerator';
import { CreateUtil } from '@salesforce/templates/lib/utils';
import LightningInterfaceGenerator from '@salesforce/templates/lib/generators/lightningInterfaceGenerator.js';
import { CreateUtil } from '@salesforce/templates/lib/utils/index.js';
import { Messages } from '@salesforce/core';
import { getCustomTemplates, runGenerator } from '../../../utils/templateCommand';
import { internalFlag, outputDirFlagLightning } from '../../../utils/flags';
import { getCustomTemplates, runGenerator } from '../../../utils/templateCommand.js';
import { internalFlag, outputDirFlagLightning } from '../../../utils/flags.js';
const lightningInterfaceFileSuffix = /.intf$/;
const BUNDLE_TYPE = 'Interface';

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));
const messages = Messages.loadMessages('@salesforce/plugin-templates', 'lightningInterface');
const lightningCommon = Messages.loadMessages('@salesforce/plugin-templates', 'lightning');

Expand Down
Loading

0 comments on commit 9ec90fb

Please sign in to comment.