From 9ddd67751c013ae9143215ae248115c180b980e3 Mon Sep 17 00:00:00 2001 From: Naveed Date: Mon, 20 May 2024 11:48:40 +0200 Subject: [PATCH 1/8] functionality updated --- components/hello-world/src/Main.ts | 45 ++++++++++++-------- components/hello-world/src/index.js | 4 +- components/hello-world/src/test/Main.test.ts | 24 ++++++----- 3 files changed, 43 insertions(+), 30 deletions(-) diff --git a/components/hello-world/src/Main.ts b/components/hello-world/src/Main.ts index 3adb798..a06e54b 100644 --- a/components/hello-world/src/Main.ts +++ b/components/hello-world/src/Main.ts @@ -1,21 +1,32 @@ -import * as fs from "fs"; -import * as path from "path"; -import * as chalk from "chalk"; #include "../VariantConfig.js" -export function Main (subStr: string): string { -// command: c-preprocessor Main.ts Main.ts -let moduleType; +/* + It provides the variant type +*/ +export function GetVariantType (): string { + let variantType; + #if "VARIANT" == "MAC" + variantType = "Mac" + #elif "VARIANT" == "LINUX" + variantType = "Linux" + #else + variantType = "Windows" + #endif + return variantType; +} + +/* + Creates the message string +*/ +export function CreateMsgString (): string { + const variant = GetVariantType(); + const msgString = "***" + variant + " platform --> Hello-World ***" + return msgString; +} -#if "VARIANT" == "MAC" -moduleType = "MAC" -console.log("*** Mac platform -->" + subStr + " ***"); -#elif "VARIANT" == "LINUX" -moduleType = "LINUX" -console.log("*** Linux platform -->" + subStr + " ***"); -#else -moduleType = "WINDOWS" -console.log("*** Windows platform --> " + subStr + " ***"); -#endif -return moduleType; +/* + Display's the message string +*/ +export function DisplayMsg (messageString: string): void { + console.log(messageString); } diff --git a/components/hello-world/src/index.js b/components/hello-world/src/index.js index 00b032a..6ca9978 100644 --- a/components/hello-world/src/index.js +++ b/components/hello-world/src/index.js @@ -41,5 +41,5 @@ if (program.red) { // #endif //------------------------------------------------- -var str = "Hello-World"; -main(str); +const msg = CreateMsgString(); +DisplayMsg(msg); diff --git a/components/hello-world/src/test/Main.test.ts b/components/hello-world/src/test/Main.test.ts index c09427a..656372c 100644 --- a/components/hello-world/src/test/Main.test.ts +++ b/components/hello-world/src/test/Main.test.ts @@ -1,21 +1,23 @@ -import * as fs from "fs"; -import * as path from "path"; -import { expect } from "chai"; -import * as rimraf from "rimraf"; -import { Main } from "../Main"; #include "../../VariantConfig.js" +import { expect } from "chai"; +import { CreateMsgString, GetVariantType, DisplayMsg } from "../Main"; + describe("Hello-World Component Tests", async () => { - it("Get required module type", async () => { - var msgStr = "Hello World"; - const moduleType = Main(msgStr); + it("verify variant and message string", async () => { + const variantType = GetVariantType(); + const msgString = CreateMsgString(); #if "VARIANT" == "MAC" - expect(moduleType).to.equal("MAC"); + expect(variantType).to.equal("Mac"); + expect(msgString).to.equal("*** Mac platform --> Hello-World ***"); #elif "VARIANT" == "LINUX" - expect(moduleType).to.equal("LINUX"); + expect(variantType).to.equal("Linux"); + expect(msgString).to.equal("*** Linux platform --> Hello-World ***"); #else - expect(moduleType).to.equal("WINDOWS"); + expect(variantType).to.equal("Windows"); + expect(msgString).to.equal("*** Windows platform --> Hello-World ***"); #endif + DisplayMsg(msgString); }); }); \ No newline at end of file From 398bee0d395987448ae929e086b6ecc62caab011 Mon Sep 17 00:00:00 2001 From: Naveed Date: Mon, 20 May 2024 12:08:09 +0200 Subject: [PATCH 2/8] colored msg and clean up commented old configurations --- components/hello-world/src/Main.ts | 11 ++++-- components/hello-world/src/index.js | 52 ++++++----------------------- 2 files changed, 19 insertions(+), 44 deletions(-) diff --git a/components/hello-world/src/Main.ts b/components/hello-world/src/Main.ts index a06e54b..fed3165 100644 --- a/components/hello-world/src/Main.ts +++ b/components/hello-world/src/Main.ts @@ -1,4 +1,5 @@ #include "../VariantConfig.js" +const chalk=require("chalk"); /* It provides the variant type @@ -25,8 +26,14 @@ export function CreateMsgString (): string { } /* - Display's the message string + Display's the colored message string */ export function DisplayMsg (messageString: string): void { - console.log(messageString); + #if "VARIANT" == "MAC" + console.log(chalk.yellow(messageString)); + #elif "VARIANT" == "LINUX" + console.log(chalk.red(messageString)); + #else + console.log(chalk.green(messageString)); + #endif } diff --git a/components/hello-world/src/index.js b/components/hello-world/src/index.js index 6ca9978..7c7cb48 100644 --- a/components/hello-world/src/index.js +++ b/components/hello-world/src/index.js @@ -1,45 +1,13 @@ -const fs = require("fs"); -const path = require("path"); -const chalk=require("chalk"); -const rimraf = require("rimraf"); -const commander = require("commander"); -const main = require("./Main").Main; - -const program = new commander.Command("Hello World NPM CLI"); -program.option("--displayMsg"); -program.option("-g, --green", "Display the message in Green."); -program.option("-r, --red", "Display the message in Red."); - -program.parse(process.argv); - -if (program.green) { - console.log(chalk.green("Message was configured to show in green color.")); +const displayMsg = require("./Main").DisplayMsg; +const msgString = require("./Main").CreateMsgString; + +/* + Main function +*/ +function main() { + const msg = msgString(); + displayMsg(msg); } -if (program.red) { - console.log(chalk.red("Message was configured to show in red color.")); -} - -// ** c-preprocess ** -// 1st globally install this package -//command: c-preprocessor index.js outputFile.js -//------------------------------------------------- -// #include "VariantConfig.js" - -// #if variable1 + variable2 == 5 && defined(MY_CONST) -// console("Multi-condition test") -// #elif "MY_CONST2" == "House" -// console.log("Equality Check Pass") -// #else -// console.log("Default Statement!") -// #endif - -// #ifndef MY_CONST3 -// console.log("Var is not defined!") -// #else -// console.log("Var is defined!") -// #endif -//------------------------------------------------- +main(); -const msg = CreateMsgString(); -DisplayMsg(msg); From b06180b2c6fc16c6abe4fc34f8d69f51bb9430dc Mon Sep 17 00:00:00 2001 From: Naveed Date: Mon, 20 May 2024 12:09:42 +0200 Subject: [PATCH 3/8] Fixed description of module --- components/hello-world/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/hello-world/package.json b/components/hello-world/package.json index 48d524b..511a833 100644 --- a/components/hello-world/package.json +++ b/components/hello-world/package.json @@ -8,7 +8,7 @@ "name": "@naveed235812/hello-world-windows", #endif "version": "1.0.3", - "description": "This component display helloworld message on screen.", + "description": "This component display variant type based hello-world message on screen.", "main": "index.js", "bin": { "hello-world": "./lib/index.js" From 86cd5e7aa1bafe343ef6e28a07f9611dbd79c02f Mon Sep 17 00:00:00 2001 From: Naveed Date: Mon, 20 May 2024 12:14:11 +0200 Subject: [PATCH 4/8] cleanup configurations --- components/hello-world/configs/Linux_Config.js | 7 +------ components/hello-world/configs/Mac_Config.js | 5 ----- components/hello-world/configs/Windows_Config.js | 5 ----- 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/components/hello-world/configs/Linux_Config.js b/components/hello-world/configs/Linux_Config.js index 713599c..be8a724 100644 --- a/components/hello-world/configs/Linux_Config.js +++ b/components/hello-world/configs/Linux_Config.js @@ -1,6 +1 @@ -#define MY_CONST true -#define variable1 1 -#define variable2 4 -//#define MY_CONST2 House -#define MY_CONST3 42 -#define VARIANT LINUX +#define VARIANT LINUX \ No newline at end of file diff --git a/components/hello-world/configs/Mac_Config.js b/components/hello-world/configs/Mac_Config.js index f3fd73e..8bfab20 100644 --- a/components/hello-world/configs/Mac_Config.js +++ b/components/hello-world/configs/Mac_Config.js @@ -1,6 +1 @@ -#define MY_CONST true -#define variable1 1 -#define variable2 4 -//#define MY_CONST2 House -#define MY_CONST3 42 #define VARIANT MAC diff --git a/components/hello-world/configs/Windows_Config.js b/components/hello-world/configs/Windows_Config.js index f7bfb01..6742513 100644 --- a/components/hello-world/configs/Windows_Config.js +++ b/components/hello-world/configs/Windows_Config.js @@ -1,6 +1 @@ -#define MY_CONST true -#define variable1 1 -#define variable2 4 -//#define MY_CONST2 House -#define MY_CONST3 42 #define VARIANT WINDOWS From 727489bf7e56d70c24c1a53c46964bd6465be7c3 Mon Sep 17 00:00:00 2001 From: Naveed Date: Mon, 20 May 2024 12:16:03 +0200 Subject: [PATCH 5/8] msg string fixed --- components/hello-world/src/Main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/hello-world/src/Main.ts b/components/hello-world/src/Main.ts index fed3165..f476582 100644 --- a/components/hello-world/src/Main.ts +++ b/components/hello-world/src/Main.ts @@ -21,7 +21,7 @@ export function GetVariantType (): string { */ export function CreateMsgString (): string { const variant = GetVariantType(); - const msgString = "***" + variant + " platform --> Hello-World ***" + const msgString = "*** " + variant + " platform --> Hello-World ***" return msgString; } From d864d10cd4cd20997e60aa8ae58f35955629189c Mon Sep 17 00:00:00 2001 From: Naveed Date: Mon, 20 May 2024 12:18:25 +0200 Subject: [PATCH 6/8] moving to version 1.0.4 --- components/hello-world/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/hello-world/package.json b/components/hello-world/package.json index 511a833..f3a4721 100644 --- a/components/hello-world/package.json +++ b/components/hello-world/package.json @@ -7,7 +7,7 @@ #else "name": "@naveed235812/hello-world-windows", #endif - "version": "1.0.3", + "version": "1.0.4", "description": "This component display variant type based hello-world message on screen.", "main": "index.js", "bin": { From 6d3732b7ad5c3705975dcc18b01b9bbda71415c6 Mon Sep 17 00:00:00 2001 From: Naveed Date: Mon, 20 May 2024 12:25:13 +0200 Subject: [PATCH 7/8] name updated for jobs --- .github/workflows/Build-And-Test-Component-Reuse-Case.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Build-And-Test-Component-Reuse-Case.yml b/.github/workflows/Build-And-Test-Component-Reuse-Case.yml index 805c0d6..5425b74 100644 --- a/.github/workflows/Build-And-Test-Component-Reuse-Case.yml +++ b/.github/workflows/Build-And-Test-Component-Reuse-Case.yml @@ -16,7 +16,7 @@ on: - .github/workflows/Build-And-Test-Component-Reuse-Case.yml jobs: - hello-world-linux: + hello-world-linux-reuse: name: "Hello-World Linux" runs-on: ubuntu-latest steps: @@ -36,7 +36,7 @@ jobs: VARIANT_TYPE: linux WORKING-DIR: ./components/ - hello-world-mac: + hello-world-mac-reuse: name: "Hello-World Mac" runs-on: macos-latest steps: @@ -56,7 +56,7 @@ jobs: VARIANT_TYPE: mac WORKING-DIR: ./components/ - hello-world-windows: + hello-world-windows-reuse: name: "Hello-World Windows" runs-on: windows-latest steps: From 1940f9956f3a6f31d4f00189ea8e53ae59180af7 Mon Sep 17 00:00:00 2001 From: Naveed Date: Mon, 20 May 2024 12:27:20 +0200 Subject: [PATCH 8/8] names updated --- .../workflows/Build-And-Test-Component-Reuse-Case.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/Build-And-Test-Component-Reuse-Case.yml b/.github/workflows/Build-And-Test-Component-Reuse-Case.yml index 5425b74..9d9834d 100644 --- a/.github/workflows/Build-And-Test-Component-Reuse-Case.yml +++ b/.github/workflows/Build-And-Test-Component-Reuse-Case.yml @@ -17,7 +17,7 @@ on: jobs: hello-world-linux-reuse: - name: "Hello-World Linux" + name: "Hello-World Linux Reuse" runs-on: ubuntu-latest steps: - name: 📚 Checkout @@ -37,7 +37,7 @@ jobs: WORKING-DIR: ./components/ hello-world-mac-reuse: - name: "Hello-World Mac" + name: "Hello-World Mac Reuse" runs-on: macos-latest steps: - name: 📚 Checkout @@ -57,7 +57,7 @@ jobs: WORKING-DIR: ./components/ hello-world-windows-reuse: - name: "Hello-World Windows" + name: "Hello-World Windows Reuse" runs-on: windows-latest steps: - name: 📚 Checkout @@ -76,12 +76,12 @@ jobs: VARIANT_TYPE: windows WORKING-DIR: ./components/ - security-scan: + security-scan-reuse: needs: - hello-world-linux - hello-world-mac - hello-world-windows - name: "Security Scan" + name: "Security Scan Reuse" runs-on: ubuntu-latest steps: - name: 📚 Checkout