From f17a7df040de62fc3f374d6ec27bdbd52601004b Mon Sep 17 00:00:00 2001 From: Kiet <31864905+Kitenite@users.noreply.github.com> Date: Tue, 3 Sep 2024 17:40:34 -0400 Subject: [PATCH] Npx script for creating a new Onlook project (#292) --- cli/README.md | 2 +- cli/bun.lockb | Bin 41026 -> 47340 bytes cli/package.json | 7 +++-- cli/src/create/constant.ts | 1 + cli/src/create/index.ts | 52 +++++++++++++++++++++++++++++++++++++ cli/src/index.ts | 5 ++-- 6 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 cli/src/create/constant.ts create mode 100644 cli/src/create/index.ts diff --git a/cli/README.md b/cli/README.md index 127fdf9f7..d1747a44a 100644 --- a/cli/README.md +++ b/cli/README.md @@ -4,7 +4,7 @@ A command line interface for Onlook. This package contains the following functionality - [x] Setting up your project -- [ ] Install template projects +- [X] Install template projects - [ ] Auto generate component library - [ ] Migrating your Onlook configuration diff --git a/cli/bun.lockb b/cli/bun.lockb index 706337a9b4e34b5857fa3f823d872183bbab8640..aec01101b0087075e7667164687e8ac8f0e1f17b 100755 GIT binary patch delta 11683 zcmeHNd014(vY#_7GK7&umSIx?K>>$NR>2VjjmRPxanvY^Fv=kNqPQSq6yqMTOrnVk zcr}T*YusYu9+0&N?yjz` z({q+Sa!7vXzI;iL|H7KRKiQv)D>|nl=V(}%ZM2A+R%aYW<=!|F(%sHBmj_R7RG ztzO%u)^@6qG3M?vnW3aSM`R)dnampeG!yj)wE=Gnn8CI?znivq9agWHKdaX-;LndZKPhEZVVwMfzfWX--AO zZOCgCs0f3AX#+BD_$w$6>~E@H3^(wAGeNn-JoLi)f90VCn4Sydl7~(}p9ii)V{U&G z8G9D}3==z&TssS+^1%PxFi$r@Ux}GD06g$APkWGi> zF14p&Gf#FOXeZG1pcvLbruteFuLtF@83xLFNhW!SN$zHnTblSEJ&dD%1by%KT(Zd)7X^`nX77tZe4S}r``2ick)JNU5z`GRD5(~ z>Z1*QQ{+>XyXSk`Rh7MSRW_-+YyR1rGec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MQk>>DrmK6_-8x)&`=x#b z^D9(`|B1%=VR_B{J?|^@1?Lko$hYm_s0tQ(Vj)!ukXF) zH+b#3HQp6VQXlg!TGvQF**`jn1*=l)R;=~X2m60TL#cp1JWw9ouzclGZ|a(cB@NBA n@?dm#-oZ11o;VPJr|cVhhEonzQ~04<-Oj_wk=>m?dqn;Z5AT`% diff --git a/cli/package.json b/cli/package.json index 59f019efa..cd8b193d3 100644 --- a/cli/package.json +++ b/cli/package.json @@ -1,7 +1,7 @@ { "name": "onlook", "description": "The Onlook Command Line Interface", - "version": "0.0.5", + "version": "0.0.6", "main": "dist/index.js", "bin": { "onlook": "dist/index.cjs" @@ -32,6 +32,7 @@ "@types/babel__generator": "^7.6.8", "@types/babel__traverse": "^7.20.6", "@types/bun": "latest", + "@types/degit": "^2.8.6", "esbuild": "^0.23.1", "tslib": "^2.6.3", "typescript": "^5.0.0" @@ -42,6 +43,8 @@ "@babel/traverse": "^7.14.5", "@babel/types": "^7.14.5", "commander": "^12.1.0", - "glob": "^11.0.0" + "degit": "^2.8.4", + "glob": "^11.0.0", + "ora": "^8.1.0" } } \ No newline at end of file diff --git a/cli/src/create/constant.ts b/cli/src/create/constant.ts new file mode 100644 index 000000000..ed2c05d61 --- /dev/null +++ b/cli/src/create/constant.ts @@ -0,0 +1 @@ +export const NEXT_TEMPLATE_REPO = 'onlook-dev/starter'; diff --git a/cli/src/create/index.ts b/cli/src/create/index.ts new file mode 100644 index 000000000..2283fcfad --- /dev/null +++ b/cli/src/create/index.ts @@ -0,0 +1,52 @@ +import { exec } from 'child_process'; +import degit from 'degit'; +import * as fs from 'fs'; +import ora from 'ora'; +import * as path from 'path'; +import { promisify } from 'util'; +import { NEXT_TEMPLATE_REPO } from './constant'; + +const execAsync = promisify(exec); + +export async function create(projectName: string) { + const targetPath = path.join(process.cwd(), projectName); + + console.log(`Creating a new Onlook project: ${projectName}`); + + // Check if the directory already exists + if (fs.existsSync(targetPath)) { + console.error(`Error: Directory ${projectName} already exists.`); + process.exit(1); + } + + const spinner = ora('Initializing project').start(); + + try { + // Clone the template using degit + spinner.text = 'Cloning template'; + const emitter = degit(NEXT_TEMPLATE_REPO, { + cache: false, + force: true, + verbose: true, + }); + + await emitter.clone(targetPath); + + // Change to the project directory + process.chdir(targetPath); + + // Install dependencies + spinner.text = 'Installing dependencies'; + await execAsync('npm install'); + + spinner.succeed('Project created successfully'); + + console.log('\nTo get started:'); + console.log(` cd ${projectName}`); + console.log(' npm run dev'); + } catch (error) { + spinner.fail('Project creation failed'); + console.error('An error occurred:', error); + process.exit(1); + } +} \ No newline at end of file diff --git a/cli/src/index.ts b/cli/src/index.ts index 897c5cff6..fb96dbec5 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -1,5 +1,6 @@ #!/usr/bin/env node import { Command } from 'commander'; +import { create } from './create'; import { setup } from './setup'; declare let PACKAGE_VERSION: string; @@ -13,9 +14,9 @@ export function createProgram() { .version(typeof PACKAGE_VERSION !== 'undefined' ? PACKAGE_VERSION : '0.0.0'); program - .command('create') + .command('create ') .description('Create a new Onlook project from scratch') - .action(() => console.log("Coming soon!")); + .action(create); program .command('setup')