Skip to content

Commit

Permalink
fix: build the bundle as a module to support node: protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed May 3, 2022
1 parent 6fd3430 commit 214355f
Show file tree
Hide file tree
Showing 20 changed files with 30 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ temp-*

# Build directories
./dist/
!./dist/setup_cpp.js
!./dist/setup_cpp.js.map
!./dist/setup_cpp.mjs
!./dist/setup_cpp.mjs.map
.parcel-cache
exe
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,25 @@ NOTE: On Unix systems, you will not need `sudo` if you are already a root user (

### With Nodejs

Download the `setup_cpp.js` file form [here](https://github.com/aminya/setup-cpp/releases/download/v0.13.2/setup_cpp.js), and run it with the available options.
Download the `setup_cpp.mjs` file form [here](https://github.com/aminya/setup-cpp/releases/download/v0.13.2/setup_cpp.mjs), and run it with the available options.

On Windows:

Open the shell as admin, download via `curl`, then install

```ps1
# open shell as admin
curl -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.13.2/setup_cpp.js"
node ./setup_cpp.js --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
curl -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.13.2/setup_cpp.mjs"
node ./setup_cpp.mjs --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
RefreshEnv.cmd # activate cpp environment variables
```

On Linux or Mac:

```ps1
wget "https://github.com/aminya/setup-cpp/releases/download/v0.13.2/setup_cpp.js"
sudo node ./setup_cpp.js --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
wget "https://github.com/aminya/setup-cpp/releases/download/v0.13.2/setup_cpp.mjs"
sudo node ./setup_cpp.mjs --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
source ~/.cpprc # activate cpp environment variables
```
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ inputs:

runs:
using: "node12"
main: "dist/setup_cpp.js"
main: "dist/setup_cpp.mjs"

branding:
icon: "award"
Expand Down
4 changes: 2 additions & 2 deletions dev/docker/ubuntu_20.04_node.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ RUN apt-get install -y --no-install-recommends curl gnupg ca-certificates
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
RUN apt-get install -y --no-install-recommends nodejs

# add setup_cpp.js
# add setup_cpp.mjs
ADD "./dist/" "/"
WORKDIR "/"

# run installation
RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --make true
RUN node ./setup_cpp.mjs --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --make true

CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]
Expand Down
4 changes: 2 additions & 2 deletions dev/docker/ubuntu_node.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ FROM ubuntu:22.04 AS base
RUN apt-get update -qq
RUN apt-get install -y --no-install-recommends nodejs

# add setup_cpp.js
# add setup_cpp.mjs
ADD "./dist/" "/"
WORKDIR "/"

# run installation
RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --make true
RUN node ./setup_cpp.mjs --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --make true

CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]
Expand Down
2 changes: 1 addition & 1 deletion dev/scripts/debug_remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { join, dirname } = require("path")

async function main() {
console.log("Disabling debug messages inside @actions/core")
const file = join(dirname(__dirname), "dist", "setup_cpp.js")
const file = join(dirname(__dirname), "dist", "setup_cpp.mjs")
const { code, map } = await minify(readFileSync(file, "utf8"), { sourceMap: true, ...require("../.terserrc.js") })

writeFileSync(file, code)
Expand Down
2 changes: 1 addition & 1 deletion dev/scripts/pack-exe.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function main() {
return Promise.all(
exes.map((exe) =>
exec(
`./node_modules/.bin/caxa --input ./dist --output ./exe/setup_cpp_${getPlatformName()}${exe} -- "{{caxa}}/node_modules/.bin/node${exe}" "{{caxa}}/setup_cpp.js"`
`./node_modules/.bin/caxa --input ./dist --output ./exe/setup_cpp_${getPlatformName()}${exe} -- "{{caxa}}/node_modules/.bin/node${exe}" "{{caxa}}/setup_cpp.mjs"`
)
)
)
Expand Down
2 changes: 0 additions & 2 deletions dist/actions_python.d60978cf.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/actions_python.d60978cf.js.map

This file was deleted.

2 changes: 2 additions & 0 deletions dist/actions_python.da267d37.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/actions_python.da267d37.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions dist/setup_cpp.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/setup_cpp.js.map

This file was deleted.

2 changes: 2 additions & 0 deletions dist/setup_cpp.mjs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/setup_cpp.mjs.map

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
"repository": "https://github.com/aminya/setup-cpp",
"license": "Apache-2.0",
"author": "Amin Yahyaabadi",
"main": "./dist/setup_cpp.js",
"main": "dist/setup_cpp.js",
"module": "dist/setup_cpp.mjs",
"source": "./src/main.ts",
"bin": {
"setup-cpp": "./dist/setup_cpp.js",
"setup_cpp": "./dist/setup_cpp.js"
"setup-cpp": "./dist/setup_cpp.mjs",
"setup_cpp": "./dist/setup_cpp.mjs"
},
"scripts": {
"build": "shx rm -rf dist/ && shx mkdir ./dist && run-p test.tsc build.parcel copy.matchers",
Expand Down Expand Up @@ -113,7 +114,8 @@
}
},
"targets": {
"main": {
"main": false,
"module": {
"context": "node",
"includeNodeModules": true,
"optimize": true
Expand Down
2 changes: 1 addition & 1 deletion src/gcc/gcc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async function activateGcc(version: string, binDir: string) {
function addGccLoggingMatcher() {
const matcherPath = path.join(__dirname, "gcc_matcher.json")
if (!existsSync(matcherPath)) {
return warning("the gcc_matcher.json file does not exist in the same folder as setup_cpp.js")
return warning("the gcc_matcher.json file does not exist in the same folder as setup_cpp.mjs")
}
info(`::add-matcher::${matcherPath}`)
}
2 changes: 1 addition & 1 deletion src/llvm/llvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export function setupClangTools(version: string, setupDir: string, arch: string)
function addLLVMLoggingMatcher() {
const matcherPath = path.join(__dirname, "llvm_matcher.json")
if (!existsSync(matcherPath)) {
return warning("the llvm_matcher.json file does not exist in the same folder as setup_cpp.js")
return warning("the llvm_matcher.json file does not exist in the same folder as setup_cpp.mjs")
}
info(`::add-matcher::${matcherPath}`)
}
2 changes: 1 addition & 1 deletion src/msvc/msvc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function setupMSVC(
function addMSVCLoggingMatcher() {
const matcherPath = path.join(__dirname, "msvc_matcher.json")
if (!existsSync(matcherPath)) {
return warning("the msvc_matcher.json file does not exist in the same folder as setup_cpp.js")
return warning("the msvc_matcher.json file does not exist in the same folder as setup_cpp.mjs")
}
info(`::add-matcher::${matcherPath}`)
}
2 changes: 1 addition & 1 deletion src/python/actions_python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function setupActionsPython(version: string, _setupDir: string, arc
function addPythonLoggingMatcher() {
const matcherPath = path.join(__dirname, "python_matcher.json")
if (!existsSync(matcherPath)) {
return warning("the python_matcher.json file does not exist in the same folder as setup_cpp.js")
return warning("the python_matcher.json file does not exist in the same folder as setup_cpp.mjs")
}
info(`::add-matcher::${matcherPath}`)
}

0 comments on commit 214355f

Please sign in to comment.