bower-away
Advanced tools
Comparing version 1.0.2 to 1.0.3
377
cli.js
#!/usr/bin/env node | ||
'use strict'; | ||
"use strict"; | ||
var _stringify = require('babel-runtime/core-js/json/stringify'); | ||
require("babel-polyfill/lib/core-js/modules/es6.promise"); | ||
var _stringify2 = _interopRequireDefault(_stringify); | ||
require("babel-polyfill/lib/core-js/modules/es6.symbol"); | ||
var _keys = require('babel-runtime/core-js/object/keys'); | ||
require("babel-polyfill/lib/core-js/modules/web.dom.iterable"); | ||
var _keys2 = _interopRequireDefault(_keys); | ||
function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
require("babel-polyfill/lib/core-js/modules/es6.symbol"); | ||
const updateNotifier = require('update-notifier'); | ||
const meow = require('meow'); | ||
const bowerConfig = require('bower-config'); | ||
const which = require('which'); | ||
const chalk = require('chalk'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
require("babel-polyfill/lib/core-js/modules/web.dom.iterable"); | ||
var _require = require('lodash'); | ||
require("babel-polyfill/lib/regenerator-runtime/runtime"); | ||
const startsWith = _require.startsWith; | ||
require("babel-polyfill/lib/core-js/modules/es6.string.starts-with"); | ||
const execa = require('execa'); | ||
const cloneDeep = require('clone-deep'); | ||
const difflet = require('difflet')({ indent: 2 }); | ||
const deepIs = require('deep-is'); | ||
var main = function () { | ||
var _ref = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee() { | ||
var cwd, yarnPath, bowerPath, config, componentsDir, original, expected, pkgs, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _pkg2, manifest, _source2, _target2, source, target, script; | ||
const pkg = require('./package.json'); | ||
updateNotifier({ pkg }).notify(); | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
cwd = process.cwd(); | ||
const cli = meow(` | ||
Usage | ||
$ bower-away | ||
if (!fs.existsSync(path.join(cwd, 'bower.json'))) { | ||
if (fs.existsSync(path.join(cwd, 'node_modules', '@bower_components'))) { | ||
step('Done', ['Your project is now converted to Yarn! Thank you for using Bower!'], true); | ||
} else { | ||
step('Browse to project directory', ['Current directory does not contain bower.json', '', 'Please browse to directory that contains your project to convert.']); | ||
} | ||
} | ||
Please call this command for next step to convert your project to Yarn | ||
`); | ||
yarnPath = exists('yarn', cwd); | ||
function help() { | ||
console.error(cli.help); | ||
process.exit(1); | ||
} | ||
if (!yarnPath) { | ||
step('Install Yarn', ['A good first step to migrate to Yarn is installing it!', '', 'Please choose your preferred method:', 'https://yarnpkg.com/lang/en/docs/install/', '', 'One good way to install it is:', '$ npm install -g yarn', '', "At the end you should be able to confirm Yarn's version with:", '$ yarn --version', '', 'THE MINIMUM SUPPORTED VERSION OF YARN IS 1.0.0!']); | ||
} | ||
function step(title, lines, last = false) { | ||
console.error(); | ||
console.error(chalk.green('# ' + title)); | ||
bowerPath = exists('bower'); | ||
console.error(); | ||
console.error(lines.join('\n')); | ||
if (!bowerPath) { | ||
step('Install Bower', ['We cannot drop Bower just yet, we need it to install legacy dependencies.', '', 'As a first step, please install Bower with:', '$ npm install -g bower', '', '...or if your project requires specific version of Bower:', '$ npm install -g bower@1.4.x', '', "At the end you should be able to confirm Bower's version with:", '$ bower --version']); | ||
} | ||
if (!last) { | ||
console.error(); | ||
console.error(chalk.red("Please call bower-away once more when you're done with this!")); | ||
} | ||
config = bowerConfig.read(cwd); | ||
componentsDir = path.resolve(cwd, config.directory); | ||
console.error(); | ||
if (!fs.existsSync(componentsDir) && !fs.existsSync(path.join(cwd, 'node_modules', '@bower_components'))) { | ||
step('Install dependencies with Bower', ['We need to install dependencies the old way first. Please run:', '$ bower install', '', 'At the end you should see some packages in:', componentsDir]); | ||
} | ||
process.exit(0); | ||
} | ||
original = {}; | ||
function exists(bin) { | ||
var path; | ||
if (fs.existsSync('package.json')) { | ||
original = JSON.parse(fs.readFileSync('package.json')); | ||
} | ||
try { | ||
path = which.sync(bin); | ||
} catch (e) { | ||
return false; | ||
} | ||
expected = cloneDeep(original); | ||
return path; | ||
} | ||
if (expected.dependencies) { | ||
Object.keys(expected.dependencies).forEach(function (k) { | ||
if (k.indexOf('@bower_components') >= 0) { | ||
delete expected.dependencies[k]; | ||
} | ||
}); | ||
} | ||
async function main() { | ||
const cwd = process.cwd(); | ||
pkgs = fs.readdirSync(componentsDir); | ||
_iteratorNormalCompletion = true; | ||
_didIteratorError = false; | ||
_iteratorError = undefined; | ||
_context.prev = 17; | ||
if (!fs.existsSync(path.join(cwd, 'bower.json'))) { | ||
if (fs.existsSync(path.join(cwd, 'node_modules', '@bower_components'))) { | ||
step('Done', ['Your project is now converted to Yarn! Thank you for using Bower!'], true); | ||
} else { | ||
step('Browse to project directory', ['Current directory does not contain bower.json', '', 'Please browse to directory that contains your project to convert.']); | ||
} | ||
} | ||
for (_iterator = pkgs[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
_pkg2 = _step.value; | ||
manifest = JSON.parse(fs.readFileSync(path.join(componentsDir, _pkg2, '.bower.json'))); | ||
_source2 = manifest._source; | ||
_target2 = manifest._target; | ||
const yarnPath = exists('yarn', cwd); | ||
if (_source2.slice(0, 19) === 'https://github.com/') { | ||
_source2 = _source2.slice(19); | ||
if (!yarnPath) { | ||
step('Install Yarn', ['A good first step to migrate to Yarn is installing it!', '', 'Please choose your preferred method:', 'https://yarnpkg.com/lang/en/docs/install/', '', 'One good way to install it is:', '$ npm install -g yarn', '', "At the end you should be able to confirm Yarn's version with:", '$ yarn --version', '', 'THE MINIMUM SUPPORTED VERSION OF YARN IS 1.0.0!']); | ||
} | ||
if (_source2.slice(-4) === '.git') { | ||
_source2 = _source2.slice(0, -4); | ||
} | ||
const bowerPath = exists('bower'); | ||
_source2 = _source2; | ||
} | ||
if (!bowerPath) { | ||
step('Install Bower', ['We cannot drop Bower just yet, we need it to install legacy dependencies.', '', 'As a first step, please install Bower with:', '$ npm install -g bower', '', '...or if your project requires specific version of Bower:', '$ npm install -g bower@1.4.x', '', "At the end you should be able to confirm Bower's version with:", '$ bower --version']); | ||
} | ||
if (!('dependencies' in expected)) { | ||
expected.dependencies = {}; | ||
} | ||
const config = bowerConfig.read(cwd); | ||
const componentsDir = path.resolve(cwd, config.directory); | ||
expected.dependencies["@bower_components/".concat(_pkg2)] = "".concat(_source2, "#").concat(_target2); | ||
} | ||
if (!fs.existsSync(componentsDir) && !fs.existsSync(path.join(cwd, 'node_modules', '@bower_components'))) { | ||
step('Install dependencies with Bower', ['We need to install dependencies the old way first. Please run:', '$ bower install', '', 'At the end you should see some packages in:', componentsDir]); | ||
} | ||
_context.next = 25; | ||
break; | ||
let original = {}; | ||
case 21: | ||
_context.prev = 21; | ||
_context.t0 = _context["catch"](17); | ||
_didIteratorError = true; | ||
_iteratorError = _context.t0; | ||
if (fs.existsSync('package.json')) { | ||
original = JSON.parse(fs.readFileSync('package.json')); | ||
} | ||
case 25: | ||
_context.prev = 25; | ||
_context.prev = 26; | ||
const expected = cloneDeep(original); | ||
if (!_iteratorNormalCompletion && _iterator.return != null) { | ||
_iterator.return(); | ||
} | ||
if (expected.dependencies) { | ||
(0, _keys2.default)(expected.dependencies).forEach(function (k) { | ||
if (k.indexOf('@bower_components') >= 0) { | ||
delete expected.dependencies[k]; | ||
} | ||
}); | ||
} | ||
case 28: | ||
_context.prev = 28; | ||
const pkgs = fs.readdirSync(componentsDir); | ||
if (!_didIteratorError) { | ||
_context.next = 31; | ||
break; | ||
} | ||
for (const pkg of pkgs) { | ||
const manifest = JSON.parse(fs.readFileSync(path.join(componentsDir, pkg, '.bower.json'))); | ||
throw _iteratorError; | ||
let source = manifest._source; | ||
let target = manifest._target; | ||
case 31: | ||
return _context.finish(28); | ||
if (source.slice(0, 19) === 'https://github.com/') { | ||
source = source.slice(19); | ||
case 32: | ||
return _context.finish(25); | ||
if (source.slice(-4) === '.git') { | ||
source = source.slice(0, -4); | ||
} | ||
case 33: | ||
if (_typeof(expected.engines) !== 'object') { | ||
expected.engines = {}; | ||
} | ||
source = source; | ||
} | ||
if (!expected.engines.yarn) { | ||
expected.engines.yarn = '>= 1.0.0'; | ||
} | ||
if (!('dependencies' in expected)) { | ||
expected.dependencies = {}; | ||
} | ||
if (!deepIs(expected, original)) { | ||
if (cli.flags.diff) { | ||
if (process.stdout.isTTY) { | ||
console.log(difflet.compare(original, expected, { | ||
indent: 2 | ||
})); | ||
} | ||
expected.dependencies[`@bower_components/${pkg}`] = `${source}#${target}`; | ||
} | ||
process.exit(0); | ||
} else if (cli.flags.apply) { | ||
fs.writeFileSync('package.json', JSON.stringify(expected, null, 2) + '\n'); | ||
} else { | ||
if (fs.existsSync('package.json')) { | ||
step('Update package.json', ['Changes need to be made in package.json. Please run following to preview them:', '', '$ bower-away --diff', '', 'And then apply them by running:', '', '$ bower-away --apply']); | ||
} | ||
} | ||
} | ||
if (typeof expected.engines !== 'object') { | ||
expected.engines = {}; | ||
} | ||
if (!fs.existsSync(path.join(cwd, 'node_modules', '@bower_components'))) { | ||
step('Install dependencies with Yarn', ['Now what package.json contains Bower dependencies, please install them with:', '$ yarn', '', 'If you encounter issues during installation, please try:', '$ yarn --ignore-engines --ignore-scripts', '', 'You can use this command from now on to install both npm and bower dependencies.']); | ||
} | ||
if (!expected.engines.yarn) { | ||
expected.engines.yarn = '>= 1.0.0'; | ||
source = path.relative(process.cwd(), componentsDir); | ||
target = path.relative(path.dirname(componentsDir), 'node_modules/@bower_components'); | ||
script = 'rm -rf ' + source + ' && ln -sf ' + target + ' ' + source; | ||
if (fs.existsSync(path.join(cwd, 'bower.json'))) { | ||
step('Remove bower.json and old bower components directory', ['Your project is now converted to Yarn!', '', 'You should find all bower components in node_modules/@bower_components', '', 'If you would like them to be available in previous location', 'please consider adding following as postinstall script in package.json:', '', '"postinstall": "' + script + '"', '', 'As a last step, please remove bower.json, .bowerrc', 'and point your scripts to node_modules/@bower_components instead']); | ||
} | ||
step('Done', ['Your project is now converted to Yarn! Thank you for using Bower!'], true); | ||
case 42: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, this, [[17, 21, 25, 33], [26,, 28, 32]]); | ||
})); | ||
return function main() { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}(); | ||
function _typeof(obj) { | ||
if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { | ||
_typeof = function _typeof(obj) { | ||
return _typeof2(obj); | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); | ||
}; | ||
} | ||
if (!deepIs(expected, original)) { | ||
if (cli.flags.diff) { | ||
if (process.stdout.isTTY) { | ||
console.log(difflet.compare(original, expected, { indent: 2 })); | ||
return _typeof(obj); | ||
} | ||
function _asyncToGenerator(fn) { | ||
return function () { | ||
var self = this, | ||
args = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
function step(key, arg) { | ||
try { | ||
var info = gen[key](arg); | ||
var value = info.value; | ||
} catch (error) { | ||
reject(error); | ||
return; | ||
} | ||
if (info.done) { | ||
resolve(value); | ||
} else { | ||
Promise.resolve(value).then(_next, _throw); | ||
} | ||
} | ||
process.exit(0); | ||
} else if (cli.flags.apply) { | ||
fs.writeFileSync('package.json', (0, _stringify2.default)(expected, null, 2) + '\n'); | ||
} else { | ||
if (fs.existsSync('package.json')) { | ||
step('Update package.json', ['Changes need to be made in package.json. Please run following to preview them:', '', '$ bower-away --diff', '', 'And then apply them by running:', '', '$ bower-away --apply']); | ||
function _next(value) { | ||
step("next", value); | ||
} | ||
} | ||
} | ||
if (!fs.existsSync(path.join(cwd, 'node_modules', '@bower_components'))) { | ||
step('Install dependencies with Yarn', ['Now what package.json contains Bower dependencies, please install them with:', '$ yarn', '', 'If you encounter issues during installation, please try:', '$ yarn --ignore-engines --ignore-scripts', '', 'You can use this command from now on to install both npm and bower dependencies.']); | ||
function _throw(err) { | ||
step("throw", err); | ||
} | ||
_next(); | ||
}); | ||
}; | ||
} | ||
var updateNotifier = require('update-notifier'); | ||
var meow = require('meow'); | ||
var bowerConfig = require('bower-config'); | ||
var which = require('which'); | ||
var chalk = require('chalk'); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var _require = require('lodash'), | ||
startsWith = _require.startsWith; | ||
var execa = require('execa'); | ||
var cloneDeep = require('clone-deep'); | ||
var difflet = require('difflet')({ | ||
indent: 2 | ||
}); | ||
var deepIs = require('deep-is'); | ||
var pkg = require('./package.json'); | ||
updateNotifier({ | ||
pkg: pkg | ||
}).notify(); | ||
var cli = meow("\n Usage\n $ bower-away\n\n Please call this command for next step to convert your project to Yarn\n "); | ||
function help() { | ||
console.error(cli.help); | ||
process.exit(1); | ||
} | ||
function step(title, lines) { | ||
var last = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
console.error(); | ||
console.error(chalk.green('# ' + title)); | ||
console.error(); | ||
console.error(lines.join('\n')); | ||
if (!last) { | ||
console.error(); | ||
console.error(chalk.red("Please call bower-away once more when you're done with this!")); | ||
} | ||
const source = path.relative(process.cwd(), componentsDir); | ||
const target = path.relative(path.dirname(componentsDir), 'node_modules/@bower_components'); | ||
const script = 'rm -rf ' + source + ' && ln -sf ' + target + ' ' + source; | ||
console.error(); | ||
process.exit(0); | ||
} | ||
if (fs.existsSync(path.join(cwd, 'bower.json'))) { | ||
step('Remove bower.json and old bower components directory', ['Your project is now converted to Yarn!', '', 'You should find all bower components in node_modules/@bower_components', '', 'If you would like them to be available in previous location', 'please consider adding following as postinstall script in package.json:', '', '"postinstall": "' + script + '"', '', 'As a last step, please remove bower.json, .bowerrc', 'and point your scripts to node_modules/@bower_components instead']); | ||
function exists(bin) { | ||
var path; | ||
try { | ||
path = which.sync(bin); | ||
} catch (e) { | ||
return false; | ||
} | ||
step('Done', ['Your project is now converted to Yarn! Thank you for using Bower!'], true); | ||
return path; | ||
} | ||
main(); |
{ | ||
"name": "bower-away", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"license": "MIT", | ||
@@ -9,3 +9,3 @@ "bin": "cli.js", | ||
"dependencies": { | ||
"babel-runtime": "^6.26.0", | ||
"babel-polyfill": "^7.0.0-beta.2", | ||
"bower-config": "^1.4.0", | ||
@@ -12,0 +12,0 @@ "bower-json": "^0.8.1", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
11495
235
1
+ Addedbabel-polyfill@^7.0.0-beta.2
+ Addedbabel-polyfill@7.0.0-beta.3(transitive)
- Removedbabel-runtime@^6.26.0
- Removedbabel-runtime@6.26.0(transitive)