Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 26 additions & 23 deletions packages/cli/src/commands/ship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,31 @@ async function loadManifest(): Promise<Manifest> {
return { name: 'stub', version: '0.0.0', channels: ['stable', 'beta', 'canary'], targets: {} };
}

export function createInitCmd(): Command {
return new Command('init')
.description('Scaffold sh1pt.config.ts in the current project')
.action(async () => {
const cfgPath = join(process.cwd(), 'sh1pt.config.ts');
try {
await access(cfgPath);
console.log(kleur.yellow('sh1pt.config.ts already exists — aborting.'));
return;
} catch {
// expected
}
const { name } = await prompts({
type: 'text',
name: 'name',
message: 'Project name',
initial: process.cwd().split('/').pop() ?? 'my-app',
});
if (!name) return;
await writeFile(cfgPath, CONFIG_TEMPLATE(name), 'utf8');
console.log(kleur.green(`✓ wrote sh1pt.config.ts`));
console.log(` next: ${kleur.cyan('sh1pt ship target add <id>')}`);
});
}

export const shipCmd = new Command('ship')
.description('Publish built artifacts to their target stores and registries')
.option('-t, --target <id...>', 'target ids to ship (default: all enabled)')
Expand All @@ -39,29 +64,7 @@ export const shipCmd = new Command('ship')
// TODO: load manifest, resolve latest build, invoke Target.ship(), record release
});

shipCmd
.command('init')
.description('Scaffold sh1pt.config.ts in the current project')
.action(async () => {
const cfgPath = join(process.cwd(), 'sh1pt.config.ts');
try {
await access(cfgPath);
console.log(kleur.yellow('sh1pt.config.ts already exists — aborting.'));
return;
} catch {
// expected
}
const { name } = await prompts({
type: 'text',
name: 'name',
message: 'Project name',
initial: process.cwd().split('/').pop() ?? 'my-app',
});
if (!name) return;
await writeFile(cfgPath, CONFIG_TEMPLATE(name), 'utf8');
console.log(kleur.green(`✓ wrote sh1pt.config.ts`));
console.log(` next: ${kleur.cyan('sh1pt ship target add <id>')}`);
});
shipCmd.addCommand(createInitCmd());

shipCmd
.command('setup')
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { updateCmd, removeCmd } from './commands/self.js';
import { makeCategoryCmd } from './commands/adapter-cmd.js';
import { CATEGORIES } from './adapter-registry.js';
import { skillsCmd } from './commands/skills.js';
import { createInitCmd } from './commands/ship.js';

const program = new Command();

Expand Down Expand Up @@ -40,6 +41,7 @@ program.addCommand(logoutCmd);
program.addCommand(secretsCmd);
program.addCommand(configCmd);
program.addCommand(skillsCmd); // skills · package/promote SKILL.md agent skills across marketplaces
program.addCommand(createInitCmd()); // init · documented shortcut for scaffolding sh1pt.config.ts

// Self-management — sh1pt update / upgrade / remove / uninstall.
program.addCommand(updateCmd);
Expand Down
Loading