Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

abt

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abt - npm Package Compare versions

Comparing version 0.0.8 to 1.0.0

bin/components/SelectInput.js

153

bin/components/App.js

@@ -12,4 +12,8 @@ 'use strict'

var _find = require('../utilities/find')
var _isEmpty = _interopRequireDefault(require('is-empty'))
var _SelectInput = _interopRequireDefault(require('./SelectInput'))
var _shelljs = _interopRequireDefault(require('shelljs'))
function _interopRequireDefault(obj) {

@@ -44,2 +48,57 @@ return obj && obj.__esModule ? obj : { default: obj }

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
}
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]
})
}
class App extends _ink.default.Component {

@@ -51,8 +110,2 @@ constructor(...args) {

(_temp = super(...args)),
Object.defineProperty(this, 'json', {
configurable: true,
enumerable: true,
writable: true,
value: ''
}),
Object.defineProperty(this, 'state', {

@@ -62,30 +115,14 @@ configurable: true,

writable: true,
value: {
gotJSON: false
}
value: {}
}),
Object.defineProperty(this, 'getJSON', {
Object.defineProperty(this, 'onSelect', {
configurable: true,
enumerable: true,
writable: true,
value: async () => {
const { packageJsonPath, propertyPath } = this.context.appVars
const json = await (0, _find.find)(packageJsonPath, propertyPath)
this.setJSON(json === 'null' ? '{}' : json)
value: item => {
_shelljs.default.exec(item.script)
_shelljs.default.exit()
}
}),
Object.defineProperty(this, 'setJSON', {
configurable: true,
enumerable: true,
writable: true,
value: json => {
this.json = json
this.setState(
state => ({
gotJSON: true
}),
() => setTimeout(() => process.exit(0), 250)
)
}
}),
_temp

@@ -96,3 +133,8 @@ )

componentDidMount() {
this.getJSON()
const { packageJsonPath } = this.context.appVars
const pkg = require(packageJsonPath)
this.scripts = generateScriptItems(pkg.scripts)
this.setState(_objectSpread({}, pkg))
}

@@ -104,6 +146,6 @@

null,
!state.gotJSON
(0, _isEmpty.default)(state)
? [
(0, _ink.h)(_inkSpaces.BlankLines, {
count: 2,
count: 1,
key: '0'

@@ -116,33 +158,40 @@ }),

(0, _ink.h)(
_ink.Text,
_ink.Color,
{
key: '2'
},
'Getting the JSON.'
'Loading scripts.'
)
]
: state.gotJSON
: !(0, _isEmpty.default)(state)
? [
(0, _ink.h)(_inkSpaces.BlankLines, {
count: 2,
count: 1,
key: '0'
}),
(0, _ink.h)(
_ink.Text,
_ink.Color,
{
key: '1'
},
'abt: ',
this.pathText
'[ abt \u2206 choose a script ]'
),
(0, _ink.h)(_inkSpaces.BlankLines, {
count: 2,
count: 1,
key: '2'
}),
(0, _ink.h)(_inkSpaces.BlankLines, {
count: 1,
key: '3'
}),
(0, _ink.h)(
'div',
{
key: '3'
key: '4'
},
(0, _ink.h)(_ink.Text, null, this.json)
(0, _ink.h)(_SelectInput.default, {
items: this.scripts,
onSelect: this.onSelect,
itemComponent: Item
})
)

@@ -153,9 +202,19 @@ ]

}
get pathText() {
const { appVars } = this.context
return `["${appVars.packageJsonPath}"].${appVars.propertyPath}`
}
}
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)
)
}

@@ -17,7 +17,3 @@ 'use strict'

const readJsonFile = filePath => {
var _fs$readFileSync
return (
(_fs$readFileSync = _fs.default.readFileSync(filePath, 'utf8')), JSON.parse(_fs$readFileSync)
)
return require(filePath) // return fs.readFileSync(filePath, 'utf8') |> JSON.parse
}

@@ -24,0 +20,0 @@

{
"name": "abt",
"version": "0.0.8",
"version": "1.0.0",
"description": "A CLI tool to get easy info from your package.json.",

@@ -57,9 +57,12 @@ "main": "./code/index.js",

"dependencies": {
"ink": "^0.4.1",
"ink": "^0.5.0",
"ink-select-input": "^1.1.0",
"ink-spaces": "^0.0.1",
"ink-spinner": "^1.0.0",
"ink-spinner": "^2.0.0",
"is-empty": "^1.2.0",
"prettyjson": "^1.2.1",
"regenerator-runtime": "^0.11.1",
"yargs": "^11.0.0"
"regenerator-runtime": "^0.12.0",
"shelljs": "^0.8.2",
"yargs": "^12.0.0"
}
}
# abt
> A CLI tool to get easy info from your `package.json`.
> A tool that makes it simple as fuck to find and execute npm scripts.
```
```sh
npm i -g abt

@@ -11,46 +11,12 @@ ```

abt takes only one argument, being the `.dotNoted` reference to the part of your `package.json` that you wish to fetch. When called with no arguments at all, abt will present you with your `.scripts` by default. When called with multiple arguments, abt will only use the first. abt also provides shortcuts. (See below.)
### Examples
Given the command `abt` or `abt .scripts`, abt will give you your `package.json`'s `scripts` value:
```json
["<path/to/projectRoot>/package.json"].scripts == {
"start": "node bin",
"test": "jest"
}
```sh
abt
```
Given the command `abt .dependencies`, abt will give you the `dependencies` value found in your `package.json`:
abt will show you a list of your scripts and allow you to run them. That is all there is to it.
```json
["<path/to/projectRoot>/package.json"].dependencies == {
"ink": "^0.4.1",
"ink-spaces": "^0.0.1",
"ink-spinner": "^1.0.0",
"node-jq": "^1.2.0",
"yargs": "^11.0.0"
}
```
![example](example.png)
Given the command `abt .version`, abt will give you the `version` value found in your `package.json`:
### Notes
```json
["<path/to/projectRoot>/package.json"].version == "0.0.2"
```
## Shortcuts
| arg | same as |
| ----- | ------------------- |
| `.DD` | '.devDependencies' |
| `.PD` | '.peerDependencies' |
| `.D` | '.dependencies' |
| `.V` | '.version' |
_Example: `abt .DD` -> `abt .devDependencies`_
## Notes
_abt is not guaranteed to work on Node < 8.1_
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc