diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3f3c8099b..ab41c408b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: node-version-file: applications/browser-extension/package.json cache: npm - run: npm ci - - run: npm run test --workspaces -- --coverage + - run: npm run test:ci - uses: actions/upload-artifact@v4 with: name: extension-test-coverage diff --git a/applications/browser-extension/package.json b/applications/browser-extension/package.json index 6e1d9089f1..934418c13c 100644 --- a/applications/browser-extension/package.json +++ b/applications/browser-extension/package.json @@ -4,6 +4,7 @@ "description": "PixieBrix Browser Extension", "scripts": { "test": "TZ=UTC jest", + "test:ci": "TZ=UTC jest --coverage", "test:watch": "TZ=UTC jest --watchAll", "test:e2e": "playwright test", "test:e2e:debug": "PWDEBUG=console playwright test", @@ -40,7 +41,7 @@ "@fortawesome/react-fontawesome": "^0.2.2", "@mozilla/readability": "^0.5.0", "@pixiebrix/jq-web": "^0.5.1", - "@pixiebrix/utils": "*", + "@pixiebrix/util-debug": "*", "@reduxjs/toolkit": "^1.9.7", "@rjsf/bootstrap-4": "^5.22.3", "@rjsf/core": "^5.22.3", diff --git a/applications/browser-extension/src/pageEditor/hooks/useSaveMod.ts b/applications/browser-extension/src/pageEditor/hooks/useSaveMod.ts index 59c279fe77..e17a69ae90 100644 --- a/applications/browser-extension/src/pageEditor/hooks/useSaveMod.ts +++ b/applications/browser-extension/src/pageEditor/hooks/useSaveMod.ts @@ -31,7 +31,7 @@ import { type EditablePackageMetadata } from "@/types/contract"; /** * Returns a callback to show the appropriate save modal based on whether: - * - The mod have been saved yet + * - The mod has been saved yet * - The user has edit permissions for the mod */ function useSaveMod(): (modId: RegistryId) => Promise { @@ -81,6 +81,7 @@ function useSaveMod(): (modId: RegistryId) => Promise { return; } + // Must be available because of the isSuccess check. But Typescript can't infer that. assertNotNullish(registryQuery.data, "Expected data"); const { modDefinitions, editablePackages } = registryQuery.data; diff --git a/applications/browser-extension/src/pageEditor/modListingPanel/ModListItem.tsx b/applications/browser-extension/src/pageEditor/modListingPanel/ModListItem.tsx index 44142e75fa..6490eec1d7 100644 --- a/applications/browser-extension/src/pageEditor/modListingPanel/ModListItem.tsx +++ b/applications/browser-extension/src/pageEditor/modListingPanel/ModListItem.tsx @@ -53,6 +53,7 @@ const ModListItem: React.FC< const isModComponentSelected = activeModComponentId != null; const isModSelected = activeModId === modId && !isModComponentSelected; + const hasModBackground = activeModId === modId && isModComponentSelected; const isExpanded = expandedModId === modId; // TODO: Fix this so it pulls from registry, after registry single-item-api-fetch is implemented @@ -76,8 +77,8 @@ const ModListItem: React.FC< eventKey={modId} as={ListGroup.Item} className={cx(styles.root, "list-group-item-action", { - // Set the alternate background if a mod component in this mod is active - [styles.modBackground ?? ""]: isModSelected || isModComponentSelected, + // Set the alternate background for the mod if a mod component in this mod is active + [styles.modBackground ?? ""]: hasModBackground, })} tabIndex={0} // Avoid using `button` because this item includes more buttons #2343 active={isModSelected} diff --git a/applications/browser-extension/src/pageEditor/store/editor/editorSlice.ts b/applications/browser-extension/src/pageEditor/store/editor/editorSlice.ts index d46331bdfe..45ee7f145c 100644 --- a/applications/browser-extension/src/pageEditor/store/editor/editorSlice.ts +++ b/applications/browser-extension/src/pageEditor/store/editor/editorSlice.ts @@ -34,7 +34,7 @@ import { uuidv4 } from "@/types/helpers"; import { cloneDeep, compact, get, pull, uniq } from "lodash"; import { DataPanelTabKey } from "@/pageEditor/tabs/editTab/dataPanel/dataPanelTypes"; import { type TreeExpandedState } from "@/components/jsonTree/JsonTree"; -import { getInvalidPath } from "@pixiebrix/utils/src/debugUtils"; +import { getInvalidPath } from "@pixiebrix/util-debug"; import { selectActiveBrickConfigurationUIState, selectActiveBrickPipelineUIState, diff --git a/applications/browser-extension/src/pageEditor/tabs/modVersionHistory/ModVersionHistory.tsx b/applications/browser-extension/src/pageEditor/tabs/modVersionHistory/ModVersionHistory.tsx index 66e9b14064..4a84236095 100644 --- a/applications/browser-extension/src/pageEditor/tabs/modVersionHistory/ModVersionHistory.tsx +++ b/applications/browser-extension/src/pageEditor/tabs/modVersionHistory/ModVersionHistory.tsx @@ -123,6 +123,31 @@ function useModPackageVersionsQuery(modId: RegistryId): AsyncState<{ }, [modId, editablePackage, packageVersionsQuery, editablePackagesQuery]); } +const PackageVersionRow: React.VFC<{ version: PackageVersionDeprecated }> = ({ + version, +}) => { + const email = version.updated_by?.email; + + return ( + + {version.version} + {dateFormat.format(Date.parse(version.updated_at))} + + {email ? ( + {email} + ) : ( + Unknown + )} + + + {version.message ?? ( + No message provided + )} + + + ); +}; + const ModVersionHistory: React.FC = () => { const modId = useSelector(selectActiveModId); diff --git a/applications/browser-extension/tsconfig.json b/applications/browser-extension/tsconfig.json index 722e205152..5216f4ff79 100644 --- a/applications/browser-extension/tsconfig.json +++ b/applications/browser-extension/tsconfig.json @@ -17,7 +17,7 @@ // All project dependencies // TODO: add @nx/js plugin which will automatically update these paths { - "path": "../../libraries/utils" + "path": "../../libraries/util-debug" } ], "exclude": ["venv", "dist", "node_modules"] diff --git a/knip.mjs b/knip.mjs index 4555a20dfe..eeb9168298 100644 --- a/knip.mjs +++ b/knip.mjs @@ -36,8 +36,10 @@ const knipConfig = { ], }, "libraries/*": { - entry: "src/*.ts!", - project: "**/*.ts", + // ! suffix files are included in production mode + entry: "src/index.ts!", + project: ["src/**/*.ts!"], + ignore: ["src/lib/globals.d.ts"], }, "applications/browser-extension": { entry: [ diff --git a/libraries/utils/.eslintrc.js b/libraries/util-debug/.eslintrc.js similarity index 100% rename from libraries/utils/.eslintrc.js rename to libraries/util-debug/.eslintrc.js diff --git a/libraries/utils/jest.config.js b/libraries/util-debug/jest.config.js similarity index 100% rename from libraries/utils/jest.config.js rename to libraries/util-debug/jest.config.js diff --git a/libraries/utils/package.json b/libraries/util-debug/package.json similarity index 73% rename from libraries/utils/package.json rename to libraries/util-debug/package.json index 6fd0a5eabf..450ac49da5 100644 --- a/libraries/utils/package.json +++ b/libraries/util-debug/package.json @@ -1,16 +1,18 @@ { - "name": "@pixiebrix/utils", + "name": "@pixiebrix/util-debug", "version": "1.0.0", - "description": "PixieBrix Utility Library", + "description": "PixieBrix Debug Utility Library", "scripts": { "test": "TZ=UTC jest", + "test:ci": "TZ=UTC jest", "lint": "eslint src --ext js,jsx,ts,tsx --quiet --report-unused-disable-directives", "lint:fast": "ESLINT_NO_IMPORTS=1 eslint src --ext js,jsx,ts,tsx --quiet", "build": "tsc --build", "build:typecheck": "tsc --build" }, - "license": "AGPL-3.0", - "repository": "https://github.com/pixiebrix/pixiebrix-extension", + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "sideEffects": false, "dependencies": { "formik": "^2.4.6" }, diff --git a/libraries/util-debug/src/index.ts b/libraries/util-debug/src/index.ts new file mode 100644 index 0000000000..9fb236c5a0 --- /dev/null +++ b/libraries/util-debug/src/index.ts @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2024 PixieBrix, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +export * from "./lib/debugUtils"; diff --git a/libraries/utils/src/debugUtils.test.ts b/libraries/util-debug/src/lib/debugUtils.test.ts similarity index 100% rename from libraries/utils/src/debugUtils.test.ts rename to libraries/util-debug/src/lib/debugUtils.test.ts diff --git a/libraries/utils/src/debugUtils.ts b/libraries/util-debug/src/lib/debugUtils.ts similarity index 100% rename from libraries/utils/src/debugUtils.ts rename to libraries/util-debug/src/lib/debugUtils.ts diff --git a/libraries/utils/src/globals.d.ts b/libraries/util-debug/src/lib/globals.d.ts similarity index 100% rename from libraries/utils/src/globals.d.ts rename to libraries/util-debug/src/lib/globals.d.ts diff --git a/libraries/utils/tsconfig.json b/libraries/util-debug/tsconfig.json similarity index 100% rename from libraries/utils/tsconfig.json rename to libraries/util-debug/tsconfig.json diff --git a/libraries/utils/tsconfig.lib.json b/libraries/util-debug/tsconfig.lib.json similarity index 100% rename from libraries/utils/tsconfig.lib.json rename to libraries/util-debug/tsconfig.lib.json diff --git a/libraries/utils/tsconfig.test.json b/libraries/util-debug/tsconfig.test.json similarity index 84% rename from libraries/utils/tsconfig.test.json rename to libraries/util-debug/tsconfig.test.json index 7ab9490ad1..442c2ee211 100644 --- a/libraries/utils/tsconfig.test.json +++ b/libraries/util-debug/tsconfig.test.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "../../dist/out-tsc/libraries/utils", + "outDir": "../../dist/out-tsc/libraries/util-debug", "types": ["jest", "node"] }, "include": [ diff --git a/nx.json b/nx.json index 4235c0198a..30bf0d6e6c 100644 --- a/nx.json +++ b/nx.json @@ -7,6 +7,11 @@ "cache": true }, "test": { + "dependsOn": ["^build:typecheck"], + "cache": true + }, + "test:ci": { + "dependsOn": ["^build:typecheck"], "cache": true }, "lint": { diff --git a/package-lock.json b/package-lock.json index 6203d8ba00..184408d4f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,7 +44,7 @@ "@fortawesome/react-fontawesome": "^0.2.2", "@mozilla/readability": "^0.5.0", "@pixiebrix/jq-web": "^0.5.1", - "@pixiebrix/utils": "*", + "@pixiebrix/util-debug": "*", "@reduxjs/toolkit": "^1.9.7", "@rjsf/bootstrap-4": "^5.22.3", "@rjsf/core": "^5.22.3", @@ -309,10 +309,9 @@ "version": "0.0.1", "extraneous": true }, - "libraries/utils": { - "name": "@pixiebrix/utils", + "libraries/util-debug": { + "name": "@pixiebrix/util-debug", "version": "1.0.0", - "license": "AGPL-3.0", "dependencies": { "formik": "^2.4.6" }, @@ -4437,8 +4436,8 @@ "resolved": "https://registry.npmjs.org/@pixiebrix/jq-web/-/jq-web-0.5.1.tgz", "integrity": "sha512-q99g6J8UVsS7+pNlxyl01eDnUtHuYC9GPgKUXntpfs7akuqhkes9AZjC678LxjTC5BkjFtfOQazFQoyW/9/B/w==" }, - "node_modules/@pixiebrix/utils": { - "resolved": "libraries/utils", + "node_modules/@pixiebrix/util-debug": { + "resolved": "libraries/util-debug", "link": true }, "node_modules/@pkgjs/parseargs": { diff --git a/package.json b/package.json index 3056021b57..17fe4a612b 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ ], "scripts": { "test": "nx run-many -t test", + "test:ci": "nx run-many -t test:ci", "lint": "nx run-many -t lint", "build": "nx build", "build:typecheck": "nx run-many -t build:typecheck", diff --git a/pixiebrix-extension.iml b/pixiebrix-extension.iml index 96e4a0616e..eb7cb662e7 100644 --- a/pixiebrix-extension.iml +++ b/pixiebrix-extension.iml @@ -11,8 +11,8 @@ - + diff --git a/tsconfig.json b/tsconfig.json index ef27631278..c8cc45c34a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,7 @@ "path": "./applications/browser-extension" }, { - "path": "./libraries/utils" + "path": "./libraries/util-debug" } ] }