cli: add support for version launch hint

This commit is contained in:
Koushik Dutta
2024-08-27 18:30:33 -07:00
parent d238d8d4ba
commit 3b6454f107
4 changed files with 14 additions and 6 deletions

View File

@@ -21,8 +21,7 @@
],
"preLaunchTask": "npm: build",
"args": [
"rtsp",
"/Volumes/Seagate/video/scrypted-1370/1720470474217/1720470474217/1720470474217.rtsp",
"serve",
],
"sourceMaps": true,
"resolveSourceMapLocations": [

View File

@@ -1,12 +1,12 @@
{
"name": "scrypted",
"version": "1.3.19",
"version": "1.3.20",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "scrypted",
"version": "1.3.19",
"version": "1.3.20",
"license": "ISC",
"dependencies": {
"@scrypted/client": "^1.3.3",

View File

@@ -1,6 +1,6 @@
{
"name": "scrypted",
"version": "1.3.19",
"version": "1.3.20",
"description": "",
"main": "./dist/packages/cli/src/main.js",
"bin": {

View File

@@ -12,6 +12,7 @@ async function sleep(ms: number) {
const EXIT_FILE = '.exit';
const UPDATE_FILE = '.update';
const VERSION_FILE = '.version';
async function runCommand(command: string, ...args: string[]) {
if (os.platform() === 'win32') {
@@ -117,6 +118,15 @@ export async function installServe(installVersion: string, ignoreError?: boolean
}
export async function serveMain(installVersion?: string) {
const { installDir, volume } = cwdInstallDir();
if (!installVersion) {
try {
installVersion = fs.readFileSync(path.join(volume, VERSION_FILE)).toString().trim();
}
catch (e) {
}
}
const options = ((): { install: true; version: string } | { install: false } => {
if (installVersion) {
console.log(`Installing @scrypted/server@${installVersion}`);
@@ -139,7 +149,6 @@ export async function serveMain(installVersion?: string) {
}
})();
const { installDir, volume } = cwdInstallDir();
if (options.install) {
await installServe(options.version, true);