@trycourier/cli 2.1.1 → 2.1.2

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/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import React from 'react';
2
+ import React, { useEffect, useState } from 'react';
3
3
  import { Box, Text, render } from 'ink';
4
4
  import args from './lib/args.js';
5
5
  import loadEnv from './lib/load-env.js';
@@ -8,40 +8,47 @@ import { execa } from 'execa';
8
8
  import _ from 'lodash';
9
9
  import VERSION from './version.js';
10
10
  import constants from './constants.js';
11
- 2;
12
11
  const CLI = async () => {
13
12
  process.removeAllListeners('warning');
14
13
  await loadEnv();
15
14
  const params = args(process.argv);
16
15
  const mappings = (await import('./mappings.js')).default;
17
16
  const Router = (await import('./components/Router.js')).default;
18
- let current;
19
- let latest;
20
- if (VERSION !== 'local') {
21
- try {
22
- const exc = await execa('npm', ['-g', 'outdated', constants.package_name, '--json'], {
23
- shell: true,
24
- reject: false,
25
- });
26
- const stdout = JSON.parse(exc.stdout);
27
- current = _.get(stdout, ['npm', 'current']);
28
- latest = _.get(stdout, ['npm', 'latest']);
17
+ const [version, setVersion] = useState({});
18
+ useEffect(() => {
19
+ getVersion();
20
+ }, []);
21
+ const getVersion = async () => {
22
+ if (VERSION !== 'local') {
23
+ try {
24
+ const exc = await execa('npm', ['-g', 'outdated', constants.package_name, '--json'], {
25
+ shell: true,
26
+ reject: false,
27
+ });
28
+ const stdout = JSON.parse(exc.stdout);
29
+ setVersion({
30
+ current: _.get(stdout, [constants.package_name, 'current']),
31
+ latest: _.get(stdout, [constants.package_name, 'latest']),
32
+ });
33
+ }
34
+ catch (e) {
35
+ console.log(e);
36
+ }
29
37
  }
30
- catch (e) {
31
- console.log(e);
32
- }
33
- }
34
- const version_text = `Upgrade available (${current} > ${latest}), run courier upgrade`;
35
- render(React.createElement(CliContextProvider, { args: params, mappings, current, latest },
38
+ };
39
+ const version_text = version.current && version.latest && version.current !== version.latest
40
+ ? `Upgrade available (${version.current} > ${version.latest}), run courier upgrade`
41
+ : undefined;
42
+ render(React.createElement(CliContextProvider, { args: params, mappings, ...version },
36
43
  React.createElement(Router, null),
37
- current && latest && current !== latest ? (React.createElement(Box, { flexDirection: "column", marginY: 1, flexShrink: 1, width: version_text.length + 2, borderColor: "gray", borderStyle: 'single' },
44
+ version_text ? (React.createElement(Box, { flexDirection: "column", marginY: 1, flexShrink: 1, width: version_text.length + 2, borderColor: "gray", borderStyle: 'single' },
38
45
  React.createElement(Text, null,
39
46
  "Upgrade available (",
40
- current,
47
+ version.current,
41
48
  " ",
42
49
  '>',
43
50
  " ",
44
- latest,
51
+ version.latest,
45
52
  "), run",
46
53
  ' ',
47
54
  React.createElement(Text, { color: "green" }, "courier upgrade")))) : (React.createElement(React.Fragment, null))));
@@ -1,12 +1,11 @@
1
+ import { Alert } from '@inkjs/ui';
1
2
  import _ from 'lodash';
2
3
  import React, { useEffect, useState } from 'react';
3
4
  import { useBoolean, useCounter } from 'usehooks-ts';
5
+ import getDb from '../../bulk.js';
4
6
  import { useCliContext } from '../../components/Context.js';
5
7
  import Spinner from '../../components/Spinner.js';
6
8
  import UhOh from '../../components/UhOh.js';
7
- // @ts-ignore
8
- import { Alert } from '@inkjs/ui';
9
- import getDb from '../../bulk.js';
10
9
  import ArchiveAll from './ArchiveAll.js';
11
10
  const ArchiveAllBulk = ({}) => {
12
11
  const [error, setError] = useState();
@@ -74,12 +73,15 @@ const ArchiveAllBulk = ({}) => {
74
73
  finished.map((t, i) => (React.createElement(Alert, { key: i, variant: t.type }, t.message))),
75
74
  React.createElement(Spinner, { text: `Processing ${current_user}` }),
76
75
  React.createElement(ArchiveAll, { key: current_user, user_id_override: current_user, onError: (error) => {
77
- const text = `${current_user} - ${error}`;
76
+ const text = `user_id: ${current_user} | ${error}`;
78
77
  setFinished(p => [...p, { type: 'error', message: text }]);
79
78
  getNext();
80
79
  }, user_finished: (messages) => {
81
- const text = `${current_user} - Archived ${messages} messages`;
82
- setFinished(p => [...p, { type: 'success', message: text }]);
80
+ const text = `user_id: ${current_user} | Archived ${messages} messages`;
81
+ setFinished(p => [
82
+ ...p,
83
+ { type: messages > 0 ? 'success' : 'info', message: text },
84
+ ]);
83
85
  getNext();
84
86
  } })));
85
87
  }
@@ -18,10 +18,10 @@ export default () => {
18
18
  }, []);
19
19
  return (React.createElement(Box, { flexDirection: "column", width: "100%" },
20
20
  React.createElement(Request, { request: request, response: resp }),
21
- resp && resp.err ? (React.createElement(Response, { response: resp })) : resp && resp.json ? (React.createElement(React.Fragment, null,
22
- React.createElement(KVP, { width: 20, label: "Workspace Name", value: resp.json.tenantName }),
23
- React.createElement(KVP, { width: 20, label: "Workspace ID", value: resp.json.tenantId }),
24
- React.createElement(KVP, { width: 20, label: "API Key Environment", value: resp.json.environment }),
25
- React.createElement(KVP, { width: 20, label: "API Key Scope", value: resp.json.scope }),
26
- resp.json.mock && (React.createElement(KVP, { width: 20, label: "API Key Simulated (Mock)", value: resp.json.scope })))) : null));
21
+ resp && resp.err ? (React.createElement(Response, { response: resp })) : resp && resp.json ? (React.createElement(Box, { flexDirection: "column", width: "100%" },
22
+ React.createElement(KVP, { label: "Workspace Name", value: resp.json.tenantName }),
23
+ React.createElement(KVP, { label: "Workspace ID", value: resp.json.tenantId }),
24
+ React.createElement(KVP, { label: "API Key Environment", value: resp.json.environment }),
25
+ React.createElement(KVP, { label: "API Key Scope", value: resp.json.scope }),
26
+ resp.json.mock && (React.createElement(KVP, { label: "API Key Simulated (Mock)", value: resp.json.scope })))) : null));
27
27
  };
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { Box, Spacer, Text } from 'ink';
3
3
  export default ({ label, labelColor, labelBold, value, width, indent, }) => {
4
4
  return (React.createElement(Box, { flexDirection: "column" },
5
- React.createElement(Box, { width: width, flexDirection: "row" },
5
+ React.createElement(Box, { width: width || '100%', flexDirection: "row" },
6
6
  React.createElement(Text, null, indent),
7
7
  React.createElement(Text, { bold: labelBold === false ? false : true, color: labelColor }, label),
8
8
  React.createElement(Spacer, null),
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- let VERSION = '2.1.1';
1
+ let VERSION = '2.1.2';
2
2
  export default VERSION;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trycourier/cli",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "courier": "dist/cli.js"