mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-11-28 20:48:52 +03:00
This commit is contained in:
parent
938fb624f5
commit
f708ff824e
5
.changes/fix-cta-set-script.md
Normal file
5
.changes/fix-cta-set-script.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"create-tauri-app": patch
|
||||
---
|
||||
|
||||
Manually set `tauri` script instead of using `npm set-script` for compatabilty with older npm versions
|
@ -14,6 +14,7 @@ const {
|
||||
install,
|
||||
checkPackageManager,
|
||||
shell,
|
||||
addTauriScript,
|
||||
} = require("../dist/");
|
||||
|
||||
/**
|
||||
@ -208,9 +209,8 @@ async function runInit(argv, config = {}) {
|
||||
});
|
||||
|
||||
console.log("===== running tauri init =====");
|
||||
await shell("npm", ["set-script", "tauri", "tauri"], {
|
||||
cwd: appDirectory,
|
||||
});
|
||||
addTauriScript(appDirectory);
|
||||
|
||||
const binary = !argv.b ? packageManager : resolve(appDirectory, argv.b);
|
||||
const runTauriArgs =
|
||||
packageManager === "npm" && !argv.b
|
||||
|
26
tooling/create-tauri-app/src/helpers/add-tauri-script.ts
Normal file
26
tooling/create-tauri-app/src/helpers/add-tauri-script.ts
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { readFileSync, writeFileSync } from "fs";
|
||||
import { join } from "path";
|
||||
|
||||
export async function addTauriScript(appDirectory: string) {
|
||||
const pkgPath = join(appDirectory, "package.json");
|
||||
const pkgString = readFileSync(pkgPath, "utf8");
|
||||
const pkg = JSON.parse(pkgString) as {
|
||||
scripts: {
|
||||
tauri: string;
|
||||
};
|
||||
};
|
||||
|
||||
let outputPkg = {
|
||||
...pkg,
|
||||
scripts: {
|
||||
...pkg.scripts,
|
||||
tauri: "tauri",
|
||||
},
|
||||
};
|
||||
|
||||
writeFileSync(pkgPath, JSON.stringify(outputPkg, undefined, 2));
|
||||
}
|
@ -10,6 +10,7 @@ import { vite } from "./recipes/vite";
|
||||
|
||||
export { shell } from "./shell";
|
||||
export { install, checkPackageManager } from "./dependency-manager";
|
||||
export { addTauriScript } from "./helpers/add-tauri-script";
|
||||
import { PackageManager } from "./dependency-manager";
|
||||
|
||||
export interface Recipe {
|
||||
@ -46,12 +47,17 @@ export interface Recipe {
|
||||
|
||||
export const allRecipes: Recipe[] = [vanillajs, reactjs, reactts, vite, vuecli];
|
||||
|
||||
export const recipeNames: Array<[string, string]> = allRecipes.map(r => [r.shortName, r.descriptiveName]);
|
||||
export const recipeNames: Array<[string, string]> = allRecipes.map((r) => [
|
||||
r.shortName,
|
||||
r.descriptiveName,
|
||||
]);
|
||||
|
||||
export const recipeByShortName = (name: string) => allRecipes.find(r => r.shortName === name);
|
||||
export const recipeByShortName = (name: string) =>
|
||||
allRecipes.find((r) => r.shortName === name);
|
||||
|
||||
export const recipeByDescriptiveName = (name: string) => allRecipes.find(r => r.descriptiveName === name);
|
||||
export const recipeByDescriptiveName = (name: string) =>
|
||||
allRecipes.find((r) => r.descriptiveName === name);
|
||||
|
||||
export const recipeShortNames = allRecipes.map(r => r.shortName);
|
||||
export const recipeShortNames = allRecipes.map((r) => r.shortName);
|
||||
|
||||
export const recipeDescriptiveNames = allRecipes.map(r => r.descriptiveName);
|
||||
export const recipeDescriptiveNames = allRecipes.map((r) => r.descriptiveName);
|
||||
|
Loading…
Reference in New Issue
Block a user