You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by bi...@apache.org on 2016/03/13 09:45:20 UTC
[05/16] git commit: [flex-utilities] [refs/heads/develop] - Create
DownloadUncompressAndCopy.js to handle repeated download,
unzip and copy operations.
Create DownloadUncompressAndCopy.js to handle repeated download, unzip and copy operations.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/05bf73a2
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/05bf73a2
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/05bf73a2
Branch: refs/heads/develop
Commit: 05bf73a2c4d1fb5c21743571bc1280aea42f7329
Parents: 3447e16
Author: OmPrakash Muppirala <bi...@gmail.com>
Authored: Mon Nov 30 03:15:57 2015 -0800
Committer: OmPrakash Muppirala <bi...@gmail.com>
Committed: Sun Mar 13 00:44:07 2016 -0800
----------------------------------------------------------------------
npm-flexjs/dependencies/AdobeAIR.js | 2 +-
npm-flexjs/dependencies/ApacheFalcon.js | 105 ++++++++++++++++++-
npm-flexjs/dependencies/ApacheFlexJS.js | 21 +++-
npm-flexjs/dependencies/Constants.js | 4 +-
.../dependencies/DownloadUncompressAndCopy.js | 71 +++++++++++++
npm-flexjs/dependencies/FlashPlayerGlobal.js | 2 +-
npm-flexjs/dependencies/SWFObject.js | 2 +-
npm-flexjs/download_dependencies.js | 1 -
npm-flexjs/package.json | 3 +-
9 files changed, 198 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/05bf73a2/npm-flexjs/dependencies/AdobeAIR.js
----------------------------------------------------------------------
diff --git a/npm-flexjs/dependencies/AdobeAIR.js b/npm-flexjs/dependencies/AdobeAIR.js
index 1940c4e..7317fa5 100644
--- a/npm-flexjs/dependencies/AdobeAIR.js
+++ b/npm-flexjs/dependencies/AdobeAIR.js
@@ -64,7 +64,7 @@ AdobeAIR.downloadAdobeAIR = function()
console.log('Downloading Adobe AIR SDK');
request
.get(AdobeAIRURL + fileNameAdobeAIR)
- .pipe(fs.createWriteStream(constants.DOWNLOADS_FOLDER + '//' + fileNameAdobeAIR)
+ .pipe(fs.createWriteStream(constants.DOWNLOADS_FOLDER + fileNameAdobeAIR)
.on('finish', function(){
console.log('Adobe AIR download complete');
AdobeAIR.emit('complete');
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/05bf73a2/npm-flexjs/dependencies/ApacheFalcon.js
----------------------------------------------------------------------
diff --git a/npm-flexjs/dependencies/ApacheFalcon.js b/npm-flexjs/dependencies/ApacheFalcon.js
index 98e831e..d9d1c5e 100644
--- a/npm-flexjs/dependencies/ApacheFalcon.js
+++ b/npm-flexjs/dependencies/ApacheFalcon.js
@@ -21,14 +21,53 @@
var request = require('request');
var fs = require('fs');
var events = require('events');
+var unzip = require('unzip');
var constants = require('../dependencies/Constants');
+var duc = require('../dependencies/DownloadUncompressAndCopy');
var ApacheFalcon = module.exports = Object.create(events.EventEmitter.prototype);
//Falcon
var pathToFalconBinary = 'flex/falcon/0.5.0/binaries/';
var fileNameFalconBinary = 'apache-flex-falconjx-0.5.0-bin.zip';
+var falconCompilerLibFolder = 'falcon/compiler/lib/';
+
+//Antlr
+var antlrURL = 'http://search.maven.org/remotecontent?filepath=org/antlr/antlr-complete/3.5.2/antlr-complete-3.5.2.jar';
+var localFileNameAntlr = 'antlr.jar';
+
+var apacheCommonsURL = 'http://archive.apache.org/dist/commons/cli/binaries/';
+var fileNameApacheCommons = 'commons-cli-1.2-bin.zip';
+var localFileNameApacheCommons = 'commons-cli.jar';
+
+var falconDependencies = [
+ {
+ url:'http://search.maven.org/remotecontent?filepath=org/antlr/antlr-complete/3.5.2/',
+ remoteFileName:'antlr-complete-3.5.2.jar',
+ destinationPath:constants.DOWNLOADS_FOLDER + falconCompilerLibFolder,
+ destinationFileName:'antlr.jar',
+ unzip:false
+ },
+ {
+ url:'http://archive.apache.org/dist/commons/cli/binaries/',
+ remoteFileName:'commons-cli-1.2-bin.zip',
+ destinationPath:constants.DOWNLOADS_FOLDER,
+ destinationFileName:'',
+ pathOfFileToBeCopiedFrom:constants.DOWNLOADS_FOLDER + 'commons-cli-1.2/commons-cli-1.2.jar',
+ pathOfFileToBeCopiedTo:constants.DOWNLOADS_FOLDER + falconCompilerLibFolder + 'commons-cli.jar',
+ unzip:true
+ },
+ {
+ url:'http://archive.apache.org/dist/commons/io/binaries/',
+ remoteFileName:'commons-io-2.4-bin.zip',
+ destinationPath:constants.DOWNLOADS_FOLDER,
+ destinationFileName:'',
+ pathOfFileToBeCopiedFrom:constants.DOWNLOADS_FOLDER + 'commons-io-2.4/commons-io-2.4.jar',
+ pathOfFileToBeCopiedTo:constants.DOWNLOADS_FOLDER + falconCompilerLibFolder + 'commons-io.jar',
+ unzip:true
+ }
+];
ApacheFalcon.handleFalconMirrorsResponse = function (error, response, body)
{
@@ -39,14 +78,76 @@ ApacheFalcon.handleFalconMirrorsResponse = function (error, response, body)
console.log('Downloading Apache Falcon');
request
.get(falconPreferredDownloadURL)
- .pipe(fs.createWriteStream(constants.DOWNLOADS_FOLDER + '//' + fileNameFalconBinary)
+ .pipe(fs.createWriteStream(constants.DOWNLOADS_FOLDER + fileNameFalconBinary)
.on('finish', function(){
console.log('Apache Falcon download complete');
- ApacheFalcon.emit('complete');
+ ApacheFalcon.extract();
})
);
}
+};
+
+ApacheFalcon.extract = function()
+{
+ console.log('Extracting Apache Falcon');
+ fs.createReadStream(constants.DOWNLOADS_FOLDER + fileNameFalconBinary)
+ .pipe(unzip.Extract({ path: constants.DOWNLOADS_FOLDER + 'falcon'})
+ .on('finish', function(){
+ console.log('Apache Falcon extraction complete');
+ ApacheFalcon.prepareForFalconDependencies();
+ })
+ );
+};
+
+ApacheFalcon.prepareForFalconDependencies = function()
+{
+ //Create lib directory if it does not exist already
+ try
+ {
+ fs.mkdirSync(constants.DOWNLOADS_FOLDER + falconCompilerLibFolder);
+ }
+ catch(e)
+ {
+ if ( e.code != 'EEXIST' ) throw e;
+ }
+ ApacheFalcon.downloadDependencies();
+};
+
+var currentStep = -1;
+
+ApacheFalcon.downloadDependencies = function()
+{
+ ApacheFalcon.downloadNextDependency();
+};
+
+ApacheFalcon.downloadNextDependency = function()
+{
+ currentStep += 1;
+
+ if(currentStep >= falconDependencies.length)
+ {
+ ApacheFalcon.dependenciesComplete();
+ }
+ else
+ {
+ duc.on("downloadComplete", handleDependencyInstallComplete);
+ duc.install(falconDependencies[currentStep]);
+ }
+};
+
+function handleDependencyInstallComplete(event)
+{
+ ApacheFalcon.downloadNextDependency();
+}
+ApacheFalcon.dependenciesComplete = function()
+{
+ ApacheFalcon.falconInstallComplete();
+};
+
+ApacheFalcon.falconInstallComplete = function()
+{
+ ApacheFalcon.emit('complete');
};
ApacheFalcon.install = function()
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/05bf73a2/npm-flexjs/dependencies/ApacheFlexJS.js
----------------------------------------------------------------------
diff --git a/npm-flexjs/dependencies/ApacheFlexJS.js b/npm-flexjs/dependencies/ApacheFlexJS.js
index 5a42bbd..d618e87 100644
--- a/npm-flexjs/dependencies/ApacheFlexJS.js
+++ b/npm-flexjs/dependencies/ApacheFlexJS.js
@@ -21,6 +21,7 @@
var request = require('request');
var fs = require('fs');
var events = require('events');
+var unzip = require('unzip');
var constants = require('../dependencies/Constants');
@@ -39,15 +40,27 @@ ApacheFlexJS.handleFlexJSMirrorsResponse = function (error, response, body)
console.log('Downloading Apache FlexJS');
request
.get(flexJSPreferredDownloadURL)
- .pipe(fs.createWriteStream(constants.DOWNLOADS_FOLDER + '//' + fileNameFlexJSBinary)
+ .pipe(fs.createWriteStream(constants.DOWNLOADS_FOLDER + fileNameFlexJSBinary)
.on('finish', function(){
- console.log('Apache FlexJS download complete');
- ApacheFlexJS.emit('complete');
- })
+ console.log('Apache FlexJS download complete');
+ ApacheFlexJS.extract();
+ })
);
}
};
+ApacheFlexJS.extract = function()
+{
+ console.log('Extracting Apache FlexJS');
+ fs.createReadStream(constants.DOWNLOADS_FOLDER + fileNameFlexJSBinary)
+ .pipe(unzip.Extract({ path: constants.NODE_MODULES_FOLDER + constants.FLEXJS_FOLDER })
+ .on('finish', function(){
+ console.log('Apache FlexJS extraction complete');
+ ApacheFlexJS.emit('complete');
+ })
+ );
+};
+
ApacheFlexJS.install = function()
{
request(constants.APACHE_MIRROR_RESOLVER_URL + pathToFlexJSBinary + fileNameFlexJSBinary + '?' + constants.REQUEST_JSON_PARAM, ApacheFlexJS.handleFlexJSMirrorsResponse);
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/05bf73a2/npm-flexjs/dependencies/Constants.js
----------------------------------------------------------------------
diff --git a/npm-flexjs/dependencies/Constants.js b/npm-flexjs/dependencies/Constants.js
index 363e688..84539ae 100644
--- a/npm-flexjs/dependencies/Constants.js
+++ b/npm-flexjs/dependencies/Constants.js
@@ -22,5 +22,7 @@ module.exports =
{
APACHE_MIRROR_RESOLVER_URL : 'http://www.apache.org/dyn/mirrors/mirrors.cgi/',
REQUEST_JSON_PARAM : 'asjson=true',
- DOWNLOADS_FOLDER : 'downloads'
+ DOWNLOADS_FOLDER : 'downloads/',
+ FLEXJS_FOLDER: 'flexjs',
+ NODE_MODULES_FOLDER: 'node_modules/'
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/05bf73a2/npm-flexjs/dependencies/DownloadUncompressAndCopy.js
----------------------------------------------------------------------
diff --git a/npm-flexjs/dependencies/DownloadUncompressAndCopy.js b/npm-flexjs/dependencies/DownloadUncompressAndCopy.js
new file mode 100644
index 0000000..1c6d1fe
--- /dev/null
+++ b/npm-flexjs/dependencies/DownloadUncompressAndCopy.js
@@ -0,0 +1,71 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+var request = require('request');
+var fs = require('fs');
+var events = require('events');
+var prompt = require('prompt');
+var unzip = require('unzip');
+var constants = require('../dependencies/Constants');
+
+var DownloadUncompressAndCopy = module.exports = Object.create(events.EventEmitter.prototype);
+
+DownloadUncompressAndCopy.downloadFile = function(item)
+{
+ console.log('Downloading: ' + item.url + item.remoteFileName);
+ request
+ .get(item.url + item.remoteFileName)
+ .pipe(fs.createWriteStream(constants.DOWNLOADS_FOLDER + item.remoteFileName)
+ .on('finish', function(){
+ console.log('Finished downloading: ' + item.url + item.remoteFileName);
+ if(item.unzip)
+ {//Unzip
+ console.log('Uncompressing: ' + constants.DOWNLOADS_FOLDER + item.remoteFileName);
+ fs.createReadStream(constants.DOWNLOADS_FOLDER + item.remoteFileName)
+ .pipe(unzip.Extract({ path: item.destinationPath + item.destinationFileName})
+ .on('finish', function(){
+ console.log('Finished uncompressing: ' + constants.DOWNLOADS_FOLDER + item.remoteFileName + ' to: ' + item.destinationPath + item.destinationFileName);
+ if(item.pathOfFileToBeCopiedTo != undefined)
+ {
+ fs.createReadStream(item.pathOfFileToBeCopiedFrom)
+ .pipe(fs.createWriteStream(item.pathOfFileToBeCopiedTo)
+ .on('finish',function(){
+ DownloadUncompressAndCopy.emit('downloadComplete');
+ }));
+ }
+ })
+ );
+ }
+ else
+ {//Just copy
+ fs.createReadStream(constants.DOWNLOADS_FOLDER + item.remoteFileName)
+ .pipe(fs.createWriteStream(item.destinationPath + item.destinationFileName)
+ .on('finish',function() {
+ DownloadUncompressAndCopy.emit('downloadComplete');
+ }));
+ }
+ })
+ );
+};
+
+DownloadUncompressAndCopy.install = function(item)
+{
+ DownloadUncompressAndCopy.downloadFile(item);
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/05bf73a2/npm-flexjs/dependencies/FlashPlayerGlobal.js
----------------------------------------------------------------------
diff --git a/npm-flexjs/dependencies/FlashPlayerGlobal.js b/npm-flexjs/dependencies/FlashPlayerGlobal.js
index dc44efa..1b820e8 100644
--- a/npm-flexjs/dependencies/FlashPlayerGlobal.js
+++ b/npm-flexjs/dependencies/FlashPlayerGlobal.js
@@ -71,7 +71,7 @@ FlashPlayerGlobal.downloadFlashPlayerGlobal = function()
console.log('Downloading Adobe FlashPlayerGlobal.swc ');
request
.get(flashPlayerGlobalURL + fileNameFlashPlayerGlobal)
- .pipe(fs.createWriteStream(constants.DOWNLOADS_FOLDER + '//' + fileNameFlashPlayerGlobal)
+ .pipe(fs.createWriteStream(constants.DOWNLOADS_FOLDER + fileNameFlashPlayerGlobal)
.on('finish', function(){
console.log('FlashPlayerGlobal download complete');
FlashPlayerGlobal.emit('complete');
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/05bf73a2/npm-flexjs/dependencies/SWFObject.js
----------------------------------------------------------------------
diff --git a/npm-flexjs/dependencies/SWFObject.js b/npm-flexjs/dependencies/SWFObject.js
index 6a4934d..7af6052 100644
--- a/npm-flexjs/dependencies/SWFObject.js
+++ b/npm-flexjs/dependencies/SWFObject.js
@@ -35,7 +35,7 @@ SWFObject.downloadSwfObject = function()
console.log('Downloading SWFObject');
request
.get(swfObjectURL)
- .pipe(fs.createWriteStream(constants.DOWNLOADS_FOLDER + '//' + fileNameSwfObject)
+ .pipe(fs.createWriteStream(constants.DOWNLOADS_FOLDER + fileNameSwfObject)
.on('finish', function(){
console.log('SWFObject download complete');
SWFObject.emit('complete');
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/05bf73a2/npm-flexjs/download_dependencies.js
----------------------------------------------------------------------
diff --git a/npm-flexjs/download_dependencies.js b/npm-flexjs/download_dependencies.js
index 87a2469..122fe6d 100644
--- a/npm-flexjs/download_dependencies.js
+++ b/npm-flexjs/download_dependencies.js
@@ -55,7 +55,6 @@ function createDownloadsDirectory()
handleInstallStepComplete();
}
-
function handleInstallStepComplete(event)
{
currentStep += 1;
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/05bf73a2/npm-flexjs/package.json
----------------------------------------------------------------------
diff --git a/npm-flexjs/package.json b/npm-flexjs/package.json
index d543f42..b16e4ac 100644
--- a/npm-flexjs/package.json
+++ b/npm-flexjs/package.json
@@ -10,8 +10,7 @@
"keywords": [
"flex",
"flexjs",
- "apache",
- "flexjs",
+ "apache flexjs",
"actionscript",
"as3",
"mxml",