Skip to content

Commit 46ffaf0

Browse files
committed
Switch from yarn to pnpm
wxt isn't compatible with yarn berry. See wxt-dev/wxt#945 wxt + yarn was causing problems generating the sources zip for Firefox. wxt also has problems with pnpm in a workspace environment. Downloading "private" packages doesn't work if because wxt uses npm pack to pull in those packages. npm pack doesn't work with the version name that is given to linked workspace packages: link:{relative-path}. I'll file an issue with wxt about this later, but for now I've written a hook in bandcamp-tempo-adjust/wxt.config.ts that regenerates the Firefox sources zip. Firefox sources zip generation for discogs-tempo-adjust isn't fixed in this commit. I'll get to that later. Also, a lot of references to yarn still exis in README.md. I'll also get to that later.
1 parent 44cf972 commit 46ffaf0

File tree

16 files changed

+13800
-17247
lines changed

16 files changed

+13800
-17247
lines changed

.yarn/releases/yarn-4.5.0.cjs

-925
This file was deleted.

.yarnrc.yml

-3
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
To build the package from the Firefox source code review zip, you can run:
2+
3+
```
4+
yarn
5+
yarn zip:firefox
6+
```

apps/bandcamp-tempo-adjust/package.json

+11-6
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@
1313
"build": "wxt build",
1414
"build:firefox": "wxt build --browser firefox --mv3",
1515
"zip": "wxt zip",
16-
"zip:firefox": "wxt zip --browser firefox",
16+
"zip:firefox": "wxt zip --browser firefox --mv3",
1717
"postinstall": "wxt prepare"
1818
},
1919
"dependencies": {
2020
"@json2csv/plainjs": "^7.0.6",
2121
"@tanstack/react-query": "^4.28.0",
2222
"@tanstack/react-query-devtools": "^4.28.0",
23-
"@tempo-adjust/permissions": "0.0.0",
24-
"@tempo-adjust/player-components": "0.0.0",
23+
"@tempo-adjust/permissions": "workspace:*",
24+
"@tempo-adjust/player-components": "workspace:*",
25+
"@tempo-adjust/theme-provider": "workspace:*",
26+
"@tempo-adjust/to-one-decimal": "workspace:*",
2527
"immer": "^9.0.17",
2628
"p-queue": "^8.0.1",
2729
"react": "^18.3.1",
@@ -31,19 +33,22 @@
3133
"webextension-polyfill": "^0.10.0"
3234
},
3335
"devDependencies": {
34-
"@testing-library/jest-dom": "^6.4.2",
35-
"@testing-library/react": "12",
36+
"@testing-library/jest-dom": "^6.6.2",
37+
"@testing-library/react": "^16.0.1",
3638
"@testing-library/user-event": "^14.5.2",
3739
"@types/chrome": "^0.0.202",
40+
"@types/fs-extra": "^11.0.4",
3841
"@types/json2csv": "^5.0.3",
3942
"@types/react": "^18.3.1",
4043
"@types/react-dom": "^18.3.1",
4144
"@types/webextension-polyfill": "^0.9.2",
4245
"@wxt-dev/module-react": "^1.1.1",
46+
"fast-glob": "^3.3.2",
4347
"fs-extra": "^11.2.0",
4448
"html-loader": "^3.1.0",
4549
"html-webpack-plugin": "^5.5.0",
4650
"jsdom": "^24.0.0",
51+
"jszip": "^3.10.1",
4752
"parcel": "2.0.0-canary.1728",
4853
"prettier": "^2.7.1",
4954
"rimraf": "^6.0.1",
@@ -61,5 +66,5 @@
6166
"@types/react": "18.3.1"
6267
},
6368
"browserslist": "> 0.5%, last 5 versions, not dead",
64-
"packageManager": "[email protected]"
69+
"packageManager": "[email protected]"
6570
}

apps/bandcamp-tempo-adjust/wxt.config.ts

+74-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { defineConfig } from 'wxt';
2+
import JSZip from 'jszip';
3+
import fs from 'fs-extra';
4+
import path from 'node:path';
5+
import glob from 'fast-glob';
26

