Skip to content

Commit

Permalink
fix: fixed friendlyNames in index and uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 2, 2018
1 parent 55684a4 commit 1d1473c
Show file tree
Hide file tree
Showing 15 changed files with 206 additions and 1,263 deletions.
42 changes: 25 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,50 @@ jobs:
docker:
- image: node:latest
working_directory: ~/cli
environment:
NYC: "yarn exec nyc -- --nycrc-path node_modules/@anycli/nyc-config/.nycrc"
MOCHA_FILE: "reports/mocha.xml"
steps:
- checkout
- restore_cache: &restore_cache
keys:
- v0-yarn-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
- v0-yarn-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-
- v0-yarn-{{checksum ".circleci/config.yml"}}-master-
- run: .circleci/test
- v0-yarn-{{checksum ".circleci/config.yml"}}-{{ checksum "yarn.lock"}}
- v0-yarn-{{checksum ".circleci/config.yml"}}
- run: .circleci/greenkeeper
- run: yarn add -D nyc@11 @anycli/nyc-config@0 mocha-junit-reporter@1 @commitlint/cli@6 @commitlint/config-conventional@6
- run: |
mkdir -p reports
$NYC yarn test --reporter mocha-junit-reporter
$NYC report --reporter text-lcov > coverage.lcov
curl -s https://codecov.io/bash | bash
- run: yarn exec commitlint -- -x @commitlint/config-conventional --from origin/master
- store_test_results: &store_test_results
path: ~/cli/reports
- save_cache: &save_cache
key: v0-yarn-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
paths:
- ~/cli/node_modules
- /usr/local/share/.cache/yarn
- /usr/local/share/.config/yarn
node-8:
<<: *test
docker:
- image: node:8
steps:
- checkout
- restore_cache: *restore_cache
- run: .circleci/test
- store_test_results: *store_test_results
release:
<<: *test
steps:
- add_ssh_keys
- checkout
- restore_cache: *restore_cache
- run: .circleci/release
- run: yarn global add @anycli/semantic-release@1 semantic-release@12
- run: yarn --frozen-lockfile
- run: |
export PATH=/usr/local/share/.config/yarn/global/node_modules/.bin:$PATH
semantic-release -e @anycli/semantic-release
- save_cache:
key: v0-yarn-{{checksum ".circleci/config.yml"}}-{{checksum "yarn.lock"}}
paths:
- ~/cli/node_modules
- /usr/local/share/.cache/yarn
- /usr/local/share/.config/yarn

workflows:
version: 2
"@anycli/plugins":
"@anycli/plugins-plugin":
jobs:
- node-latest
- node-8
Expand Down
11 changes: 0 additions & 11 deletions .circleci/release

This file was deleted.

12 changes: 0 additions & 12 deletions .circleci/setup_git

This file was deleted.

29 changes: 0 additions & 29 deletions .circleci/test

This file was deleted.

20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@anycli/plugins
==============
@anycli/plugins-plugin
======================

plugins plugin for anycli

