Commit 3c0543f6 authored by Philipp Nowinski's avatar Philipp Nowinski
Browse files

[FEATURE] add upgrade wizard

parent d467804e
'use strict';
let filePath = process.cwd() + '/../.sgc-config.json';
const sgcConfiguration = require(filePath);
const jsonFormat = require('json-format');
const fs = require('fs');
const chalk = require('chalk');
const request = require('request');
const inquirer = require('inquirer');
if (!sgcConfiguration.js.hasOwnProperty('pipeline')) {
console.log(chalk.green('Add JS pipeline configuration to your .sgc-config.json ✓'));
sgcConfiguration.js.pipeline = {
uglify: true,
renameToDotMin: true
};
}
if (!sgcConfiguration.css.hasOwnProperty('pipeline')) {
console.log(chalk.green('Add CSS pipeline configuration to your .sgc-config.json ✓'));
sgcConfiguration.css.pipeline = {
cleanCss: true,
renameToDotMin: true
};
}
if (!sgcConfiguration.css.hasOwnProperty('supportedBrowsers')) {
console.log(chalk.green('Add supported Browsers configuration to your .sgc-config.json ✓'));
sgcConfiguration.css.supportedBrowsers = ['last 1 version', '> 1%', 'ie 8'];
}
console.log('');
console.log(chalk.green('Your .sgc-config.json is compatible with SGC 2.1.0 ✓'));
fs.writeFile(filePath, jsonFormat(sgcConfiguration), error => console.log);
fs.exists(process.cwd() + '/../.eslintrc.js', exists => {
if (!exists) {
inquirer.prompt([
{
type: 'confirm',
name: 'provideEsLint',
message: 'Looks like you don\'t have an EsLint configuration file, yet. Do you want to include the sgalinski default configuration?'
}
]).then(answers => {
if (answers.provideEsLint) {
request('https://gitlab.sgalinski.de/snippets/28/raw').pipe(fs.createWriteStream(process.cwd() + '/../.eslintrc.js'));
console.log(chalk.green('Add EsLint configuration ✓'));
}
});
} else {
console.log(chalk.green('EsLint configuration found ✓'));
}
});
fs.exists(process.cwd() + '/../.jshintrc', exists => {
if (!exists) {
inquirer.prompt([
{
type: 'confirm',
name: 'removeJsHint',
message: 'The SGC does not use JsHint anymore. Do you want to remove your .jshintrc file?'
}
]).then(answers => {
if (answers.removeJsHint) {
fs.unlink(process.cwd() + '/../.jshintrc', error => console.log);
console.log(chalk.green('Removed .jshintr ✓'));
}
});
} else {
console.log(chalk.green('EsLint configuration found ✓'));
}
});
......@@ -78,6 +78,9 @@ then
echo -e "\033[0;32mSGC config file created ✓\033[0m\n"
else
echo -e "\033[0;34mSGC config file found. Skip config creation...\033[0m";
# run upgrade wizard to ensure compatibility with current version
node ./core/installers/upgrade.js
exit 1;
fi
if [ "$1" == "--local" ]; then
......
......@@ -4174,6 +4174,10 @@ json-content-demux@~0.1.2:
version "0.1.3"
resolved json-content-demux-0.1.3.tgz#5c1277bf7f3b7512a86b732ddd41b32d4dfcb1cc
json-format@^1.0.1:
version "1.0.1"
resolved json-format-1.0.1.tgz#143f67e62af129d6bffed288a46265ea23d0df0c
json-schema@0.2.3:
version "0.2.3"
resolved json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment