From 6b320ce354c82af89569cc5f143468033489965e Mon Sep 17 00:00:00 2001 From: Court Ewing Date: Fri, 22 Jul 2016 16:40:06 -0400 Subject: [PATCH] Remove rebuild task This is a manual revert of 28aa6c9, which is not very useful with the new build tasks, completely brittle, and a flawed idea from the start. I regret having written it. Former-commit-id: 2b842b0904924219aea7b9f80d702c0b958de5a4 --- Gruntfile.js | 1 - tasks/rebuild/confirm.js | 36 ------------------ tasks/rebuild/create_archives.js | 23 ----------- tasks/rebuild/extract_zips.js | 14 ------- tasks/rebuild/index.js | 65 -------------------------------- tasks/rebuild/update_builds.js | 57 ---------------------------- 6 files changed, 196 deletions(-) delete mode 100644 tasks/rebuild/confirm.js delete mode 100644 tasks/rebuild/create_archives.js delete mode 100644 tasks/rebuild/extract_zips.js delete mode 100644 tasks/rebuild/index.js delete mode 100644 tasks/rebuild/update_builds.js diff --git a/Gruntfile.js b/Gruntfile.js index 48bac0d380743..02d9ae9a78452 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -91,5 +91,4 @@ module.exports = function (grunt) { // load task definitions grunt.task.loadTasks('tasks'); grunt.task.loadTasks('tasks/build'); - grunt.task.loadTasks('tasks/rebuild'); }; diff --git a/tasks/rebuild/confirm.js b/tasks/rebuild/confirm.js deleted file mode 100644 index 5ece1bce93b8a..0000000000000 --- a/tasks/rebuild/confirm.js +++ /dev/null @@ -1,36 +0,0 @@ -import { execFileSync } from 'child_process'; -import { readFileSync, writeFileSync } from 'fs'; -import { join } from 'path'; -import { createInterface } from 'readline'; - -export default (grunt) => { - grunt.registerTask('_rebuild:confirm', function () { - const newVersion = grunt.option('buildversion') || grunt.config.get('pkg').version; - const newBuildNum = grunt.option('buildnum') || grunt.config.get('build.number'); - const newSha = grunt.option('buildsha') || grunt.config.get('build.sha'); - - grunt.config('rebuild', { newVersion, newBuildNum, newSha }); - - grunt.log.writeln('Targets will be rebuilt with the following:'); - grunt.log.writeln(`Version: ${newVersion}`); - grunt.log.writeln(`Build number: ${newBuildNum}`); - grunt.log.writeln(`Build sha: ${newSha}`); - - const rl = createInterface({ - input: process.stdin, - output: process.stdout - }); - - rl.on('close', this.async()); - - rl.question('Do you want to rebuild these packages? [N/y] ', (resp) => { - const answer = resp.toLowerCase().trim(); - - if (answer === 'y') { - grunt.config.set('rebuild.continue', true); - } - - rl.close(); - }); - }); -}; diff --git a/tasks/rebuild/create_archives.js b/tasks/rebuild/create_archives.js deleted file mode 100644 index 852e3b52e666b..0000000000000 --- a/tasks/rebuild/create_archives.js +++ /dev/null @@ -1,23 +0,0 @@ -import { execFileSync } from 'child_process'; -import { join } from 'path'; - -export default (grunt) => { - grunt.registerTask('_rebuild:createArchives', function () { - const buildDir = grunt.config.get('buildDir'); - const targetDir = grunt.config.get('target'); - - grunt.file.mkdir('target'); - - grunt.file.expand({ cwd: buildDir }, '*').forEach(build => { - const tar = join(targetDir, `${build}.tar.gz`); - execFileSync('tar', ['-zchf', tar, build], { cwd: buildDir }); - - const zip = join(targetDir, `${build}.zip`); - if (/windows/.test(build)) { - execFileSync('zip', ['-rq', '-ll', zip, build], { cwd: buildDir }); - } else { - execFileSync('zip', ['-rq', zip, build], { cwd: buildDir }); - } - }); - }); -}; diff --git a/tasks/rebuild/extract_zips.js b/tasks/rebuild/extract_zips.js deleted file mode 100644 index fdd02601ad6e6..0000000000000 --- a/tasks/rebuild/extract_zips.js +++ /dev/null @@ -1,14 +0,0 @@ -import { execFileSync } from 'child_process'; - -export default (grunt) => { - grunt.registerTask('_rebuild:extractZips', function () { - const buildDir = grunt.config.get('buildDir'); - const targetDir = grunt.config.get('target'); - - const zips = grunt.file.expand({ cwd: targetDir }, '*.zip'); - - zips.forEach(zip => { - execFileSync('unzip', [zip, '-d', buildDir], { cwd: targetDir }); - }); - }); -}; diff --git a/tasks/rebuild/index.js b/tasks/rebuild/index.js deleted file mode 100644 index 4e382c06a5cc6..0000000000000 --- a/tasks/rebuild/index.js +++ /dev/null @@ -1,65 +0,0 @@ -import { execSync } from 'child_process'; -import { trim } from 'lodash'; - -/** - * Repackages all of the current archives in target/ with the same build - * number, sha, and commit hash. This is useful when all you need to do is bump - * the version of the release and do not want to introduce any other changes. - * - * Even if there are new commits, the standard build task reinstalls all npm - * dependencies, which introduces at least a small amount of risk of - * introducing bugs into the build since not all dependencies have fixed - * versions. - * - * Options: - * --skip-archives Will skip the archive step, useful for debugging - * --buildversion="1.2.3" Sets new version to 1.2.3 - * --buildnum="99999" Sets new build number to 99999 - * --buildsha="9a5b2c1" Sets new build sha to 9a5b2c1 (use the full sha, though) - */ -export default (grunt) => { - grunt.registerTask('rebuild', 'Rebuilds targets as a new version', function () { - grunt.task.run([ - '_rebuild:confirm', - '_rebuild:continue' - ]); - }); - - grunt.registerTask('_rebuild:continue', function () { - grunt.task.requires('_rebuild:confirm'); - - if (!grunt.config.get('rebuild.continue')) { - grunt.log.writeln('Aborting without rebuilding anything'); - } else { - grunt.task.run([ - '_rebuild:builds', - '_rebuild:archives' - ]); - } - }); - - grunt.registerTask('_rebuild:builds', function () { - grunt.task.requires('_rebuild:continue'); - - grunt.task.run([ - 'clean:build', - '_rebuild:extractZips', - '_rebuild:updateBuilds' - ]); - }); - - grunt.registerTask('_rebuild:archives', function () { - grunt.task.requires('_rebuild:continue'); - - const skip = grunt.option('skip-archives'); - if (skip) { - grunt.log.writeln('Skipping archive step since rebuild debugging was enabled'); - } else { - grunt.task.run([ - 'clean:target', - '_rebuild:createArchives', - '_build:shasums' - ]); - } - }); -}; diff --git a/tasks/rebuild/update_builds.js b/tasks/rebuild/update_builds.js deleted file mode 100644 index afe4177804f52..0000000000000 --- a/tasks/rebuild/update_builds.js +++ /dev/null @@ -1,57 +0,0 @@ -import { execFileSync } from 'child_process'; -import { readFileSync, writeFileSync } from 'fs'; -import { join } from 'path'; - -export default (grunt) => { - grunt.registerTask('_rebuild:updateBuilds', function () { - const buildDir = grunt.config.get('buildDir'); - - const { newVersion, newBuildNum, newSha } = grunt.config.get('rebuild'); - - grunt.file.expand({ cwd: buildDir }, '*').forEach(build => { - const thisBuildDir = join(buildDir, build); - const thisBundlesDir = join(thisBuildDir, 'optimize', 'bundles'); - - const readmePath = join(thisBuildDir, 'README.txt'); - const pkgjsonPath = join(thisBuildDir, 'package.json'); - const bundlePaths = [ - ...grunt.file.expand({ cwd: thisBundlesDir }, '*.bundle.js'), - ...grunt.file.expand({ cwd: thisBundlesDir }, '*.entry.js') - ]; - - const { oldBuildNum, oldSha, oldVersion } = readBuildInfo(pkgjsonPath); - - replaceIn(readmePath, oldVersion, newVersion); - replaceIn(pkgjsonPath, oldVersion, newVersion); - replaceIn(pkgjsonPath, `"number": ${oldBuildNum},`, `"number": ${newBuildNum},`); - replaceIn(pkgjsonPath, oldSha, newSha); - bundlePaths - .map(bundle => join(thisBundlesDir, bundle)) - .forEach(file => { - replaceIn(file, `"kbnVersion":"${oldVersion}"`, `"kbnVersion":"${newVersion}"`); - replaceIn(file, `"buildNum":${oldBuildNum}`, `"buildNum":${newBuildNum}`); - }); - - const newBuild = build.replace(oldVersion, newVersion); - if (build !== newBuild) { - execFileSync('mv', [ build, newBuild ], { cwd: buildDir }); - } - }); - }); -}; - -function readBuildInfo(path) { - const pkgjson = readFileSync(path).toString(); - const pkg = JSON.parse(pkgjson); - return { - oldBuildNum: pkg.build.number, - oldSha: pkg.build.sha, - oldVersion: pkg.version - }; -} - -function replaceIn(path, oldValue, newValue) { - let contents = readFileSync(path).toString(); - contents = contents.replace(oldValue, newValue); - writeFileSync(path, contents); -}