Comparing version 1.0.1 to 1.0.2
@@ -1,212 +0,114 @@ | ||
'use strict' | ||
"use strict"; | ||
exports.__esModule = true | ||
exports.App = void 0 | ||
exports.__esModule = true; | ||
exports.App = void 0; | ||
var _ink = _interopRequireWildcard(require('ink')) | ||
var _ink = _interopRequireWildcard(require("ink")); | ||
var _inkSpaces = require('ink-spaces') | ||
var _inkSpaces = require("ink-spaces"); | ||
var _inkSpinner = _interopRequireDefault(require('ink-spinner')) | ||
var _inkSpinner = _interopRequireDefault(require("ink-spinner")); | ||
var _isEmpty = _interopRequireDefault(require('is-empty')) | ||
var _isEmpty = _interopRequireDefault(require("is-empty")); | ||
var _SelectInput = _interopRequireDefault(require('./SelectInput')) | ||
var _SelectInput = _interopRequireDefault(require("./SelectInput")); | ||
var _shelljs = _interopRequireDefault(require('shelljs')) | ||
var _shelljs = _interopRequireDefault(require("shelljs")); | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : { default: obj } | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireWildcard(obj) { | ||
if (obj && obj.__esModule) { | ||
return obj | ||
} else { | ||
var newObj = {} | ||
if (obj != null) { | ||
for (var key in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = | ||
Object.defineProperty && Object.getOwnPropertyDescriptor | ||
? Object.getOwnPropertyDescriptor(obj, key) | ||
: {} | ||
if (desc.get || desc.set) { | ||
Object.defineProperty(newObj, key, desc) | ||
} else { | ||
newObj[key] = obj[key] | ||
} | ||
} | ||
} | ||
} | ||
newObj.default = obj | ||
return newObj | ||
} | ||
} | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {} | ||
var ownKeys = Object.keys(source) | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat( | ||
Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable | ||
}) | ||
) | ||
} | ||
ownKeys.forEach(function(key) { | ||
_defineProperty(target, key, source[key]) | ||
}) | ||
} | ||
return target | ||
} | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}) | ||
} else { | ||
obj[key] = value | ||
} | ||
return obj | ||
} | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
const generateScriptItems = scripts => { | ||
const scriptPairs = Object.entries(scripts) | ||
const sortedByNameLength = scriptPairs.sort((a, b) => { | ||
return a[0].length < b[0].length | ||
}) | ||
const totalNameLength = sortedByNameLength[0][0].length + 5 | ||
const items = scriptPairs.reduce((final, [name, script]) => { | ||
const item = { | ||
name: | ||
name + | ||
Array(totalNameLength - name.length) | ||
.fill(' ') | ||
.join(''), | ||
script | ||
} | ||
final.push(item) | ||
return final | ||
}, []) | ||
return items.sort((a, b) => { | ||
return a.name[0] > b.name[0] | ||
}) | ||
} | ||
const scriptPairs = Object.entries(scripts); | ||
const sortedByNameLength = scriptPairs.sort((a, b) => { | ||
return a[0].length < b[0].length; | ||
}); | ||
const totalNameLength = sortedByNameLength[0][0].length + 5; | ||
const items = scriptPairs.reduce((final, [name, script]) => { | ||
const item = { | ||
name: name + Array(totalNameLength - name.length).fill(' ').join(''), | ||
script | ||
}; | ||
final.push(item); | ||
return final; | ||
}, []); | ||
return items.sort((a, b) => { | ||
return a.name[0] > b.name[0]; | ||
}); | ||
}; | ||
class App extends _ink.default.Component { | ||
constructor(...args) { | ||
var _temp | ||
constructor(...args) { | ||
super(...args); | ||
return ( | ||
(_temp = super(...args)), | ||
Object.defineProperty(this, 'state', { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: {} | ||
}), | ||
Object.defineProperty(this, 'onSelect', { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: item => { | ||
_shelljs.default.exec(item.script) | ||
_defineProperty(this, "state", {}); | ||
_shelljs.default.exit() | ||
} | ||
}), | ||
_temp | ||
) | ||
} | ||
_defineProperty(this, "onSelect", item => { | ||
this.setState({ | ||
EXEC: true | ||
}); | ||
componentDidMount() { | ||
const { packageJsonPath } = this.context.appVars | ||
_shelljs.default.exec(`npm run ${item.name}`, { | ||
cwd: process.cwd() | ||
}); | ||
const pkg = require(packageJsonPath) | ||
_shelljs.default.exit(); | ||
this.scripts = generateScriptItems(pkg.scripts) | ||
this.setState(_objectSpread({}, pkg)) | ||
} | ||
process.exit(0); | ||
}); | ||
} | ||
render(props, state, context) { | ||
return (0, _ink.h)( | ||
'div', | ||
null, | ||
(0, _isEmpty.default)(state) | ||
? [ | ||
(0, _ink.h)(_inkSpaces.BlankLines, { | ||
count: 1, | ||
key: '0' | ||
}), | ||
(0, _ink.h)(_inkSpinner.default, { | ||
green: true, | ||
key: '1' | ||
}), | ||
(0, _ink.h)( | ||
_ink.Color, | ||
{ | ||
key: '2' | ||
}, | ||
'Loading scripts.' | ||
) | ||
] | ||
: !(0, _isEmpty.default)(state) | ||
? [ | ||
(0, _ink.h)(_inkSpaces.BlankLines, { | ||
count: 1, | ||
key: '0' | ||
}), | ||
(0, _ink.h)( | ||
_ink.Color, | ||
{ | ||
key: '1' | ||
}, | ||
'[ abt \u2206 choose a script ]' | ||
), | ||
(0, _ink.h)(_inkSpaces.BlankLines, { | ||
count: 1, | ||
key: '2' | ||
}), | ||
(0, _ink.h)(_inkSpaces.BlankLines, { | ||
count: 1, | ||
key: '3' | ||
}), | ||
(0, _ink.h)( | ||
'div', | ||
{ | ||
key: '4' | ||
}, | ||
(0, _ink.h)(_SelectInput.default, { | ||
items: this.scripts, | ||
onSelect: this.onSelect, | ||
itemComponent: Item | ||
}) | ||
) | ||
] | ||
: null | ||
) | ||
} | ||
componentDidMount() { | ||
const { | ||
packageJsonPath | ||
} = this.context.appVars; | ||
const pkg = require(packageJsonPath); | ||
this.scripts = generateScriptItems(pkg.scripts); | ||
this.setState(_objectSpread({}, pkg)); | ||
} | ||
render(props, state, context) { | ||
return (0, _ink.h)("div", null, state.EXEC ? (0, _ink.h)(_ink.Color, null) : (0, _isEmpty.default)(state) ? [(0, _ink.h)(_inkSpaces.BlankLines, { | ||
count: 1, | ||
key: "0" | ||
}), (0, _ink.h)(_inkSpinner.default, { | ||
green: true, | ||
key: "1" | ||
}), (0, _ink.h)(_ink.Color, { | ||
key: "2" | ||
}, "Loading scripts.")] : !(0, _isEmpty.default)(state) ? [(0, _ink.h)(_inkSpaces.BlankLines, { | ||
count: 1, | ||
key: "0" | ||
}), (0, _ink.h)(_ink.Color, { | ||
key: "1" | ||
}, "[ abt \u2206 choose a script ]"), (0, _ink.h)(_inkSpaces.BlankLines, { | ||
count: 1, | ||
key: "2" | ||
}), (0, _ink.h)(_inkSpaces.BlankLines, { | ||
count: 1, | ||
key: "3" | ||
}), (0, _ink.h)("div", { | ||
key: "4" | ||
}, (0, _ink.h)(_SelectInput.default, { | ||
items: this.scripts, | ||
onSelect: this.onSelect, | ||
itemComponent: Item | ||
}))] : null); | ||
} | ||
} | ||
exports.App = App | ||
exports.App = App; | ||
const Item = props => { | ||
return (0, _ink.h)( | ||
'span', | ||
null, | ||
(0, _ink.h)( | ||
_ink.Color, | ||
{ | ||
green: true | ||
}, | ||
props.name | ||
), | ||
(0, _ink.h)(_ink.Color, null, props.script) | ||
) | ||
} | ||
return (0, _ink.h)("span", null, (0, _ink.h)(_ink.Color, { | ||
green: true | ||
}, props.name), (0, _ink.h)(_ink.Color, null, props.script)); | ||
}; |
@@ -1,76 +0,31 @@ | ||
'use strict' | ||
"use strict"; | ||
exports.__esModule = true | ||
exports.Provider = void 0 | ||
exports.__esModule = true; | ||
exports.Provider = void 0; | ||
var _ink = require('ink') | ||
var _ink = require("ink"); | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {} | ||
var ownKeys = Object.keys(source) | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat( | ||
Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable | ||
}) | ||
) | ||
} | ||
ownKeys.forEach(function(key) { | ||
_defineProperty(target, key, source[key]) | ||
}) | ||
} | ||
return target | ||
} | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}) | ||
} else { | ||
obj[key] = value | ||
} | ||
return obj | ||
} | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _objectWithoutProperties(source, excluded) { | ||
if (source == null) return {} | ||
var target = {} | ||
var sourceKeys = Object.keys(source) | ||
var key, i | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i] | ||
if (excluded.indexOf(key) >= 0) continue | ||
target[key] = source[key] | ||
} | ||
if (Object.getOwnPropertySymbols) { | ||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source) | ||
for (i = 0; i < sourceSymbolKeys.length; i++) { | ||
key = sourceSymbolKeys[i] | ||
if (excluded.indexOf(key) >= 0) continue | ||
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue | ||
target[key] = source[key] | ||
} | ||
} | ||
return target | ||
} | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
class Provider extends _ink.Component { | ||
render(props, state, context) { | ||
return props.children | ||
} | ||
render(props, state, context) { | ||
return props.children; | ||
} | ||
getChildContext() { | ||
const _props = this.props, | ||
{ children } = _props, | ||
props = _objectWithoutProperties(_props, ['children']) | ||
getChildContext() { | ||
const _this$props = this.props, | ||
{ | ||
children | ||
} = _this$props, | ||
props = _objectWithoutProperties(_this$props, ["children"]); | ||
return _objectSpread({}, props) | ||
} | ||
return _objectSpread({}, props); | ||
} | ||
} | ||
exports.Provider = Provider | ||
exports.Provider = Provider; |
@@ -1,1 +0,1 @@ | ||
'use strict' | ||
"use strict"; |
#!/usr/bin/env node | ||
'use strict' | ||
"use strict"; | ||
var _ink = _interopRequireWildcard(require('ink')) | ||
var _ink = _interopRequireWildcard(require("ink")); | ||
var _yargs = _interopRequireDefault(require('yargs')) | ||
var _yargs = _interopRequireDefault(require("yargs")); | ||
var _Provider = require('./components/Provider') | ||
var _Provider = require("./components/Provider"); | ||
var _App = require('./components/App') | ||
var _App = require("./components/App"); | ||
var _handleArgs = require('./utilities/handleArgs') | ||
var _handleArgs = require("./utilities/handleArgs"); | ||
var _yargs$argv | ||
var _yargs$argv; | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : { default: obj } | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireWildcard(obj) { | ||
if (obj && obj.__esModule) { | ||
return obj | ||
} else { | ||
var newObj = {} | ||
if (obj != null) { | ||
for (var key in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = | ||
Object.defineProperty && Object.getOwnPropertyDescriptor | ||
? Object.getOwnPropertyDescriptor(obj, key) | ||
: {} | ||
if (desc.get || desc.set) { | ||
Object.defineProperty(newObj, key, desc) | ||
} else { | ||
newObj[key] = obj[key] | ||
} | ||
} | ||
} | ||
} | ||
newObj.default = obj | ||
return newObj | ||
} | ||
} | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
_ink.default.render( | ||
(0, _ink.h)( | ||
_Provider.Provider, | ||
{ | ||
appVars: ((_yargs$argv = _yargs.default.argv), (0, _handleArgs.handleArgs)(_yargs$argv)) | ||
}, | ||
(0, _ink.h)(_App.App, null) | ||
) | ||
) | ||
_ink.default.render((0, _ink.h)(_Provider.Provider, { | ||
appVars: (_yargs$argv = _yargs.default.argv, (0, _handleArgs.handleArgs)(_yargs$argv)) | ||
}, (0, _ink.h)(_App.App, null))); |
@@ -1,24 +0,17 @@ | ||
'use strict' | ||
"use strict"; | ||
exports.__esModule = true | ||
exports.handleArgs = void 0 | ||
exports.__esModule = true; | ||
exports.handleArgs = void 0; | ||
const handleArgs = args => { | ||
const _propertyPath = args._[0] || '.scripts' | ||
const _propertyPath = args._[0] || '.scripts'; | ||
const propertyPath = | ||
_propertyPath === '.DD' | ||
? 'devDependencies' | ||
: _propertyPath === '.PD' | ||
? 'peerDependencies' | ||
: _propertyPath === '.D' | ||
? 'dependencies' | ||
: _propertyPath === '.V' ? 'version' : _propertyPath.slice(1) | ||
return { | ||
packageJsonPath: `${process.env.PWD}/package.json`, | ||
pwd: process.env.PWD, | ||
propertyPath | ||
} | ||
} | ||
const propertyPath = _propertyPath === '.DD' ? 'devDependencies' : _propertyPath === '.PD' ? 'peerDependencies' : _propertyPath === '.D' ? 'dependencies' : _propertyPath === '.V' ? 'version' : _propertyPath.slice(1); | ||
return { | ||
packageJsonPath: `${process.env.PWD}/package.json`, | ||
pwd: process.env.PWD, | ||
propertyPath | ||
}; | ||
}; | ||
exports.handleArgs = handleArgs | ||
exports.handleArgs = handleArgs; |
{ | ||
"name": "abt", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A CLI tool to get easy info from your package.json.", | ||
@@ -62,2 +62,3 @@ "main": "./code/index.js", | ||
"is-empty": "^1.2.0", | ||
"npx": "^10.2.0", | ||
"prettyjson": "^1.2.1", | ||
@@ -64,0 +65,0 @@ "regenerator-runtime": "^0.12.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45781
10
308
+ Addednpx@^10.2.0
+ Addednpx@10.2.2(transitive)