Skip to content

Commit

Permalink
chore: unify prettier to 3.4.2 (#212)
Browse files Browse the repository at this point in the history
* chore: unify prettier to 3.4.2

* chore: run root-level prettier:fix

* chore: rebuild api reports in all workspaces

* add .eslintignore

* chore: call eslint fix in all workspaces

* handle no-disabled-tests rule

* chore: call yarn dedupe
  • Loading branch information
mareklibra authored Jan 13, 2025
1 parent 68cb7be commit e2f788f
Show file tree
Hide file tree
Showing 78 changed files with 590 additions and 396 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
playwright.config.ts
dist-types
coverage
2 changes: 1 addition & 1 deletion .github/workflows/automate_changeset_feedback.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ jobs:
bot-username: rhdh-gh-app[bot]
private-key: ${{ secrets.RHDH_GH_APP_PRIVATE_KEY }}
installation-id: ${{ secrets.RHDH_GH_APP_INSTALLATION_ID }}
multiple-workspaces: true
multiple-workspaces: true
2 changes: 1 addition & 1 deletion .github/workflows/automate_renovate_changesets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
git config --global user.name 'Github changeset workflow'
- name: Generate changesets
run: node ./scripts/ci/generate-bump-changesets.js
run: node ./scripts/ci/generate-bump-changesets.js
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
id: find-changed-workspaces
run: node ./scripts/ci/list-workspaces-with-changes.js
env:
COMMIT_SHA_BEFORE: "${{ github.event.before }}"
COMMIT_SHA_BEFORE: '${{ github.event.before }}'

maybe-release-workspace:
name: Maybe release ${{ matrix.workspace }}
Expand Down
20 changes: 9 additions & 11 deletions .github/workflows/release_workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@ on:
workflow_dispatch:
inputs:
workspace:
description: "Name of the Workspace"
description: 'Name of the Workspace'
required: true
type: string
force_release:
description: "Force release even if no changesets are present"
description: 'Force release even if no changesets are present'
required: false
type: boolean
branch:
description: "Branch to run the workflow on"
description: 'Branch to run the workflow on'
required: false
default: "main"
default: 'main'
type: string
workflow_call:
inputs:
force_release:
description: "Force release even if no changesets are present"
description: 'Force release even if no changesets are present'
required: false
type: boolean
workspace:
description: "Name of the Workspace"
description: 'Name of the Workspace'
required: true
type: string
branch:
description: "Branch to run the workflow on"
description: 'Branch to run the workflow on'
required: false
default: "main"
default: 'main'
type: string

concurrency:
Expand Down Expand Up @@ -102,8 +102,6 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.RHDH_BOT_TOKEN }}



release:
name: Release workspace ${{ inputs.workspace }} on branch ${{ inputs.branch }}
runs-on: ubuntu-latest
Expand Down Expand Up @@ -157,7 +155,7 @@ jobs:
yarn workspaces foreach -v --no-private npm publish --access public --tolerate-republish
env:
NODE_AUTH_TOKEN: ${{ secrets.RHDH_NPM_TOKEN }}

- name: Create tag
working-directory: ${{ github.workspace }}/scripts/ci
run: node create-tag.js
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/version-bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
- name: Run dedupe
working-directory: ./workspaces/${{ matrix.workspace }}
run: yarn dedupe
run: yarn dedupe
- name: 'Check for changes'
id: check_for_changes
run: |
Expand Down
8 changes: 8 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
dist
dist-types
coverage
.vscode
.eslintrc.js
generated
report.api.md
*.hbs
4 changes: 2 additions & 2 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ httpTimeout: 300000

nodeLinker: node-modules

npmRegistryServer: "https://registry.npmjs.org/"
npmRegistryServer: 'https://registry.npmjs.org/'

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
spec: '@yarnpkg/plugin-workspace-tools'

