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

INSTUI-3794 update dependencies. Major updates are TS, Vitest #1578

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
9,256 changes: 4,774 additions & 4,482 deletions package-lock.json

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,39 +67,39 @@
"@storybook/react/webpack": "^5"
},
"devDependencies": {
"@babel/cli": "^7.24.5",
"@babel/cli": "^7.24.7",
"@commitlint/cli": "^17.8.1",
"@commitlint/config-conventional": "^17.8.1",
"@emotion/cache": "^11.11.0",
"@emotion/react": "^11.11.4",
"@testing-library/dom": "^9.3.4",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^14.3.1",
"@testing-library/user-event": "^14.5.2",
"@types/react-dom": "^18.3",
"@vitejs/plugin-react": "^4.2.1",
"chai": "^5.1.0",
"@vitejs/plugin-react": "^4.3.1",
"chai": "^4.4.1",
"chalk": "^4.1.2",
"commitizen": "^4.3.0",
"cross-spawn": "^7.0.3",
"cypress": "^13.9.0",
"cypress-real-events": "^1.12.0",
"esbuild": "^0.21.3",
"cypress": "^13.13.0",
"cypress-real-events": "^1.13.0",
"esbuild": "^0.23.0",
"eslint": "^8.57.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"husky": "^9.0.11",
"jsdom": "^24.0.0",
"lerna": "^8.1.3",
"lint-staged": "^15.2.2",
"lerna": "^7.4.2",
"lint-staged": "^15.2.7",
"npm-run-all": "^4.1.5",
"react": "^18.3.1",
"typescript": "5.4.5",
"vitest": "^1.6.0",
"webpack": "^5.91.0"
"typescript": "5.5.3",
"vitest": "^2.0.2",
"webpack": "^5.92.1"
},
"//dependency-comments": {
"danger": "^11.3.1 -- add this back if we use it in pr-validation.yml",
"chalk": "IMPORTANT: Chalk 5 is ESM. If you want to use Chalk with TypeScript or a build tool, you will probably want to use Chalk 4 for now."
"chalk": "Chalk 5 is ESM. (used here by the scripts/ folder)",
"lerna": "Lerna 8.1.6 doesnt seem to work, we're hitting this fixed(?) bug: https://github.com/lerna/lerna/issues/4005"
},
"engines": {
"node": ">=18",
Expand Down
2 changes: 1 addition & 1 deletion packages/__examples__/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"prop-types": "^15.8.1",
"react-docgen": "6.0.4",
"storybook": "^7.6.19",
"webpack": "^5.91.0"
"webpack": "^5.92.1"
},
"resolutions": {
"@storybook/react/webpack": "^5"
Expand Down
11 changes: 6 additions & 5 deletions packages/command-utils/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import path from 'path'
import which from 'which'
import rl from 'readline'
import chalk from 'chalk'
import crossSpawn from 'cross-spawn'
import { sync, spawn } from 'cross-spawn'

const require = createRequire(import.meta.url)

Expand Down Expand Up @@ -100,7 +100,7 @@ async function runCommandsConcurrently(commands) {
}

function runCommandSync(bin, args = [], envVars = {}, opts = {}) {
return crossSpawn.sync(bin, args, {
return sync(bin, args, {
env: { ...process.env, ...envVars },
stdio: 'inherit',
windowsHide: true,
Expand All @@ -118,7 +118,7 @@ function runCommandSync(bin, args = [], envVars = {}, opts = {}) {
* @returns {Promise<{stdout: string, stderr: string, code:number}>}
*/
async function runCommandAsync(bin, args = [], envVars = {}, opts = {}) {
const result = crossSpawn.spawn(bin, args, {
const result = spawn(bin, args, {
env: { ...process.env, ...envVars },
stdio: 'inherit',
windowsHide: true,
Expand Down Expand Up @@ -168,8 +168,9 @@ function resolveBin(
}
try {
// returns the full path to this package.json
// TODO this might break in Node 18!
// https://nodejs.dev/en/api/v18/packages/#main-entry-point-export
// TODO this might break in Node 18+ if a package uses "exports" field and
// does not export its package.json
// https://nodejs.org/api/packages.html#package-entry-points
const modPkgPath = require.resolve(`${modName}/package.json`)
const modPkgDir = path.dirname(modPkgPath)
const { bin } = require(modPkgPath)
Expand Down
2 changes: 1 addition & 1 deletion packages/command-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"license": "MIT",
"dependencies": {
"chalk": "^4.1.2",
"chalk": "^5.3.0",
"cross-spawn": "^7.0.3",
"which": "^4.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cz-lerna-changelog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@types/inquirer": "^8.2.10"
},
"peerDependencies": {
"lerna": "^8"
"lerna": "^7"
},
"//dependency-comments": {
"cz-cli": "This module cannot be ESM because cz-cli can only import CommonJS, see https://github.com/commitizen/cz-cli/issues/916",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-a11y-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@instructure/ui-dom-utils": "9.2.0",
"@instructure/ui-react-utils": "9.2.0",
"@instructure/uid": "9.2.0",
"keycode": "^2.2.1"
Copy link
Collaborator Author

@matyasf matyasf Jul 11, 2024

Choose a reason for hiding this comment

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

Its better to define supported versions for user-consumed packages in the broadest range possible to reduce the chance of including it twice in their builds. Luckily we just have a few such dependencies

"keycode": "^2"
},
"devDependencies": {
"@instructure/ui-babel-preset": "9.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-alerts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@instructure/ui-react-utils": "9.2.0",
"@instructure/ui-themes": "9.2.0",
"@instructure/ui-view": "9.2.0",
"keycode": "^2.2.1",
"keycode": "^2",
"prop-types": "^15.8.1"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-avatar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
"@instructure/ui-test-locator": "9.2.0",
"@instructure/ui-test-utils": "9.2.0",
"@instructure/ui-themes": "9.2.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^15.0.7",
"vitest": "^1.6.0"
"vitest": "^2.0.2"
},
"peerDependencies": {
"react": ">=16.8 <=18"
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-badge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
"@instructure/ui-babel-preset": "9.2.0",
"@instructure/ui-test-utils": "9.2.0",
"@instructure/ui-themes": "9.2.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^15.0.7",
"vitest": "^1.6.0"
"vitest": "^2.0.2"
},
"peerDependencies": {
"react": ">=16.8 <=18"
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-billboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
"@instructure/ui-icons": "9.2.0",
"@instructure/ui-test-utils": "9.2.0",
"@instructure/ui-themes": "9.2.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^15.0.7",
"@testing-library/user-event": "^14.5.2",
"vitest": "^1.6.0"
"vitest": "^2.0.2"
},
"dependencies": {
"@babel/runtime": "^7.24.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-breadcrumb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"@instructure/ui-babel-preset": "9.2.0",
"@instructure/ui-scripts": "9.2.0",
"@instructure/ui-themes": "9.2.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^15.0.7",
"vitest": "^1.6.0"
"vitest": "^2.0.2"
},
"dependencies": {
"@babel/runtime": "^7.24.5",
Expand Down
6 changes: 3 additions & 3 deletions packages/ui-buttons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"@instructure/ui-babel-preset": "9.2.0",
"@instructure/ui-test-utils": "9.2.0",
"@instructure/ui-themes": "9.2.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^15.0.7",
"@testing-library/user-event": "^14.5.2",
"vitest": "^1.6.0"
"vitest": "^2.0.2"
},
"dependencies": {
"@babel/runtime": "^7.24.5",
Expand All @@ -49,7 +49,7 @@
"@instructure/ui-tooltip": "9.2.0",
"@instructure/ui-utils": "9.2.0",
"@instructure/ui-view": "9.2.0",
"keycode": "^2.2.1",
"keycode": "^2",
"prop-types": "^15.8.1"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-byline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
"@instructure/ui-color-utils": "9.2.0",
"@instructure/ui-test-utils": "9.2.0",
"@instructure/ui-themes": "9.2.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^15.0.7",
"vitest": "^1.6.0"
"vitest": "^2.0.2"
},
"peerDependencies": {
"react": ">=16.8 <=18"
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-calendar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
"@instructure/ui-test-locator": "9.2.0",
"@instructure/ui-test-utils": "9.2.0",
"@instructure/ui-themes": "9.2.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^15.0.7",
"vitest": "^1.6.0"
"vitest": "^2.0.2"
},
"dependencies": {
"@babel/runtime": "^7.24.5",
Expand Down
6 changes: 3 additions & 3 deletions packages/ui-checkbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@instructure/ui-utils": "9.2.0",
"@instructure/ui-view": "9.2.0",
"@instructure/uid": "9.2.0",
"keycode": "^2.2.1",
"keycode": "^2",
"prop-types": "^15.8.1"
},
"devDependencies": {
Expand All @@ -46,10 +46,10 @@
"@instructure/ui-color-utils": "9.2.0",
"@instructure/ui-test-utils": "9.2.0",
"@instructure/ui-themes": "9.2.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^15.0.7",
"@testing-library/user-event": "^14.5.2",
"vitest": "^1.6.0"
"vitest": "^2.0.2"
},
"peerDependencies": {
"react": ">=16.8 <=18"
Expand Down
31 changes: 19 additions & 12 deletions packages/ui-codemods/lib/helpers/codemodHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,17 @@ import {
JSXIdentifier,
JSXMemberExpression,
JSXSpreadAttribute,
JSXSpreadChild,
JSXText,
Literal,
MemberExpression,
SpreadElement
} from 'jscodeshift'
import type { LiteralKind } from 'ast-types/gen/kinds'
import fs from 'fs'

type JSXChild =
| JSXElement
| JSXExpressionContainer
| JSXSpreadChild
| JSXFragment
| LiteralKind
type GetArrayType<T extends any[] | undefined> = T extends (infer U)[]
? U
: never
export type JSXChild = GetArrayType<JSXElement['children']>

type Attribute = {
name: string
Expand Down Expand Up @@ -544,6 +540,7 @@ function removeAllChildren(element: JSXElement) {

// type checkers
type astElem = { type: string }

function isSpreadElement(elem?: astElem | null): elem is SpreadElement {
return elem !== null && elem !== undefined && elem.type === 'SpreadElement'
}
Expand Down Expand Up @@ -582,12 +579,22 @@ function isJSXAttribue(elem?: astElem | null): elem is JSXAttribute {
return elem !== null && elem !== undefined && elem.type === 'JSXAttribute'
}

function isJSXElement(elem?: astElem | null): elem is JSXElement {
return elem !== null && elem !== undefined && elem.type == 'JSXElement'
function isJSXElement(elem?: astElem | astElem[] | null): elem is JSXElement {
return (
elem !== null &&
elem !== undefined &&
!Array.isArray(elem) &&
elem.type == 'JSXElement'
)
}

function isJSXText(elem?: astElem | null): elem is JSXText {
return elem !== null && elem !== undefined && elem.type == 'JSXText'
function isJSXText(elem?: astElem | astElem[] | null): elem is JSXText {
return (
elem !== null &&
elem !== undefined &&
!Array.isArray(elem) &&
elem.type == 'JSXText'
)
}

function isJSXIdentifier(elem?: astElem | null): elem is JSXIdentifier {
Expand Down
14 changes: 13 additions & 1 deletion packages/ui-codemods/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@
*/

import updatePropNames from './updatePropNames'
import updateImports from './updateImports'
import updateV7Props from './updateV7Props'
import updateV8Breaking from './updateV8Breaking'
import UpdateV8ReactDOM from './updateV8ReactDOM'
import updateV9Breaking from './updateV9Breaking'

export { updatePropNames }
export {
updatePropNames,
updateImports,
updateV7Props,
updateV8Breaking,
UpdateV8ReactDOM,
updateV9Breaking
}
export default updatePropNames
10 changes: 3 additions & 7 deletions packages/ui-codemods/lib/utils/updateV7Popover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
import type {
Collection,
JSCodeshift,
JSXElement,
JSXExpressionContainer,
StringLiteral
} from 'jscodeshift'
import type { JSXChild } from '../helpers/codemodHelpers'
import {
findElements,
findImport,
Expand Down Expand Up @@ -72,7 +72,7 @@ export default function updateV7Popover(
// should have 0 or 1 child
isUpdated = true
const theChild = trigger[0]
let toAdd = theChild as JSXExpressionContainer | StringLiteral
let toAdd = theChild as StringLiteral | JSXExpressionContainer
if (isJSXText(theChild)) {
toAdd = j.stringLiteral(theChild.value)
}
Expand Down Expand Up @@ -112,11 +112,7 @@ export default function updateV7Popover(
* Removes the child of the given array that is named like `Name1.Name2`
* It returns the first child of the child that has this name (if any)
*/
function getChildrenByName(
name1: string,
name2: string,
array?: JSXElement['children']
) {
function getChildrenByName(name1: string, name2: string, array?: JSXChild[]) {
if (!array) {
return
}
Expand Down
8 changes: 6 additions & 2 deletions packages/ui-codemods/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"scripts": {
"test:jest": "jest",
"lint": "ui-scripts lint",
"lint:fix": "ui-scripts lint --fix"
"lint:fix": "ui-scripts lint --fix",
"ts:check": "tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false"
},
"license": "MIT",
"devDependencies": {
Expand All @@ -24,9 +25,12 @@
},
"dependencies": {
"babel-core": "^7.0.0-bridge.0",
"jscodeshift": "^0.15.2",
"jscodeshift": "^0.16.1",
"prettier": "^2.8.8"
},
"//dependency-comments": {
"prettier": "Prettier 3 is async, https://prettier.io/blog/2023/07/05/3.0.0.html#api-1"
},
"publishConfig": {
"access": "public"
}
Expand Down
Loading
Loading