feat(cta): add preset for vue-cli (#1473)

This commit is contained in:
Noah Klayman 2021-04-13 17:53:40 -07:00 committed by GitHub
parent 6ec0971e78
commit 1b2bb6adb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 17 deletions

35
tooling/create-tauri-app/bin/create-tauri-app.js Normal file → Executable file
View 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) =====");

View File

@ -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,

View 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 };