Skip to content

Commit

Permalink
Merge pull request MetaMask#19310 from MetaMask/Version-v10.32.0
Browse files Browse the repository at this point in the history
Version v10.32.0 RC
  • Loading branch information
danjm authored Jun 15, 2023
2 parents 1cea94c + bae279b commit b1ef4e7
Show file tree
Hide file tree
Showing 378 changed files with 22,255 additions and 15,489 deletions.
10 changes: 8 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ executors:
resource_class: medium+
environment:
NODE_OPTIONS: --max_old_space_size=2048
node-browsers-large:
docker:
- image: cimg/node:16.20-browsers
resource_class: large
environment:
NODE_OPTIONS: --max_old_space_size=2048
shellcheck:
docker:
- image: koalaman/shellcheck-alpine@sha256:dfaf08fab58c158549d3be64fb101c626abc5f16f341b569092577ae207db199
Expand Down Expand Up @@ -500,7 +506,7 @@ jobs:
- builds-test

prep-build-storybook:
executor: node-browsers-medium-plus
executor: node-browsers-large
steps:
- checkout
- attach_workspace:
Expand Down Expand Up @@ -551,7 +557,7 @@ jobs:
command: yarn verify-locales --quiet

test-storybook:
executor: node-browsers-medium-plus
executor: node-browsers-large
steps:
- checkout
- attach_workspace:
Expand Down
3 changes: 3 additions & 0 deletions .depcheckrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ ignores:
- 'improved-yarn-audit'
- 'nyc'
# storybook
- '@storybook/cli'
- '@storybook/core'
- '@storybook/addon-essentials'
- '@storybook/addon-a11y'
- '@storybook/addon-mdx-gfm'
- '@storybook/builder-webpack5'
- '@storybook/manager-webpack5'
- '@storybook/react-webpack5'
- 'storybook-dark-mode'
- '@whitespace/storybook-addon-html'
- 'react-syntax-highlighter'
Expand Down
177 changes: 177 additions & 0 deletions .github/scripts/label-prs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
import * as core from '@actions/core';
import { context, getOctokit } from '@actions/github';
import { GitHub } from '@actions/github/lib/utils';

main().catch((error: Error): void => {
console.error(error);
process.exit(1);
});

async function main(): Promise<void> {
const token = process.env.GITHUB_TOKEN;

if (!token) {
core.setFailed('GITHUB_TOKEN not found');
process.exit(1);
}

const octokit = getOctokit(token);

const headRef = context.payload.pull_request?.head.ref || '';

let issueNumber = await getIssueNumberFromPullRequestBody();
if (issueNumber === "") {
bailIfIsBranchNameInvalid(headRef);
bailIfIsNotFeatureBranch(headRef);
issueNumber = getIssueNumberFromBranchName(headRef);
}

if (Number(issueNumber) === 0) {
process.exit(0);
}

await updateLabels(octokit, issueNumber);
}

async function getIssueNumberFromPullRequestBody(): Promise<string> {
console.log("Checking if the PR's body references an issue...");

let ISSUE_LINK_IN_PR_DESCRIPTION_REGEX =
/(close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)\s#\d+/gi;

const prBody = await getPullRequestBody();

let matches = prBody.match(ISSUE_LINK_IN_PR_DESCRIPTION_REGEX);
if (!matches || matches?.length === 0) {
console.log(
'No direct link can be drawn between the PR and an issue from the PR body because no issue number was referenced.',
);
return "";
}

if (matches?.length > 1) {
console.log(
'No direct link can be drawn between the PR and an issue from the PR body because more than one issue number was referenced.',
);
return "";
}

const ISSUE_NUMBER_REGEX = /\d+/;
const issueNumber = matches[0].match(ISSUE_NUMBER_REGEX)?.[0] || '';

console.log(`Found issue number ${issueNumber} in PR body.`);

return issueNumber;
}

async function getPullRequestBody(): Promise<string> {
if (context.eventName !== 'pull_request') {
console.log('This action should only run on pull_request events.');
process.exit(1);
}

const prBody = context.payload.pull_request?.body || '';
return prBody;
}

