Skip to content

Commit d04f045

Browse files
feat(cli): add env package (#755)
1 parent f91d2cd commit d04f045

File tree

246 files changed

+2676
-2289
lines changed

Some content is hidden

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

246 files changed

+2676
-2289
lines changed

.oxfmtrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
22
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"experimentalSortImports": {
4+
"order": "asc"
5+
},
6+
"experimentalSortPackageJson": true,
37
"ignorePatterns": ["*.hbs", "apps/cli/templates/**"]
48
}

apps/cli/src/constants.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import path from "node:path";
22
import { fileURLToPath } from "node:url";
3+
34
import { getUserPkgManager } from "./utils/get-package-manager";
45

56
const __filename = fileURLToPath(import.meta.url);
@@ -164,11 +165,14 @@ export const dependencyVersionMap = {
164165
"@sveltejs/adapter-cloudflare": "^7.2.4",
165166
"@cloudflare/workers-types": "^4.20251213.0",
166167

167-
alchemy: "^0.81.2",
168+
alchemy: "^0.82.1",
168169

169170
dotenv: "^17.2.2",
170171
tsdown: "^0.16.5",
171172
zod: "^4.1.13",
173+
"@t3-oss/env-core": "^0.13.1",
174+
"@t3-oss/env-nextjs": "^0.13.1",
175+
"@t3-oss/env-nuxt": "^0.13.1",
172176
srvx: "0.8.15",
173177

174178
"@polar-sh/better-auth": "^1.1.3",

apps/cli/src/helpers/addons/addons-setup.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import path from "node:path";
21
import { log } from "@clack/prompts";
32
import fs from "fs-extra";
3+
import path from "node:path";
44
import pc from "picocolors";
5+
56
import type { Frontend, ProjectConfig } from "../../types";
7+
68
import { addPackageDependency } from "../../utils/add-package-deps";
79
import { setupFumadocs } from "./fumadocs-setup";
810
import { setupOxlint } from "./oxlint-setup";
@@ -11,8 +13,8 @@ import { setupStarlight } from "./starlight-setup";
1113
import { setupTauri } from "./tauri-setup";
1214
import { setupTui } from "./tui-setup";
1315
import { setupUltracite } from "./ultracite-setup";
14-
import { setupWxt } from "./wxt-setup";
1516
import { addPwaToViteConfig } from "./vite-pwa-setup";
17+
import { setupWxt } from "./wxt-setup";
1618

1719
export async function setupAddons(config: ProjectConfig, isAddCommand = false) {
1820
const { addons, frontend, projectDir, packageManager } = config;

apps/cli/src/helpers/addons/examples-setup.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import path from "node:path";
21
import fs from "fs-extra";
2+
import path from "node:path";
3+
34
import type { AvailableDependencies } from "../../constants";
45
import type { ProjectConfig } from "../../types";
6+
57
import { addPackageDependency } from "../../utils/add-package-deps";
68

79
export async function setupExamples(config: ProjectConfig) {

apps/cli/src/helpers/addons/fumadocs-setup.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import path from "node:path";
21
import { isCancel, log, select, spinner } from "@clack/prompts";
32
import consola from "consola";
4-
import { execa } from "execa";
3+
import { $ } from "execa";
54
import fs from "fs-extra";
5+
import path from "node:path";
66
import pc from "picocolors";
7+
78
import type { ProjectConfig } from "../../types";
9+
810
import { exitCancelled } from "../../utils/errors";
9-
import { getPackageExecutionCommand } from "../../utils/package-runner";
11+
import { getPackageExecutionArgs } from "../../utils/package-runner";
1012

1113
type FumadocsTemplate =
1214
| "next-mdx"
@@ -64,20 +66,15 @@ export async function setupFumadocs(config: ProjectConfig) {
6466
const templateArg = TEMPLATES[template].value;
6567

6668
const commandWithArgs = `create-fumadocs-app@latest fumadocs --template ${templateArg} --src --pm ${packageManager} --no-git`;
67-
68-
const fumadocsInitCommand = getPackageExecutionCommand(packageManager, commandWithArgs);
69+
const args = getPackageExecutionArgs(packageManager, commandWithArgs);
6970

7071
const appsDir = path.join(projectDir, "apps");
7172
await fs.ensureDir(appsDir);
7273

7374
const s = spinner();
7475
s.start("Running Fumadocs create command...");
7576

76-
await execa(fumadocsInitCommand, {
77-
cwd: appsDir,
78-
env: { CI: "true" },
79-
shell: true,
80-
});
77+
await $({ cwd: appsDir, env: { CI: "true" } })`${args}`;
8178

8279
const fumadocsDir = path.join(projectDir, "apps", "fumadocs");
8380
const packageJsonPath = path.join(fumadocsDir, "package.json");
Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import path from "node:path";
21
import { spinner } from "@clack/prompts";
3-
import { execa } from "execa";
2+
import { $ } from "execa";
43
import fs from "fs-extra";
4+
import path from "node:path";
5+
56
import type { PackageManager } from "../../types";
7+
68
import { addPackageDependency } from "../../utils/add-package-deps";
7-
import { getPackageExecutionCommand } from "../../utils/package-runner";
9+
import { getPackageExecutionArgs } from "../../utils/package-runner";
810

911
export async function setupOxlint(projectDir: string, packageManager: PackageManager) {
1012
await addPackageDependency({
@@ -26,19 +28,11 @@ export async function setupOxlint(projectDir: string, packageManager: PackageMan
2628

2729
const s = spinner();
2830

29-
const oxlintInitCommand = getPackageExecutionCommand(packageManager, "oxlint@latest --init");
31+
const oxlintArgs = getPackageExecutionArgs(packageManager, "oxlint@latest --init");
3032
s.start("Initializing oxlint and oxfmt...");
31-
await execa(oxlintInitCommand, {
32-
cwd: projectDir,
33-
env: { CI: "true" },
34-
shell: true,
35-
});
33+
await $({ cwd: projectDir, env: { CI: "true" } })`${oxlintArgs}`;
3634

37-
const oxfmtInitCommand = getPackageExecutionCommand(packageManager, "oxfmt@latest --init");
38-
await execa(oxfmtInitCommand, {
39-
cwd: projectDir,
40-
env: { CI: "true" },
41-
shell: true,
42-
});
35+
const oxfmtArgs = getPackageExecutionArgs(packageManager, "oxfmt@latest --init");
36+
await $({ cwd: projectDir, env: { CI: "true" } })`${oxfmtArgs}`;
4337
s.stop("oxlint and oxfmt initialized successfully!");
4438
}

apps/cli/src/helpers/addons/ruler-setup.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import path from "node:path";
21
import { autocompleteMultiselect, isCancel, log, spinner } from "@clack/prompts";
3-
import { execa } from "execa";
2+
import { $ } from "execa";
43
import fs from "fs-extra";
4+
import path from "node:path";
55
import pc from "picocolors";
6+
67
import type { ProjectConfig } from "../../types";
8+
79
import { exitCancelled } from "../../utils/errors";
8-
import { getPackageExecutionCommand } from "../../utils/package-runner";
10+
import { getPackageExecutionArgs, getPackageExecutionCommand } from "../../utils/package-runner";
911

1012
export async function setupRuler(config: ProjectConfig) {
1113
const { packageManager, projectDir } = config;
@@ -90,15 +92,11 @@ export async function setupRuler(config: ProjectConfig) {
9092
s.start("Applying rules with Ruler...");
9193

9294
try {
93-
const rulerApplyCmd = getPackageExecutionCommand(
95+
const rulerApplyArgs = getPackageExecutionArgs(
9496
packageManager,
9597
`@intellectronica/ruler@latest apply --agents ${selectedEditors.join(",")} --local-only`,
9698
);
97-
await execa(rulerApplyCmd, {
98-
cwd: projectDir,
99-
env: { CI: "true" },
100-
shell: true,
101-
});
99+
await $({ cwd: projectDir, env: { CI: "true" } })`${rulerApplyArgs}`;
102100

103101
s.stop("Applied rules with Ruler");
104102
} catch {

apps/cli/src/helpers/addons/starlight-setup.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import path from "node:path";
21
import { spinner } from "@clack/prompts";
32
import consola from "consola";
4-
import { execa } from "execa";
3+
import { $ } from "execa";
54
import fs from "fs-extra";
5+
import path from "node:path";
66
import pc from "picocolors";
7+
78
import type { ProjectConfig } from "../../types";
8-
import { getPackageExecutionCommand } from "../../utils/package-runner";
9+
10+
import { getPackageExecutionArgs } from "../../utils/package-runner";
911

1012
export async function setupStarlight(config: ProjectConfig) {
1113
const { packageManager, projectDir } = config;
@@ -27,19 +29,12 @@ export async function setupStarlight(config: ProjectConfig) {
2729
const starlightArgsString = starlightArgs.join(" ");
2830

2931
const commandWithArgs = `create-astro@latest ${starlightArgsString}`;
30-
31-
const starlightInitCommand = getPackageExecutionCommand(packageManager, commandWithArgs);
32+
const args = getPackageExecutionArgs(packageManager, commandWithArgs);
3233

3334
const appsDir = path.join(projectDir, "apps");
3435
await fs.ensureDir(appsDir);
3536

36-
await execa(starlightInitCommand, {
37-
cwd: appsDir,
38-
env: {
39-
CI: "true",
40-
},
41-
shell: true,
42-
});
37+
await $({ cwd: appsDir, env: { CI: "true" } })`${args}`;
4338

4439
s.stop("Starlight docs setup successfully!");
4540
} catch (error) {

apps/cli/src/helpers/addons/tauri-setup.ts

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import path from "node:path";
21
import { spinner } from "@clack/prompts";
32
import { consola } from "consola";
4-
import { execa } from "execa";
3+
import { $ } from "execa";
54
import fs from "fs-extra";
5+
import path from "node:path";
66
import pc from "picocolors";
7+
78
import type { ProjectConfig } from "../../types";
9+
810
import { addPackageDependency } from "../../utils/add-package-deps";
9-
import { getPackageExecutionCommand } from "../../utils/package-runner";
11+
import { getPackageRunnerPrefix } from "../../utils/package-runner";
1012

1113
export async function setupTauri(config: ProjectConfig) {
1214
const { packageManager, frontend, projectDir } = config;
@@ -64,27 +66,18 @@ export async function setupTauri(config: ProjectConfig) {
6466
: "../dist";
6567

6668
const tauriArgs = [
69+
"@tauri-apps/cli@latest",
6770
"init",
6871
`--app-name=${path.basename(projectDir)}`,
6972
`--window-title=${path.basename(projectDir)}`,
7073
`--frontend-dist=${frontendDist}`,
7174
`--dev-url=${devUrl}`,
72-
`--before-dev-command="${packageManager} run dev"`,
73-
`--before-build-command="${packageManager} run build"`,
75+
`--before-dev-command=${packageManager} run dev`,
76+
`--before-build-command=${packageManager} run build`,
7477
];
75-
const tauriArgsString = tauriArgs.join(" ");
78+
const prefix = getPackageRunnerPrefix(packageManager);
7679

77-
const commandWithArgs = `@tauri-apps/cli@latest ${tauriArgsString}`;
78-
79-
const tauriInitCommand = getPackageExecutionCommand(packageManager, commandWithArgs);
80-
81-
await execa(tauriInitCommand, {
82-
cwd: clientPackageDir,
83-
env: {
84-
CI: "true",
85-
},
86-
shell: true,
87-
});
80+
await $({ cwd: clientPackageDir, env: { CI: "true" } })`${[...prefix, ...tauriArgs]}`;
8881

8982
s.stop("Tauri desktop app support configured successfully!");
9083
} catch (error) {

apps/cli/src/helpers/addons/tui-setup.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import path from "node:path";
21
import { isCancel, log, select, spinner } from "@clack/prompts";
3-
import { execa } from "execa";
2+
import { $ } from "execa";
43
import fs from "fs-extra";
4+
import path from "node:path";
55
import pc from "picocolors";
6+
67
import type { ProjectConfig } from "../../types";
8+
79
import { exitCancelled } from "../../utils/errors";
8-
import { getPackageExecutionCommand } from "../../utils/package-runner";
10+
import { getPackageExecutionArgs } from "../../utils/package-runner";
911

1012
type TuiTemplate = "core" | "react" | "solid";
1113

@@ -43,20 +45,15 @@ export async function setupTui(config: ProjectConfig) {
4345
if (isCancel(template)) return exitCancelled("Operation cancelled");
4446

4547
const commandWithArgs = `create-tui@latest --template ${template} --no-git --no-install tui`;
46-
47-
const tuiInitCommand = getPackageExecutionCommand(packageManager, commandWithArgs);
48+
const args = getPackageExecutionArgs(packageManager, commandWithArgs);
4849

4950
const appsDir = path.join(projectDir, "apps");
5051
await fs.ensureDir(appsDir);
5152

5253
const s = spinner();
5354
s.start("Running OpenTUI create command...");
5455

55-
await execa(tuiInitCommand, {
56-
cwd: appsDir,
57-
env: { CI: "true" },
58-
shell: true,
59-
});
56+
await $({ cwd: appsDir, env: { CI: "true" } })`${args}`;
6057

6158
s.stop("OpenTUI setup complete!");
6259
} catch (error) {

0 commit comments

Comments
 (0)