yarnPath: .yarn/releases/yarn-3.8.7.cjs
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@backstage/cli": "^0.27.0",
"@backstage/cli-node": "^0.2.2",
"@changesets/parse": "^0.4.0",
"@ianvs/prettier-plugin-sort-imports": "^4.4.0",
"@manypkg/get-packages": "^2.2.2",
"@octokit/rest": "^20.1.1",
"@red-hat-developer-hub/cli": "portal:./workspaces/repo-tools/packages/cli",
Expand All @@ -33,7 +34,7 @@
"lint-staged": "^15.2.2",
"lodash.escaperegexp": "^4.1.2",
"node-fetch": "^2.6.7",
"prettier": "^2.3.2"
"prettier": "^3.4.2"
},
"prettier": "@spotify/prettier-config",
"lint-staged": {
Expand Down
52 changes: 26 additions & 26 deletions scripts/ci/verify-changesets.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
* limitations under the License.
*/

import { join } from "path";
import fs from "fs/promises";
import { default as parseChangeset } from "@changesets/parse";
import { join } from 'path';
import fs from 'fs/promises';
import { default as parseChangeset } from '@changesets/parse';

const privatePackages = new Set([
"app",
"backend",
"e2e-test",
"storybook",
"techdocs-cli-embedded-app",
'app',
'backend',
'e2e-test',
'storybook',
'techdocs-cli-embedded-app',
]);

/**
Expand All @@ -34,42 +34,42 @@ const privatePackages = new Set([
*/
async function main() {
if (process.argv.length < 3) {
throw new Error("Usage: node verify-changesets.js name-of-the-workspace");
throw new Error('Usage: node verify-changesets.js name-of-the-workspace');
}
const workspace = process.argv[2];

const changesetsFolderPath = join(
import.meta.dirname,
"..",
"..",
"workspaces",
'..',
'..',
'workspaces',
workspace,
".changeset"
'.changeset',
);
const fileNames = await fs.readdir(changesetsFolderPath);
const changesetNames = fileNames.filter(
(name) => name.endsWith(".md") && name !== "README.md"
name => name.endsWith('.md') && name !== 'README.md',
);

const changesets = await Promise.all(
changesetNames.map(async (name) => {
changesetNames.map(async name => {
const content = await fs.readFile(
join(changesetsFolderPath, name),
"utf8"
'utf8',
);
return { name, ...parseChangeset(content) };
})
}),
);

const errors = [];
for (const changeset of changesets) {
const privateReleases = changeset.releases.filter((release) =>
privatePackages.has(release.name)
const privateReleases = changeset.releases.filter(release =>
privatePackages.has(release.name),
);
if (privateReleases.length > 0) {
const names = privateReleases
.map((release) => `'${release.name}'`)
.join(", ");
.map(release => `'${release.name}'`)
.join(', ');
errors.push({
name: changeset.name,
messages: [
Expand All @@ -81,9 +81,9 @@ async function main() {

if (errors.length) {
console.log();
console.log("***********************************************************");
console.log("* Changeset verification failed! *");
console.log("***********************************************************");
console.log('***********************************************************');
console.log('* Changeset verification failed! *');
console.log('***********************************************************');
console.log();
for (const error of errors) {
console.error(`Changeset '${error.name}' is invalid:`);
Expand All @@ -93,13 +93,13 @@ async function main() {
}
}
console.log();
console.log("***********************************************************");
console.log('***********************************************************');
console.log();
process.exit(1);
}
}

main().catch((error) => {
main().catch(error => {
console.error(error.stack);
process.exit(1);
});
50 changes: 25 additions & 25 deletions scripts/ci/verify-lockfile-duplicates.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@

/* eslint-disable @backstage/no-undeclared-imports */

import { execFile as execFileCb } from "child_process";
import { resolve as resolvePath, dirname as dirnamePath } from "path";
import { promisify } from "util";
import { execFile as execFileCb } from 'child_process';
import { resolve as resolvePath, dirname as dirnamePath } from 'path';
import { promisify } from 'util';

const execFile = promisify(execFileCb);

async function findLockFiles() {
// Not using relative paths as this should be run inside a workspace folder
const projectRoot = resolvePath(".");
const projectRoot = resolvePath('.');

let files = process.argv.slice(2).filter((arg) => !arg.startsWith("--"));
let files = process.argv.slice(2).filter(arg => !arg.startsWith('--'));

for (const argumentFile of files) {
if (!argumentFile.match(/(?:^|[\/\\])yarn.lock$/)) {
Expand All @@ -37,10 +37,10 @@ async function findLockFiles() {

if (!files.length) {
// List all lock files that are in the root or in an immediate subdirectory
files = ["yarn.lock"];
files = ['yarn.lock'];
}

return files.map((file) => ({
return files.map(file => ({
fileRelativeToProjectRoot: file,
directoryRelativeToProjectRoot: dirnamePath(file),
directoryAbsolute: resolvePath(projectRoot, dirnamePath(file)),
Expand All @@ -52,8 +52,8 @@ async function main() {

let fix = false;
for (const arg of process.argv) {
if (arg.startsWith("--")) {
if (arg === "--fix") {
if (arg.startsWith('--')) {
if (arg === '--fix') {
fix = true;
} else {
throw new Error(`Unknown argument ${arg}`);
Expand All @@ -62,20 +62,20 @@ async function main() {
}

for (const lockFile of lockFiles) {
console.log("Checking lock file", lockFile.fileRelativeToProjectRoot);
console.log('Checking lock file', lockFile.fileRelativeToProjectRoot);

let stdout;
let stderr;
let failed;

try {
const result = await execFile(
"yarn",
["dedupe", ...(fix ? [] : ["--check"])],
'yarn',
['dedupe', ...(fix ? [] : ['--check'])],
{
shell: true,
cwd: lockFile.directoryAbsolute,
}
},
);
stdout = result.stdout?.trim();
stderr = result.stderr?.trim();
Expand All @@ -97,40 +97,40 @@ async function main() {
if (failed) {
if (!fix) {
const command = `yarn${
lockFile.directoryRelativeToProjectRoot === "."
? ""
lockFile.directoryRelativeToProjectRoot === '.'
? ''
: ` --cwd ${lockFile.directoryRelativeToProjectRoot}`
} dedupe`;
const padding = " ".repeat(Math.max(0, 85 - 6 - command.length));
console.error("");
const padding = ' '.repeat(Math.max(0, 85 - 6 - command.length));
console.error('');
console.error(
"*************************************************************************************"
'*************************************************************************************',
);
console.error(
"* You have duplicate versions of some packages in a yarn.lock file. *"
'* You have duplicate versions of some packages in a yarn.lock file. *',
);
console.error(
"* To solve this, run the following command from the project root and commit all *"
'* To solve this, run the following command from the project root and commit all *',
);
console.log(
"* yarn.lock changes. *"
'* yarn.lock changes. *',
);
console.log(
"* *"
'* *',
);
console.log(`* ${command}${padding} *`);
console.error(
"*************************************************************************************"
'*************************************************************************************',
);
console.error("");
console.error('');
}

process.exit(1);
}
}
}

main().catch((error) => {
main().catch(error => {
console.error(error.stack);
process.exit(1);
});
2 changes: 1 addition & 1 deletion workspaces/bulk-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@spotify/prettier-config": "^12.0.0",
"knip": "^5.27.4",
"node-gyp": "^9.0.0",
"prettier": "^2.3.2",
"prettier": "^3.4.2",
"typescript": "~5.3.0"
},
"resolutions": {
Expand Down
2 changes: 1 addition & 1 deletion workspaces/bulk-import/packages/app/public/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down
Loading

0 comments on commit e2f788f

Please sign in to comment.