Skip to content

Commit

Permalink
feat!: migrate to ESM
Browse files Browse the repository at this point in the history
BREAKING CHANGES: ESM and node 18 minimum
  • Loading branch information
mdonnalley committed Dec 14, 2023
1 parent fb52067 commit eeaa3b2
Show file tree
Hide file tree
Showing 56 changed files with 368 additions and 274 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.cjs/
3 changes: 3 additions & 0 deletions .lintstagedrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'**/*.{js,json,md}?(x)': () => 'npm run reformat',
};
3 changes: 0 additions & 3 deletions .lintstagedrc.js

This file was deleted.

5 changes: 3 additions & 2 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"require": "ts-node/register,source-map-support/register",
"require": ["ts-node/register"],
"watch-extensions": "ts",
"recursive": true,
"reporter": "spec",
"timeout": 20000
"timeout": 20000,
"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
100644 → 100755
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();
3 changes: 0 additions & 3 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.
41 changes: 21 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
{
"name": "@salesforce/plugin-packaging",
"description": "SF plugin that support Salesforce Packaging Platform",
"version": "1.27.9",
"main": "lib/index.js",
"version": "2.0.0",
"author": "Salesforce",
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
"@oclif/core": "^3.14.1",
"@salesforce/core": "^6.4.0",
"@salesforce/core": "^6.4.1",
"@salesforce/kit": "^3.0.15",
"@salesforce/packaging": "^3.0.4",
"@salesforce/sf-plugins-core": "^5.0.8",
"chalk": "^4.1.2",
"tslib": "^2"
"@salesforce/sf-plugins-core": "^5.0.9",
"chalk": "^5.3.0"
},
"devDependencies": {
"@oclif/plugin-command-snapshot": "^4.0.16",
"@salesforce/cli-plugins-testkit": "^4.4.12",
"@oclif/plugin-command-snapshot": "^5.0.4",
"@salesforce/cli-plugins-testkit": "^5.1.1",
"@salesforce/dev-scripts": "^8.1.2",
"@salesforce/plugin-command-reference": "^3.0.51",
"@swc/core": "1.3.100",
"eslint-plugin-sf-plugin": "^1.16.15",
"oclif": "^4",
"oclif": "^4.0.4",
"shx": "0.3.4",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
},
"config": {},
"engines": {
"node": ">=16.0.0"
"node": ">=18.0.0"
},
"files": [
"/lib",
Expand All @@ -41,11 +38,11 @@
"keywords": [
"force",
"salesforce",
"sfdx",
"sf",
"salesforcedx",
"sfdx-plugin",
"sf-plugin"
"sf",
"sf-plugin",
"sfdx",
"sfdx-plugin"
],
"license": "BSD-3-Clause",
"oclif": {
Expand Down Expand Up @@ -108,7 +105,9 @@
}
}
}
}
},
"flexibleTaxonomy": true,
"topicSeparator": " "
},
"repository": "salesforcecli/plugin-packaging",
"scripts": {
Expand Down Expand Up @@ -210,7 +209,7 @@
"output": []
},
"test:command-reference": {
"command": "\"./bin/dev\" commandreference:generate --erroronwarnings",
"command": "node --loader ts-node/esm --no-warnings=ExperimentalWarning \"./bin/dev.js\" commandreference:generate --erroronwarnings",
"files": [
"src/**/*.ts",
"messages/**",
Expand All @@ -221,7 +220,7 @@
]
},
"test:deprecation-policy": {
"command": "\"./bin/dev\" snapshot:compare",
"command": "node --loader ts-node/esm --no-warnings=ExperimentalWarning \"./bin/dev.js\" snapshot:compare",
"files": [
"src/**/*.ts"
],
Expand All @@ -231,7 +230,7 @@
]
},
"test:json-schema": {
"command": "\"./bin/dev\" schema:compare",
"command": "node --loader ts-node/esm --no-warnings=ExperimentalWarning \"./bin/dev.js\" schema:compare",
"files": [
"src/**/*.ts",
"schemas"
Expand All @@ -247,5 +246,7 @@
],
"output": []
}
}
},
"exports": "./lib/index.js",
"type": "module"
}
4 changes: 2 additions & 2 deletions src/commands/package/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import {
PackagingSObjects,
} from '@salesforce/packaging';
import { camelCaseToTitleCase, Duration } from '@salesforce/kit';
import { requiredHubFlag } from '../../utils/hubFlag';
import { requiredHubFlag } from '../../utils/hubFlag.js';

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_convert');
const pvcMessages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_version_create');

