Repository navigation
chore: remove shelljs from automation scripts - #2502
Merged
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
gjulivan
previously approved these changes
Nov 2, 2026
r0b1n
force-pushed
the
chore/automation-utils-drop-shelljs
branch
from
November 9, 2026 11:51
c7e0f34 to
0cbc705
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
r0b1n
force-pushed
the
chore/automation-utils-drop-shelljs
branch
from
November 10, 2026 11:05
58f7782 to
ba5f620
Compare
This comment has been minimized.
This comment has been minimized.
leonardomendix
previously approved these changes
Nov 10, 2026
r0b1n
force-pushed
the
chore/automation-utils-drop-shelljs
branch
from
November 13, 2026 13:12
ba5f620 to
98d822c
Compare
This comment has been minimized.
This comment has been minimized.
…ushd First step towards dropping shelljs. Export only the shelljs helpers that are used, and run git commands with execa's cwd option instead of pushd/popd. This also fixes two cases where the process directory was left changed: pushUpdateToTestProject returned early on "Nothing to commit" without popd, and zip() skipped popd when zipping failed.
Use node:fs/promises for rm, mkdir and cp in automation/utils and the charts-web and data-widgets scripts, and remove shelljs from automation/utils. shell.ts keeps small helpers where node:fs has no direct equivalent: - findFiles: glob that fails when a pattern matches nothing, like shelljs find - move: rename with a copy and remove fallback across file systems, like mv - makeWritableRecursive: chmod -R a+rw zip() now switches directories with process.chdir instead of pushd/popd.
Use node:fs for ls, rm, mkdir, mv, cp, test and cat in run-e2e, spawnSync for `gh auth token` and the themesource chmod, and remove shelljs from run-e2e. shelljs was not in fatal mode here, so a failed cp or mv only printed an error. They now throw; the Atlas theme and core releases in use contain the copied folders. A missing runtime.log is still reported instead of thrown.
pluggable-widgets-tools depends on shx, which pulls in shelljs 0.9.2, but neither the tools nor this repo call it. Remove it with a pnpm override, like the other unused tools dependencies. The tools still use shelljs 0.10.0 in their rollup config until a release without it is available.
No code in the repo imports shelljs anymore. The pattern also had no effect, because shamefully-hoist=true already hoists every package to the root.
Add node:test specs for ensureFileExists, findFiles, move, makeWritableRecursive and zip/unzip, run by a new test script so CI runs them with the other unit tests. No new dependencies.
r0b1n
force-pushed
the
chore/automation-utils-drop-shelljs
branch
from
November 16, 2026 08:44
98d822c to
3028ca3
Compare
Contributor
AI Code Review
What was reviewed
Skipped (out of scope): CI: pending: Run code quality check, Plan E2E matrix, sigridci · unrelated failures: security/snyk (external scanner; does not point to a code issue in this diff) Positives
I checked these as well and found nothing to report:
|
gjulivan
approved these changes
Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request type
Refactoring (e.g. file rename, variable rename, etc.)
Description
Removes shelljs from the repo's own scripts (follow-up to #2484), as eight commits that can be reviewed separately. Replacing
exec(execa v5) with zx is the next step.1. Trim shell exports and pass
cwdinstead ofpushd(83f482d)src/shell.tsexported 29 shelljs functions; only the ones in use are kept.pushUpdateToTestProject(steps.ts) andupdateChangelogsAndCreatePR(changelog.ts) run their git commands with execa'scwdoption instead ofpushd/popd.This fixes two cases where the process was left in a different directory:
pushUpdateToTestProjectcalledpushdand then returned early on "Nothing to commit" withoutpopd.zip()only calledpopdon success, so a failed zip left the process inside the zipped folder.2. Replace shelljs file helpers with
node:fs(b729ca3)rm -rf,mkdir -pandcpcall sites now usenode:fs/promises, inautomation/utilsand in the charts-web and data-widgets scripts. shelljs is removed fromautomation/utils/package.json.shell.tskeeps small helpers only wherenode:fshas no direct equivalent:findFiles(...patterns):fs.globSyncthat throws when a pattern matches nothing. shelljsfindwithfatalfailed the same way, so a missing mpk still stops the release instead of being skipped silently.move(source, dest):renamewith a copy and remove fallback when crossing file systems, like shelljsmv. This replaces the cp + rm workaround inmoveModuleToDistfor mv silently swallows errors shelljs/shelljs#878.makeWritableRecursive(dir): thechmod -R a+rwused before re-zipping mpks.ensureFileExistsusesfs.accessand is now async.zip()switches directories withprocess.chdir; cross-zip has nocwdoption.rui-oss-clearanceimportsnode:fs/promisesstatically instead of the inlineawait import(...)calls.Copying a file into a directory now passes the full destination path, since
fs.cpdoesn't copy into an existing directory the way shelljscpdoes.pnpm-lock.yaml: removes shelljs 0.8.5.3. Replace shelljs in run-e2e with
node:fs(3961d22)ls,rm,mkdir,mv,cp,testandcatinautomation/run-e2e/libnow usenode:fs; globs (tests/testProjects-*,*.mpr,dist/<version>/*.mpk) usefs.globSync.gh auth token(dev mode) and the themesourcechmod -R +wusespawnSync.automation/run-e2e/package.jsonand from the lockfile.Behaviour change: shelljs was not in
fatalmode in run-e2e, so a failedcp/mvonly printed an error and continued. These now throw. The Atlas theme releases (atlasui-theme-files-2024-01-25,-2025-10-08) containwebandnative, and the Atlas core releases (3.17.0, 4.5.0) containthemesource, so the copies succeed. A missingresults/runtime.logis still reported instead of thrown. A missing widget mpk after the release script throws, butupdateTestProjectalready catches and logs errors from that step.4. Drop the unused
shxdependency of pluggable-widgets-tools (2555853)@mendix/pluggable-widgets-toolsdepends onshx, which brings in shelljs 0.9.2 (and an oldexeca@1chain), but neither the tools nor this repo call it. It is removed with a"@mendix/pluggable-widgets-tools>shx": "-"override, like the other unused tools dependencies in the rootpackage.json.The only shelljs left in the lockfile is 0.10.0, used by the tools' rollup config to copy XML, icons, LICENSE and the mpk. The upstream fix is merged but not yet released; the override and that dependency can go once we upgrade the tools.
5. Remove the stale shelljs hoist pattern from
.npmrc(949e9f6)No code in the repo imports shelljs anymore. The
public-hoist-pattern[]=*shelljs*line also had no effect, becauseshamefully-hoist=truealready hoists every package to the root; installs are unchanged.6. Tests for the
shell.tsfile helpers (29779f4)automation/utilshad no tests. This addssrc/__tests__/shell.spec.ts, run with Node's built-in test runner (node --test, no new dependencies) through a newtestscript, so CI runs it with the other unit tests. It coversensureFileExists,findFiles,move,makeWritableRecursive(including not following symlinks) andzip/unzip: archive entries at the root, and the working directory restored after both a successful and a failed zip. Putting back the old "no restore on failure" behaviour makes the test fail.7. Tests for the release steps that rebuild mpks (ac4a10c)
src/__tests__/mpk-archive.spec.tsruns the real release steps against a fake module mpk and then unzips the result to check it:addTestProjectWidgetsToMpk(the sameinsertWidgetsIntoMpkpath asaddWidgetsToMpk): widget mpks end up underwidgets/, including one with a space in its name, and are listed inpackage.xml. A nested widget mpk comes back byte-for-byte, and the temp folder is removed.copyFilesToMpk: the files are added and listed inpackage.xml.includeReadmeOssIntoMpk: the READMEOSS file is added to the existing mpk in place.The fake mpk contains a read-only file, like mxbuild output (POSIX only).
shell.spec.tsalso gets zip round trips with spaces in the archive, folder and entry paths, and with binary content. Whenzip()is changed to zip the wrong folder, 6 tests fail.8. Run these tests on the release build runners (98d822c)
Unit tests only ran in the ubuntu
checkjob, but the release job runs on ubuntu and Windows, and cross-zip works differently on each: it callszip/unzipon Linux and PowerShell on Windows. A new "Test release scripts" step runspnpm --filter @mendix/automation-utils run testin the release job, before the release task. It runs on every PR, not only whenautomation/utilschanges, so a zip break on either runner shows up before a release does. It passes on both runners; the mpk tests take a few seconds on Windows.What should be covered while testing?
Verified locally:
automation/utilstype-checks and lints; script lints pass for all modules and charts-web.Helper smoke test: zip/unzip,
ziprestoring the directory on success and failure,ensureFileExiststhrowingENOENT,findFilesmatching and throwing,makeWritableRecursive(600 → 666),move.pnpm turbo build --filter=@mendix/charts-web: Charts.mpk contains all 10 widgets merged undercom/pluspackage.xmlandLicense.txt.pnpm turbo build --filter=@mendix/badge-web --forceand its unit tests pass withoutshxinstalled.run-e2e:
setupTestProject(twice, covering the cleanup branch) andupdateTestProjectfor badge-web: the mpr, Atlastheme/webandtheme/native,themesource/atlas_coreandBadge.mpkare in place, and the themesource files are writable.build:modulefordata-widgets(all 9 widget mpks copied, themesource,.version, LICENSE) andweb-actions(themesource identical to source).Module release pipeline for
data-widgets, run locally withCIunset: the steps fromscripts/release.ts, with only the clone swapped for an anonymous one becausecloneTestProjectneedsGH_PAT. That coverscreateModuleMpkin Docker (mxbuild 10.24.0.73019),addWidgetsToMpk(9 widgets added) andmoveModuleToDist. The resultingdist/3.11.8/DataWidgets.mpkhas the same file list and the samepackage.xmlentries as the publisheddata-widgets-v3.11.8asset. The only difference is the READMEOSS HTML, which OSS clearance adds after release. No temp folders were left behind.Not run locally or in CI, worth watching on the next module release:
includeReadmeOssIntoMpkis now covered by tests) andrui-create-gh-release.pushUpdateToTestProjectand the changelog flow, which push to remotes.move.ci.mjs,docker-utils.mjs); the E2E jobs exercise them.