@tmlmobilidade/export-data 20251229.1617.34 → 20251229.1636.59
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/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { promptAccessKey } from './prompts/access-key.js';
|
|
3
3
|
import { promptExportTypes } from './prompts/export-types.js';
|
|
4
4
|
import { promptFilterByAgencyIds } from './prompts/filter-agency-ids.js';
|
|
5
5
|
import { promptFilterByDates } from './prompts/filter-dates.js';
|
|
@@ -23,7 +23,6 @@ import { ASCII_CM_SHORT } from '@tmlmobilidade/consts';
|
|
|
23
23
|
/* * */
|
|
24
24
|
(async function main() {
|
|
25
25
|
//
|
|
26
|
-
await promptEnvironmentVariable();
|
|
27
26
|
//
|
|
28
27
|
// Initialize the export context
|
|
29
28
|
const context = initExportContext();
|
|
@@ -34,6 +33,9 @@ import { ASCII_CM_SHORT } from '@tmlmobilidade/consts';
|
|
|
34
33
|
log.info(`O ID desta exportação é: ${context._id}`);
|
|
35
34
|
log.info(`Todos os resultados serão guardados aqui: ${context.output}`);
|
|
36
35
|
//
|
|
36
|
+
// Prompt for the access key
|
|
37
|
+
await promptAccessKey();
|
|
38
|
+
//
|
|
37
39
|
// Request the export types and which filters to apply
|
|
38
40
|
const exportTypes = await promptExportTypes();
|
|
39
41
|
const filterTypes = await promptFilterTypes();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function promptAccessKey(): Promise<void>;
|
|
@@ -4,22 +4,29 @@ import { cancel, isCancel, note, spinner, text } from '@clack/prompts';
|
|
|
4
4
|
/* * */
|
|
5
5
|
const CREDENTIAL_KEY = 'access-key';
|
|
6
6
|
/* * */
|
|
7
|
-
export async function
|
|
7
|
+
export async function promptAccessKey() {
|
|
8
8
|
//
|
|
9
9
|
//
|
|
10
|
-
// Delete credentials on init
|
|
11
|
-
await deleteCredential(CREDENTIAL_KEY);
|
|
12
|
-
//
|
|
13
10
|
// Check if there is an access key already saved in the computer
|
|
14
11
|
const s = spinner();
|
|
15
12
|
s.start('A verificar credenciais guardadas...');
|
|
16
13
|
const existingKey = await getCredential(CREDENTIAL_KEY);
|
|
17
|
-
|
|
14
|
+
//
|
|
15
|
+
// If --delete-credentials flag was passed, delete existing credentials
|
|
16
|
+
if (process.argv.includes('--delete-credentials') && existingKey) {
|
|
17
|
+
s.stop('Flag --delete-credentials detectada.');
|
|
18
|
+
s.start('A remover credenciais guardadas...');
|
|
19
|
+
await deleteCredential(CREDENTIAL_KEY);
|
|
20
|
+
s.stop('Credenciais removidas. A começar de novo...');
|
|
21
|
+
}
|
|
22
|
+
else if (existingKey) {
|
|
18
23
|
s.stop('Chave de acesso encontrada no armazenamento seguro do sistema.');
|
|
19
24
|
process.env.DATABASE_URI = existingKey;
|
|
20
25
|
return;
|
|
21
26
|
}
|
|
22
|
-
|
|
27
|
+
else {
|
|
28
|
+
s.stop('Nenhuma chave de acesso encontrada.');
|
|
29
|
+
}
|
|
23
30
|
//
|
|
24
31
|
// If no key exists, ask the user to enter the access key
|
|
25
32
|
note('A chave de acesso será guardada de forma segura:\n'
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function promptEnvironmentVariable(): Promise<void>;
|