Skip to content

Commit a4d4c37

Browse files
committed
1.1.9 release
1 parent 6ee5503 commit a4d4c37

File tree

5 files changed

+46
-26
lines changed

5 files changed

+46
-26
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ program
99
.name(STRINGS.APP_NAME)
1010
.description(STRINGS.APP_DESCRIPTION)
1111
.option("run", STRINGS.RUN_COMMAND)
12-
.option("update", STRINGS.UPDATE_COMMAND)
12+
.option("upgrade", STRINGS.UPDATE_COMMAND)
1313
.option("config", STRINGS.CONFIG_COMMAND)
1414
.option("host", STRINGS.HOST_STATIC_FILES)
1515
.option("generate", STRINGS.GENERATE_ENUMS)

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sqlink",
3-
"version": "1.1.8",
3+
"version": "1.1.9",
44
"main": "index.js",
55
"scripts": {
66
"test": "echo \"Error: no test specified\" && exit 1",

src/app.js

+30-22
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { exec } from "child_process";
44
import { launchProvider } from "./utils/config/provider.js";
55
import {
66
createConfigurationIfNotPresent,
7+
getAppLatestVersion,
78
hasConfiguration,
89
initConfiguration,
910
returnPropertiesPath,
@@ -13,7 +14,7 @@ import { initServer } from "./server/init.js";
1314
import { initialiseDatabase } from "./mysql/connector.js";
1415
import { STRINGS } from "./strings.js";
1516
import { staticHost } from "./server/host.js";
16-
import { generateEnum } from "./server/generator.js";
17+
import { generateEnum } from "./server/generator.js";
1718

1819
export async function validateCommand(command) {
1920
if (command == "run") {
@@ -25,35 +26,42 @@ export async function validateCommand(command) {
2526
} else {
2627
await lpFunction();
2728
}
28-
} else if (command == "update") {
29-
let update_command =
30-
platform() == "win32"
31-
? STRINGS.NPM_INSTALL_CMD
32-
: STRINGS.SUDO_NPM_INSTALL_CMD;
33-
exec(update_command, (error, stdout, stderr) => {
34-
if (error) {
35-
SQLog.error(STRINGS.UPDATE_ERROR, false);
36-
return;
37-
}
38-
if (stdout) {
39-
SQLog.success(STRINGS.UPDATE_SUCCESSFULLY, false);
40-
return;
41-
}
42-
if (stderr) {
43-
SQLog.error(STRINGS.UPDATE_ERROR, false);
44-
return;
45-
}
46-
});
29+
} else if (command == "upgrade") {
30+
let latestVersion = await getAppLatestVersion()
31+
if (latestVersion === STRINGS.APP_VERSION) {
32+
SQLog.info(STRINGS.ALREADY_UP_TO_DATE)
33+
} else {
34+
SQLog.info(`${STRINGS.NEW_VERSION_AVAILABLE} ${latestVersion}.`)
35+
SQLog.info(`${STRINGS.CURRENT_VERSION} ${STRINGS.APP_VERSION}`)
36+
let update_command =
37+
platform() == "win32"
38+
? STRINGS.NPM_INSTALL_CMD
39+
: STRINGS.SUDO_NPM_INSTALL_CMD;
40+
exec(update_command, (error, stdout, stderr) => {
41+
if (error) {
42+
SQLog.error(STRINGS.UPDATE_ERROR, false);
43+
return;
44+
}
45+
if (stdout) {
46+
SQLog.success(STRINGS.UPDATE_SUCCESSFULLY, false);
47+
return;
48+
}
49+
if (stderr) {
50+
SQLog.error(STRINGS.UPDATE_ERROR, false);
51+
return;
52+
}
53+
});
54+
}
4755
} else if (command == "config") {
4856
await lpFunction();
4957
} else if (command == "host") {
5058
staticHost();
51-
} else if (command == "enum"){
59+
} else if (command == "enum") {
5260
await initConfiguration();
5361
await initialiseDatabase();
5462
await generateEnum();
5563
}
56-
else {
64+
else {
5765
SQLog.error(STRINGS.UNKNOWN_COMMAND, false);
5866
}
5967
}

src/strings.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const STRINGS = {
2-
APP_VERSION: "1.1.8",
2+
APP_VERSION: "1.1.9",
33
APP_NAME: "sqlink",
44
APP_DESCRIPTION:
55
"SQLink is a Node.js library that turns MySQL tables into RESTful APIs with procedure execution and full CRUD support.",
@@ -58,5 +58,8 @@ export const STRINGS = {
5858
WEBSITE: "https://sqlinkjs.github.io/",
5959
NPM: "https://www.npmjs.com/package/sqlink",
6060
GITHUB: "https://github.com/Santhoshlm10/SQLink"
61-
}
61+
},
62+
ALREADY_UP_TO_DATE: "SQLink is already on the latest version!",
63+
NEW_VERSION_AVAILABLE: "New version of SQLink is available",
64+
CURRENT_VERSION: "Current Version: "
6265
};

src/utils/config/checker.js

+9
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,13 @@ export async function initConfiguration(){
6565
await verifyUploadsFolder();
6666
db_config = jsonData
6767
return;
68+
}
69+
70+
export async function getAppLatestVersion(){
71+
let res = await fetch("https://registry.npmjs.com/sqlink")
72+
let data = await res.json();
73+
if(data["dist-tags"]["latest"]){
74+
return data["dist-tags"]["latest"]
75+
}
76+
return null;
6877
}

0 commit comments

Comments
 (0)