Commit Graph

82 Commits

Author SHA1 Message Date
Girish Ramakrishnan 96dc79cfe6 Migrate codebase from CommonJS to ES Modules
- Convert all require()/module.exports to import/export across 260+ files
- Add "type": "module" to package.json to enable ESM by default
- Add migrations/package.json with "type": "commonjs" to keep db-migrate compatible
- Convert eslint.config.js to ESM with sourceType: "module"
- Replace __dirname/__filename with import.meta.dirname/import.meta.filename
- Replace require.main === module with process.argv[1] === import.meta.filename
- Remove 'use strict' directives (implicit in ESM)
- Convert dynamic require() in switch statements to static import lookup maps
  (dns.js, domains.js, backupformats.js, backupsites.js, network.js)
- Extract self-referencing exports.CONSTANT patterns into standalone const
  declarations (apps.js, services.js, locks.js, users.js, mail.js, etc.)
- Lazify SERVICES object in services.js to avoid circular dependency TDZ issues
- Add clearMailQueue() to mailer.js for ESM-safe queue clearing in tests
- Add _setMockApp() to ldapserver.js for ESM-safe test mocking
- Add _setMockResolve() wrapper to dig.js for ESM-safe DNS mocking in tests
- Convert backupupload.js to use dynamic imports so --check exits before
  loading the module graph (which requires BOX_ENV)
- Update check-install to use ESM import for infra_version.js
- Convert scripts/ (hotfix, release, remote_hotfix.js, find-unused-translations)
- All 1315 tests passing

Migration stats (AI-assisted using Cursor with Claude):
- Wall clock time: ~3-4 hours
- Assistant completions: ~80-100
- Estimated token usage: ~1-2M tokens

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-14 15:11:45 +01:00
Girish Ramakrishnan 5276321ade integrity: add integrity check fields and initial UI 2026-02-08 23:26:57 +01:00
Girish Ramakrishnan 53de61330f remove debug 2025-10-01 10:09:32 +02:00
Girish Ramakrishnan 5dd5a20fc1 code -> sqlCode 2025-09-29 12:18:26 +02:00
Girish Ramakrishnan 12e073e8cf use node: prefix for requires
mostly because code is being autogenerated by all the AI stuff using
this prefix. it's also used in the stack trace.
2025-08-14 12:55:35 +05:30
Girish Ramakrishnan cbc73f5c9a remove uuid module
built into node.js now
2025-07-28 12:54:09 +02:00
Girish Ramakrishnan 1672217dd9 replace mysql module with mysql2
mysql is deprecated since years now
2025-06-19 12:41:49 +02:00
Girish Ramakrishnan 313c90ff85 database: change charset to utf8mb4
part of #836
2025-06-19 10:39:40 +02:00
Girish Ramakrishnan 84111996b4 database: some debugs 2025-06-19 10:12:59 +02:00
Girish Ramakrishnan 059547e37c test: set FOREIGN_KEY_CHECKS=1 after clearing 2025-06-11 15:35:00 +02:00
Johannes Zellner c6aef98361 Use SQL commands instead of mysql cli to clear tables for test 2025-06-10 11:47:05 +02:00
Girish Ramakrishnan 85ea71d9aa remove inline require 2025-05-20 09:59:48 +02:00
Girish Ramakrishnan df5ba25010 shell: add explicit bash() function 2024-10-16 10:40:17 +02:00
Girish Ramakrishnan 6c3ca9c364 shell: rework code to use shell.spawn
spawn gives out streams and we have more control over the stdout/stderr
buffers. otherwise, we have to provide a max buffer capture size to exec
2024-10-15 12:13:46 +02:00
Girish Ramakrishnan a9e1d7641d shell: make require take a tag 2024-10-14 21:08:32 +02:00
Girish Ramakrishnan 34969d9980 groups: bump group_concat_max_len to accomdate more users 2024-10-09 19:12:53 +02:00
Girish Ramakrishnan d12b2ae2db Revert "database: change db fields"
This reverts commit 0227ae1d96.

