|
| 1 | +const fs = require('fs'); |
| 2 | +const { spawn, spawnSync } = require('child_process'); |
| 3 | +const ng5Pkg = require('./ng5/package.json'); |
| 4 | +const pkg = require('../../package.json'); |
| 5 | +const shell = require('shelljs'); |
| 6 | + |
| 7 | +const PACKAGED_VERSION = `angularfire2-${pkg.version}.tgz`; |
| 8 | + |
| 9 | +function packageAngularFire() { |
| 10 | + console.log(`------------ PACKAGING VERSION ${PACKAGED_VERSION} ------------`); |
| 11 | + const res = spawnSync('sh', ['pack.sh']); |
| 12 | + console.log(`------------ FINISHED PACKAGING VERSION ${PACKAGED_VERSION} ------------`); |
| 13 | + console.log(`------------ INSTALLING VERSION ${PACKAGED_VERSION} ------------`); |
| 14 | + if (shell.exec(`cd ng5 && npm i firebase ../${PACKAGED_VERSION}`).code !== 0) { |
| 15 | + shell.echo('Error'); |
| 16 | + shell.exit(1); |
| 17 | + } |
| 18 | + console.log(`------------ FINISHED INSTALLING VERSION ${PACKAGED_VERSION} ------------`); |
| 19 | + buildVersion5(); |
| 20 | +} |
| 21 | + |
| 22 | +function buildVersion5() { |
| 23 | + console.log(`------------ BUILDING VERSION ${ng5Pkg.dependencies['@angular/core']} ------------`); |
| 24 | + const cmd = spawn('sh', ['build.sh']); |
| 25 | + cmd.stdout.on('data', (data) => { |
| 26 | + console.log(data.toString('utf8')); |
| 27 | + }); |
| 28 | + cmd.stderr.on('data', (data) => { |
| 29 | + console.log(data.toString('utf8')); |
| 30 | + }); |
| 31 | + cmd.on('close', () => { |
| 32 | + try { |
| 33 | + const dir = fs.readdirSync(__dirname + '/ng5/dist'); |
| 34 | + console.log(dir); |
| 35 | + console.log(`------------ SUCCESS VERSION ${ng5Pkg.dependencies['@angular/core']} ------------`); |
| 36 | + } catch (e) { |
| 37 | + console.log(`------------ FAIL VERSION ${ng5Pkg.dependencies['@angular/core']} ------------`); |
| 38 | + console.log(e); |
| 39 | + throw new Error('ng build failed'); |
| 40 | + } |
| 41 | + }); |
| 42 | +} |
| 43 | + |
| 44 | +packageAngularFire(); |
| 45 | +//buildVersion5(); |
0 commit comments