twofas / 2fas-browser-extension

Source code for 2FAS Browser Extension
https://2fas.com/browser-extension
GNU General Public License v3.0
247 stars 36 forks source link

feat: add documentation for contributors, including removing system-level assumptions #68

Closed globau closed 5 months ago

globau commented 6 months ago

Feature description

While I know Javascript, I generally don't follow the JS web ecosystem so I wasn't sure how to build the add-on in order to contribute. The current CONTRIBUTING.md simply says Make your changes with zero details about the build environment or requirements,.

Here's my journey through figuring things out and working around issues encountered.

  "scripts": {
    "clean": "rimraf --glob ./public/*",
    "chrome-dev": "yarn clean && yarn generate-locales && cross-env EXT_PLATFORM=Chrome node_modules/.bin/webpack --mode development --progress --config webpack/development.config.js",
…
$ npm run firefox-build
…
error 2fas-browser-extension@1.6.3: The engine "node" is incompatible with this module. Expected version "20.9.0". Got "21.6.2"
error Commands cannot run with an incompatible environment.
$ npm run firefox-build
…
Error: ENOENT: no such file or directory, mkdir './public/_locales'
    at Object.mkdirSync (node:fs:1379:3)
    at /Users/byron/dev/2fas-browser-extension/webpack/utils/generateLocales.js:65:10 {
  errno: -2,
  syscall: 'mkdir',
  code: 'ENOENT',
  path: './public/_locales'
}
$ npm run firefox-build
…
No target browser changes
 Webpack PROD Build [Firefox]
Failed to load /Users/byron/dev/2fas-browser-extension/.env.
[webpack-cli] Error: Missing environment variable: API_URL
$ npm run firefox-dev
…
 Webpack DEV Build [Firefox]
Failed to load /Users/byron/dev/2fas-browser-extension/.env.
[webpack-cli] Error: Missing environment variable: API_URL
$ npm run firefox-build
…
 Webpack PROD Build [Firefox]
[webpack-cli] Error: Missing environment variable: WS_URL
$ npm run firefox-build
…
 Webpack PROD Build [Firefox]
[webpack-cli] Error: Missing environment variable: LOCO_KEY
$ npm run firefox-build
…
`sh: powershell: command not found`
$ npm run firefox-build
…
Writing ./public/_locales, ./public/background, ./public/content, ./public/fonts, ./public/images, ./public/installPage, ./public/manifest.json, ./public/optionsPage to ./build/firefox_ext_%npm_package_version%.zip...
zip I/O error: No such file or directory
zip error: Could not create output file (./build/firefox_ext_%npm_package_version%.zip)
$ npm run firefox-build
…
✨  Done in 7.37s.
Writing . to ../build/firefox_ext_%npm_package_version%.zip...
zipped!
$ npm run firefox-build
…
✨  Done in 7.37s.
Writing . to ../build/firefox_ext_%npm_package_version%.zip...
zipped!

For completeness here's the changes I made to the Firefox specific lines in package.json

    "firefox-dev": "npx -y yarn clean && npx -y yarn generate-locales && npx -y cross-env EXT_PLATFORM=Firefox node_modules/.bin/webpack --mode development --progress --config webpack/development.config.js",
    "firefox-prod": "npx -y yarn clean && npx -y yarn generate-locales && npx -y update-browserslist-db@latest && npx -y cross-env EXT_PLATFORM=Firefox NODE_ENV=production node_modules/.bin/webpack --mode production --progress --config webpack/production.config.js",
    "firefox-build": "npx -y yarn firefox-prod && npx -y rimraf ./public/.gitkeep && cd public && npx -y bestzip ../build/firefox_ext_%npm_package_version%.zip .",
    "firefox-run": "npx -y web-ext run --source-dir ./public/",

In summary I recommend:

[edit]

Motivation

I want to fix a bug, found zero documentation on how to setup the development environment, as well as several incorrect system-level assumptions.

Acknowledgements

GrzegorzZajac000 commented 6 months ago

@globau Thank you for putting so much work into describing the problem. I agree that not everything was clear and the scripts were poorly prepared for external contributing. I made few changes. You can see them on branch feature/1.6.4.

FYI #67 will be fixed in next version ;)

GrzegorzZajac000 commented 5 months ago

Merged