From 57600be4eb62eb473d9b3916fa0e96ee00881ea4 Mon Sep 17 00:00:00 2001 From: ficristo Date: Wed, 15 Mar 2017 07:13:49 +0100 Subject: [PATCH] Create config.json based on task run (#12778) --- .gitignore | 3 +++ Gruntfile.js | 5 +++-- src/brackets.config.dev.json | 3 +++ src/brackets.config.dist.json | 3 +++ src/brackets.config.json | 3 +-- tasks/write-config.js | 16 ++++++++++++++-- 6 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 src/brackets.config.dev.json create mode 100644 src/brackets.config.dist.json diff --git a/.gitignore b/.gitignore index 415a22353f8..11228855c39 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,9 @@ Thumbs.db # ignore .disabled file for default extensions /src/extensions/default/*/.disabled +# generate through grunt +/src/config.json + #OSX .DS_Store files .DS_Store diff --git a/Gruntfile.js b/Gruntfile.js index d768df5d37a..860e6556a90 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -341,7 +341,7 @@ module.exports = function (grunt) { }); // task: install - grunt.registerTask('install', ['write-config', 'less', 'npm-install-source']); + grunt.registerTask('install', ['write-config:dev', 'less', 'npm-install-source']); // task: test grunt.registerTask('test', ['eslint', 'jasmine', 'nls-check']); @@ -349,10 +349,11 @@ module.exports = function (grunt) { // task: set-release // Update version number in package.json and rewrite src/config.json - grunt.registerTask('set-release', ['update-release-number', 'write-config']); + grunt.registerTask('set-release', ['update-release-number', 'write-config:dev']); // task: build grunt.registerTask('build', [ + 'write-config:dist', 'eslint:src', 'jasmine', 'clean', diff --git a/src/brackets.config.dev.json b/src/brackets.config.dev.json new file mode 100644 index 00000000000..fb63f4d01ba --- /dev/null +++ b/src/brackets.config.dev.json @@ -0,0 +1,3 @@ +{ + "healthDataServerURL" : "https://healthdev.brackets.io/healthDataLog" +} diff --git a/src/brackets.config.dist.json b/src/brackets.config.dist.json new file mode 100644 index 00000000000..51a409ad9a0 --- /dev/null +++ b/src/brackets.config.dist.json @@ -0,0 +1,3 @@ +{ + "healthDataServerURL" : "https://health.brackets.io/healthDataLog" +} diff --git a/src/brackets.config.json b/src/brackets.config.json index 25041fd3938..89a0db49067 100644 --- a/src/brackets.config.json +++ b/src/brackets.config.json @@ -20,7 +20,6 @@ "extension_registry" : "https://s3.amazonaws.com/extend.brackets/registry.json", "extension_url" : "https://s3.amazonaws.com/extend.brackets/{0}/{0}-{1}.zip", "linting.enabled_by_default" : true, - "build_timestamp" : "", - "healthDataServerURL" : "https://health.brackets.io/healthDataLog" + "build_timestamp" : "" } } diff --git a/tasks/write-config.js b/tasks/write-config.js index 1a3b4003cb8..86a7e24c5d3 100644 --- a/tasks/write-config.js +++ b/tasks/write-config.js @@ -31,9 +31,21 @@ module.exports = function (grunt) { // task: write-config grunt.registerTask("write-config", "Merge package.json and src/brackets.config.json into src/config.json", function () { - var packageJSON = grunt.file.readJSON("package.json"), - appConfigJSON = grunt.file.readJSON("src/brackets.config.json"); + var name = "dev"; + if (this.flags.dist === true) { + name = "dist"; + } + var appConfigJSON = grunt.file.readJSON("src/brackets.config.json"), + appConfigEnvJSON = grunt.file.readJSON("src/brackets.config." + name + ".json"), + key; + for (key in appConfigEnvJSON) { + if (appConfigEnvJSON.hasOwnProperty(key)) { + appConfigJSON.config[key] = appConfigEnvJSON[key]; + } + } + + var packageJSON = grunt.file.readJSON("package.json"); Object.keys(packageJSON).forEach(function (key) { if (appConfigJSON[key] === undefined) { appConfigJSON[key] = packageJSON[key];