Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 0941d9c

Browse files
authored
feat: migrate to esm (#22)
* feat: migrate to esm also: * remove swc * bump deps * remove `@salesforce/ts-sinon`, it's no longer required: forcedotcom/sfdx-core#974
1 parent 31be5e3 commit 0941d9c

File tree

16 files changed

+701
-775
lines changed

16 files changed

+701
-775
lines changed

.eslintrc.js renamed to .eslintrc.cjs

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
/*
2-
* Copyright (c) 2020, salesforce.com, inc.
3-
* All rights reserved.
4-
* Licensed under the BSD 3-Clause license.
5-
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6-
*/
71
module.exports = {
82
extends: ['eslint-config-salesforce-typescript', 'plugin:sf-plugin/recommended'],
93
rules: {

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ node_modules
4141
.idea
4242

4343
oclif.manifest.json
44+
oclif.lock

.mocharc.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
2-
"require": "ts-node/register,source-map-support/register",
3-
"watch-extensions": "ts",
4-
"watch-files": ["src", "test"],
2+
"require": "ts-node/register",
3+
"loader": "ts-node/esm",
54
"recursive": true,
65
"reporter": "spec",
76
"timeout": 5000

bin/dev

-21
This file was deleted.

bin/dev.cmd

-3
This file was deleted.

bin/dev.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning
2+
// eslint-disable-next-line node/shebang
3+
async function main() {
4+
const {execute} = await import('@oclif/core')
5+
await execute({development: true, dir: import.meta.url})
6+
}
7+
8+
await main()

bin/run

-3
This file was deleted.

bin/run.cmd

-3
This file was deleted.

bin/run.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env node
2+
async function main() {
3+
const {execute} = await import('@oclif/core')
4+
await execute({dir: import.meta.url})
5+
}
6+
7+
await main()

package.json

+14-14
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,24 @@
66
"name": "Cristian Dominguez",
77
"url": "https://github.com/cristiand391"
88
},
9+
"type": "module",
910
"bugs": "https://github.com/cristiand391/sf-plugin-api/issues",
1011
"dependencies": {
11-
"@oclif/core": "^2.15.0",
12-
"@salesforce/core": "^5.3.3",
13-
"@salesforce/sf-plugins-core": "^3.1.27",
14-
"chalk": "^4",
15-
"got": "11.8.6",
12+
"@oclif/core": "^3.10.1",
13+
"@salesforce/core": "^5.3.17",
14+
"@salesforce/sf-plugins-core": "^4.0.0",
15+
"chalk": "^5.3.0",
16+
"got": "^13.0.0",
1617
"proxy-agent": "^6.3.1"
1718
},
1819
"devDependencies": {
19-
"@oclif/plugin-command-snapshot": "^4.0.12",
20-
"@salesforce/ts-sinon": "^1.4.14",
21-
"@swc/core": "^1.3.11",
20+
"@oclif/plugin-command-snapshot": "^5.0.1",
2221
"@types/chai": "^4.3.4",
2322
"@types/inquirer": "^9.0.3",
2423
"@types/mocha": "^10.0.1",
2524
"@types/sinon": "^10.0.13",
26-
"@typescript-eslint/eslint-plugin": "^5.40.0",
27-
"@typescript-eslint/parser": "^5.40.1",
25+
"@typescript-eslint/eslint-plugin": "^6.9.0",
26+
"@typescript-eslint/parser": "^6.9.0",
2827
"chai": "^4.3.6",
2928
"eslint": "^8.26.0",
3029
"eslint-config-prettier": "^8.5.0",
@@ -39,12 +38,13 @@
3938
"prettier": "^3.0.1",
4039
"shx": "0.3.4",
4140
"sinon": "^15.0.3",
41+
"strip-ansi": "^7.1.0",
4242
"ts-node": "^10.9.1",
43-
"typescript": "^4.8.4",
43+
"typescript": "^5.2.2",
4444
"wireit": "^0.10.0"
4545
},
4646
"engines": {
47-
"node": ">=16"
47+
"node": ">=18"
4848
},
4949
"prettier": {
5050
"singleQuote": true
@@ -64,7 +64,6 @@
6464
"sf"
6565
],
6666
"license": "BSD-3-Clause",
67-
"main": "lib/index.js",
6867
"oclif": {
6968
"commands": "./lib/commands",
7069
"bin": "sf",
@@ -85,6 +84,7 @@
8584
"postpack": "shx rm -f oclif.manifest.json",
8685
"prepack": "oclif manifest .",
8786
"test": "wireit",
87+
"test:run": "wireit",
8888
"version": "oclif readme"
8989
},
9090
"wireit": {
@@ -135,7 +135,7 @@
135135
]
136136
},
137137
"test:deprecation-policy": {
138-
"command": "\"./bin/dev\" snapshot:compare",
138+
"command": "ts-node \"./bin/dev.js\" snapshot:compare",
139139
"files": [
140140
"src/**/*.ts"
141141
],

src/commands/org/api.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { readFile } from 'node:fs/promises';
22
import { EOL } from 'node:os';
33
import got, { Headers, Method } from 'got';
4-
import * as chalk from 'chalk';
4+
import chalk from 'chalk';
55
import { ProxyAgent } from 'proxy-agent';
66
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
77
import { SfError, Org } from '@salesforce/core';

src/index.ts

-1
This file was deleted.

test/commands/org/api.test.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import nock = require('nock');
2-
import { TestContext, MockTestOrgData } from '@salesforce/core/lib/testSetup';
2+
import { TestContext, MockTestOrgData } from '@salesforce/core/lib/testSetup.js';
33
import { SfError } from '@salesforce/core';
44
import { expect } from 'chai';
5-
import stripAnsi = require('strip-ansi');
6-
import { stdout } from '@oclif/core';
7-
import { OrgApi } from '../../../src/commands/org/api';
5+
import stripAnsi from 'strip-ansi';
6+
import { OrgApi } from '../../../src/commands/org/api.js';
87

98
describe('org api', () => {
109
const $$ = new TestContext();
@@ -16,7 +15,7 @@ describe('org api', () => {
1615

1716
beforeEach(async () => {
1817
await $$.stubAuths(testOrg);
19-
stdoutSpy = $$.SANDBOX.stub(stdout, 'write');
18+
stdoutSpy = $$.SANDBOX.stub(process.stdout, 'write');
2019
});
2120

2221
afterEach(() => {

test/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"include": ["./**/*.ts"],
33
"compilerOptions": {
4+
"module": "nodenext",
45
"strict": true,
56
"noEmit": true,
67
"skipLibCheck": true,

tsconfig.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
{
22
"compilerOptions": {
33
"strict": true,
4-
"module": "commonjs",
4+
"module": "nodenext",
55
"target": "ES2021",
66
"lib": ["ES2021"],
7-
"moduleResolution": "node",
7+
"moduleResolution": "nodenext",
8+
"skipLibCheck": true,
89
"alwaysStrict": true,
910
"noUnusedLocals": true,
1011
"outDir": "lib",
1112
"rootDir": "src",
1213
"allowSyntheticDefaultImports": true
1314
},
15+
"ts-node": { "esm": true },
1416
"include": ["./src/**/*.ts"]
1517
}

0 commit comments

Comments
 (0)