Compare commits

..

13 Commits

Author SHA1 Message Date
calebboyd 7bc3a83667 fix: node 10 cli args 2018-11-20 14:35:35 -06:00
calebboyd aa93ab6516 chore: update resolve-dependencies 2018-11-15 14:27:36 -06:00
calebboyd c681a62566 chore: log json error response 2018-10-25 10:06:05 -05:00
calebboyd 2ea0f897d5 chore: bump version 2018-10-23 10:23:34 -05:00
António Nuno Monteiro cfa3036694 feat: invalidate binary cache when snapshot file changes (#542) 2018-10-23 09:31:17 -05:00
calebboyd c3ba3ec872 chore: bump version 2018-10-21 12:25:35 -05:00
António Nuno Monteiro 142338ede6 fix: stringify compiler.entrypoint in shims (#541) 2018-10-21 12:00:06 -05:00
calebboyd e3f1d6fc74 fix: missing cwd on resolve 2018-10-20 11:31:05 -05:00
calebboyd 0db8122f8f fix: handle configure script in node 10.11+ 2018-10-20 11:23:12 -05:00
António Nuno Monteiro 129c2f86a0 fix: include snapshot in patches (#539) 2018-10-20 11:16:41 -05:00
calebboyd db766e2832 fix: use vcBuild and make based on current platform 2018-10-20 10:33:39 -05:00
calebboyd e6a416cc4f fix: add internalModuleReadJSON patch 2018-10-17 21:56:37 -05:00
calebboyd 35f4811826 fix: remove spread operator 2018-10-09 14:07:32 -05:00
15 changed files with 241 additions and 125 deletions
+4 -3
View File
@@ -130,10 +130,11 @@ compile({
- Example: `['--with-dtrace', '--dest-cpu=x64']`
- default: `[]`
- #### `make: string[]`
- Array of arguments for the node build make step, on windows this step recieves options for vcBuild.bat
- default: `[]` or `['nosign', 'release']` for non windows systems
- Array of arguments for the node build make step
- default: `[]`
- #### `vcBuild: string[]`
- Alias for `make` option
- Options for windows build
- default: `['nosign', 'release']`
- #### `snapshot: string`
- path to a file to be used as the warmup snapshot for the build
- default: `null`
BIN
View File
Binary file not shown.
+83 -63
View File
@@ -1,6 +1,6 @@
{
"name": "nexe",
"version": "3.0.0-beta.0",
"version": "3.0.0-beta.9",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -37,9 +37,9 @@
}
},
"@types/chai": {
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.5.tgz",
"integrity": "sha512-nyzJ08qQMY4umgXD6SzbLflQucEnoAf2H5iUxPX5t0euDgXDV+bFTJlEmEepM35/2l07jYHdAfP6YEndeTWM0w==",
"version": "4.1.7",
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.7.tgz",
"integrity": "sha512-2Y8uPt0/jwjhQ6EiluT0XCri1Dbplr0ZxfFXUz+ye13gaqE8u5gL5ppao1JrUYr9cIip5S6MvQzBS7Kke7U9VA==",
"dev": true
},
"@types/events": {
@@ -79,12 +79,13 @@
}
},
"@types/got": {
"version": "8.3.4",
"resolved": "https://registry.npmjs.org/@types/got/-/got-8.3.4.tgz",
"integrity": "sha512-0AbIQzpqQafYPFg26nwg5PfNgPLYwHeTP6z5F1u+5oypLIdpx34o5r8wYTTj3X3YYF2yPHtZPO/KYwlI8Nu/hQ==",
"version": "9.2.0",
"resolved": "https://registry.npmjs.org/@types/got/-/got-9.2.0.tgz",
"integrity": "sha512-6aWDCt7AO0rhQSjnk+aLFIPfStFH1tMNQ9KLLfOT9SctmjOEndrqoo5Bw/YEIFYY2QRy744D/qUc2F3a3+mLsw==",
"dev": true,
"requires": {
"@types/node": "*"
"@types/node": "*",
"@types/tough-cookie": "*"
}
},
"@types/minimatch": {
@@ -160,6 +161,17 @@
"integrity": "sha512-41qEJgBH/TWgo5NFSvBCJ1qkoi3Q6ONSF2avrHq1LVEZfYpdHmj0y9SuTK+u9ZhG1sYQKBL1AWXKyLWP4RaUoQ==",
"dev": true
},
"@types/tough-cookie": {
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-2.3.4.tgz",
"integrity": "sha512-Set5ZdrAaKI/qHdFlVMgm/GsAv/wkXhSTuZFkJ+JI7HK+wIkIlOaUXSXieIvJ0+OvGIqtREFoE+NHJtEq0gtEw==",
"dev": true
},
"acorn": {
"version": "6.0.4",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.0.4.tgz",
"integrity": "sha512-VY4i5EKSKkofY2I+6QLTbTTN/UvEQPCo6eiwzzSaSWfpaDhOmStMCMod6wmuPciNq+XS0faCglFu2lHZpdHUtg=="
},
"ansi-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
@@ -520,17 +532,17 @@
}
},
"chai": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz",
"integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=",
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz",
"integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==",
"dev": true,
"requires": {
"assertion-error": "^1.0.1",
"check-error": "^1.0.1",
"deep-eql": "^3.0.0",
"assertion-error": "^1.1.0",
"check-error": "^1.0.2",
"deep-eql": "^3.0.1",
"get-func-name": "^2.0.0",
"pathval": "^1.0.0",
"type-detect": "^4.0.0"
"pathval": "^1.1.0",
"type-detect": "^4.0.5"
}
},
"chalk": {
@@ -967,9 +979,9 @@
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
},
"eslint-plugin-prettier": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-2.6.2.tgz",
"integrity": "sha512-tGek5clmW5swrAx1mdPYM8oThrBE83ePh7LeseZHBWfHVGrHPhKn7Y5zgRMbU/9D5Td9K4CEmUPjGxA7iw98Og==",
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-2.7.0.tgz",
"integrity": "sha512-CStQYJgALoQBw3FsBzH0VOVDRnJ/ZimUlpLm226U8qgqYJfPOY/CPK6wyRInMxh73HSKg5wyRwdS4BVYYHwokA==",
"dev": true,
"requires": {
"fast-diff": "^1.1.1",
@@ -1142,9 +1154,9 @@
}
},
"fast-diff": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.1.2.tgz",
"integrity": "sha512-KaJUt+M9t1qaIteSvjc6P3RbMdXsNhK61GRftR6SNxqmhthcd9MGIi4T+o0jD8LUSpSnSKXE20nLtJ3fOHxQig==",
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz",
"integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==",
"dev": true
},
"fast-glob": {
@@ -1324,34 +1336,35 @@
}
},
"got": {
"version": "9.2.2",
"resolved": "https://registry.npmjs.org/got/-/got-9.2.2.tgz",
"integrity": "sha512-XLXmtO1QxLuzj6t4JBClWD1NI/bMvsR9utYl0yyPg49eUJjqU7HaQhPDvSVGwYoSbAqsRfe5aNZXHl1Zctzwmw==",
"version": "9.3.2",
"resolved": "https://registry.npmjs.org/got/-/got-9.3.2.tgz",
"integrity": "sha512-OyKOUg71IKvwb8Uj0KP6EN3+qVVvXmYsFznU1fnwUnKtDbZnwSlAi7muNlu4HhBfN9dImtlgg9e7H0g5qVdaeQ==",
"requires": {
"@sindresorhus/is": "^0.11.0",
"@sindresorhus/is": "^0.12.0",
"@szmarczak/http-timer": "^1.1.0",
"cacheable-request": "^5.0.0",
"cacheable-request": "^5.1.0",
"decompress-response": "^3.3.0",
"duplexer3": "^0.1.4",
"get-stream": "^4.0.0",
"get-stream": "^4.1.0",
"lowercase-keys": "^1.0.1",
"mimic-response": "^1.0.1",
"p-cancelable": "^0.5.0",
"p-cancelable": "^1.0.0",
"to-readable-stream": "^1.0.0",
"url-parse-lax": "^3.0.0"
},
"dependencies": {
"@sindresorhus/is": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.11.0.tgz",
"integrity": "sha512-i5Zh5+3QARyXtzq3Bd2Lg3aBRFLcgYbNoap3Hyu1uRN8X+D+0JMqqc4uk4XjhNxfVdCnL8WHUA2wxa33QCC50w==",
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.12.0.tgz",
"integrity": "sha512-9ve22cGrAKlSRvi8Vb2JIjzcaaQg79531yQHnF+hi/kOpsSj3Om8AyR1wcHrgl0u7U3vYQ7gmF5erZzOp4+51Q==",
"requires": {
"symbol-observable": "^1.2.0"
}
},
"cacheable-request": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-5.0.0.tgz",
"integrity": "sha512-gU53XCfodl+GZ37ecX/uLobGE+WvgE2QE3VfhX7sPf04Kc35tNPip3IfCKfqJ2e04HLuHRxFCWgGWttv8OQbfw==",
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-5.2.0.tgz",
"integrity": "sha512-h1n0vjpFaByTvU6PiyTKk2kx4OnuV1aVUynCUd/FiKl4icpPSceowk3rHczwFEBuZvz+E1EU4KExR0MCPeQfaQ==",
"requires": {
"clone-response": "^1.0.2",
"get-stream": "^4.0.0",
@@ -1363,9 +1376,9 @@
}
},
"get-stream": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.0.0.tgz",
"integrity": "sha512-FneLKMENeOR7wOK0/ZXCh+lwqtnPwkeunJjRN28LPqzGvNAhYvrTAhXv6xDm4vsJ0M7lcRbIYHQudKsSy2RtSQ==",
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz",
"integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==",
"requires": {
"pump": "^3.0.0"
}
@@ -1381,9 +1394,9 @@
"integrity": "sha512-U+JJi7duF1o+u2pynbp2zXDW2/PADgC30f0GsHZtRh+HOcXHnw137TrNlyxxRvWW5fjKd3bcLHPxofWuCjaeZg=="
},
"p-cancelable": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-0.5.1.tgz",
"integrity": "sha512-vkOBXQgQb03QTOoMeeB5/uS2W3iafXzQLaIh7ChHjEb8DDT06sWJizhdOACL1Sittl5dFqsyumJ4rD1WUF8Isw=="
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-1.0.0.tgz",
"integrity": "sha512-USgPoaC6tkTGlS831CxsVdmZmyb8tR1D+hStI84MyckLOzfJlYQUweomrwE3D8T7u5u5GVuW064LT501wHTYYA=="
}
}
},
@@ -1713,6 +1726,12 @@
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
"integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA=="
},
"lines-and-columns": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz",
"integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=",
"dev": true
},
"log-symbols": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz",
@@ -2138,9 +2157,9 @@
"integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA="
},
"pify": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-4.0.0.tgz",
"integrity": "sha512-zrSP/KDf9DH3K3VePONoCstgPiYJy9z0SCatZuTpOc7YdnWIqwkWdXOuwlr4uDc7em8QZRsFWsT/685x5InjYg=="
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
"integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g=="
},
"pinkie": {
"version": "2.0.4",
@@ -2166,9 +2185,9 @@
"integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc="
},
"prettier": {
"version": "1.14.3",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.14.3.tgz",
"integrity": "sha512-qZDVnCrnpsRJJq5nSsiHCE3BYMED2OtsI+cmzIzF1QIfqm5ALf8tEJcO27zV1gKNKRPdhjO0dNWnrzssDQ1tFg==",
"version": "1.15.2",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.15.2.tgz",
"integrity": "sha512-YgPLFFA0CdKL4Eg2IHtUSjzj/BWgszDHiNQAe0VAIBse34148whfdzLagRL+QiKS+YfK5ftB6X4v/MBw8yCoug==",
"dev": true
},
"process-nextick-args": {
@@ -2248,12 +2267,12 @@
}
},
"resolve-dependencies": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/resolve-dependencies/-/resolve-dependencies-2.1.1.tgz",
"integrity": "sha512-Qmd1eEp9CmAZZx1e3scW2Cof0kauO3Y6jKMoZIm8RN/BWwkfhUdfLV+qpb7+ONITVmqWFUdHb6r62HSlmAMv5Q==",
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/resolve-dependencies/-/resolve-dependencies-2.2.0.tgz",
"integrity": "sha512-XIF2ujfs7qBOa4awXgdpQfhCawKiwOeUT/n9YlaipKHqj2iO41t56QDKdO0GGluPs4QduzKtbbM/B+iYPlQVUA==",
"requires": {
"@calebboyd/semaphore": "^1.3.1",
"cherow": "^1.6.8",
"acorn": "^6.0.4",
"enhanced-resolve": "^4.1.0",
"globby": "^8.0.1",
"pify": "^4.0.0"
@@ -2625,9 +2644,9 @@
"integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ=="
},
"tapable": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-1.0.0.tgz",
"integrity": "sha512-dQRhbNQkRnaqauC7WqSJ21EEksgT0fYZX2lqXzGkpo8JNig9zGZTYoMGvyI2nWmXlE2VSVXVDu7wLVGu/mQEsg=="
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.0.tgz",
"integrity": "sha512-IlqtmLVaZA2qab8epUXbVWRn3aB1imbDMJtjB3nu4X0NqPkcY/JH9ZtCBWKHWPxs8Svi9tyo8w2dBoi07qZbBA=="
},
"tar-stream": {
"version": "1.6.1",
@@ -2752,18 +2771,19 @@
}
},
"tslint-config-prettier": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.15.0.tgz",
"integrity": "sha512-06CgrHJxJmNYVgsmeMoa1KXzQRoOdvfkqnJth6XUkNeOz707qxN0WfxfhYwhL5kXHHbYJRby2bqAPKwThlZPhw==",
"version": "1.16.0",
"resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.16.0.tgz",
"integrity": "sha512-zu6RAcpBtqdvhT6KpBh9kRPYATjOf9BnRi718kNqVKFjEgSE4rFrPprFju1YJrkOa3RbtbWI1ZSuLd2NBX1MDw==",
"dev": true
},
"tslint-plugin-prettier": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/tslint-plugin-prettier/-/tslint-plugin-prettier-2.0.0.tgz",
"integrity": "sha512-nA8yM+1tS9dylirSajTxxFV6jCQrIMQ0Ykl//jjRgqmwwmGp3hqodG+rtr16S/OUwyQBfoFScFDK7nuHYPd4Gw==",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/tslint-plugin-prettier/-/tslint-plugin-prettier-2.0.1.tgz",
"integrity": "sha512-4FX9JIx/1rKHIPJNfMb+ooX1gPk5Vg3vNi7+dyFYpLO+O57F4g+b/fo1+W/G0SUOkBLHB/YKScxjX/P+7ZT/Tw==",
"dev": true,
"requires": {
"eslint-plugin-prettier": "^2.2.0",
"lines-and-columns": "^1.1.6",
"tslib": "^1.7.1"
}
},
@@ -2791,9 +2811,9 @@
"dev": true
},
"typescript": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.0.3.tgz",
"integrity": "sha512-kk80vLW9iGtjMnIv11qyxLqZm20UklzuR2tL0QAnDIygIUIemcZMxlMWudl9OOt76H3ntVzcTiddQ1/pAAJMYg==",
"version": "3.1.6",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.1.6.tgz",
"integrity": "sha512-tDMYfVtvpb96msS1lDX9MEdHrW4yOuZ4Kdc4Him9oU796XldPYF/t2+uKoX0BBa0hXXwDlqYQbXY5Rzjzc5hBA==",
"dev": true
},
"uglify-es": {
+11 -11
View File
@@ -2,7 +2,7 @@
"name": "nexe",
"description": "Create a single executable out of your Node.js application",
"license": "MIT",
"version": "3.0.0-beta.1",
"version": "3.0.0-beta.9",
"contributors": [
"Craig Condon <craig.j.condon@gmail.com> (http://crcn.io)",
"Jared Allard <jaredallard@outlook.com>",
@@ -40,20 +40,20 @@
"cherow": "^1.6.8",
"download": "^7.1.0",
"globby": "^8.0.1",
"got": "^9.2.2",
"got": "^9.3.2",
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
"multistream": "^2.1.1",
"ora": "^3.0.0",
"pify": "^4.0.0",
"resolve-dependencies": "^2.1.1",
"pify": "^4.0.1",
"resolve-dependencies": "^2.2.0",
"rimraf": "^2.6.2"
},
"devDependencies": {
"@types/chai": "^4.1.5",
"@types/chai": "^4.1.7",
"@types/execa": "^0.9.0",
"@types/globby": "^8.0.0",
"@types/got": "^8.3.4",
"@types/got": "^9.2.0",
"@types/minimist": "^1.2.0",
"@types/mkdirp": "^0.5.2",
"@types/mocha": "^5.2.5",
@@ -62,14 +62,14 @@
"@types/pify": "3.0.2",
"@types/rimraf": "2.0.2",
"@types/semver": "^5.5.0",
"chai": "^4.1.2",
"chai": "^4.2.0",
"execa": "^1.0.0",
"mocha": "^5.2.0",
"prettier": "^1.14.3",
"prettier": "^1.15.2",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"tslint-plugin-prettier": "^2.0.0",
"typescript": "^3.0.3"
"tslint-config-prettier": "^1.16.0",
"tslint-plugin-prettier": "^2.0.1",
"typescript": "^3.1.6"
}
}
+77 -5
View File
@@ -4,7 +4,16 @@ import { createReadStream } from 'fs'
import { Readable, Stream } from 'stream'
import { spawn } from 'child_process'
import { Logger, LogStep } from './logger'
import { readFileAsync, writeFileAsync, pathExistsAsync, dequote, isWindows, bound } from './util'
import {
readFileAsync,
writeFileAsync,
pathExistsAsync,
statAsync,
dequote,
isWindows,
bound,
semverGt
} from './util'
import { NexeOptions, version } from './options'
import { NexeTarget } from './target'
import download = require('download')
@@ -26,20 +35,60 @@ export interface NexeFile {
export { NexeOptions }
export class NexeCompiler {
/**
* Epoch of when compilation started
*/
private start = Date.now()
/**
* Copy of process.env
*/
private env = { ...process.env }
/**
* Virtual FileSystem
*/
private bundle: Bundle
private compileStep: LogStep | undefined
public log = new Logger(this.options.loglevel)
/**
* Root directory for the source of the current build
*/
public src: string
/**
* In memory files that are being manipulated by the compiler
*/
public files: NexeFile[] = []
/**
* Standalone pieces of code run before the application entrypoint
*/
public shims: string[] = []
/**
* The last shim (defaults to "require('module').runMain()")
*/
public startup: string = ''
/**
* The main entrypoint filename for your application - eg. node mainFile.js
*/
public entrypoint: string | undefined
public bundledInput?: string
/**
* Not used
*/
public targets: NexeTarget[]
/**
* Current target of the compiler
*/
public target: NexeTarget
/**
* Output filename (-o myapp.exe)
*/
public output = this.options.output
/**
* Path to the configure script
*/
public configureScript: string
/**
* The file path of node binary
*/
private nodeSrcBinPath: string
constructor(public options: NexeOptions) {
@@ -47,6 +96,7 @@ export class NexeCompiler {
this.targets = options.targets as NexeTarget[]
this.target = this.targets[0]
this.src = join(this.options.temp, this.target.version)
this.configureScript = configure + (semverGt(this.target.version, '10.10.0') ? '.py' : '')
this.nodeSrcBinPath = isWindows
? join(this.src, 'Release', 'node.exe')
: join(this.src, 'out', 'Release', 'node')
@@ -166,7 +216,7 @@ export class NexeCompiler {
private _configureAsync() {
return this._runBuildCommandAsync(this.env.PYTHON || 'python', [
configure,
this.configureScript,
...this.options.configure
])
}
@@ -219,6 +269,28 @@ export class NexeCompiler {
return createReadStream(filename)
}
private async _shouldCompileBinaryAsync(
binary: NodeJS.ReadableStream | null,
location: string | undefined
) {
//TODO combine make/configure/vcBuild/and modified times of included files
const { snapshot, build } = this.options
if (!binary) {
return true
}
if (build && snapshot != null && (await pathExistsAsync(snapshot))) {
const snapshotLastModified = (await statAsync(snapshot)).mtimeMs
const binaryLastModified = (await statAsync(location)).mtimeMs
// if build was requested and there's a snapshot to embed in the binary,
// we need to rebuild if the snapshot was just modified.
return snapshotLastModified > binaryLastModified
}
return false
}
async compileAsync(target: NexeTarget) {
const step = (this.compileStep = this.log.step('Compiling result'))
const build = this.options.build
@@ -228,11 +300,11 @@ export class NexeCompiler {
step.modify('Fetching prebuilt binary')
binary = await this._fetchPrebuiltBinaryAsync(target)
}
if (!binary) {
if (await this._shouldCompileBinaryAsync(binary, location)) {
binary = await this._buildAsync()
step.log('Node binary compiled')
}
return this._assembleDeliverable(binary)
return this._assembleDeliverable(binary!)
}
code() {
+18 -13
View File
@@ -1,15 +1,20 @@
const __nexe_patches = (process.nexe = { patches: {} }).patches
function __nexe_noop_patch(original, ...args) {
return original.call(this, ...args)
}
function __nexe_patch(obj, method, patch) {
const original = obj[method]
if (!original) return
__nexe_patches[method] = patch
obj[method] = function( ...args) {
return __nexe_patches[method].call(this, original, ...args)
if (true) {
const __nexe_patches = (process.nexe = { patches: {} }).patches
const slice = [].slice
const __nexe_noop_patch = function (original) {
const args = slice.call(arguments, 1)
return original.apply(this, args)
}
const __nexe_patch = function (obj, method, patch) {
const original = obj[method]
if (!original) return
__nexe_patches[method] = patch
obj[method] = function() {
const args = [original].concat(slice.call(arguments))
return __nexe_patches[method].apply(this, args)
}
}
__nexe_patch((process).binding('fs'), 'internalModuleReadFile', __nexe_noop_patch)
__nexe_patch((process).binding('fs'), 'internalModuleReadJSON', __nexe_noop_patch)
__nexe_patch((process).binding('fs'), 'internalModuleStat', __nexe_noop_patch)
}
__nexe_patch((process).binding('fs'), 'internalModuleReadFile', __nexe_noop_patch)
__nexe_patch((process).binding('fs'), 'internalModuleReadJSON', __nexe_noop_patch)
__nexe_patch((process).binding('fs'), 'internalModuleStat', __nexe_noop_patch)
+1
View File
@@ -301,6 +301,7 @@ function shimFs(binary: NexeBinary, fs: any = require('fs')) {
log('read (miss) ' + filepath)
return original.call(this, ...args)
}
patches.internalModuleReadJSON = patches.internalModuleReadFile
patches.internalModuleStat = function(this: any, original: any, ...args: any[]) {
setupManifest()
const [filepath] = args
+1 -1
View File
@@ -244,7 +244,7 @@ function normalizeOptions(input?: Partial<NexeOptions>): NexeOptions {
options.targets.push(getTarget())
}
options.ghToken = options.ghToken || process.env.GITHUB_TOKEN || ''
options.make = flatten(options.vcBuild, options.make)
options.make = flatten(isWindows ? options.vcBuild : options.make)
options.configure = flatten(options.configure)
options.resources = flatten(opts.resource, options.resources)
+14 -9
View File
@@ -1,20 +1,25 @@
import { NexeCompiler } from '../compiler'
import { semverGt } from '../util'
export default async function disableNodeCli(compiler: NexeCompiler, next: () => Promise<void>) {
if (compiler.options.enableNodeCli) {
return next()
}
const nodeccMarker = 'argv[index][0] =='
if (semverGt(compiler.target.version, '9.99')) {
await compiler.replaceInFileAsync('src/node.cc', /(?<!void )ProcessArgv\(/g, '//ProcessArgv(')
} else {
const nodeccMarker = 'argv[index][0] =='
await compiler.replaceInFileAsync(
'src/node.cc',
`${nodeccMarker} '-'`,
// allow NODE_OPTIONS, introduced in 8.0
parseInt(compiler.target.version.split('.')[0]) >= 8
? `(${nodeccMarker} (is_env ? '-' : ']'))`
: `(${nodeccMarker} ']')`
)
await compiler.replaceInFileAsync(
'src/node.cc',
`${nodeccMarker} '-'`,
// allow NODE_OPTIONS, introduced in 8.0
semverGt(compiler.target.version, '7.99')
? `(${nodeccMarker} (is_env ? '-' : ']'))`
: `(${nodeccMarker} ']')`
)
}
return next()
}
+2 -1
View File
@@ -5,7 +5,8 @@ import cli from './disable-node-cli'
import flags from './flags'
import ico from './ico'
import rc from './node-rc'
import snapshot from './snapshot'
const patches = [gyp, bootNexe, buildFixes, cli, flags, ico, rc]
const patches = [gyp, bootNexe, buildFixes, cli, flags, ico, rc, snapshot]
export default patches
+9 -7
View File
@@ -1,18 +1,20 @@
import { resolve } from 'path'
import { NexeCompiler } from '../compiler'
export default async function snapshot(compiler: NexeCompiler, next: () => Promise<void>) {
const snapshotFile = compiler.options.snapshot
const warmupScript = compiler.options.warmup
export default async function(compiler: NexeCompiler, next: () => Promise<void>) {
const { snapshot, warmup, cwd } = compiler.options
if (!snapshotFile) {
if (!snapshot) {
return next()
}
await compiler.replaceInFileAsync(
'configure',
compiler.configureScript,
'def configure_v8(o):',
`def configure_v8(o):\n o['variables']['embed_script'] = '${snapshotFile}'\n o['variables']['warmup_script'] = '${warmupScript ||
snapshotFile}'`
`def configure_v8(o):\n o['variables']['embed_script'] = r'${resolve(
cwd,
snapshot
)}'\n o['variables']['warmup_script'] = r'${resolve(cwd, warmup || snapshot)}'`
)
return next()
+1 -11
View File
@@ -1,16 +1,6 @@
import { NexeCompiler } from '../compiler'
import { parse } from 'cherow'
function semverGt(version: string, operand: string) {
const [cMajor, cMinor, cPatch] = version.split('.').map(Number)
const [major, minor, patch] = operand.split('.').map(Number)
return (
cMajor > major ||
(cMajor === major && cMinor > minor) ||
(cMajor === major && cMinor === minor && cPatch > patch)
)
}
import { semverGt } from '../util'
function walkSome(node: any, visit: Function) {
if (!node || typeof node.type !== 'string' || node._visited) {
+1 -1
View File
@@ -22,7 +22,7 @@ export default function(compiler: NexeCompiler, next: () => Promise<void>) {
compiler.shims.push(
wrap(`
if (!process.send) {
process.argv.splice(1,0, require.resolve("${compiler.entrypoint}"))
process.argv.splice(1,0, require.resolve(${JSON.stringify(compiler.entrypoint)}))
}
`)
)
+16
View File
@@ -80,10 +80,26 @@ function isDirectoryAsync(path: string) {
.then(x => x.isDirectory())
.catch(falseOnEnoent)
}
/**
* @param version See if this version is greather than the second one
* @param operand Version to compare against
*/
function semverGt(version: string, operand: string) {
const [cMajor, cMinor, cPatch] = version.split('.').map(Number)
let [major, minor, patch] = operand.split('.').map(Number)
if (!minor) minor = 0
if (!patch) patch = 0
return (
cMajor > major ||
(cMajor === major && cMinor > minor) ||
(cMajor === major && cMinor === minor && cPatch > patch)
)
}
export {
dequote,
padRight,
semverGt,
bound,
isWindows,
rimrafAsync,
+3
View File
@@ -77,6 +77,9 @@ async function build() {
...headers,
'Content-Type': 'application/octet-stream'
}
}).catch(reason => {
console.log(reason && reason.response && reason.response.body)
throw reason
})
console.log(target + ' uploaded.')
}