Expand Down
4 changes: 2 additions & 2 deletions src/commands/package/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand } from '@salesforce/sf-plugins-core';
import { Messages } from '@salesforce/core';
import { Package, PackageCreateOptions, PackageType } from '@salesforce/packaging';
import { requiredHubFlag } from '../../utils/hubFlag';
import { requiredHubFlag } from '../../utils/hubFlag.js';

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_create');

export type PackageCreate = { Id: string };
Expand Down
4 changes: 2 additions & 2 deletions src/commands/package/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand } from '@salesforce/sf-plugins-core';
import { Messages } from '@salesforce/core';
import { Package, PackageSaveResult } from '@salesforce/packaging';
import { requiredHubFlag } from '../../utils/hubFlag';
import { requiredHubFlag } from '../../utils/hubFlag.js';

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_delete');

export class PackageDeleteCommand extends SfCommand<PackageSaveResult> {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/package/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import {
PackagingSObjects,
SubscriberPackageVersion,
} from '@salesforce/packaging';
import { Report } from './install/report';
import { Report } from './install/report.js';

export type PackageInstallRequest = PackagingSObjects.PackageInstallRequest;

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_install');

// maps of command flag values to PackageInstallRequest values
Expand Down
2 changes: 1 addition & 1 deletion src/commands/package/install/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { PackagingSObjects, SubscriberPackageVersion } from '@salesforce/packagi

export type PackageInstallRequest = PackagingSObjects.PackageInstallRequest;

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_install_report');
const installMsgs = Messages.loadMessages('@salesforce/plugin-packaging', 'package_install');

Expand Down
2 changes: 1 addition & 1 deletion src/commands/package/installed/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { ux } from '@oclif/core';
import { SubscriberPackageVersion } from '@salesforce/packaging';

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_installed_list');

export type PackageInstalledListResult = {
Expand Down
6 changes: 3 additions & 3 deletions src/commands/package/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand } from '@salesforce/sf-plugins-core';
import { Messages } from '@salesforce/core';
import { Package, PackagingSObjects } from '@salesforce/packaging';
import * as chalk from 'chalk';
import { requiredHubFlag } from '../../utils/hubFlag';
import chalk from 'chalk';
import { requiredHubFlag } from '../../utils/hubFlag.js';

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_list');

export type Package2Result = Partial<
Expand Down
2 changes: 1 addition & 1 deletion src/commands/package/uninstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Duration } from '@salesforce/kit';

export type UninstallResult = PackagingSObjects.SubscriberPackageVersionUninstallRequest;

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_uninstall');

export class PackageUninstallCommand extends SfCommand<UninstallResult> {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/package/uninstall/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { Messages } from '@salesforce/core';
import { PackagingSObjects, SubscriberPackageVersion } from '@salesforce/packaging';

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_uninstall_report');

export class PackageUninstallReportCommand extends SfCommand<PackagingSObjects.SubscriberPackageVersionUninstallRequest> {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/package/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand } from '@salesforce/sf-plugins-core';
import { Messages } from '@salesforce/core';
import { Package, PackageSaveResult } from '@salesforce/packaging';
import { requiredHubFlag } from '../../utils/hubFlag';
import { requiredHubFlag } from '../../utils/hubFlag.js';

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_update');
const packageCreate = Messages.loadMessages('@salesforce/plugin-packaging', 'package_create');

Expand Down
6 changes: 3 additions & 3 deletions src/commands/package/version/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import * as os from 'node:os';
import os from 'node:os';
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand } from '@salesforce/sf-plugins-core';
import { camelCaseToTitleCase, Duration } from '@salesforce/kit';
import { Lifecycle, Messages } from '@salesforce/core';
Expand All @@ -17,10 +17,10 @@ import {
PackageVersionEvents,
PackagingSObjects,
} from '@salesforce/packaging';
import { requiredHubFlag } from '../../../utils/hubFlag';
import { requiredHubFlag } from '../../../utils/hubFlag.js';
import Package2VersionStatus = PackagingSObjects.Package2VersionStatus;

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_version_create');

