Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/enforce-exhau…
Browse files Browse the repository at this point in the history
…stive-deps
  • Loading branch information
twschiller committed Nov 13, 2024
2 parents 2e518ac + 4712baa commit d50f4e2
Show file tree
Hide file tree
Showing 28 changed files with 93 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/beta-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
cache: npm
- run: npm ci
- run: npm run build
- run: bash scripts/upload-sourcemaps.sh
- run: bash applications/browser-extension/scripts/upload-sourcemaps.sh
env:
AWS_ACCESS_KEY_ID: ${{ secrets.SOURCEMAP_USER_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.SOURCEMAP_USER_KEY }}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,28 @@ jobs:
RELEASE_CHANNEL: stable
DATADOG_APPLICATION_ID: ${{ secrets.DATADOG_APPLICATION_ID }}
DATADOG_CLIENT_TOKEN: ${{ secrets.DATADOG_CLIENT_TOKEN }}
- run: bash scripts/upload-sourcemaps.sh
- run: bash applications/browser-extension/scripts/upload-sourcemaps.sh
env:
AWS_ACCESS_KEY_ID: ${{ secrets.SOURCEMAP_USER_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.SOURCEMAP_USER_KEY }}
AWS_DEFAULT_REGION: "us-east-2"
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
- name: Delete local sourcemaps
run: find dist -name '*.map' -delete
run: find applications/browser-extension/dist -name '*.map' -delete
- name: Save store extension
uses: actions/upload-artifact@v4
with:
name: build-for-store
path: dist
path: applications/browser-extension/dist
retention-days: 30
if-no-files-found: error
- name: Create production version
run: npx [email protected] dist/manifest.json key '${{ env.CHROME_MANIFEST_KEY }}'
run: npx [email protected] applications/browser-extension/dist/manifest.json key '${{ env.CHROME_MANIFEST_KEY }}'
- name: Save production extension
uses: actions/upload-artifact@v4
with:
name: build-production
path: dist
path: applications/browser-extension/dist
retention-days: 30
if-no-files-found: error

Expand Down
4 changes: 4 additions & 0 deletions .idea/nx-angular-config.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ repos:
rev: v3.1.0
hooks:
- id: prettier
additional_dependencies:
# mirrors-prettier won't receive updates after v3.1.0 because prettier changed their
# plugin system: "prettier made some changes that breaks plugins entirely"
# See: https://github.com/pre-commit/pre-commit/issues/3133
# The additional_dependencies aren't updated with `pre-commit autoupdate`
- [email protected]
# TODO: restore in https://github.com/pixiebrix/pixiebrix-extension/issues/9441
# - repo: local
# hooks:
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ coverage

# ignore libraries
node_modules
public/mockServiceWorker.js
**/public/mockServiceWorker.js

# ignore snapshots
**/*-snapshots/**
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export class PageEditorPage extends BasePageObject {
name: "Launch Template Gallery",
});

toastLocator = this.getByRole("status");

constructor(
page: Page,
private readonly urlToConnectTo: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ test("Add new mod with different starter brick components", async ({
page.getByRole("link", { name: "navigation" }),
);

// Check for https://github.com/pixiebrix/pixiebrix-extension/issues/9511
await expect(pageEditorPage.toastLocator).toBeHidden();

await expect(
pageEditorPage.getByText(modComponentNameMatcher),
).toBeVisible();
Expand Down
4 changes: 2 additions & 2 deletions applications/browser-extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pixiebrix/extension",
"version": "2.1.9-alpha.0",
"version": "2.2.1-alpha.0",
"description": "PixieBrix Browser Extension",
"scripts": {
"test": "TZ=UTC jest",
Expand Down Expand Up @@ -153,7 +153,6 @@
"slugify": "^1.6.6",
"stemmer": "^2.0.1",
"uint8array-extras": "^1.4.0",
"urlpattern-polyfill": "^5.0.3",
"use-async-effect": "^2.2.7",
"use-debounce": "^10.0.4",
"use-sync-external-store": "^1.2.2",
Expand Down Expand Up @@ -289,6 +288,7 @@
"type-fest": "^4.26.1",
"typescript": "^5.6.3",
"typescript-plugin-css-modules": "^5.1.0",
"urlpattern-polyfill": "^10.0.0",
"webpack": "^5.96.1",
"webpack-build-notifier": "^3.1.0",
"webpack-bundle-analyzer": "^4.10.2",
Expand Down
2 changes: 1 addition & 1 deletion applications/browser-extension/scripts/upload-extension.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ BUILD_FILENAME="${BUILD_PATH##*/}"
: "${AWS_SECRET_ACCESS_KEY?Need to set AWS_SECRET_ACCESS_KEY}"
: "${AWS_DEFAULT_REGION?Need to set AWS_DEFAULT_REGION}"

