From e821fd43205574d8b1d3edf7687d0294573e2107 Mon Sep 17 00:00:00 2001 From: Jason Morse Date: Mon, 29 Jun 2026 16:14:03 -0700 Subject: [PATCH 1/4] add jest multiplexing and remove deprecated/unused scripts --- apps/fluent-tester/package.json | 1 - apps/tester-core/package.json | 1 - apps/win32/package.json | 1 - packages/codemods/package.json | 1 - packages/components/Avatar/package.json | 1 - packages/components/Badge/package.json | 1 - packages/components/Button/package.json | 1 - packages/components/Callout/package.json | 1 - packages/components/Checkbox/package.json | 1 - packages/components/Chip/package.json | 1 - .../components/ContextualMenu/package.json | 1 - packages/components/Divider/package.json | 1 - .../components/FocusTrapZone/package.json | 1 - packages/components/FocusZone/package.json | 1 - packages/components/Icon/package.json | 1 - packages/components/Input/package.json | 1 - packages/components/Link/package.json | 1 - packages/components/Menu/package.json | 1 - packages/components/MenuButton/package.json | 1 - packages/components/Notification/package.json | 1 - packages/components/Persona/package.json | 1 - packages/components/PersonaCoin/package.json | 1 - packages/components/Pressable/package.json | 1 - packages/components/RadioGroup/package.json | 1 - packages/components/Separator/package.json | 1 - packages/components/Stack/package.json | 1 - packages/components/Switch/package.json | 1 - packages/components/TabList/package.json | 1 - packages/components/Text/package.json | 1 - .../foundation-composable/package.json | 1 - .../foundation-compose/package.json | 1 - .../foundation-settings/package.json | 1 - .../deprecated/foundation-tokens/package.json | 1 - .../deprecated/theme-registry/package.json | 1 - .../deprecated/themed-settings/package.json | 1 - packages/deprecated/theming-ramp/package.json | 1 - .../theming-react-native/package.json | 1 - .../ActivityIndicator/package.json | 1 - .../AppearanceAdditions/package.json | 1 - packages/experimental/Avatar/package.json | 1 - packages/experimental/Checkbox/package.json | 1 - packages/experimental/Drawer/package.json | 1 - packages/experimental/Dropdown/package.json | 1 - packages/experimental/Expander/package.json | 1 - packages/experimental/MenuButton/package.json | 1 - .../NativeDatePicker/package.json | 1 - .../NativeFontMetrics/package.json | 1 - packages/experimental/Overflow/package.json | 1 - packages/experimental/Popover/package.json | 1 - packages/experimental/Shadow/package.json | 1 - packages/experimental/Shimmer/package.json | 1 - packages/experimental/Spinner/package.json | 1 - packages/experimental/Tooltip/package.json | 1 - .../experimental/VibrancyView/package.json | 1 - packages/framework-base/package.json | 1 - packages/framework/composition/package.json | 1 - packages/framework/framework/package.json | 1 - packages/framework/theme/package.json | 1 - .../framework/themed-stylesheet/package.json | 1 - packages/framework/use-slot/package.json | 1 - packages/framework/use-slots/package.json | 1 - packages/framework/use-styling/package.json | 1 - packages/framework/use-tokens/package.json | 1 - packages/libraries/core/package.json | 1 - packages/theming/android-theme/package.json | 1 - packages/theming/apple-theme/package.json | 1 - packages/theming/default-theme/package.json | 1 - packages/theming/theme-tokens/package.json | 1 - packages/theming/theme-types/package.json | 1 - packages/theming/theming-utils/package.json | 1 - packages/theming/win32-theme/package.json | 1 - packages/utils/adapters/package.json | 1 - packages/utils/interactive-hooks/package.json | 1 - packages/utils/styling/package.json | 1 - packages/utils/test-tools/package.json | 1 - packages/utils/tokens/package.json | 1 - scripts/configs/jest/jest.config.cjs | 3 +- scripts/dynamic.extensions.mts | 2 +- scripts/package.json | 1 - scripts/src/cli.ts | 4 - scripts/src/const.mts | 9 + scripts/src/pkgContext.ts | 48 ++ scripts/src/preinstall/tool-versions.ts | 2 +- scripts/src/tasks/build.ts | 46 -- scripts/src/tasks/constrain.ts | 1 + scripts/src/tasks/depcheck.ts | 285 ----------- scripts/src/tasks/format.ts | 2 +- scripts/src/tasks/jest.ts | 61 ++- scripts/src/utils/buildConfig.ts | 68 --- scripts/src/utils/fileData.ts | 64 +++ scripts/src/utils/projectRoot.ts | 462 ------------------ scripts/src/utils/runScript.ts | 9 +- scripts/targets/tsconfig.check.json | 2 + 93 files changed, 193 insertions(+), 952 deletions(-) create mode 100644 scripts/src/const.mts delete mode 100644 scripts/src/tasks/build.ts delete mode 100644 scripts/src/tasks/depcheck.ts delete mode 100644 scripts/src/utils/buildConfig.ts create mode 100644 scripts/src/utils/fileData.ts delete mode 100644 scripts/src/utils/projectRoot.ts diff --git a/apps/fluent-tester/package.json b/apps/fluent-tester/package.json index 2ea10278fd..5234e125e9 100644 --- a/apps/fluent-tester/package.json +++ b/apps/fluent-tester/package.json @@ -30,7 +30,6 @@ "bundle:macos": "rnx-cli bundle --dev false --platform macos", "bundle:windows": "rnx-cli bundle --dev false --platform windows", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "ios": "rnx-cli run --platform ios", "lint": "fluentui-scripts lint", diff --git a/apps/tester-core/package.json b/apps/tester-core/package.json index a8432fe904..803f9b802f 100644 --- a/apps/tester-core/package.json +++ b/apps/tester-core/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint" }, diff --git a/apps/win32/package.json b/apps/win32/package.json index 4473e8445a..9689486ccb 100644 --- a/apps/win32/package.json +++ b/apps/win32/package.json @@ -22,7 +22,6 @@ "bundle": "rnx-cli bundle --dev false", "bundle-dev": "rnx-cli bundle", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "run-win32": "rex-win32 --bundle index.win32 --component FluentTester --basePath ./dist --useDirectDebugger --windowTitle \"FluentUI Tester\" --pluginProps --debugBundlePath index --jsEngine v8", diff --git a/packages/codemods/package.json b/packages/codemods/package.json index 30db2e4628..7ac14a201b 100644 --- a/packages/codemods/package.json +++ b/packages/codemods/package.json @@ -28,7 +28,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest" diff --git a/packages/components/Avatar/package.json b/packages/components/Avatar/package.json index 6eb51db7ab..2b31a95123 100644 --- a/packages/components/Avatar/package.json +++ b/packages/components/Avatar/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/Badge/package.json b/packages/components/Badge/package.json index 610c1e91cf..b9a6255a22 100644 --- a/packages/components/Badge/package.json +++ b/packages/components/Badge/package.json @@ -21,7 +21,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/Button/package.json b/packages/components/Button/package.json index f533544d8f..2d93bcba70 100644 --- a/packages/components/Button/package.json +++ b/packages/components/Button/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/Callout/package.json b/packages/components/Callout/package.json index 14b4df8165..f4793af023 100644 --- a/packages/components/Callout/package.json +++ b/packages/components/Callout/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/Checkbox/package.json b/packages/components/Checkbox/package.json index a5c0446d17..8ecac9593e 100644 --- a/packages/components/Checkbox/package.json +++ b/packages/components/Checkbox/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/Chip/package.json b/packages/components/Chip/package.json index c3e985d900..38c4dd8f2e 100644 --- a/packages/components/Chip/package.json +++ b/packages/components/Chip/package.json @@ -20,7 +20,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/ContextualMenu/package.json b/packages/components/ContextualMenu/package.json index 9d22cbf3ff..7c322a29bb 100644 --- a/packages/components/ContextualMenu/package.json +++ b/packages/components/ContextualMenu/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/Divider/package.json b/packages/components/Divider/package.json index 85c06c2e3b..a7154c959b 100644 --- a/packages/components/Divider/package.json +++ b/packages/components/Divider/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/FocusTrapZone/package.json b/packages/components/FocusTrapZone/package.json index 096dbafbd4..088e1fbed2 100644 --- a/packages/components/FocusTrapZone/package.json +++ b/packages/components/FocusTrapZone/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/FocusZone/package.json b/packages/components/FocusZone/package.json index ad06d323d2..e743479a4a 100644 --- a/packages/components/FocusZone/package.json +++ b/packages/components/FocusZone/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/Icon/package.json b/packages/components/Icon/package.json index ba0f73ece3..97a9f4858f 100644 --- a/packages/components/Icon/package.json +++ b/packages/components/Icon/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/Input/package.json b/packages/components/Input/package.json index 5bc9fb585a..4c04a0bb22 100644 --- a/packages/components/Input/package.json +++ b/packages/components/Input/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/Link/package.json b/packages/components/Link/package.json index 8736f353ed..c1d227c2d6 100644 --- a/packages/components/Link/package.json +++ b/packages/components/Link/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/Menu/package.json b/packages/components/Menu/package.json index d6f623ae97..00699dcf67 100644 --- a/packages/components/Menu/package.json +++ b/packages/components/Menu/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/MenuButton/package.json b/packages/components/MenuButton/package.json index 5a10e1b6c5..132c57be49 100644 --- a/packages/components/MenuButton/package.json +++ b/packages/components/MenuButton/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/Notification/package.json b/packages/components/Notification/package.json index 8c10abdb4b..85f56edbbd 100644 --- a/packages/components/Notification/package.json +++ b/packages/components/Notification/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/Persona/package.json b/packages/components/Persona/package.json index 0a59a31748..e9810aa451 100644 --- a/packages/components/Persona/package.json +++ b/packages/components/Persona/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/PersonaCoin/package.json b/packages/components/PersonaCoin/package.json index 4365b49ece..b1bb1b9817 100644 --- a/packages/components/PersonaCoin/package.json +++ b/packages/components/PersonaCoin/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/Pressable/package.json b/packages/components/Pressable/package.json index 333208ed4c..0ee941c581 100644 --- a/packages/components/Pressable/package.json +++ b/packages/components/Pressable/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/RadioGroup/package.json b/packages/components/RadioGroup/package.json index 03d3e5cb40..3bfecc57b9 100644 --- a/packages/components/RadioGroup/package.json +++ b/packages/components/RadioGroup/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/Separator/package.json b/packages/components/Separator/package.json index 8750b9f19a..6a2b860cf4 100644 --- a/packages/components/Separator/package.json +++ b/packages/components/Separator/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/Stack/package.json b/packages/components/Stack/package.json index c82a62acfc..b860bed8ee 100644 --- a/packages/components/Stack/package.json +++ b/packages/components/Stack/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/Switch/package.json b/packages/components/Switch/package.json index 42fa330221..3f5f116d5b 100644 --- a/packages/components/Switch/package.json +++ b/packages/components/Switch/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/TabList/package.json b/packages/components/TabList/package.json index a44cb84a21..af5b3dbd13 100644 --- a/packages/components/TabList/package.json +++ b/packages/components/TabList/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/components/Text/package.json b/packages/components/Text/package.json index 6b0ea50728..aaaab9a5c1 100644 --- a/packages/components/Text/package.json +++ b/packages/components/Text/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/deprecated/foundation-composable/package.json b/packages/deprecated/foundation-composable/package.json index 7618fc4bac..f5273f03f5 100644 --- a/packages/deprecated/foundation-composable/package.json +++ b/packages/deprecated/foundation-composable/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/deprecated/foundation-compose/package.json b/packages/deprecated/foundation-compose/package.json index 4b5682ffb3..3936591c90 100644 --- a/packages/deprecated/foundation-compose/package.json +++ b/packages/deprecated/foundation-compose/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/deprecated/foundation-settings/package.json b/packages/deprecated/foundation-settings/package.json index d0305238b3..ebe883309d 100644 --- a/packages/deprecated/foundation-settings/package.json +++ b/packages/deprecated/foundation-settings/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/deprecated/foundation-tokens/package.json b/packages/deprecated/foundation-tokens/package.json index fbe072000b..b0e3ec554f 100644 --- a/packages/deprecated/foundation-tokens/package.json +++ b/packages/deprecated/foundation-tokens/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/deprecated/theme-registry/package.json b/packages/deprecated/theme-registry/package.json index 09e9c5ef8b..72f4e4e957 100644 --- a/packages/deprecated/theme-registry/package.json +++ b/packages/deprecated/theme-registry/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/deprecated/themed-settings/package.json b/packages/deprecated/themed-settings/package.json index c21f5d9b3e..7a7652a2e8 100644 --- a/packages/deprecated/themed-settings/package.json +++ b/packages/deprecated/themed-settings/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/deprecated/theming-ramp/package.json b/packages/deprecated/theming-ramp/package.json index 0940b31ea2..c3ab09921e 100644 --- a/packages/deprecated/theming-ramp/package.json +++ b/packages/deprecated/theming-ramp/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/deprecated/theming-react-native/package.json b/packages/deprecated/theming-react-native/package.json index 3612df9f90..82e0f7fc89 100644 --- a/packages/deprecated/theming-react-native/package.json +++ b/packages/deprecated/theming-react-native/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/experimental/ActivityIndicator/package.json b/packages/experimental/ActivityIndicator/package.json index fb7d539b62..cda524dccd 100644 --- a/packages/experimental/ActivityIndicator/package.json +++ b/packages/experimental/ActivityIndicator/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/experimental/AppearanceAdditions/package.json b/packages/experimental/AppearanceAdditions/package.json index 1672a502aa..bbd5c46263 100644 --- a/packages/experimental/AppearanceAdditions/package.json +++ b/packages/experimental/AppearanceAdditions/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/experimental/Avatar/package.json b/packages/experimental/Avatar/package.json index ab73d41432..503f365165 100644 --- a/packages/experimental/Avatar/package.json +++ b/packages/experimental/Avatar/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/experimental/Checkbox/package.json b/packages/experimental/Checkbox/package.json index 07c02c31dc..a1b6b8fbf1 100644 --- a/packages/experimental/Checkbox/package.json +++ b/packages/experimental/Checkbox/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/experimental/Drawer/package.json b/packages/experimental/Drawer/package.json index 968e160730..1eb81bb156 100644 --- a/packages/experimental/Drawer/package.json +++ b/packages/experimental/Drawer/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/experimental/Dropdown/package.json b/packages/experimental/Dropdown/package.json index 2468123afc..688a3f3dab 100644 --- a/packages/experimental/Dropdown/package.json +++ b/packages/experimental/Dropdown/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/experimental/Expander/package.json b/packages/experimental/Expander/package.json index a015ffdbf7..4c94118b11 100644 --- a/packages/experimental/Expander/package.json +++ b/packages/experimental/Expander/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", "update-api": "fluentui-scripts update-api-extractor", diff --git a/packages/experimental/MenuButton/package.json b/packages/experimental/MenuButton/package.json index 8e073b838d..251b1ae5df 100644 --- a/packages/experimental/MenuButton/package.json +++ b/packages/experimental/MenuButton/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/experimental/NativeDatePicker/package.json b/packages/experimental/NativeDatePicker/package.json index 05ef54cc70..4016d19679 100644 --- a/packages/experimental/NativeDatePicker/package.json +++ b/packages/experimental/NativeDatePicker/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/experimental/NativeFontMetrics/package.json b/packages/experimental/NativeFontMetrics/package.json index 93c194be73..f2eabeaaf8 100644 --- a/packages/experimental/NativeFontMetrics/package.json +++ b/packages/experimental/NativeFontMetrics/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/experimental/Overflow/package.json b/packages/experimental/Overflow/package.json index de665abbf6..40c1afbccc 100644 --- a/packages/experimental/Overflow/package.json +++ b/packages/experimental/Overflow/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/experimental/Popover/package.json b/packages/experimental/Popover/package.json index c02e5183ae..529b8c3bb5 100644 --- a/packages/experimental/Popover/package.json +++ b/packages/experimental/Popover/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/experimental/Shadow/package.json b/packages/experimental/Shadow/package.json index 83ffaec411..7f3ea2a096 100644 --- a/packages/experimental/Shadow/package.json +++ b/packages/experimental/Shadow/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/experimental/Shimmer/package.json b/packages/experimental/Shimmer/package.json index 80aea4b32f..4426771c85 100644 --- a/packages/experimental/Shimmer/package.json +++ b/packages/experimental/Shimmer/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/experimental/Spinner/package.json b/packages/experimental/Spinner/package.json index fe375a783d..d1bc7b02b5 100644 --- a/packages/experimental/Spinner/package.json +++ b/packages/experimental/Spinner/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/experimental/Tooltip/package.json b/packages/experimental/Tooltip/package.json index e47c1bc329..c10d57349a 100644 --- a/packages/experimental/Tooltip/package.json +++ b/packages/experimental/Tooltip/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/experimental/VibrancyView/package.json b/packages/experimental/VibrancyView/package.json index cecccb5b90..e0ba89c5d4 100644 --- a/packages/experimental/VibrancyView/package.json +++ b/packages/experimental/VibrancyView/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/framework-base/package.json b/packages/framework-base/package.json index bee6dfb0da..4297a8c9a2 100644 --- a/packages/framework-base/package.json +++ b/packages/framework-base/package.json @@ -31,7 +31,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/framework/composition/package.json b/packages/framework/composition/package.json index f9b9475748..44a4af8f67 100644 --- a/packages/framework/composition/package.json +++ b/packages/framework/composition/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/framework/framework/package.json b/packages/framework/framework/package.json index d0862364ce..d3ff001131 100644 --- a/packages/framework/framework/package.json +++ b/packages/framework/framework/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start-test": "fluentui-scripts jest-watch", diff --git a/packages/framework/theme/package.json b/packages/framework/theme/package.json index 46d683219c..f14223d8db 100644 --- a/packages/framework/theme/package.json +++ b/packages/framework/theme/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/framework/themed-stylesheet/package.json b/packages/framework/themed-stylesheet/package.json index 2583053ee5..50627f6a75 100644 --- a/packages/framework/themed-stylesheet/package.json +++ b/packages/framework/themed-stylesheet/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/framework/use-slot/package.json b/packages/framework/use-slot/package.json index f419a0c559..baf6036cdd 100644 --- a/packages/framework/use-slot/package.json +++ b/packages/framework/use-slot/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/framework/use-slots/package.json b/packages/framework/use-slots/package.json index 5080cc5e93..074a333a43 100644 --- a/packages/framework/use-slots/package.json +++ b/packages/framework/use-slots/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/framework/use-styling/package.json b/packages/framework/use-styling/package.json index 93eb9a9579..4bbd61254c 100644 --- a/packages/framework/use-styling/package.json +++ b/packages/framework/use-styling/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/framework/use-tokens/package.json b/packages/framework/use-tokens/package.json index 4ee9d3d93a..f2cc50044a 100644 --- a/packages/framework/use-tokens/package.json +++ b/packages/framework/use-tokens/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/libraries/core/package.json b/packages/libraries/core/package.json index 2341a5bc96..2982e5830f 100644 --- a/packages/libraries/core/package.json +++ b/packages/libraries/core/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start-test": "fluentui-scripts jest-watch", diff --git a/packages/theming/android-theme/package.json b/packages/theming/android-theme/package.json index 5c4a03bb77..a93cd7ead8 100644 --- a/packages/theming/android-theme/package.json +++ b/packages/theming/android-theme/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/theming/apple-theme/package.json b/packages/theming/apple-theme/package.json index 387a1e07cf..783204d00a 100644 --- a/packages/theming/apple-theme/package.json +++ b/packages/theming/apple-theme/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/theming/default-theme/package.json b/packages/theming/default-theme/package.json index 81e45928ce..41ca047921 100644 --- a/packages/theming/default-theme/package.json +++ b/packages/theming/default-theme/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/theming/theme-tokens/package.json b/packages/theming/theme-tokens/package.json index 72fe3e863c..460bc6356d 100644 --- a/packages/theming/theme-tokens/package.json +++ b/packages/theming/theme-tokens/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/theming/theme-types/package.json b/packages/theming/theme-types/package.json index 4909e49956..cea3a91e06 100644 --- a/packages/theming/theme-types/package.json +++ b/packages/theming/theme-types/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/theming/theming-utils/package.json b/packages/theming/theming-utils/package.json index ae1b388e1c..31895445f8 100644 --- a/packages/theming/theming-utils/package.json +++ b/packages/theming/theming-utils/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/theming/win32-theme/package.json b/packages/theming/win32-theme/package.json index 70764f6477..971c140694 100644 --- a/packages/theming/win32-theme/package.json +++ b/packages/theming/win32-theme/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "start": "fluentui-scripts dev", diff --git a/packages/utils/adapters/package.json b/packages/utils/adapters/package.json index 37935c3cbd..6ce797e80f 100644 --- a/packages/utils/adapters/package.json +++ b/packages/utils/adapters/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest && yarn verify-drift", diff --git a/packages/utils/interactive-hooks/package.json b/packages/utils/interactive-hooks/package.json index 276780afd0..991924b988 100644 --- a/packages/utils/interactive-hooks/package.json +++ b/packages/utils/interactive-hooks/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/utils/styling/package.json b/packages/utils/styling/package.json index 2fde33223f..19f001073d 100644 --- a/packages/utils/styling/package.json +++ b/packages/utils/styling/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/packages/utils/test-tools/package.json b/packages/utils/test-tools/package.json index c08525762e..636410ad78 100644 --- a/packages/utils/test-tools/package.json +++ b/packages/utils/test-tools/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "update-snapshots": "fluentui-scripts jest -u" diff --git a/packages/utils/tokens/package.json b/packages/utils/tokens/package.json index b7954a2759..8cb50b4401 100644 --- a/packages/utils/tokens/package.json +++ b/packages/utils/tokens/package.json @@ -24,7 +24,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", diff --git a/scripts/configs/jest/jest.config.cjs b/scripts/configs/jest/jest.config.cjs index 0cc0644743..a709a1888b 100644 --- a/scripts/configs/jest/jest.config.cjs +++ b/scripts/configs/jest/jest.config.cjs @@ -1,10 +1,11 @@ const fs = require('fs'); const path = require('path'); +const { PLATFORM_ENV_VAR } = require('../../src/const.mts'); const projectManifestPath = path.resolve(process.cwd(), 'package.json'); const foundProject = fs.existsSync(projectManifestPath); const projectManifest = foundProject ? require(projectManifestPath) : null; -const platform = projectManifest?.furn?.jestPlatform ?? 'ios'; +const platform = process.env[PLATFORM_ENV_VAR] ?? projectManifest?.furn?.jestPlatform ?? 'ios'; const rnPlatforms = ['ios', 'android', 'windows', 'macos', 'win32']; diff --git a/scripts/dynamic.extensions.mts b/scripts/dynamic.extensions.mts index c6c50ee710..241bdb8028 100644 --- a/scripts/dynamic.extensions.mts +++ b/scripts/dynamic.extensions.mts @@ -1,7 +1,7 @@ import fs from 'node:fs'; import path from 'node:path'; import { getToolVersion, hasJestConfig } from './src/preinstall/tool-versions.ts'; -import type { PackageManifest } from './src/utils/projectRoot.ts'; +import type { PackageManifest } from './src/pkgContext.ts'; type ConditionalCheck = () => boolean; diff --git a/scripts/package.json b/scripts/package.json index 2c3a2c7624..3958caedcd 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -28,7 +28,6 @@ "scripts": { "build": "tsgo -b", "bundlesize": "bundlesize --debug", - "depcheck": "node ./src/cli.ts depcheck", "format": "node ./src/cli.ts format", "lint": "node ./src/cli.ts lint" }, diff --git a/scripts/src/cli.ts b/scripts/src/cli.ts index a48c091644..b059ff5f0a 100644 --- a/scripts/src/cli.ts +++ b/scripts/src/cli.ts @@ -1,13 +1,11 @@ #!/usr/bin/env node import { Builtins, Cli } from 'clipanion'; -import { BuildCommand } from './tasks/build.ts'; import { CleanCommand } from './tasks/clean.ts'; import { FormatCommand } from './tasks/format.ts'; import { LintCommand } from './tasks/lint.ts'; import { JestCommand } from './tasks/jest.ts'; import { CheckPublishingCommand } from './tasks/checkPublishingTask.ts'; -import { DepcheckCommand } from './tasks/depcheck.ts'; const cli = new Cli({ binaryLabel: 'fluentui-scripts CLI', @@ -15,13 +13,11 @@ const cli = new Cli({ binaryVersion: '0.0.0', }); -cli.register(BuildCommand); cli.register(CleanCommand); cli.register(FormatCommand); cli.register(LintCommand); cli.register(JestCommand); cli.register(CheckPublishingCommand); -cli.register(DepcheckCommand); cli.register(Builtins.DefinitionsCommand); cli.register(Builtins.HelpCommand); diff --git a/scripts/src/const.mts b/scripts/src/const.mts new file mode 100644 index 0000000000..975193da53 --- /dev/null +++ b/scripts/src/const.mts @@ -0,0 +1,9 @@ +// env variable to signal the current platform for scripts that need to know (like jest) +export const PLATFORM_ENV_VAR = 'FURN_RN_PLATFORM' as const; +// env variable to signal that we're in fix mode for scripts that support it +export const FIX_ENV_VAR = 'FURN_FIX_MODE' as const; + +export const REACT_PLATFORM = 'react' as const; +export const NATIVE_PLATFORMS = ['ios', 'android', 'windows', 'macos', 'win32'] as const; +export const DEFULT_WIN_PLATFORM = 'win32' as const; +export const ALL_PLATFORMS = [...NATIVE_PLATFORMS, REACT_PLATFORM] as const; diff --git a/scripts/src/pkgContext.ts b/scripts/src/pkgContext.ts index d820018886..2437830e14 100644 --- a/scripts/src/pkgContext.ts +++ b/scripts/src/pkgContext.ts @@ -4,6 +4,7 @@ import type { PackageManifest as PackageManifestBase } from '@rnx-kit/types-node import type { Yarn } from '@yarnpkg/types'; import path from 'node:path'; import fs from 'node:fs'; +import Module from 'node:module'; import { styleText } from 'util'; export type PackageType = 'library' | 'component' | 'app' | 'tooling'; @@ -43,6 +44,7 @@ export class PackageContext extends PackageValidationContext { const validator = createJSONValidator(jsonPath, manifest as JSONObject, innerOptions); return new PackageContext(root, validator); } + /** * Create a package validation context for a Yarn workspace * @param workspace the Yarn workspace to validate @@ -58,16 +60,55 @@ export class PackageContext extends PackageValidationContext { } private _files?: string[]; + private _cachedRequire: ReturnType | undefined = undefined; static BLOCKED_DIRS = new Set(['node_modules', 'dist', 'lib', 'lib-commonjs', 'lib-esm', 'build', '.git', '.vscode', '.idea']); + /** + * Get the cached require function for this package, allows using require within the context of this package and in esm scope + * @returns {NodeRequire} - built on demand and cached require function + */ + get require() { + return (this._cachedRequire ??= Module.createRequire(this.root)); + } + + /** + * Get the list of all files in the package, excluding things like node_modules, lib, and dist + * @returns {string[]} - the list of all files in the package + */ get files(): string[] { return (this._files ??= getFilesSync(this.root, PackageContext.BLOCKED_DIRS)); } + /** + * Get the list of all files in the package, excluding things like node_modules, lib, and dist + * @returns {Promise} - the list of all files in the package + */ async getFiles(): Promise { return (this._files ??= await getAllFiles(this.root, PackageContext.BLOCKED_DIRS)); } + + /** + * Open a module relative to this project root + */ + openModule(moduleName: string): PackageContext { + const pkgJsonPath = this.require.resolve(`${moduleName}/package.json`, { paths: [this.root] }); + return PackageContext.init(path.dirname(pkgJsonPath)); + } + + /** + * Get the path to a bin entry for a js package. + */ + getBinPath(command: string): string | undefined { + const bin = this.manifest.bin; + if (bin) { + const binRelative = typeof bin === 'string' ? bin : bin[command]; + if (binRelative) { + return normalizePath(path.join(this.root, binRelative)); + } + } + return undefined; + } } async function getAllFiles(dir: string, excludedDirs?: Set): Promise { @@ -113,3 +154,10 @@ function getFilesSync(dir: string, excludedDirs?: Set): string[] { walkDir(dir, excludedDirs); return results; } + +/** + * Normalize a file path by replacing backslashes with forward slashes. + */ +export function normalizePath(p: string): string { + return path.normalize(p).replaceAll('\\', '/'); +} diff --git a/scripts/src/preinstall/tool-versions.ts b/scripts/src/preinstall/tool-versions.ts index 3382c94572..6d6f48e2fa 100644 --- a/scripts/src/preinstall/tool-versions.ts +++ b/scripts/src/preinstall/tool-versions.ts @@ -2,7 +2,7 @@ import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; -import type { PackageManifest } from '../utils/projectRoot.ts'; +import type { PackageManifest } from '../pkgContext.ts'; /** * Get the package.json manifest for a given folder. diff --git a/scripts/src/tasks/build.ts b/scripts/src/tasks/build.ts deleted file mode 100644 index b3dcc73ce7..0000000000 --- a/scripts/src/tasks/build.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { Command } from 'clipanion'; -import { runYarn } from '../utils/runScript.ts'; -import { getProjectRoot } from '../utils/projectRoot.ts'; -import { getResolvedConfig } from '../utils/buildConfig.ts'; - -export class BuildCommand extends Command { - /** @override */ - static override paths = [['build']]; - - /** @override */ - static override usage = Command.Usage({ - description: 'Builds the current package using TypeScript compiler', - details: 'This command builds the current package based on the tsconfig.json and package.json configuration.', - examples: [['Build the current package', '$0 build']], - }); - - async execute() { - const cwd = process.cwd(); - const buildConfig = getResolvedConfig(getProjectRoot(cwd)).typescript; - const { cjsScript, esmScript } = buildConfig; - - if (!cjsScript && !esmScript) { - console.log('No build scripts defined. Skipping build.'); - return 0; - } - - if (cjsScript) { - const [cmd, ...args] = cjsScript.split(' '); - const result = await runYarn(cmd, ...args); - if (result !== 0) { - console.error(`Build (cjs) - failed with code ${result}`); - return result; - } - } - - if (esmScript && esmScript !== cjsScript) { - const [cmd, ...args] = esmScript.split(' '); - const result = await runYarn(cmd, ...args); - if (result !== 0) { - console.error(`Build (esm) - failed with code ${result}`); - return result; - } - } - return 0; - } -} diff --git a/scripts/src/tasks/constrain.ts b/scripts/src/tasks/constrain.ts index bc5a6bf1bc..c1b75e5e16 100644 --- a/scripts/src/tasks/constrain.ts +++ b/scripts/src/tasks/constrain.ts @@ -18,6 +18,7 @@ export function constrain(workspace: Yarn.Constraints.Workspace): void { } ctx.enforce('scripts.build-cjs', undefined); ctx.enforce('scripts.build-core', undefined); + ctx.enforce('scripts.depcheck', undefined); const tsCtx = ctx.validateJSON('tsconfig.json'); if (tsCtx) { const depBuilds = new Set(); diff --git a/scripts/src/tasks/depcheck.ts b/scripts/src/tasks/depcheck.ts deleted file mode 100644 index 0ddc7d5f99..0000000000 --- a/scripts/src/tasks/depcheck.ts +++ /dev/null @@ -1,285 +0,0 @@ -import { Command, Option } from 'clipanion'; -import depcheck from 'depcheck'; -import type { ProjectRoot } from '../utils/projectRoot.ts'; -import { getProjectRoot } from '../utils/projectRoot.ts'; -import getInjectedDeps from '../../dynamic.extensions.mts'; -import { getFormatter } from '@rnx-kit/reporter'; -import { getToolVersion } from '../preinstall/tool-versions.ts'; -import micromatch from 'micromatch'; -import { isFixMode } from '../utils/env.ts'; - -type IssueType = 'unused' | 'missing'; -type DependencyType = 'dependency' | 'devDependency'; -type Issue = { - issue: IssueType; - depType?: DependencyType; - dependency: string; - files?: string[]; -}; - -/** - * Merges two objects at one level. - */ -function mergeOneLevel(a: Record, b: Record = {}): Record { - const result = { ...a, ...b }; - Object.keys(a).forEach((key) => { - if (Array.isArray(b[key]) && Array.isArray(a[key])) { - result[key] = [...a[key], ...b[key]]; - } - }); - return result; -} - -export class DepcheckCommand extends Command { - /** @override */ - static override paths = [['depcheck']]; - - /** @override */ - static override usage = Command.Usage({ - description: 'Check for unused dependencies in the project using depcheck', - details: 'This command analyzes the project to find unused dependencies and missing dependencies.', - examples: [['Check dependencies in the current package', '$0 depcheck']], - }); - - verbose = Option.Boolean('--verbose', false, { - description: 'Enable verbose output, showing suppressed warnings and errors', - }); - - fixErrors = Option.Boolean('--fix-errors', false, { - description: 'Attempt to automatically fix issues found by depcheck', - }); - - fixWarnings = Option.Boolean('--fix-warnings', false, { - description: 'Attempt to automatically fix warnings found by depcheck', - }); - - dryRun = Option.Boolean('--dry-run', false, { - description: 'Perform a dry run of fixes without making any changes', - }); - - async execute() { - const runner = new DepCheckRunner({ - verbose: this.verbose, - fixErrors: isFixMode(this.fixErrors), - fixWarnings: this.fixWarnings, - dryRun: this.dryRun, - }); - return runner.execute(); - } -} - -/** - * Runner for depcheck task, can be called from the command or from another command - */ -export class DepCheckRunner { - private verbose: boolean; - private fixErrors: boolean; - private fixWarnings: boolean; - private dryRun: boolean; - private changes = false; - private issues: Issue[] = []; - private errors = 0; - private projectRoot = getProjectRoot(); - private ignored: Set = new Set(injectedDevDeps(this.projectRoot)); - private removedDevDeps: string[] = []; - private removedDeps: string[] = []; - private addedDeps: { dependencies?: Record; devDependencies?: Record } = {}; - private formatter = getFormatter(); - // Map the prior @rnx-kit/reporter `color(text, semantic)` API onto the 0.2 formatter's - // per-semantic functions (warn/error prefixes have no semantic, so use ansi yellow/red). - private color = (text: string, name: 'highlight1' | 'highlight3' | 'warnPrefix' | 'errorPrefix'): string => { - switch (name) { - case 'highlight1': - return this.formatter.highlight1(text); - case 'highlight3': - return this.formatter.highlight3(text); - case 'warnPrefix': - return this.formatter.yellow(text); - case 'errorPrefix': - return this.formatter.red(text); - } - }; - - constructor(options: { verbose?: boolean; fixErrors?: boolean; fixWarnings?: boolean; dryRun?: boolean } = {}) { - this.verbose = options.verbose ?? false; - this.fixErrors = options.fixErrors ?? false; - this.fixWarnings = options.fixWarnings ?? false; - this.dryRun = options.dryRun ?? false; - } - - async execute() { - const depcheckOptions = this.projectRoot.buildConfig.depcheck ?? {}; - const options = mergeOneLevel( - { - ignorePatterns: ['/lib/*', '/lib-commonjs/*'], - specials: [depcheck.special.eslint, depcheck.special.jest, depcheck.special.ttypescript], - }, - depcheckOptions, - ); - - return new Promise((resolve, reject) => { - depcheck(process.cwd(), options, (result) => { - try { - // build up the set of found issues - result.devDependencies.forEach((dependency) => this.issues.push({ issue: 'unused', depType: 'devDependency', dependency })); - result.dependencies.forEach((dependency) => this.issues.push({ issue: 'unused', depType: 'dependency', dependency })); - Object.keys(result.missing).forEach((dependency) => - this.issues.push({ issue: 'missing', dependency, files: result.missing[dependency] }), - ); - - // handle and/or report the issues - this.handleIssues(); - - if (this.errors > 0) { - reject(new Error('Dependency checking failed')); - return; - } - - resolve(0); - } catch (error) { - console.error('Error during depcheck processing:', error); - resolve(1); - } - }); - }); - } - - madeChanges(): boolean { - return this.changes; - } - - private handleIssues() { - for (const issue of this.issues) { - if (issue.issue === 'unused') { - this.handleUnused(issue); - } else if (issue.issue === 'missing') { - this.handleMissing(issue); - } - } - - this.handleFixes(); - } - - private handleFixes() { - this.changes = this.removedDeps.length > 0 || this.removedDevDeps.length > 0 || Object.keys(this.addedDeps).length > 0; - const prefix = this.dryRun ? '[dry-run]' : ' -'; - if (this.removedDevDeps.length > 0) { - if (!this.dryRun) { - for (const dep of this.removedDevDeps) { - this.projectRoot.updateRecordEntry('devDependencies', dep, undefined); - } - } - console.warn(prefix, `Removed unused devDependencies: ${this.removedDevDeps.map((dep) => this.formatter.package(dep)).join(', ')}`); - } - if (this.removedDeps.length > 0) { - if (!this.dryRun) { - for (const dep of this.removedDeps) { - this.projectRoot.updateRecordEntry('dependencies', dep, undefined); - } - } - console.error(prefix, `Removed unused dependencies: ${this.removedDeps.map((dep) => this.formatter.package(dep)).join(', ')}`); - } - if (this.addedDeps.dependencies) { - for (const [dep, version] of Object.entries(this.addedDeps.dependencies)) { - if (!this.dryRun) { - this.projectRoot.updateRecordEntry('dependencies', dep, version); - } - console.warn(prefix, `Added dependency: ${this.formatter.package(dep)}@${version}`); - } - } - if (this.addedDeps.devDependencies) { - for (const [dep, version] of Object.entries(this.addedDeps.devDependencies)) { - if (!this.dryRun) { - this.projectRoot.updateRecordEntry('devDependencies', dep, version); - } - console.warn(prefix, `Added devDependency: ${this.formatter.package(dep)}@${version}`); - } - } - } - - private handleUnused(issue: Issue) { - const color = this.color; - const { dependency, depType = 'dependency' } = issue; - const prettyDependency = this.formatter.package(dependency); - if (this.ignored.has(dependency)) { - if (this.verbose) { - console.log(`- [${color('ignored', 'highlight1')}]: unused ${depType}: ${prettyDependency}`); - } - return; - } - if (depType === 'devDependency') { - if (this.fixWarnings) { - this.removedDevDeps.push(dependency); - } else { - console.warn(`- [${color('warn', 'warnPrefix')}]: unused ${depType}: ${prettyDependency}`); - } - } else { - if (this.fixErrors) { - this.removedDeps.push(dependency); - } else { - console.error(`- [${color('error', 'errorPrefix')}]: unused ${depType}: ${prettyDependency}`); - this.errors++; - } - } - } - - private handleMissing(issue: Issue) { - const color = this.color; - const { dependency, files } = issue; - const prettyDependency = this.formatter.package(dependency); - if (files && files.length > 0) { - const fileNames = files.map((file) => ` - ${color(file, 'highlight3')}`).join('\n'); - const msgEnd = `missing dependency: ${prettyDependency} from files:\n${fileNames}`; - if (this.ignored.has(dependency)) { - if (this.verbose) { - console.log(`- [${color('ignored', 'highlight1')}]: ${msgEnd}`); - } - return; - } - const toolVersion = getToolVersion(dependency); - if (this.fixErrors && toolVersion) { - let isNonTest = false; - for (const file of files) { - isNonTest = isNonTest || !isTestFile(file); - } - if (isNonTest) { - this.addedDeps.dependencies ??= {}; - this.addedDeps.dependencies[dependency] = toolVersion; - } else { - this.addedDeps.devDependencies ??= {}; - this.addedDeps.devDependencies[dependency] = toolVersion; - } - } else { - console.error(`- [${color('error', 'errorPrefix')}]: ${msgEnd}`); - this.errors++; - } - } - - if (this.ignored.has(dependency)) { - if (this.verbose) { - console.log(`- [${color('ignored', 'highlight1')}]: missing ${prettyDependency}`); - } - return; - } - console.error(`- [${color('error', 'errorPrefix')}]: missing ${prettyDependency}`); - } -} - -function injectedDevDeps(projectRoot: ProjectRoot): string[] { - const options = { cwd: projectRoot.root, manifest: projectRoot.manifest }; - const injectedDeps = getInjectedDeps(options); - return Object.keys(injectedDeps.dependencies ?? {}); -} - -function isTestFile(fileName: string): boolean { - return micromatch.isMatch(fileName, [ - '**/*.test.*', - '**/*.spec.*', - '**/__tests__/**', - '**/__testfixtures__/**', - '**/babel.config.*', - '**/jest.config.*', - '**/eslint.config.*', - '**/oxlint.config.*', - ]); -} diff --git a/scripts/src/tasks/format.ts b/scripts/src/tasks/format.ts index 8878eeaec2..68202d2e50 100644 --- a/scripts/src/tasks/format.ts +++ b/scripts/src/tasks/format.ts @@ -17,6 +17,6 @@ export class FormatCommand extends Command { async execute() { const args = isFixMode(!this.check) ? [] : ['--check']; - return await runScript('oxfmt', ...args); + return await runScript('oxfmt', args); } } diff --git a/scripts/src/tasks/jest.ts b/scripts/src/tasks/jest.ts index bbffcfbd25..8232bd23f5 100644 --- a/scripts/src/tasks/jest.ts +++ b/scripts/src/tasks/jest.ts @@ -1,6 +1,9 @@ import { Command, Option } from 'clipanion'; import { runScript } from '../utils/runScript.ts'; import { hasJestConfig } from '../preinstall/tool-versions.ts'; +import { PackageContext, type PlatformTarget } from '../pkgContext.ts'; +import { PLATFORM_ENV_VAR, DEFULT_WIN_PLATFORM } from '../const.mts'; +import { getFileMetadata } from '../utils/fileData.ts'; export class JestCommand extends Command { static override paths = [['jest']]; @@ -14,15 +17,69 @@ export class JestCommand extends Command { args = Option.Proxy(); async execute() { + const context = PackageContext.init(process.cwd()); if (!hasJestConfig(process.cwd())) { console.warn('No jest configuration found, skipping jest.'); return; } - const args = ['--passWithNoTests']; + const args = ['--passWithNoTests', '--runTestsByPath']; if (process.env.TF_BUILD) { args.push('--runInBand'); } - return await runScript('jest', 'src/', ...args, ...this.args); + const defaultPlatform = getBaseJestPlatform(context); + const targetFiles = getJestTargetFiles(context, defaultPlatform); + if (targetFiles) { + for (const key in targetFiles) { + const platform = key as PlatformTarget; + const files = targetFiles[platform]; + if (files && files.length > 0) { + console.log(`Running jest for platform ${platform} with ${files.length} test files.`); + const options = platform !== defaultPlatform ? { env: { ...process.env, [PLATFORM_ENV_VAR]: platform } } : undefined; + const result = await runScript('jest', [...args, ...this.args, ...files], options); + if (result !== 0) { + return result; + } + } + } + } else { + console.warn('No test files found for any platform, skipping jest.'); + } + return 0; + } +} + +export function getBaseJestPlatform(context: PackageContext): PlatformTarget { + return context.manifest.furn?.jestPlatform ?? 'ios'; +} + +/** + * Get the list of test files for the given package context, defaulting to the base jest platform but allowing other platforms to + * execute in parallel if they have platform-specific test files. + */ +export function getJestTargetFiles( + context: PackageContext, + defaultPlatform: PlatformTarget, +): Partial> | undefined { + let results: Partial> | undefined = undefined; + + const files = context.files; + for (const file of files) { + const metadata = getFileMetadata(file); + // we only care about source test files + if (!metadata.isSource || !metadata.isTest) { + continue; + } + results ??= {}; + let platform: string | undefined = undefined; + if (defaultPlatform !== 'react') { + // If the default platform is not 'react', check for platform-specific suffixes to multiplex the tests. + platform = (metadata.platformSuffix ?? metadata.intermediateSuffix === 'win') ? DEFULT_WIN_PLATFORM : undefined; + } + // fall through to the default platform + platform ??= defaultPlatform; + const fileList = (results[platform as PlatformTarget] ??= []); + fileList.push(file); } + return results; } diff --git a/scripts/src/utils/buildConfig.ts b/scripts/src/utils/buildConfig.ts deleted file mode 100644 index 6d32cf04e9..0000000000 --- a/scripts/src/utils/buildConfig.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { getPackageInfoFromPath } from '@rnx-kit/tools-packages'; -import { type RepoBuildConfig, type ProjectRoot, type ResolvedBuildConfig } from './projectRoot.ts'; -import { readTypeScriptConfig } from '@rnx-kit/tools-typescript'; -import fs from 'node:fs'; -import path from 'node:path'; -import type ts from 'typescript'; - -/** - * Get a fully resolved build config for this package. - * @param projRoot project root for this package - * @param analyze whether to parse required config files for deeper analysis. Defaults to false. - */ -export function getResolvedConfig(projRoot: ProjectRoot, analyze?: boolean): ResolvedBuildConfig { - const buildConfig = projRoot.buildConfig; - return { - packageType: buildConfig.packageType ?? 'library', - typescript: getTypescriptBuildConfig(projRoot, buildConfig, analyze), - depcheck: buildConfig.depcheck ?? {}, - }; -} - -function getTypescriptBuildConfig( - projRoot: ProjectRoot, - buildConfig: RepoBuildConfig, - analyze?: boolean, -): ResolvedBuildConfig['typescript'] { - const buildTsConfig = buildConfig.typescript || {}; - const { cjsDir = 'lib-commonjs', esmDir = 'lib', engine = 'tsgo', extraArgs } = buildTsConfig; - const scripts = projRoot.manifest.scripts || {}; - let cjsScript = scripts['build-cjs'] ?? buildTsConfig.cjsScript ?? ''; - let esmScript = scripts['build-esm'] ?? buildTsConfig.esmScript ?? ''; - let checkScript = scripts['build-check'] ?? buildTsConfig.checkScript ?? ''; - if (analyze) { - // helper to build up the correct build command - function getScript(options: ts.CompilerOptions, outDir: string, isDefaultType: boolean, moduleType: 'commonjs' | 'esnext'): string { - const parts: string[] = [engine]; - if (options.noEmit) { - return ''; - } - if (outDir !== options.outDir) { - parts.push('--outDir', outDir); - } - if (!isDefaultType) { - parts.push('--module', moduleType, '--moduleResolution', 'bundler'); - } - if (extraArgs) { - parts.push(extraArgs); - } - return parts.join(' '); - } - - if (!fs.existsSync(path.join(projRoot.root, 'tsconfig.json'))) { - // no tsconfig.json means no TypeScript build - cjsScript = ''; - esmScript = ''; - checkScript = ''; - } else { - const pkgInfo = getPackageInfoFromPath(projRoot.root); - const tsConfig = readTypeScriptConfig(pkgInfo); - const options = tsConfig.options; - const isModule = pkgInfo.manifest.type === 'module'; - cjsScript = getScript(options, cjsDir, !isModule, 'commonjs'); - esmScript = getScript(options, esmDir, isModule, 'esnext'); - checkScript = options.noEmit ? engine : ''; - } - } - return { engine, cjsDir, esmDir, cjsScript, esmScript, checkScript, extraArgs }; -} diff --git a/scripts/src/utils/fileData.ts b/scripts/src/utils/fileData.ts new file mode 100644 index 0000000000..0124672b27 --- /dev/null +++ b/scripts/src/utils/fileData.ts @@ -0,0 +1,64 @@ +import path from 'node:path'; + +export type FileMetadata = { + isTypeScript?: boolean; + isSource?: boolean; + isTest?: boolean; + platformSuffix?: string; + intermediateSuffix?: string; +}; + +const TS_EXTENSIONS = new Set(['.ts', '.tsx', '.mts', 'cts']); +const JS_EXTENSIONS = new Set(['.js', '.jsx', '.mjs', 'cjs']); +const PLATFORM_SUFFIXES = new Set(['android', 'ios', 'win32', 'windows', 'macos']); +const INTERMEDIATE_SUFFIXES = new Set(['native', 'win']); + +function testNamePart(part: string, metadata: FileMetadata): boolean { + if (part === 'test' || part === 'spec') { + metadata.isTest = true; + return true; + } + if (PLATFORM_SUFFIXES.has(part)) { + metadata.platformSuffix = part; + return true; + } + if (INTERMEDIATE_SUFFIXES.has(part)) { + metadata.intermediateSuffix = part; + return true; + } + return false; +} + +/** + * Get the metadata for a given file. This will attempt to determine: + * - is this a source file type? + * - is this a test file? + * - what is the platform suffix? + * - what is the intermediate platform suffix? (like native, win) + * + * For files to be treated as having platform suffixes those should come last. E.g.: + * - MyFile.test.android.ts - is a test file and android platform + * - Myfile.android.ts - is an android platform file + * - MyFile.android.test.ts - is a test file but NOT an android platform file as Jest/Metro wouldn't treat it as such. + * + * @param file The file path to analyze. + * @returns The metadata for the given file. + */ +export function getFileMetadata(file: string): FileMetadata { + const parts = path.parse(file); + const ext = parts.ext; + + const isTypeScript = TS_EXTENSIONS.has(ext); + const isSource = isTypeScript || JS_EXTENSIONS.has(ext); + const result: FileMetadata = { isTypeScript, isSource }; + + const nameParts = parts.name.split('.'); + if (nameParts.length > 1) { + const last = nameParts.pop(); + if (last && testNamePart(last, result) && nameParts.length > 1 && !result.isTest) { + const secondLast = nameParts.pop(); + testNamePart(secondLast || '', result); + } + } + return result; +} diff --git a/scripts/src/utils/projectRoot.ts b/scripts/src/utils/projectRoot.ts deleted file mode 100644 index 8f733edcbc..0000000000 --- a/scripts/src/utils/projectRoot.ts +++ /dev/null @@ -1,462 +0,0 @@ -import Module from 'node:module'; -import { fileURLToPath } from 'node:url'; -import path from 'node:path'; -import fs from 'node:fs'; -import type { KitConfig } from '@rnx-kit/types-kit-config'; - -export type ExportSet = { - default?: string; - types?: string; - 'react-native'?: string; - import?: string; - require?: string; -}; - -export type ExportEntry = string | ExportSet; - -export type Exports = Record; - -export type PackageType = 'library' | 'component' | 'app' | 'tooling'; -export type PlatformTarget = 'react' | 'win32' | 'macos' | 'ios' | 'android' | 'windows'; - -export type ResolvedBuildConfig = { - packageType: PackageType; - jestPlatform?: PlatformTarget; - typescript: { - /** whether to use tsc or tsgo to build this package */ - engine: 'tsc' | 'tsgo'; - /** cjs outDir - defaults to lib-commonjs */ - cjsDir: string; - /** esm outDir - defaults to lib */ - esmDir: string; - /** extra arguments to pass to the TypeScript compiler */ - extraArgs?: string; - /** script to run for cjs build */ - cjsScript: string; - /** script to run for esm build */ - esmScript: string; - /** check script */ - checkScript: string; - }; - depcheck: { - ignoreMatches?: string[]; - ignorePatterns?: string[]; - }; -}; - -export type RepoBuildConfig = Partial & { typescript: Partial }>; - -export type PackageManifest = { - // Most canonical identity and metadata fields - name: string; - version: string; - private?: boolean; - description?: string; - keywords?: string[]; - license?: string; - author?: string; - contributors?: string[]; - homepage?: string; - - // Repository and issue tracking - repository?: string | Record; - bugs?: Record | string; - - // Package type and entry points - type?: string; - main?: string; - module?: string; - types?: string; - typings?: string; // deprecated, use types instead - exports?: Exports; - - // files, side effects, and bin - files?: string[]; - sideEffects?: boolean; - bin?: string | Record; - - // scripts - scripts?: Record; - - // dependencies - dependencies?: Record; - optionalDependencies?: Record; - peerDependencies?: Record; - peerDependenciesMeta?: Record; - devDependencies?: Record; - - // package manager, tools and environment - packageManager?: string; - engines?: Record; - os?: string[]; - cpu?: string[]; - - // monorepo management - workspaces?: string[] | { packages: string[] }; - resolutions?: Record; - - // tool configurations - furn?: RepoBuildConfig; - 'rnx-kit'?: KitConfig; - eslintConfig?: Record; - jest?: Record; - prettier?: Record; - babel?: Record; - lage?: Record; - - // publishing and distribution - publishConfig?: Record; -}; - -const defaultKeyOrder: string[] = [ - '$schema', - 'name', - 'displayName', - 'version', - 'stableVersion', - 'private', - 'description', - 'categories', - 'keywords', - 'homepage', - 'bugs', - 'repository', - 'funding', - 'license', - 'qna', - 'author', - 'maintainers', - 'contributors', - 'publisher', - 'sideEffects', - 'type', - 'imports', - 'exports', - 'main', - 'svelte', - 'umd:main', - 'jsdelivr', - 'unpkg', - 'module', - 'source', - 'jsnext:main', - 'browser', - 'react-native', - 'types', - 'typesVersions', - 'typings', - 'style', - 'example', - 'examplestyle', - 'assets', - 'bin', - 'man', - 'directories', - 'files', - 'workspaces', - 'binary', - 'scripts', - 'betterScripts', - 'l10n', - 'contributes', - 'activationEvents', - 'husky', - 'simple-git-hooks', - 'pre-commit', - 'commitlint', - 'lint-staged', - 'nano-staged', - 'config', - 'nodemonConfig', - 'browserify', - 'babel', - 'browserslist', - 'xo', - 'prettier', - 'eslintConfig', - 'eslintIgnore', - 'npmpkgjsonlint', - 'npmPackageJsonLintConfig', - 'npmpackagejsonlint', - 'release', - 'remarkConfig', - 'stylelint', - 'ava', - 'jest', - 'jest-junit', - 'jest-stare', - 'mocha', - 'nyc', - 'c8', - 'tap', - 'oclif', - 'resolutions', - 'overrides', - 'dependencies', - 'devDependencies', - 'dependenciesMeta', - 'peerDependencies', - 'peerDependenciesMeta', - 'optionalDependencies', - 'bundledDependencies', - 'bundleDependencies', - 'extensionPack', - 'extensionDependencies', - 'furn', - 'rnx-kit', - 'lage', - 'flat', - 'packageManager', - 'engines', - 'engineStrict', - 'devEngines', - 'volta', - 'languageName', - 'os', - 'cpu', - 'preferGlobal', - 'publishConfig', - 'icon', - 'badges', - 'galleryBanner', - 'preview', - 'markdown', - 'pnpm', -]; - -export type PackageRecordKeys = Extract< - keyof PackageManifest, - | 'dependencies' - | 'devDependencies' - | 'peerDependencies' - | 'peerDependenciesMeta' - | 'scripts' - | 'optionalDependencies' - | 'resolutions' - | 'exports' ->; - -const recordKeys: PackageRecordKeys[] = [ - 'dependencies', - 'devDependencies', - 'peerDependencies', - 'peerDependenciesMeta', - 'scripts', - 'optionalDependencies', - 'resolutions', - 'exports', -] as const; -type RecordValueType = T extends Record ? TValue : never; - -const scriptPath = normalizePath(path.join(path.dirname(fileURLToPath(import.meta.url)), '../..')); -const rootPath = path.dirname(scriptPath); - -const rootCache: Record = {}; - -/** - * Normalize a file path by replacing backslashes with forward slashes. - */ -export function normalizePath(p: string): string { - return path.normalize(p).replaceAll('\\', '/'); -} - -/** - * Returns a project root for the given path. This will load from a cache if available, and will throw if a package.json - * cannot be found at the given path. - * @param {string} [rootPath=process.cwd()] - * @returns {ProjectRoot} - */ -export function getProjectRoot(rootPath: string = process.cwd()): ProjectRoot { - const normalized = normalizePath(rootPath); - return (rootCache[normalized] ??= new ProjectRoot(normalized)); -} - -/** - * @returns {ProjectRoot} - */ -export function getScriptProjectRoot() { - return getProjectRoot(scriptPath); -} - -/** - * @returns {ProjectRoot} - */ -export function getRepoProjectRoot() { - return getProjectRoot(rootPath); -} - -/** - * Utilities for looking up information about a given package. This helps loading things like package.json multiple times - * in a single process and centralizes some functionality. - */ -export class ProjectRoot { - root: string; - - private _manifestText: string; - private _manifest: PackageManifest; - private _manifestKeys: string[]; - - cachedRequire: ReturnType | undefined = undefined; - - constructor(rootPath: string) { - const pkgJsonPath = path.join(rootPath, 'package.json'); - if (!fs.existsSync(pkgJsonPath)) { - throw new Error(`No package.json found at ${pkgJsonPath}`); - } - this._manifestText = fs.readFileSync(pkgJsonPath, 'utf-8'); - this._manifest = JSON.parse(this._manifestText) ?? {}; - this._manifestKeys = this.initKeys(this._manifest); - this.root = rootPath; - } - - get manifest(): Readonly { - return this._manifest; - } - - /** @returns {NodeRequire} - built on demand and cached require function */ - get require() { - return (this.cachedRequire ??= Module.createRequire(this.root)); - } - - /** - * Reload the manifest from disk. Returns true if the manifest changed since the last reload. - */ - reloadManifest(): boolean { - const pkgJsonPath = path.join(this.root, 'package.json'); - const newText = fs.readFileSync(pkgJsonPath, 'utf-8'); - const changed = newText !== this._manifestText; - if (changed) { - this._manifestText = newText; - this._manifest = JSON.parse(this._manifestText) ?? {}; - this._manifestKeys = this.initKeys(this._manifest); - } - return changed; - } - - /** - * Add or update an entry in the project manifest, maintaining key order. - */ - setManifestEntry(key: K, value: Required[K]): Required[K] { - this._manifest[key] = value; - if (!this._manifestKeys.includes(key)) { - const idealIndex = defaultKeyOrder.indexOf(key as string); - if (idealIndex >= 0) { - // find the first key after idealIndex that exists in _manifestKeys - for (let i = idealIndex + 1; i < defaultKeyOrder.length; i++) { - const nextKey = defaultKeyOrder[i]; - const existingIndex = this._manifestKeys.indexOf(nextKey); - if (existingIndex >= 0) { - // insert before existingIndex - this._manifestKeys.splice(existingIndex, 0, key); - return value; - } - } - } - // otherwise add the key to the end - this._manifestKeys.push(key); - } - return value; - } - - /** - * Remove an entry in the project manifest - */ - clearManifestEntry(key: K) { - delete this._manifest[key]; - const index = this._manifestKeys.indexOf(key); - if (index >= 0) { - this._manifestKeys.splice(index, 1); - } - } - - updateRecordEntry(recordKey: K, valueKey: string, value: RecordValueType | undefined) { - if (value !== undefined) { - const record = this.manifest[recordKey] ?? this.setManifestEntry(recordKey, {}); - record[valueKey] = value; - } else { - const existing = this.manifest[recordKey]; - if (existing && valueKey in existing) { - delete existing[valueKey]; - } - } - } - - writeManifest() { - // write the manifest to disk - const pkgJsonPath = path.join(this.root, 'package.json'); - this.prepManifestForWrite(); - fs.writeFileSync(pkgJsonPath, JSON.stringify(this._manifest, null, 2) + '\n', 'utf-8'); - } - - /** - * Open a module relative to this project root - */ - openModule(moduleName: string): ProjectRoot { - const pkgJsonPath = this.require.resolve(`${moduleName}/package.json`, { paths: [this.root] }); - return getProjectRoot(path.dirname(pkgJsonPath)); - } - - /** - * Get the path to a bin entry for a js package. - */ - getBinPath(command: string): string | undefined { - const bin = this.manifest.bin; - if (bin) { - const binRelative = typeof bin === 'string' ? bin : bin[command]; - if (binRelative) { - return normalizePath(path.join(this.root, binRelative)); - } - } - return undefined; - } - - private initKeys(manifest: PackageManifest) { - const keys: string[] = []; - for (const key of defaultKeyOrder) { - if (key in manifest) { - keys.push(key); - } - } - let prevIndex = -1; - for (const key of Object.keys(manifest)) { - const currentIndex = keys.indexOf(key); - if (!keys.includes(key)) { - // insert key in the first position after prevIndex - prevIndex++; - keys.splice(prevIndex, 0, key); - } else { - prevIndex = currentIndex; - } - } - return keys; - } - - get buildConfig(): RepoBuildConfig { - return { ...this.manifest.furn }; - } - - private prepManifestForWrite() { - for (const key of recordKeys) { - this.prepRecordEntryForWrite(key); - } - const reordered: Record = {}; - for (const key of this._manifestKeys) { - reordered[key] = this._manifest[key as keyof PackageManifest]; - } - this._manifest = reordered as PackageManifest; - } - - prepRecordEntryForWrite(key: K) { - const existingRecord = this.manifest[key]; - if (existingRecord) { - const keys = Object.keys(existingRecord); - if (keys.length === 0) { - this.clearManifestEntry(key); - return; - } - const orderedKeys = Object.keys(existingRecord).sort((a, b) => a.localeCompare(b)); - const newObj = Object.fromEntries(orderedKeys.map((key) => [key, existingRecord[key]])) as Required[K]; - this.setManifestEntry(key, newObj); - } - } -} diff --git a/scripts/src/utils/runScript.ts b/scripts/src/utils/runScript.ts index 50d60fdb90..fc8e446b6a 100644 --- a/scripts/src/utils/runScript.ts +++ b/scripts/src/utils/runScript.ts @@ -1,5 +1,5 @@ -import { spawn } from 'node:child_process'; -import { getProjectRoot } from './projectRoot.ts'; +import { spawn, type SpawnOptions } from 'node:child_process'; +import { PackageContext } from '../pkgContext.ts'; import os from 'node:os'; export const yarnVerb = os.platform() === 'win32' ? 'yarn.cmd' : 'yarn'; @@ -12,12 +12,12 @@ const cmdToModule: Record = { * Get the path to a bin entrypoint for a js package. */ function getBinPath(command: string): string | undefined { - const wdRoot = getProjectRoot(process.cwd()); + const wdRoot = PackageContext.init(process.cwd()); const cmdModule = cmdToModule[command] ?? command; return wdRoot.openModule(cmdModule).getBinPath(command); } -export async function runScript(command: string, ...args: string[]): Promise { +export async function runScript(command: string, args: string[], options?: SpawnOptions): Promise { const binPath = getBinPath(command); const verb = binPath ? process.execPath : yarnVerb; const spawnArgs = binPath ? [binPath, ...args] : ['exec', command, ...args]; @@ -27,6 +27,7 @@ export async function runScript(command: string, ...args: string[]): Promise { resolve(code ?? -1); }); diff --git a/scripts/targets/tsconfig.check.json b/scripts/targets/tsconfig.check.json index 4add80b804..a5dcaf12b0 100644 --- a/scripts/targets/tsconfig.check.json +++ b/scripts/targets/tsconfig.check.json @@ -1,6 +1,8 @@ { "extends": "@rnx-kit/tsconfig/tsconfig.node.json", "compilerOptions": { + "module": "nodenext", + "moduleResolution": "nodenext", "noEmit": true, "allowSyntheticDefaultImports": true, "target": "es2022", From 7b14257323f34f5dccd0962574ce7e6d74abf20a Mon Sep 17 00:00:00 2001 From: Jason Morse Date: Mon, 29 Jun 2026 16:21:32 -0700 Subject: [PATCH 2/4] fix Stack test (that wasn't running before) --- packages/components/Stack/package.json | 6 ++++-- .../Stack/src/__tests__/__snapshots__/Stack.test.tsx.snap | 6 +++--- yarn.lock | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/components/Stack/package.json b/packages/components/Stack/package.json index b860bed8ee..d31f1b6ec8 100644 --- a/packages/components/Stack/package.json +++ b/packages/components/Stack/package.json @@ -43,6 +43,7 @@ "@babel/core": "catalog:", "@fluentui-react-native/scripts": "workspace:*", "@fluentui-react-native/text": "workspace:*", + "@office-iss/react-native-win32": "^0.81.0", "@react-native-community/cli": "^20.0.0", "@react-native-community/cli-platform-android": "^20.0.0", "@react-native-community/cli-platform-ios": "^20.0.0", @@ -57,7 +58,7 @@ "react-test-renderer": "19.1.4" }, "peerDependencies": { - "@office-iss/react-native-win32": "^0.74.0 || ^0.81.0", + "@office-iss/react-native-win32": "^0.73.0 || ^0.74.0 || ^0.78.0 || ^0.81.0", "@types/react": "~18.2.0 || ~19.0.0 || ~19.1.4", "react": "18.2.0 || 19.0.0 || 19.1.4", "react-native": "^0.73.0 || ^0.74.0 || ^0.78.0 || ^0.81.6", @@ -79,7 +80,7 @@ } }, "furn": { - "jestPlatform": "android" + "jestPlatform": "win32" }, "rnx-kit": { "kitType": "library", @@ -91,6 +92,7 @@ "core-ios", "core-macos", "core-windows", + "core-win32", "react", "react-test-renderer" ] diff --git a/packages/components/Stack/src/__tests__/__snapshots__/Stack.test.tsx.snap b/packages/components/Stack/src/__tests__/__snapshots__/Stack.test.tsx.snap index c93c71bb55..cdf90f64c3 100644 --- a/packages/components/Stack/src/__tests__/__snapshots__/Stack.test.tsx.snap +++ b/packages/components/Stack/src/__tests__/__snapshots__/Stack.test.tsx.snap @@ -15,7 +15,7 @@ exports[`Stack with tokens 1`] = ` { "color": "#323130", "fontFamily": "Segoe UI", - "fontSize": 13, + "fontSize": 12, "fontWeight": "400", "margin": 0, } @@ -28,7 +28,7 @@ exports[`Stack with tokens 1`] = ` { "color": "#323130", "fontFamily": "Segoe UI", - "fontSize": 13, + "fontSize": 12, "fontWeight": "400", "margin": 0, "marginTop": 8, @@ -42,7 +42,7 @@ exports[`Stack with tokens 1`] = ` { "color": "#323130", "fontFamily": "Segoe UI", - "fontSize": 13, + "fontSize": 12, "fontWeight": "400", "margin": 0, "marginTop": 8, diff --git a/yarn.lock b/yarn.lock index b4719b5bd1..659006fb55 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4804,6 +4804,7 @@ __metadata: "@fluentui-react-native/scripts": "workspace:*" "@fluentui-react-native/text": "workspace:*" "@fluentui-react-native/tokens": "workspace:*" + "@office-iss/react-native-win32": "npm:^0.81.0" "@react-native-community/cli": "npm:^20.0.0" "@react-native-community/cli-platform-android": "npm:^20.0.0" "@react-native-community/cli-platform-ios": "npm:^20.0.0" @@ -4821,7 +4822,7 @@ __metadata: react-native-windows: "npm:^0.81.0" react-test-renderer: "npm:19.1.4" peerDependencies: - "@office-iss/react-native-win32": ^0.74.0 || ^0.81.0 + "@office-iss/react-native-win32": ^0.73.0 || ^0.74.0 || ^0.78.0 || ^0.81.0 "@types/react": ~18.2.0 || ~19.0.0 || ~19.1.4 react: 18.2.0 || 19.0.0 || 19.1.4 react-native: ^0.73.0 || ^0.74.0 || ^0.78.0 || ^0.81.6 From 38c23c3a5cfd1d5b526f69f68cf1e455663726dd Mon Sep 17 00:00:00 2001 From: Jason Morse Date: Mon, 29 Jun 2026 16:23:27 -0700 Subject: [PATCH 3/4] merge in changes and fix break --- packages/agentic-components/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/agentic-components/package.json b/packages/agentic-components/package.json index d249d873b8..0545ecf1ae 100644 --- a/packages/agentic-components/package.json +++ b/packages/agentic-components/package.json @@ -25,7 +25,6 @@ "scripts": { "build": "tsgo -b", "clean": "fluentui-scripts clean", - "depcheck": "fluentui-scripts depcheck", "format": "fluentui-scripts format", "lint": "fluentui-scripts lint", "test": "fluentui-scripts jest", From 5cff45222a984b6749bdc25ee0f0e1b88625a9e7 Mon Sep 17 00:00:00 2001 From: Jason Morse Date: Mon, 29 Jun 2026 16:24:44 -0700 Subject: [PATCH 4/4] add changeset --- .changeset/rare-files-cry.md | 77 ++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .changeset/rare-files-cry.md diff --git a/.changeset/rare-files-cry.md b/.changeset/rare-files-cry.md new file mode 100644 index 0000000000..f926bbcf89 --- /dev/null +++ b/.changeset/rare-files-cry.md @@ -0,0 +1,77 @@ +--- +"@uifabricshared/foundation-composable": patch +"@fluentui-react-native/experimental-appearance-additions": patch +"@uifabricshared/theming-react-native": patch +"@uifabricshared/foundation-settings": patch +"@fluentui-react-native/experimental-activity-indicator": patch +"@fluentui-react-native/experimental-native-font-metrics": patch +"@uifabricshared/foundation-compose": patch +"@fluentui-react-native/experimental-native-date-picker": patch +"@uifabricshared/foundation-tokens": patch +"@fluentui-react-native/themed-stylesheet": patch +"@uifabricshared/themed-settings": patch +"@fluentui-react-native/contextual-menu": patch +"@uifabricshared/theme-registry": patch +"@fluentui-react-native/vibrancy-view": patch +"@fluentui-react-native/focus-trap-zone": patch +"@fluentui-react-native/notification": patch +"@uifabricshared/theming-ramp": patch +"@fluentui-react-native/experimental-menu-button": patch +"@fluentui-react-native/interactive-hooks": patch +"@fluentui-react-native/persona-coin": patch +"@fluentui-react-native/menu-button": patch +"@fluentui-react-native/radio-group": patch +"@fluentui-react-native/experimental-checkbox": patch +"@fluentui-react-native/dropdown": patch +"@fluentui-react-native/experimental-expander": patch +"@fluentui-react-native/overflow": patch +"@fluentui-react-native/composition": patch +"@fluentui-react-native/use-styling": patch +"@fluentui-react-native/android-theme": patch +"@fluentui-react-native/default-theme": patch +"@fluentui-react-native/theming-utils": patch +"@fluentui-react-native/focus-zone": patch +"@fluentui-react-native/pressable": patch +"@fluentui-react-native/separator": patch +"@fluentui-react-native/popover": patch +"@fluentui-react-native/experimental-shimmer": patch +"@fluentui-react-native/spinner": patch +"@fluentui-react-native/tooltip": patch +"@fluentui-react-native/use-tokens": patch +"@fluentui-react-native/theme-tokens": patch +"@fluentui-react-native/checkbox": patch +"@fluentui-react-native/experimental-avatar": patch +"@fluentui-react-native/drawer": patch +"@fluentui-react-native/experimental-shadow": patch +"@fluentui-react-native/framework": patch +"@fluentui-react-native/use-slots": patch +"@fluentui-react-native/apple-theme": patch +"@fluentui-react-native/theme-types": patch +"@fluentui-react-native/win32-theme": patch +"@fluentui-react-native/callout": patch +"@fluentui-react-native/divider": patch +"@fluentui-react-native/persona": patch +"@fluentui-react-native/tablist": patch +"@fluentui-react-native/use-slot": patch +"@fluentui-react-native/avatar": patch +"@fluentui-react-native/button": patch +"@fluentui-react-native/switch": patch +"@fluentui-react-native/badge": patch +"@fluentui-react-native/input": patch +"@fluentui-react-native/stack": patch +"@fluentui-react-native/chip": patch +"@fluentui-react-native/icon": patch +"@fluentui-react-native/link": patch +"@fluentui-react-native/menu": patch +"@fluentui-react-native/text": patch +"@fluentui-react-native/theme": patch +"@fluentui-react-native/framework-base": patch +"@fluentui/react-native": patch +"@fluentui-react-native/adapters": patch +"@fluentui-react-native/styling-utils": patch +"@fluentui-react-native/tokens": patch +"@fluentui-react-native/tester": patch +"@fluentui-react-native/codemods": patch +--- + +Remove depcheck script, allow jest to run tests with platform module suffixes