Skip to content

Commit f54bd34

Browse files
committed
chord: merge main
2 parents e16cbda + d8d8f40 commit f54bd34

File tree

14 files changed

+186
-9
lines changed

14 files changed

+186
-9
lines changed

cli/create-start-app/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"name": "create-start-app",
3+
<<<<<<< HEAD
34
"version": "0.10.0-alpha.15",
5+
=======
6+
"version": "0.12.0",
7+
>>>>>>> main
48
"description": "Tanstack Start Builder",
59
"bin": "./dist/index.js",
610
"type": "module",

cli/create-tanstack/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"name": "create-tanstack",
3+
<<<<<<< HEAD
34
"version": "0.10.0-alpha.15",
5+
=======
6+
"version": "0.12.0",
7+
>>>>>>> main
48
"description": "Tanstack Application Builder",
59
"bin": "./dist/index.js",
610
"type": "module",

cli/create-tsrouter-app/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"name": "create-tsrouter-app",
3+
<<<<<<< HEAD
34
"version": "0.10.0-alpha.15",
5+
=======
6+
"version": "0.12.0",
7+
>>>>>>> main
48
"description": "Tanstack Application Builder",
59
"bin": "./dist/index.js",
610
"type": "module",

packages/cta-engine/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"name": "@tanstack/cta-engine",
3+
<<<<<<< HEAD
34
"version": "0.10.0-alpha.15",
5+
=======
6+
"version": "0.12.0",
7+
>>>>>>> main
48
"description": "Tanstack Application Builder Engine",
59
"type": "module",
610
"main": "./dist/index.js",

packages/cta-engine/src/cli.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { add } from './add.js'
1616

1717
import type { PackageManager } from './package-manager.js'
1818
import type { ToolChain } from './toolchain.js'
19-
import type { CliOptions, Framework } from './types.js'
19+
import type { CliOptions, Framework, Mode, TemplateOptions } from './types.js'
2020