[![Version](https://img.shields.io/npm/v/@anycli/plugins.svg)](https://npmjs.org/package/@anycli/plugins)
[![CircleCI](https://circleci.com/gh/anycli/plugins/tree/master.svg?style=svg)](https://circleci.com/gh/anycli/plugins/tree/master)
[![Appveyor CI](https://ci.appveyor.com/api/projects/status/github/anycli/plugins?branch=master&svg=true)](https://ci.appveyor.com/project/heroku/plugins/branch/master)
[![Codecov](https://codecov.io/gh/anycli/plugins/branch/master/graph/badge.svg)](https://codecov.io/gh/anycli/plugins)
[![Greenkeeper](https://badges.greenkeeper.io/anycli/plugins.svg)](https://greenkeeper.io/)
[![Known Vulnerabilities](https://snyk.io/test/npm/@anycli/plugins/badge.svg)](https://snyk.io/test/npm/@anycli/plugins)
[![Downloads/week](https://img.shields.io/npm/dw/@anycli/plugins.svg)](https://npmjs.org/package/@anycli/plugins)
[![License](https://img.shields.io/npm/l/@anycli/plugins.svg)](https://github.com/anycli/plugins/blob/master/package.json)
[![Version](https://img.shields.io/npm/v/@anycli/plugins-plugin.svg)](https://npmjs.org/package/@anycli/plugins-plugin)
[![CircleCI](https://circleci.com/gh/anycli/plugins-plugin/tree/master.svg?style=svg)](https://circleci.com/gh/anycli/plugins-plugin/tree/master)
[![Appveyor CI](https://ci.appveyor.com/api/projects/status/github/anycli/plugins-plugin?branch=master&svg=true)](https://ci.appveyor.com/project/heroku/plugins-plugin/branch/master)
[![Codecov](https://codecov.io/gh/anycli/plugins-plugin/branch/master/graph/badge.svg)](https://codecov.io/gh/anycli/plugins-plugin)
[![Greenkeeper](https://badges.greenkeeper.io/anycli/plugins-plugin.svg)](https://greenkeeper.io/)
[![Known Vulnerabilities](https://snyk.io/test/npm/@anycli/plugins-plugin/badge.svg)](https://snyk.io/test/npm/@anycli/plugins-plugin)
[![Downloads/week](https://img.shields.io/npm/dw/@anycli/plugins-plugin.svg)](https://npmjs.org/package/@anycli/plugins-plugin)
[![License](https://img.shields.io/npm/l/@anycli/plugins-plugin.svg)](https://github.com/anycli/plugins-plugin/blob/master/package.json)
9 changes: 3 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ cache:

install:
- ps: Install-Product node $env:nodejs_version x64
- git submodule sync
- git submodule update --init --recursive
- git config --global user.email "anycli@example.com"
- git config --global user.name "anycli"
- yarn add -D nyc @anycli/nyc-config
- yarn add -D nyc@11 @anycli/nyc-config@0
test_script:
- yarn test
- .\node_modules\.bin\nyc --nycrc-path node_modules/@anycli/nyc-config/.nycrc yarn test
after_test:
- .\node_modules\.bin\nyc --nycrc-path node_modules/@anycli/nyc-config/.nycrc report --reporter text-lcov > coverage.lcov
- ps: |
$env:PATH = 'C:\msys64\usr\bin;' + $env:PATH
Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh
Expand Down
53 changes: 0 additions & 53 deletions package-scripts.js

This file was deleted.

46 changes: 22 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@anycli/plugins",
"name": "@anycli/plugins-plugin",
"description": "plugins plugin for anycli",
"version": "0.2.2",
"author": "Jeff Dickey @jdxcode",
Expand All @@ -11,11 +11,11 @@
"@anycli/version"
]
},
"bugs": "https://github.com/jdxcode/plugins/issues",
"bugs": "https://github.com/anycli/plugins-plugin/issues",
"dependencies": {
"@anycli/command": "^0.3.2",
"@anycli/manifest-file": "^0.3.0",
"@heroku-cli/color": "^1.1.1",
"@anycli/command": "^0.3.4",
"@anycli/manifest-file": "^0.3.8",
"@heroku-cli/color": "^1.1.3",
"cli-ux": "^3.3.12",
"debug": "^3.1.0",
"fs-extra": "^5.0.0",
Expand All @@ -26,30 +26,25 @@
"yarn": "^1.3.2"
},
"devDependencies": {
"@anycli/config": "^0.2.10",
"@anycli/engine": "^0.1.39",
"@anycli/test": "^0.10.1",
"@anycli/tslint": "^0.2.1",
"@anycli/config": "^0.2.11",
"@anycli/engine": "^0.1.44",
"@anycli/test": "^0.10.2",
"@anycli/tslint": "^0.2.2",
"@anycli/version": "^0.1.19",
"@commitlint/cli": "^6.0.5",
"@commitlint/config-conventional": "^6.0.4",
"@types/chai": "^4.1.2",
"@types/fs-extra": "^5.0.0",
"@types/lodash": "^4.14.99",
"@types/lodash": "^4.14.100",
"@types/mocha": "^2.2.48",
"@types/nock": "^9.1.2",
"@types/node": "^9.4.0",
"@types/node-notifier": "^0.0.28",
"@types/read-pkg": "^3.0.0",
"@types/supports-color": "^3.1.0",
"chai": "^4.1.2",
"concurrently": "^3.5.1",
"eslint": "^4.16.0",
"eslint-config-anycli": "^1.3.0",
"husky": "^0.14.3",
"eslint-config-anycli": "^1.3.1",
"mocha": "^5.0.0",
"mocha-junit-reporter": "^1.17.0",
"nps": "^5.7.1",
"nps-utils": "^1.5.0",
"ts-node": "^4.1.0",
"typescript": "^2.7.1"
},
Expand All @@ -59,16 +54,19 @@
"files": [
"/lib"
],
"homepage": "https://github.com/jdxcode/plugins",
"homepage": "https://github.com/anycli/plugins-plugin",
"keywords": [
"anycli-plugin"
],
"license": "MIT",
"repository": "anycli/plugins",
"main": "lib/index.js",
"repository": "anycli/plugins-plugin",
"scripts": {
"commitmsg": "commitlint -x @commitlint/config-conventional -e $GIT_PARAMS",
"precommit": "nps lint -l warn",
"prepublishOnly": "nps build",
"test": "nps test -l warn"
}
"build": "rm -rf lib && tsc",
"lint": "concurrently -p command \"eslint .\" \"tsc -p test --noEmit\" \"tslint -p test\"",
"posttest": "yarn run lint",
"prepublishOnly": "yarn run build",
"test": "mocha --forbid-only \"test/**/*.test.ts\""
},
"types": "lib/index.d.ts"
}
2 changes: 1 addition & 1 deletion src/commands/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ${examplePluginsHelp.join('\n')}
cli.info('no plugins installed')
}
for (let plugin of plugins) {
let output = `${plugin.name} ${color.dim(plugin.version)}`
let output = `${this.plugins.friendlyName(plugin.name)} ${color.dim(plugin.version)}`
if (plugin.type !== 'user') output += color.dim(` (${plugin.type})`)
if (plugin.type === 'link') output += ` ${plugin.root}`
else if (plugin.tag && plugin.tag !== 'latest') output += color.dim(` (${String(plugin.tag)})`)
Expand Down
38 changes: 8 additions & 30 deletions src/commands/plugins/install.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Command, parse} from '@anycli/command'
import chalk from 'chalk'
import cli from 'cli-ux'
import HTTP from 'http-call'

import Plugins from '../../plugins'

Expand Down Expand Up @@ -31,38 +31,16 @@ export default class PluginsInstall extends Command {

async run() {
for (let plugin of this.options.argv) {
let {name, tag, scope} = parsePlugin(plugin)
plugin = scope ? `@${scope}/${name}@${tag}` : `${name}@${tag}`
cli.action.start(`Installing plugin ${plugin}`)
const defaultScope = this.config.pjson.anycli.pluginScope
if (!scope && defaultScope) {
let version = await this.fetchVersionFromNPM({name, tag, scope: defaultScope})
if (version) scope = defaultScope
}
await this.plugins.install(scope ? `@${scope}/${name}` : name, tag)
let {name, tag} = parsePlugin(plugin)
cli.action.start(`Installing plugin ${chalk.cyan(this.plugins.friendlyName(name))}`)
await this.plugins.install(name, tag)
cli.action.stop()
}
}

private async fetchVersionFromNPM(plugin: {name: string, scope?: string, tag: string}): Promise<string | undefined> {
try {
let url = plugin.scope ? `${this.config.npmRegistry}/-/package/@${plugin.scope}%2f${plugin.name}/dist-tags` : `${this.config.npmRegistry}/-/package/${plugin.name}/dist-tags`
const {body: pkg} = await HTTP.get(url)
return pkg[plugin.tag]
} catch (err) {
this.debug(err)
}
}
}

function parsePlugin(input: string): {name: string, scope?: string, tag: string} {
if (input.includes('/')) {
let [scope, nameAndTag] = input.split('/')
scope = scope.slice(1)
let [name, tag = 'latest'] = nameAndTag.split('@')
return {scope, name, tag}
} else {
let [name, tag = 'latest'] = input.split('@')
return {name, tag}
}
function parsePlugin(input: string): {name: string, tag: string} {
if (input.includes('/')) input = input.slice(1)
let [name, tag = 'latest'] = input.split('@')
return {name, tag}
}
7 changes: 1 addition & 6 deletions src/commands/plugins/uninstall.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {Command, parse} from '@anycli/command'
import cli from 'cli-ux'

import Plugins from '../../plugins'

Expand Down Expand Up @@ -30,10 +29,6 @@ export default class PluginsUninstall extends Command {

async run() {
this.plugins = new Plugins(this.config)
for (let plugin of this.options.argv) {
cli.action.start(`Uninstalling ${plugin}`)
await this.plugins.uninstall(plugin)
cli.action.stop()
}
for (let plugin of this.options.argv) await this.plugins.uninstall(plugin)
}
}
Loading

0 comments on commit 1d1473c

Please sign in to comment.