From 00d9ec5c0e17603984517302f523820ed902437f Mon Sep 17 00:00:00 2001 From: shmyga Date: Fri, 27 Apr 2018 17:44:44 +0300 Subject: [PATCH] [flashplayer] update download link --- haxetool/flashplayer.js | 94 +++++++++++++---------------------------- haxetool/haxe.js | 2 - haxetool/project.js | 45 ++++++++++---------- haxetool/sdk.js | 4 +- haxetool/tail.js | 5 ++- 5 files changed, 58 insertions(+), 92 deletions(-) diff --git a/haxetool/flashplayer.js b/haxetool/flashplayer.js index 02073e5..1da0945 100755 --- a/haxetool/flashplayer.js +++ b/haxetool/flashplayer.js @@ -8,65 +8,46 @@ const exec = require('./exec'); const PluginError = require('plugin-error'); const colors = require('ansi-colors'); const log = require('fancy-log'); -const tar = require('tar'); const Vinyl = require('vinyl'); class FlashPlayer extends Sdk { - constructor(version) { + constructor(debug, version) { super(FlashPlayer.ID, version || FlashPlayer.VERSION); - } - - playerPath(debug) { - return this.path; + this.debug = debug; } prepare() { - let p = super.prepare(); - if (!this.prepared && os.type() === 'Linux') { - p = p.then(() => { - let arch = null; - if (os.arch() === 'ia32') { arch = 'i386'} - if (os.arch() === 'x64') { arch = 'x86_64'} - - const extract = (debug) => { - const v = this.version.split('.'); - const playerPath = this.playerPath(debug); - const archive = `${playerPath}/flashplayer${v[0]}_${v[1]}r${v[2]}_${v[3]}_linux_sa${debug ? '_debug' : ''}.${arch}.tar.gz`; - return fs.createReadStream(archive).pipe(tar.x({C: this.path})); - }; - - // ToDo: - return new Promise((success, fail) => { - extract().on('end', () => { - extract(true).on('end', success).on('error', fail) - }).on('error', fail); - }) - }) - } - return p; + return super.prepare(0) } get prepared() { try { - return fs.existsSync(`${this.flashPlayerBin()}`); + return fs.existsSync(this.flashPlayerBin); } catch (e) { return false; } } get link() { - return `https://fpdownload.macromedia.com/pub/flashplayer/installers/archive/fp_${this.version}_archive.zip`; + const baseUrl = `https://fpdownload.macromedia.com/pub/flashplayer/updaters/${this.version}/`; + if (Sdk.System.isWindows) { + return baseUrl + `flashplayer_${this.version}_sa${this.debug ? '_debug' : ''}.exe`; + } else if (Sdk.System.isLinux) { + return baseUrl + `flash_player_sa_linux${this.debug ? '_debug' : ''}.x86_64.tar.gz`; + } else { + throw `Unsupported os '${os.type()}'`; + } } - flashPlayerBin(debug) { + get flashPlayerBin() { if (os.type() === 'Windows_NT') { const v = this.version.split('.'); - const playerName = `flashplayer${v[0]}_${v[1]}r${v[2]}_${v[3]}_win_sa${debug ? '_debug' : ''}.exe`; - return `${this.playerPath(debug)}/${playerName}`; + const playerName = `flashplayer_${this.version}_sa${this.debug ? '_debug' : ''}.exe`; + return path.join(this.path, playerName); } else if (os.type() === 'Linux') { - const binPath = `${this.playerPath(debug)}/${debug ? 'flashplayerdebugger': 'flashplayer'}`; + const binPath = path.join(this.path, `flashplayer${this.debug ? 'debugger' : ''}`); fs.chmodSync(binPath, 0o755); return binPath; } else { @@ -76,18 +57,18 @@ class FlashPlayer extends Sdk { static get flashPlayerDir() { if (os.type() === 'Windows_NT') { - return `${process.env.APPDATA}/Macromedia/Flash Player`; + return path.join(process.env.APPDATA, 'Macromedia', 'Flash Player'); } else if (os.type() === 'Linux') { - return `${os.homedir()}/.macromedia/Flash_Player`; + return path.join(os.homedir(), '.macromedia', 'Flash_Player'); } } static get log() { - return `${this.flashPlayerDir}/Logs/flashlog.txt`; + return path.join(this.flashPlayerDir, 'Logs', 'flashlog.txt'); } static enableLog() { - const filename = `${os.homedir()}/mm.cfg`; + const filename = path.join(os.homedir(), 'mm.cfg'); const value = 'TraceOutputFileEnable=1'; if (fs.exists(filename)) { const data = fs.readFileSync(filename); @@ -100,7 +81,7 @@ class FlashPlayer extends Sdk { } static trust(value) { - const filename = `${this.flashPlayerDir}/#Security/FlashPlayerTrust/gulp.cfg`; + const filename = path.join(this.flashPlayerDir, '#Security', 'FlashPlayerTrust', 'gulp.cfg'); if (fs.exists(filename)) { const data = fs.readFileSync(filename); if (data.indexOf(value) === -1) { @@ -114,13 +95,13 @@ class FlashPlayer extends Sdk { } } - run(debug) { + run() { let stream = null; const bufferContents = (file, enc, callback) => { log(this.tag, colors.cyan("run"), colors.magenta(file.path)); FlashPlayer.trust(file.path); FlashPlayer.enableLog(); - exec('.', [this.flashPlayerBin(debug), file.path].join(' ')).then(() => { + exec('.', [this.flashPlayerBin, file.path].join(' ')).then(() => { stream.emit('end'); callback(); }).catch((error) => { @@ -140,29 +121,14 @@ class FlashPlayer extends Sdk { } } -FlashPlayer.ID = "flashplayer"; +FlashPlayer.ID = 'flashplayer'; -FlashPlayer.VERSION_11_2_202_644 = '11.2.202.644'; -FlashPlayer.VERSION_11 = FlashPlayer.VERSION_11_2_202_644; +FlashPlayer.VERSION_24 = '24'; +FlashPlayer.VERSION_25 = '25'; +FlashPlayer.VERSION_26 = '26'; +FlashPlayer.VERSION_27 = '27'; +FlashPlayer.VERSION_29 = '29'; -FlashPlayer.VERSION_24_0_0_186 = '24.0.0.186'; -FlashPlayer.VERSION_24_0_0_194 = '24.0.0.194'; -FlashPlayer.VERSION_24_0_0_221 = '24.0.0.221'; -FlashPlayer.VERSION_24 = FlashPlayer.VERSION_24_0_0_221; - -FlashPlayer.VERSION_25_0_0_127 = '25.0.0.127'; -FlashPlayer.VERSION_25_0_0_148 = '25.0.0.148'; -FlashPlayer.VERSION_25_0_0_163 = '25.0.0.163'; -FlashPlayer.VERSION_25_0_0_117 = '25.0.0.171'; -FlashPlayer.VERSION_25 = FlashPlayer.VERSION_25_0_0_117; - -FlashPlayer.VERSION_26_0_0_131 = '26.0.0.131'; -FlashPlayer.VERSION_26 = FlashPlayer.VERSION_26_0_0_131; - -if (os.type() === 'Linux' && os.arch() === 'ia32') { //Linux i386 - FlashPlayer.VERSION = FlashPlayer.VERSION_11; -} else { - FlashPlayer.VERSION = FlashPlayer.VERSION_26; -} +FlashPlayer.VERSION = FlashPlayer.VERSION_29; module.exports = FlashPlayer; \ No newline at end of file diff --git a/haxetool/haxe.js b/haxetool/haxe.js index 3490a46..4ebfc61 100755 --- a/haxetool/haxe.js +++ b/haxetool/haxe.js @@ -58,11 +58,9 @@ class Haxe extends Sdk { process.env.HAXE_VERSION = this.version; process.env.HAXE_STD_PATH = path.join(this.binPath, 'std'); process.env.HAXE_HOME = this.binPath; - console.log('process.env.PATH A', process.env.PATH); if (process.env.PATH.split(path.delimiter).indexOf(this.binPath) === -1) { process.env.PATH = [process.env.PATH, this.binPath].join(path.delimiter); } - console.log('process.env.PATH B', process.env.PATH); } prepare() { diff --git a/haxetool/project.js b/haxetool/project.js index 30daf34..96e67ee 100644 --- a/haxetool/project.js +++ b/haxetool/project.js @@ -3,10 +3,6 @@ const path = require('path'); const os = require('os'); const fs = require('fs'); const fse = require('fs-extra'); -//const concat = require('gulp-concat'); -//const uglify = require('gulp-uglify'); -//const babel = require('gulp-babel'); -//const template = require('gulp-template'); const Haxe = require('./haxe'); const FlashPlayer = require('./flashplayer'); const debug = require('./debug'); @@ -19,6 +15,8 @@ const vfs = require('vinyl-fs'); const rename = require('gulp-rename'); const template = require('lodash.template'); const mkdirp = require('mkdirp'); +const through = require('through2'); +const Vinyl = require('vinyl'); const streamToPromise = (stream) => { @@ -217,7 +215,7 @@ class Runner extends Target { } log(stream) { - stream + return stream .pipe(tail(debug.log)) .pipe(rename('out.log')) .pipe(gulp.dest(this.targetPath)); @@ -241,7 +239,7 @@ class FlashRunner extends Runner { constructor(config, debug) { super(config, Platform.FLASH, debug); - this.player = new FlashPlayer(); + this.player = new FlashPlayer(debug); } prepare() { @@ -251,11 +249,16 @@ class FlashRunner extends Runner { call() { const target = this.targetPath; const filename = path.resolve(target, this.config.meta.filename+'.swf'); - const player = this.player.flashPlayerBin(this.debug); + const player = this.player.flashPlayerBin; FlashPlayer.trust(filename); fs.writeFileSync(FlashPlayer.log, ''); - const result = gulp.src(filename).pipe(run(player + " <%=file.basename%>", {cwd: target})); - return this.log(gulp.src(FlashPlayer.log)); + let result = gulp.src(filename) + .pipe(run(player + " <%=file.basename%>", {cwd: target, verbosity: 0})) + .pipe(through.obj(function (file, enc, callback) { + this.push(new Vinyl({path: FlashPlayer.log})); + callback(); + })); + return this.log(result); } } @@ -294,7 +297,7 @@ class LinuxRunner extends Runner { call() { const target = this.targetPath; const filename = path.resolve(target, this.config.meta.filename); - const result = gulp.src(filename).pipe(run("./<%=file.basename%>", {cwd: target})); + const result = gulp.src(filename).pipe(run("./<%=file.basename%>", {cwd: target, verbosity: 0})); return this.log(result); } } @@ -327,29 +330,27 @@ Runner.register(Platform.NEKO, NekoRunner); */ class Project { - constructor(buildSystem, platforms, config) { + constructor(buildSystem, platforms, config, prepare) { this.buildSystem = buildSystem; this.platforms = Array.isArray(platforms) ? platforms : [platforms]; this.config = config; + this.prepare = prepare; } - build(platform) { - const builder = Builder.new(this.config, platform, this.buildSystem, false); - return [ - builder.prepare.bind(builder), - builder.call.bind(builder), - ]; + build(platform, debug) { + const builder = Builder.new(this.config, platform, this.buildSystem, debug); + const tasks = [builder.prepare.bind(builder)]; + if (this.prepare) tasks.push(this.prepare); + tasks.push(builder.call.bind(builder)); + return tasks; } run(platform) { - const builder = Builder.new(this.config, platform, this.buildSystem, debug); const runner = Runner.new(this.config, platform, debug); - return [ - builder.prepare.bind(builder), - builder.call.bind(builder), + return this.build(platform, debug).concat([ runner.prepare.bind(runner), runner.call.bind(runner), - ]; + ]); } pack(platform) { diff --git a/haxetool/sdk.js b/haxetool/sdk.js index aaa568d..1a1f8d8 100755 --- a/haxetool/sdk.js +++ b/haxetool/sdk.js @@ -75,7 +75,7 @@ class Sdk { throw "Not implemented"; } - prepare() { + prepare(strip=1) { log(this.tag, `version: ${colors.magenta(this.version)}`); if (this.prepared) { @@ -99,7 +99,7 @@ class Sdk { } }); } else if (this.link.endsWith('tar.gz')) { - stream = stream.pipe(tar.x({C: this.path, strip: 1})); + stream = stream.pipe(tar.x({C: this.path, strip: strip})); } else { stream = stream.pipe(fs.createWriteStream(this.path)); } diff --git a/haxetool/tail.js b/haxetool/tail.js index d326ea6..2eb15d0 100644 --- a/haxetool/tail.js +++ b/haxetool/tail.js @@ -38,8 +38,9 @@ module.exports = (handler) => { file.contents.pipe(new StringWritable(handler)); } else { const tail = new Tail(file.path); - tail.on("line", data => handler(data)); - tail.on("error", error => handler('[ERROR]: ', error)); + tail.on('line', data => handler(data)); + tail.on('error', error => handler('[ERROR]: ', error)); + this.on('end', () => tail.unwatch()); } this.push(file); callback();