Skip to content

Commit

Permalink
feat: generate cli with core v4 (#1435)
Browse files Browse the repository at this point in the history
* feat: generate cli with core v4

* fix: add types/node during init
  • Loading branch information
mdonnalley committed Jun 4, 2024
1 parent 7497ba6 commit d0b5a98
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,26 @@ export default class Generate extends GeneratorCommand<typeof Generate> {
})
}

const allInstalledDeps = [...installedDeps, ...Object.keys(packageJSON.devDependencies ?? {})]
if (!allInstalledDeps.includes('ts-node')) {
const allInstalledDeps = new Set([...installedDeps, ...Object.keys(packageJSON.devDependencies ?? {})])
if (!allInstalledDeps.has('ts-node')) {
this.log('Installing ts-node')
await exec(`${packageManager} ${packageManager === 'yarn' ? 'add --dev' : 'install --save-dev'} ts-node`, {
cwd: location,
silent: false,
})
}

if (!allInstalledDeps.has('@types/node')) {
this.log('@types/node')
await exec(
`${packageManager} ${packageManager === 'yarn' ? 'add --dev' : 'install --save-dev'} @types/node@^18`,
{
cwd: location,
silent: false,
},
)
}

this.log(`\nCreated CLI ${chalk.green(bin)}`)
}
}
2 changes: 1 addition & 1 deletion templates/cli/shared/package.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"bugs": "https://github.com/<%- owner %>/<%- repository %>/issues",
"dependencies": {
"@oclif/core": "^3",
"@oclif/core": "^4",
"@oclif/plugin-help": "^6",
"@oclif/plugin-plugins": "^5"
},
Expand Down

0 comments on commit d0b5a98

Please sign in to comment.