export type PackageVersionCommandResult = Partial<PackageVersionCreateRequestResult>;
Expand Down
6 changes: 3 additions & 3 deletions src/commands/package/version/create/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand } from '@salesforce/sf-plugins-core';
import { Connection, Messages } from '@salesforce/core';
import { PackageVersion, PackageVersionCreateRequestResult, getPackageVersionNumber } from '@salesforce/packaging';
import * as chalk from 'chalk';
import { requiredHubFlag } from '../../../../utils/hubFlag';
import chalk from 'chalk';
import { requiredHubFlag } from '../../../../utils/hubFlag.js';

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_version_create_list');
const packaging = Messages.loadMessages('@salesforce/plugin-packaging', 'packaging');

Expand Down
8 changes: 4 additions & 4 deletions src/commands/package/version/create/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand } from '@salesforce/sf-plugins-core';
import { Messages, Org } from '@salesforce/core';
import * as pkgUtils from '@salesforce/packaging';
import pkgUtils from '@salesforce/packaging';
import { PackageVersion, PackageVersionCreateRequestResult } from '@salesforce/packaging';
import * as chalk from 'chalk';
import chalk from 'chalk';
import { camelCaseToTitleCase } from '@salesforce/kit';
import { requiredHubFlag } from '../../../../utils/hubFlag';
import { requiredHubFlag } from '../../../../utils/hubFlag.js';

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_version_create_report');
const pvclMessages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_version_create_list');
const pvlMessages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_version_list');
Expand Down
4 changes: 2 additions & 2 deletions src/commands/package/version/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand } from '@salesforce/sf-plugins-core';
import { Messages } from '@salesforce/core';
import { PackageSaveResult, PackageVersion } from '@salesforce/packaging';
import { requiredHubFlag } from '../../../utils/hubFlag';
import { requiredHubFlag } from '../../../utils/hubFlag.js';

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_version_delete');

export class PackageVersionDeleteCommand extends SfCommand<PackageSaveResult> {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/package/version/displayancestry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand } from '@salesforce/sf-plugins-core';
import { Messages } from '@salesforce/core';
import { Package, PackageAncestryNodeData } from '@salesforce/packaging';
import { requiredHubFlag } from '../../../utils/hubFlag';
import { requiredHubFlag } from '../../../utils/hubFlag.js';

// Import i18n messages
Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_displayancestry');

export type DisplayAncestryCommandResult = PackageAncestryNodeData | string | void;
Expand Down
4 changes: 2 additions & 2 deletions src/commands/package/version/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import {
Package,
PackageVersionListResult,
} from '@salesforce/packaging';
import { requiredHubFlag } from '../../../utils/hubFlag';
import { requiredHubFlag } from '../../../utils/hubFlag.js';

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_version_list');
const packaging = Messages.loadMessages('@salesforce/plugin-packaging', 'packaging');

Expand Down
4 changes: 2 additions & 2 deletions src/commands/package/version/promote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand } from '@salesforce/sf-plugins-core';
import { Messages, SfError } from '@salesforce/core';
import { PackageSaveResult, PackageVersion } from '@salesforce/packaging';
import { requiredHubFlag } from '../../../utils/hubFlag';
import { requiredHubFlag } from '../../../utils/hubFlag.js';

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_version_promote');

export class PackageVersionPromoteCommand extends SfCommand<PackageSaveResult> {
Expand Down
Loading

0 comments on commit eeaa3b2

Please sign in to comment.