speedtest/DEVELOPMENT.md
sstidl cb265a2d91
add eslinter, update github actions (stale issues, dependabot), optimize docker image (#728)
* Create stale.yml

* Configure Dependabot for GitHub Actions and Docker

Added support for GitHub Actions and Docker updates.

* Bump actions/stale from 5 to 10

Bumps [actions/stale](https://github.com/actions/stale) from 5 to 10.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v5...v10)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-version: '10'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump actions/checkout from 4 to 6

Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump docker/build-push-action from 5 to 6

Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5 to 6.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v5...v6)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* typo

* Add npm package manager with development tooling and improve Docker builds (#5)

* Initial plan

* Add npm package manager with development tooling

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Add package manager investigation summary

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Improve Docker build process and analyze PHP package manager needs

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Fix documentation based on code review feedback

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Initial plan

* Add npm package manager with development tooling

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Add package manager investigation summary

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Improve Docker build process and analyze PHP package manager needs

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Fix documentation based on code review feedback

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Restore Dockerfile.alpine to dev version (re-enable php-apache2)

* Remove redundant docker-php-extension-installer from Dockerfile.alpine

* remove useless ai files

* typo

* Initial plan

* Initial plan

* Improve Docker build process and analyze PHP package manager needs

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* remove useless ai files

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
Co-authored-by: Stefan Stidl <stefan.stidl@ffg.at>

* Update .github/workflows/stale.yml

Co-authored-by: qodo-merge-for-open-source[bot] <189517486+qodo-merge-for-open-source[bot]@users.noreply.github.com>

* Update Dockerfile.alpine

Co-authored-by: qodo-merge-for-open-source[bot] <189517486+qodo-merge-for-open-source[bot]@users.noreply.github.com>

* Update .github/workflows/stale.yml

Co-authored-by: qodo-merge-for-open-source[bot] <189517486+qodo-merge-for-open-source[bot]@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Stefan Stidl <stefan.stidl@ffg.at>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
Co-authored-by: qodo-merge-for-open-source[bot] <189517486+qodo-merge-for-open-source[bot]@users.noreply.github.com>
2025-12-06 18:47:56 +01:00

122 lines
2.9 KiB
Markdown

# Development Guide
This document describes how to use the package manager (npm) for development tasks.
## Prerequisites
- Node.js 14.0.0 or higher
- npm (comes with Node.js)
## Getting Started
Install development dependencies:
```bash
npm install
```
## Available Scripts
### Linting
Check code for potential issues:
```bash
npm run lint
```
Automatically fix linting issues where possible:
```bash
npm run lint:fix
```
### Code Formatting
Check code formatting (JavaScript files only):
```bash
npm run format:check
```
Format JavaScript files:
```bash
npm run format
```
> **Note**: The existing codebase uses its original formatting style. Prettier and ESLint are provided as optional tools for new code or improvements.
### Validation
Run all checks (formatting and linting):
```bash
npm run validate
```
### Testing
Currently, there are no automated tests configured:
```bash
npm run test
```
### Docker
Build Docker images:
```bash
npm run docker:build # Standard Debian-based image
npm run docker:build-alpine # Alpine-based image
```
## Development Tools
The package manager setup includes:
- **ESLint**: JavaScript linting tool to catch common errors
- **Prettier**: Code formatting tool to maintain consistent style
These tools are configured but non-intrusive to the existing codebase.
## Project Structure
```
.
├── speedtest.js # Main speedtest library
├── speedtest_worker.js # Web Worker for speed testing
├── index.html # Default UI
├── backend/ # PHP backend files
├── examples/ # Example implementations
├── results/ # Results/telemetry handling
├── docker/ # Docker-related files
└── package.json # npm package configuration
```
## Why Use a Package Manager?
The package manager provides several benefits:
1. **Standardized tooling**: Common commands across different environments
2. **Development dependencies**: Easy installation of linting and formatting tools
3. **Project metadata**: Version, description, and licensing information
4. **Future extensibility**: Foundation for adding build tools, tests, or bundlers if needed
5. **npm distribution**: Makes the library easy to use in other Node.js projects
## Contributing
When making changes:
1. Run `npm run lint` to check for potential issues
2. Consider running `npm run format` on new files for consistency
3. Test your changes manually in a browser
4. For PHP backend changes, test with the appropriate server setup
## Notes
- The core library has **no runtime dependencies** - it's pure vanilla JavaScript
- Development dependencies (ESLint, Prettier) are only needed for development
- The library can still be used standalone without npm (just include the JS files)
- npm setup is completely optional and doesn't change how the library is deployed