-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
179 additions
and
8 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,19 @@ | ||
name: CLI | ||
on: | ||
push: | ||
paths: | ||
- 'cli/**' | ||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: latest | ||
- name: Install dependencies | ||
run: bun install | ||
- name: 🔦 Run linter | ||
run: bun run lint | ||
- name: 🪐 Check TypeScript | ||
run: bun run typecheck |
Binary file not shown.
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,53 @@ | ||
{ | ||
"name": "v1-run", | ||
"version": "0.0.1", | ||
"description": "A CLI for v1", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"license": "MIT", | ||
"author": { | ||
"name": "pontusab", | ||
"url": "https://twitter.com/pontusab" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/midday-ai/v1.git", | ||
"directory": "cli" | ||
}, | ||
"files": ["dist"], | ||
"keywords": ["nextjs"], | ||
"type": "module", | ||
"exports": "./dist/index.js", | ||
"bin": "./dist/index.js", | ||
"scripts": { | ||
"dev": "tsup --watch", | ||
"build": "tsup", | ||
"typecheck": "tsc --noEmit", | ||
"clean": "rimraf dist && rimraf components", | ||
"start:dev": "node dist/index.js", | ||
"start": "node dist/index.js", | ||
"release": "changeset version", | ||
"pub:beta": "pnpm build && pnpm publish --no-git-checks --access public --tag beta", | ||
"pub:next": "pnpm build && pnpm publish --no-git-checks --access public --tag next", | ||
"pub:release": "pnpm build && pnpm publish --access public", | ||
"test": "vitest run" | ||
}, | ||
"dependencies": { | ||
"chalk": "5.2.0", | ||
"commander": "^10.0.0", | ||
"fast-glob": "^3.3.2", | ||
"fs-extra": "^11.1.0", | ||
"ora": "^6.1.2", | ||
"prompts": "^2.4.2", | ||
"zod": "^3.23.8" | ||
}, | ||
"devDependencies": { | ||
"@types/fs-extra": "^11.0.1", | ||
"@types/prompts": "^2.4.2", | ||
"rimraf": "^4.1.3", | ||
"tsup": "^6.6.3", | ||
"type-fest": "^3.8.0", | ||
"typescript": "^4.9.3" | ||
} | ||
} |
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,36 @@ | ||
import { existsSync } from "node:fs"; | ||
import path from "node:path"; | ||
import { Command } from "commander"; | ||
import { z } from "zod"; | ||
|
||
const initOptionsSchema = z.object({ | ||
cwd: z.string(), | ||
yes: z.boolean(), | ||
defaults: z.boolean(), | ||
}); | ||
|
||
export const init = new Command() | ||
.name("init") | ||
.description("initialize your project and install dependencies") | ||
.option("-y, --yes", "skip confirmation prompt.", false) | ||
.option("-d, --defaults,", "use default configuration.", false) | ||
.option( | ||
"-c, --cwd <cwd>", | ||
"the working directory. defaults to the current directory.", | ||
process.cwd(), | ||
) | ||
.action(async (opts) => { | ||
try { | ||
const options = initOptionsSchema.parse(opts); | ||
const cwd = path.resolve(options.cwd); | ||
|
||
// Ensure target directory exists. | ||
if (!existsSync(cwd)) { | ||
// logger.error(`The path ${cwd} does not exist. Please try again.`); | ||
process.exit(1); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
process.exit(1); | ||
} | ||
}); |
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 @@ | ||
#!/usr/bin/env node | ||
import { init } from "@/src/commands/init"; | ||
import { Command } from "commander"; | ||
import { getPackageInfo } from "./utils/get-package-info"; | ||
|
||
process.on("SIGINT", () => process.exit(0)); | ||
process.on("SIGTERM", () => process.exit(0)); | ||
|
||
async function main() { | ||
const packageInfo = await getPackageInfo(); | ||
|
||
const program = new Command() | ||
.name("v1-run") | ||
.description("Blah") | ||
.version( | ||
packageInfo.version || "1.0.0", | ||
"-v, --version", | ||
"display the version number", | ||
); | ||
|
||
program.addCommand(init); | ||
// .addCommand(add).addCommand(diff); | ||
|
||
program.parse(); | ||
} | ||
|
||
main(); |
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,9 @@ | ||
import path from "node:path"; | ||
import fs from "fs-extra"; | ||
import type { PackageJson } from "type-fest"; | ||
|
||
export function getPackageInfo() { | ||
const packageJsonPath = path.join("package.json"); | ||
|
||
return fs.readJSONSync(packageJsonPath) as PackageJson; | ||
} |
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,15 @@ | ||
{ | ||
"extends": "@v1/typescript/base.json", | ||
"compilerOptions": { | ||
"isolatedModules": false, | ||
"module": "preserve", | ||
"moduleResolution": "bundler", | ||
"resolveJsonModule": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"@/*": ["./*"] | ||
} | ||
}, | ||
"include": ["src/**/*.ts"], | ||
"exclude": ["node_modules"] | ||
} |
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,12 @@ | ||
import { defineConfig } from "tsup"; | ||
|
||
export default defineConfig({ | ||
clean: true, | ||
dts: true, | ||
entry: ["src/index.ts"], | ||
format: ["esm"], | ||
sourcemap: true, | ||
minify: true, | ||
target: "esnext", | ||
outDir: "dist", | ||
}); |
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
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,5 +1,5 @@ | ||
{ | ||
"name": "dub", | ||
"name": "Dub", | ||
"envs": { | ||
"DUB_API_KEY": { | ||
"description": "The API key to use for Dub", | ||
|
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
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
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