Skip to content

Conversation

@paul90
Copy link
Member

@paul90 paul90 commented May 22, 2025

Converting the server to JavaScript.

Tests are converted first, and use of grunt to run mocha retained (for now), as it is configured to allow the use of a mix of CoffeeScript and JavaScript.

CoffeeScript files are renamed using git mv so we can follow the git blame path back to the original CoffeeScript.

Post convertion we should review each dependency, taking into account advances in JavaScript and Node.

This is a restart of PR195 due to some strangeness with preservation of git history over the conversion.

@paul90
Copy link
Member Author

paul90 commented May 22, 2025

At this point, with all the tests converted, we can run grunt or grunt watch as each Coffeescript file is decaffeinated.

@paul90
Copy link
Member Author

paul90 commented May 25, 2025

Currently no tests for search, but the serialised index file before and after decaffienation are identical so that suggests the code does the same thing.

@paul90
Copy link
Member Author

paul90 commented May 27, 2025

while all the tests pass, there are a few things that don't work.

paul90 added 5 commits May 28, 2025 10:51
- Remove used variables and parameters.
- The code to remove the update flag had dropped outside an `else` block, add the missing {}.
fix the pair-wise splitting of lineup url into pages and locations
fix the reversed element / index in iterating of the entries in urlPages
Add update author script, with prior authors
Add require for should to test, that use it
Make async tests async, and await supertest requests
Remove grunt file, and related packages
The server used in the tests will continue running until the sitemap time ends. Add an arg for testing to use a much shorter timeout.
@paul90
Copy link
Member Author

paul90 commented May 28, 2025

Grunt has now been removed. Tests are run with npm run test. If c8 is installed, coverage can be seen with c8 -r 'lcov' npm run test.

paul90 added 5 commits June 1, 2025 12:02
remove {}’s so name is returned.
should hasn’t been archived, so replace with node’s builtin assert.
add support for `node —test`, this is not ready as there appears to be a timeout issue causing describe to fail even though all the tests have passed.
In `lib/server.js`, don’t set a default `process.exitCode` when running tests. So the tests don't report a failure when the server is closed.

In `lib/sitemap.js`, the sitemap timeout is not relevant for the test environment.
The changes in this commit focus on improving the asynchronous behavior of the page tests. The main changes are:

- Refactor the tests to use `async/await` syntax for better readability and error handling.
- Add `return new Promise` blocks to ensure the tests wait for callbacks to complete.
@paul90 paul90 marked this pull request as ready for review June 18, 2025 04:57
@paul90
Copy link
Member Author

paul90 commented Jun 24, 2025

Express.js updated to v5, and node-fetch replaced with native Fetch.

also fixed CoffeeScript template literals that were missed.

@paul90
Copy link
Member Author

paul90 commented Jul 8, 2025

Use of glob replaced with use of node's Modules: CommonJS, this will change at some point when we switch to ECMAScript modules.
Replace deprecated Node API, and the use of the Async package.

@paul90 paul90 merged commit 71c867f into main Jul 16, 2025
4 checks passed
@paul90 paul90 deleted the decaffeinate branch July 16, 2025 09:24
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