diff --git a/.github/workflows/notify-slack-on-pr-open.yml b/.github/workflows/notify-slack-on-pr-open.yml new file mode 100644 index 00000000..13b5c9e5 --- /dev/null +++ b/.github/workflows/notify-slack-on-pr-open.yml @@ -0,0 +1,23 @@ +name: Pull Request Slack Notification + +on: + pull_request: + types: [opened, reopened] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Notify Slack on PR open + env: + WEBHOOK_URL : ${{ secrets.CLI_TEAM_SLACK_WEBHOOK_URL }} + PULL_REQUEST_AUTHOR_ICON_URL : ${{ github.event.pull_request.user.avatar_url }} + PULL_REQUEST_AUTHOR_NAME : ${{ github.event.pull_request.user.login }} + PULL_REQUEST_AUTHOR_PROFILE_URL: ${{ github.event.pull_request.user.html_url }} + PULL_REQUEST_BASE_BRANCH_NAME : ${{ github.event.pull_request.base.ref }} + PULL_REQUEST_COMPARE_BRANCH_NAME : ${{ github.event.pull_request.head.ref }} + PULL_REQUEST_NUMBER : ${{ github.event.pull_request.number }} + PULL_REQUEST_REPO: ${{ github.event.pull_request.head.repo.name }} + PULL_REQUEST_TITLE : ${{ github.event.pull_request.title }} + PULL_REQUEST_URL : ${{ github.event.pull_request.html_url }} + uses: salesforcecli/github-workflows/.github/actions/prNotification@main diff --git a/package.json b/package.json index bf0c409c..c3f40211 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@oclif/core", "description": "base library for oclif CLIs", - "version": "1.16.4", + "version": "1.16.7", "author": "Salesforce", "bugs": "https://github.com/oclif/core/issues", "dependencies": { @@ -114,4 +114,4 @@ "pretest": "yarn build --noEmit && tsc -p test --noEmit --skipLibCheck" }, "types": "lib/index.d.ts" -} +} \ No newline at end of file diff --git a/src/command.ts b/src/command.ts index 90e509db..45c0c44a 100644 --- a/src/command.ts +++ b/src/command.ts @@ -267,6 +267,7 @@ export default abstract class Command { const opts = {context: this, ...options} // the spread operator doesn't work with getters so we have to manually add it here opts.flags = options?.flags + opts.args = options?.args return Parser.parse(argv, opts) } diff --git a/src/config/config.ts b/src/config/config.ts index c85fde17..5a1c9421 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -753,6 +753,7 @@ export async function toCached(c: Command.Class, plugin?: IPlugin): Promise } + private readonly flagAliases: { [k: string]: BooleanFlag | OptionFlag } private readonly context: any @@ -52,6 +53,10 @@ export class Parser f.type === 'boolean') as any + this.flagAliases = Object.fromEntries(Object.values(input.flags).flatMap(flag => { + return (flag.aliases ?? []).map(a => [a, flag]) + })) + this.metaData = {} } @@ -64,6 +69,10 @@ export class Parser { static aliases = ['app:init', 'create'] static description = `first line + multiline help` static enableJsonFlag = true @@ -222,7 +223,7 @@ DESCRIPTION .commandHelp(class extends Command { static id = 'apps:create' - static description = 'description of apps:create\nthese values are after and will show up in the command description' + static description = 'description of apps:create\n\nthese values are after and will show up in the command description' static aliases = ['app:init', 'create'] @@ -259,7 +260,7 @@ ALIASES .commandHelp(class extends Command { static id = 'apps:create' - static description = 'root part of the description\nThe <%= config.bin %> CLI has <%= command.id %>' + static description = 'root part of the description\n\nThe <%= config.bin %> CLI has <%= command.id %>' static disableJsonFlag = true }) @@ -275,7 +276,7 @@ DESCRIPTION .commandHelp(class extends Command { static id = 'apps:create' - static description = 'root part of the description\r\nusing both carriage \nreturn and new line' + static description = 'root part of the description\r\n\nusing both carriage \n\nreturn and new line' static disableJsonFlag = true }) diff --git a/test/parser/parse.test.ts b/test/parser/parse.test.ts index 48a27b5d..1cd60587 100644 --- a/test/parser/parse.test.ts +++ b/test/parser/parse.test.ts @@ -1338,4 +1338,28 @@ See more help with --help`) }) }) }) + + describe('flag aliases', () => { + it('works with defined name', async () => { + const out = await parse(['--foo'], { + flags: { + foo: flags.boolean({ + aliases: ['bar'], + }), + }, + }) + expect(out.flags.foo).to.equal(true) + }) + + it('works with aliased name', async () => { + const out = await parse(['--bar'], { + flags: { + foo: flags.boolean({ + aliases: ['bar'], + }), + }, + }) + expect(out.flags.foo).to.equal(true) + }) + }) }) diff --git a/yarn.lock b/yarn.lock index 43a20535..2a540c50 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2460,9 +2460,9 @@ minimist-options@4.1.0: kind-of "^6.0.3" minimist@^1.2.3, minimist@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" - integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== + version "1.2.7" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.7.tgz#daa1c4d91f507390437c6a8bc01078e7000c4d18" + integrity sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g== mocha@^8.4.0: version "8.4.0"