Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

Commit

Permalink
fix: fixing legacy requires
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 7, 2018
1 parent 4639c2b commit 432a5f4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -16,7 +16,7 @@
"bugs": "https://github.com/anycli/dev-cli/issues",
"dependencies": {
"@anycli/command": "^1.2.14",
"@anycli/config": "^1.3.32",
"@anycli/config": "^1.3.34",
"@anycli/errors": "^0.2.1",
"@anycli/plugin-help": "^0.6.9",
"lodash.template": "^4.4.0",
Expand Down
4 changes: 3 additions & 1 deletion src/commands/manifest.ts
Expand Up @@ -18,7 +18,9 @@ export default class Manifest extends Command {
let plugin = new Config.Plugin({root, type: 'core', ignoreManifest: true})
if (!plugin) throw new Error('plugin not found')
if (!plugin.valid) {
const {PluginLegacy} = require('@anycli/plugin-legacy')
// @ts-ignore
let p = require.resolve('@anycli/plugin-legacy', {paths: [process.cwd()]})
const {PluginLegacy} = require(p)
delete plugin.name
plugin = new PluginLegacy(this.config, plugin)
}
Expand Down
7 changes: 5 additions & 2 deletions src/commands/readme.ts
Expand Up @@ -21,14 +21,16 @@ export default class Readme extends Command {
const {flags} = this.parse(Readme)
const config = Config.load({root: process.cwd(), devPlugins: false, userPlugins: false})
try {
let p = require.resolve('@anycli/plugin-legacy')
config.plugins.push(new Config.Plugin({root: p}))
// @ts-ignore
let p = require.resolve('@anycli/plugin-legacy', {paths: [process.cwd()]})
config.plugins.push(new Config.Plugin({root: p, type: 'core'}))
} catch {}
await config.runHook('init', {id: 'readme', argv: this.argv})
let readme = await fs.readFile('README.md', 'utf8')
let commands = config.commands
commands = commands.filter(c => !c.hidden)
commands = commands.filter(c => c.pluginType === 'core')
this.debug('commands:', commands.map(c => c.id).length)
commands = uniqBy(commands, c => c.id)
commands = sortBy(commands, c => c.id)
// if (readme.includes('<!-- toc -->')) {
Expand Down Expand Up @@ -128,6 +130,7 @@ USAGE
}

renderCommand(config: Config.IConfig, c: Config.Command, commands: Config.Command[], level: number = 2): string {
this.debug('rendering command', c.id)
let title = template({config})(c.description || '').split('\n')[0]
const help = new Help(config, {stripAnsi: true, maxWidth: 120})
const header = () => '#'.repeat(level) + ` ${c.id}`
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Expand Up @@ -8,9 +8,9 @@
dependencies:
"@anycli/parser" "^3.2.6"

"@anycli/config@^1.3.32":
version "1.3.32"
resolved "https://registry.yarnpkg.com/@anycli/config/-/config-1.3.32.tgz#6e27153046cbb7cdc3783b698628221afeaf4010"
"@anycli/config@^1.3.34":
version "1.3.34"
resolved "https://registry.yarnpkg.com/@anycli/config/-/config-1.3.34.tgz#785f9ac9416aa923d8c7ef65520f1f8b36be7fea"

"@anycli/errors@^0.2.1":
version "0.2.1"
Expand Down

0 comments on commit 432a5f4

Please sign in to comment.