Skip to content

Commit a4aea02

Browse files
committed
feat: update cli
1 parent 973a820 commit a4aea02

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+303
-346
lines changed

.changeset/goofy-banks-hear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'create-yuki-stack': minor
3+
---
4+
5+
update cli

bun.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { defineConfig } from 'eslint/config'
2+
23
import baseConfig from '@yuki/eslint-config/base'
34
import reactConfig from '@yuki/eslint-config/react'
45

cli/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"lint": "eslint",
4343
"typecheck": "tsc --noEmit"
4444
},
45+
"prettier": "@yuki/prettier-config",
4546
"dependencies": {
4647
"@clack/prompts": "^0.11.0",
4748
"@trpc/server": "^11.7.2",
@@ -53,6 +54,7 @@
5354
"devDependencies": {
5455
"@types/node": "catalog:",
5556
"@yuki/eslint-config": "workspace:*",
57+
"@yuki/prettier-config": "workspace:*",
5658
"@yuki/tsconfig": "workspace:*",
5759
"eslint": "catalog:",
5860
"prettier": "catalog:",

cli/src/commands/add-email/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export async function addEmailMonorepo(spinner?: ReturnType<typeof p.spinner>) {
2828

2929
await fs.cp(templatePath, destPath, { recursive: true })
3030

31-
await addEnv('server', 'RESEND_TOKEN', 'z.string()')
31+
await addEnv('RESEND_TOKEN', 'z.string()')
3232

3333
const { name, packageManager } = await getProjectMetadata()
3434

cli/src/commands/init/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ export const APP_TITLE = `
3838
╚════██║ ██║ ██╔══██║ ██║ ██╔═██╗
3939
███████║ ██║ ██║ ██║ ╚██████╗ ██║ ██╗
4040
╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝`
41-
export const APP_COLORS = ['#c3c0ff', '#c7c4dd', '#eab9d2']
41+
export const APP_COLORS = ['#5a7de4', '#9ab0e5', '#dbe6f6']

cli/src/commands/init/create/api.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export async function addApi(opts: ProjectOptions): Promise<void> {
3030
])
3131
}
3232

33-
const [packageJson] = await Promise.all([
33+
const [packageJson, libPackageJson] = await Promise.all([
3434
fs
3535
.readFile(
3636
opts.backend === 'none'
@@ -39,6 +39,9 @@ export async function addApi(opts: ProjectOptions): Promise<void> {
3939
'utf-8',
4040
)
4141
.then((data) => JSON.parse(data) as PackageJson),
42+
fs
43+
.readFile('packages/lib/package.json', 'utf-8')
44+
.then((data) => JSON.parse(data) as PackageJson),
4245
fs.copyFile(
4346
new URL(
4447
`src/${opts.api}/${opts.database !== 'none' ? 'db' : 'none'}.${opts.auth}.ts`,
@@ -60,10 +63,15 @@ export async function addApi(opts: ProjectOptions): Promise<void> {
6063
])
6164

6265
packageJson.dependencies = packageJson.dependencies ?? {}
66+
libPackageJson.dependencies = libPackageJson.dependencies ?? {}
6367
if (opts.api === 'trpc') {
6468
packageJson.dependencies['@trpc/server'] = 'catalog:trpc'
6569
packageJson.dependencies.superjson = 'catalog:trpc'
66-
} else packageJson.dependencies['@orpc/server'] = 'catalog:orpc'
70+
libPackageJson.dependencies.superjson = 'catalog:trpc'
71+
} else {
72+
packageJson.dependencies['@orpc/server'] = 'catalog:orpc'
73+
libPackageJson.dependencies['@orpc/client'] = 'catalog:orpc'
74+
}
6775

6876
if (opts.backend === 'none') {
6977
if (opts.database !== 'none')
@@ -76,4 +84,9 @@ export async function addApi(opts: ProjectOptions): Promise<void> {
7684
`${destPath}/package.json`,
7785
JSON.stringify(packageJson, null, 2),
7886
)
87+
88+
await fs.writeFile(
89+
'packages/lib/package.json',
90+
JSON.stringify(libPackageJson, null, 2),
91+
)
7992
}

cli/src/commands/init/create/auth.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export async function addAuth(opts: ProjectOptions): Promise<void> {
5454
packageJson.dependencies['better-auth'] = versions['better-auth']
5555
if (opts.database === 'mongoose')
5656
packageJson.dependencies.mongodb = versions.mongodb
57-
} else {
57+
} else if (opts.auth === 'next-auth') {
5858
packageJson.dependencies['next-auth'] = versions['next-auth@beta']
5959
if (opts.database === 'drizzle')
6060
packageJson.dependencies['@auth/drizzle-adapter'] =
@@ -73,6 +73,7 @@ export async function addAuth(opts: ProjectOptions): Promise<void> {
7373
JSON.stringify(packageJson, null, 2),
7474
)
7575

76-
await addEnv('server', 'AUTH_DISCORD_ID', 'z.string()')
77-
await addEnv('server', 'AUTH_DISCORD_SECRET', 'z.string()')
76+
await addEnv('AUTH_SECRET', 'z.optional(z.string())')
77+
await addEnv('AUTH_DISCORD_ID', 'z.string()')
78+
await addEnv('AUTH_DISCORD_SECRET', 'z.string()')
7879
}

cli/src/commands/init/create/backend.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import fs from 'node:fs/promises'
22

33
import type { ProjectOptions } from '@/commands/init/types'
4-
import { addEnv } from '@/utils/add-env'
54
import {
65
getPackageVersion,
76
getPackageVersions,
@@ -19,7 +18,6 @@ export async function addBackend(opts: ProjectOptions): Promise<void> {
1918
'apps/api',
2019
{ recursive: true, force: true },
2120
)
22-
await addEnv('client', 'NEXT_PUBLIC_API_URL', 'z.optional(z.string())')
2321
return
2422
}
2523

@@ -114,8 +112,6 @@ export async function addBackend(opts: ProjectOptions): Promise<void> {
114112
if (modifiedContent !== serverContent)
115113
await fs.writeFile(`${srcDir}/server.ts`, modifiedContent)
116114
}
117-
118-
await addEnv('client', 'API_URL', 'z.optional(z.string())')
119115
}
120116

121117
async function configureBackendDependencies(

cli/src/commands/init/create/base.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fs from 'node:fs/promises'
33
import type { ProjectOptions } from '@/commands/init/types'
44

55
const versionMap = new Map<string, string>([
6-
['node', '22.0.0'],
6+
['node', '24.0.0'],
77
['npm', '11.6.0'],
88
['yarn', '1.22.22'],
99
['pnpm', '10.20.0'],
@@ -16,25 +16,21 @@ export async function addBase(opts: ProjectOptions): Promise<void> {
1616

1717
await Promise.all([
1818
fs.copyFile(new URL('_gitignore', templatePath), '.gitignore'),
19-
fs.copyFile(new URL('tsconfig.json', templatePath), 'tsconfig.json'),
2019
fs.copyFile(new URL('turbo.json', templatePath), 'turbo.json'),
2120
fs.cp(new URL('tools', templatePath), 'tools', copyOptions),
2221
fs.mkdir('apps', { recursive: true }),
23-
fs.mkdir('packages', { recursive: true }),
24-
fs.writeFile('.env.example', '# Example environment variables\n'),
25-
fs.writeFile('.nvmrc', `v${versionMap.get('node')}`),
26-
])
27-
28-
await setupPackageManager(opts, templatePath)
29-
30-
await Promise.all([
22+
fs.cp(new URL('packages/lib', templatePath), 'packages/lib', copyOptions),
3123
fs.cp(new URL('packages/ui', templatePath), 'packages/ui', copyOptions),
3224
fs.cp(
3325
new URL('packages/validators', templatePath),
3426
'packages/validators',
3527
copyOptions,
3628
),
29+
fs.writeFile('.env.example', '# Example environment variables\n'),
30+
fs.writeFile('.nvmrc', `v${versionMap.get('node')}`),
3731
])
32+
33+
await setupPackageManager(opts, templatePath)
3834
}
3935

4036
async function setupPackageManager(opts: ProjectOptions, templatePath: URL) {

0 commit comments

Comments
 (0)