fix: fixing single
MODIFY
src/generators/app.ts
src/generators/app.ts
@@ -339,9 +339,6 @@ class App extends Generator {
'@anycli/help',
'cli-ux',
)
- devDependencies.push(
- '@anycli/engine',
- )
break
case 'plugin':
dependencies.push(
@@ -458,11 +455,7 @@ class App extends Generator {
let bin = this.pjson.anycli.bin || this.pjson.anycli.dirname || this.pjson.name
if (bin.includes('/')) bin = bin.split('/').pop()
const opts = {...this as any, _, bin, cmd: bin, name: this.pjson.name}
- if (this.ts) {
- this.fs.copyTpl(this.templatePath('single/bin/run.ts'), this.destinationPath('bin/run'), opts)
- } else {
- this.fs.copyTpl(this.templatePath('bin/run'), this.destinationPath('bin/run'), opts)
- }
+ this.fs.copyTpl(this.templatePath(`single/bin/run.${this._ext}`), this.destinationPath('bin/run'), opts)
this.fs.copyTpl(this.templatePath('bin/run.cmd'), this.destinationPath('bin/run.cmd'), opts)
this.fs.copyTpl(this.templatePath(`src/command.${this._ext}.ejs`), this.destinationPath(`src/index.${this._ext}`), opts)
if (this.mocha) {

ADD
templates/single/bin/run
+#!/usr/bin/env node
+
+const fs = require('fs')
+const path = require('path')
+const dev = fs.existsSync(path.join(__dirname, '../tsconfig.json'))
+
+if (dev) require('ts-node/register')
+
+require(`../${dev ? 'src' : 'lib'}`).run()

ADD
templates/single/bin/run.js
+#!/usr/bin/env node
+
+require('..').run()

MODIFY
templates/single/bin/run.ts
templates/single/bin/run.ts
#!/usr/bin/env node
-require('@anycli/engine').run()
+const fs = require('fs')
+const path = require('path')
+const dev = fs.existsSync(path.join(__dirname, '../tsconfig.json'))
+
+if (dev) require('ts-node/register')
+
+require(`../${dev ? 'src' : 'lib'}`).run()

MODIFY
templates/src/command.ts.ejs
templates/src/command.ts.ejs
@@ -2,7 +2,11 @@ import {Command, flags, parse} from '@anycli/command'
import cli from 'cli-ux'
<%_ const klass = _.upperFirst(_.camelCase(name)) _%>
+<%_ if (type === 'single') { _%>
+class <%- klass %> extends Command {
+<%_ } else { _%>
export default class <%- klass %> extends Command {
+<%_ } _%>
static title = 'scaffolded command that says hello'
<%_ if (type !== 'single') { _%>
@@ -107,3 +111,7 @@ hello myname from <%- name %>!
// this.options.args.file and this.options.argv[0] is a string or undefined
}
}
+<%_ if (type === 'single') { _%>
+
+export = <%- klass %>
+<%_ } _%>

MODIFY
templates/test/command.test.ts.ejs
templates/test/command.test.ts.ejs
import {expect, test} from '@anycli/test'
<%_ if (type === 'single') { _%>
-import cmd from '../src'
+import cmd = require('../src')
<%_ } _%>
const command = '<%- name %>'

fix: fixing single