function bailIfIsBranchNameInvalid(branchName: string): void {
const BRANCH_REGEX =
/^(main|develop|(ci|chore|docs|feat|feature|fix|perf|refactor|revert|style)\/\d*(?:[-](?![-])\w*)*|Version-v\d+\.\d+\.\d+)$/;
const isValidBranchName = new RegExp(BRANCH_REGEX).test(branchName);

if (!isValidBranchName) {
console.log('This branch name does not follow the convention.');
console.log(
'Here are some example branch names that are accepted: "fix/123-description", "feat/123-longer-description", "feature/123", "main", "develop", "Version-v10.24.2".',
);
console.log(
'No issue could be linked to this PR, so no labels were copied',
);

process.exit(0);
}
}

function bailIfIsNotFeatureBranch(branchName: string): void {
if (
branchName === 'main' ||
branchName === 'develop' ||
branchName.startsWith('Version-v')
) {
console.log(`${branchName} is not a feature branch.`);
console.log(
'No issue could be linked to this PR, so no labels were copied',
);
process.exit(0);
}
}

async function updateLabels(octokit: InstanceType<typeof GitHub>, issueNumber: string): Promise<void> {
interface ILabel {
name: string;
};

const owner = context.repo.owner;
const repo = context.repo.repo;

const issue = await octokit.rest.issues.get({
owner: owner,
repo: repo,
issue_number: Number(issueNumber),
});

const getNameFromLabel = (label: ILabel): string => label.name

const issueLabels = issue.data.labels.map(label => getNameFromLabel(label as ILabel));

const prNumber = context.payload.number;

const pr = await octokit.rest.issues.get({
owner: owner,
repo: repo,
issue_number: prNumber,
});

const startingPRLabels = pr.data.labels.map(label => getNameFromLabel(label as ILabel));

const dedupedFinalPRLabels = [
...new Set([...startingPRLabels, ...issueLabels]),
];

const hasIssueAdditionalLabels = !sortedArrayEqual(
startingPRLabels,
dedupedFinalPRLabels,
);
if (hasIssueAdditionalLabels) {
await octokit.rest.issues.update({
owner,
repo,
issue_number: prNumber,
labels: dedupedFinalPRLabels,
});
}
}

function getIssueNumberFromBranchName(branchName: string): string {
console.log('Checking if the branch name references an issue...');

let issueNumber: string;
if (branchName.split('/').length > 1) {
issueNumber = branchName.split('/')[1].split('-')[0];
} else {
issueNumber = branchName.split('-')[0];
}

console.log(`Found issue number ${issueNumber} in branch name.`);

return issueNumber;
}

function sortedArrayEqual(array1: string[], array2: string[]): boolean {
const lengthsAreEqual = array1.length === array2.length;
const everyElementMatchesByIndex = array1.every(
(value: string, index: number): boolean => value === array2[index],
);

return lengthsAreEqual && everyElementMatchesByIndex;
}
27 changes: 27 additions & 0 deletions .github/workflows/label-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Label PR

on:
pull_request:
types: [assigned, opened, edited, synchronize, reopened]

jobs:
label-pr:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Install Yarn
run: npm install -g yarn

- name: Install dependencies
run: yarn
5 changes: 0 additions & 5 deletions .iyarc
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# improved-yarn-audit advisory exclusions
GHSA-257v-vj4p-3w2h

# yarn berry's `yarn npm audit` script reports the following vulnerability but
# it is a false positive. The offending version of 'ws' that is installed is
# 7.1.1 and is included only via remote-redux-devtools which is a devDependency
GHSA-6fc8-4gx4-v693

# request library is subject to SSRF.
# addressed by temporary patch in .yarn/patches/request-npm-2.88.2-f4a57c72c4.patch
GHSA-p8p7-x288-28g6
37 changes: 20 additions & 17 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
const path = require('path');

const { ProvidePlugin } = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');

const { generateIconNames } = require('../development/generate-icon-names');

