✨ First-time installation prompt
This commit is contained in:
19
bin/builders/BaseBuilder.ts
vendored
19
bin/builders/BaseBuilder.ts
vendored
@@ -22,7 +22,11 @@ export default abstract class BaseBuilder {
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
if (!IS_MAC) {
|
||||
const tauriSrcPath = path.join(npmDirectory, 'src-tauri');
|
||||
const tauriTargetPath = path.join(tauriSrcPath, 'target');
|
||||
const tauriTargetPathExists = await fsExtra.pathExists(tauriTargetPath);
|
||||
|
||||
if (!IS_MAC && !tauriTargetPathExists) {
|
||||
logger.info('✺ The first use requires installing system dependencies.');
|
||||
logger.info('✺ See more in https://tauri.app/v1/guides/getting-started/prerequisites.');
|
||||
}
|
||||
@@ -44,20 +48,25 @@ export default abstract class BaseBuilder {
|
||||
|
||||
const isChina = await isChinaDomain('www.npmjs.com');
|
||||
const spinner = getSpinner('Installing package...');
|
||||
const rustProjectDir = path.join(tauriSrcPath, '.cargo');
|
||||
const projectConf = path.join(rustProjectDir, 'config');
|
||||
await fsExtra.ensureDir(rustProjectDir);
|
||||
|
||||
if (isChina) {
|
||||
logger.info('✺ Located in China, using npm/rsProxy CN mirror.');
|
||||
const rustProjectDir = path.join(npmDirectory, 'src-tauri', '.cargo');
|
||||
await fsExtra.ensureDir(rustProjectDir);
|
||||
const projectCnConf = path.join(npmDirectory, 'src-tauri', 'rust_proxy.toml');
|
||||
const projectConf = path.join(rustProjectDir, 'config');
|
||||
const projectCnConf = path.join(tauriSrcPath, 'rust_proxy.toml');
|
||||
await fsExtra.copy(projectCnConf, projectConf);
|
||||
await shellExec(`cd "${npmDirectory}" && npm install --registry=https://registry.npmmirror.com`);
|
||||
} else {
|
||||
await shellExec(`cd "${npmDirectory}" && npm install`);
|
||||
}
|
||||
spinner.succeed(chalk.green('Package installed!'));
|
||||
if (!tauriTargetPathExists) {
|
||||
logger.warn('✼ The first packaging may be slow, please be patient and wait, it will be faster afterwards.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async build(url: string) {
|
||||
await this.buildAndCopy(url, this.options.targets);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user