Skip to content

Commit

Permalink
feat(cli): prevent default bundle identifier from building, closes #4041
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored May 4, 2022
1 parent 0180dcc commit 95726eb
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changes/validate-bundle-identifier.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"cli.rs": patch
"cli.js": patch
---

Prevent building when the bundle identifier is the default `com.tauri.dev`.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/isolation/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"bundle": {
"active": true,
"targets": "all",
"identifier": "com.tauri.isolation",
"identifier": "com.tauri.dev",
"icon": [
"../.icons/32x32.png",
"../.icons/128x128.png",
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"bundle": {
"active": true,
"targets": "all",
"identifier": "com.tauri.dev",
"identifier": "com.tauri.resources",
"icon": [
"../../.icons/32x32.png",
"../../.icons/128x128.png",
Expand Down
2 changes: 1 addition & 1 deletion examples/sidecar/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"bundle": {
"active": true,
"targets": "all",
"identifier": "com.tauri.dev",
"identifier": "com.tauri.sidecar",
"icon": [
"../../.icons/32x32.png",
"../../.icons/128x128.png",
Expand Down
2 changes: 1 addition & 1 deletion examples/updater/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"bundle": {
"active": true,
"targets": "all",
"identifier": "com.tauri.dev",
"identifier": "com.tauri.updater",
"icon": [
"../../.icons/32x32.png",
"../../.icons/128x128.png",
Expand Down
4 changes: 4 additions & 0 deletions tooling/cli/node/test/jest/__tests__/template.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions tooling/cli/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 95726eb

Please sign in to comment.