module.exports = {
core: {
builder: 'webpack5',
disableTelemetry: true,
},
features: {
buildStoriesJson: true,
},
features: { buildStoriesJson: true },
stories: [
'../ui/**/*.stories.js',
'../ui/**/*.stories.tsx',
Expand All @@ -23,19 +21,14 @@ module.exports = {
'@storybook/addon-knobs',
'./i18n-party-addon/register.js',
'storybook-dark-mode',
'@whitespace/storybook-addon-html'
'@whitespace/storybook-addon-html',
'@storybook/addon-mdx-gfm',
],
staticDirs: ['../app', './images'],
// Uses babel.config.js settings and prevents "Missing class properties transform" error
babel: async (options) => ({ overrides: options.overrides }),
// Sets env variables https://storybook.js.org/docs/react/configure/environment-variables/
env: async (config) => {
return {
...config,
// Creates the icon names environment variable for the component-library/icon/icon.js component
ICON_NAMES: generateIconNames(),
};
},
babel: async (options) => ({
overrides: options.overrides,
}),
webpackFinal: async (config) => {
config.context = process.cwd();
config.node = {
Expand All @@ -54,7 +47,10 @@ module.exports = {
os: false,
path: false,
stream: require.resolve('stream-browserify'),
_stream_transform: require.resolve('readable-stream/lib/_stream_transform.js'),
zlib: false,
_stream_transform: require.resolve(
'readable-stream/lib/_stream_transform.js',
),
};
config.module.strictExportPresence = true;
config.module.rules.push({
Expand Down Expand Up @@ -102,4 +98,11 @@ module.exports = {
);
return config;
},
docs: {
autodocs: true,
},
framework: {
name: '@storybook/react-webpack5',
options: {},
},
};
16 changes: 11 additions & 5 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/*
* The addParameters and addDecorator APIs to add global decorators and parameters, exported by the various frameworks (e.g. @storybook/react) and @storybook/client were deprecated in 6.0 and have been removed in 7.0.
Instead, use export const parameters = {}; and export const decorators = []; in your .storybook/preview.js. Addon authors similarly should use such an export in a preview entry file (see Preview entries).
* */
import React, { useEffect, useState } from 'react';
import { addDecorator, addParameters } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { Provider } from 'react-redux';
import configureStore from '../ui/store/store';
Expand All @@ -13,9 +17,9 @@ import { Router } from 'react-router-dom';
import { createBrowserHistory } from 'history';
import { _setBackgroundConnection } from '../ui/store/action-queue';
import MetaMaskStorybookTheme from './metamask-storybook-theme';
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';

addParameters({
export const parameters = {
backgrounds: {
default: 'default',
values: [
Expand All @@ -41,7 +45,7 @@ addParameters({
controls: {
expanded: true,
},
});
};

export const globalTypes = {
locale: {
Expand Down Expand Up @@ -117,4 +121,6 @@ const metamaskDecorator = (story, context) => {
);
};

addDecorator(metamaskDecorator);
export const decorators = [
metamaskDecorator,
];
2 changes: 1 addition & 1 deletion .storybook/test-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ const state = {
nextNonce: 71,
connectedStatusPopoverHasBeenShown: true,
swapsWelcomeMessageHasBeenShown: true,
defaultHomeActiveTabName: 'Assets',
defaultHomeActiveTabName: 'Tokens',
providerConfig: {
type: 'goerli',
ticker: 'ETH',
Expand Down
12 changes: 12 additions & 0 deletions .yarn/patches/@babel-core-npm-7.21.5-c72c337956.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/lib/index.js b/lib/index.js
index c991f62dc64553502e9911a7f21e77e008d7f438..e503c7494d21b13df85b10e1657b2af8ca4d964f 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -222,7 +222,6 @@ var _transform = require("./transform");
var _transformFile = require("./transform-file");
var _transformAst = require("./transform-ast");
var _parse = require("./parse");
-var thisFile = require("./index");
const version = "7.21.5";
exports.version = version;
const DEFAULT_EXTENSIONS = Object.freeze([".js", ".jsx", ".es6", ".es", ".mjs", ".cjs"]);
Loading

0 comments on commit b1ef4e7

Please sign in to comment.