diff --git a/.pnpmfile.cjs b/.pnpmfile.cjs index d0ba5ccb874fb..e240885b44358 100644 --- a/.pnpmfile.cjs +++ b/.pnpmfile.cjs @@ -66,6 +66,9 @@ function fixDeps( pkg ) { '@use-gesture/react', 'use-memo-one', 'uuid', + // Needed for storybook to build with the /wp endpoint. Normal builds don't need them due to dependency extraction. + '@wordpress/date', + '@wordpress/hooks', ] ) { pkg.optionalDependencies[ dep ] = '*'; } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 499247870e0ff..f31b636042fbd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,7 +4,7 @@ settings: autoInstallPeers: false excludeLinksFromLockfile: false -pnpmfileChecksum: sha256-zCxWVmeqIVdzVzgWqWEctKVmBIozYb01nBTVlyTN+ps= +pnpmfileChecksum: sha256-vsSLfJFMcv7GYtNElbicbg3ukYfUNh3r8B4Wm2GpQv0= patchedDependencies: '@wordpress/dataviews': @@ -20698,6 +20698,8 @@ snapshots: '@emotion/utils': 1.4.2 '@floating-ui/react-dom': 2.1.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@use-gesture/react': 10.3.1(react@18.3.1) + '@wordpress/date': 5.19.0 + '@wordpress/hooks': 4.19.0 change-case: 4.1.2 colord: 2.9.3 date-fns: 3.6.0 @@ -20739,6 +20741,8 @@ snapshots: '@emotion/utils': 1.4.2 '@floating-ui/react-dom': 2.1.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@use-gesture/react': 10.3.1(react@18.3.1) + '@wordpress/date': 5.19.0 + '@wordpress/hooks': 4.19.0 change-case: 4.1.2 colord: 2.9.3 date-fns: 3.6.0 @@ -20780,6 +20784,8 @@ snapshots: '@emotion/utils': 1.4.2 '@floating-ui/react-dom': 2.1.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@use-gesture/react': 10.3.1(react@18.3.1) + '@wordpress/date': 5.19.0 + '@wordpress/hooks': 4.19.0 change-case: 4.1.2 colord: 2.9.3 date-fns: 3.6.0 diff --git a/projects/js-packages/scan/src/components/scan-report/index.tsx b/projects/js-packages/scan/src/components/scan-report/index.tsx index 16391109c4941..44d98e41c46bd 100644 --- a/projects/js-packages/scan/src/components/scan-report/index.tsx +++ b/projects/js-packages/scan/src/components/scan-report/index.tsx @@ -5,7 +5,7 @@ import { type Field, DataViews, filterSortAndPaginate, -} from '@wordpress/dataviews'; +} from '@wordpress/dataviews/wp'; import { __, _n } from '@wordpress/i18n'; import { Icon } from '@wordpress/icons'; import { useCallback, useMemo, useState } from 'react'; diff --git a/projects/js-packages/scan/src/components/threat-severity-badge/index.tsx b/projects/js-packages/scan/src/components/threat-severity-badge/index.tsx index 112ea50ecd43d..1b69d39bbd5f7 100644 --- a/projects/js-packages/scan/src/components/threat-severity-badge/index.tsx +++ b/projects/js-packages/scan/src/components/threat-severity-badge/index.tsx @@ -1,6 +1,6 @@ import { Badge } from '@automattic/jetpack-components'; import { __, sprintf } from '@wordpress/i18n'; -import { getSeverityLabel, getSeverityVariant } from '@automattic/jetpack-scan'; +import { getSeverityLabel, getSeverityVariant } from '../../utils/severity.js'; const ThreatSeverityBadge = ( { severity, showLabel = false } ) => { const title = getSeverityLabel( severity ); diff --git a/projects/js-packages/scan/src/components/threats-data-views/index.tsx b/projects/js-packages/scan/src/components/threats-data-views/index.tsx index bff6b30dee3f1..ec80db9a666c7 100644 --- a/projects/js-packages/scan/src/components/threats-data-views/index.tsx +++ b/projects/js-packages/scan/src/components/threats-data-views/index.tsx @@ -8,18 +8,15 @@ import { type View, DataViews, filterSortAndPaginate, -} from '@wordpress/dataviews'; +} from '@wordpress/dataviews/wp'; import { dateI18n } from '@wordpress/date'; import { __ } from '@wordpress/i18n'; import { Icon } from '@wordpress/icons'; import { useCallback, useContext, useMemo, useState } from 'react'; -import { - getThreatType, - THREAT_ACTION_FIX, - THREAT_ACTION_IGNORE, - ThreatsContext, - type Threat, -} from '@automattic/jetpack-scan'; +import { THREAT_ACTION_FIX, THREAT_ACTION_IGNORE } from '../../actions/index.js'; +import { ThreatsContext } from '../../context/index.js'; +import { type Threat } from '../../types/threats.js'; +import { getThreatType } from '../../utils/threats.js'; import ThreatFixerButton from '../threat-fixer-button/index.js'; import ThreatDetailsModal from '../threat-modals/details-modal/index.js'; import ThreatFixerModal from '../threat-modals/fixer-modal/index.js'; diff --git a/projects/js-packages/scan/src/components/threats-data-views/test/index.test.jsx b/projects/js-packages/scan/src/components/threats-data-views/test/index.test.jsx deleted file mode 100644 index 49f68132d853f..0000000000000 --- a/projects/js-packages/scan/src/components/threats-data-views/test/index.test.jsx +++ /dev/null @@ -1,82 +0,0 @@ -import { render, screen } from '@testing-library/react'; -import { ThreatsContextProvider } from '@automattic/jetpack-scan'; -import ThreatsDataViews from '../index.js'; - -const data = [ - // Scan API Data - { - id: 185869885, - signature: 'EICAR_AV_Test', - title: 'Malicious code found in file: index.php', - description: - "This is the standard EICAR antivirus test code, and not a real infection. If your site contains this code when you don't expect it to, contact Jetpack support for some help.", - firstDetected: '2024-10-07T20:45:06.000Z', - fixedIn: null, - fixedOn: '2024-10-07T20:45:06.000Z', - fixable: { fixer: 'rollback', target: 'January 26, 2024, 6:49 am', extensionStatus: '' }, - fixer: { - status: 'in_progress', - startedAt: '2024-10-07T20:45:06.000Z', - lastUpdated: '2024-10-07T20:45:06.000Z', - }, - severity: 8, - status: 'current', - filename: '/var/www/html/wp-content/index.php', - context: { - 1: 'echo << {}, - onFixThreats: () => {}, - onIgnoreThreats: () => {}, - onUnignoreThreats: () => {}, - isThreatEligibleForFix: () => true, - isThreatEligibleForIgnore: () => true, - isThreatEligibleForUnignore: () => true, - isUserConnected: true, - hasConnectedOwner: true, - userIsConnecting: false, - handleConnectUser: () => {}, - credentials: [], - credentialsIsFetching: false, - credentialsRedirectUrl: '/redirect-url', - onModalOpen: () => {}, - onModalClose: () => {}, -}; - -describe( 'ThreatsDataViews', () => { - it( 'renders threat data', () => { - render( - - - - ); - expect( screen.getByText( 'Malicious code found in file: index.php' ) ).toBeInTheDocument(); - expect( - screen.getByText( 'WooCommerce <= 3.2.3 - Authenticated PHP Object Injection' ) - ).toBeInTheDocument(); - } ); -} ); diff --git a/projects/js-packages/scan/tsconfig.json b/projects/js-packages/scan/tsconfig.json index ad9a26c4877f5..17a2fff4bcd52 100644 --- a/projects/js-packages/scan/tsconfig.json +++ b/projects/js-packages/scan/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "jetpack-js-tools/tsconfig.tsc.json", "include": [ "./src/**/*" ], + "exclude": [ "**/test/**", "**/stories/**" ], "compilerOptions": { "typeRoots": [ "./node_modules/@types/", "src/*" ], "sourceMap": false, diff --git a/projects/plugins/protect/webpack.config.js b/projects/plugins/protect/webpack.config.js index 0c65dfec146a7..0815336f45487 100644 --- a/projects/plugins/protect/webpack.config.js +++ b/projects/plugins/protect/webpack.config.js @@ -39,13 +39,56 @@ module.exports = [ * @see https://github.com/Automattic/jetpack/issues/39907 */ jetpackWebpackConfig.TranspileRule( { - includeNodeModules: [ '@wordpress/dataviews/' ], + includeNodeModules: [ '@wordpress/dataviews/build-wp/' ], babelOpts: { configFile: false, plugins: [ [ require.resolve( '@automattic/babel-plugin-replace-textdomain' ), - { textdomain: 'jetpack-protect' }, + { + textdomain: 'jetpack-protect', + functions: { + __: 1, + __1: 1, + __2: 1, + __3: 1, + __4: 1, + __5: 1, + __6: 1, + __7: 1, + __8: 1, + __9: 1, + __10: 1, + __11: 1, + __12: 1, + __13: 1, + __14: 1, + __15: 1, + __16: 1, + __17: 1, + __18: 1, + __19: 1, + __20: 1, + __21: 1, + __22: 1, + __23: 1, + __24: 1, + __25: 1, + __26: 1, + __27: 1, + __28: 1, + __29: 1, + __30: 1, + _x: 2, + _x1: 2, + _x2: 2, + _x3: 2, + _x4: 2, + _x5: 2, + _n: 3, + _nx: 4, + }, + }, ], ], },