zip -r "$BUILD_FILENAME" dist -x '*.map'
zip -r "$BUILD_FILENAME" applications/browser-extension/dist -x '*.map'
aws s3 cp "$BUILD_FILENAME" "s3://pixiebrix-extension-builds/$BUILD_PATH" --no-progress
6 changes: 3 additions & 3 deletions applications/browser-extension/scripts/upload-sourcemaps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ set -e

# Upload to S3 for debugging in Chrome
S3_UPLOAD_BASE_URL="s3://pixiebrix-extension-source-maps/$SOURCE_MAP_PATH"
aws s3 cp ./dist "$S3_UPLOAD_BASE_URL" --exclude '*' --include '*.js.map' --include '*.js' --recursive --no-progress
aws s3 cp ./applications/browser-extension/dist "$S3_UPLOAD_BASE_URL" --exclude '*' --include '*.js.map' --include '*.js' --recursive --no-progress

# Datadog uses release-version, not the code commit version. So get from produced manifest
# Clean-up the name because it's not clear if the cli normalized the name like the JS library does
RELEASE_VERSION=$(jq -r '.version_name | gsub("\\+"; "_") | ascii_downcase' dist/manifest.json)
RELEASE_VERSION=$(jq -r '.version_name | gsub("\\+"; "_") | ascii_downcase' applications/browser-extension/dist/manifest.json)

