Files
Pake/bin/builders/common.ts

52 lines
1.1 KiB
TypeScript
Vendored

import { PakeAppOptions } from '@/types.js';
import prompts from 'prompts';
import path from 'path';
import fs from 'fs/promises';
import { npmDirectory } from '@/utils/dir.js';
export async function promptText(message: string, initial?: string) {
const response = await prompts({
type: 'text',
name: 'content',
message,
initial,
});
return response.content;
}
export async function mergeTauriConfig(
url: string,
options: PakeAppOptions,
tauriConf: any
) {
const {
width,
height,
fullscreen,
transparent,
resizable,
identifier,
name,
} = options;
const tauriConfWindowOptions = {
width,
height,
fullscreen,
transparent,
resizable,
};
Object.assign(tauriConf.tauri.windows[0], { url, ...tauriConfWindowOptions });
tauriConf.package.productName = name;
tauriConf.tauri.bundle.identifier = identifier;
tauriConf.tauri.bundle.icon = [options.icon];
const configJsonPath = path.join(npmDirectory, 'src-tauri/tauri.conf.json');
await fs.writeFile(
configJsonPath,
Buffer.from(JSON.stringify(tauriConf), 'utf-8')
);
}