feat(cli): prevent default bundle identifier from building, closes #4041 (#4042)

This commit is contained in:
Lucas Fernandes Nogueira 2022-05-04 06:48:38 -07:00 committed by GitHub
parent 0180dcc812
commit 95726ebb61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 20 additions and 6 deletions

View File

@ -0,0 +1,6 @@
---
"cli.rs": patch
"cli.js": patch
---
Prevent building when the bundle identifier is the default `com.tauri.dev`.

View File

@ -19,8 +19,7 @@ exclude = [
"examples/api/src-tauri",
"examples/updater/src-tauri",
"examples/resources/src-tauri",
"examples/sidecar/src-tauri",
"examples/isolation/src-tauri"
"examples/sidecar/src-tauri"
]
# default to small, optimized workspace release binaries

View File

@ -21,7 +21,7 @@
"bundle": {
"active": true,
"targets": "all",
"identifier": "com.tauri.isolation",
"identifier": "com.tauri.dev",
"icon": [
"../.icons/32x32.png",
"../.icons/128x128.png",

View File

@ -11,7 +11,7 @@
"bundle": {
"active": true,
"targets": "all",
"identifier": "com.tauri.dev",
"identifier": "com.tauri.resources",
"icon": [
"../../.icons/32x32.png",
"../../.icons/128x128.png",

View File

@ -11,7 +11,7 @@
"bundle": {
"active": true,
"targets": "all",
"identifier": "com.tauri.dev",
"identifier": "com.tauri.sidecar",
"icon": [
"../../.icons/32x32.png",
"../../.icons/128x128.png",

View File

@ -10,7 +10,7 @@
"bundle": {
"active": true,
"targets": "all",
"identifier": "com.tauri.dev",
"identifier": "com.tauri.updater",
"icon": [
"../../.icons/32x32.png",
"../../.icons/128x128.png",

View File

@ -39,6 +39,10 @@ describe('[CLI] cli.js template', () => {
const manifestFile = readFileSync(manifestPath).toString()
writeFileSync(manifestPath, `workspace = { }\n${manifestFile}`)
const configPath = resolve(tauriFixturePath, 'tauri.conf.json')
const config = readFileSync(configPath).toString()
writeFileSync(configPath, config.replace('com.tauri.dev', 'com.tauri.test'))
await cli.run(['build', '--verbose']).catch(err => {
console.error(err)
throw err

View File

@ -70,6 +70,11 @@ pub fn command(options: Options) -> Result<()> {
let config_guard = config.lock().unwrap();
let config_ = config_guard.as_ref().unwrap();
if config_.tauri.bundle.identifier == "com.tauri.dev" {
logger.error("You must change the bundle identifier in `tauri.conf.json > tauri > bundle > identifier`. The default value `com.tauri.dev` is not allowed as it must be unique across applications.");
std::process::exit(1);
}
if let Some(before_build) = &config_.build.before_build_command {
if !before_build.is_empty() {
logger.log(format!("Running `{}`", before_build));