Skip to content

Commit bf8a309

Browse files
committed
feat: generic agent commands
1 parent bbfeef9 commit bf8a309

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

packages/create/src/index.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,26 @@ const argv = parse(process.argv.slice(2), {
2727
},
2828
})
2929

30+
function agentInstall(agent: string) {
31+
const commands = {
32+
yarn: '',
33+
npm: 'install',
34+
pnpm: 'install',
35+
deno: 'install',
36+
} as const
37+
return `${agent} ${commands[agent] ?? commands['npm']}`
38+
}
39+
40+
function agentRun(agent: string, script: string) {
41+
const commands = {
42+
'yarn': '',
43+
'npm': ' run',
44+
'pnpm': ' run',
45+
'deno': ' task',
46+
} as const
47+
return `${agent}${commands[agent] ?? commands['npm']} ${script}`
48+
}
49+
3050
function supports(command: string) {
3151
try {
3252
execSync(command, { stdio: 'ignore' })
@@ -154,15 +174,15 @@ async function install() {
154174
const yes = await confirm('Install and start it now?')
155175
if (yes) {
156176
execSync([agent, 'install'].join(' '), { stdio: 'inherit', cwd: rootDir })
157-
execSync([agent, 'run', 'start'].join(' '), { stdio: 'inherit', cwd: rootDir })
177+
execSync([agent, agent === 'deno' ? 'task' : 'run', 'start'].join(' '), { stdio: 'inherit', cwd: rootDir })
158178
} else {
159179
console.log(kleur.dim(' You can start it later by:\n'))
160180
if (rootDir !== cwd) {
161181
const related = relative(cwd, rootDir)
162182
console.log(kleur.blue(` cd ${kleur.bold(related)}`))
163183
}
164-
console.log(kleur.blue(` ${agent === 'yarn' ? 'yarn' : `${agent} install`}`))
165-
console.log(kleur.blue(` ${agent === 'yarn' ? 'yarn start' : `${agent} run start`}`))
184+
console.log(kleur.blue(` ${agentInstall(agent)}`))
185+
console.log(kleur.blue(` ${agentRun(agent, 'start')}`))
166186
console.log()
167187
}
168188
}

0 commit comments

Comments
 (0)