Commit 88aae5f2 authored by Jure's avatar Jure

feat(cli): remove adding and removing components

This is an unused feature that also comes with its fair share of bugs and edge-cases. As such, we're
removing it in favour of manually editing the config/components.json list.

BREAKING CHANGE: Removes pubsweet add and pubsweet remove

closes #449
parent 43af70cf
Pipeline #13046 failed with stages
in 9 minutes and 51 seconds
......@@ -2,21 +2,11 @@ Using a component is as simple as installing it, configuring it, and then includ
## Installing
Components can be installed using the PubSweet CLI:
Components can be installed using the yarn:
pubsweet add login
`yarn add pubsweet-component-login`
This installs the `pubsweet-component-login` package, and adds the component to the app config so PubSweet knows to load it.
Note that the CLI adds the `pubsweet-component-` prefix automatically if it's not already present.
You can also manually install components using npm or yarn:
npm install \--save pubsweet-component-login
yarn add pubsweet-component-login
If you do that, you'll need to also add the component manually to the list in `config/components.json`.
You can then add the component to the list in `config/components.json`.
## Configuring
......
#!/usr/bin/env node
require('../cli/add')().catch(require('../src/error-exit'))
#!/usr/bin/env node
require('../cli/remove')().catch(require('../src/error-exit'))
const logger = require('@pubsweet/logger')
const colors = require('colors/safe')
const program = require('commander')
const _ = require('lodash')
const readCommand = async argsOverride => {
program.arguments('<components>').description(`Add component(s) to an app.
<components> - a space-separated list of one or more components.`)
return program.parse(argsOverride || process.argv)
}
module.exports = async argsOverride => {
const commandOpts = await readCommand(argsOverride)
const components = commandOpts.args
if (_.isEmpty(components)) {
const eg = colors.bold(`pubsweet add ${colors.italic('login signup blog')}`)
throw new Error(`You must specify one or more components, e.g. ${eg}`)
}
logger.info(`Installing ${components.length} components...`)
require('../src/package-management/').add(components)
logger.info(`Success: ${components.length} components installed`)
}
const logger = require('@pubsweet/logger')
const colors = require('colors/safe')
const program = require('commander')
const _ = require('lodash')
const readCommand = async argsOverride => {
program.arguments('<components>').description(`Remove component(s) in an app.
<components> - a space-separated list of one or more components.`)
return program.parse(argsOverride || process.argv)
}
module.exports = async argsOverride => {
const commandOpts = await readCommand(argsOverride)
const components = commandOpts.args
if (_.isEmpty(components)) {
const eg = colors.bold(
`pubsweet remove ${colors.italic('login signup blog')}`,
)
throw new Error(`You must specify one or more components, e.g. ${eg}`)
}
logger.info(`Removing ${components.length} components...`)
require('../src/package-management/').remove(components)
logger.info(`Success: ${components.length} components removed`)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment