Skip to content

Commit f6e7286

Browse files
mdonnalleysvc-cli-botmshanemc
authored
Version 3 (#767)
* chore: v3 prerelease branch * chore(release): 3.0.0-beta.1 [skip ci] * feat: ESM support (#759) * fix: set moduleResolution to Node16 * fix: use file urls * chore: add types * feat: support linking CJS plugins into ESM plugins * chore: integration tests for module interoperability * test: add CJS/ESM interoperability tests * fix: e2e tests * test: isolate cache, config, and data dir for e2e tests * test: test bug * test: make less noisy * test: esm/cjs hooks * chore: parallelize e2e tests * chore: typo * test: parallelize e2e tests * test: no more hanging tests * chore: un-parallelize esm-cjs tests * chore: add DEBUG to esm-cjs interop tests * chore: add DEBUG to esm-cjs interop tests * chore: try enabling debug again * test: fix node 20 tests * chore: update DEBUG env var * chore: debug tests * chore: debug tests * test: more debugging * test: more debugging * test: more debugging * test: more debugging * test: more debugging * test: more debugging * test: more debugging * test: use path.join * test: stop using replace-in-file * chore: more test debugging * fix: use path.join when registering ts-node * test: run in parallel * test: run tests serially * fix: dont remove undefined values from tsconfig * fix: further isolate ts-configs * feat: throw error when loading ESM paths from linked plugins * fix: default esm to true * test: compilation errors * feat: better developer experience * fix: add getPluginsList * chore(release): 2.11.9 [skip ci] * fix: add getPluginsList to Config interface * chore(release): 2.11.10 [skip ci] --------- Co-authored-by: svc-cli-bot <[email protected]> * chore(release): 3.0.0-beta.2 [skip ci] * More v3 features (#772) * fix: set moduleResolution to Node16 * fix: use file urls * chore: add types * feat: support linking CJS plugins into ESM plugins * chore: integration tests for module interoperability * test: add CJS/ESM interoperability tests * fix: e2e tests * test: isolate cache, config, and data dir for e2e tests * test: test bug * test: make less noisy * test: esm/cjs hooks * chore: parallelize e2e tests * chore: typo * test: parallelize e2e tests * test: no more hanging tests * chore: un-parallelize esm-cjs tests * chore: add DEBUG to esm-cjs interop tests * chore: add DEBUG to esm-cjs interop tests * chore: try enabling debug again * test: fix node 20 tests * chore: update DEBUG env var * chore: debug tests * chore: debug tests * test: more debugging * test: more debugging * test: more debugging * test: more debugging * test: more debugging * test: more debugging * test: more debugging * test: use path.join * test: stop using replace-in-file * chore: more test debugging * fix: use path.join when registering ts-node * test: run in parallel * test: run tests serially * fix: dont remove undefined values from tsconfig * fix: further isolate ts-configs * feat: throw error when loading ESM paths from linked plugins * fix: default esm to true * test: compilation errors * feat: better developer experience * fix: add getPluginsList * chore(release): 2.11.9 [skip ci] * fix: add getPluginsList to Config interface * chore(release): 2.11.10 [skip ci] * feat: use exports * fix: ux class * fix: add exports for help and perf * chore: tests * feat: use Map for config.plugins * feat: add noCacheDefault * feat: add exports for Args and Flags * chore: fix tests * feat: put permutations into manifest * fix: add return to execute * fix: add version to PJSON interface * feat: drop node 14 and 16 support * fix: use CLIError for integer flag errors * fix: skip findRoot for linked plugins * chore: remove console.log * fix: dont load core plugin if already loaded as linked or user plugin * fix: ux export * chore: making things readonly * feat: add config export * test: make tests passing again * feat: rename cli-ux global to ux global * chore: go back to node 16 support * chore: migration guide * chore: remove source-map register * test: remove resolution * chore: update migration guide * fix: revert link findRoot optimization * fix: remove unneeded exports * feat: add PluginLoader * chore: update migration guide * chore: merge conflict * chore: more merge conflicts * test: recursive mkdir --------- Co-authored-by: svc-cli-bot <[email protected]> * chore(release): 3.0.0-beta.3 [skip ci] * chore(release): 3.0.0-beta.4 [skip ci] * fix: add main to package.json * chore(release): 3.0.0-beta.5 [skip ci] * fix: export CustomOptions * chore(release): 3.0.0-beta.6 [skip ci] * fix: interface exports * chore(release): 3.0.0-beta.7 [skip ci] * feat: remove ux and interfaces export * chore(release): 3.0.0-beta.8 [skip ci] * fix: revert ux changes * chore(release): 3.0.0-beta.9 [skip ci] * feat: revert exports changes (#776) * feat: revert exports changes * fix: run e2e tests even if linting error * fix: revert cli-ux dir renaming * chore(release): 3.0.0-beta.10 [skip ci] * fix: revert styledJSON change * chore(release): 3.0.0-beta.11 [skip ci] * fix: update imports in Config * chore(release): 3.0.0-beta.12 [skip ci] * feat: skip ts-node register for ESM plugins (#778) * feat: skip ts-node register for ESM plugins * chore: update debug message * chore(release): 3.0.0-beta.13 [skip ci] * feat: final v3 features (#779) * feat: add charAliases * feat: add Flags.option * fix: undo default options * fix: allow bin/dev.js to auto-transpile ESM plugin * chore: update execute examples * fix: update tsnode skip logic * chore: test debugging * fix: ts-node skip logic * fix: ts-node skip logic * feat: cache relativePath and isESM in manifest * fix: calculate id permutations at runtime to support backwards compatability * perf: avoid findLegacyRoot for linked plugins * chore: remove env var * fix: improve perf metrics * perf: improve perf debug output * perf: more debug improvements * test: compilation errors * fix: make relativePath OS safe * test: use sf esm branch * perf: give full hook path * chore: test debugging * chore: test debugging * chore: test debugging * test: set shell for e2e tests * fix: flag types respect defaults * feat: node protocol * test: move windows sf integration tests into separate job * test: update assertion on plugins install test * test: use correct file path * test: use -Force * test: use bash shell * test: clean up * test: remove shell option * test: oclif/config, core v1, and core v2 interop tests * chore: drop node 16 * test: remove lts/-1 * chore: code review * chore: add pre core migration guide * refactor: break up ModuleLoader * chore: remove unicorn/consistent-function-scoping * chore: remove unicorn/no-missing-imports * chore: remove @typescript-eslint/no-empty-function * chore: remove ban-ts-comment and ban-ts-ignore * chore: add sort-import rule * fix: throw error if non-multiple flag provided more than once * test: mutliples of non-multiple flag test * test: ut for charAliases (#791) * test: duplicate aliases tests * test: extend timeout * test: split windows esm-cjs tests * test: parallelize linux interop tests too * test: typo * test: use right executor * test: use right executor for clean up * chore: update eslint libs (#792) * chore: update eslint libs * chore: clean up * chore: tests and linting * test: windows paths * fix: exports * test: update run import * chore: replaceAll * fix: error exit codes * fix: use es2021 * feat: use ES2022 * fix: use ES2021 again * test: incorporate flags and args in esm-cjs tests * test: use correct expected values --------- Co-authored-by: Shane McLaughlin <[email protected]> * chore(release): 3.0.0-beta.14 [skip ci] * fix: allow undefined from flag parser * chore(release): 3.0.0-beta.15 [skip ci] * feat: set spinner style * chore(release): 3.0.0-beta.16 [skip ci] * test: unset config vars after setting them * feat: remove ts-node (#794) * feat: drop ts-node dependency * test: use --json for config unset * chore(release): 3.0.0-beta.17 [skip ci] * fix: use ES2022 (#793) * fix: use ES2022 * test: use --json for config unset * feat: stop using getters and setters for flags * chore: clean up * feat: expose json flag * feat: remove pass through getter and setter * fix: correct order of flags in toCached * chore: clean up * fix: flag merge order * chore: documentation * test: use oclif/test v3 * feat: set spinner style on windows too * fix: handle cmd with baseFlags but no flags * fix: some circular deps * fix: circular deps in help * fix: ts-node and config circular deps * fix: toCached circular dep in help * chore: organize utils * test: enforce no circular deps * chore: remove Flags.json * chore: add prettier config * test: add nyc * test: improve test coverage * test: windows unit tests * chore: revert change to automerge.yml * chore: code review * perf: parallelize cacheCommand * chore(release): 3.0.0-beta.18 [skip ci] * chore: use prettier and lint-staged (#798) * chore: update prettier config * chore: prettier and lint-staged * chore: reformat everything * chore: deal with reformat aftermath * chore: update configs and deps * perf: move ansi-escapes require to top level * chore: automerge.yml * chore: unpin eslint-plugin-prettier * chore: remove prettier plugin * chore: update lint-staged config * fix: update util import * chore(release): 3.0.0-beta.19 [skip ci] * chore: remove util/index.ts (#802) * fix: remove tsPath export * fix: move @types/cli-progress to devDeps * chore(release): 3.0.0-beta.20 [skip ci] * fix: force release * chore(release): 3.0.0-beta.21 [skip ci] * fix: move styledJson to index * chore(release): 3.0.0-beta.22 [skip ci] * feat: collect perf results from outside oclif (#797) * feat: collect perf results from outside oclif * chore: pr feedback * refactor: naming for non-core perf * chore(release): 3.0.0-beta.23 [skip ci] * fix: remove OCLIF_NEXT_VERSION * chore: add prepare for husky install * test: try false for ignoreScripts * chore(release): 3.0.0-beta.25 [skip ci] * test: ignore scripts for external nuts * chore: use eslint-plugin-perfectionist (#807) --------- Co-authored-by: svc-cli-bot <[email protected]> Co-authored-by: Shane McLaughlin <[email protected]>
1 parent c992403 commit f6e7286

File tree

165 files changed

+15131
-8746
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+15131
-8746
lines changed

.commitlintrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["@commitlint/config-conventional"]
3+
}

.editorconfig

-11
This file was deleted.

.eslintrc

-19
This file was deleted.

.eslintrc.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": ["oclif", "oclif-typescript", "prettier", "plugin:perfectionist/recommended-natural"],
3+
"rules": {
4+
"unicorn/prefer-module": "off",
5+
"unicorn/no-array-reduce": "off",
6+
"no-useless-constructor": "off",
7+
"perfectionist/sort-object-types": "off",
8+
"perfectionist/sort-union-types": "off"
9+
}
10+
}

