diff --git a/cli/bun.lockb b/cli/bun.lockb index aec01101..b2e51cdb 100755 Binary files a/cli/bun.lockb and b/cli/bun.lockb differ diff --git a/cli/package.json b/cli/package.json index a6f4cc31..f4ff291b 100644 --- a/cli/package.json +++ b/cli/package.json @@ -1,50 +1,52 @@ { - "name": "onlook", - "description": "The Onlook Command Line Interface", - "version": "0.0.8", - "main": "dist/index.js", - "bin": { - "onlook": "dist/index.cjs" - }, - "directories": { - "test": "tests" - }, - "scripts": { - "esbuild": "esbuild src/index.ts --bundle --platform=node --format=cjs --outfile=dist/index.cjs", - "dev": "npm run esbuild -- --watch", - "build": "tsc --noEmit --skipLibCheck src/index.ts && esbuild src/index.ts --bundle --platform=node --format=cjs --outfile=dist/index.cjs --define:PACKAGE_VERSION=\\\"$npm_package_version\\\"", - "build:notype": "npm run esbuild", - "test": "bun test" - }, - "keywords": [ - "npx", - "onlook", - "setup", - "plugins" - ], - "author": { - "name": "Onlook", - "email": "contact@onlook.dev" - }, - "license": "Apache-2.0", - "homepage": "https://onlook.dev", - "devDependencies": { - "@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" - }, - "dependencies": { - "@babel/generator": "^7.14.5", - "@babel/parser": "^7.14.3", - "@babel/traverse": "^7.14.5", - "@babel/types": "^7.14.5", - "commander": "^12.1.0", - "degit": "^2.8.4", - "glob": "^11.0.0", - "ora": "^8.1.0" - } + "name": "onlook", + "description": "The Onlook Command Line Interface", + "version": "0.0.8", + "main": "dist/api/index.mjs", + "module": "dist/api/index.mjs", + "bin": { + "onlook": "dist/cli/index.cjs" + }, + "directories": { + "test": "tests" + }, + "scripts": { + "dev": "npm run esbuild -- --watch", + "esbuild": "esbuild src/cli/index.ts --bundle --platform=node --format=cjs --outfile=dist/cli/index.cjs", + "build": "tsc --noEmit --skipLibCheck src/cli/index.ts && esbuild src/cli/index.ts --bundle --platform=node --format=cjs --outfile=dist/cli/index.cjs --define:PACKAGE_VERSION=\\\"$npm_package_version\\\"", + "build:notype": "npm run esbuild", + "build:api": "tsc --noEmit --skipLibCheck src/api/index.ts && esbuild src/api/index.ts --bundle --platform=node --format=esm --outfile=dist/api/index.mjs", + "test": "bun test" + }, + "keywords": [ + "npx", + "onlook", + "setup", + "plugins" + ], + "author": { + "name": "Onlook", + "email": "contact@onlook.dev" + }, + "license": "Apache-2.0", + "homepage": "https://onlook.dev", + "devDependencies": { + "@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" + }, + "dependencies": { + "@babel/generator": "^7.14.5", + "@babel/parser": "^7.14.3", + "@babel/traverse": "^7.14.5", + "@babel/types": "^7.14.5", + "commander": "^12.1.0", + "degit": "^2.8.4", + "glob": "^11.0.0", + "ora": "^8.1.0" + } } \ No newline at end of file diff --git a/cli/src/api/index.ts b/cli/src/api/index.ts new file mode 100644 index 00000000..e21f5d5f --- /dev/null +++ b/cli/src/api/index.ts @@ -0,0 +1,14 @@ +import type { ApiResponse } from "../models"; + +export function isOnlookEnabled(folder: string): Promise> { + return Promise.resolve({ + status: 'success', + data: true + }); +} + +export function createProject(folder: string, name: string): Promise { + return Promise.resolve({ + status: 'success' + }); +} \ No newline at end of file diff --git a/cli/src/index.ts b/cli/src/cli/index.ts similarity index 91% rename from cli/src/index.ts rename to cli/src/cli/index.ts index fb96dbec..f8db9eb2 100644 --- a/cli/src/index.ts +++ b/cli/src/cli/index.ts @@ -1,7 +1,7 @@ #!/usr/bin/env node import { Command } from 'commander'; -import { create } from './create'; -import { setup } from './setup'; +import { create } from '../create'; +import { setup } from '../setup'; declare let PACKAGE_VERSION: string; diff --git a/cli/src/models.ts b/cli/src/models.ts new file mode 100644 index 00000000..fae847be --- /dev/null +++ b/cli/src/models.ts @@ -0,0 +1,14 @@ +export type ApiResponse = SuccessResponse | ErrorResponse; + +export type SuccessResponse = { + status: 'success'; + data?: T; +}; + +export type ErrorResponse = { + status: 'error'; + error: { + message: string; + code: string; + }; +}; \ No newline at end of file diff --git a/cli/tests/program.test.ts b/cli/tests/program.test.ts index 2025d255..948260a5 100644 --- a/cli/tests/program.test.ts +++ b/cli/tests/program.test.ts @@ -1,5 +1,5 @@ import { afterAll, expect, jest, mock, test } from "bun:test"; -import { createProgram } from "../src"; +import { createProgram } from "../src/cli"; import { setup } from "../src/setup"; const originalConsoleLog = console.log; diff --git a/cli/tsconfig.json b/cli/tsconfig.json index 39008eea..dcc6b5ae 100644 --- a/cli/tsconfig.json +++ b/cli/tsconfig.json @@ -1,31 +1,31 @@ { - "include": [ - "src", - "tests" - ], - "compilerOptions": { - // Enable latest features - "lib": [ - "ESNext", - "DOM" + "include": [ + "src", + "tests" ], - "target": "ESNext", - "module": "ESNext", - "moduleDetection": "force", - "jsx": "react-jsx", - "allowJs": true, - // Bundler mode - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, - // Best practices - "strict": true, - "skipLibCheck": true, - "noFallthroughCasesInSwitch": true, - // Some stricter flags (disabled by default) - "noUnusedLocals": false, - "noUnusedParameters": false, - "noPropertyAccessFromIndexSignature": false, - } + "compilerOptions": { + // Enable latest features + "lib": [ + "ESNext", + "DOM" + ], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + // Some stricter flags (disabled by default) + "noUnusedLocals": false, + "noUnusedParameters": false, + "noPropertyAccessFromIndexSignature": false, + } } \ No newline at end of file diff --git a/demos/next/bun.lockb b/demos/next/bun.lockb index 71335b99..fb1f7065 100755 Binary files a/demos/next/bun.lockb and b/demos/next/bun.lockb differ diff --git a/demos/next/next.config.mjs b/demos/next/next.config.mjs index db6129c2..7d858519 100644 --- a/demos/next/next.config.mjs +++ b/demos/next/next.config.mjs @@ -1,9 +1,8 @@ import path from "path"; - const nextConfig = { reactStrictMode: true, experimental: { swcPlugins: [["@onlook/nextjs", { root: path.resolve(".") }]], }, -} +}; export default nextConfig;