mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-01 11:13:40 +03:00
feat(cta): add preset for vue-cli (#1473)
This commit is contained in:
parent
6ec0971e78
commit
1b2bb6adb8
35
tooling/create-tauri-app/bin/create-tauri-app.js
Normal file → Executable file
35
tooling/create-tauri-app/bin/create-tauri-app.js
Normal file → Executable file
@ -197,23 +197,26 @@ async function runInit(argv, config = {}) {
|
||||
}
|
||||
}, []);
|
||||
|
||||
console.log("===== installing any additional needed deps =====");
|
||||
await install({
|
||||
appDir: appDirectory,
|
||||
dependencies: recipe.extraNpmDependencies,
|
||||
devDependencies: ["@tauri-apps/cli", ...recipe.extraNpmDevDependencies],
|
||||
packageManager,
|
||||
});
|
||||
// Vue CLI plugin automatically runs these
|
||||
if (recipe.shortName !== "vuecli") {
|
||||
console.log("===== installing any additional needed deps =====");
|
||||
await install({
|
||||
appDir: appDirectory,
|
||||
dependencies: recipe.extraNpmDependencies,
|
||||
devDependencies: ["@tauri-apps/cli", ...recipe.extraNpmDevDependencies],
|
||||
packageManager,
|
||||
});
|
||||
|
||||
console.log("===== running tauri init =====");
|
||||
const binary = !argv.b ? packageManager : resolve(appDirectory, argv.b);
|
||||
const runTauriArgs =
|
||||
packageManager === "npm" && !argv.b
|
||||
? ["run", "tauri", "--", "init"]
|
||||
: ["tauri", "init"];
|
||||
await shell(binary, [...runTauriArgs, ...initArgs], {
|
||||
cwd: appDirectory,
|
||||
});
|
||||
console.log("===== running tauri init =====");
|
||||
const binary = !argv.b ? packageManager : resolve(appDirectory, argv.b);
|
||||
const runTauriArgs =
|
||||
packageManager === "npm" && !argv.b
|
||||
? ["run", "tauri", "--", "init"]
|
||||
: ["tauri", "init"];
|
||||
await shell(binary, [...runTauriArgs, ...initArgs], {
|
||||
cwd: appDirectory,
|
||||
});
|
||||
}
|
||||
|
||||
if (recipe.postInit) {
|
||||
console.log("===== running final command(s) =====");
|
||||
|
@ -5,6 +5,7 @@
|
||||
import { map, find } from "lodash";
|
||||
import { TauriBuildConfig } from "./types/config";
|
||||
import { reactjs, reactts } from "./recipes/react";
|
||||
import { vuecli } from "./recipes/vue-cli";
|
||||
import { vanillajs } from "./recipes/vanilla";
|
||||
import { vite } from "./recipes/vite";
|
||||
|
||||
@ -44,7 +45,7 @@ export interface Recipe {
|
||||
}) => Promise<void>;
|
||||
}
|
||||
|
||||
export const allRecipes: Recipe[] = [vanillajs, reactjs, reactts, vite];
|
||||
export const allRecipes: Recipe[] = [vanillajs, reactjs, reactts, vite, vuecli];
|
||||
|
||||
export const recipeNames: Array<[string, string]> = map(
|
||||
allRecipes,
|
||||
|
41
tooling/create-tauri-app/src/recipes/vue-cli.ts
Normal file
41
tooling/create-tauri-app/src/recipes/vue-cli.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import { Recipe } from "..";
|
||||
import { join } from "path";
|
||||
//@ts-ignore
|
||||
import { shell } from "../shell";
|
||||
|
||||
const completeLogMsg = `
|
||||
Your installation completed.
|
||||
To start, run yarn tauri:serve
|
||||
`;
|
||||
|
||||
const vuecli: Recipe = {
|
||||
descriptiveName: "Vue CLI",
|
||||
shortName: "vuecli",
|
||||
extraNpmDevDependencies: [],
|
||||
extraNpmDependencies: [],
|
||||
configUpdate: ({ cfg }) => cfg,
|
||||
preInit: async ({ cwd, cfg }) => {
|
||||
// Vue CLI creates the folder for you
|
||||
await shell("npx", ["@vue/cli", "create", `${cfg.appName}`], { cwd });
|
||||
await shell(
|
||||
"npx",
|
||||
[
|
||||
"@vue/cli",
|
||||
"add",
|
||||
"tauri",
|
||||
"--appName",
|
||||
`${cfg.appName}`,
|
||||
"--windowTitle",
|
||||
`${cfg.windowTitle}`,
|
||||
],
|
||||
{
|
||||
cwd: join(cwd, cfg.appName),
|
||||
}
|
||||
);
|
||||
},
|
||||
postInit: async () => {
|
||||
console.log(completeLogMsg);
|
||||
},
|
||||
};
|
||||
|
||||
export { vuecli };
|
Loading…
Reference in New Issue
Block a user