diff --git a/build-tests/sparo-completion-test/.eslintrc.js b/build-tests/sparo-completion-test/.eslintrc.js new file mode 100644 index 0000000..612bb5d --- /dev/null +++ b/build-tests/sparo-completion-test/.eslintrc.js @@ -0,0 +1,19 @@ +// This is a workaround for https://github.com/eslint/eslint/issues/3458 +require('@rushstack/heft-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution'); +// This is a workaround for https://github.com/microsoft/rushstack/issues/3021 +require('@rushstack/heft-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names'); + +module.exports = { + extends: [ + '@rushstack/heft-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool', + '@rushstack/heft-node-rig/profiles/default/includes/eslint/mixins/friendly-locals' + ], + parserOptions: { tsconfigRootDir: __dirname }, + + overrides: [ + { + files: ['*.ts', '*.tsx'], + rules: {} + } + ] +}; diff --git a/build-tests/sparo-completion-test/LICENSE b/build-tests/sparo-completion-test/LICENSE new file mode 100644 index 0000000..3bd1dad --- /dev/null +++ b/build-tests/sparo-completion-test/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) TikTok Pte. Ltd. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/build-tests/sparo-completion-test/README.md b/build-tests/sparo-completion-test/README.md new file mode 100644 index 0000000..426181d --- /dev/null +++ b/build-tests/sparo-completion-test/README.md @@ -0,0 +1,11 @@ +# sparo-completion-test + +Building this project tests sparo command completion outputs + +# Details + +`lib/start-test.js` is run after building the project. This scripts generate the output text files under `temp/etc`. In local builds, those files are copied to `etc` folder. During a CI build, the files under these two folders are compared and the CI build fails if they are different. This ensures that files under `etc` folder must be up to date in the PR, and people who review the PR must approve any changes. + +# How to fix the build errors + +Run `rush build -t sparo-completion-test` to regenerate files under `etc` folder and commit them into Git. \ No newline at end of file diff --git a/build-tests/sparo-completion-test/__fixture__/dir-a/file-under-a.txt b/build-tests/sparo-completion-test/__fixture__/dir-a/file-under-a.txt new file mode 100644 index 0000000..e69de29 diff --git a/build-tests/sparo-completion-test/__fixture__/file.txt b/build-tests/sparo-completion-test/__fixture__/file.txt new file mode 100644 index 0000000..e69de29 diff --git a/build-tests/sparo-completion-test/config/heft.json b/build-tests/sparo-completion-test/config/heft.json new file mode 100644 index 0000000..acf3ab4 --- /dev/null +++ b/build-tests/sparo-completion-test/config/heft.json @@ -0,0 +1,24 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/heft/v0/heft.schema.json", + + "extends": "@rushstack/heft-node-rig/profiles/default/config/heft.json", + + "phasesByName": { + "build": { + "tasksByName": { + "post-compile": { + "taskDependencies": ["typescript"], + + "taskPlugin": { + "pluginName": "run-script-plugin", + "pluginPackage": "@rushstack/heft", + + "options": { + "scriptPath": "lib/start-test.js" + } + } + } + } + } + } +} diff --git a/build-tests/sparo-completion-test/config/rig.json b/build-tests/sparo-completion-test/config/rig.json new file mode 100644 index 0000000..58032e0 --- /dev/null +++ b/build-tests/sparo-completion-test/config/rig.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json", + + "rigPackageName": "@rushstack/heft-node-rig" +} diff --git a/build-tests/sparo-completion-test/etc/add-folder-completion.txt b/build-tests/sparo-completion-test/etc/add-folder-completion.txt new file mode 100644 index 0000000..bfdfe08 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/add-folder-completion.txt @@ -0,0 +1,3 @@ +Running "sparo --get-yargs-completions sparo add __fixture__/": +__fixture__/dir-a/ +__fixture__/file.txt diff --git a/build-tests/sparo-completion-test/etc/add-folder-partial-completion.txt b/build-tests/sparo-completion-test/etc/add-folder-partial-completion.txt new file mode 100644 index 0000000..1d6e843 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/add-folder-partial-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo add __fixture__/dir-a/file": +__fixture__/dir-a/file-under-a.txt diff --git a/build-tests/sparo-completion-test/etc/add-partial-completion.txt b/build-tests/sparo-completion-test/etc/add-partial-completion.txt new file mode 100644 index 0000000..ca00a5a --- /dev/null +++ b/build-tests/sparo-completion-test/etc/add-partial-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo add __fixture__": +__fixture__/ diff --git a/build-tests/sparo-completion-test/etc/auto-config-completion.txt b/build-tests/sparo-completion-test/etc/auto-config-completion.txt new file mode 100644 index 0000000..e6ba841 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/auto-config-completion.txt @@ -0,0 +1 @@ +Running "sparo --get-yargs-completions sparo auto-config": diff --git a/build-tests/sparo-completion-test/etc/auto-config-long-parameters-completion.txt b/build-tests/sparo-completion-test/etc/auto-config-long-parameters-completion.txt new file mode 100644 index 0000000..3a7ad9d --- /dev/null +++ b/build-tests/sparo-completion-test/etc/auto-config-long-parameters-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo auto-config --": +--overwrite diff --git a/build-tests/sparo-completion-test/etc/checkout-add-profile-completion.txt b/build-tests/sparo-completion-test/etc/checkout-add-profile-completion.txt new file mode 100644 index 0000000..9fb2e9a --- /dev/null +++ b/build-tests/sparo-completion-test/etc/checkout-add-profile-completion.txt @@ -0,0 +1,4 @@ +Running "sparo --get-yargs-completions sparo checkout --add-profile": +my-team +sparo-development +sparo-website diff --git a/build-tests/sparo-completion-test/etc/checkout-add-profile-spa-completion.txt b/build-tests/sparo-completion-test/etc/checkout-add-profile-spa-completion.txt new file mode 100644 index 0000000..f225231 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/checkout-add-profile-spa-completion.txt @@ -0,0 +1,3 @@ +Running "sparo --get-yargs-completions sparo checkout --add-profile spa": +sparo-development +sparo-website diff --git a/build-tests/sparo-completion-test/etc/checkout-completion.txt b/build-tests/sparo-completion-test/etc/checkout-completion.txt new file mode 100644 index 0000000..650777e --- /dev/null +++ b/build-tests/sparo-completion-test/etc/checkout-completion.txt @@ -0,0 +1 @@ +Running "sparo --get-yargs-completions sparo checkout": diff --git a/build-tests/sparo-completion-test/etc/checkout-from-web-completion.txt b/build-tests/sparo-completion-test/etc/checkout-from-web-completion.txt new file mode 100644 index 0000000..08007df --- /dev/null +++ b/build-tests/sparo-completion-test/etc/checkout-from-web-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo checkout --from web": +website diff --git a/build-tests/sparo-completion-test/etc/checkout-long-parameters-completion.txt b/build-tests/sparo-completion-test/etc/checkout-long-parameters-completion.txt new file mode 100644 index 0000000..e073da4 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/checkout-long-parameters-completion.txt @@ -0,0 +1,6 @@ +Running "sparo --get-yargs-completions sparo checkout --": +--no-profile +--profile +--add-profile +--to +--from diff --git a/build-tests/sparo-completion-test/etc/checkout-no-profile-completion.txt b/build-tests/sparo-completion-test/etc/checkout-no-profile-completion.txt new file mode 100644 index 0000000..0c15ffa --- /dev/null +++ b/build-tests/sparo-completion-test/etc/checkout-no-profile-completion.txt @@ -0,0 +1,3 @@ +Running "sparo --get-yargs-completions sparo checkout --no-profile --": +--to +--from diff --git a/build-tests/sparo-completion-test/etc/checkout-pro-completion.txt b/build-tests/sparo-completion-test/etc/checkout-pro-completion.txt new file mode 100644 index 0000000..8ebe1e0 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/checkout-pro-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo checkout --pro": +--profile diff --git a/build-tests/sparo-completion-test/etc/checkout-profile-completion.txt b/build-tests/sparo-completion-test/etc/checkout-profile-completion.txt new file mode 100644 index 0000000..11738fb --- /dev/null +++ b/build-tests/sparo-completion-test/etc/checkout-profile-completion.txt @@ -0,0 +1,4 @@ +Running "sparo --get-yargs-completions sparo checkout --profile": +my-team +sparo-development +sparo-website diff --git a/build-tests/sparo-completion-test/etc/checkout-profile-spa-completion.txt b/build-tests/sparo-completion-test/etc/checkout-profile-spa-completion.txt new file mode 100644 index 0000000..43a6b1d --- /dev/null +++ b/build-tests/sparo-completion-test/etc/checkout-profile-spa-completion.txt @@ -0,0 +1,3 @@ +Running "sparo --get-yargs-completions sparo checkout --profile spa": +sparo-development +sparo-website diff --git a/build-tests/sparo-completion-test/etc/checkout-second-add-profile-completion.txt b/build-tests/sparo-completion-test/etc/checkout-second-add-profile-completion.txt new file mode 100644 index 0000000..2722ca0 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/checkout-second-add-profile-completion.txt @@ -0,0 +1,3 @@ +Running "sparo --get-yargs-completions sparo checkout --add-profile sparo-website --add-profile": +my-team +sparo-development diff --git a/build-tests/sparo-completion-test/etc/checkout-second-profile-completion.txt b/build-tests/sparo-completion-test/etc/checkout-second-profile-completion.txt new file mode 100644 index 0000000..e3384ee --- /dev/null +++ b/build-tests/sparo-completion-test/etc/checkout-second-profile-completion.txt @@ -0,0 +1,3 @@ +Running "sparo --get-yargs-completions sparo checkout --profile sparo-website --profile": +my-team +sparo-development diff --git a/build-tests/sparo-completion-test/etc/checkout-to-web-completion.txt b/build-tests/sparo-completion-test/etc/checkout-to-web-completion.txt new file mode 100644 index 0000000..de7ab19 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/checkout-to-web-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo checkout --to web": +website diff --git a/build-tests/sparo-completion-test/etc/clone-completion.txt b/build-tests/sparo-completion-test/etc/clone-completion.txt new file mode 100644 index 0000000..0fcfda3 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/clone-completion.txt @@ -0,0 +1 @@ +Running "sparo --get-yargs-completions sparo clone": diff --git a/build-tests/sparo-completion-test/etc/clone-long-parameters-completion.txt b/build-tests/sparo-completion-test/etc/clone-long-parameters-completion.txt new file mode 100644 index 0000000..b3460c1 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/clone-long-parameters-completion.txt @@ -0,0 +1,5 @@ +Running "sparo --get-yargs-completions sparo clone --": +--profile +--branch +--full +--skip-git-config diff --git a/build-tests/sparo-completion-test/etc/clone-pro-completion.txt b/build-tests/sparo-completion-test/etc/clone-pro-completion.txt new file mode 100644 index 0000000..bcbe27d --- /dev/null +++ b/build-tests/sparo-completion-test/etc/clone-pro-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo clone --pro": +--profile diff --git a/build-tests/sparo-completion-test/etc/clone-profile-completion.txt b/build-tests/sparo-completion-test/etc/clone-profile-completion.txt new file mode 100644 index 0000000..b81bf0c --- /dev/null +++ b/build-tests/sparo-completion-test/etc/clone-profile-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo clone --profile": +--profile diff --git a/build-tests/sparo-completion-test/etc/fetch-al-completion.txt b/build-tests/sparo-completion-test/etc/fetch-al-completion.txt new file mode 100644 index 0000000..457c626 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/fetch-al-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo fetch --al": +--all diff --git a/build-tests/sparo-completion-test/etc/fetch-completion.txt b/build-tests/sparo-completion-test/etc/fetch-completion.txt new file mode 100644 index 0000000..ddac3b2 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/fetch-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo fetch": +origin diff --git a/build-tests/sparo-completion-test/etc/fetch-long-parameters-completion.txt b/build-tests/sparo-completion-test/etc/fetch-long-parameters-completion.txt new file mode 100644 index 0000000..960c6be --- /dev/null +++ b/build-tests/sparo-completion-test/etc/fetch-long-parameters-completion.txt @@ -0,0 +1,3 @@ +Running "sparo --get-yargs-completions sparo fetch --": +--all +--tags diff --git a/build-tests/sparo-completion-test/etc/fetch-long-parameters-with-all-completion.txt b/build-tests/sparo-completion-test/etc/fetch-long-parameters-with-all-completion.txt new file mode 100644 index 0000000..11a3796 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/fetch-long-parameters-with-all-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo fetch --all --": +--tags diff --git a/build-tests/sparo-completion-test/etc/fetch-long-parameters-with-tags-completion.txt b/build-tests/sparo-completion-test/etc/fetch-long-parameters-with-tags-completion.txt new file mode 100644 index 0000000..53e6392 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/fetch-long-parameters-with-tags-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo fetch --tags --": +--all diff --git a/build-tests/sparo-completion-test/etc/fetch-origin-HEA-completion.txt b/build-tests/sparo-completion-test/etc/fetch-origin-HEA-completion.txt new file mode 100644 index 0000000..6ecd24f --- /dev/null +++ b/build-tests/sparo-completion-test/etc/fetch-origin-HEA-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo fetch origin HEA": +HEAD diff --git a/build-tests/sparo-completion-test/etc/init-profile-completion.txt b/build-tests/sparo-completion-test/etc/init-profile-completion.txt new file mode 100644 index 0000000..ad047a8 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/init-profile-completion.txt @@ -0,0 +1 @@ +Running "sparo --get-yargs-completions sparo init-profile": diff --git a/build-tests/sparo-completion-test/etc/init-profile-long-parameters-completion.txt b/build-tests/sparo-completion-test/etc/init-profile-long-parameters-completion.txt new file mode 100644 index 0000000..9d797b8 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/init-profile-long-parameters-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo init-profile --": +--profile diff --git a/build-tests/sparo-completion-test/etc/init-profile-pro-completion.txt b/build-tests/sparo-completion-test/etc/init-profile-pro-completion.txt new file mode 100644 index 0000000..1b373c5 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/init-profile-pro-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo init-profile --pro": +--profile diff --git a/build-tests/sparo-completion-test/etc/list-profiles-completion.txt b/build-tests/sparo-completion-test/etc/list-profiles-completion.txt new file mode 100644 index 0000000..4fc2b72 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/list-profiles-completion.txt @@ -0,0 +1 @@ +Running "sparo --get-yargs-completions sparo list-profiles": diff --git a/build-tests/sparo-completion-test/etc/list-profiles-long-parameters-completion.txt b/build-tests/sparo-completion-test/etc/list-profiles-long-parameters-completion.txt new file mode 100644 index 0000000..edcabb2 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/list-profiles-long-parameters-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo list-profiles --": +--project diff --git a/build-tests/sparo-completion-test/etc/list-profiles-pro-completion.txt b/build-tests/sparo-completion-test/etc/list-profiles-pro-completion.txt new file mode 100644 index 0000000..2219093 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/list-profiles-pro-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo list-profiles --pro": +--project diff --git a/build-tests/sparo-completion-test/etc/list-profiles-project-web-completion.txt b/build-tests/sparo-completion-test/etc/list-profiles-project-web-completion.txt new file mode 100644 index 0000000..104e556 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/list-profiles-project-web-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo list-profiles --project web": +website diff --git a/build-tests/sparo-completion-test/etc/pull-completion.txt b/build-tests/sparo-completion-test/etc/pull-completion.txt new file mode 100644 index 0000000..fa98902 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/pull-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo pull": +origin diff --git a/build-tests/sparo-completion-test/etc/pull-long-parameters-completion.txt b/build-tests/sparo-completion-test/etc/pull-long-parameters-completion.txt new file mode 100644 index 0000000..2af3c14 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/pull-long-parameters-completion.txt @@ -0,0 +1,3 @@ +Running "sparo --get-yargs-completions sparo pull --": +--profile +--no-profile diff --git a/build-tests/sparo-completion-test/etc/pull-no-profile-completion.txt b/build-tests/sparo-completion-test/etc/pull-no-profile-completion.txt new file mode 100644 index 0000000..be74b25 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/pull-no-profile-completion.txt @@ -0,0 +1 @@ +Running "sparo --get-yargs-completions sparo pull --no-profile --": diff --git a/build-tests/sparo-completion-test/etc/pull-pro-completion.txt b/build-tests/sparo-completion-test/etc/pull-pro-completion.txt new file mode 100644 index 0000000..99c50a1 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/pull-pro-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo pull --pro": +--profile diff --git a/build-tests/sparo-completion-test/etc/pull-profile-completion.txt b/build-tests/sparo-completion-test/etc/pull-profile-completion.txt new file mode 100644 index 0000000..14c9b71 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/pull-profile-completion.txt @@ -0,0 +1,4 @@ +Running "sparo --get-yargs-completions sparo pull --profile": +my-team +sparo-development +sparo-website diff --git a/build-tests/sparo-completion-test/etc/pull-profile-spa-completion.txt b/build-tests/sparo-completion-test/etc/pull-profile-spa-completion.txt new file mode 100644 index 0000000..7bfe4ae --- /dev/null +++ b/build-tests/sparo-completion-test/etc/pull-profile-spa-completion.txt @@ -0,0 +1,3 @@ +Running "sparo --get-yargs-completions sparo pull --profile spa": +sparo-development +sparo-website diff --git a/build-tests/sparo-completion-test/etc/pull-second-profile-completion.txt b/build-tests/sparo-completion-test/etc/pull-second-profile-completion.txt new file mode 100644 index 0000000..61e20b9 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/pull-second-profile-completion.txt @@ -0,0 +1,3 @@ +Running "sparo --get-yargs-completions sparo pull --profile sparo-website --profile": +my-team +sparo-development diff --git a/build-tests/sparo-completion-test/etc/rebase-long-parameters-completion.txt b/build-tests/sparo-completion-test/etc/rebase-long-parameters-completion.txt new file mode 100644 index 0000000..d8c00cc --- /dev/null +++ b/build-tests/sparo-completion-test/etc/rebase-long-parameters-completion.txt @@ -0,0 +1,5 @@ +Running "sparo --get-yargs-completions sparo rebase --": +--continue +--skip +--abort +--interactive diff --git a/build-tests/sparo-completion-test/etc/rebase-long-with-abort-completion.txt b/build-tests/sparo-completion-test/etc/rebase-long-with-abort-completion.txt new file mode 100644 index 0000000..c1492a1 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/rebase-long-with-abort-completion.txt @@ -0,0 +1,4 @@ +Running "sparo --get-yargs-completions sparo rebase --abort --": +--continue +--skip +--interactive diff --git a/build-tests/sparo-completion-test/etc/rebase-long-with-continue-completion.txt b/build-tests/sparo-completion-test/etc/rebase-long-with-continue-completion.txt new file mode 100644 index 0000000..3dd124b --- /dev/null +++ b/build-tests/sparo-completion-test/etc/rebase-long-with-continue-completion.txt @@ -0,0 +1,4 @@ +Running "sparo --get-yargs-completions sparo rebase --continue --": +--skip +--abort +--interactive diff --git a/build-tests/sparo-completion-test/etc/rebase-long-with-i-completion.txt b/build-tests/sparo-completion-test/etc/rebase-long-with-i-completion.txt new file mode 100644 index 0000000..552aa51 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/rebase-long-with-i-completion.txt @@ -0,0 +1,4 @@ +Running "sparo --get-yargs-completions sparo rebase -i --": +--continue +--skip +--abort diff --git a/build-tests/sparo-completion-test/etc/rebase-long-with-interactive-completion.txt b/build-tests/sparo-completion-test/etc/rebase-long-with-interactive-completion.txt new file mode 100644 index 0000000..8046eae --- /dev/null +++ b/build-tests/sparo-completion-test/etc/rebase-long-with-interactive-completion.txt @@ -0,0 +1,4 @@ +Running "sparo --get-yargs-completions sparo rebase --interactive --": +--continue +--skip +--abort diff --git a/build-tests/sparo-completion-test/etc/rebase-long-with-skip-completion.txt b/build-tests/sparo-completion-test/etc/rebase-long-with-skip-completion.txt new file mode 100644 index 0000000..9e2c348 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/rebase-long-with-skip-completion.txt @@ -0,0 +1,4 @@ +Running "sparo --get-yargs-completions sparo rebase --skip --": +--continue +--abort +--interactive diff --git a/build-tests/sparo-completion-test/etc/rebase-short-parameters-completion.txt b/build-tests/sparo-completion-test/etc/rebase-short-parameters-completion.txt new file mode 100644 index 0000000..4960b81 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/rebase-short-parameters-completion.txt @@ -0,0 +1,2 @@ +Running "sparo --get-yargs-completions sparo rebase -": +-i diff --git a/build-tests/sparo-completion-test/etc/rebase-short-with-i-completion.txt b/build-tests/sparo-completion-test/etc/rebase-short-with-i-completion.txt new file mode 100644 index 0000000..8e06b70 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/rebase-short-with-i-completion.txt @@ -0,0 +1 @@ +Running "sparo --get-yargs-completions sparo rebase -i -": diff --git a/build-tests/sparo-completion-test/etc/rebase-short-with-interactive-completion.txt b/build-tests/sparo-completion-test/etc/rebase-short-with-interactive-completion.txt new file mode 100644 index 0000000..8bdc3b5 --- /dev/null +++ b/build-tests/sparo-completion-test/etc/rebase-short-with-interactive-completion.txt @@ -0,0 +1 @@ +Running "sparo --get-yargs-completions sparo rebase --interactive -": diff --git a/build-tests/sparo-completion-test/etc/sparo-top-level-completion.txt b/build-tests/sparo-completion-test/etc/sparo-top-level-completion.txt new file mode 100644 index 0000000..d48b1ad --- /dev/null +++ b/build-tests/sparo-completion-test/etc/sparo-top-level-completion.txt @@ -0,0 +1,23 @@ +Running "sparo --get-yargs-completions sparo": +auto-config:Automatic setup optimized git config +list-profiles:List all available profiles or query profiles that contain the specified project name +init-profile:Initialize a new profile. +clone:Clone a repository into a new directory +checkout:Updates files in the working tree to match the version in the index or the specified tree. If no pathspec was given, git checkout will also update HEAD to set the specified branch as the current branch. +fetch:fetch remote branch to local +pull:Incorporates changes from a remote repository into the current branch. +git-clone:original git clone command +git-checkout:original git checkout command +git-fetch:original git fetch command +git-pull:original git pull command +add:add file contents to the index +branch:list, create, or delete branches +commit:record changes to the repository +diff:show changes between commits, commit and working tree, etc +log:show commit logs +merge:join two or more development histories together +push:update remote refs along with associated objects +rebase:forward-port local commits to the updated upstream head +reset:reset current HEAD to the specified state +restore:restore working tree files +status:show the working tree status diff --git a/build-tests/sparo-completion-test/package.json b/build-tests/sparo-completion-test/package.json new file mode 100644 index 0000000..eb2d3ee --- /dev/null +++ b/build-tests/sparo-completion-test/package.json @@ -0,0 +1,24 @@ +{ + "name": "sparo-completion-test", + "description": "Building this project tests Sparo command-line outputs", + "version": "1.0.0", + "private": true, + "scripts": { + "_phase:build": "heft run --only build -- --clean", + "build": "heft build --clean" + }, + "dependencies": { + "@rushstack/node-core-library": "~3.64.2", + "build-test-utilities": "workspace:*" + }, + "devDependencies": { + "@rushstack/heft": "0.64.3", + "@rushstack/heft-node-rig": "2.4.5", + "@types/heft-jest": "1.0.6", + "@types/node": "20.11.16", + "eslint": "8.56.0", + "typescript": "~5.3.3" + }, + "keywords": [], + "license": "MIT" +} diff --git a/build-tests/sparo-completion-test/src/start-test.ts b/build-tests/sparo-completion-test/src/start-test.ts new file mode 100644 index 0000000..58803d6 --- /dev/null +++ b/build-tests/sparo-completion-test/src/start-test.ts @@ -0,0 +1,311 @@ +import { + ICommandDefinition, + executeCommandsAndCollectOutputs, + updateOrCompareOutputs +} from 'build-test-utilities'; +import type { IRunScriptOptions } from '@rushstack/heft'; + +/** + * This build test is highly inspired by the build test for api-extractor in rushstack. + */ +export async function runAsync(runScriptOptions: IRunScriptOptions): Promise { + const { + heftTaskSession: { + logger, + parameters: { production } + }, + heftConfiguration: { buildFolderPath } + } = runScriptOptions; + + const prefixArgs: string[] = ['--get-yargs-completions', 'sparo']; + + const commandDefinitions: ICommandDefinition[] = [ + { + kind: 'sparo-command', + name: 'sparo-top-level-completion', + args: prefixArgs.concat([]) + }, + // auto-config + { + kind: 'sparo-command', + name: 'auto-config-completion', + args: prefixArgs.concat(['auto-config']) + }, + { + kind: 'sparo-command', + name: 'auto-config-long-parameters-completion', + args: prefixArgs.concat(['auto-config', '--']) + }, + // list-profiles + { + kind: 'sparo-command', + name: 'list-profiles-completion', + args: prefixArgs.concat(['list-profiles']) + }, + { + kind: 'sparo-command', + name: 'list-profiles-long-parameters-completion', + args: prefixArgs.concat(['list-profiles', '--']) + }, + { + kind: 'sparo-command', + name: 'list-profiles-pro-completion', + args: prefixArgs.concat(['list-profiles', '--pro']) + }, + { + kind: 'sparo-command', + name: 'list-profiles-project-web-completion', + args: prefixArgs.concat(['list-profiles', '--project', 'web']) + }, + // init-profile + { + kind: 'sparo-command', + name: 'init-profile-completion', + args: prefixArgs.concat(['init-profile']) + }, + { + kind: 'sparo-command', + name: 'init-profile-long-parameters-completion', + args: prefixArgs.concat(['init-profile', '--']) + }, + { + kind: 'sparo-command', + name: 'init-profile-pro-completion', + args: prefixArgs.concat(['init-profile', '--pro']) + }, + // clone + { + kind: 'sparo-command', + name: 'clone-completion', + args: prefixArgs.concat(['clone']) + }, + { + kind: 'sparo-command', + name: 'clone-long-parameters-completion', + args: prefixArgs.concat(['clone', '--']) + }, + { + kind: 'sparo-command', + name: 'clone-long-parameters-completion', + args: prefixArgs.concat(['clone', '--']) + }, + { + kind: 'sparo-command', + name: 'clone-pro-completion', + args: prefixArgs.concat(['clone', '--pro']) + }, + { + kind: 'sparo-command', + name: 'clone-profile-completion', + args: prefixArgs.concat(['clone', '--profile']) + }, + // checkout + { + kind: 'sparo-command', + name: 'checkout-completion', + args: prefixArgs.concat(['checkout']) + }, + { + kind: 'sparo-command', + name: 'checkout-long-parameters-completion', + args: prefixArgs.concat(['checkout', '--']) + }, + { + kind: 'sparo-command', + name: 'checkout-pro-completion', + args: prefixArgs.concat(['checkout', '--pro']) + }, + { + kind: 'sparo-command', + name: 'checkout-profile-completion', + args: prefixArgs.concat(['checkout', '--profile']) + }, + { + kind: 'sparo-command', + name: 'checkout-profile-spa-completion', + args: prefixArgs.concat(['checkout', '--profile', 'spa']) + }, + { + kind: 'sparo-command', + name: 'checkout-second-profile-completion', + args: prefixArgs.concat(['checkout', '--profile', 'sparo-website', '--profile']) + }, + { + kind: 'sparo-command', + name: 'checkout-add-profile-completion', + args: prefixArgs.concat(['checkout', '--add-profile']) + }, + { + kind: 'sparo-command', + name: 'checkout-add-profile-spa-completion', + args: prefixArgs.concat(['checkout', '--add-profile', 'spa']) + }, + { + kind: 'sparo-command', + name: 'checkout-second-add-profile-completion', + args: prefixArgs.concat(['checkout', '--add-profile', 'sparo-website', '--add-profile']) + }, + { + kind: 'sparo-command', + name: 'checkout-no-profile-completion', + args: prefixArgs.concat(['checkout', '--no-profile', '--']) + }, + { + kind: 'sparo-command', + name: 'checkout-to-web-completion', + args: prefixArgs.concat(['checkout', '--to', 'web']) + }, + { + kind: 'sparo-command', + name: 'checkout-from-web-completion', + args: prefixArgs.concat(['checkout', '--from', 'web']) + }, + // fetch + { + kind: 'sparo-command', + name: 'fetch-completion', + args: prefixArgs.concat(['fetch']) + }, + { + kind: 'sparo-command', + name: 'fetch-long-parameters-completion', + args: prefixArgs.concat(['fetch', '--']) + }, + { + kind: 'sparo-command', + name: 'fetch-long-parameters-with-all-completion', + args: prefixArgs.concat(['fetch', '--all', '--']) + }, + { + kind: 'sparo-command', + name: 'fetch-long-parameters-with-tags-completion', + args: prefixArgs.concat(['fetch', '--tags', '--']) + }, + { + kind: 'sparo-command', + name: 'fetch-al-completion', + args: prefixArgs.concat(['fetch', '--al']) + }, + { + kind: 'sparo-command', + name: 'fetch-origin-HEA-completion', + args: prefixArgs.concat(['fetch', 'origin', 'HEA']) + }, + // pull + { + kind: 'sparo-command', + name: 'pull-completion', + args: prefixArgs.concat(['pull']) + }, + { + kind: 'sparo-command', + name: 'pull-long-parameters-completion', + args: prefixArgs.concat(['pull', '--']) + }, + { + kind: 'sparo-command', + name: 'pull-pro-completion', + args: prefixArgs.concat(['pull', '--pro']) + }, + { + kind: 'sparo-command', + name: 'pull-profile-completion', + args: prefixArgs.concat(['pull', '--profile']) + }, + { + kind: 'sparo-command', + name: 'pull-profile-spa-completion', + args: prefixArgs.concat(['pull', '--profile', 'spa']) + }, + { + kind: 'sparo-command', + name: 'pull-second-profile-completion', + args: prefixArgs.concat(['pull', '--profile', 'sparo-website', '--profile']) + }, + { + kind: 'sparo-command', + name: 'pull-no-profile-completion', + args: prefixArgs.concat(['pull', '--no-profile', '--']) + }, + // add + { + kind: 'sparo-command', + name: 'add-partial-completion', + args: prefixArgs.concat(['add', '__fixture__']) + }, + { + kind: 'sparo-command', + name: 'add-folder-completion', + args: prefixArgs.concat(['add', '__fixture__/']) + }, + { + kind: 'sparo-command', + name: 'add-folder-partial-completion', + args: prefixArgs.concat(['add', '__fixture__/dir-a/file']) + }, + // branch + // commit + // diff + // log + // merge + // rebase + { + kind: 'sparo-command', + name: 'rebase-short-parameters-completion', + args: prefixArgs.concat(['rebase', '-']) + }, + { + kind: 'sparo-command', + name: 'rebase-short-with-i-completion', + args: prefixArgs.concat(['rebase', '-i', '-']) + }, + { + kind: 'sparo-command', + name: 'rebase-short-with-interactive-completion', + args: prefixArgs.concat(['rebase', '--interactive', '-']) + }, + { + kind: 'sparo-command', + name: 'rebase-long-parameters-completion', + args: prefixArgs.concat(['rebase', '--']) + }, + { + kind: 'sparo-command', + name: 'rebase-long-with-continue-completion', + args: prefixArgs.concat(['rebase', '--continue', '--']) + }, + { + kind: 'sparo-command', + name: 'rebase-long-with-skip-completion', + args: prefixArgs.concat(['rebase', '--skip', '--']) + }, + { + kind: 'sparo-command', + name: 'rebase-long-with-abort-completion', + args: prefixArgs.concat(['rebase', '--abort', '--']) + }, + { + kind: 'sparo-command', + name: 'rebase-long-with-interactive-completion', + args: prefixArgs.concat(['rebase', '--interactive', '--']) + }, + { + kind: 'sparo-command', + name: 'rebase-long-with-i-completion', + args: prefixArgs.concat(['rebase', '-i', '--']) + } + // restore + // status + ]; + + await executeCommandsAndCollectOutputs({ + buildFolderPath, + commandDefinitions + }); + + await updateOrCompareOutputs({ + buildFolderPath, + logger, + production + }); +} diff --git a/build-tests/sparo-completion-test/tsconfig.json b/build-tests/sparo-completion-test/tsconfig.json new file mode 100644 index 0000000..f0b86d0 --- /dev/null +++ b/build-tests/sparo-completion-test/tsconfig.json @@ -0,0 +1,8 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + + "extends": "./node_modules/@rushstack/heft-node-rig/profiles/default/tsconfig-base.json", + "compilerOptions": { + "types": ["node", "heft-jest"] + } +} diff --git a/build-tests/test-utilities/src/index.ts b/build-tests/test-utilities/src/index.ts index bc1bc8e..9813a28 100644 --- a/build-tests/test-utilities/src/index.ts +++ b/build-tests/test-utilities/src/index.ts @@ -111,6 +111,7 @@ export async function executeCommandsAndCollectOutputs({ outputPath, `Running "sparo ${args.join(' ')}":\n${processSparoOutput( stdout, + // process.cwd() -> project folder currentWorkingDirectory || process.cwd() )}` ); diff --git a/cspell.config.yaml b/cspell.config.yaml index dd90ee3..1839ad8 100644 --- a/cspell.config.yaml +++ b/cspell.config.yaml @@ -13,5 +13,6 @@ words: - rushstack - Sparo - tiktok + - yargs ignoreWords: [] import: [] diff --git a/rush.json b/rush.json index 5ecca4d..99d6131 100644 --- a/rush.json +++ b/rush.json @@ -405,6 +405,10 @@ // } // Build tests + { + "packageName": "sparo-completion-test", + "projectFolder": "build-tests/sparo-completion-test" + }, { "packageName": "sparo-output-test", "projectFolder": "build-tests/sparo-output-test"