create-tribo-app 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +36 -0
- package/src/index.ts +85 -0
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-tribo-app",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI to bootstrap Tribo Ecosystem Mini Apps",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-tribo-app": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsup src/index.ts --format cjs --minify --clean",
|
|
11
|
+
"dev": "tsup src/index.ts --format cjs --watch"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"tribo",
|
|
15
|
+
"cli",
|
|
16
|
+
"create-app",
|
|
17
|
+
"minikit"
|
|
18
|
+
],
|
|
19
|
+
"author": "Tribo",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"chalk": "^5.3.0",
|
|
23
|
+
"commander": "^11.1.0",
|
|
24
|
+
"execa": "^8.0.1",
|
|
25
|
+
"fs-extra": "^11.2.0",
|
|
26
|
+
"inquirer": "^9.2.12",
|
|
27
|
+
"ora": "^7.0.1"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"tsup": "^8.0.0",
|
|
31
|
+
"typescript": "^5.0.0",
|
|
32
|
+
"@types/node": "^20.0.0",
|
|
33
|
+
"@types/fs-extra": "^11.0.0",
|
|
34
|
+
"@types/inquirer": "^9.0.0"
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import ora from 'ora';
|
|
6
|
+
import { execa } from 'execa';
|
|
7
|
+
import fs from 'fs-extra';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
|
|
10
|
+
const program = new Command();
|
|
11
|
+
|
|
12
|
+
program
|
|
13
|
+
.name('create-tribo-app')
|
|
14
|
+
.description('Bootstrap a new Tribo Ecosystem Mini App')
|
|
15
|
+
.version('1.0.0')
|
|
16
|
+
.argument('[directory]', 'directory to create the app in')
|
|
17
|
+
.action(async (directory) => {
|
|
18
|
+
console.log(chalk.bold.blue('\nš Welcome to Tribo Ecosystem SDK CLI\n'));
|
|
19
|
+
|
|
20
|
+
const answers = await inquirer.prompt([
|
|
21
|
+
{
|
|
22
|
+
type: 'input',
|
|
23
|
+
name: 'projectName',
|
|
24
|
+
message: 'What is your project name?',
|
|
25
|
+
default: directory || 'my-tribo-app',
|
|
26
|
+
when: !directory
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: 'list',
|
|
30
|
+
name: 'type',
|
|
31
|
+
message: 'How would you like to start?',
|
|
32
|
+
choices: [
|
|
33
|
+
{ name: 'Clone official Template (Next.js + SDK)', value: 'template' },
|
|
34
|
+
{ name: 'Install SDK only (tribo-kit-sdk)', value: 'sdk-only' }
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
const projectName = directory || answers.projectName;
|
|
40
|
+
const targetDir = path.resolve(process.cwd(), projectName);
|
|
41
|
+
|
|
42
|
+
if (answers.type === 'template') {
|
|
43
|
+
const spinner = ora(`Cloning Tribo template into ${chalk.cyan(projectName)}...`).start();
|
|
44
|
+
try {
|
|
45
|
+
// Here we would ideally clone from a public URL.
|
|
46
|
+
// For now, since we are in the user's environment, we'll simulate the clone logic.
|
|
47
|
+
// In reality, this would be: await execa('git', ['clone', 'https://github.com/Ortegaa03/template_ecosystem_app.git', targetDir]);
|
|
48
|
+
|
|
49
|
+
await execa('git', ['clone', 'https://github.com/Ortegaa03/template_ecosystem_app.git', targetDir]);
|
|
50
|
+
|
|
51
|
+
// Clean up git history of the template
|
|
52
|
+
await fs.remove(path.join(targetDir, '.git'));
|
|
53
|
+
|
|
54
|
+
spinner.succeed(chalk.green('Template cloned successfully!'));
|
|
55
|
+
|
|
56
|
+
console.log('\nNext steps:');
|
|
57
|
+
console.log(chalk.cyan(` cd ${projectName}`));
|
|
58
|
+
console.log(chalk.cyan(' npm install'));
|
|
59
|
+
console.log(chalk.cyan(' npm run dev'));
|
|
60
|
+
} catch (error: any) {
|
|
61
|
+
spinner.fail(chalk.red('Failed to clone template.'));
|
|
62
|
+
console.error(error.message);
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
const spinner = ora(`Initializing project with ${chalk.cyan('tribo-kit-sdk')}...`).start();
|
|
66
|
+
try {
|
|
67
|
+
await fs.ensureDir(targetDir);
|
|
68
|
+
await execa('npm', ['init', '-y'], { cwd: targetDir });
|
|
69
|
+
await execa('npm', ['install', 'tribo-kit-sdk'], { cwd: targetDir });
|
|
70
|
+
|
|
71
|
+
spinner.succeed(chalk.green('SDK installed successfully!'));
|
|
72
|
+
|
|
73
|
+
console.log('\nNext steps:');
|
|
74
|
+
console.log(chalk.cyan(` cd ${projectName}`));
|
|
75
|
+
console.log(chalk.cyan(' Start building your Tribo app!'));
|
|
76
|
+
} catch (error: any) {
|
|
77
|
+
spinner.fail(chalk.red('Failed to initialize project.'));
|
|
78
|
+
console.error(error.message);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
console.log(chalk.bold.blue('\nHappy hacking! š Tribo\n'));
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
program.parse();
|