.github/workflows/automerge.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ name: automerge
22
on:
33
workflow_dispatch:
44
schedule:
5-
- cron: '17 2,5,8,11 * * *'
5+
- cron: "17 2,5,8,11 * * *"
66

77
jobs:
88
automerge:
9-
uses: oclif/github-workflows/.github/workflows/automerge.yml@main
10-
secrets: inherit
9+
uses: salesforcecli/github-workflows/.github/workflows/automerge.yml@main
10+
secrets:
11+
SVC_CLI_BOT_GITHUB_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}

.github/workflows/create-github-release.yml

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
# However, if this is a manual release (workflow_dispatch), then we want to disable skip-on-empty
2525
# This helps recover from forgetting to add semantic commits ('fix:', 'feat:', etc.)
2626
skip-on-empty: ${{ github.event_name == 'push' }}
27+
generate-readme: false
2728
# docs:
2829
# # Most repos won't use this
2930
# # Depends on the 'release' job to avoid git collisions, not for any functionality reason

.github/workflows/test.yml

+56-13
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ jobs:
1313
windows-unit-tests:
1414
needs: linux-unit-tests
1515
uses: salesforcecli/github-workflows/.github/workflows/unitTestsWindows.yml@main
16-
node14:
16+
e2e:
1717
needs: linux-unit-tests
1818
strategy:
1919
matrix:
20-
os: ["ubuntu-latest", "windows-latest"]
21-
node_version: [14.x]
20+
os: [ubuntu-latest, windows-latest]
21+
node_version: [lts/*, latest]
22+
exclude:
23+
- os: windows-latest
24+
node_version: lts/*
2225
fail-fast: false
2326
runs-on: ${{ matrix.os }}
2427
steps:
@@ -27,38 +30,77 @@ jobs:
2730
with:
2831
node-version: ${{ matrix.node_version }}
2932
cache: yarn
30-
- run: yarn install
33+
- uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main
3134
- run: yarn build
32-
- run: yarn test
33-
e2e:
35+
- if: runner.os == 'Windows'
36+
run: yarn mocha --forbid-only "test/**/*.e2e.ts" --exclude "test/integration/sf.e2e.ts" --parallel --timeout 1200000
37+
- if: runner.os == 'Linux'
38+
run: yarn test:e2e
39+
windows-sf-e2e:
40+
# For whatever reason the windows-latest runner doesn't like it when you shell yarn commands in the sf repo
41+
# which is an integral part of the setup for the tests. Instead, we replicate the setup here.
42+
needs: linux-unit-tests
43+
strategy:
44+
fail-fast: false
45+
runs-on: windows-latest
46+
steps:
47+
- uses: actions/checkout@v3
48+
- uses: actions/setup-node@v3
49+
with:
50+
node-version: latest
51+
cache: yarn
52+
- uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main
53+
- run: yarn build
54+
- run: yarn link
55+
- run: New-Item -Path D:\a -Name "e2e" -ItemType "directory"
56+
- run: New-Item -Path D:\a\e2e -Name "sf.e2e.ts" -ItemType "directory"
57+
- run: |
58+
git clone https://github.com/salesforcecli/cli.git --branch mdonnalley/esm
59+
cd cli
60+
61+
$Json = Get-Content package.json | ConvertFrom-Json
62+
$Json.dependencies | Add-Member -Force -MemberType NoteProperty -Name "@oclif/core" -Value "file:D:\a\core\core"
63+
$Json.resolutions | Add-Member -MemberType NoteProperty -Name "@oclif/core" -Value "D:\a\core\core"
64+
$Json | ConvertTo-Json -Depth 9 | Out-File package.json
65+
66+
yarn install --network-timeout 600000
67+
yarn link @oclif/core
68+
yarn build
69+
working-directory: D:\a\e2e\sf.e2e.ts
70+
- run: yarn mocha --forbid-only "test/integration/sf.e2e.ts" --parallel --timeout 1200000
71+
env:
72+
OCLIF_CORE_E2E_SKIP_SETUP: true
73+
OCLIF_CORE_E2E_TEST_DIR: D:\a\e2e
74+
DEBUG: e2e:*
75+
esm-cjs-interop:
3476
needs: linux-unit-tests
3577
strategy:
3678
matrix:
37-
os: ["ubuntu-latest", "windows-latest"]
38-
node_version: [lts/-1, lts/*, latest]
79+
os: [ubuntu-latest, windows-latest]
80+
node_version: [lts/*, latest]
81+
test: [esm, cjs, precore, coreV1, coreV2]
3982
exclude:
4083
- os: windows-latest
4184
node_version: lts/*
42-
- os: windows-latest
43-
node_version: lts/-1
4485
fail-fast: false
4586
runs-on: ${{ matrix.os }}
87+
timeout-minutes: 75
4688
steps:
4789
- uses: actions/checkout@v3
4890
- uses: actions/setup-node@v3
4991
with:
5092
node-version: ${{ matrix.node_version }}
5193
cache: yarn
52-
- run: yarn install --network-timeout 600000
94+
- uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main
5395
- run: yarn build
54-
- run: yarn test:e2e
96+
- run: yarn test:esm-cjs --test=${{ matrix.test }}
5597
nuts:
5698
needs: linux-unit-tests
5799
uses: salesforcecli/github-workflows/.github/workflows/externalNut.yml@main
58100
strategy:
59101
fail-fast: false
60102
matrix:
61-
os: ["ubuntu-latest", "windows-latest"]
103+
os: [ubuntu-latest, windows-latest]
62104
externalProjectGitUrl:
63105
- https://github.com/salesforcecli/plugin-auth
64106
- https://github.com/salesforcecli/plugin-data
@@ -73,6 +115,7 @@ jobs:
73115
useCache: false
74116
preSwapCommands: "npx yarn-deduplicate; yarn install"
75117
preExternalBuildCommands: "shx rm -rf node_modules/@salesforce/sf-plugins-core/node_modules/@oclif/core"
118+
ignoreScripts: true
76119
secrets:
77120
TESTKIT_AUTH_URL: ${{ secrets.TESTKIT_AUTH_URL }}
78121
TESTKIT_HUB_USERNAME: ${{ secrets.TESTKIT_HUB_USERNAME }}

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn lint-staged --concurrent false

.lintstagedrc.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"*.json": ["prettier --write"],
3+
"*.md": ["prettier --write"],
4+
"+(src|test)/**/*.+(ts|js)": ["eslint --fix", "prettier --write"]
5+
}

.mocharc.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"reporter": "spec",
44
"require": [
55
"test/helpers/init.js",
6-
"ts-node/register",
7-
"source-map-support/register"
6+
"ts-node/register"
87
],
98
"timeout": 60000,
109
"watch-extensions": [

.nycrc.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"check-coverage": true,
3+
"lines": 80,
4+
"statements": 70,
5+
"functions": 70,
6+
"branches": 60,
7+
"reporter": ["lcov", "text"],
8+
"extension": [".ts"],
9+
"include": ["**/*.ts"],
10+
"exclude": ["**/*.d.ts", "test/**"]
11+
}

.prettierrc.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"@oclif/prettier-config"

README.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ base library for oclif CLIs
1111
Migrating
1212
=====
1313

14-
See the [migration guide](./MIGRATION.md) for an overview of breaking changes that occurred between v1 and v2.
14+
See the [v3 migration guide](./guides/V3_MIGRATION.md) for an overview of breaking changes that occurred between v2 and v3.
15+
16+
See the [v2 migration guide](./guides/V2_MIGRATION.md) for an overview of breaking changes that occurred between v1 and v2.
17+
18+
Migrating from `@oclif/config` and `@oclif/command`? See the [v1 migration guide](./guides/PRE_CORE_MIGRATION.md).
1519

1620
CLI UX
1721
=====
@@ -28,7 +32,7 @@ You can, however, use `@oclif/core` in a standalone script like this:
2832
#!/usr/bin/env ts-node
2933

3034
import * as fs from 'fs'
31-
import {Command, Flags} from '@oclif/core'
35+
import {Command, Flags, flush, handle} from '@oclif/core'
3236

3337
class LS extends Command {
3438
static description = 'List the files in a directory.'
@@ -50,10 +54,10 @@ class LS extends Command {
5054
}
5155
}
5256

53-
LS.run().then(() => {
54-
require('@oclif/core/flush')
55-
}, () => {
56-
require('@oclif/core/handle')
57+
LS.run().then(async () => {
58+
await flush()
59+
}, async (err) => {
60+
await handle(err)
5761
})
5862
```
5963

commitlint.config.js

-1
This file was deleted.

flush.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require('./lib').flush
1+
module.exports = require('./lib/cli-ux/flush').flush

0 commit comments

Comments
 (0)