async function listTar(file) { const tar = await execFile( 'tar', ['--list', '--warning=no-unknown-keyword', '-f', file], { maxBuffer: 50 * 1024 * 1024 } ); return tar.stdout .split('\n') .filter(x => !!x) .filter(x => x !== 'package') .sort(); }
it('should deploy the manifests', function() { var manifest_directory = path.normalize(path.join(path.dirname(__filename), '..', '/deploy')) const exec = util.promisify(require('child_process').exec); return exec('kubectl apply -f '+manifest_directory) .then((res) => { // console.log(util.inspect(res)); expect(res.stdout).to.not.be.null; expect(res.stderr).to.be.empty; }, (err) => { expect(err).to.be.null; }) })
async function gitVerify () { const currentHead = await exec('git rev-parse --abbrev-ref HEAD') const remoteRef = await exec(`git rev-parse origin/${currentHead.stdout.trim()}`) const currentRef = await exec('git rev-parse HEAD') const count = await exec(`git rev-list ${currentRef.stdout.trim()}..${remoteRef.stdout.trim()} --count`) if (count.stdout.trim() > 0) logger.warn('VERSION', `You're behind ${count.stdout.trim()} commit(s) compared to remote branch ${currentHead.stdout.trim()}, update recommended`) else logger.log('VERSION', 'Fully up-to-date, nice!') }
Promise.resolve().then(async () => { if (!username) { throw new Error('missing postgres username as first argument') } await exec(`dropdb republik`) .then(r => console.log(r.stdout, r.stderr)) .catch(e => {}) await exec(`createdb republik`) .then(r => console.log(r.stdout, r.stderr)) const DATABASE_URL = `postgres://${username}@localhost:5432/republik` await exec(`pg_dump postgres://${username}@localhost:5432/postgres | psql ${DATABASE_URL}`) .then(r => console.log(r.stdout, r.stderr)) }) .then(() => { process.exit(0) })
expect(res.stdout).to.not.be.null; expect(res.stderr).to.be.empty; }, (err) => {
exec(getCurrentBranchName).then((branchName) => currentBranch = branchName.stdout.trim(); process.on("exit", cleanUp); process.on("SIGINT", cleanUp); const pushToPages = `git ${gitDirCmd} push --force origin ${result.stdout.trim()}:refs/heads/gh-pages`; console.log(`Pushing content to the ${branch} branch: ${pushToPages}`); return exec(pushToPages);
}) .then(result => { return JSON.parse(result.stdout) }) .catch(err => {
Promise.resolve().then(async () => { if (!username) { throw new Error('missing postgres username as first argument') } await exec(`dropdb republik`) .then(r => console.log(r.stdout, r.stderr)) .catch(e => {}) await exec(`createdb republik`) .then(r => console.log(r.stdout, r.stderr)) const DATABASE_URL = `postgres://${username}@localhost:5432/republik` await exec(`pg_dump postgres://${username}@localhost:5432/postgres | psql ${DATABASE_URL}`) .then(r => console.log(r.stdout, r.stderr)) }) .then(() => { process.exit(0) })