diff --git a/.circleci/scripts/highlights/README.md b/.circleci/scripts/highlights/README.md
deleted file mode 100644
index f5c5952b..00000000
--- a/.circleci/scripts/highlights/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-### highlights
-
-the purpose of this directory is to house utilities for generating "highlight" messages for the metamaskbot comment based on changes included in the PR
diff --git a/.circleci/scripts/highlights/index.js b/.circleci/scripts/highlights/index.js
deleted file mode 100644
index 5ed891e5..00000000
--- a/.circleci/scripts/highlights/index.js
+++ /dev/null
@@ -1,31 +0,0 @@
-const { promisify } = require('util');
-const exec = promisify(require('child_process').exec);
-const storybook = require('./storybook.js');
-
-module.exports = { getHighlights };
-
-async function getHighlights({ artifactBase }) {
- let highlights = '';
- // here we assume the PR base branch ("target") is `develop` in lieu of doing
- // a query against the github api which requires an access token
- // see https://discuss.circleci.com/t/how-to-retrieve-a-pull-requests-base-branch-name-github/36911
- const changedFiles = await getChangedFiles({ target: 'develop' });
- console.log(`detected changed files vs develop:`);
- for (const filename of changedFiles) {
- console.log(` ${filename}`);
- }
- const announcement = await storybook.getHighlightAnnouncement({
- changedFiles,
- artifactBase,
- });
- if (announcement) {
- highlights += announcement;
- }
- return highlights;
-}
-
-async function getChangedFiles({ target }) {
- const { stdout } = await exec(`git diff --name-only ${target}...HEAD`);
- const changedFiles = stdout.split('\n').slice(0, -1);
- return changedFiles;
-}
diff --git a/.circleci/scripts/highlights/storybook.js b/.circleci/scripts/highlights/storybook.js
deleted file mode 100644
index abed67dd..00000000
--- a/.circleci/scripts/highlights/storybook.js
+++ /dev/null
@@ -1,91 +0,0 @@
-const path = require('path');
-const { promisify } = require('util');
-const exec = promisify(require('child_process').exec);
-const dependencyTree = require('dependency-tree');
-
-const cwd = process.cwd();
-const resolutionCache = {};
-
-// 1. load stories
-// 2. load list per story
-// 3. filter against files
-module.exports = {
- getHighlights,
- getHighlightAnnouncement,
-};
-
-async function getHighlightAnnouncement({ changedFiles, artifactBase }) {
- const highlights = await getHighlights({ changedFiles });
- if (!highlights.length) {
- return null;
- }
- const highlightsBody = highlights
- .map((entry) => `\n- [${entry}](${urlForStoryFile(entry, artifactBase)})`)
- .join('');
- const announcement = `
- storybook
- ${highlightsBody}
- \n\n`;
- return announcement;
-}
-
-async function getHighlights({ changedFiles }) {
- const highlights = [];
- const storyFiles = await getAllStories();
- // check each story file for dep graph overlap with changed files
- for (const storyFile of storyFiles) {
- const list = await getLocalDependencyList(storyFile);
- if (list.some((entry) => changedFiles.includes(entry))) {
- highlights.push(storyFile);
- }
- }
- return highlights;
-}
-
-async function getAllStories() {
- const { stdout } = await exec('find ui -name "*.stories.js"');
- const matches = stdout.split('\n').slice(0, -1);
- return matches;
-}
-
-async function getLocalDependencyList(filename) {
- const list = dependencyTree
- .toList({
- filename,
- // not sure what this does but its mandatory
- directory: cwd,
- webpackConfig: `.storybook/main.js`,
- // skip all dependencies
- filter: (entry) => !entry.includes('node_modules'),
- // for memoization across trees: 30s -> 5s
- visited: resolutionCache,
- })
- .map((entry) => path.relative(cwd, entry));
- return list;
-}
-
-function urlForStoryFile(filename, artifactBase) {
- const storyId = sanitize(filename);
- return `${artifactBase}/storybook/index.html?path=/story/${storyId}`;
-}
-
-/**
- * Remove punctuation and illegal characters from a story ID.
- * See:
- * https://gist.github.com/davidjrice/9d2af51100e41c6c4b4a
- * https://github.com/ComponentDriven/csf/blame/7ac941eee85816a4c567ca85460731acb5360f50/src/index.ts
- *
- * @param {string} string - The string to sanitize.
- * @returns The sanitized string.
- */
-function sanitize(string) {
- return (
- string
- .toLowerCase()
- // eslint-disable-next-line no-useless-escape
- .replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/giu, '-')
- .replace(/-+/gu, '-')
- .replace(/^-+/u, '')
- .replace(/-+$/u, '')
- );
-}
diff --git a/.circleci/scripts/metamaskbot-build-announce.js b/.circleci/scripts/metamaskbot-build-announce.js
index 0f94c9ff..a5e8695c 100755
--- a/.circleci/scripts/metamaskbot-build-announce.js
+++ b/.circleci/scripts/metamaskbot-build-announce.js
@@ -1,8 +1,5 @@
#!/usr/bin/env node
-const { promises: fs } = require('fs');
-const path = require('path');
const fetch = require('node-fetch');
-const { getHighlights } = require('./highlights');
start().catch((error) => {
console.error(error);
@@ -10,14 +7,12 @@ start().catch((error) => {
});
async function start() {
- const { GITHUB_COMMENT_TOKEN, CIRCLE_PULL_REQUEST } = process.env;
- console.log('CIRCLE_PULL_REQUEST', CIRCLE_PULL_REQUEST);
- const { CIRCLE_SHA1 } = process.env;
- console.log('CIRCLE_SHA1', CIRCLE_SHA1);
- const { CIRCLE_BUILD_NUM } = process.env;
- console.log('CIRCLE_BUILD_NUM', CIRCLE_BUILD_NUM);
- const { CIRCLE_WORKFLOW_JOB_ID } = process.env;
- console.log('CIRCLE_WORKFLOW_JOB_ID', CIRCLE_WORKFLOW_JOB_ID);
+ const {
+ GITHUB_COMMENT_TOKEN,
+ CIRCLE_PULL_REQUEST,
+ CIRCLE_SHA1,
+ CIRCLE_WORKFLOW_JOB_ID,
+ } = process.env;
if (!CIRCLE_PULL_REQUEST) {
console.warn(`No pull request detected for commit "${CIRCLE_SHA1}"`);
@@ -31,33 +26,11 @@ async function start() {
const storybookUrl = `${BUILD_LINK_BASE}/storybook/index.html`;
const storybookLink = `Storybook`;
- // link to artifacts
- const allArtifactsUrl = `https://circleci.com/gh/MetaMask/design-tokens/${CIRCLE_BUILD_NUM}#artifacts/containers/0`;
-
- const contentRows = [
- `storybook: ${storybookLink}`,
- `all artifacts`,
- ];
- const hiddenContent = `
${contentRows
- .map((row) => `- ${row}
`)
- .join('\n')}
`;
- const exposedContent = `Builds ready [${SHORT_SHA1}]`;
- const artifactsBody = `${exposedContent}
${hiddenContent} \n\n`;
-
- let commentBody = artifactsBody;
- try {
- const highlights = await getHighlights({ artifactBase: BUILD_LINK_BASE });
- if (highlights) {
- const highlightsBody = `### highlights:\n${highlights}\n`;
- commentBody += highlightsBody;
- }
- } catch (error) {
- console.error(`Error constructing highlight results: '${error}'`);
- }
+ const commentBody = `Builds ready [${SHORT_SHA1}]\n\nStorybook: ${storybookLink}`;
const JSON_PAYLOAD = JSON.stringify({ body: commentBody });
const POST_COMMENT_URI = `https://api.github.com/repos/metamask/design-tokens/issues/${CIRCLE_PR_NUMBER}/comments`;
- console.log(`Announcement:\n${commentBody}`);
+
console.log(`Posting to: ${POST_COMMENT_URI}`);
const response = await fetch(POST_COMMENT_URI, {