Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: duckduckgo/content-scope-scripts
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3.5.0
Choose a base ref
...
head repository: duckduckgo/content-scope-scripts
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Loading
Showing 1,756 changed files with 141,992 additions and 51,655 deletions.
16 changes: 16 additions & 0 deletions .cursorrules
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Content Scope Scripts - Cursor Rules

## Documentation References

When asked about Content Scope Scripts topics, refer to these documentation files:

- **API Reference**: `injected/docs/api-reference.md`
- **Feature Development**: `injected/docs/features-guide.md`
- **Platform Integration and engine support**: `injected/docs/platform-integration.md`
- **Development Utilities**: `injected/docs/development-utilities.md`
- **Testing**: `injected/docs/testing-guide.md`
- **Favicon**: `injected/docs/favicon.md`
- **Message Bridge**: `injected/docs/message-bridge.md`
- **Test Pages**: `injected/docs/test-pages-guide.md`
- **Documentation Index**: `injected/docs/README.md`
- **High-level Overview**: `injected/README.md`
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

17 changes: 0 additions & 17 deletions .eslintrc

This file was deleted.

7 changes: 7 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# .git-blame-ignore-revs
# Moved all packaged to root level https://github.com/duckduckgo/content-scope-scripts/pull/1103
f16b140c7731f9a66619e426b1f24414abaeb954
# Switched to a shared DDG ESLint config https://github.com/duckduckgo/content-scope-scripts/pull/1185
76bab4d80982ddab63265c694ab96c27a0fa5138
# introduced Prettier https://github.com/duckduckgo/content-scope-scripts/pull/1198
53818cc0152d4a814d170563145004b65f5d404d
6 changes: 3 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Sources/ContentScopeScripts/dist/** binary
build/** binary linguist-generated
shared/** binary linguist-generated
src/locales/** linguist-generated
src/types/* text eol=lf
* text=auto eol=lf
41 changes: 34 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
target-branch: "main"
labels:
- "dependencies"
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'weekly'
target-branch: 'main'
open-pull-requests-limit: 20
labels:
- 'dependencies'
groups:
eslint:
patterns:
- 'eslint*'
- '@typescript-eslint*'
stylelint:
patterns:
- 'stylelint*'
typescript:
patterns:
- 'typedoc'
- 'typescript'
- '@types/*'
- '@typescript-eslint*'
rollup:
patterns:
- '@rollup/*'
- 'rollup-*'
- 'rollup'
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'weekly'
target-branch: 'main'
labels:
- 'dependencies'
29 changes: 29 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
**Asana Task/Github Issue:** <!-- Link to Asana Task/Github Issue -->

## Description

<!--
Provide a terse summary of what the change is, detailed descriptions should belong in ship reviews or tech designs
-->

## Testing Steps

- <!-- Include simple steps on how to check this change is working. Write "N/A" if not applicable. -->

## Checklist

<!--
These questions are a friendly reminder to shipping code, if you're uncertain ask the AoR owners.
It's also totally appropriate to not check some of these boxes, if they don't apply to your change.
-->
*Please tick all that apply:*

- [ ] I have tested this change locally
- [ ] I have tested this change locally in all supported browsers
- [ ] This change will be visible to users
- [ ] I have added automated tests that cover this change
- [ ] I have ensured the change is gated by config
- [ ] This change was covered by a ship review
- [ ] This change was covered by a tech design
- [ ] Any dependent config has been merged

124 changes: 124 additions & 0 deletions .github/scripts/diff-directories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import fs from 'fs';
import path from 'path';

function readFilesRecursively(directory) {
const filenames = fs.readdirSync(directory);
const files = {};

filenames.forEach((filename) => {
const filePath = path.join(directory, filename);
const fileStats = fs.statSync(filePath);

if (fileStats.isDirectory()) {
const nestedFiles = readFilesRecursively(filePath);
for (const [nestedFilePath, nestedFileContent] of Object.entries(nestedFiles)) {
files[path.join(filename, nestedFilePath)] = nestedFileContent;
}
} else {
files[filename] = fs.readFileSync(filePath, 'utf-8');
}
});

return files;
}

function upperCaseFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}

function displayDiffs(dir1Files, dir2Files) {
const rollupGrouping = {};
/**
* Rolls up multiple files with the same diff into a single entry
* @param {string} fileName
* @param {string} string
* @param {string} [summary]
*/
function add(fileName, string, summary = undefined) {
if (summary === undefined) {
summary = string;
}
if (!(summary in rollupGrouping)) {
rollupGrouping[summary] = { files: [] };
}
rollupGrouping[summary].files.push(fileName);
rollupGrouping[summary].string = string;
}
for (const [filePath, fileContent] of Object.entries(dir1Files)) {
let diffOut = '';
let compareOut;
if (filePath in dir2Files) {
const fileOut = fileContent;
const file2Out = dir2Files[filePath];
delete dir2Files[filePath];
if (fileOut === file2Out) {
continue;
} else {
compareOut = filePath.split('/')[0];
diffOut = `File has changed`;
}
} else {
diffOut = '❌ File only exists in old changeset';
compareOut = 'Removed Files';
}
add(filePath, diffOut, compareOut);
}

