@logto/cli 1.2.3 → 1.3.0
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/lib/commands/install/utils.js +19 -2
- package/lib/package-json.js +2 -2
- package/package.json +2 -2
|
@@ -5,6 +5,7 @@ import os from 'node:os';
|
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import { assert } from '@silverhand/essentials';
|
|
7
7
|
import chalk from 'chalk';
|
|
8
|
+
import { got, RequestError } from 'got';
|
|
8
9
|
import inquirer from 'inquirer';
|
|
9
10
|
import * as semver from 'semver';
|
|
10
11
|
import tar from 'tar';
|
|
@@ -68,10 +69,26 @@ export const validateDatabase = async () => {
|
|
|
68
69
|
consoleLog.fatal('Logto requires a Postgres instance to run.');
|
|
69
70
|
}
|
|
70
71
|
};
|
|
72
|
+
const fetchDownloadUrl = async (url) => {
|
|
73
|
+
if (url) {
|
|
74
|
+
return url;
|
|
75
|
+
}
|
|
76
|
+
const defaultUrl = `https://github.com/logto-io/logto/releases/download/v${packageJson.version}/logto.tar.gz`;
|
|
77
|
+
try {
|
|
78
|
+
await got.head(defaultUrl);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (error instanceof RequestError && error.response?.statusCode === 404) {
|
|
82
|
+
consoleLog.warn(`Current version "v${packageJson.version}" not found in GitHub Releases, fallback to "latest".\n` +
|
|
83
|
+
'If you want to download the latest version, please wait a few moments and try again.');
|
|
84
|
+
return 'https://github.com/logto-io/logto/releases/latest/download/logto.tar.gz';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return defaultUrl;
|
|
88
|
+
};
|
|
71
89
|
export const downloadRelease = async (url) => {
|
|
72
90
|
const tarFilePath = path.resolve(os.tmpdir(), './logto.tar.gz');
|
|
73
|
-
const from = url
|
|
74
|
-
`https://github.com/logto-io/logto/releases/download/v${packageJson.version}/logto.tar.gz`;
|
|
91
|
+
const from = await fetchDownloadUrl(url);
|
|
75
92
|
consoleLog.info(`Download Logto from ${from}`);
|
|
76
93
|
consoleLog.info(`Target ${tarFilePath}`);
|
|
77
94
|
await downloadFile(from, tarFilePath);
|
package/lib/package-json.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const packageJson = {
|
|
2
2
|
"name": "@logto/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Logto CLI.",
|
|
5
5
|
"author": "Silverhand Inc. <contact@silverhand.io>",
|
|
6
6
|
"homepage": "https://github.com/logto-io/logto#readme",
|
|
@@ -48,7 +48,7 @@ export const packageJson = {
|
|
|
48
48
|
"@logto/language-kit": "workspace:^1.0.0",
|
|
49
49
|
"@logto/phrases": "workspace:^1.2.0",
|
|
50
50
|
"@logto/phrases-ui": "workspace:^1.2.0",
|
|
51
|
-
"@logto/schemas": "workspace
|
|
51
|
+
"@logto/schemas": "workspace:1.3.0",
|
|
52
52
|
"@logto/shared": "workspace:^2.0.0",
|
|
53
53
|
"@silverhand/essentials": "^2.5.0",
|
|
54
54
|
"chalk": "^5.0.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Logto CLI.",
|
|
5
5
|
"author": "Silverhand Inc. <contact@silverhand.io>",
|
|
6
6
|
"homepage": "https://github.com/logto-io/logto#readme",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@logto/language-kit": "^1.0.0",
|
|
34
34
|
"@logto/phrases": "^1.2.0",
|
|
35
35
|
"@logto/phrases-ui": "^1.2.0",
|
|
36
|
-
"@logto/schemas": "
|
|
36
|
+
"@logto/schemas": "1.3.0",
|
|
37
37
|
"@logto/shared": "^2.0.0",
|
|
38
38
|
"@silverhand/essentials": "^2.5.0",
|
|
39
39
|
"chalk": "^5.0.0",
|