Skip to content

Commit

Permalink
feat!: migrate to ESM (#269)
Browse files Browse the repository at this point in the history
* feat!: migrate to ESM

BREAKING CHANGES: node 18 minimum, removed exports

* chore: remove disabled linting rules

* fix: update bin scripts

* chore(release): 1.3.11-qa.0

---------

Co-authored-by: svc-cli-bot <[email protected]>
Co-authored-by: mshanemc <[email protected]>
  • Loading branch information
3 people authored Oct 10, 2023
1 parent 06f0116 commit 85f1947
Show file tree
Hide file tree
Showing 29 changed files with 2,025 additions and 1,197 deletions.
1 change: 1 addition & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"extends": ["@commitlint/config-conventional"]}
11 changes: 0 additions & 11 deletions .editorconfig

This file was deleted.

8 changes: 0 additions & 8 deletions .eslintrc

This file was deleted.

3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["oclif", "oclif-typescript", "prettier"]
}
4 changes: 2 additions & 2 deletions .git2gus/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"productTag": "a1aB0000000ce2IIAQ",
"defaultBuild": "offcore.tooling.55",
"issueTypeLabels": { "enhancement": "USER STORY", "bug": "BUG P3" },
"defaultBuild": "offcore.tooling.59",
"issueTypeLabels": {"enhancement": "USER STORY", "bug": "BUG P3"},
"hideWorkItemUrl": true,
"statusWhenClosed": "CLOSED"
}
9 changes: 6 additions & 3 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ name: automerge
on:
workflow_dispatch:
schedule:
- cron: '17 2,5,8,11 * * *'
- cron: '42 2,5,8,11 * * *'

jobs:
automerge:
uses: oclif/github-workflows/.github/workflows/automerge.yml@main
secrets: inherit
uses: salesforcecli/github-workflows/.github/workflows/automerge.yml@main
secrets:
SVC_CLI_BOT_GITHUB_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
with:
mergeMethod: squash
4 changes: 2 additions & 2 deletions .github/workflows/create-github-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ on:
# point at specific branches, or a naming convention via wildcard
- prerelease/**
tags-ignore:
- "*"
- '*'
workflow_dispatch:
inputs:
prerelease:
type: string
description: "Name to use for the prerelease: beta, dev, etc. NOTE: If this is already set in the package.json, it does not need to be passed in here."
description: 'Name to use for the prerelease: beta, dev, etc. NOTE: If this is already set in the package.json, it does not need to be passed in here.'

jobs:
release:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/failureNotifications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: failureNotifications
on:
workflow_run:
workflows:
- version, tag and github release
- create-github-release
- publish
types:
- completed
Expand Down
36 changes: 0 additions & 36 deletions .github/workflows/manualRelease.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/onPushToMain.yml

This file was deleted.

10 changes: 8 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@ on:
workflow_dispatch:

jobs:
unit-tests:
uses: oclif/github-workflows/.github/workflows/unitTest.yml@main
yarn-lockfile-check:
uses: salesforcecli/github-workflows/.github/workflows/lockFileCheck.yml@main
linux-unit-tests:
needs: yarn-lockfile-check
uses: salesforcecli/github-workflows/.github/workflows/unitTestsLinux.yml@main
windows-unit-tests:
needs: linux-unit-tests
uses: salesforcecli/github-workflows/.github/workflows/unitTestsWindows.yml@main
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
/node_modules
/tmp
.idea
oclif.lock
oclif.manifest.json
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged --concurrent false
5 changes: 5 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"*.json": ["prettier --write"],
"*.md": ["prettier --write"],
"+(src|test)/**/*.+(ts|js)": ["eslint --fix", "prettier --write"]
}
13 changes: 4 additions & 9 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
{
"require": [
"test/helpers/init.js",
"ts-node/register",
"source-map-support/register"
],
"watch-extensions": [
"ts"
],
"require": ["ts-node/register"],
"watch-extensions": ["ts"],
"recursive": true,
"reporter": "spec",
"timeout": 60000
"timeout": 60000,
"node-option": ["loader=ts-node/esm"]
}
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@oclif/prettier-config"
17 changes: 0 additions & 17 deletions bin/dev

This file was deleted.

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 ts-node
// 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.

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

async function main() {
const {execute} = await import('@oclif/core')
await execute({dir: import.meta.url})
}

await main()
1 change: 0 additions & 1 deletion commitlint.config.js

This file was deleted.