37
export default defineConfig({
48
manifest: {
59
name: 'Bandcamp Tempo Adjust',
6-
version: '0.8.1',
10+
version: '1.0.0',
711
description:
812
'A browser extension to detect and adjust track tempo on Bandcamp',
913
browser_specific_settings: {
@@ -15,6 +19,75 @@ export default defineConfig({
1519
host_permissions: ['https://*.bcbits.com/stream/*'],
1620
permissions: ['storage'],
1721
},
22+
hooks: {
23+
'zip:sources:done': async (wxt, sourcesZipPath) => {
24+
console.log('\x1b[36mℹ\x1b[0m', 'Re-zipping sources...');
25+
26+
const projectDirName = path.basename(wxt.config.root);
27+
28+
/*
29+
* assumes that the workspace is structured like this:
30+
*
31+
* packages/
32+
* - package-a/
33+
* apps/
34+
* - app-a/ <- wxt.config.root
35+
*/
36+
const workspaceRoot = path.resolve(wxt.config.root, '../..');
37+
38+
const zip = new JSZip();
39+
40+
// zip the workspace root's pnpm-workspace.yaml
41+
zip.file(
42+
'pnpm-workspace.yaml',
43+
fs.readFileSync(path.resolve(workspaceRoot, 'pnpm-workspace.yaml'))
44+
);
45+
46+
// zip the workspace root's package.json
47+
zip.file(
48+
'package.json',
49+
fs.readFileSync(path.resolve(workspaceRoot, 'package.json'))
50+
);
51+
52+
// get all files in all packages
53+
const packageFiles = glob.sync('packages/**/*', {
54+
cwd: workspaceRoot,
55+
ignore: ['**/node_modules/**/*'],
56+
});
57+
58+
// get all files in the current app
59+
const appFiles = glob.sync(`apps/${projectDirName}/**/*`, {
60+
cwd: workspaceRoot,
61+
ignore: ['**/node_modules/**/*'],
62+
});
63+
64+
const files = [...packageFiles, ...appFiles];
65+
66+
for (const file of files) {
67+
const absolutePath = path.resolve(workspaceRoot, file);
68+
const content = fs.readFileSync(absolutePath);
69+
zip.file(file, content);
70+
}
71+
72+
await new Promise((resolve, reject) => {
73+
zip
74+
.generateNodeStream({
75+
type: 'nodebuffer',
76+
...(wxt.config.zip.compressionLevel === 0
77+
? { compression: 'STORE' }
78+
: {
79+
compression: 'DEFLATE',
80+
compressionOptions: {
81+
level: wxt.config.zip.compressionLevel,
82+
},
83+
}),
84+
})
85+
.pipe(fs.createWriteStream(sourcesZipPath))
86+
.on('error', reject)
87+
.on('close', resolve);
88+
});
89+
},
90+
},
1891
modules: ['@wxt-dev/module-react'],
1992
srcDir: 'src',
2093
});

apps/discogs-tempo-adjust/package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
"postinstall": "wxt prepare"
2121
},
2222
"dependencies": {
23-
"@tempo-adjust/player-components": "0.0.0",
23+
"@tempo-adjust/permissions": "workspace:*",
24+
"@tempo-adjust/player-components": "workspace:*",
25+
"@tempo-adjust/theme-provider": "workspace:*",
2426
"@types/react": "^18.3.1",
2527
"@types/react-dom": "^18.3.1",
2628
"classnames": "^2.5.1",
@@ -31,5 +33,6 @@
3133
"webextension-polyfill": "^0.10.0",
3234
"zustand": "^5.0.0-rc.2"
3335
},
34-
"type": "module"
36+
"type": "module",
37+
"packageManager": "[email protected]"
3538
}

package.json

+15-19
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@
88
"url": "https://github.com/azarbayejani/bandcamp-tempo-adjust.git"
99
},
1010
"scripts": {
11-
"check": "yarn workspaces foreach -A run tsc",
12-
"dev:bandcamp": "yarn workspace bandcamp-tempo-adjust dev",
13-
"dev:discogs": "yarn workspace discogs-tempo-adjust dev",
14-
"build": "yarn build-chrome && yarn build-firefox",
15-
"build-chrome": "yarn workspaces foreach -Ap --include '{bandcamp-tempo-adjust,discogs-tempo-adjust}' run build",
16-
"build-firefox": "yarn workspaces foreach -Ap --include '{bandcamp-tempo-adjust,discogs-tempo-adjust}' run build -b firefox --mv3",
17-
"zip": "yarn zip-chrome && yarn zip-firefox",
18-
"zip-chrome": "yarn workspaces foreach -Ap --include '{bandcamp-tempo-adjust,discogs-tempo-adjust}' run zip",
19-
"zip-firefox": "yarn workspaces foreach -Ap --include '{bandcamp-tempo-adjust,discogs-tempo-adjust}' run zip -b firefox --mv3"
11+
"preinstall": "npx only-allow pnpm",
12+
"check": "pnpm -r exec tsc",
13+
"dev:bandcamp": "pnpm --filter bandcamp-tempo-adjust dev",
14+
"dev:discogs": "pnpm --filter discogs-tempo-adjust dev",
15+
"build": "pnpm build-chrome && pnpm build-firefox",
16+
"build:chrome": "pnpm --filter './apps/**' build",
17+
"build:firefox": "pnpm --filter './apps/**' build -b firefox --mv3",
18+
"zip": "pnpm zip-chrome && pnpm zip-firefox",
19+
"zip:chrome": "pnpm --filter './apps/**' zip",
20+
"zip:firefox": "pnpm --filter './apps/**' zip -b firefox --mv3"
2021
},
2122
"dependencies": {
2223
"@json2csv/plainjs": "^7.0.6",
2324
"@tanstack/react-query": "^4.28.0",
2425
"@tanstack/react-query-devtools": "^4.28.0",
25-
"@tempo-adjust/permissions": "0.0.0",
26-
"@tempo-adjust/player-components": "0.0.0",
2726
"immer": "^9.0.17",
2827
"p-queue": "^8.0.1",
2928
"react": "^18.3.1",
@@ -33,8 +32,9 @@
3332
"webextension-polyfill": "^0.10.0"
3433
},
3534
"devDependencies": {
36-
"@testing-library/jest-dom": "^6.4.2",
37-
"@testing-library/react": "12",
35+
"@testing-library/dom": "^10.4.0",
36+
"@testing-library/jest-dom": "^6.6.2",
37+
"@testing-library/react": "^16.0.1",
3838
"@testing-library/user-event": "^14.5.2",
3939
"@types/chrome": "^0.0.202",
4040
"@types/json2csv": "^5.0.3",
@@ -62,16 +62,12 @@
6262
"style-loader": "^3.3.1",
6363
"terser-webpack-plugin": "^5.3.6",
6464
"typescript": "^5.6.3",
65-
"vitest": "^1.3.0",
65+
"vitest": "^2.1.3",
6666
"web-ext": "^7.11.0",
6767
"wxt": "^0.19.11"
6868
},
6969
"resolutions": {
7070
"@types/react": "18.3.1"
7171
},
72-
"packageManager": "[email protected]",
73-
"workspaces": [
74-
"packages/*",
75-
"apps/*"
76-
]
72+
"packageManager": "[email protected]"
7773
}

