Skip to content

Commit

Permalink
feat: make esm (#1094)
Browse files Browse the repository at this point in the history
* feat: make esm

* fix: deprecation-policy test

* chore: bump dev-scripts

* chore: bump plugin-release-management

* fix: convert import.meta.url to file path

* chore: update tsconfig.json

* chore: update deps

* chore: update prepare script

* chore: merge conflicts

* refactor: display-release-notes hook

* chore: update oclif eslint deps

* refactor: post-install-release-notes script

* chore: clean up

* chore: bump core and sf-plugins-core

* chore: regen yarn.lock

* chore: bump deps

* chore: bump plugin-release-management

* chore: add back compile to prepare script

* chore: bump plugin-release-management

* chore: code review

* chore: update test tsconfig

* chore: remove tslib

* chore: bump oclif

* chore: bump oclif

* chore: bump mocha

* chore: remove globby

* fix: types in custom help

* chore: bump core

* chore: bump oclif
  • Loading branch information
mdonnalley authored Oct 6, 2023
1 parent 6ae14db commit 137c095
Show file tree
Hide file tree
Showing 28 changed files with 821 additions and 1,120 deletions.
6 changes: 0 additions & 6 deletions .eslintrc

This file was deleted.

File renamed without changes.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ docs
oclif.manifest.json

# -- CLEAN ALL
*.tsbuildinfo
.eslintcache
.wireit
node_modules

# --
Expand Down
5 changes: 3 additions & 2 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"require": "ts-node/register,source-map-support/register",
"require": "ts-node/register",
"watch-extensions": "ts",
"recursive": true,
"reporter": "spec",
"timeout": 5000,
"exclude": "node_modules/**/*"
"exclude": "node_modules/**/*",
"node-option": ["loader=ts-node/esm"]
}
6 changes: 1 addition & 5 deletions .sfdevrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{
"script": {
"prepare": "sf-install && yarn compile && yarn lint",
"pretest": "echo disable # sf-compile-test",
"lint": "eslint \"src/**/*.ts\""
}
"exclude-scripts": ["test", "test:deprecation-policy", "test:command-reference", "test:json-schema"]
}
13 changes: 0 additions & 13 deletions bin/dev

This file was deleted.

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

async function main() {
const oclif = await import('@oclif/core');
oclif.settings.performanceEnabled = true;
await oclif.execute({ development: true, dir: import.meta.url });
}

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

This file was deleted.

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

// Pre-process/prune flags before creating or running the actual CLI
(await import('../dist/flags.js')).preprocessCliFlags(process);

const oclif = await import('@oclif/core');
const { createRequire } = await import('module');
const pjson = createRequire(import.meta.url)('../package.json');

const cli = await import('../dist/cli.js');

async function main() {
// Since the CLI is a single process, we can have a larger amount of max listeners since
// the process gets shut down. Don't set it to 0 (no limit) since we should still be aware
// of rouge event listeners
process.setMaxListeners(parseInt(process.env.SF_MAX_EVENT_LISTENERS, 10) || 1000);

// Don't let other plugins override the CLI specified max listener count
process.setMaxListeners = () => {};

cli
.create({ version: pjson.version, bin: pjson.oclif.bin, channel: 'stable' })
.run()
.then(async () => {
await oclif.flush();
})
.catch(async (err) => {
await oclif.handle(err);
});
}