unclear why this doesn't work now
2024-06-03 10:37:59 +02:00
Girish Ramakrishnan 0227ae1d96 database: change db fields 2024-05-31 16:55:41 +02:00
Girish Ramakrishnan a6f078330f shell: no need to promise scoping 2024-02-21 19:40:27 +01:00
Girish Ramakrishnan cfd5c0f82b shell: rewrite exec to use execFile
this also renames execFile to execArgs
2024-02-21 18:54:43 +01:00
Girish Ramakrishnan 14c9260ab0 shell: exec encoding is utf8 by default and no shell
explicitly mark calls that require the shell
2024-02-21 17:47:25 +01:00
Girish Ramakrishnan 9b94cf18d0 convert more execSync to async 2024-02-21 11:00:12 +01:00
Girish Ramakrishnan 26eb739b46 shell: add options to exec 2024-02-20 21:11:09 +01:00
Girish Ramakrishnan 5beb7d7d92 Fix tests 2023-07-11 18:45:49 +05:30
Girish Ramakrishnan 94a196bfa0 Fix issue where only 25 group members were returned
This is because GROUP_CONCAT defaults to 1024. uuid is 40 chars.
1024/40 = ~25
2022-06-22 17:54:52 -07:00
Girish Ramakrishnan a74de3811b mysqldump: better detection of --column-statistics support
since it's also needed for ubuntu 22
2022-04-27 15:39:53 -07:00
Girish Ramakrishnan 4ffe03553a database: sqlMessage can be undefined for connection errors 2021-11-02 23:23:59 -07:00
Girish Ramakrishnan ac59a7dcc2 disable col stats in test mode (mysql 5.7) or non-ubuntu 20 2021-09-16 17:25:09 -07:00
Girish Ramakrishnan 9a2ed4f2c8 apptask: asyncify 2021-09-16 17:25:05 -07:00
Girish Ramakrishnan bb7eb6d50e database: remove callback support 2021-09-10 11:40:01 -07:00
Girish Ramakrishnan 51d067cbe3 sysinfo: async'ify
in the process, provision, dyndns, mail, dns also got further asyncified
2021-09-02 16:19:46 -07:00
Girish Ramakrishnan 77f5cb183b merge appdb.js into apps.js 2021-08-23 15:35:38 -07:00
Girish Ramakrishnan b6f2d6d620 Make database.initialize async 2021-08-23 15:20:14 -07:00
Girish Ramakrishnan 31d742fa67 fix sporadic ETIMEDOUT
it seems when docker is busy deleting images, we get a ETIMEDOUT.
the default was 10000.

2021-06-25T22:18:32.324Z box:apps BoxError: connect ETIMEDOUT
    at /home/yellowtent/box/src/settingsdb.js:26:36
    at Query.queryCallback [as _callback] (/home/yellowtent/box/src/database.js:96:42)
2021-06-25 16:46:49 -07:00
Girish Ramakrishnan bdbda9b80e transaction now returns a promise 2021-06-01 16:11:01 -07:00
Girish Ramakrishnan 3a252fe10e boxerror: override the properties directly 2021-05-11 17:50:40 -07:00
Girish Ramakrishnan 035f356dff add async support to database.query() 2021-05-02 23:18:07 -07:00
Girish Ramakrishnan 199eda82d1 Use Array.isArray instead 2021-05-02 11:26:47 -07:00
Girish Ramakrishnan 442110a437 lint 2021-05-01 11:21:09 -07:00
Girish Ramakrishnan 7cfc455cd3 make tests pass again
also disable column statistics on ubuntu 20
2020-07-10 09:33:35 -07:00
Girish Ramakrishnan 1c96fbb533 Fixes for tests 2020-07-03 13:47:56 -07:00
Girish Ramakrishnan 3dc163c33d database: rework connection logic 2020-07-03 13:14:00 -07:00
Girish Ramakrishnan d1ff8e9d6b Fix crash when mysql crashes 2020-07-02 15:10:05 -07:00
Girish Ramakrishnan 70743bd285 database: Fix event emitter warning
the connection object gets reused after release. this means that we keep
attaching the 'error' event and not unlistening.

--trace-warnings can be added to box.service to get the stack trace
2020-07-02 12:00:56 -07:00
Girish Ramakrishnan aabb9dee13 Fix transaction rollback logic 2020-06-11 09:50:49 -07:00
Girish Ramakrishnan 865a549885 say connected 2020-06-04 11:27:11 -07:00
Girish Ramakrishnan 50dcf827a5 remove console.error use in many places
the backtraces just flood the logs

apphealthtask: remove console.error
remove spurious console.dir
cleanup scheduler error logging
2020-06-04 11:21:56 -07:00
Girish Ramakrishnan aae49f16a2 database: do no reconnect in query 2020-06-04 09:17:58 -07:00
Girish Ramakrishnan 45d5f8c74d make rollback return an error
fixes #690
2020-06-04 09:17:58 -07:00
Girish Ramakrishnan 6cfd64e536 database: do not crash if connection errors
Part of #690
2020-06-04 09:17:58 -07:00