packages/permissions/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "@tempo-adjust/permissions",
3-
"packageManager": "[email protected]",
43
"type": "module",
54
"version": "0.0.0",
65
"main": "index.ts",

packages/player-components/Button.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const Button = ({
1919
disabled?: boolean;
2020
}) => {
2121
const theme = useTheme();
22-
console.log('THEME', theme);
2322
return (
2423
<button
2524
className={classnames(css.button, {
+4-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
{
22
"name": "@tempo-adjust/player-components",
3-
"packageManager": "[email protected]",
43
"type": "module",
54
"main": "index.ts",
65
"private": true,
76
"dependencies": {
7+
"@tempo-adjust/theme-provider": "workspace:*",
8+
"@tempo-adjust/to-one-decimal": "workspace:*",
89
"classnames": "^2.5.1"
910
},
1011
"devDependencies": {
1112
"typescript": "^5.6.3"
1213
},
13-
"version": "0.0.0"
14+
"version": "0.0.0",
15+
"packageManager": "[email protected]"
1416
}

packages/theme-provider/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "@tempo-adjust/theme-provider",
3-
"packageManager": "[email protected]",
43
"type": "module",
54
"main": "index.tsx",
65
"private": true,
76
"devDependencies": {
87
"typescript": "^5.6.3"
9-
}
8+
},
9+
"packageManager": "[email protected]"
1010
}

packages/theme-provider/tsconfig.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ESNext",
4+
"module": "ESNext",
5+
"moduleResolution": "Bundler",
6+
"noEmit": true,
7+
"esModuleInterop": true,
8+
"forceConsistentCasingInFileNames": true,
9+
"resolveJsonModule": true,
10+
"strict": true,
11+
"skipLibCheck": true,
12+
"allowImportingTsExtensions": true,
13+
"jsx": "react-jsx",
14+
"types": ["@testing-library/jest-dom"]
15+
}
16+
}

packages/to-one-decimal/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "@tempo-adjust/to-one-decimal",
3-
"packageManager": "[email protected]",
43
"type": "module",
54
"main": "index.ts",
65
"private": true,
76
"devDependencies": {
87
"typescript": "^5.6.3"
9-
}
8+
},
9+
"packageManager": "[email protected]"
1010
}

0 commit comments

Comments
 (0)