Skip to content

Commit

Permalink
feat: use TAURI_PATH_DEPTH env if it exists
Browse files Browse the repository at this point in the history
update to @tauri-appa/cli@1.0.0-rc.4
  • Loading branch information
amrbashir committed Feb 14, 2022
1 parent a724da4 commit b5224fb
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 50 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
"vite": "^2.0.0"
},
"devDependencies": {
"@tauri-apps/cli": "1.0.0-rc.2",
"@tauri-apps/cli": "1.0.0-rc.4",
"@types/node": "17.0.17",
"conventional-changelog-cli": "2.2.2",
"prettier": "2.5.1",
"taze": "0.4.6",
"tsup": "5.11.13",
"typescript": "4.5.5",
"vite": "2.8.1"
"vite": "2.8.2"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
Expand Down
73 changes: 33 additions & 40 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { resolveConfig, build as viteBuild } from "vite";
import { getTauriConfPath } from "./utils";
import { logger } from "./logger";
import { relative, dirname } from "node:path";
import TauriCli from "@tauri-apps/cli";
import { init } from "./init";
import TauriCli from "@tauri-apps/cli";

export async function build(args?: string[]) {
let tauriConfPath = getTauriConfPath();
Expand All @@ -17,7 +17,7 @@ export async function build(args?: string[]) {
logger.info(`Vite build finished.`);

logger.info(`Building Tauri app...`);
TauriCli.run(
await TauriCli.run(
[
"build",
"--config",
Expand All @@ -27,7 +27,9 @@ export async function build(args?: string[]) {
// at this point, `tauriConfPath` can't be null,
// because we made sure to initialize tauri if it weren't and got the new path.
dirname(tauriConfPath as string),
(await resolveConfig({}, "build", "production")).build.outDir
(
await resolveConfig({}, "build", "production")
).build.outDir
),
},
}),
Expand Down
2 changes: 1 addition & 1 deletion src/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function dev(args?: string[]) {
logger.info("Vite dev server started.");

logger.info("Starting Tauri...");
TauriCli.run(
await TauriCli.run(
[
"dev",
"--config",
Expand Down
4 changes: 2 additions & 2 deletions src/init.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import TauriCli from "@tauri-apps/cli";
import { logger } from "./logger";
import { getPackageJson } from "./utils";
import enquirer from "enquirer";
import TauriCli from "@tauri-apps/cli/main";

export async function init(args?: string[], promptUser = false) {
if (promptUser) {
Expand All @@ -17,7 +17,7 @@ export async function init(args?: string[], promptUser = false) {

logger.info("Initializing Tauri...");
const pkgName = getPackageJson().name;
TauriCli.run(
await TauriCli.run(
[
"init",
"--app-name",
Expand Down
5 changes: 4 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import { readFileSync } from "node:fs";
import fg from "fast-glob";

export function getTauriConfPath(): string | null {
const tauriDepthEnv = process.env.TAURI_PATH_DEPTH;
const deep = tauriDepthEnv ? parseInt(tauriDepthEnv) : 3;

return fg.sync("**/tauri.conf.(json|json5)", {
absolute: true,
unique: true,
ignore: ["node_modules/**", "target/**"],
deep: 5,
deep,
})[0];
}

Expand Down
2 changes: 1 addition & 1 deletion src/vite-tauri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function run() {
await build(args);
break;
default:
TauriCli.run([cmd ?? "help", ...args, "vite-tauri"]);
await TauriCli.run([cmd ?? "help", ...args, "vite-tauri"], "vite-tauri");
}
}

Expand Down

0 comments on commit b5224fb

Please sign in to comment.