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

chore: add automatic font generation and fix VSCode settings #893

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Place your settings in this file to overwrite default and user settings.
{
"editor.formatOnSave": false,
Copy link
Contributor Author

@gagik gagik Dec 2, 2024

Choose a reason for hiding this comment

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

This is unrelated but could we remove this? I am not sure I see value in this. format on save override that is stated below never works for me so I always end up removing it while working on the project and it all seems fine.

"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
Expand Down
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,7 @@
"@types/mkdirp": "^2.0.0",
"@types/mocha": "^8.2.3",
"@types/node": "^14.18.63",
"@types/prettier": "^2.7.3",
"@types/react": "^17.0.83",
"@types/react-dom": "^17.0.25",
"@types/sinon": "^9.0.11",
Expand Down
22 changes: 14 additions & 8 deletions scripts/generate-icon-font.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import webfont from 'webfont';
import fs from 'fs/promises';
import { GlyphData } from 'webfont/dist/src/types';
import prettier from 'prettier';

/** Icons to include in the generated icon font */
const INCLUDED_ICONS = ['connection-active', 'connection-inactive'];
Expand Down Expand Up @@ -40,14 +41,19 @@ async function main(): Promise<void> {
});

// Prints out the VSCode configuration package.json
console.info(
JSON.stringify(
{
icons: iconsConfig,
},
undefined,
2
)
const currentConfiguration = JSON.parse(
await fs.readFile('./package.json', 'utf8')
);

currentConfiguration.contributes.icons = iconsConfig;

const prettierConfig = await prettier.resolveConfig('./.prettierrc.json');
await fs.writeFile(
'./package.json',
prettier.format(JSON.stringify(currentConfiguration), {
...prettierConfig,
parser: 'json-stringify',
Copy link
Contributor

Choose a reason for hiding this comment

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

Which exactly rules are applied here? I am wondering what is there on top of JSON.stringify(..., null, 2).

Copy link
Contributor Author

@gagik gagik Dec 3, 2024

Choose a reason for hiding this comment

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

I am pretty sure the only config being passed to prettier ends up being singleQuote: true and this gets ignored for JSON, the rest (i.e. space size 2) I assume are the prettier defaults so yeah it'd be the same as this.

So it ends up tied to our prettier config (and we have nearly nothing there so... this should be default prettier) so it just stays consistent with any style rules for our prettier formatter. This way if someone autoformats the file using VSCode there won't be inconsistencies.

})
);
}

Expand Down
Loading