diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3627f106..f83bf0be 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -21,6 +21,8 @@ jobs: - 14 # installed on the images pnpm: - 6 + cache_reset_counter: + - 0 steps: - uses: actions/checkout@v2 with: @@ -32,7 +34,7 @@ jobs: path: | ~/.pnpm-store D:\.pnpm-store - key: "setupcpp-cache-OS:${{ matrix.os }}-node:${{ matrix.node }}-pnpm:${{ matrix.pnpm }}-${{ hashFiles('./.npmrc') }}-deps:${{ hashFiles('./package.json') }}" + key: "setupcpp-cache-OS:${{ matrix.os }}-node:${{ matrix.node }}-pnpm:${{ matrix.pnpm }}-${{ hashFiles('./.npmrc') }}-deps:${{ hashFiles('./package.json') }}-${{ matrix.cache_reset_counter }}" restore-keys: | "setupcpp-cache-OS:${{ matrix.os }}" @@ -52,4 +54,17 @@ jobs: - name: Test run: | - pnpm test + pnpm run test + + # Create self-contained executable that bundles Nodejs + - name: Create Executable + run: | + pnpm run pack.exe + + - name: Upload Executable + uses: actions/upload-artifact@v2 + with: + path: | + ./exe + ./dist + retention-days: 1 diff --git a/.gitignore b/.gitignore index 2d1461bd..9c25d70f 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ temp-* # Build directories dist -.parcel-cache \ No newline at end of file +.parcel-cache +exe \ No newline at end of file diff --git a/building/pack-exe.js b/building/pack-exe.js new file mode 100644 index 00000000..4134ce9b --- /dev/null +++ b/building/pack-exe.js @@ -0,0 +1,38 @@ +const { exec } = require("@actions/exec") + +function getPlatformName() { + switch (process.platform) { + case "win32": { + return "windows" + } + case "darwin": { + return "mac" + } + default: { + return process.platform + } + } +} + +function main() { + let exes + if (process.platform === "win32") { + exes = [".exe"] + } else if (process.platform === "darwin") { + exes = [".app", ".sh"] + } else { + exes = ["", ".sh"] + } + + 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}}/main.js"` + ) + ) + ) +} + +main().then((exit) => { + process.exit(exit) +}) diff --git a/package.json b/package.json index 9325b5de..6bed366e 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "scripts": { "format": "prettier --write .", "lint": "eslint . --fix", - "clean": "shx rm -rf dist", + "clean": "shx rm -rf dist exe", "dev": "cross-env NODE_ENV=development parcel watch", "build": "cross-env NODE_ENV=production parcel build --detailed-report", "prepare": "git submodule update --init --recursive && npm run build", @@ -16,7 +16,8 @@ "test.lint": "eslint .", "test.tsc": "tsc --noEmit", "test.unit": "jest", - "test": "run-p test.format test.lint test.tsc test.unit" + "test": "run-p test.format test.lint test.tsc test.unit", + "pack.exe": "shx rm -rf ./dist/tsconfig.tsbuildinfo && node ./building/pack-exe.js" }, "engines": { "node": ">=12.x" @@ -45,6 +46,7 @@ "@types/node": "^16.9.1", "@types/semver": "^7.3.8", "@types/which": "^2.0.1", + "caxa": "^2.1.0", "cross-env": "7.0.3", "eslint-config-atomic": "^1.16.2", "jest": "^27.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d9cf2e5e..96311cb9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,6 +12,7 @@ importers: '@types/node': ^16.9.1 '@types/semver': ^7.3.8 '@types/which': ^2.0.1 + caxa: ^2.1.0 cross-env: 7.0.3 eslint-config-atomic: ^1.16.2 hasha: ^5.2.2 @@ -38,6 +39,7 @@ importers: '@types/node': 16.9.1 '@types/semver': 7.3.8 '@types/which': 2.0.1 + caxa: 2.1.0 cross-env: 7.0.3 eslint-config-atomic: 1.16.2 jest: 27.2.0 @@ -1818,6 +1820,35 @@ packages: picomatch: 2.3.0 dev: true + /archiver-utils/2.1.0: + resolution: {integrity: sha512-bEL/yUb/fNNiNTuUz979Z0Yg5L+LzLxGJz8x79lYmR54fmTIb6ob/hNQgkQnIUDWIFjZVQwl9Xs356I6BAMHfw==} + engines: {node: '>= 6'} + dependencies: + glob: 7.1.7 + graceful-fs: 4.2.8 + lazystream: 1.0.0 + lodash.defaults: 4.2.0 + lodash.difference: 4.5.0 + lodash.flatten: 4.4.0 + lodash.isplainobject: 4.0.6 + lodash.union: 4.6.0 + normalize-path: 3.0.0 + readable-stream: 2.3.7 + dev: true + + /archiver/5.3.0: + resolution: {integrity: sha512-iUw+oDwK0fgNpvveEsdQ0Ase6IIKztBJU2U0E9MzszMfmVVUyv1QJhS2ITW9ZCqx8dktAxVAjWWkKehuZE8OPg==} + engines: {node: '>= 10'} + dependencies: + archiver-utils: 2.1.0 + async: 3.2.1 + buffer-crc32: 0.2.13 + readable-stream: 3.6.0 + readdir-glob: 1.1.1 + tar-stream: 2.2.0 + zip-stream: 4.1.0 + dev: true + /argparse/1.0.10: resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==} dependencies: @@ -1947,10 +1978,19 @@ packages: resolution: {integrity: sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==} dev: true + /async/3.2.1: + resolution: {integrity: sha512-XdD5lRO/87udXCMC9meWdYiR+Nq6ZjUfXidViUZGu2F1MO4T3XwZ1et0hb2++BgLfhyJwy44BGB/yx80ABx8hg==} + dev: true + /asynckit/0.4.0: resolution: {integrity: sha1-x57Zf380y48robyXkLzDZkdLS3k=} dev: true + /at-least-node/1.0.0: + resolution: {integrity: sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==} + engines: {node: '>= 4.0.0'} + dev: true + /atob/2.1.2: resolution: {integrity: sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==} engines: {node: '>= 4.5.0'} @@ -2302,6 +2342,10 @@ packages: node-int64: 0.4.0 dev: true + /buffer-crc32/0.2.13: + resolution: {integrity: sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=} + dev: true + /buffer-from/1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} dev: true @@ -2380,6 +2424,19 @@ packages: resolution: {integrity: sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=} dev: true + /caxa/2.1.0: + resolution: {integrity: sha512-RMenUUAKteG7neQeIZchqLGWa2QkrlO8KUHeefvDiPURASiKAGHCJUXh8CyLHkDCk5NKIz0IdcRyVXXypB+hXQ==} + hasBin: true + dependencies: + archiver: 5.3.0 + commander: 7.2.0 + crypto-random-string: 3.3.1 + dedent: 0.7.0 + execa: 4.1.0 + fs-extra: 9.1.0 + globby: 11.0.4 + dev: true + /chalk/1.1.3: resolution: {integrity: sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=} engines: {node: '>=0.10.0'} @@ -2585,6 +2642,16 @@ packages: resolution: {integrity: sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==} dev: true + /compress-commons/4.1.1: + resolution: {integrity: sha512-QLdDLCKNV2dtoTorqgxngQCMA+gWXkM/Nwu7FpeBhk/RdkzimqC3jueb/FDmaZeXh+uby1jkBqE3xArsLBE5wQ==} + engines: {node: '>= 10'} + dependencies: + buffer-crc32: 0.2.13 + crc32-stream: 4.0.2 + normalize-path: 3.0.0 + readable-stream: 3.6.0 + dev: true + /concat-map/0.0.1: resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=} dev: true @@ -2668,6 +2735,23 @@ packages: yaml: 1.10.2 dev: true + /crc-32/1.2.0: + resolution: {integrity: sha512-1uBwHxF+Y/4yF5G48fwnKq6QsIXheor3ZLPT80yGBV1oEUwpPojlEhQbWKVw1VwcTQyMGHK1/XMmTjmlsmTTGA==} + engines: {node: '>=0.8'} + hasBin: true + dependencies: + exit-on-epipe: 1.0.1 + printj: 1.1.2 + dev: true + + /crc32-stream/4.0.2: + resolution: {integrity: sha512-DxFZ/Hk473b/muq1VJ///PMNLj0ZMnzye9thBpmjpJKCc5eMgB95aK8zCGrGfQ90cWo561Te6HK9D+j4KPdM6w==} + engines: {node: '>= 10'} + dependencies: + crc-32: 1.2.0 + readable-stream: 3.6.0 + dev: true + /create-ecdh/4.0.4: resolution: {integrity: sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A==} dependencies: @@ -2740,6 +2824,13 @@ packages: randomfill: 1.0.4 dev: true + /crypto-random-string/3.3.1: + resolution: {integrity: sha512-5j88ECEn6h17UePrLi6pn1JcLtAiANa3KExyr9y9Z5vo2mv56Gh3I4Aja/B9P9uyMwyxNHAHWv+nE72f30T5Dg==} + engines: {node: '>=8'} + dependencies: + type-fest: 0.8.1 + dev: true + /css-color-names/1.0.1: resolution: {integrity: sha512-/loXYOch1qU1biStIFsHH8SxTmOseh1IJqFvy8IujXOm1h+QjUdDhkzOrR5HG8K8mlxREj0yfi8ewCHx0eMxzA==} dev: true @@ -3201,6 +3292,12 @@ packages: engines: {node: '>= 0.8'} dev: true + /end-of-stream/1.4.4: + resolution: {integrity: sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==} + dependencies: + once: 1.4.0 + dev: true + /enquirer/2.3.6: resolution: {integrity: sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==} engines: {node: '>=8.6'} @@ -3742,6 +3839,21 @@ packages: safe-buffer: 5.2.1 dev: true + /execa/4.1.0: + resolution: {integrity: sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA==} + engines: {node: '>=10'} + dependencies: + cross-spawn: 7.0.3 + get-stream: 5.2.0 + human-signals: 1.1.1 + is-stream: 2.0.1 + merge-stream: 2.0.0 + npm-run-path: 4.0.1 + onetime: 5.1.2 + signal-exit: 3.0.3 + strip-final-newline: 2.0.0 + dev: true + /execa/5.1.1: resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} engines: {node: '>=10'} @@ -3757,6 +3869,11 @@ packages: strip-final-newline: 2.0.0 dev: true + /exit-on-epipe/1.0.1: + resolution: {integrity: sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==} + engines: {node: '>=0.8'} + dev: true + /exit/0.1.2: resolution: {integrity: sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=} engines: {node: '>= 0.8.0'} @@ -4013,6 +4130,20 @@ packages: map-cache: 0.2.2 dev: true + /fs-constants/1.0.0: + resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} + dev: true + + /fs-extra/9.1.0: + resolution: {integrity: sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==} + engines: {node: '>=10'} + dependencies: + at-least-node: 1.0.0 + graceful-fs: 4.2.8 + jsonfile: 6.1.0 + universalify: 2.0.0 + dev: true + /fs.realpath/1.0.0: resolution: {integrity: sha1-FQStJSMVjKpA20onh8sBQRmU6k8=} dev: true @@ -4067,6 +4198,13 @@ packages: engines: {node: '>=6'} dev: true + /get-stream/5.2.0: + resolution: {integrity: sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==} + engines: {node: '>=8'} + dependencies: + pump: 3.0.0 + dev: true + /get-stream/6.0.1: resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==} engines: {node: '>=10'} @@ -4396,6 +4534,11 @@ packages: - supports-color dev: true + /human-signals/1.1.1: + resolution: {integrity: sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==} + engines: {node: '>=8.12.0'} + dev: true + /human-signals/2.1.0: resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} engines: {node: '>=10.17.0'} @@ -5513,6 +5656,14 @@ packages: resolution: {integrity: sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA==} dev: true + /jsonfile/6.1.0: + resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==} + dependencies: + universalify: 2.0.0 + optionalDependencies: + graceful-fs: 4.2.8 + dev: true + /jsprim/1.4.1: resolution: {integrity: sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=} engines: {'0': node >=0.6.0} @@ -5578,6 +5729,13 @@ packages: language-subtag-registry: 0.3.21 dev: true + /lazystream/1.0.0: + resolution: {integrity: sha1-9plf4PggOS9hOWvolGJAe7dxaOQ=} + engines: {node: '>= 0.6.3'} + dependencies: + readable-stream: 2.3.7 + dev: true + /leven/3.1.0: resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==} engines: {node: '>=6'} @@ -5671,6 +5829,22 @@ packages: resolution: {integrity: sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=} dev: true + /lodash.defaults/4.2.0: + resolution: {integrity: sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=} + dev: true + + /lodash.difference/4.5.0: + resolution: {integrity: sha1-nMtOUF1Ia5FlE0V3KIWi3yf9AXw=} + dev: true + + /lodash.flatten/4.4.0: + resolution: {integrity: sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=} + dev: true + + /lodash.isplainobject/4.0.6: + resolution: {integrity: sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=} + dev: true + /lodash.memoize/4.1.2: resolution: {integrity: sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=} dev: true @@ -5687,6 +5861,10 @@ packages: resolution: {integrity: sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=} dev: true + /lodash.union/4.6.0: + resolution: {integrity: sha1-SLtQiECfFvGCFmZkHETdGqrjzYg=} + dev: true + /lodash.uniq/4.5.0: resolution: {integrity: sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=} dev: true @@ -6976,6 +7154,12 @@ packages: react-is: 17.0.2 dev: true + /printj/1.1.2: + resolution: {integrity: sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ==} + engines: {node: '>=0.8'} + hasBin: true + dev: true + /process-nextick-args/2.0.1: resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} dev: true @@ -7021,6 +7205,13 @@ packages: safe-buffer: 5.2.1 dev: true + /pump/3.0.0: + resolution: {integrity: sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==} + dependencies: + end-of-stream: 1.4.4 + once: 1.4.0 + dev: true + /punycode/1.3.2: resolution: {integrity: sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=} dev: true @@ -7158,6 +7349,12 @@ packages: util-deprecate: 1.0.2 dev: true + /readdir-glob/1.1.1: + resolution: {integrity: sha512-91/k1EzZwDx6HbERR+zucygRFfiPl2zkIYZtv3Jjr6Mn7SkKcVct8aVO+sSRiGMc6fLf72du3d92/uY63YPdEA==} + dependencies: + minimatch: 3.0.4 + dev: true + /rechoir/0.6.2: resolution: {integrity: sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=} engines: {node: '>= 0.10'} @@ -7880,6 +8077,17 @@ packages: strip-ansi: 6.0.0 dev: true + /tar-stream/2.2.0: + resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==} + engines: {node: '>=6'} + dependencies: + bl: 4.1.0 + end-of-stream: 1.4.4 + fs-constants: 1.0.0 + inherits: 2.0.4 + readable-stream: 3.6.0 + dev: true + /term-size/2.2.1: resolution: {integrity: sha512-wK0Ri4fOGjv/XPy8SBHZChl8CM7uMc5VML7SqiQ0zG7+J5Vr+RMQDoHa2CNT6KHUnTGIXH34UDMkPzAUyapBZg==} engines: {node: '>=8'} @@ -8121,7 +8329,6 @@ packages: /type-fest/0.8.1: resolution: {integrity: sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==} engines: {node: '>=8'} - dev: false /typedarray-to-buffer/3.1.5: resolution: {integrity: sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==} @@ -8189,6 +8396,11 @@ packages: engines: {node: '>= 4.0.0'} dev: true + /universalify/2.0.0: + resolution: {integrity: sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==} + engines: {node: '>= 10.0.0'} + dev: true + /unpipe/1.0.0: resolution: {integrity: sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=} engines: {node: '>= 0.8'} @@ -8526,3 +8738,12 @@ packages: y18n: 5.0.8 yargs-parser: 20.2.9 dev: true + + /zip-stream/4.1.0: + resolution: {integrity: sha512-zshzwQW7gG7hjpBlgeQP9RuyPGNxvJdzR8SUM3QhxCnLjWN2E7j3dOvpeDcQoETfHx0urRS7EtmVToql7YpU4A==} + engines: {node: '>= 10'} + dependencies: + archiver-utils: 2.1.0 + compress-commons: 4.1.1 + readable-stream: 3.6.0 + dev: true