From e5083c779b12f11f623a026d9688f408f40f823f Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Fri, 6 Sep 2019 18:00:08 +0530 Subject: [PATCH 1/2] Fix race condition in get_file --- lib/install.js | 16 ++++-- lib/src/install.js | 58 ---------------------- lib/test.js | 4 -- node_modules/@types/jest-diff/package.json | 24 +++++---- node_modules/@types/jest/package.json | 22 ++++---- node_modules/fs/package.json | 22 ++++---- node_modules/https/package.json | 22 ++++---- package-lock.json | 28 ++++++++--- src/install.ts | 12 ++++- 9 files changed, 94 insertions(+), 114 deletions(-) delete mode 100644 lib/src/install.js delete mode 100644 lib/test.js diff --git a/lib/install.js b/lib/install.js index 0caca88c..4cae30ea 100644 --- a/lib/install.js +++ b/lib/install.js @@ -18,14 +18,22 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); const core = __importStar(require("@actions/core")); const exec_1 = require("@actions/exec/lib/exec"); -var https = require('https'); +const https = require('https'); const fs = require('fs'); function get_file(filename) { return __awaiter(this, void 0, void 0, function* () { - let github_path = 'https://raw.githubusercontent.com/shivammathur/setup-php/develop/src/'; + let github_path = 'https://raw.githubusercontent.com/shivammathur/setup-php/master/src/'; const file = fs.createWriteStream(filename); - const request = https.get(github_path + filename, function (response) { - response.pipe(file); + file.on('open', function (fd) { + https.get(github_path + filename, function (response) { + response + .on('data', function (chunk) { + file.write(chunk); + }) + .on('end', function () { + file.end(); + }); + }); }); }); } diff --git a/lib/src/install.js b/lib/src/install.js deleted file mode 100644 index 4071ad69..00000000 --- a/lib/src/install.js +++ /dev/null @@ -1,58 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const core = __importStar(require("@actions/core")); -const exec_1 = require("@actions/exec/lib/exec"); -var https = require('https'); -const fs = require('fs'); -function get_file(filename) { - let github_path = 'https://raw.githubusercontent.com/shivammathur/setup-php/develop/src/'; - const file = fs.createWriteStream(filename); - const request = https.get(github_path + filename, function (response) { - response.pipe(file); - }); -} -function run() { - return __awaiter(this, void 0, void 0, function* () { - try { - const version = core.getInput('php-version', { required: true }); - console.log('Input: ' + version); - let os_version = process.platform; - if (os_version == 'darwin') { - get_file('darwin.sh'); - yield exec_1.exec('sudo chmod a+x darwin.sh'); - yield exec_1.exec('./darwin.sh ' + version); - } - else if (os_version == 'win32') { - get_file('windows.ps1'); - yield exec_1.exec('powershell windows.ps1 -version ' + version); - } - else if (os_version == 'linux') { - get_file('linux.sh'); - yield exec_1.exec('sudo chmod a+x linux.sh'); - yield exec_1.exec('./linux.sh ' + version); - } - } - catch (err) { - core.setFailed(err.message); - } - }); -} -run().then(() => { - console.log('done'); -}); diff --git a/lib/test.js b/lib/test.js deleted file mode 100644 index 3174e6cf..00000000 --- a/lib/test.js +++ /dev/null @@ -1,4 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -let v = process.env['php-version']; -console.log(v); diff --git a/node_modules/@types/jest-diff/package.json b/node_modules/@types/jest-diff/package.json index 35b882f9..73a0813b 100644 --- a/node_modules/@types/jest-diff/package.json +++ b/node_modules/@types/jest-diff/package.json @@ -1,32 +1,37 @@ { - "_from": "@types/jest-diff@*", + "_args": [ + [ + "@types/jest-diff@20.0.1", + "E:\\python\\setup-php" + ] + ], + "_development": true, + "_from": "@types/jest-diff@20.0.1", "_id": "@types/jest-diff@20.0.1", "_inBundle": false, "_integrity": "sha512-yALhelO3i0hqZwhjtcr6dYyaLoCHbAMshwtj6cGxTvHZAKXHsYGdff6E8EPw3xLKY0ELUTQ69Q1rQiJENnccMA==", "_location": "/@types/jest-diff", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "@types/jest-diff@*", + "raw": "@types/jest-diff@20.0.1", "name": "@types/jest-diff", "escapedName": "@types%2fjest-diff", "scope": "@types", - "rawSpec": "*", + "rawSpec": "20.0.1", "saveSpec": null, - "fetchSpec": "*" + "fetchSpec": "20.0.1" }, "_requiredBy": [ "/@types/jest" ], "_resolved": "https://registry.npmjs.org/@types/jest-diff/-/jest-diff-20.0.1.tgz", - "_shasum": "35cc15b9c4f30a18ef21852e255fdb02f6d59b89", - "_spec": "@types/jest-diff@*", - "_where": "E:\\python\\setup-php\\node_modules\\@types\\jest", + "_spec": "20.0.1", + "_where": "E:\\python\\setup-php", "bugs": { "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues" }, - "bundleDependencies": false, "contributors": [ { "name": "Alex Coles", @@ -34,7 +39,6 @@ } ], "dependencies": {}, - "deprecated": false, "description": "TypeScript definitions for jest-diff", "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped#readme", "license": "MIT", diff --git a/node_modules/@types/jest/package.json b/node_modules/@types/jest/package.json index c26c784c..943ad95e 100644 --- a/node_modules/@types/jest/package.json +++ b/node_modules/@types/jest/package.json @@ -1,32 +1,37 @@ { - "_from": "@types/jest@^24.0.13", + "_args": [ + [ + "@types/jest@24.0.18", + "E:\\python\\setup-php" + ] + ], + "_development": true, + "_from": "@types/jest@24.0.18", "_id": "@types/jest@24.0.18", "_inBundle": false, "_integrity": "sha512-jcDDXdjTcrQzdN06+TSVsPPqxvsZA/5QkYfIZlq1JMw7FdP5AZylbOc+6B/cuDurctRe+MziUMtQ3xQdrbjqyQ==", "_location": "/@types/jest", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "@types/jest@^24.0.13", + "raw": "@types/jest@24.0.18", "name": "@types/jest", "escapedName": "@types%2fjest", "scope": "@types", - "rawSpec": "^24.0.13", + "rawSpec": "24.0.18", "saveSpec": null, - "fetchSpec": "^24.0.13" + "fetchSpec": "24.0.18" }, "_requiredBy": [ "#DEV:/" ], "_resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.18.tgz", - "_shasum": "9c7858d450c59e2164a8a9df0905fc5091944498", - "_spec": "@types/jest@^24.0.13", + "_spec": "24.0.18", "_where": "E:\\python\\setup-php", "bugs": { "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues" }, - "bundleDependencies": false, "contributors": [ { "name": "Asana", @@ -120,7 +125,6 @@ "dependencies": { "@types/jest-diff": "*" }, - "deprecated": false, "description": "TypeScript definitions for Jest", "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped#readme", "license": "MIT", diff --git a/node_modules/fs/package.json b/node_modules/fs/package.json index bd177305..35cb69ca 100644 --- a/node_modules/fs/package.json +++ b/node_modules/fs/package.json @@ -1,34 +1,36 @@ { - "_from": "fs", + "_args": [ + [ + "fs@0.0.1-security", + "E:\\python\\setup-php" + ] + ], + "_from": "fs@0.0.1-security", "_id": "fs@0.0.1-security", "_inBundle": false, "_integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ=", "_location": "/fs", "_phantomChildren": {}, "_requested": { - "type": "tag", + "type": "version", "registry": true, - "raw": "fs", + "raw": "fs@0.0.1-security", "name": "fs", "escapedName": "fs", - "rawSpec": "", + "rawSpec": "0.0.1-security", "saveSpec": null, - "fetchSpec": "latest" + "fetchSpec": "0.0.1-security" }, "_requiredBy": [ - "#USER", "/" ], "_resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", - "_shasum": "8a7bd37186b6dddf3813f23858b57ecaaf5e41d4", - "_spec": "fs", + "_spec": "0.0.1-security", "_where": "E:\\python\\setup-php", "author": "", "bugs": { "url": "https://github.com/npm/security-holder/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "This package name is not currently in use, but was formerly occupied by another package. To avoid malicious use, npm is hanging on to the package name, but loosely, and we'll probably give it to you if you want it.", "homepage": "https://github.com/npm/security-holder#readme", "keywords": [], diff --git a/node_modules/https/package.json b/node_modules/https/package.json index 2782fe63..311b8e25 100644 --- a/node_modules/https/package.json +++ b/node_modules/https/package.json @@ -1,35 +1,37 @@ { - "_from": "https", + "_args": [ + [ + "https@1.0.0", + "E:\\python\\setup-php" + ] + ], + "_from": "https@1.0.0", "_id": "https@1.0.0", "_inBundle": false, "_integrity": "sha1-PDfHrhqO65ZpBKKtHpdaGUt+06Q=", "_location": "/https", "_phantomChildren": {}, "_requested": { - "type": "tag", + "type": "version", "registry": true, - "raw": "https", + "raw": "https@1.0.0", "name": "https", "escapedName": "https", - "rawSpec": "", + "rawSpec": "1.0.0", "saveSpec": null, - "fetchSpec": "latest" + "fetchSpec": "1.0.0" }, "_requiredBy": [ - "#USER", "/" ], "_resolved": "https://registry.npmjs.org/https/-/https-1.0.0.tgz", - "_shasum": "3c37c7ae1a8eeb966904a2ad1e975a194b7ed3a4", - "_spec": "https", + "_spec": "1.0.0", "_where": "E:\\python\\setup-php", "author": { "name": "hardus van der berg", "email": "hardus@sunfork.com", "url": "http://www.sunfork.com" }, - "bundleDependencies": false, - "deprecated": false, "description": "https mediation", "keywords": [ "https", diff --git a/package-lock.json b/package-lock.json index 7c42b262..a0fa3217 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1761,12 +1761,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -1781,17 +1783,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -1908,7 +1913,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -1920,6 +1926,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -1934,6 +1941,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -1941,12 +1949,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -1965,6 +1975,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -2045,7 +2056,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -2057,6 +2069,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -2178,6 +2191,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/src/install.ts b/src/install.ts index f69d08d6..da95a41c 100644 --- a/src/install.ts +++ b/src/install.ts @@ -7,8 +7,16 @@ async function get_file(filename: string) { let github_path: string = 'https://raw.githubusercontent.com/shivammathur/setup-php/master/src/'; const file: any = fs.createWriteStream(filename); - https.get(github_path + filename, function(response: any) { - response.pipe(file); + file.on('open', function(fd: any) { + https.get(github_path + filename, function(response: any) { + response + .on('data', function(chunk: any) { + file.write(chunk); + }) + .on('end', function() { + file.end(); + }); + }); }); } From 13824286dbc93ed89344b6528d28da3d44cde40e Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Fri, 6 Sep 2019 20:25:07 +0530 Subject: [PATCH 2/2] Install composer manually --- src/darwin.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/darwin.sh b/src/darwin.sh index 93dc4754..ba26b6f1 100644 --- a/src/darwin.sh +++ b/src/darwin.sh @@ -2,8 +2,11 @@ echo $1 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" brew unlink php brew tap exolnet/homebrew-deprecated +brew tap homebrew/homebrew-php brew install php@$1 brew link --force --overwrite php@$1 -brew install composer +curl -sS https://getcomposer.org/installer | php +chmod +x composer.phar +mv composer.phar /usr/local/bin/composer php -v composer -V \ No newline at end of file