Ver Fonte

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

Lucas Fernandes Nogueira há 3 anos atrás
pai
commit
95726ebb61

+ 6 - 0
.changes/validate-bundle-identifier.md

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

+ 1 - 2
Cargo.toml

@@ -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

+ 1 - 1
examples/isolation/tauri.conf.json

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

+ 1 - 1
examples/resources/src-tauri/tauri.conf.json

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

+ 1 - 1
examples/sidecar/src-tauri/tauri.conf.json

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

+ 1 - 1
examples/updater/src-tauri/tauri.conf.json

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

+ 4 - 0
tooling/cli/node/test/jest/__tests__/template.spec.js

@@ -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

+ 5 - 0
tooling/cli/src/build.rs

@@ -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));