feat: transform node_prefix using babel

This commit is contained in:
Amin Yahyaabadi 2023-04-23 00:53:36 -07:00
parent e7cc3cb456
commit e0367b710b
12 changed files with 125 additions and 34 deletions

View File

@ -75,6 +75,7 @@ words:
- tsbuildinfo
- ucrt
- untildify
- upleveled
- vbatts
- vcpkg
- vcvarsall

View File

@ -1,20 +0,0 @@
/* eslint-disable import/no-extraneous-dependencies */
import { readFile, writeFile } from "fs/promises"
import glob from "fast-glob"
const distFolder = "dist"
// remove node: prefix from the scripts in the dist folder
async function main() {
const files = await glob([`${distFolder}/**/*.js`, `${distFolder}/**/*.js.map`], { absolute: true, onlyFiles: true })
await Promise.all(
files.map(async (file) => {
const content = await readFile(file, "utf8")
const newContent = content.replace(/require\("node:/g, 'require("')
await writeFile(file, newContent)
})
)
}
await main()

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -31,8 +31,7 @@
"build.docker.arch": "pnpm build && docker build -f ./dev/docker/arch_node.dockerfile -t setup-cpp:arch .",
"build.docker.fedora": "pnpm build && docker build -f ./dev/docker/fedora_node.dockerfile -t setup-cpp:fedora .",
"build.docker.ubuntu": "pnpm build && docker build -f ./dev/docker/ubuntu_node.dockerfile -t setup-cpp:ubuntu .",
"build.parcel": "cross-env NODE_ENV=production parcel build && pnpm run build.node_prefix",
"build.node_prefix": "node ./dev/scripts/node_prefix.mjs",
"build.parcel": "cross-env NODE_ENV=production parcel build && babel ./dist --out-dir dist --plugins @upleveled/babel-plugin-remove-node-prefix --compact --no-babelrc --source-maps true",
"bump": "ncu -u -x execa,numerous,path-exists && pnpm update",
"clean": "shx rm -rf .parcel-cache dist exe",
"copy.matchers": "shx cp ./src/gcc/gcc_matcher.json ./dist/node12/ && shx cp ./src/msvc/msvc_matcher.json ./dist/node12/ && shx cp ./src/python/python_matcher.json ./dist/node12/ && shx cp ./src/llvm/llvm_matcher.json ./dist/node12/ && shx cp ./dist/node12/*.json ./dist/node16/",
@ -65,6 +64,7 @@
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.3",
"@actions/tool-cache": "^2.0.1",
"@babel/cli": "^7.21.0",
"@npmcli/ci-detect": "^3.0.2",
"@types/cross-spawn": "^6.0.2",
"@types/eslint": "^8.37.0",
@ -75,6 +75,7 @@
"@types/prettier": "2.7.2",
"@types/semver": "^7.3.13",
"@types/which": "^3.0.0",
"@upleveled/babel-plugin-remove-node-prefix": "github:aminya/babel-plugin-remove-node-prefix#95fcbd92405b99a6eece48c493548996f12e6519",
"admina": "^0.1.3",
"caxa": "^3.0.1",
"ci-log": "workspace:*",

View File

@ -24,6 +24,9 @@ importers:
'@actions/tool-cache':
specifier: ^2.0.1
version: 2.0.1
'@babel/cli':
specifier: ^7.21.0
version: 7.21.0(@babel/core@7.21.4)
'@npmcli/ci-detect':
specifier: ^3.0.2
version: 3.0.2
@ -54,6 +57,9 @@ importers:
'@types/which':
specifier: ^3.0.0
version: 3.0.0
'@upleveled/babel-plugin-remove-node-prefix':
specifier: github:aminya/babel-plugin-remove-node-prefix#95fcbd92405b99a6eece48c493548996f12e6519
version: github.com/aminya/babel-plugin-remove-node-prefix/95fcbd92405b99a6eece48c493548996f12e6519(@babel/core@7.21.4)
admina:
specifier: ^0.1.3
version: 0.1.3
@ -425,6 +431,26 @@ packages:
- encoding
dev: true
/@babel/cli@7.21.0(@babel/core@7.21.4):
resolution: {integrity: sha512-xi7CxyS8XjSyiwUGCfwf+brtJxjW1/ZTcBUkP10xawIEXLX5HzLn+3aXkgxozcP2UhRhtKTmQurw9Uaes7jZrA==}
engines: {node: '>=6.9.0'}
hasBin: true
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
'@babel/core': 7.21.4
'@jridgewell/trace-mapping': 0.3.18
commander: 4.1.1
convert-source-map: 1.9.0
fs-readdir-recursive: 1.1.0
glob: 7.2.3
make-dir: 2.1.0
slash: 2.0.0
optionalDependencies:
'@nicolo-ribaudo/chokidar-2': 2.1.8-no-fsevents.3
chokidar: 3.5.3
dev: true
/@babel/code-frame@7.21.4:
resolution: {integrity: sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==}
engines: {node: '>=6.9.0'}
@ -1525,6 +1551,12 @@ packages:
dev: true
optional: true
/@nicolo-ribaudo/chokidar-2@2.1.8-no-fsevents.3:
resolution: {integrity: sha512-s88O1aVtXftvp5bCPB7WnmXc5IwOZZ7YPuwNPt+GtOOXpPvad1LfbmjYv+qII7zP6RU2QGnqve27dnLycEnyEQ==}
requiresBuild: true
dev: true
optional: true
/@nicolo-ribaudo/eslint-scope-5-internals@5.1.1-v1:
resolution: {integrity: sha512-54/JRvkLIzzDWshCWfuhadfrfZVPiElY8Fcgmg1HroEly/EDSszzhBAsarCux+D/kOslTRquNzuyGSmUSTTHGg==}
dependencies:
@ -3163,6 +3195,12 @@ packages:
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
dev: true
/binary-extensions@2.2.0:
resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==}
engines: {node: '>=8'}
dev: true
optional: true
/binary-searching@2.0.5:
resolution: {integrity: sha512-v4N2l3RxL+m4zDxyxz3Ne2aTmiPn8ZUpKFpdPtO+ItW1NcTCXA7JeHG5GMBSvoKSkQZ9ycS+EouDVxYB9ufKWA==}
dev: true
@ -3451,6 +3489,23 @@ packages:
resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==}
dev: true
/chokidar@3.5.3:
resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==}
engines: {node: '>= 8.10.0'}
requiresBuild: true
dependencies:
anymatch: 3.1.3
braces: 3.0.2
glob-parent: 5.1.2
is-binary-path: 2.1.0
is-glob: 4.0.3
normalize-path: 3.0.0
readdirp: 3.6.0
optionalDependencies:
fsevents: 2.3.2
dev: true
optional: true
/chownr@2.0.0:
resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==}
engines: {node: '>=10'}
@ -3662,6 +3717,11 @@ packages:
resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==}
dev: true
/commander@4.1.1:
resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==}
engines: {node: '>= 6'}
dev: true
/commander@7.2.0:
resolution: {integrity: sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==}
engines: {node: '>= 10'}
@ -5245,6 +5305,10 @@ packages:
minipass: 4.2.8
dev: true
/fs-readdir-recursive@1.1.0:
resolution: {integrity: sha512-GNanXlVr2pf02+sPN40XN8HG+ePaNcvM0q5mZBd668Obwb0yD5GiUbZOFgwn8kGMY6I3mdyDJzieUy3PTYyTRA==}
dev: true
/fs.realpath@1.0.0:
resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==}
dev: true
@ -6004,6 +6068,14 @@ packages:
has-bigints: 1.0.2
dev: true
/is-binary-path@2.1.0:
resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==}
engines: {node: '>=8'}
dependencies:
binary-extensions: 2.2.0
dev: true
optional: true
/is-boolean-object@1.1.2:
resolution: {integrity: sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==}
engines: {node: '>= 0.4'}
@ -7165,6 +7237,14 @@ packages:
engines: {node: '>=12'}
dev: true
/make-dir@2.1.0:
resolution: {integrity: sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==}
engines: {node: '>=6'}
dependencies:
pify: 4.0.1
semver: 7.3.8
dev: true
/make-dir@3.1.0:
resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==}
engines: {node: '>=8'}
@ -8359,6 +8439,11 @@ packages:
hasBin: true
dev: true
/pify@4.0.1:
resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==}
engines: {node: '>=6'}
dev: true
/pinkie-promise@2.0.1:
resolution: {integrity: sha512-0Gni6D4UcLTbv9c57DfxDGdr41XfgUjqWZu492f0cIGr16zDU06BWP/RAEvOuo7CQ0CNjHaLlM59YJJFm3NWlw==}
engines: {node: '>=0.10.0'}
@ -8721,6 +8806,14 @@ packages:
minimatch: 5.1.6
dev: true
/readdirp@3.6.0:
resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==}
engines: {node: '>=8.10.0'}
dependencies:
picomatch: 2.3.1
dev: true
optional: true
/readme-md-generator@1.0.0:
resolution: {integrity: sha512-K2v858y99S+AH0OTtaCVgEQg47LU6OecKbF1Eu1nDGE2E8QhSYGeLfAKQWwnglm2xtUGn9rjhgK6l2aJHcA8Qg==}
engines: {node: '>=9.3.0', npm: '>=5.5.0'}
@ -9100,6 +9193,11 @@ packages:
resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==}
dev: true
/slash@2.0.0:
resolution: {integrity: sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==}
engines: {node: '>=6'}
dev: true
/slash@3.0.0:
resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==}
engines: {node: '>=8'}
@ -10293,6 +10391,17 @@ packages:
- encoding
dev: true
github.com/aminya/babel-plugin-remove-node-prefix/95fcbd92405b99a6eece48c493548996f12e6519(@babel/core@7.21.4):
resolution: {tarball: https://codeload.github.com/aminya/babel-plugin-remove-node-prefix/tar.gz/95fcbd92405b99a6eece48c493548996f12e6519}
id: github.com/aminya/babel-plugin-remove-node-prefix/95fcbd92405b99a6eece48c493548996f12e6519
name: '@upleveled/babel-plugin-remove-node-prefix'
version: 1.0.1
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
'@babel/core': 7.21.4
dev: true
github.com/aminya/ci-detect/37fe40075bebec96794ba0a7c4a6d5c70cbea00d:
resolution: {tarball: https://codeload.github.com/aminya/ci-detect/tar.gz/37fe40075bebec96794ba0a7c4a6d5c70cbea00d}
name: '@npmcli/ci-detect'