# Should match the path that appears in minified stack trace
# See sourceMapPublicUrl in webpack.config.mjs
Expand All @@ -32,7 +32,7 @@ echo "Uploading sourcemaps to Datadog for version [[$RELEASE_VERSION]] with mini
# Reference: https://github.com/DataDog/datadog-ci/tree/master/src/commands/sourcemaps#commands
# `release-version` must match the version in initErrorReporter.ts and performance.ts
# project-path is the prefix before src in the map: webpack:///./src/bricks/registry.ts
npx --yes @datadog/datadog-ci sourcemaps upload ./dist \
npx --yes @datadog/datadog-ci sourcemaps upload ./applications/browser-extension/dist \
--service="pixiebrix-browser-extension" \
--release-version="$RELEASE_VERSION" \
--minified-path-prefix="$MINIFIED_PATH_PREFIX" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ function setVarsFromSchema({
const nodePath = [...parentPath, key];

const existence =
existenceOverride ?? required?.includes(key)
(existenceOverride ?? required?.includes(key))
? VarExistence.DEFINITELY
: VarExistence.MAYBE;

Expand Down Expand Up @@ -254,7 +254,7 @@ function setVarsFromSchema({
});
} else if (propertySchema.type === "array") {
const existence =
existenceOverride ?? required?.includes(key)
(existenceOverride ?? required?.includes(key))
? VarExistence.DEFINITELY
: VarExistence.MAYBE;

Expand Down Expand Up @@ -295,7 +295,7 @@ function setVarsFromSchema({
source,
path: [...parentPath, key],
existence:
existenceOverride ?? required?.includes(key)
(existenceOverride ?? required?.includes(key))
? VarExistence.DEFINITELY
: VarExistence.MAYBE,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export async function launchAuthIntegration({
"Integration did not return an OAuth2 context",
);

const refreshUrl = refreshToken ? oAuth2Context.tokenUrl ?? null : null;
const refreshUrl = refreshToken ? (oAuth2Context.tokenUrl ?? null) : null;

console.info("Setting partner auth for Control Room %s", controlRoomUrl);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const MarketplaceListingIcon: React.FC<{
color={
inheritColor
? "inherit"
: listing?.icon_color ?? DEFAULT_TEXT_ICON_COLOR
: (listing?.icon_color ?? DEFAULT_TEXT_ICON_COLOR)
}
className={faIconClass}
size={size}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ function lookupAuthId(

return dependency == null
? null
: authOptions.find(({ value }) => value === dependency.configId)?.value ??
null;
: (authOptions.find(({ value }) => value === dependency.configId)?.value ??
null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,14 @@ const initialValues: DatabaseConfig = {

function getOrganizationOptions(organizations: Team[]) {
const organizationOptions = (organizations ?? [])
.filter(
(organization) =>
organization.memberships?.some(
(member) =>
// If the current user is an admin of the organization, then all of the members are listed for the organization
// Otherwise, only the current user is listed for the organization
// So if any listed member is an admin, the current user is an admin
member.role === UserRole.admin,
),
.filter((organization) =>
organization.memberships?.some(
(member) =>
// If the current user is an admin of the organization, then all of the members are listed for the organization
// Otherwise, only the current user is listed for the organization
// So if any listed member is an admin, the current user is an admin
member.role === UserRole.admin,
),
)
.map((organization) => ({
label: organization.teamName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ const DatabaseWidget: React.FunctionComponent<SchemaFieldProps> = ({
// eslint-disable-next-line react-hooks/exhaustive-deps -- only run on mount
const initialFieldValue = useMemo(() => fieldValue, []);
const fullDatabaseOptions = useMemo(() => {
const loadedOptions = isLoadingDatabaseOptions ? [] : databaseOptions ?? [];
const loadedOptions = isLoadingDatabaseOptions
? []
: (databaseOptions ?? []);

// If the schema format is 'preview', and the initial field value is a string, use that string
// as the auto-created database name, and add it as an option to the database dropdown at the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ const ObjectFieldRow: React.FunctionComponent<RowProps> = ({
// As of v3, we allow object props of any type, not just string
const defaultSchema: Schema = {};
const rawSchema = defined
? parentSchema.properties?.[property] ?? defaultSchema
: parentSchema.additionalProperties ?? defaultSchema;
? (parentSchema.properties?.[property] ?? defaultSchema)
: (parentSchema.additionalProperties ?? defaultSchema);

return typeof rawSchema === "boolean" ? defaultSchema : rawSchema;
}, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ const SourceLabel: React.FunctionComponent<SourceLabelProps> = ({
}

default: {
const brickConfig = nodes.find((node) => node.path === source)
?.blockConfig;
const brickConfig = nodes.find(
(node) => node.path === source,
)?.blockConfig;
if (brickConfig == null) {
label = source;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ const RemoteMultiSelectWidget = <TOption extends Option<TOption["value"]>>({
} as ChangeEvent<MultiSelectLike<TOption>>);
};

const selectedOptions = options.filter(
(option: Option) => value?.includes(option.value),
const selectedOptions = options.filter((option: Option) =>
value?.includes(option.value),
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ function useSubmitPackage({ create = false }: SubmitOptions): SubmitCallbacks {
const { kind, metadata } = unsavedPackageJson;

try {
const data = await (create
? createPackage({ ...values, kind })
: updatePackage({ ...values, kind })
const data = await (
create
? createPackage({ ...values, kind })
: updatePackage({ ...values, kind })
).unwrap();

// We attach the handler below, and don't want it to block the save
Expand Down
1 change: 1 addition & 0 deletions applications/browser-extension/src/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ https://github.com/typescript-eslint/typescript-eslint/issues/3295#issuecomment-
*/

// We only use this package for its types. URLPattern is Chrome 95+
// See https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1199
/// <reference types="urlpattern-polyfill" />

// Improve standard type library https://www.totaltypescript.com/ts-reset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ import { StarterBrickTypes } from "@/types/starterBrickTypes";
import { openSidePanel } from "@/utils/sidePanelUtils";
import { useInsertPane } from "@/pageEditor/panes/insert/InsertPane";
import { type ModMetadata } from "@/types/modComponentTypes";
import { createNewUnsavedModMetadata } from "@/utils/modUtils";
import {
createNewUnsavedModMetadata,
emptyModVariablesDefinitionFactory,
} from "@/utils/modUtils";
import {
selectGetModDraftStateForModId,
selectModMetadatas,
Expand Down Expand Up @@ -123,14 +126,20 @@ function useAddNewModComponent(modMetadata?: ModMetadata): AddNewModComponent {
dispatch(actions.addModComponentFormState(initialFormState));
// Need to explicitly check availability of the new component form state
// TODO: https://github.com/pixiebrix/pixiebrix-extension/issues/9389
void dispatch(actions.checkActiveModComponentAvailability());
void dispatch(actions.checkAvailableDraftModComponents());

// Mod won't exist in getModDraftStateForModId (method will throw) because it captures the state
// from the render, not the current state of the store
const draftModState = modMetadata
? getModDraftStateForModId(initialFormState.modMetadata.id)
: {
variablesDefinition: emptyModVariablesDefinitionFactory(),
optionsArgs: {},
};

updateDraftModComponent(
allFramesInInspectedTab,
adapter.asDraftModComponent(
initialFormState,
getModDraftStateForModId(initialFormState.modMetadata.id),
),
adapter.asDraftModComponent(initialFormState, draftModState),
{
isSelectedInEditor: true,
runReason: RunReason.PAGE_EDITOR_REGISTER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function useAddBrick(): AddBrick {

return {};
},
[activeModComponent, getModDraftStateForModId, modalData, makeNewBrick],
[activeModComponent, modalData, makeNewBrick, getModDraftStateForModId],
);

const addBrick = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const selectActiveModComponentTraces: EditorSelector<TraceRecord[]> =
(activeModComponentId, modComponentTraces) =>
activeModComponentId
? // eslint-disable-next-line security/detect-object-injection -- UUID
modComponentTraces[activeModComponentId] ?? []
(modComponentTraces[activeModComponentId] ?? [])
: [],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ const sidebarSlice = createSlice({
-- Immer Draft<T> type resolution can't handle JsonObject (recursive) types properly
See: https://github.com/immerjs/immer/issues/839 */
// @ts-ignore-error -- SidebarEntries.panels --> PanelEntry.actions --> PanelButton.detail is JsonObject
initialEventKey ?? defaultEventKey(state, state.closedTabs);
(initialEventKey ?? defaultEventKey(state, state.closedTabs));
},
selectTab(state, action: PayloadAction<string>) {
// We were seeing some automatic calls to selectTab with a stale event key...
Expand Down
10 changes: 4 additions & 6 deletions applications/browser-extension/src/testUtils/permissionsMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,12 @@ browser.permissions = {
remove: jest
.fn()
.mockImplementation(async (toRemove: Permissions.AnyPermissions) => {
remove(
extensionPermissions.permissions,
(permission) => toRemove.permissions?.includes(permission),
remove(extensionPermissions.permissions, (permission) =>
toRemove.permissions?.includes(permission),
);
// XXX: only handles exact matches
remove(
extensionPermissions.origins,
(permission) => toRemove.origins?.includes(permission),
remove(extensionPermissions.origins, (permission) =>
toRemove.origins?.includes(permission),
);

for (const listener of removeListeners) {
Expand Down
Loading

0 comments on commit d50f4e2

Please sign in to comment.