eitri-cli 1.3.0-beta.3 → 1.3.0-beta.5
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
package/src/cmd/create.js
CHANGED
package/src/cmd/start.js
CHANGED
|
@@ -80,7 +80,11 @@ module.exports = async function start(args) {
|
|
|
80
80
|
|
|
81
81
|
const loadedTarget = await workspace.getTarget()
|
|
82
82
|
const platform = loadedTarget.platform
|
|
83
|
-
|
|
83
|
+
const argsWithDeeplinks = {
|
|
84
|
+
...args,
|
|
85
|
+
deepLinks: loadedTarget?.deepLinks || []
|
|
86
|
+
}
|
|
87
|
+
await handleStartServer(argsWithDeeplinks, trackingService, watcher, workspace, target, targetConfig, platform)
|
|
84
88
|
|
|
85
89
|
TrackingEitriAnalytics.sendEvent({
|
|
86
90
|
eventName:"start",
|
|
@@ -24,7 +24,7 @@ async function handleStartServer(args, trackingService, watcher, workspace, fact
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
const starter = factory.create(args, trackingService, watcher, workspace, targetConfig)
|
|
27
|
+
const starter = await factory.create(args, trackingService, watcher, workspace, targetConfig)
|
|
28
28
|
await starter.startServer()
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -3,6 +3,7 @@ const { Ios, Android } = require("uri-scheme");
|
|
|
3
3
|
const readline = require("readline");
|
|
4
4
|
const chalk = require("chalk");
|
|
5
5
|
const os = require("os");
|
|
6
|
+
|
|
6
7
|
function QRCodeStarter(
|
|
7
8
|
args,
|
|
8
9
|
trackingService,
|
|
@@ -56,35 +57,51 @@ function QRCodeStarter(
|
|
|
56
57
|
_QRCodeFactory.generate({ ...this.args, qrCodePath, fullUrl });
|
|
57
58
|
|
|
58
59
|
if (this.args.emulator) {
|
|
59
|
-
tryOpenEmulator(fullUrl, args);
|
|
60
|
+
await tryOpenEmulator(fullUrl, args);
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
listenerKeyPressToOpenEmulator(fullUrl);
|
|
63
|
+
await listenerKeyPressToOpenEmulator(fullUrl, args.deepLinks);
|
|
63
64
|
};
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
function tryOpenEmulator(fullUrl, args) {
|
|
67
|
+
async function tryOpenEmulator(fullUrl, args) {
|
|
67
68
|
const shareId = extractShareId(fullUrl);
|
|
68
|
-
const { emulator } = args;
|
|
69
|
-
if
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
const { emulator, deepLinks } = args;
|
|
70
|
+
if(!deepLinks || deepLinks?.length < 1) {
|
|
71
|
+
console.log("Seu application não contém deep links configurados.")
|
|
72
|
+
return
|
|
73
|
+
};
|
|
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
|
+
})
|
|
75
93
|
}
|
|
76
|
-
)
|
|
77
|
-
}
|
|
78
|
-
return Android.openAsync({ uri: `eitri://workspace/${shareId}` }).catch(
|
|
79
|
-
() => {
|
|
94
|
+
} catch (error) {
|
|
80
95
|
console.error(
|
|
81
|
-
`Houve um erro ao tentar abrir o Eitri-App na plataforma
|
|
96
|
+
`Houve um erro ao tentar abrir o Eitri-App na plataforma ${emulator}`
|
|
82
97
|
);
|
|
83
98
|
}
|
|
84
|
-
|
|
99
|
+
}
|
|
100
|
+
|
|
85
101
|
}
|
|
86
102
|
|
|
87
|
-
function listenerKeyPressToOpenEmulator(url) {
|
|
103
|
+
async function listenerKeyPressToOpenEmulator(url, deepLinks) {
|
|
104
|
+
if(!deepLinks || deepLinks?.length < 1) return;
|
|
88
105
|
const enterText = chalk.blue.bold("Enter");
|
|
89
106
|
console.log("================================================");
|
|
90
107
|
console.log(`\t${chalk.green.bold("Abertura de Eitri-App automática")}`);
|
|
@@ -104,20 +121,16 @@ function listenerKeyPressToOpenEmulator(url) {
|
|
|
104
121
|
console.log("================================================");
|
|
105
122
|
readline.emitKeypressEvents(process.stdin);
|
|
106
123
|
|
|
107
|
-
process.stdin.on("keypress", (chunk, key) => {
|
|
124
|
+
process.stdin.on("keypress", async (chunk, key) => {
|
|
108
125
|
if (key && key.name == "a") {
|
|
109
126
|
const emulator = "android";
|
|
110
127
|
console.log(`Abrindo Eitri-App no ${chalk.blue.bold("Android")}`);
|
|
111
|
-
tryOpenEmulator(url, { emulator });
|
|
128
|
+
await tryOpenEmulator(url, { emulator, deepLinks });
|
|
112
129
|
}
|
|
113
130
|
if (os.platform() === "darwin" && key && key.name == "i") {
|
|
114
131
|
const emulator = "ios";
|
|
115
132
|
console.log(`Abrindo Eitri-App no ${chalk.blue.bold("iOS")}`);
|
|
116
|
-
tryOpenEmulator(url, { emulator });
|
|
117
|
-
}
|
|
118
|
-
if (key && key.name == "q") {
|
|
119
|
-
console.log("Parando execução do Eitri-App");
|
|
120
|
-
process.exit(0);
|
|
133
|
+
await tryOpenEmulator(url, { emulator, deepLinks });
|
|
121
134
|
}
|
|
122
135
|
});
|
|
123
136
|
}
|