Commit Graph

203 Commits

Author SHA1 Message Date
Girish Ramakrishnan 2c559d63f5 Fix bugs in esm migration 2026-02-15 20:11:58 +01:00
Girish Ramakrishnan b5a1554631 Fix various linter errors 2026-02-15 19:37:30 +01:00
Girish Ramakrishnan e9f96593c3 reorder functions for no-use-before-define 2026-02-14 16:34:34 +01:00
Girish Ramakrishnan 36aa641cb9 migrate to "export default"
also, set no-use-before-define in linter
2026-02-14 15:43:24 +01:00
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 17b0c3e48d services: Graphite -> Metrics 2026-02-04 11:33:40 +01:00
Johannes Zellner b9af8ee6be Send the service name when listing services 2026-02-03 18:32:11 +01:00
Girish Ramakrishnan 03fe72e0b1 services: fix usage of pipework 2026-01-22 18:09:41 +01:00
Girish Ramakrishnan b238443a9d services: switch to using @cloudron/pipework
also improve the error messages along the way
2026-01-21 21:32:02 +01:00
Girish Ramakrishnan 021a39a964 services: destroy the read/write stream on error 2026-01-21 17:23:27 +01:00
Girish Ramakrishnan 6e9cd4c11b platform: give feedback on service being started 2025-11-28 12:54:22 +01:00
Girish Ramakrishnan de75ae5b9e collectd is gone 2025-11-24 13:50:07 +01:00
Girish Ramakrishnan 45d68c4da8 shell: set utf8 encoding explicity for spawn and as the default for sudo 2025-10-13 13:14:50 +02:00
Girish Ramakrishnan e45af9b611 sqlite: disable docker logging when backing up
The redirection > ${outputFile} applies to the docker run client process, not to the container itself.
The Docker daemon is still collecting the container’s stdout and logging it.

https://forum.cloudron.io/topic/13361/after-ubuntu-22-24-upgrade-syslog-getting-spammed-and-grows-way-to-much-clogging-up-the-diskspace/
2025-09-15 15:46:27 +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 989d843fcb shell: make shell.sudo promise based and waitable 2025-07-16 22:04:24 +02:00
Girish Ramakrishnan b42a51cc56 typo 2025-07-13 17:02:35 +02:00
Girish Ramakrishnan bf8a5e6a11 oidc: separate clients for oidc and proxyAuth
in e2e, our test app has both. in such cases, the auth fails because
the redirect URI does not match
2025-07-13 15:51:39 +02:00
Girish Ramakrishnan a7e507a137 oidc: some comments 2025-07-13 15:28:47 +02:00
Girish Ramakrishnan 6ac0cd421a use the @cloudron/superagent module 2025-07-10 10:56:05 +02:00
Girish Ramakrishnan 9f35801f64 docker: add options to getStats 2025-07-03 23:56:03 +02:00
Girish Ramakrishnan 6b8b69d324 metrics: rename functions 2025-07-01 11:10:21 +02:00
Girish Ramakrishnan 227da8dce4 test: remove double uninit of db 2025-06-19 10:24:17 +02:00
Girish Ramakrishnan 39cbfb84ae refactor: move moveDataDir into services 2025-06-14 21:18:56 +02:00
Girish Ramakrishnan 73a56830b0 apps: do not start redis when app is stopped
stopped apps stop the container and the services. a good reason to
not delete them is to keep the image around and it's quick to start up again.

only update is not allowed during the app is stopped (because the start.sh
cannot be run).

all other operations like cpu/memory/device/service changes/data dir/location change
are all allowed.
2025-06-14 21:03:10 +02:00
Girish Ramakrishnan d924f73ceb services: change restart policy to unless-stopped
when we stop an app, the service containers are stopped. they
start running again on reboot.

correct restart policy is "unless-stopped" for all the containers.
2025-06-14 17:51:35 +02:00
Girish Ramakrishnan 5d42439bf4 proxyauth: fix install 2025-06-13 02:05:04 +02:00
Johannes Zellner afd19a7307 Optionally take id from data when adding an oidcClient
clients for apps use the app.id as the client id
2025-06-12 22:29:11 +02:00
Girish Ramakrishnan 1ca8eeeb50 split oidc into server and clients 2025-06-11 22:26:23 +02:00
Girish Ramakrishnan f14fbfe087 turn: verbose logs in debug mode 2025-06-04 13:22:25 +02:00
Girish Ramakrishnan 446099b1f9 turn: add note on why we still use host mode 2025-06-04 13:11:12 +02:00
Girish Ramakrishnan 3770f07720 docker: rename function 2025-05-21 15:37:31 +02:00
Girish Ramakrishnan 8cdae41051 update container for auth free healthcheck
this allows us to check status from cloudron-support script more easily
2025-04-08 13:25:29 +02:00
Girish Ramakrishnan 5d88e86462 sendmail: add requiresValidCertificate
some apps really want a valid certificate to send mail and upstream
authors won't add support to skip self-signed certs or skip host name
check in cert. In our case, the issue is that we use 'mail' as the
server name despite having valid certs.

this flag will set the server name to the full mail server fqdn and
also reconfigure the app as needed when the mail server name changes.

we also set up the mail server name to resolve to internal IP because
no mail port is exposed when we are not receiving emails!
2025-03-08 13:15:53 +01:00
Girish Ramakrishnan a669144d16 graphite: static IP
this allows some predictible connectivity from apps to play around
2025-03-03 17:06:20 +01:00
Girish Ramakrishnan d3b10a6711 async not needed, they already return a promise 2025-02-18 14:03:09 +01:00
Girish Ramakrishnan 8e58349bfa replace with custom superagent based on fetch API 2025-02-15 15:14:09 +01:00
Girish Ramakrishnan e34e479c33 services: separate volume clear and rm 2025-01-12 18:08:53 +01:00
Girish Ramakrishnan bd961025f6 platform: get shell output as utf8 2024-12-19 16:59:28 +01:00
Girish Ramakrishnan 83adcd73a9 sqlite3: images.base is gone 2024-12-14 21:40:47 +01:00
Girish Ramakrishnan 8e6890b4d6 docker: rework image pruning
with our new retagging approach, the Digest ID remains <null> because
this is only set by docker if truly fetched from the registry.

this means that redis container always gets removed...
2024-12-14 20:47:35 +01:00
Girish Ramakrishnan 5893f53b43 typo 2024-12-14 19:05:32 +01:00
Girish Ramakrishnan 5ce82d6794 docker: parseImageRef 2024-12-14 14:00:05 +01:00
Girish Ramakrishnan 872705d58d oidc: use the cloudron name as provider name 2024-12-02 12:01:19 +01:00
Girish Ramakrishnan ca5776e6f3 services: fix oidc usage 2024-12-02 11:00:12 +01:00
Girish Ramakrishnan 22be1f1b72 sqlite: create dumps based on the basename 2024-11-21 12:34:06 +05:30
Girish Ramakrishnan 7095862601 sqlite: add some comments 2024-11-21 12:24:27 +05:30
Girish Ramakrishnan fa98e0570f sqlite: change path to paths 2024-11-21 10:02:26 +05:30
Girish Ramakrishnan 4316d3eade add sqlite3 addon take 2
- there is no container id during the addon lifecycle
- sqlite3 requires the localstorage addon to be inited. so this has to
  become like the ftp option
- remove all that child_process streaming stuff. too complicated
2024-11-21 00:13:17 +05:30
Girish Ramakrishnan f8cd0b5f52 add sqlite3 addon 2024-11-21 00:13:17 +05:30