Skip to content

Commit d70dd9a

Browse files
committed
Skill installation code moved to the new file
1 parent c73f5f9 commit d70dd9a

File tree

2 files changed

+33
-27
lines changed

2 files changed

+33
-27
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import chalk from 'chalk';
2+
import { confirmPrompt } from './utils/prompts';
3+
import { spawn } from './utils/spawn';
4+
5+
const SMELTER_SKILL_REPO = 'smelter-labs/skills';
6+
const SMELTER_SKILL_NAME = 'live-composing-smelter';
7+
8+
export async function promptInstallSkill(directory: string): Promise<void> {
9+
const installSkill = await confirmPrompt(
10+
'Would you like to install the Smelter TypeScript SDK skill for your AI coding assistant?'
11+
);
12+
13+
if (installSkill) {
14+
console.log();
15+
console.log('Installing Smelter skill...');
16+
try {
17+
await spawn(
18+
'npx',
19+
['-y', 'skills', 'add', SMELTER_SKILL_REPO, '--skill', SMELTER_SKILL_NAME],
20+
{ cwd: directory }
21+
);
22+
console.log(chalk.green('Smelter skill installed successfully.'));
23+
} catch {
24+
console.log(chalk.yellow('Failed to install Smelter skill. You can install it later with:'));
25+
console.log(
26+
chalk.bold(` npx skills add ${SMELTER_SKILL_REPO} --skill ${SMELTER_SKILL_NAME}`)
27+
);
28+
}
29+
}
30+
}

ts/create-smelter-app/src/run.ts

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import chalk from 'chalk';
22
import { resolveOptions } from './options';
33
import { createNodeProject } from './createNodeProject';
4-
import { confirmPrompt } from './utils/prompts';
5-
import { spawn } from './utils/spawn';
4+
import { promptInstallSkill } from './installSkill';
65

7-
const SMELTER_SKILL_REPO = 'smelter-labs/skills';
8-
const SMELTER_SKILL_NAME = 'live-composing-smelter';
9-
10-
export default async function() {
6+
export default async function () {
117
const options = await resolveOptions();
128
if (options.runtime.type === 'node') {
139
console.log('Generating Node.js Smelter project');
@@ -19,27 +15,7 @@ export default async function() {
1915
console.log(chalk.green('Project created successfully.'));
2016
console.log();
2117

22-
const installSkill = await confirmPrompt(
23-
'Would you like to install the Smelter TypeScript SDK skill for your AI coding assistant?'
24-
);
25-
26-
if (installSkill) {
27-
console.log();
28-
console.log('Installing Smelter skill...');
29-
try {
30-
await spawn(
31-
'npx',
32-
['-y', 'skills', 'add', SMELTER_SKILL_REPO, '--skill', SMELTER_SKILL_NAME],
33-
{ cwd: options.directory }
34-
);
35-
console.log(chalk.green('Smelter skill installed successfully.'));
36-
} catch (err: any) {
37-
console.log(chalk.yellow('Failed to install Smelter skill. You can install it later with:'));
38-
console.log(
39-
chalk.bold(` npx skills add ${SMELTER_SKILL_REPO} --skill ${SMELTER_SKILL_NAME}`)
40-
);
41-
}
42-
}
18+
await promptInstallSkill(options.directory);
4319

4420
console.log();
4521
console.log(`To get started run:`);

0 commit comments

Comments
 (0)