Skip to content

Commit

Permalink
refactor: create shared-helpers package
Browse files Browse the repository at this point in the history
  • Loading branch information
adamviktora committed Nov 12, 2024
1 parent aa86311 commit ac04c82
Show file tree
Hide file tree
Showing 23 changed files with 51 additions and 19 deletions.
3 changes: 2 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"packages/eslint-plugin-pf-codemods",
"packages/pf-codemods",
"packages/class-name-updater",
"packages/css-vars-updater"
"packages/css-vars-updater",
"packages/shared-helpers"
],
"version": "independent"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "yarn test:v4 && yarn test:v5 && yarn test:v6",
"test:v4": "mocha packages/eslint-plugin-pf-codemods/test/rules/v4",
"test:v5": "mocha packages/eslint-plugin-pf-codemods/test/rules/v5",
"test:v6": "yarn build && mocha packages/eslint-plugin-pf-codemods/dist/js/packages/eslint-plugin-pf-codemods/src/rules/v6/*/*.test.js",
"test:v6": "yarn build && mocha packages/eslint-plugin-pf-codemods/dist/js/rules/v6/*/*.test.js",
"test:v4:single": "pf-codemods --v4 --no-cache test/v4test.tsx",
"test:v5:single": "pf-codemods --no-cache test/test.tsx",
"test:v6:single": "yarn build && pf-codemods --v6 --no-cache packages/eslint-plugin-pf-codemods/src/rules/v6/*/*Input.tsx",
Expand Down
9 changes: 5 additions & 4 deletions packages/class-name-updater/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Red Hat",
"license": "MIT",
"bin": {
"class-name-updater": "./dist/packages/class-name-updater/src/cli.js"
"class-name-updater": "./dist/cli.js"
},
"engines": {
"node": ">=18"
Expand All @@ -17,14 +17,15 @@
"build": "tsc --build --verbose ./tsconfig.json",
"clean": "rimraf ./dist",
"test": "yarn build && yarn test:v5 && yarn test:v6",
"test:v5": "node ./dist/packages/class-name-updater/src/cli.js test --exclude test/largeFile.js",
"test:v6": "node ./dist/packages/class-name-updater/src/cli.js test --exclude test/largeFile.js --v6"
"test:v5": "node ./dist/cli.js test --exclude test/largeFile.js",
"test:v6": "node ./dist/cli.js test --exclude test/largeFile.js --v6"
},
"dependencies": {
"colors": "^1.4.0",
"commander": "^5.1.0",
"diff": "^5.1.0",
"glob": "^10.2.6"
"glob": "^10.2.6",
"shared-helpers": "^1.0.0"
},
"devDependencies": {
"@types/diff": "^5.0.9",
Expand Down
4 changes: 2 additions & 2 deletions packages/class-name-updater/src/classNameUpdate.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { sync } from "glob";
import { readFileSync, writeFileSync } from "fs";
import { join } from "path";
import { isDir } from "../../../helpers/utils";
import { printDiff } from "../../../helpers/printDiff";
import { isDir } from "shared-helpers/dist/utils";
import { printDiff } from "shared-helpers/dist/printDiff";

export async function classNameUpdate(
globTarget: string,
Expand Down
4 changes: 2 additions & 2 deletions packages/class-name-updater/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { join } from "path";
import { Command } from "commander";
const program = new Command();

import { isDir } from "../../../helpers/utils";
import { isDir } from "shared-helpers/dist/utils";
import { classNameUpdate } from "./classNameUpdate";

program
.version(
require('../../../../package.json').version
require('../package.json').version
)
.description("Update class name versioning")
.arguments("<path> [otherPaths...]")
Expand Down
7 changes: 3 additions & 4 deletions packages/css-vars-updater/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"description": "Utility to update Patternfly CSS variables when migrating from V5 to a new design token system in V6",
"author": "Red Hat",
"license": "MIT",
"bin": {
"css-vars-updater": "./dist/packages/css-vars-updater/src/cli.js"
},
"bin": "./dist/cli.js",
"engines": {
"node": ">=18"
},
Expand All @@ -22,7 +20,8 @@
"commander": "^5.1.0",
"diff": "^5.1.0",
"glob": "^10.2.6",
"inquirer": "^12.0.1"
"inquirer": "^12.0.1",
"shared-helpers": "^1.0.0"
},
"devDependencies": {
"@types/diff": "^5.0.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/css-vars-updater/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Command } from "commander";
const program = new Command();
import inquirer from "inquirer";

import { isDir } from "../../../helpers/utils";
import { isDir } from "shared-helpers/dist/utils";
import { cssVarsUpdate } from "./cssVarsUpdate";
import { Answers } from "./answers";

Expand Down
4 changes: 2 additions & 2 deletions packages/css-vars-updater/src/cssVarsUpdate.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { sync } from "glob";
import { readFileSync, writeFileSync } from "fs";
import { join } from "path";
import { isDir } from "../../../helpers/utils";
import { isDir } from "shared-helpers/dist/utils";
// import { printDiff } from "../../../helpers/printDiff";
import {
globalNonColorCssVarNamesMap,
oldCssVarNames,
oldGlobalColorCssVarNames,
oldGlobalNonColorCssVarNames,
v6DirectionCssVars,
} from "../../../helpers/tokenLists";
} from "shared-helpers/dist/tokenLists";
import { Answers } from "./answers";
import { getDirectionMap } from "./directionalStyles";

Expand Down
3 changes: 3 additions & 0 deletions packages/eslint-plugin-pf-codemods/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"test": "eslint . --ext .ts",
"clean": "rimraf ./dist"
},
"dependencies": {
"shared-helpers": "^1.0.0"
},
"peerDependencies": {
"@typescript-eslint/parser": ">=5.58.0",
"eslint": ">=0.8.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
getImportPath,
} from "../../helpers";
import { Identifier, ImportSpecifier } from "estree-jsx";
import { tokensToPrefixWithT } from "../../../../../../helpers/tokenLists";
import { tokensToPrefixWithT } from "shared-helpers/dist/tokenLists";

module.exports = {
meta: { fixable: "code" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
globalNonColorCssVarNamesMap,
oldGlobalColorCssVarNames,
oldGlobalColorTokens,
} from "../../../../../../helpers/tokenLists";
} from "shared-helpers/dist/tokenLists";

module.exports = {
meta: { fixable: "code" },
Expand Down
19 changes: 19 additions & 0 deletions packages/shared-helpers/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "shared-helpers",
"version": "1.0.0",
"description": "Shared helpers for the monorepo",
"scripts": {
"build": "tsc --build --verbose ./tsconfig.json",
"clean": "rimraf ./dist"
},
"author": "Red Hat",
"license": "MIT",
"dependencies": {
"colors": "^1.4.0",
"diff": "^5.1.0"
},
"devDependencies": {
"@types/diff": "^5.0.9",
"typescript": "^5.4.2"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions packages/shared-helpers/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "CommonJS",
"outDir": "./dist"
},
"include": ["src/**/*"],
"exclude": ["dist"]
}

0 comments on commit ac04c82

Please sign in to comment.