57 changes: 32 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,50 @@
{
"name": "@oclif/plugin-version",
"description": "A command that shows the CLI version",
"version": "1.3.10",
"version": "1.3.11-qa.0",
"author": "Salesforce",
"bugs": "https://github.com/oclif/plugin-version/issues",
"dependencies": {
"@oclif/core": "^2.15.0"
"@oclif/core": "^3.0.4"
},
"devDependencies": {
"@commitlint/config-conventional": "^12.1.4",
"@commitlint/config-conventional": "^17.7.0",
"@oclif/plugin-help": "5.2.20",
"@oclif/test": "^2.5.6",
"@oclif/prettier-config": "^0.2.1",
"@oclif/test": "^3",
"@types/chai": "^4.3.6",
"@types/mocha": "^8.0.0",
"@types/node": "^16",
"@types/mocha": "^10",
"@types/node": "^18",
"chai": "^4.3.10",
"commitlint": "^12.1.4",
"eslint": "^7.3.1",
"eslint-config-oclif": "^4",
"eslint-config-oclif-typescript": "^1.0.2",
"fancy-test": "^2.0.42",
"husky": "6",
"mocha": "^8.2.1",
"oclif": "^3.17.2",
"commitlint": "^17.7.2",
"eslint": "^8.51.0",
"eslint-config-oclif": "^5",
"eslint-config-oclif-typescript": "^3",
"eslint-config-prettier": "^9.0.0",
"fancy-test": "^3",
"husky": "^8",
"lint-staged": "^14.0.1",
"mocha": "^10.2.0",
"oclif": "^4",
"prettier": "^3.0.3",
"shx": "^0.3.4",
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
"typescript": "^5"
},
"engines": {
"node": ">=14.0.0"
"node": ">=18.0.0"
},
"files": [
"oclif.manifest.json",
"oclif.lock",
"/lib"
],
"homepage": "https://github.com/oclif/plugin-version",
"keywords": [
"oclif-plugin"
],
"license": "MIT",
"main": "lib/index.js",
"exports": "./lib/index.js",
"oclif": {
"commands": "./lib/commands",
"devPlugins": [
Expand All @@ -49,16 +54,18 @@
"repository": "oclif/plugin-version",
"scripts": {
"build": "shx rm -rf lib && tsc",
"clean": "shx rm -f oclif.manifest.json oclif.lock",
"commitlint": "commitlint",
"clean": "shx rm -f oclif.manifest.json",
"lint": "eslint . --ext .ts --config .eslintrc",
"pretest": "yarn build",
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
"posttest": "yarn lint",
"prepublishOnly": "yarn run build && oclif manifest . && oclif readme",
"lint": "eslint . --ext .ts",
"postpublish": "yarn run clean",
"posttest": "yarn lint",
"prepare": "husky install",
"prepublishOnly": "yarn run build && oclif lock && oclif manifest . && oclif readme",
"pretest": "yarn build --noEmit && tsc -p test --noEmit",
"preversion": "yarn run clean",
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
"version": "oclif readme && git add README.md"
},
"types": "lib/index.d.ts"
}
"types": "lib/index.d.ts",
"type": "module"
}
38 changes: 19 additions & 19 deletions src/commands/version.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import {Command, Flags, Interfaces} from '@oclif/core'
// eslint-disable-next-line unicorn/prefer-node-protocol
import {EOL} from 'os'
import {EOL} from 'node:os'

export type VersionDetail = Omit<Interfaces.VersionDetails, 'pluginVersions'> & {
pluginVersions?: string[];
pluginVersions?: string[]
}

export default class Version extends Command {
static enableJsonFlag = true

public static flags = {
verbose: Flags.boolean({
description:
'Additionally shows the architecture, node version, operating system, and versions of plugins that the CLI is using.',
summary: 'Show additional information about the CLI.',
description: 'Additionally shows the architecture, node version, operating system, and versions of plugins that the CLI is using.',
}),
}

Expand Down Expand Up @@ -51,28 +51,28 @@ export default class Version extends Command {

this.log(output)

return flags.verbose ?
versionDetail :
{
cliVersion: versionDetail.cliVersion,
architecture: versionDetail.architecture,
nodeVersion: versionDetail.nodeVersion,
}
return flags.verbose
? versionDetail
: {
architecture: versionDetail.architecture,
cliVersion: versionDetail.cliVersion,
nodeVersion: versionDetail.nodeVersion,
}
}

private formatPlugins(plugins: Record<string, Interfaces.PluginVersionDetail>): string[] {
return Object.entries(plugins)
.map(([name, plugin]) => ({name, ...plugin}))
.sort((a, b) => (a.name > b.name ? 1 : -1))
.map(plugin =>
`${this.getFriendlyName(plugin.name)} ${plugin.version} (${plugin.type}) ${
plugin.type === 'link' ? plugin.root : ''
}`.trim(),
)
.map(([name, plugin]) => ({name, ...plugin}))
.sort((a, b) => (a.name > b.name ? 1 : -1))
.map((plugin) =>
`${this.getFriendlyName(plugin.name)} ${plugin.version} (${plugin.type}) ${
plugin.type === 'link' ? plugin.root : ''
}`.trim(),
)
}

private getFriendlyName(name: string): string {
const scope = this.config.pjson.oclif.scope
const {scope} = this.config.pjson.oclif
if (!scope) return name
const match = name.match(`@${scope}/plugin-(.+)`)
if (!match) return name
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {VersionDetail, default as VersionCommand} from './commands/version'
export {run} from '@oclif/core'
Loading

0 comments on commit 85f1947

Please sign in to comment.