From 44f6fc2bee97259165aa863a0c9a0387b80dd59d Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Mon, 14 Jan 2019 20:58:21 +0300 Subject: [PATCH] Add .browserslistrc support (#96) * Add .browserslistrc update support * Update tars-cli version * Move logic of browserlistrc file update into separate function --- lib/command-actions/update-project.js | 28 ++++++ .../update-project/update-plugins-config.js | 7 ++ package-lock.json | 92 +++++++++++++++---- package.json | 4 +- 4 files changed, 110 insertions(+), 21 deletions(-) diff --git a/lib/command-actions/update-project.js b/lib/command-actions/update-project.js index 121e288..16f7dc1 100644 --- a/lib/command-actions/update-project.js +++ b/lib/command-actions/update-project.js @@ -180,6 +180,34 @@ function updateConfigFiles() { * END update plugins-config.js */ + /** + * START update .browserslistrc + */ + let downloadedBrowserslistrc; + let currentBrowserslistrc; + + const updateBrowserslistrc = () => { + if (!fs.existsSync(`${cwd}/.browserslistrc`)) { + fsExtra.copySync(`${dest.tars.fullPath}/.browserslistrc`, `${cwd}/.browserslistrc`, { clobber: true }); + return; + } + + downloadedBrowserslistrc = fs.readFileSync(`${dest.tars.fullPath}/.browserslistrc`); + currentBrowserslistrc = fs.readFileSync(`${cwd}/.browserslistrc`); + + if (downloadedBrowserslistrc !== currentBrowserslistrc) { + fsExtra.copySync(`${cwd}/.browserslistrc`, `${cwd}/${currentTarsVersion}-browserslistrc`, {clobber: true}); + fsExtra.copySync(`${dest.tars.fullPath}/.browserslistrc`, `${cwd}/.browserslistrc`, { clobber: true }); + } + }; + + if (semver.cmp(downloadedVersion, '>', '1.11.8')) { + updateBrowserslistrc(); + } + /** + * END update .browserslistrc + */ + /** * START tars-config.js update */ diff --git a/lib/command-actions/utils/update-project/update-plugins-config.js b/lib/command-actions/utils/update-project/update-plugins-config.js index 5f9faac..7041f82 100644 --- a/lib/command-actions/utils/update-project/update-plugins-config.js +++ b/lib/command-actions/utils/update-project/update-plugins-config.js @@ -1,6 +1,7 @@ 'use strict'; const commentJson = require('comment-json'); +const semver = require('semver'); module.exports = function updatePluginsConfig(downloadedPluginsConfigString, currentPluginsConfigString, tarsConfig, currentTarsVersion) { let parsedPluginsConfig = {}; @@ -31,6 +32,12 @@ module.exports = function updatePluginsConfig(downloadedPluginsConfigString, cur parsedPluginsConfig['gulp-minify-html'] = undefined; // eslint-disable-line no-undefined } + if (semver.cmp(currentTarsVersion, '>', '1.11.7')) { + if (parsedPluginsConfig.autoprefixerConfig) { + delete parsedPluginsConfig.autoprefixerConfig; + } + } + parsedPluginsConfig = Object.assign( parsedDownloadedPluginsConfig, parsedPluginsConfig diff --git a/package-lock.json b/package-lock.json index 83143af..5758a05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "tars-cli", - "version": "1.10.7", + "version": "1.10.8", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -815,16 +815,61 @@ "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==" }, "autoprefixer": { - "version": "8.6.5", - "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-8.6.5.tgz", - "integrity": "sha512-PLWJN3Xo/rycNkx+mp8iBDMTm3FeWe4VmYaZDSqL5QQB9sLsQkG5k8n+LNDFnhh9kdq2K+egL/icpctOmDHwig==", + "version": "9.4.4", + "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-9.4.4.tgz", + "integrity": "sha512-7tpjBadJyHKf+gOJEmKhZIksWxdZCSrnKbbTJNsw+/zX9+f//DLELRQPWjjjVoDbbWlCuNRkN7RfmZwDVgWMLw==", "requires": { - "browserslist": "^3.2.8", - "caniuse-lite": "^1.0.30000864", + "browserslist": "^4.3.7", + "caniuse-lite": "^1.0.30000926", "normalize-range": "^0.1.2", "num2fraction": "^1.2.2", - "postcss": "^6.0.23", - "postcss-value-parser": "^3.2.3" + "postcss": "^7.0.7", + "postcss-value-parser": "^3.3.1" + }, + "dependencies": { + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "dependencies": { + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "postcss": { + "version": "7.0.10", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.10.tgz", + "integrity": "sha512-wuaQVkYI+mgMud6UwID/XX9w0Zf1Rh/ZHK0rIz0o08q3rUaPrezdl/oJD9aWma4Pw6q7mgRBJQS4xA1yZAHptA==", + "requires": { + "chalk": "^2.4.2", + "source-map": "^0.6.1", + "supports-color": "^6.1.0" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + }, + "supports-color": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", + "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", + "requires": { + "has-flag": "^3.0.0" + } + } } }, "aws-sign2": { @@ -1294,12 +1339,13 @@ } }, "browserslist": { - "version": "3.2.8", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-3.2.8.tgz", - "integrity": "sha512-WHVocJYavUwVgVViC0ORikPHQquXwVh939TaelZ4WDqpWgTX/FsGhl/+P4qBUAGcRvtOgDgC+xftNWWp2RUTAQ==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.4.0.tgz", + "integrity": "sha512-tQkHS8VVxWbrjnNDXgt7/+SuPJ7qDvD0Y2e6bLtoQluR2SPvlmPUcfcU75L1KAalhqULlIFJlJ6BDfnYyJxJsw==", "requires": { - "caniuse-lite": "^1.0.30000844", - "electron-to-chromium": "^1.3.47" + "caniuse-lite": "^1.0.30000928", + "electron-to-chromium": "^1.3.100", + "node-releases": "^1.1.3" } }, "bs-recipes": { @@ -1499,9 +1545,9 @@ } }, "caniuse-lite": { - "version": "1.0.30000912", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000912.tgz", - "integrity": "sha512-M3zAtV36U+xw5mMROlTXpAHClmPAor6GPKAMD5Yi7glCB5sbMPFtnQ3rGpk4XqPdUrrTIaVYSJZxREZWNy8QJg==" + "version": "1.0.30000928", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000928.tgz", + "integrity": "sha512-aSpMWRXL6ZXNnzm8hgE4QDLibG5pVJ2Ujzsuj3icazlIkxXkPXtL+BWnMx6FBkWmkZgBHGUxPZQvrbRw2ZTxhg==" }, "capture-stack-trace": { "version": "1.0.1", @@ -3024,9 +3070,9 @@ "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" }, "electron-to-chromium": { - "version": "1.3.85", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.85.tgz", - "integrity": "sha512-kWSDVVF9t3mft2OHVZy4K85X2beP6c6mFm3teFS/mLSDJpQwuFIWHrULCX+w6H1E55ZYmFRlT+ATAFRwhrYzsw==" + "version": "1.3.102", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.102.tgz", + "integrity": "sha512-2nzZuXw/KBPnI3QX3UOCSRvJiVy7o9+VHRDQ3D/EHCvVc89X6aj/GlNmEgiR2GBIhmSWXIi4W1M5okA5ScSlNg==" }, "elliptic": { "version": "6.4.1", @@ -9742,6 +9788,14 @@ "which": "^1.3.0" } }, + "node-releases": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.3.tgz", + "integrity": "sha512-6VrvH7z6jqqNFY200kdB6HdzkgM96Oaj9v3dqGfgp6mF+cHmU4wyQKZ2/WPDRVoR0Jz9KqbamaBN0ZhdUaysUQ==", + "requires": { + "semver": "^5.3.0" + } + }, "node-sass": { "version": "4.10.0", "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.10.0.tgz", diff --git a/package.json b/package.json index 5119500..a268fb9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tars-cli", - "version": "1.10.7", + "version": "1.10.8", "engines": { "node": "^6.x.x" }, @@ -34,7 +34,7 @@ "license": "MIT", "dependencies": { "@babel/core": "^7.1.5", - "autoprefixer": "^8.2.0", + "autoprefixer": "^9.4.4", "babel-loader": "^8.0.4", "browser-sync": "^2.26.3", "chalk": "^1.1.3",