await main();
File renamed without changes.
121 changes: 97 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"version": "2.13.1",
"author": "Salesforce",
"bin": {
"sf": "./bin/run",
"sfdx": "./bin/run"
"sf": "./bin/run.js",
"sfdx": "./bin/run.js"
},
"homepage": "https://github.com/salesforcecli/cli",
"bugs": "https://github.com/forcedotcom/cli/issues",
"engines": {
"node": ">=14.0.0"
"node": ">=16.0.0"
},
"packageManager": "[email protected]",
"files": [
Expand All @@ -27,7 +27,8 @@
"sf"
],
"license": "BSD-3-Clause",
"main": "dist/index.js",
"exports": "./dist/index.js",
"type": "module",
"oclif": {
"bin": "sf",
"binAliases": [
Expand Down Expand Up @@ -121,7 +122,7 @@
]
},
"dependencies": {
"@oclif/core": "2.15.0",
"@oclif/core": "3.0.3",
"@oclif/plugin-autocomplete": "2.3.9",
"@oclif/plugin-commands": "2.2.28",
"@oclif/plugin-help": "5.2.20",
Expand Down Expand Up @@ -150,9 +151,8 @@
"@salesforce/plugin-templates": "55.5.14",
"@salesforce/plugin-trust": "2.6.18",
"@salesforce/plugin-user": "2.3.35",
"@salesforce/sf-plugins-core": "3.1.28",
"debug": "^4.3.4",
"tslib": "^2.4.1"
"@salesforce/sf-plugins-core": "4.0.0",
"debug": "^4.3.4"
},
"pinnedDependencies": [
"@oclif/plugin-autocomplete",
Expand Down Expand Up @@ -191,14 +191,14 @@
},
"repository": "salesforcecli/cli",
"scripts": {
"build": "sf-build",
"build": "wireit",
"channel:promote": "sf-release channel:promote",
"clean": "sf-clean",
"clean-all": "sf-clean all",
"compile": "sf-compile",
"compile": "wireit",
"docs": "sf-docs",
"format": "sf-format",
"lint": "eslint \"src/**/*.ts\"",
"format": "wireit",
"lint": "wireit",
"oclif-artifacts": "oclif manifest",
"pack:deb": "oclif pack:deb",
"pack:macos": "oclif pack:macos",
Expand All @@ -213,13 +213,13 @@
"prepare": "sf-install && yarn compile && yarn lint",
"prepublishOnly": "npm shrinkwrap",
"pretarball": "sf-release cli:tarballs:prepare --types",
"pretest": "echo disable # sf-compile-test",
"promote": "oclif promote",
"promote-dist-tags": "./scripts/promote-dist-tags",
"promote:verify": "sf-release cli:versions:inspect --channels stable --locations archive --cli sf",
"promote:verify-rc": "sf-release cli:versions:inspect --channels stable-rc --locations archive --cli sf",
"test": "sf-test",
"test": "wireit",
"test:deprecation-policy": "sf-release cli:artifacts:compare",
"test:only": "wireit",
"test:smoke-unix": "sf-release cli:tarballs:smoke",
"upload:deb": "oclif upload:deb",
"upload:macos": "oclif upload:macos",
Expand All @@ -229,10 +229,10 @@
},
"types": "dist/index.d.ts",
"devDependencies": {
"@oclif/plugin-command-snapshot": "^3.3.0",
"@oclif/plugin-command-snapshot": "^4.0.2",
"@salesforce/dev-config": "^4.0.1",
"@salesforce/dev-scripts": "^3.1.1",
"@salesforce/plugin-release-management": "^4.4.0",
"@salesforce/dev-scripts": "^5.10.0",
"@salesforce/plugin-release-management": "^4.4.7",
"@salesforce/prettier-config": "^0.0.3",
"@salesforce/ts-sinon": "^1.4.17",
"@types/debug": "^4.1.9",
Expand All @@ -241,24 +241,97 @@
"aws-sdk": "^2.1468.0",
"chai": "^4.3.10",
"eslint": "^8.50.0",
"eslint-config-oclif": "^3.1",
"eslint-config-oclif-typescript": "^0.2.0",
"eslint-config-oclif": "^5",
"eslint-config-oclif-typescript": "^2.0.1",
"eslint-config-prettier": "^8.10.0",
"eslint-config-salesforce": "^2.0.2",
"eslint-config-salesforce-license": "^0.2.0",
"eslint-config-salesforce-typescript": "^1.1.1",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jsdoc": "^46.8.2",
"globby": "^11.1.0",
"husky": "^7.0.4",
"mocha": "^9.2.2",
"mocha": "^10",
"nyc": "^15.1.0",
"oclif": "^3.17.2",
"oclif": "^4.0.0",
"prettier": "^2.8.8",
"pretty-quick": "^3.1.3",
"sinon": "^11.1.2",
"sinon": "^15.2.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
"typescript": "^5",
"wireit": "^0.9.5"
},
"wireit": {
"build": {
"dependencies": [
"compile",
"lint"
]
},
"compile": {
"command": "tsc -p . --pretty --incremental",
"files": [
"src/**/*.ts",
"**/tsconfig.json",
"messages/**"
],
"output": [
"lib/**",
"*.tsbuildinfo"
],
"clean": "if-file-deleted"
},
"format": {
"command": "prettier --write \"+(src|test|schemas)/**/*.+(ts|js|json)|command-snapshot.json\"",
"files": [
"src/**/*.ts",
"test/**/*.ts",
"schemas/**/*.json",
"command-snapshot.json",
".prettier*"
],
"output": []
},
"lint": {
"command": "eslint src test --color --cache --cache-location .eslintcache",
"files": [
"src/**/*.ts",
"test/**/*.ts",
"messages/**",
"**/.eslint*",
"**/tsconfig.json"
],
"output": []
},
"test:compile": {
"command": "tsc -p \"./test\" --pretty",
"files": [
"test/**/*.ts",
"**/tsconfig.json"
],
"output": []
},
"test": {
"dependencies": [
"test:compile",
"test:only",
"lint"
]
},
"test:only": {
"command": "nyc mocha \"test/**/*.test.ts\"",
"env": {
"FORCE_COLOR": "2"
},
"files": [
"test/**/*.ts",
"src/**/*.ts",
"**/tsconfig.json",
".mocha*",
"!*.nut.ts",
".nycrc"
],
"output": []
}
}
}
Loading

0 comments on commit 137c095

Please sign in to comment.