Repository: flex-utilities Updated Branches: refs/heads/develop 5bd8a7987 -> b3f5ddc8f
Beginnings of npm install functionality for Apache FlexJS. WIP. Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/f6c7e2af Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/f6c7e2af Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/f6c7e2af Branch: refs/heads/develop Commit: f6c7e2afa4ab7e0fa2cec9803d4c34c6140307be Parents: 5bd8a79 Author: OmPrakash Muppirala <[email protected]> Authored: Mon Nov 23 02:21:05 2015 -0800 Committer: OmPrakash Muppirala <[email protected]> Committed: Sun Mar 13 00:44:00 2016 -0800 ---------------------------------------------------------------------- .gitignore | 2 + npm-flexjs/package.json | 27 +++++++++++++ npm-flexjs/prepublish.js | 93 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/f6c7e2af/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore index a1386da..b5fed5c 100644 --- a/.gitignore +++ b/.gitignore @@ -121,3 +121,5 @@ Squiggly/main/generated/ flex-installer/deps MD5Checker/MD5CheckerLog.txt +node_modules +npm-flexjs.iml http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/f6c7e2af/npm-flexjs/package.json ---------------------------------------------------------------------- diff --git a/npm-flexjs/package.json b/npm-flexjs/package.json new file mode 100644 index 0000000..d19c3a0 --- /dev/null +++ b/npm-flexjs/package.json @@ -0,0 +1,27 @@ +{ + "name": "apache-flexjs", + "version": "0.5.0", + "description": "Apache FlexJS", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "flex", + "flexjs", + "apache", + "flexjs", + "actionscript", + "as3", + "mxml", + "angularjs", + "reactjs" + ], + "author": "OmPrakash Muppirala <[email protected]>", + "license": "Apache-2.0", + "dependencies": { + "prompt": "^0.2.14", + "request": "^2.67.0", + "unzip": "^0.1.11" + } +} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/f6c7e2af/npm-flexjs/prepublish.js ---------------------------------------------------------------------- diff --git a/npm-flexjs/prepublish.js b/npm-flexjs/prepublish.js new file mode 100644 index 0000000..1ac5d20 --- /dev/null +++ b/npm-flexjs/prepublish.js @@ -0,0 +1,93 @@ +'use strict'; + +var request = require('request'); +var fs = require('fs'); +var prompt = require('prompt'); + +var apacheMirrorsCGI = 'http://www.apache.org/dyn/mirrors/mirrors.cgi/'; + +//FlexJS +var pathToFlexJSBinary = 'flex/flexjs/0.5.0/binaries/'; +var fileNameFlexJSBinary = 'apache-flex-flexjs-0.5.0-bin.zip'; + +//Falcon +var pathToFalconBinary = 'flex/falcon/0.5.0/binaries/'; +var fileNameFalconBinary = 'apache-flex-falconjx-0.5.0-bin.zip'; + +//Adobe AIR +var AdobeAIRURL = 'http://airdownload.adobe.com/air/win/download/20.0/'; +var fileNameAdobeAIR = 'AdobeAIRSDK.zip'; + +//Flash Player Global + +var requestJSON = 'asjson=true'; + +var createDownloadsDirectory = function() +{ + try { + fs.mkdirSync('downloads'); + } catch(e) { + if ( e.code != 'EEXIST' ) throw e; + } +} + +var handleFlexJSMirrorsResponse = function (error, response, body) +{ + if (!error && response.statusCode == 200) + { + var mirrors = JSON.parse(body); + var flexJSPreferredDownloadURL = mirrors.preferred + pathToFlexJSBinary + fileNameFlexJSBinary; + //Download FlexJS + //request(this.flexJSPreferredDownloadURL, handleFlexJSBinaryResponse); + request + .get(flexJSPreferredDownloadURL) + .on('response', function(response) { + }) + .pipe(fs.createWriteStream('downloads//' + fileNameFlexJSBinary)); + } + +}; + +var handleFalconMirrorsResponse = function (error, response, body) +{ + if (!error && response.statusCode == 200) + { + var mirrors = JSON.parse(body); + var falconPreferredDownloadURL = mirrors.preferred + pathToFalconBinary + fileNameFalconBinary; + //Download Falcon + request + .get(falconPreferredDownloadURL) + .on('response', function(response) { + }) + .pipe(fs.createWriteStream('downloads//' + fileNameFalconBinary)); + } + +}; + +var promptForAdobeAIR = function() +{ + var schema = { + properties: { + accept: { + description: "Do you accept Adobe's license?", + pattern: /^[YNyn\s]{1}$/, + message: 'Please respond with either y or n', + required: true + } + } + }; + prompt.start(); + prompt.get(schema, function (err, result) { + console.log(' accept?: ' + result.accept); + }); +}; + +createDownloadsDirectory(); +request(apacheMirrorsCGI + pathToFlexJSBinary + fileNameFlexJSBinary + '?' + requestJSON, handleFlexJSMirrorsResponse); +request(apacheMirrorsCGI + pathToFalconBinary + fileNameFalconBinary + '?' + requestJSON, handleFalconMirrorsResponse); +promptForAdobeAIR(); +//promptForFlashPlayerGlobal(); + +//Download Adobe AIR + +//Download Flash Player Global \ No newline at end of file
