-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: now you can install tailwind and make sure the config exist an
return it
- Loading branch information
Showing
41 changed files
with
680 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#!/usr/bin/env node |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,77 @@ | ||
{ | ||
"name": "duck-ui", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@types/fs-extra": "^11.0.1", | ||
"@types/node": "^17.0.45", | ||
"chalk": "5.2.0", | ||
"commander": "^10.0.0", | ||
"cosmiconfig": "^8.1.3", | ||
"fast-glob": "^3.3.2", | ||
"fs-extra": "^11.1.0", | ||
"globals": "^15.9.0", | ||
"kleur": "^4.1.5", | ||
"log-symbols": "^7.0.0", | ||
"ora": "^6.1.2", | ||
"tsconfig-paths": "^4.2.0", | ||
"type-fest": "^3.8.0", | ||
"zod": "^3.23.8" | ||
} | ||
"name": "duck-ui", | ||
"version": "0.0.2", | ||
"description": "Add components to your apps.", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"license": "MIT", | ||
"author": "wildduck (https://github.com/wildduck2)", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/gentelduck/ui.git", | ||
"directory": "packages/cli" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"keywords": [ | ||
"components", | ||
"ui", | ||
"tailwind", | ||
"radix-ui", | ||
"duck-ui" | ||
], | ||
"type": "module", | ||
"exports": "./dist/index.js", | ||
"bin": { | ||
"duck-ui": "dist/index.js" | ||
}, | ||
"scripts": { | ||
"dev": "tsup --watch", | ||
"build": "tsup", | ||
"typecheck": "tsc --noEmit", | ||
"clean": "rimraf dist", | ||
"start:dev": "cross-env COMPONENTS_REGISTRY_URL=http://localhost:3003 node dist/index.js", | ||
"start": "node dist/index.js", | ||
"format:write": "prettier --write \"**/*.{ts,tsx,mdx}\" --cache", | ||
"format:check": "prettier --check \"**/*.{ts,tsx,mdx}\" --cache", | ||
"release": "changeset version", | ||
"test": "vitest run" | ||
}, | ||
"dependencies": { | ||
"@antfu/ni": "^0.21.12", | ||
"chalk": "5.2.0", | ||
"commander": "^10.0.1", | ||
"cosmiconfig": "^8.3.6", | ||
"execa": "^9.4.1", | ||
"fast-glob": "^3.3.2", | ||
"fs-extra": "^11.2.0", | ||
"globals": "^15.11.0", | ||
"kleur": "^4.1.5", | ||
"log-symbols": "^7.0.0", | ||
"ora": "^6.3.1", | ||
"prompts": "^2.4.2", | ||
"tsconfig-paths": "^4.2.0", | ||
"zod": "^3.23.8" | ||
}, | ||
"devDependencies": { | ||
"@types/babel__core": "^7.20.1", | ||
"@types/diff": "^5.0.3", | ||
"@types/fs-extra": "^11.0.1", | ||
"@types/lodash.template": "^4.5.1", | ||
"@types/prompts": "^2.4.2", | ||
"rimraf": "^4.1.3", | ||
"tsup": "^6.6.3", | ||
"type-fest": "^3.8.0", | ||
"typescript": "^4.9.3" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/gentelduck/ui/issues" | ||
}, | ||
"homepage": "https://github.com/gentelduck/ui#readme", | ||
"main": "index.js", | ||
"directories": { | ||
"test": "test" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,38 @@ | ||
export const init_command_config = { | ||
import { InitCommandConfig } from './init.types' | ||
|
||
export const init_command_config: InitCommandConfig = { | ||
name: 'init', | ||
description: 'init the project', | ||
option_1: { | ||
flags: '-y, --yes', | ||
description: 'skip confirmation prompt.', | ||
defaultValue: false | ||
}, | ||
option_2: { | ||
flags: '-d, --defaults,', | ||
description: 'use default configuration.', | ||
defaultValue: false | ||
}, | ||
option_3: { | ||
flags: '-c, --cwd <cwd>', | ||
description: 'the working directory. defaults to the current directory.', | ||
defaultValue: process.cwd() | ||
options: { | ||
option_1: { | ||
flags: '-y, --yes', | ||
description: 'skip confirmation prompt.', | ||
defaultValue: false | ||
}, | ||
option_2: { | ||
flags: '-d, --defaults,', | ||
description: 'use default configuration.', | ||
defaultValue: false | ||
}, | ||
option_3: { | ||
flags: '-c, --cwd <cwd>', | ||
description: 'the working directory. defaults to the current directory.', | ||
defaultValue: process.cwd() | ||
}, | ||
option_4: { | ||
flags: '-s, --silent', | ||
description: 'silent mode', | ||
defaultValue: false | ||
}, | ||
option_5: { | ||
flags: '-f, --force', | ||
description: 'will force and overwrite old configurations.', | ||
defaultValue: false | ||
}, | ||
option_6: { | ||
flags: '-sd, --src-dir <src-dir>', | ||
description: 'the source directory. defaults to the current directory.', | ||
defaultValue: process.cwd() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,46 @@ | ||
import path from 'path' | ||
import { init_options_schema, InitOptions } from './init.dto' | ||
import { | ||
checkTailwindCssInstalled, | ||
checkTypeScriptInstalled, | ||
get_project_config | ||
get_project_config, | ||
logger, | ||
pref_light_tailwindcss | ||
} from '@/src/utils' | ||
import { spinner } from '@/src/utils/spinner' | ||
import { REGISTRY_URL } from '@/src/main' | ||
|
||
export async function init_command_action(opt: InitOptions) { | ||
const options = init_options_schema.parse(opt) | ||
const cwd = path.resolve(options.cwd) | ||
|
||
await checkTailwindCssInstalled(cwd) | ||
logger.info({ args: ['Checking for preflight...'] }) | ||
|
||
const typescript = await checkTypeScriptInstalled(cwd) | ||
await pref_light_tailwindcss(cwd, typescript) | ||
const config = await get_project_config(cwd) | ||
|
||
console.log(config) | ||
} | ||
|
||
export async function init_command() {} | ||
function isUrl(path: string) { | ||
try { | ||
new URL(path) | ||
return true | ||
} catch (error) { | ||
return false | ||
} | ||
} | ||
|
||
function getRegistryUrl(path: string) { | ||
if (isUrl(path)) { | ||
// If the url contains /chat/b/, we assume it's the v0 registry. | ||
//NOTE: We need to add the /json suffix if it's missing. | ||
const url = new URL(path) | ||
if (url.pathname.match(/\/chat\/b\//) && !url.pathname.endsWith('/json')) { | ||
url.pathname = `${url.pathname}/json` | ||
} | ||
|
||
return url.toString() | ||
} | ||
|
||
return `${REGISTRY_URL}/${path}` | ||
} | ||
// export async function init_command() {} | ||
// function isUrl(path: string) { | ||
// try { | ||
// new URL(path) | ||
// return true | ||
// } catch (error) { | ||
// return false | ||
// } | ||
// } | ||
// | ||
// function getRegistryUrl(path: string) { | ||
// if (isUrl(path)) { | ||
// // If the url contains /chat/b/, we assume it's the v0 registry. | ||
// //NOTE: We need to add the /json suffix if it's missing. | ||
// const url = new URL(path) | ||
// if (url.pathname.match(/\/chat\/b\//) && !url.pathname.endsWith('/json')) { | ||
// url.pathname = `${url.pathname}/json` | ||
// } | ||
// | ||
// return url.toString() | ||
// } | ||
// | ||
// return `${REGISTRY_URL}/${path}` | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export type InitCommandConfig = { | ||
name: string | ||
description: string | ||
options: Record<`option_${number}`, OptionType> | ||
} | ||
|
||
export type OptionType = { | ||
flags: `-${string}, --${string}` | ||
description: string | ||
defaultValue: boolean | string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/cli-t/src/utils/get-package-manager/get-package-manager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Agent, detect } from '@antfu/ni' | ||
|
||
export async function get_package_manager( | ||
cwd: string | ||
): Promise<Exclude<Agent, 'yarn@berry' | 'pnpm@6'>> { | ||
const packageManager = await detect({ | ||
programmatic: true, | ||
cwd | ||
}) | ||
|
||
if (packageManager === 'yarn@berry') return 'yarn' | ||
if (packageManager === 'pnpm@6') return 'pnpm' | ||
if (!packageManager) return 'npm' | ||
|
||
return packageManager | ||
} | ||
|
||
export async function getPackageRunner( | ||
cwd: string, | ||
pm: Exclude<Agent, 'yarn@berry' | 'pnpm@6'> | ||
): Promise<'pnpm dlx' | 'bunx' | 'npx'> { | ||
const packageManager = pm ?? (await get_package_manager(cwd)) | ||
|
||
if (packageManager === 'pnpm') return 'pnpm dlx' | ||
if (packageManager === 'bun') return 'bunx' | ||
return 'npx' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './get-package-manager' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.