eitri-cli 1.3.0-beta.5 → 1.3.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eitri-cli",
3
- "version": "1.3.0-beta.5",
3
+ "version": "1.3.0-beta.6",
4
4
  "description": "Command Line Interface to make \"Eitri-App\" with code and fire.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -61,7 +61,6 @@
61
61
  "tmp": "^0.1.0",
62
62
  "tough-cookie": "^3.0.1",
63
63
  "tough-cookie-file-store": "^2.0.2",
64
- "uri-scheme": "^1.1.0",
65
64
  "uuid": "^7.0.2"
66
65
  },
67
66
  "devDependencies": {
@@ -1,8 +1,9 @@
1
1
  const QRCodeFactory = require("../QRCodeFactory");
2
- const { Ios, Android } = require("uri-scheme");
3
2
  const readline = require("readline");
4
3
  const chalk = require("chalk");
5
4
  const os = require("os");
5
+ const util = require('util')
6
+ const exec = util.promisify(require("child_process").exec)
6
7
 
7
8
  function QRCodeStarter(
8
9
  args,
@@ -71,33 +72,30 @@ async function tryOpenEmulator(fullUrl, args) {
71
72
  console.log("Seu application não contém deep links configurados.")
72
73
  return
73
74
  };
74
-
75
- let opened = false
76
- for await (const deepLink of deepLinks) {
77
- if(opened) return
78
- try {
79
- if (emulator === "ios") {
80
- Ios.openAsync({ uri: `${deepLink}/${shareId}` })
81
- .then(() => {opened = true})
82
- .catch(() => {
83
- opened = false;
84
- console.log(`Houve um erro ao tentar abrir o Eitri-App na plataforma iOS`)
85
- })
86
- } else {
87
- Android.openAsync({ uri: `${deepLink}/${shareId}` })
88
- .then(() => {opened = true})
89
- .catch(() => {
90
- opened = false;
91
- console.log(`Houve um erro ao tentar abrir o Eitri-App na plataforma Android`)
92
- })
93
- }
94
- } catch (error) {
95
- console.error(
96
- `Houve um erro ao tentar abrir o Eitri-App na plataforma ${emulator}`
97
- );
75
+ for (const deepLink of deepLinks) {
76
+ if (emulator === "ios") {
77
+ const cmd = `xcrun simctl openurl booted ${deepLink}/${shareId}`
78
+ const opened = await openDeepLink(cmd)
79
+ if(opened) return;
80
+ } else {
81
+ const cmd = `adb shell am start -a android.intent.action.VIEW -d ${deepLink}/${shareId}`
82
+ const opened = await openDeepLink(cmd)
83
+ if(opened) return;
98
84
  }
99
85
  }
86
+ }
100
87
 
88
+ async function openDeepLink(cmd) {
89
+ try {
90
+ const {stderr} = await exec(cmd)
91
+ if(stderr) {
92
+ return false
93
+ }
94
+ return true
95
+ } catch (error) {
96
+ console.log(`Houve um erro ao tentar abrir o Eitri-App via deep link`)
97
+ return process.exit(1)
98
+ }
101
99
  }
102
100
 
103
101
  async function listenerKeyPressToOpenEmulator(url, deepLinks) {