forked from binary-com/binary-static
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request binary-com#4619 from binary-hamedanchi/mohammad/sp…
…lit_release_process [new-app] mohammad/split_release_process
- Loading branch information
Showing
41 changed files
with
572 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,7 @@ | ||
module.exports = function (grunt) { | ||
// map release parameters to the required branch, origin, and target gh-pages sub-folder | ||
global.release_config = { | ||
production : { branch: 'master', target_folder: '', origin: '[email protected]:binary-static-deployed/binary-static.git', CNAME: 'www.binary.com' }, | ||
staging : { branch: 'master', target_folder: '', origin: '[email protected]:binary-com/binary-static.git', CNAME: 'staging.binary.com' }, | ||
translations: { branch: 'translations', target_folder: 'translations', origin: '[email protected]:binary-com/binary-static.git', CNAME: 'staging.binary.com' }, | ||
}; | ||
|
||
global.is_production = grunt.cli.tasks[0] === 'release'; | ||
|
||
if (global.is_production) { | ||
Object.keys(global.release_config).forEach(function (target) { | ||
if (grunt.option(target)) { | ||
global.release_target = target; | ||
} | ||
}); | ||
} | ||
const { initGlobals } = require('./build/config/init'); | ||
|
||
if (global.release_target) { | ||
global.release_info = global.release_config[global.release_target]; | ||
global.branch_prefix = ''; | ||
global.branch = global.release_info.target_folder; | ||
} else { | ||
global.branch_prefix = 'br_'; | ||
global.branch = grunt.option('branch'); | ||
} | ||
|
||
global.dist = `dist${global.branch ? `/${global.branch_prefix}${global.branch}` : ''}`; | ||
global.path = grunt.option('path'); | ||
|
||
global.compileCommand = function(params) { | ||
return `cd ${process.cwd()} && ./scripts/render.js ${params || ''} ${global.branch ? '-b ' + global.branch_prefix + global.branch : ''} ${global.path ? '-p ' + global.path : ''}`; | ||
}; | ||
module.exports = function (grunt) { | ||
initGlobals(grunt); | ||
|
||
require('time-grunt')(grunt); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ css: | |
- 'cssmin' | ||
|
||
js: | ||
- 'webpack:all' | ||
- 'webpack:section' | ||
- 'babel:landing_pages' | ||
|
||
test: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
module.exports = { | ||
landing_pages: { | ||
options: { | ||
minified : true, | ||
plugins : ['transform-remove-strict-mode'], | ||
presets : ['env'], | ||
sourceMap : true, | ||
sourceType: 'script', | ||
}, | ||
files: [ | ||
{ | ||
expand: true, | ||
cwd : 'src/javascript/landing_pages/', | ||
src : ['*.js'], | ||
dest : global.dist + '/js/landing_pages/' | ||
module.exports = function (grunt) { | ||
const config = { | ||
app: { | ||
options: { | ||
minified : true, | ||
plugins : ['transform-remove-strict-mode'], | ||
presets : ['env'], | ||
sourceMap : true, | ||
sourceType: 'script', | ||
}, | ||
], | ||
}, | ||
files : [ | ||
{ | ||
expand: true, | ||
cwd : 'src/javascript/landing_pages/', | ||
src : ['*.js'], | ||
dest : global.dist + '/js/landing_pages/' | ||
}, | ||
], | ||
}, | ||
app_2: {}, | ||
get all() { | ||
return this.app; | ||
}, | ||
}; | ||
|
||
return { | ||
landing_pages: config[global.section], | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const targets_config = { | ||
production: { | ||
origin: '[email protected]:binary-static-deployed/binary-static.git', | ||
CNAME : 'www.binary.com', | ||
}, | ||
staging: { | ||
origin: '[email protected]:binary-com/binary-static.git', | ||
CNAME : 'staging.binary.com', | ||
}, | ||
}; | ||
|
||
// map release parameters to the required branch, origin, CNAME, and target gh-pages sub-folder | ||
const release_config = { | ||
production : { branch: 'master', target_folder: '', origin: targets_config.production.origin, CNAME: targets_config.production.CNAME }, | ||
staging : { branch: 'master', target_folder: '', origin: targets_config.staging.origin, CNAME: targets_config.staging.CNAME }, | ||
translations: { branch: 'translations', target_folder: 'translations', origin: targets_config.staging.origin, CNAME: targets_config.staging.CNAME }, | ||
}; | ||
|
||
const node_modules_paths = { | ||
binary_style: 'node_modules/@binary-com/binary-style', | ||
smartcharts : 'node_modules/@binary-com/smartcharts', | ||
}; | ||
|
||
const config = { | ||
branch_prefix : 'br_', | ||
valid_sections : ['all', 'app', 'app_2'], | ||
default_section: 'all', | ||
app_2_folder : 'app', | ||
}; | ||
|
||
module.exports = { | ||
release_config, | ||
node_modules_paths, | ||
config, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const Constants = require('./constants'); | ||
|
||
const isRelease = (grunt) => grunt.cli.tasks[0] === 'release'; | ||
|
||
const getReleaseTarget = (grunt) => Object.keys(global.release_config).find(grunt.option); | ||
|
||
const getSection = (grunt) => { | ||
const section = grunt.option('section') || Constants.config.default_section; | ||
|
||
if (!Constants.config.valid_sections.includes(section)) { | ||
grunt.fail.fatal(`Unknown section: '${section}'.\nValid sections are: ${Constants.config.valid_sections.join(', ')}.`); | ||
} | ||
|
||
return section; | ||
}; | ||
|
||
const checkSection = (grunt) => { | ||
if (!grunt.option('section')) { | ||
grunt.fail.fatal(`It is mandatory to specify the section when releasing.\nValid sections are: ${Constants.config.valid_sections.join(', ')}`); | ||
} | ||
}; | ||
|
||
const getDistPath = () => `dist${global.branch ? `/${global.branch_prefix}${global.branch}` : ''}`; | ||
|
||
const generateCompileCommand = (params) => ( | ||
[ | ||
`cd ${process.cwd()}`, | ||
'&& ./scripts/render.js', | ||
...[ // parameters | ||
params || '', | ||
global.branch ? `-b ${global.branch_prefix}${global.branch}` : '', | ||
global.path ? `-p ${global.path}` : '', | ||
`-s ${global.section}`, | ||
], | ||
].join(' ') | ||
); | ||
|
||
module.exports = { | ||
isRelease, | ||
getReleaseTarget, | ||
getSection, | ||
checkSection, | ||
getDistPath, | ||
generateCompileCommand, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const Constants = require('./constants'); | ||
const Helpers = require('./helpers'); | ||
|
||
const initGlobals = (grunt) => { | ||
// ----- global info ----- | ||
global.node_modules_paths = Constants.node_modules_paths; | ||
global.release_config = Constants.release_config; | ||
|
||
// ----- release info ----- | ||
global.is_release = Helpers.isRelease(grunt); | ||
if (global.is_release) { | ||
Helpers.checkSection(grunt); // To prevent mistakes, section is mandatory when releasing | ||
global.release_target = Helpers.getReleaseTarget(grunt); | ||
} | ||
|
||
// ----- branch info ----- | ||
if (global.release_target) { | ||
global.release_info = global.release_config[global.release_target]; | ||
global.branch_prefix = ''; | ||
global.branch = global.release_info.target_folder; | ||
} else { | ||
global.branch_prefix = Constants.config.branch_prefix; | ||
global.branch = grunt.option('branch'); | ||
} | ||
|
||
// ----- section ----- | ||
global.section = Helpers.getSection(grunt); | ||
|
||
// ----- paths ----- | ||
global.dist = Helpers.getDistPath(); | ||
global.dist_app_2 = `${global.dist}/${Constants.config.app_2_folder}`; | ||
global.path = grunt.option('path'); | ||
|
||
// ----- compile templates ----- | ||
global.compileCommand = params => Helpers.generateCompileCommand(params); | ||
}; | ||
|
||
module.exports = { | ||
initGlobals, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.