UNPKG

15.3 kBMarkdownView Raw
1**In English**
2# UpdateCheckerNotifier
3[![downloads](https://badgen.net/npm/dt/electron-update-checker-notifier)](https://npm-stat.com/charts.html?package=electron-update-checker-notifier&from=2023-01-01)
4[![npm-version](https://badgen.net/npm/v/electron-update-checker-notifier?icon=npm&label)](https://www.npmjs.com/package/electron-update-checker-notifier)
5[![github-tag](https://badgen.net/github/tag/FabioLucenaRibas/electron-update-checker-notifier)](https://github.com/FabioLucenaRibas/electron-update-checker-notifier/tags)
6[![license](https://badgen.net/github/license/FabioLucenaRibas/electron-update-checker-notifier)](LICENSE.txt)
7[![install size](https://packagephobia.com/badge?p=electron-update-checker-notifier)](https://packagephobia.com/result?p=electron-update-checker-notifier)
8[![build](https://github.com/FabioLucenaRibas/electron-update-checker-notifier/workflows/build/badge.svg)](https://github.com/FabioLucenaRibas/electron-update-checker-notifier/actions)
9![ts](https://badgen.net/badge/Built%20With/TypeScript/blue)
10
11It's a project that seeks new updates for the app from the GitHub repository and informs the user about these updates. The goal is to keep the user informed about the latest versions of their software and allow for simple and fast updating.
12
13# Functionalities
14* Checks the latest version of the app in the Github repository.
15* Displays a notification to the user when a new update is available.
16* Event management for customizing update checks and notification display.
17* Ability to choose the language used for log messages and notifications.
18
19# Language setting
20You can choose the language that will be used for log messages and notifications by adding the following option to the updateNotification method call:
21
22```javascript
23import { updateCheckerNotifier, Language } from 'electron-update-checker-notifier';
24
25updateCheckerNotifier.language = Language.PT_BR;
26
27updateCheckerNotifier.updateNotification();
28```
29```javascript
30import { UpdateCheckerNotifier, Language } from 'electron-update-checker-notifier';
31
32const notifier = new UpdateCheckerNotifier();
33
34notifier.updateNotification({
35 language: Language.PT_BR,
36});
37```
38
39The currently supported languages are:
40* en-US (English - United States)
41* pt-BR (Portuguese - Brazil)
42
43# Installation
44
45```bash
46npm install electron-update-checker-notifier
47```
48
49# Use
50To use UpdateCheckerNotifier, you need to import it and create an instance. Then, you can call the updateNotification() method to check if there are updates available for your app.
51
52```javascript
53import { UpdateCheckerNotifier } from 'electron-update-checker-notifier';
54
55const notifier = new UpdateCheckerNotifier();
56notifier.updateNotification();
57```
58
59# Options
60You can pass options to the updateNotification() method to customize its behavior.
61
62**repository** (Optional): Your app repository on GitHub. If not specified, it will use the repository defined in your app's package.json file.
63
64**token** (Optional): The access token to the GitHub API.
65
66**debug** (Optional, default: false): Allows checking for updates during development.
67
68**enablePreRelease** (Optional, default: false): Notify pre-release version.
69
70**enableNewVersionAvailableDialog** (Optional, default: true): Notifies when there are new versions available, otherwise remains silent.
71
72**enableLatestVersionDialog** (Optional, default: false): Notifies when you are already running the latest version.
73
74**enableErrorDialog** (Optional, default: false): Notifies when an error occurs.
75
76**language** (Optional, default: Language.EN): The language used for log messages and notifications.
77
78**logger** (Optional): The logger. You can pass a logger such as electron-log, winston, or other with the following interfaces: { **info()**, **warn()**, **error()** }. Set to null if you wish to disable logging.
79
80# Events
81UpdateCheckerNotifier emits several events that you can listen to for information about the update process.
82
83**checking-for-update**: Emitted when the update check process begins.
84
85**update-available**: Emitted when there is a new version available for download.
86
87**update-not-available**: Emitted when there are no new updates available.
88
89**this-is-last-update**: Emitted when the update check determines that the current version of your app is the last available version.
90
91**error**: Emitted when an error occurs during the update check process.
92
93You can listen to these events as follows:
94```javascript
95notifier.on('checking-for-update', () => {
96 console.log('Checking for updates...');
97});
98
99notifier.on('update-available', (info: UpdateInfo) => {
100 console.log(`A new version (${info.version}) is available for download!`);
101});
102
103notifier.on('update-not-available', (info: UpdateInfo) => {
104 console.log('There are no new updates available.');
105});
106
107notifier.on('this-is-last-update', (info: UpdateInfo) => {
108 console.log('This is the latest update available.: ', info);
109});
110
111notifier.on('error', (error: Error) => {
112 console.error(`An error has occurred: ${error}`);
113});
114```
115
116The UpdateInfo object is passed as an argument to the event handler and contains information about the current and latest available version of your application.
117
118# Example
119Here is a full example of how to use UpdateCheckerNotifier in an Electron application:
120```javascript
121import { updateCheckerNotifier, Language } from 'electron-update-checker-notifier';
122
123updateCheckerNotifier.repository = 'user/repo'
124updateCheckerNotifier.token = 'my-github-token'
125updateCheckerNotifier.debug = true
126updateCheckerNotifier.enablePreRelease = true
127updateCheckerNotifier.enableNewVersionAvailableDialog = true
128updateCheckerNotifier.enableLatestVersionDialog = true
129updateCheckerNotifier.enableErrorDialog = true
130updateCheckerNotifier.language = Language.PT_BR
131updateCheckerNotifier.logger = log
132
133updateCheckerNotifier.updateNotification();
134```
135
136```javascript
137import { UpdateCheckerNotifier, Language } from 'electron-update-checker-notifier';
138
139const notifier = new UpdateCheckerNotifier();
140
141notifier.updateNotification({
142 repository: 'user/repo',
143 token: 'my-github-token',
144 debug: true,
145 enablePreRelease = true,
146 enableNewVersionAvailableDialog: true,
147 enableLatestVersionDialog: true,
148 enableErrorDialog: true,
149 language: Language.PT_BR,
150 logger: log,
151});
152
153notifier.on('update-available', (info: UpdateInfo) => {
154 console.log(`A new version (${info.version}) is available for download!`);
155});
156
157notifier.on('error', (error: Error) => {
158 console.error(`An error has occurred: ${error}`);
159});
160```
161
162# Contribution
163If you want to contribute to this project, follow these steps:
164
1651. Fork the repository
1662. Create your branch
1673. Commit your changes
1684. Push on the branch
1695. Create a pull request
170
171# Acknowledgments
172I would like to thank the following developers for the work done on the project [electron-update-notifier](https://github.com/ankurk91/electron-update-notifier)
173
174* [ankurk91](https://github.com/ankurk91)
175* [pd4d10](https://github.com/pd4d10)
176
177Thank you for your dedication and contribution to the community.
178
179# License
180This project is licensed under the MIT license. See the [LICENSE](https://github.com/FabioLucenaRibas/electron-update-checker-notifier/blob/main/LICENSE) file for more details.
181
182
183**In Portuguese**
184# UpdateCheckerNotifier
185[![downloads](https://badgen.net/npm/dt/electron-update-checker-notifier)](https://npm-stat.com/charts.html?package=electron-update-checker-notifier&from=2023-01-01)
186[![npm-version](https://badgen.net/npm/v/electron-update-checker-notifier?icon=npm&label)](https://www.npmjs.com/package/electron-update-checker-notifier)
187[![github-tag](https://badgen.net/github/tag/FabioLucenaRibas/electron-update-checker-notifier)](https://github.com/FabioLucenaRibas/electron-update-checker-notifier/tags)
188[![license](https://badgen.net/github/license/FabioLucenaRibas/electron-update-checker-notifier)](LICENSE.txt)
189[![install size](https://packagephobia.com/badge?p=electron-update-checker-notifier)](https://packagephobia.com/result?p=electron-update-checker-notifier)
190[![build](https://github.com/FabioLucenaRibas/electron-update-checker-notifier/workflows/build/badge.svg)](https://github.com/FabioLucenaRibas/electron-update-checker-notifier/actions)
191![ts](https://badgen.net/badge/Built%20With/TypeScript/blue)
192
193É um projeto que busca novas atualizações do aplicativo a partir do repositório do GitHub e notifica o usuário sobre essas atualizações. O objetivo é manter o usuário informado sobre as versões mais recentes de seu software e possibilitar a atualização de maneira simples e rápida.
194
195# Funcionalidades
196* Verifica a versão mais recente do aplicativo no repositório do Github.
197* Exibi uma notificação para o usuário quando uma nova atualização estiver disponível.
198* Gerenciamento de eventos para personalização da verificação de atualizações e exibição de notificações.
199* Possibilidade de escolher o idioma usado para as mensagens de log e notificações.
200
201# Configuração de idioma
202Você pode escolher o idioma que será utilizado usado para as mensagens de log e notificações adicionando a seguinte opção à chamada do método updateNotification:
203
204```javascript
205import { updateCheckerNotifier, Language } from 'electron-update-checker-notifier';
206
207updateCheckerNotifier.language = Language.PT_BR;
208
209updateCheckerNotifier.updateNotification();
210```
211```javascript
212import { UpdateCheckerNotifier, Language } from 'electron-update-checker-notifier';
213
214const notifier = new UpdateCheckerNotifier();
215
216notifier.updateNotification({
217 language: Language.PT_BR,
218});
219```
220
221Os idiomas atualmente suportados são:
222
223* en-US (Inglês - Estados Unidos)
224* pt-BR (Português - Brasil)
225
226
227# Instalação
228
229```bash
230npm install electron-update-checker-notifier
231```
232# Uso
233
234Para usar UpdateCheckerNotifier, você precisa importá-lo e criar uma instância. Em seguida, você pode chamar o método updateNotification() para verificar se há atualizações disponíveis para o seu aplicativo.
235
236
237```javascript
238import { UpdateCheckerNotifier } from 'electron-update-checker-notifier';
239
240const notifier = new UpdateCheckerNotifier();
241notifier.updateNotification();
242```
243
244# Opções
245Você pode passar opções para o método updateNotification() para personalizar o comportamento.
246
247**repository** (opcional): O repositório do seu aplicativo no GitHub. Se não for especificado, ele usará o repositório definido no arquivo package.json do seu aplicativo.
248
249**token** (opcional): O token de acesso à API do GitHub.
250
251**debug** (opcional, padrão: false): Permite verificar atualizações durante o desenvolvimento.
252
253**enablePreRelease** (opcional, padrão: false): Notifica versão de pré-lançamento
254
255**enableNewVersionAvailableDialog** (opcional, padrão: true): Notifica quando houver novas versões disponíveis, caso contrário, permanece silencioso.
256
257**enableLatestVersionDialog** (opcional, padrão: false): Notifica quando você já está executando a versão mais recente.
258
259**enableErrorDialog** (opcional, padrão: false): Notifica quando um erro acontecer
260
261**language** (opcional, padrão: Language.EN): O idioma usado para as mensagens de log e notificações.
262
263**logger** (opcional): O registrador. Você pode passar um registrador como electron-log, winston ou outro com as seguintes interfaces: { **info()**, **warn()**, **error()** }.
264Defina como null se você desejar desativar o recurso de log.
265
266# Eventos
267UpdateCheckerNotifier emite vários eventos que você pode ouvir para obter informações sobre o processo de atualização.
268
269**checking-for-update**: Emitido quando o processo de verificação de atualização começa.
270
271**update-available**: Emitido quando há uma nova versão disponível para download.
272
273**update-not-available**: Emitido quando não há novas atualizações disponíveis.
274
275**this-is-last-update**: Emitido quando quando a verificação de atualização determina que a versão atual do seu aplicativo é a última versão disponível.
276
277**error**: Emitido quando ocorre um erro durante o processo de verificação de atualização.
278
279Você pode ouvir esses eventos da seguinte maneira:
280
281```javascript
282notifier.on('checking-for-update', () => {
283 console.log('Verificando por atualizações...');
284});
285
286notifier.on('update-available', (info: UpdateInfo) => {
287 console.log(`Uma nova versão (${info.version}) está disponível para download!`);
288});
289
290notifier.on('update-not-available', (info: UpdateInfo) => {
291 console.log('Não há novas atualizações disponíveis.');
292});
293
294notifier.on('this-is-last-update', (info: UpdateInfo) => {
295 console.log('Esta é a última atualização disponível: ', info);
296});
297
298notifier.on('error', (error: Error) => {
299 console.error(`Ocorreu um erro: ${error}`);
300});
301```
302O objeto **UpdateInfo** é passado como um argumento para o manipulador de eventos e contém informações sobre a versão atual e a última versão disponível do seu aplicativo.
303
304# Exemplo
305Aqui está um exemplo completo de como usar UpdateCheckerNotifier em um aplicativo Electron:
306
307```javascript
308import { updateCheckerNotifier, Language } from 'electron-update-checker-notifier';
309
310updateCheckerNotifier.repository = 'user/repo'
311updateCheckerNotifier.token = 'my-github-token'
312updateCheckerNotifier.debug = true
313updateCheckerNotifier.enablePreRelease = true
314updateCheckerNotifier.enableNewVersionAvailableDialog = true
315updateCheckerNotifier.enableLatestVersionDialog = true
316updateCheckerNotifier.enableErrorDialog = true
317updateCheckerNotifier.language = Language.PT_BR
318updateCheckerNotifier.logger = log
319
320updateCheckerNotifier.updateNotification();
321```
322
323```javascript
324import { UpdateCheckerNotifier, Language } from 'electron-update-checker-notifier';
325
326const notifier = new UpdateCheckerNotifier();
327
328notifier.updateNotification({
329 repository: 'user/repo',
330 token: 'my-github-token',
331 debug: true,
332 enablePreRelease = true,
333 enableNewVersionAvailableDialog: true,
334 enableLatestVersionDialog: true,
335 enableErrorDialog: true,
336 language: Language.PT_BR,
337 logger: log,
338});
339
340notifier.on('update-available', (info: UpdateInfo) => {
341 console.log(`Uma nova versão (${info.version}) está disponível para download!`);
342});
343
344notifier.on('error', (error: Error) => {
345 console.error(`Ocorreu um erro: ${error}`);
346});
347```
348
349# Contribuição
350Se você deseja contribuir para este projeto, siga as seguintes etapas:
351
3521. Faça um fork do repositório
3532. Crie sua branch
3543. Commit suas alterações
3554. Push na branch
3565. Crie um pull request
357
358# Reconhecimentos
359Gostaría de agradecer aos seguintes desenvolvedores pelo trabalho realizado no projeto [electron-update-notifier](https://github.com/ankurk91/electron-update-notifier):
360
361* [ankurk91](https://github.com/ankurk91)
362* [pd4d10](https://github.com/pd4d10)
363
364Obrigado por sua dedicação e contribuição com a comunidade.
365
366# Licença
367Este projeto está licenciado sob a licença MIT. Veja o arquivo [LICENSE](https://github.com/FabioLucenaRibas/electron-update-checker-notifier/blob/main/LICENSE) para mais detalhes.