for (const filePath of Object.keys(dir2Files)) {
add(filePath, '❌ File only exists in new changeset', 'New Files');
}
const outString = Object.keys(rollupGrouping)
.map((key) => {
const rollup = rollupGrouping[key];
let outString = `
`;
const title = key;
if (rollup.files.length) {
for (const file of rollup.files) {
outString += `- ${file}\n`;
}
}
outString += '\n\n' + rollup.string;
return renderDetails(title, outString);
})
.join('\n');
return outString;
}

function renderDetails(section, text) {
if (section === 'dist') {
section = 'apple';
}
const open = section !== 'integration' ? 'open' : '';
return `<details ${open}>
<summary>${upperCaseFirstLetter(section)}</summary>
${text}
</details>`;
}

if (process.argv.length !== 4) {
console.error('Usage: node diff_directories.js <directory1> <directory2>');
process.exit(1);
}

const dir1 = process.argv[2];
const dir2 = process.argv[3];

const sections = {};
function sortFiles(dirFiles, dirName) {
for (const [filePath, fileContent] of Object.entries(dirFiles)) {
sections[dirName] = sections[dirName] || {};
sections[dirName][filePath] = fileContent;
}
}

const buildDir = '/build';
const sourcesOutput = '/Sources/ContentScopeScripts/';
sortFiles(readFilesRecursively(dir1 + buildDir), 'dir1');
sortFiles(readFilesRecursively(dir2 + buildDir), 'dir2');
sortFiles(readFilesRecursively(dir1 + sourcesOutput), 'dir1');
sortFiles(readFilesRecursively(dir2 + sourcesOutput), 'dir2');

// console.log(Object.keys(files))
const fileOut = displayDiffs(sections.dir1, sections.dir2);
console.log(fileOut);
25 changes: 25 additions & 0 deletions .github/workflows/asana.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'asana sync'
on:
pull_request_review:
pull_request_target:
types:
- opened
- edited
- closed
- reopened
- synchronize
- review_requested

jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: duckduckgo/action-asana-sync@v11
with:
ASANA_ACCESS_TOKEN: ${{ secrets.ASANA_ACCESS_TOKEN }}
ASANA_WORKSPACE_ID: ${{ secrets.ASANA_WORKSPACE_ID }}
ASANA_PROJECT_ID: '1208598406046969'
GITHUB_PAT: ${{ secrets.GH_RO_PAT }}
USER_MAP: ${{ vars.USER_MAP }}
ASSIGN_PR_AUTHOR: 'true'
84 changes: 84 additions & 0 deletions .github/workflows/auto-respond-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Auto Respond to PR

on:
pull_request:
types: [opened, synchronize, closed, ready_for_review]

jobs:
auto_respond:
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest

steps:
- name: Checkout base branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
path: base

- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
path: pr
fetch-depth: 0

- name: Run build script on base branch
run: |
cd base
npm install
npm run build
cd ..
- name: Run build script on PR branch
run: |
cd pr
git config --global user.email "dax@duck.com"
git config --global user.name "dax"
echo ${{ github.event.pull_request.base.ref }}
git fetch origin ${{ github.event.pull_request.base.ref }}
git rebase -X theirs origin/${{ github.event.pull_request.base.ref }}
npm install
npm run build
cd ..
- name: Create diff of file outputs
run: |
node pr/.github/scripts/diff-directories.js base pr > diff.txt
- name: Find Previous Comment
uses: peter-evans/find-comment@v3
id: find_comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Generated file diff'
direction: last

- name: Create Comment Body
uses: actions/github-script@v7
id: create_body
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const prNumber = context.issue.number;
const diffOut = fs.readFileSync('diff.txt', 'utf8');
const commentBody = `
### *[Beta]* Generated file diff
*Time updated:* ${new Date().toUTCString()}
${diffOut}
`;
core.setOutput('comment_body', commentBody);
core.setOutput('pr_number', prNumber);
- name: Create, or Update the Comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find_comment.outputs.comment-id }}
body: ${{ steps.create_body.outputs.comment_body }}
edit-mode: replace
Loading