* Replace imports.
* Migrate config.js to TS.
* Replace build references.
* Adjust TargetOS to infer from a runtime list.
* Apply stricter rules for optional properties.
* Restore options.outputDir to keep the PR without any logic change.
Migrate `build/commands` code to ESM to allow `.js`/`.ts` imports to work correctly in any direction. This allows for gradual migration to `.ts` while keeping `.js` files around.
Few notes on migration:
1. `import.meta.*` cannot be used reliably with Jest. I tried different versions and approaches, eventually came up with a `.cjs` module that still uses `__dirName`, but can be imported into ESM and CommonJS modules without issues. I also considered rewriting Jest tests into built-in Node test runner, but since I was able to make Jest work, this was abandoned.
2. `tsc` accepts both `file.js`/`file.ts` in imports and passes a compiler check without errors, but Node requires an import of a real file (type stripping is based on a file type). This means an incorrect import will pass `test:scripts`, but fail on real execution (see [related discussion](https://github.com/microsoft/TypeScript/issues/61021)). An eslint rule was added to enforce that.
3. local `require()` calls replaced with async/global imports depending on context.
* Write .sisorc from js and warn if siso_cache_dir is not set.
* Remove auto-directory setting.
* Remove try/catch around mkdirSync as it doesn't throw when dir exists.
* Use path.
* Adjust writeFileIfModified to not create empty files.
* Update .gclient file on sync.
* Rename var to disable .gclient auto-update.
* Improve header comment examples slightly.
* Remove checks for always set existingGclientConfig.
* Treat disable_gclient_config_update flag as exception, not norm.
* Move custom_deps/vars to package.json config.
There has been some long investigation to determine why `npm run init`
was hanging when being called from Brockit. Although the proper reason
couldn't be properly ascertained, it is possible to say now that in
certain contexts, Jenkins doesn't like `gclient sync` with the
`--revision` flag.
This PR works around this issue by providing a specific flag to remove
the use of `--revision`, and manually checkout `chromium/src` to the
desired tag. The flag is named `--with_issue_44921`, in order to provide
better context of its use and rationale behind it.
Resolves https://github.com/brave/brave-browser/issues/44921
* Check node and npm version.
* Parse version parts to integer to handle possible non-digits chars.
* Use package.json "engines" field.
* Fix error style.
* Harden depot_tools checkout and support revision enforcement.
* Move depot_tools install process into a separate file.
* Rename ActionGuard.with() -> run().
* Use depot_tools dir value from package.json.
* Format.
* Always checkout FETCH_HEAD after fetching a reference.
* Only allow git revision to be enforced for depot_tools.
* Guard all possibly failing steps.
* Use brave-core-relative depot_tools path in package.json.
* Move bootstrap into a separate function, swap guard and log calls.
* Fix Linux Arm64 build
`npm run init` didn't install all dependencies necessary for it.
* Always run arm64 gclient hooks on Linux
This in particular creates the arm64 sysroot, which we need when
building for that architecture.
* sync script - never ask gclient to sync brave-core
The inconsistency between the developer or CI using git or gclient being used was causing issues, especially if GIT_CACHE was set
* Sync: No need to reset remote repo url since git cache won't be used for brave-core dir anymore
Co-authored-by: Mihai PLESA <mihai.plesa@gmail.com>