@circleback/cli 0.1.6 → 0.1.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.
|
@@ -12,11 +12,11 @@ const profiles_1 = require("./profiles");
|
|
|
12
12
|
const support_1 = require("./support");
|
|
13
13
|
const tags_1 = require("./tags");
|
|
14
14
|
const transcripts_1 = require("./transcripts");
|
|
15
|
-
const
|
|
15
|
+
const update_1 = require("./update");
|
|
16
16
|
exports.standaloneCommands = [
|
|
17
17
|
auth_1.loginCommand,
|
|
18
18
|
auth_1.logoutCommand,
|
|
19
|
-
|
|
19
|
+
update_1.updateCommand,
|
|
20
20
|
];
|
|
21
21
|
exports.commandGroups = [
|
|
22
22
|
{
|
|
@@ -14,7 +14,7 @@ exports.updateCommand = new commander_1.Command('update')
|
|
|
14
14
|
.action(async () => {
|
|
15
15
|
console.log(chalk_1.default.dim(`Current version: ${constants_1.CLIENT_VERSION}`));
|
|
16
16
|
console.log(chalk_1.default.dim('Checking for updates…'));
|
|
17
|
-
const result = await (0, update_1.
|
|
17
|
+
const result = await (0, update_1.getUpdateCheckResult)(constants_1.CLIENT_PACKAGE_NAME);
|
|
18
18
|
if (!result.updateAvailable) {
|
|
19
19
|
console.log(chalk_1.default.green('Already on the latest version.'));
|
|
20
20
|
return;
|
package/dist/helpers/update.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.printUpdateNotification = exports.
|
|
6
|
+
exports.printUpdateNotification = exports.getUpdateCheckResult = void 0;
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
@@ -62,15 +62,16 @@ const isNewerVersion = (latest, current) => {
|
|
|
62
62
|
const firstDifference = Array.from({ length }, (_, index) => (latestParts[index] ?? 0) - (currentParts[index] ?? 0)).find((difference) => difference !== 0);
|
|
63
63
|
return (firstDifference ?? 0) > 0;
|
|
64
64
|
};
|
|
65
|
-
const
|
|
65
|
+
const resultFromCache = (cached) => ({
|
|
66
|
+
updateAvailable: isNewerVersion(cached.latestVersion, constants_1.CLIENT_VERSION),
|
|
67
|
+
currentVersion: constants_1.CLIENT_VERSION,
|
|
68
|
+
latestVersion: cached.latestVersion,
|
|
69
|
+
});
|
|
70
|
+
const getUpdateCheckResult = async (packageName) => {
|
|
66
71
|
const cached = loadCache();
|
|
67
72
|
const now = Date.now();
|
|
68
73
|
if (cached && now - cached.checkedAt < CHECK_INTERVAL_MILLISECONDS) {
|
|
69
|
-
return
|
|
70
|
-
updateAvailable: isNewerVersion(cached.latestVersion, constants_1.CLIENT_VERSION),
|
|
71
|
-
currentVersion: constants_1.CLIENT_VERSION,
|
|
72
|
-
latestVersion: cached.latestVersion,
|
|
73
|
-
};
|
|
74
|
+
return resultFromCache(cached);
|
|
74
75
|
}
|
|
75
76
|
try {
|
|
76
77
|
const latestVersion = await fetchLatestVersion(packageName);
|
|
@@ -90,7 +91,7 @@ const checkForUpdate = async (packageName) => {
|
|
|
90
91
|
};
|
|
91
92
|
}
|
|
92
93
|
};
|
|
93
|
-
exports.
|
|
94
|
+
exports.getUpdateCheckResult = getUpdateCheckResult;
|
|
94
95
|
const printUpdateNotification = (result) => {
|
|
95
96
|
if (!result.updateAvailable)
|
|
96
97
|
return;
|
package/dist/index.js
CHANGED
|
@@ -8,28 +8,30 @@ const help_1 = require("./helpers/help");
|
|
|
8
8
|
const style_1 = require("./helpers/style");
|
|
9
9
|
const update_1 = require("./helpers/update");
|
|
10
10
|
const program = new commander_1.Command();
|
|
11
|
+
const updateCheck = (0, update_1.getUpdateCheckResult)(constants_1.CLIENT_PACKAGE_NAME);
|
|
11
12
|
program
|
|
12
13
|
.name('circleback')
|
|
13
14
|
.description('Search and access meetings, emails, calendar events, and more.')
|
|
14
15
|
.version(constants_1.CLIENT_VERSION)
|
|
15
16
|
.option('--json', 'Output raw JSON instead of formatted text')
|
|
16
17
|
.addHelpText('before', style_1.BANNER)
|
|
18
|
+
.exitOverride()
|
|
17
19
|
.configureOutput({
|
|
18
20
|
writeOut: (text) => process.stdout.write((0, help_1.styleHelpOutput)(text)),
|
|
19
21
|
writeErr: (text) => process.stderr.write((0, help_1.styleHelpOutput)(text)),
|
|
20
22
|
});
|
|
21
23
|
(0, registry_1.getAllCommands)().reduce((p, command) => p.addCommand(command), program);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const updateCheckPromise = (0, update_1.checkForUpdate)(constants_1.CLIENT_PACKAGE_NAME);
|
|
26
|
-
program.hook('postAction', async () => {
|
|
24
|
+
program.hook('postAction', async (_thisCommand, actionCommand) => {
|
|
25
|
+
if (actionCommand.name() === 'update')
|
|
26
|
+
return;
|
|
27
27
|
try {
|
|
28
|
-
|
|
29
|
-
(0, update_1.printUpdateNotification)(result);
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
// Never let the update check interfere with normal CLI operation.
|
|
28
|
+
(0, update_1.printUpdateNotification)(await updateCheck);
|
|
33
29
|
}
|
|
30
|
+
catch { }
|
|
31
|
+
});
|
|
32
|
+
program.parseAsync().catch((error) => {
|
|
33
|
+
if (error instanceof commander_1.CommanderError)
|
|
34
|
+
process.exit(error.exitCode);
|
|
35
|
+
console.error(error);
|
|
36
|
+
process.exit(1);
|
|
34
37
|
});
|
|
35
|
-
program.parse();
|
package/package.json
CHANGED