fix: simplified bin scripts
MODIFY
bin/run
bin/run
#!/usr/bin/env node
-/* eslint-disable no-unpublished-require */
-
-const undefault = m => m.__esModule === true ? m.default : m
-
-const fs = require('fs')
-const path = require('path')
-const dev = fs.existsSync(path.join(__dirname, '../tsconfig.json'))
-
-if (dev) require('ts-node/register')
-
-undefault(require(`../${dev ? 'src' : 'lib'}`))()
+require('..').run()

MODIFY
package.json
package.json
"bin": "bin/run",
"bugs": "https://github.com/dxcli/create-dxcli/issues",
"dependencies": {
- "@dxcli/command": "^0.2.3",
- "@dxcli/config": "^0.1.32",
+ "@dxcli/command": "^0.2.4",
+ "@dxcli/config": "^0.1.33",
"@dxcli/engine": "^0.1.17",
"@dxcli/version": "^0.1.12",
"cli-ux": "^3.3.8",

MODIFY
src/generators/app/index.ts
src/generators/app/index.ts
@@ -403,7 +403,7 @@ class App extends Generator {
private _writePlugin() {
if (!this.fromScratch) return
- this.fs.copyTpl(this.templatePath(`plugin/bin/run.${this._ext}`), this.destinationPath('bin/run'), this)
+ this.fs.copyTpl(this.templatePath('plugin/bin/run'), this.destinationPath('bin/run'), this)
this.fs.copyTpl(this.templatePath('bin/run.cmd'), this.destinationPath('bin/run.cmd'), this)
this.fs.copyTpl(this.templatePath(`command.${this._ext}.ejs`), this.destinationPath(`src/commands/hello.${this._ext}`), {name: 'hello', _})
if (this.ts) {
@@ -416,7 +416,11 @@ class App extends Generator {
private _writeSingle() {
if (!this.fromScratch) return
- this.fs.copyTpl(this.templatePath(`single/bin/run.${this._ext}`), this.destinationPath('bin/run'), this)
+ if (this.ts) {
+ this.fs.copyTpl(this.templatePath('single/bin/run.ts'), this.destinationPath('bin/run'), this)
+ } else {
+ this.fs.copyTpl(this.templatePath('bin/run'), this.destinationPath('bin/run'), this)
+ }
this.fs.copyTpl(this.templatePath('bin/run.cmd'), this.destinationPath('bin/run.cmd'), this)
this.fs.copyTpl(this.templatePath(`single/src/index.${this._ext}.ejs`), this.destinationPath(`src/index.${this._ext}`), {name: this.pjson.name, _})
if (this.mocha) {
@@ -427,7 +431,7 @@ class App extends Generator {
private _writeMulti() {
if (!this.fromScratch) return
this._writePlugin()
- this.fs.copyTpl(this.templatePath(`multi/bin/run.${this._ext}`), this.destinationPath('bin/run'), this)
+ this.fs.copyTpl(this.templatePath('bin/run'), this.destinationPath('bin/run'), this)
this.fs.copyTpl(this.templatePath('bin/run.cmd'), this.destinationPath('bin/run.cmd'), this)
this.fs.copyTpl(this.templatePath(`multi/src/index.${this._ext}`), this.destinationPath(`src/index.${this._ext}`), this)
}

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

DELETE
templates/multi/bin/run.js
-#!/usr/bin/env node
-
-const run = require('..')
-run()

DELETE
templates/multi/bin/run.ts
-#!/usr/bin/env node
-
-/* eslint-disable no-unpublished-require */
-
-const undefault = m => m.__esModule === true ? m.default : m
-
-const fs = require('fs')
-const path = require('path')
-const dev = fs.existsSync(path.join(__dirname, '../tsconfig.json'))
-
-if (dev) require('ts-node/register')
-
-undefault(require(`../${dev ? 'src' : 'lib'}`))()

MODIFY
templates/multi/src/index.js
templates/multi/src/index.js
-const {run} = require('@dxcli/engine')
-module.exports = run
+module.exports = require('@dxcli/engine')

MODIFY
templates/multi/src/index.ts
templates/multi/src/index.ts
-import run from '@dxcli/engine'
-export {run}
-export default run
+export {run} from '@dxcli/engine'

ADD
templates/plugin/bin/run
+#!/usr/bin/env node
+
+require('@dxcli/engine').run()

DELETE
templates/plugin/bin/run.js
-#!/usr/bin/env node
-
-const undefault = m => m.__esModule === true ? m.default : m
-undefault(require('@dxcli/engine'))()

DELETE
templates/plugin/bin/run.ts
-#!/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')
-
-const undefault = m => m.__esModule === true ? m.default : m
-undefault(require('@dxcli/engine'))()

DELETE
templates/single/bin/run.js
-#!/usr/bin/env node
-
-const cmd = require('..')
-cmd.run()

MODIFY
templates/single/bin/run.ts
templates/single/bin/run.ts
#!/usr/bin/env node
-/* eslint-disable no-unpublished-require */
-
-const undefault = m => m.__esModule === true ? m.default : m
-
-const fs = require('fs')
-const path = require('path')
-const dev = fs.existsSync(path.join(__dirname, '../tsconfig.json'))
-
-if (dev) require('ts-node/register')
-
-const cmd = undefault(require(`../${dev ? 'src' : 'lib'}`))
-cmd.run()
+require('..').default.run()

MODIFY
yarn.lock
yarn.lock
lodash "^4.17.4"
tslib "^1.9.0"
-"@dxcli/command@^0.2.3":
- version "0.2.3"
- resolved "https://registry.yarnpkg.com/@dxcli/command/-/command-0.2.3.tgz#244ffea9939bd3a4b6cd9defe5f8657a5041cb93"
+"@dxcli/command@^0.2.4":
+ version "0.2.4"
+ resolved "https://registry.yarnpkg.com/@dxcli/command/-/command-0.2.4.tgz#697dd134d60b409e2a42b86260835e78967d10de"
dependencies:
"@dxcli/parser" "^0.0.5"
debug "^3.1.0"
lodash "^4.17.4"
tslib "^1.9.0"
-"@dxcli/config@^0.1.32":
- version "0.1.32"
- resolved "https://registry.yarnpkg.com/@dxcli/config/-/config-0.1.32.tgz#b07b33cc9f91031ff795983bacf8a84f60294ecb"
+"@dxcli/config@^0.1.33":
+ version "0.1.33"
+ resolved "https://registry.yarnpkg.com/@dxcli/config/-/config-0.1.33.tgz#b29c059c2f5b8b764f00ccf42b2ea7aaa4f962e4"
dependencies:
cli-ux "^3.3.8"
debug "^3.1.0"

fix: simplified bin scripts