vibeeditor-render 0.3.2 → 0.3.3

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.
@@ -182,6 +182,35 @@ async function versaoNova() {
182
182
  return null;
183
183
  }
184
184
 
185
+ /**
186
+ * Atualização ao abrir: se saiu versão nova no npm, troca por ela na hora (npx com o número exato, então a cópia
187
+ * guardada do npx não segura a antiga) e esta fica só esperando a nova fechar. Não roda em desenvolvimento (com o
188
+ * código-fonte do host ao lado) nem duas vezes seguidas (VIBE_RENDER_ATUALIZADO), e nunca trava a abertura:
189
+ * sem internet ou com o npm fora, segue na versão atual.
190
+ */
191
+ async function atualizarSeTiver(argv) {
192
+ if (process.env.VIBE_RENDER_ATUALIZADO || process.env.VIBE_RENDER_SEM_ATUALIZAR) return false;
193
+ if (fs.existsSync(path.join(RAIZ, "host", "build.mjs"))) return false;
194
+ const nova = await versaoNova();
195
+ if (!nova) return false;
196
+ dizer(`${azul("›")} Saiu a versão ${negrito(nova)} (esta é a ${VERSAO}). Atualizando e abrindo a nova…`);
197
+ // no Windows o npx é um .cmd e precisa do shell: argumento com espaço (--pasta "C:\Meus Vídeos") vai entre aspas
198
+ const args = process.platform === "win32" ? argv.map((a) => (/[\s"]/.test(a) ? `"${a.replace(/"/g, '\\"')}"` : a)) : argv;
199
+ const filho = spawn("npx", ["-y", `${PACOTE.name}@${nova}`, ...args], {
200
+ stdio: "inherit", shell: process.platform === "win32", env: {...process.env, VIBE_RENDER_ATUALIZADO: "1"},
201
+ });
202
+ // o Ctrl+C chega nos dois: quem cuida é a versão nova; esta só repassa o código de saída
203
+ process.on("SIGINT", () => {});
204
+ await new Promise((ok) => {
205
+ filho.on("error", (e) => {
206
+ dizer(`${ambar("!")} Não consegui atualizar (${e.message}). Sigo na ${VERSAO}.`);
207
+ ok(false);
208
+ });
209
+ filho.on("exit", (code) => process.exit(code == null ? 0 : code));
210
+ });
211
+ return false;
212
+ }
213
+
185
214
  /** "1.10.0" é mais nova que "1.9.3"? (só números; pré-lançamentos não entram) */
186
215
  function maisNova(a, b) {
187
216
  const x = String(a).split(".").map(Number), y = String(b).split(".").map(Number);
@@ -255,7 +284,8 @@ async function principal() {
255
284
  }
256
285
 
257
286
  dizer(`\n${negrito(azul("▶ Vibe Render"))} ${cinza(`v${VERSAO}`)} ${cinza("· exporta os vídeos do Editor IA neste computador")}\n`);
258
- versaoNova().then((v) => v && dizer(`${ambar("!")} Saiu a versão ${v}. Feche e abra de novo com ${azul("npx vibeeditor-render@latest")}.`));
287
+ // versão nova no npm: abre direto nela (esta só espera); sem internet, segue nesta
288
+ await atualizarSeTiver(process.argv.slice(2));
259
289
 
260
290
  const {PORTAS} = require("../core/config");
261
291
  const outra = await jaAberto(PORTAS);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibeeditor-render",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Vibe Render: exporta os vídeos do Editor IA (vibeeditor.com.br) no seu computador, com Remotion + Chrome Headless Shell.",
5
5
  "keywords": [
6
6
  "vibeeditor",