2121
export function cli({
2222
name,
@@ -26,7 +26,7 @@ export function cli({
2626
}: {
2727
name: string
2828
appName: string
29-
forcedMode?: 'typescript' | 'javascript' | 'file-router'
29+
forcedMode?: Mode
3030
forcedAddOns?: Array<string>
3131
}) {
3232
const program = new Command()
@@ -147,12 +147,12 @@ export function cli({
147147
program.action(async (projectName: string, options: CliOptions) => {
148148
if (options.listAddOns) {
149149
await listAddOns(options, {
150-
forcedMode,
150+
forcedMode: forcedMode as TemplateOptions,
151151
forcedAddOns,
152152
})
153153
} else if (options.mcp || options.mcpSse) {
154154
await runServer(!!options.mcpSse, {
155-
forcedMode,
155+
forcedMode: forcedMode as TemplateOptions,
156156
forcedAddOns,
157157
appName,
158158
})
@@ -164,16 +164,20 @@ export function cli({
164164
} as CliOptions
165165

166166
if (forcedMode) {
167-
cliOptions.template = forcedMode
167+
cliOptions.template = forcedMode as TemplateOptions
168168
}
169169

170-
let finalOptions = await normalizeOptions(cliOptions, forcedAddOns)
170+
let finalOptions = await normalizeOptions(
171+
cliOptions,
172+
forcedMode,
173+
forcedAddOns,
174+
)
171175
if (finalOptions) {
172176
intro(`Creating a new ${appName} app in ${projectName}...`)
173177
} else {
174178
intro(`Let's configure your ${appName} application`)
175179
finalOptions = await promptForOptions(cliOptions, {
176-
forcedMode,
180+
forcedMode: forcedMode as TemplateOptions,
177181
forcedAddOns,
178182
})
179183
}

packages/cta-engine/src/options.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,24 @@ import { DEFAULT_TOOLCHAIN, SUPPORTED_TOOLCHAINS } from './toolchain.js'
1616
import { CODE_ROUTER, DEFAULT_FRAMEWORK, FILE_ROUTER } from './constants.js'
1717
import { finalizeAddOns, getAllAddOns, loadRemoteAddOn } from './add-ons.js'
1818

19+
<<<<<<< HEAD
1920
import type { AddOn, CliOptions, Options, Starter, Variable } from './types.js'
21+
=======
22+
import type {
23+
AddOn,
24+
CliOptions,
25+
Mode,
26+
Options,
27+
Overlay,
28+
TemplateOptions,
29+
Variable,
30+
} from './types.js'
31+
>>>>>>> main
2032

2133
// If all CLI options are provided, use them directly
2234
export async function normalizeOptions(
2335
cliOptions: CliOptions,
36+
forcedMode?: Mode,
2437
forcedAddOns?: Array<string>,
2538
): Promise<Options | undefined> {
2639
// in some cases, if you use windows/powershell, the argument for addons
@@ -80,7 +93,9 @@ export async function normalizeOptions(
8093
}
8194
chosenAddOns = await finalizeAddOns(
8295
cliOptions.framework || DEFAULT_FRAMEWORK,
83-
cliOptions.template === 'file-router' ? FILE_ROUTER : CODE_ROUTER,
96+
forcedMode || cliOptions.template === 'file-router'
97+
? FILE_ROUTER
98+
: CODE_ROUTER,
8499
finalAddOns,
85100
)
86101
tailwind = true
@@ -154,7 +169,7 @@ export async function promptForOptions(
154169
forcedMode,
155170
}: {
156171
forcedAddOns?: Array<string>
157-
forcedMode?: 'typescript' | 'javascript' | 'file-router'
172+
forcedMode?: TemplateOptions
158173
},
159174
): Promise<Required<Options>> {
160175
const options = {} as Required<Options>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## T3Env
2+
3+
- You can use T3Env to add type safety to your environment variables.
4+
- Add Environment variables to the `src/env.mjs` file.
5+
- Use the environment variables in your code.
6+
7+
### Usage
8+
9+
```ts
10+
import { env } from "@/env";
11+
12+
console.log(env.VITE_APP_TITLE);
13+
```
14+
15+
16+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { createEnv } from "@t3-oss/env-core";
2+
import { z } from "zod";
3+
4+
export const env = createEnv({
5+
server: {
6+
SERVER_URL: z.string().url().optional(),
7+
},
8+
9+
/**
10+
* The prefix that client-side variables must have. This is enforced both at
11+
* a type-level and at runtime.
12+
*/
13+
clientPrefix: "VITE_",
14+
15+
client: {
16+
VITE_APP_TITLE: z.string().min(1).optional(),
17+
},
18+
19+
/**
20+
* What object holds the environment variables at runtime. This is usually
21+
* `process.env` or `import.meta.env`.
22+
*/
23+
runtimeEnv: import.meta.env,
24+
25+
/**
26+
* By default, this library will feed the environment variables directly to
27+
* the Zod validator.
28+
*
29+
* This means that if you have an empty string for a value that is supposed
30+
* to be a number (e.g. `PORT=` in a ".env" file), Zod will incorrectly flag
31+
* it as a type mismatch violation. Additionally, if you have an empty string
32+
* for a value that is supposed to be a string with a default value (e.g.
33+
* `DOMAIN=` in an ".env" file), the default value will never be applied.
34+
*
35+
* In order to solve these issues, we recommend that all new projects
36+
* explicitly specify this option as true.
37+
*/
38+
emptyStringAsUndefined: true,
39+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "T3Env",
3+
"description": "Add type safety to your environment variables",
4+
"phase": "add-on",
5+
"link": "https://github.com/t3-oss/t3-env",
6+
"templates": [
7+
"file-router",
8+
"code-router"
9+
]
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"dependencies": {
3+
"zod": "^3.24.2",
4+
"@t3-oss/env-core": "^0.12.0"
5+
}
6+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## T3Env
2+
3+
- You can use T3Env to add type safety to your environment variables.
4+
- Add Environment variables to the `src/env.mjs` file.
5+
- Use the environment variables in your code.
6+
7+
### Usage
8+
9+
```ts
10+
import { env } from "@/env";
11+
12+
console.log(env.VITE_APP_TITLE);
13+
```
14+
15+
16+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { createEnv } from "@t3-oss/env-core";
2+
import { z } from "zod";
3+
4+
export const env = createEnv({
5+
server: {
6+
SERVER_URL: z.string().url().optional(),
7+
},
8+
9+
/**
10+
* The prefix that client-side variables must have. This is enforced both at
11+
* a type-level and at runtime.
12+
*/
13+
clientPrefix: "VITE_",
14+
15+
client: {
16+
VITE_APP_TITLE: z.string().min(1).optional(),
17+
},
18+
19+
/**
20+
* What object holds the environment variables at runtime. This is usually
21+
* `process.env` or `import.meta.env`.
22+
*/
23+
runtimeEnv: import.meta.env,
24+
25+
/**
26+
* By default, this library will feed the environment variables directly to
27+
* the Zod validator.
28+
*
29+
* This means that if you have an empty string for a value that is supposed
30+
* to be a number (e.g. `PORT=` in a ".env" file), Zod will incorrectly flag
31+
* it as a type mismatch violation. Additionally, if you have an empty string
32+
* for a value that is supposed to be a string with a default value (e.g.
33+
* `DOMAIN=` in an ".env" file), the default value will never be applied.
34+
*
35+
* In order to solve these issues, we recommend that all new projects
36+
* explicitly specify this option as true.
37+
*/
38+
emptyStringAsUndefined: true,
39+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "T3Env",
3+
"description": "Add type safety to your environment variables",
4+
"phase": "add-on",
5+
"link": "https://github.com/t3-oss/t3-env",
6+
"templates": [
7+
"file-router",
8+
"code-router"
9+
]
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"dependencies": {
3+
"zod": "^3.24.2",
4+
"@t3-oss/env-core": "^0.12.0"
5+
}
6+
}

0 commit comments

Comments
 (0)