Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add script to update VSCode config with proper excludes #110161

Merged

Conversation

spalger
Copy link
Contributor

@spalger spalger commented Aug 25, 2021

Fixes #85782

Adds a step to bootstrap which will update the .vscode/settings.json file or create it if it doesn't exist, then add the files.watcherExclude key to it or override that value if it doesn't exist. The process of updating this file uses babel to parse the file to an AST, updates the AST, and then prints it again using babel, then formats it using Prettier. This allows users to keep comments in their file as supported by VSCode and as is very useful if you want to temporarily disable some configuration but keep the values around for later use.

For now the files.watcherExclude is the only key we're setting in the config, but we might expand this to include settings for eslint, prettier, Typescript version, etc in the future.

The settings which will be written/overwritten to the file are defined in https://github.com/spalger/kibana/blob/implement/setup-vscode-workspace-settings/packages/kbn-dev-utils/src/vscode_config/managed_config_keys.ts

Users who want to manage their VSCode settings manually can do so by putting the comment // SELF MANAGED at the top of the file.

Additionally, individual settings can be proceeded with // SELF MANAGED to avoid having their values changed.

@spalger spalger added Team:Operations Team label for Operations Team v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.15.0 v7.16.0 labels Aug 25, 2021
*/
export const MANAGED_CONFIG_KEYS: ManagedConfigKey[] = [
{
key: 'files.watcherExclude',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we should list artifacts in search.exclude setting to speed up the default experience for search operations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you turn off the "Use exclude settings and ignore files" setting? Artifacts should be excluded by default because they're not tracked by git.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only ask because I've never felt like search was slow and I definitely prefer to rely on the existing ignore files if we can.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One example that may be useful here is the kbn-pm dist. That's the only one I'm running in to on first glance though, doesn't impact me much.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's checked into the code so it makes sense to me

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, in order to support managing the search.exclude property it felt like people needed to be able to add exclusions for themselves, so I've updated the logic to define management comments on each property it writes like so:

/**
 * @managed
 *
 * Some settings in this file are managed by @kbn/dev-utils. When a setting is managed it is preceeded
 * with a comment "// @managed" comment. Replace that with "// self managed" and the scripts will not
 * touch that value. Put a "// self managed" comment at the top of the file, or above a group of settings
 * to disable management of that entire section.
 */
{
  "workbench.colorTheme": "Noctis Obscuro",
  "files.watcherExclude": {
    // self managed
    "**/.eslintcache": false,
    // @managed
    "**/.es": true,
    // @managed
    "**/.yarn-local-mirror": true,
    // @managed
    "**/.chromium": true,
    // @managed
    "**/bazel-*": true,
    // @managed
    "**/node_modules": true,
    // @managed
    "**/target": true,
    // @managed
    "**/*.log": true,
    // @managed
    "**/packages/kbn-pm/dist/index.js": true
  },
  "search.exclude": {
    // @managed
    "**/packages/kbn-pm/dist/index.js": true
  }
}

Now, when the script runs it will ignore any property which doesn't have a @managed comment, and delete @managed properties which are no longer managed. Additionally, users can self manage a property by replacing the @managed comment with // self managed and then customize things further.

@spalger spalger marked this pull request as ready for review August 26, 2021 21:50
@spalger spalger requested a review from a team as a code owner August 26, 2021 21:50
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-operations (Team:Operations)

@spalger
Copy link
Contributor Author

spalger commented Aug 30, 2021

@elasticmachine merge upstream

@spalger spalger requested a review from mshustov August 30, 2021 17:44
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@spalger spalger added the auto-backport Deprecated - use backport:version if exact versions are needed label Aug 30, 2021
@spalger spalger merged commit 1500534 into elastic:master Aug 30, 2021
@spalger spalger deleted the implement/setup-vscode-workspace-settings branch August 30, 2021 23:43
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Aug 30, 2021
Co-authored-by: spalger <spalger@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Aug 30, 2021
Co-authored-by: spalger <spalger@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.15
7.x

The backport PRs will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Aug 31, 2021
…10554)

Co-authored-by: spalger <spalger@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Spencer <email@spalger.com>
Co-authored-by: spalger <spalger@users.noreply.github.com>
kibanamachine added a commit that referenced this pull request Aug 31, 2021
…10553)

Co-authored-by: spalger <spalger@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Spencer <email@spalger.com>
Co-authored-by: spalger <spalger@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes Team:Operations Team label for Operations Team v7.15.0 v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Providing VS Code and other editor settings
6 participants