Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added configuration option to choose between metric and imperial units. #143

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

jeremyakers
Copy link

Added configuration option to choose between metric and imperial units. Added section to config.md documenting this new flag as well.

@jeremyakers
Copy link
Author

Fixes #103

Copy link
Member

@linusg linusg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Please run npm run format:js and npm run format:md after making these changes :)

docs/config.md Outdated Show resolved Hide resolved
docs/config.md Outdated Show resolved Hide resolved
src/config.js Outdated Show resolved Hide resolved
src/util.js Outdated Show resolved Hide resolved
@jeremyakers jeremyakers requested a review from linusg January 2, 2025 08:16
Copy link
Member

@linusg linusg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still not formatted

@jeremyakers
Copy link
Author

jeremyakers commented Jan 2, 2025

Please run npm run format:js and npm run format:md after making these changes

I don't usually work with node so I didn't have npm set up on my machine. I was using the docker compose --build option to build to avoid needing npm. I did just try installing npm but that added 290 packages to my machine... it then expected eslint and a command called "prettier" to also be installed. I installed eslint but then it complains it cannot find my eslint config file:
ESLint looked for configuration files in /home/jeremy/github/owntracks-frontend/src and its ancestors. If it found none, it then looked in your home directory.

Looks like there's one in the root folder but the npm run format:js expects to find it under src? I could run eslint directly and add the -c flag maybe, but then why did I need to install all those npm packages?

However: I have never heard of "prettier" and it doesn't seem to be available in standard apt repos:

 $ sudo apt install prettier
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package prettier

So i googled it and apparently I need to install this through npm itself according to https://prettier.io/docs/en/install.html -
$ npm install --save-dev --save-exact prettier

But then it complains:

$ npm run format:md

> [email protected] format:md
> prettier --write '{*.md,docs/**/*.md,src/**/*.md}'

prettier requires at least version 14 of Node, please upgrade

Seems the version of npm that ships with my version of Ubuntu (22.04) is only 8.5.1.

Bottom line: It's very unlikely that I'm going to have a working npm environment anytime soon so hopefully running these npm format commands is not critical...

@linusg
Copy link
Member

linusg commented Jan 2, 2025

it then expected eslint and a command called "prettier" to also be installed

You need this:

Run npm install to install dependencies

hopefully running these npm format commands is not critical...

It is, I won't merge the PR without it (and should set up CI that fails in that case).

@jeremyakers
Copy link
Author

jeremyakers commented Jan 2, 2025

It still doesn't work after doing npm install -

$ npm run format:js

> [email protected] format:js
> eslint --fix 'src/**/*.{js,vue}'

internal/modules/cjs/loader.js:818
  throw err;
  ^

Error: Cannot find module 'node:util'
Require stack:
- /home/jeremy/github/owntracks-frontend/node_modules/eslint/bin/eslint.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:85:18)
    at getErrorMessage (/home/jeremy/github/owntracks-frontend/node_modules/eslint/bin/eslint.js:67:18)
    at process.onFatalError (/home/jeremy/github/owntracks-frontend/node_modules/eslint/bin/eslint.js:123:3)
    at process.emit (events.js:314:20)
    at process._fatalException (internal/process/execution.js:165:25) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/jeremy/github/owntracks-frontend/node_modules/eslint/bin/eslint.js'
  ]
}

This is an awful lot of trouble for a linter. What formatting is off? Can't I just fix it by hand? I did make a conscious effort to try to match the formatting of the rest of the code, copying other blocks and using them as templates, etc.

@linusg
Copy link
Member

linusg commented Jan 2, 2025

Sounds like your Node.js is older than v16 (which is quite old) where node: module prefixes were introduced.

package.json Outdated Show resolved Hide resolved
@jeremyakers
Copy link
Author

Sounds like your Node.js is older than v16 (which is quite old) where node: module prefixes were introduced.

Right, because like I said: I'm not a Node.js dev. I didn't have Node.js installed at all prior to you asking me to run those format commands. I literally just ran apt install npm and that's what it installed. (I am on the most recent version of Pop_OS, 22.04, and the version of Node.js in those repos is v12.22.9) I have spent more time trying to get this format/lint process to run than I spent writing the actual code for the enhancement. Keep in mind I was able to make the code changes and test them without needing Node.js or npm being installed... that only took me maybe 2 hours... but I somehow need to install a full blown Node.js env just to "format" said code?

After a ton of googling and trying different install methods I finally managed to get Node and npm working. I just pushed the changes after running the format commands.

Copy link
Member

@linusg linusg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this work so far, I'll test this locally later today and tomorrow and make tweaks if necessary :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants