From ea10de76bd390fa599858d1ea24685da9cac0edb Mon Sep 17 00:00:00 2001 From: nothingbutsyntaxerror Date: Thu, 18 Dec 2025 20:18:01 +0000 Subject: [PATCH 1/8] fix: grammar error in CLI unknown command message --- src/cli/unknown.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/unknown.ts b/src/cli/unknown.ts index 6f468ba..668521e 100644 --- a/src/cli/unknown.ts +++ b/src/cli/unknown.ts @@ -8,7 +8,7 @@ export const handleUnknownArgs = (): void => { if (!(flags.length === 1 && (flags[0] === '--help' || flags[0] === '-h'))) { const message = `${flags.join( ', ' - )} does not exists as a valid command.`; + )} does not exist as a valid command.`; warn(message); } From 0ba854428b261fd45e63bd9f790bfe3fd4e31235 Mon Sep 17 00:00:00 2001 From: nothingbutsyntaxerror Date: Thu, 18 Dec 2025 21:33:27 +0000 Subject: [PATCH 2/8] feat: enable --confDir argument and add integration tests --- package-lock.json | 2 +- package.json | 2 +- src/help.ts | 2 +- src/test/confDir.spec.ts | 41 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 src/test/confDir.spec.ts diff --git a/package-lock.json b/package-lock.json index 02928e6..3525bf7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8941,4 +8941,4 @@ "integrity": "sha512-UzIwO92D0dSFwIRyyqAfRXICITLjF0IP8tRbEK/un7adirMssWZx8xF/1hZNE7t61knWZ+lhEuUvxlu2MO8qqA==" } } -} \ No newline at end of file +} diff --git a/package.json b/package.json index 4b011ed..32c5ec4 100644 --- a/package.json +++ b/package.json @@ -128,4 +128,4 @@ "prettier": "^2.1.2", "typescript": "^4.3.2" } -} \ No newline at end of file +} diff --git a/src/help.ts b/src/help.ts index e1b0775..a33dab1 100644 --- a/src/help.ts +++ b/src/help.ts @@ -23,7 +23,7 @@ Options -l --logout nothing Accepts boolean value: use it in order to expire your current session. -r --listPlans nothing Accepts boolean value: list all the plans that are offered in your account using it. -u --serverUrl string Change the base URL for the FaaS. - -c --confDir string (TODO) Overwrite the default configuration directory.`; + -c --confDir string Overwrite the default configuration directory.`; export const printHelp = (): void => { console.log(helpText); diff --git a/src/test/confDir.spec.ts b/src/test/confDir.spec.ts new file mode 100644 index 0000000..38c8418 --- /dev/null +++ b/src/test/confDir.spec.ts @@ -0,0 +1,41 @@ +import { strictEqual } from 'assert'; +import { existsSync, mkdirSync, rmdirSync, writeFileSync } from 'fs'; +import { join } from 'path'; +import { startup } from '../startup'; + +describe('Configuration Directory Logic', () => { + // 1. Create a temporary folder path + const customPath = join(process.cwd(), 'test-custom-config'); + const configFilePath = join(customPath, 'config.ini'); + + const fakeToken = 'test-token-12345'; + + // Write in INI format (key=value) + const iniContent = `token=${fakeToken}`; + + before(() => { + if (!existsSync(customPath)) { + mkdirSync(customPath); + } + // Write the INI file + writeFileSync(configFilePath, iniContent, 'utf8'); + }); + + after(() => { + if (existsSync(customPath)) { + // Cleanup + rmdirSync(customPath, { recursive: true }); + } + }); + + it('should load config from a custom directory via --confDir', async () => { + // Run startup. It should find config.ini and use the token inside. + const config = await startup(customPath); + + strictEqual( + config.token, + fakeToken, + 'The token loaded does not match the custom config file' + ); + }); +}); From 2e47685da9ad13efc1d7f39486f904b5f6a00ca0 Mon Sep 17 00:00:00 2001 From: nothingbutsyntaxerror Date: Thu, 18 Dec 2025 21:45:04 +0000 Subject: [PATCH 3/8] style: manual fix for linting errors --- src/test/cli.integration.spec.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/test/cli.integration.spec.ts b/src/test/cli.integration.spec.ts index 6063f99..c9d4111 100644 --- a/src/test/cli.integration.spec.ts +++ b/src/test/cli.integration.spec.ts @@ -2,13 +2,13 @@ import { fail, notStrictEqual, ok, strictEqual } from 'assert'; import { join } from 'path'; import { load } from '../config'; import { - checkEnvVars, - clearCache, - createTmpDirectory, - deleted, - deployed, - keys, - runCLI + checkEnvVars, + clearCache, + createTmpDirectory, + deleted, + deployed, + keys, + runCLI } from './cli'; describe('Integration CLI (Deploy)', function () { @@ -92,9 +92,7 @@ describe('Integration CLI (Deploy)', function () { )}` ); } catch (err) { - ok( - String(err) === '! --yeet does not exists as a valid command.\n' - ); + ok(String(err) === '! --yeet does not exists as a valid command.\n'); } }); From 876f16b631f4fce48bc335f46b0ef01b7555a5c9 Mon Sep 17 00:00:00 2001 From: nothingbutsyntaxerror Date: Thu, 18 Dec 2025 21:50:47 +0000 Subject: [PATCH 4/8] style: fix indentation (tabs vs spaces) --- src/test/cli.integration.spec.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/test/cli.integration.spec.ts b/src/test/cli.integration.spec.ts index c9d4111..9bd226d 100644 --- a/src/test/cli.integration.spec.ts +++ b/src/test/cli.integration.spec.ts @@ -2,13 +2,13 @@ import { fail, notStrictEqual, ok, strictEqual } from 'assert'; import { join } from 'path'; import { load } from '../config'; import { - checkEnvVars, - clearCache, - createTmpDirectory, - deleted, - deployed, - keys, - runCLI + checkEnvVars, + clearCache, + createTmpDirectory, + deleted, + deployed, + keys, + runCLI } from './cli'; describe('Integration CLI (Deploy)', function () { From 67488a6f691663189d7ef3f820d514618ab07c1b Mon Sep 17 00:00:00 2001 From: nothingbutsyntaxerror Date: Thu, 18 Dec 2025 21:56:56 +0000 Subject: [PATCH 5/8] style: final indentation fix --- src/test/cli.integration.spec.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test/cli.integration.spec.ts b/src/test/cli.integration.spec.ts index 9bd226d..6063f99 100644 --- a/src/test/cli.integration.spec.ts +++ b/src/test/cli.integration.spec.ts @@ -92,7 +92,9 @@ describe('Integration CLI (Deploy)', function () { )}` ); } catch (err) { - ok(String(err) === '! --yeet does not exists as a valid command.\n'); + ok( + String(err) === '! --yeet does not exists as a valid command.\n' + ); } }); From 104c1d7bc37def695fb54031783b34a31ba4d617 Mon Sep 17 00:00:00 2001 From: nothingbutsyntaxerror Date: Thu, 18 Dec 2025 22:04:31 +0000 Subject: [PATCH 6/8] style: apply npm run fix --- .vscode/settings.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index af451c9..f24c653 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,5 +11,8 @@ "strings": "on", "other": "on" }, - "editor.suggestOnTriggerCharacters": true + "editor.suggestOnTriggerCharacters": true, + "[typescript]": { + "editor.defaultFormatter": "vscode.typescript-language-features" + } } From f0bd65558371cac9e85961005f83510a2ae4b1a9 Mon Sep 17 00:00:00 2001 From: nothingbutsyntaxerror Date: Thu, 18 Dec 2025 22:09:44 +0000 Subject: [PATCH 7/8] chore: revert integration test formatting to upstream --- src/test/cli.integration.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/cli.integration.spec.ts b/src/test/cli.integration.spec.ts index 6063f99..14a0525 100644 --- a/src/test/cli.integration.spec.ts +++ b/src/test/cli.integration.spec.ts @@ -93,7 +93,7 @@ describe('Integration CLI (Deploy)', function () { ); } catch (err) { ok( - String(err) === '! --yeet does not exists as a valid command.\n' + String(err) === '! --yeet does not exist as a valid command.\n' ); } }); From ba1ba28d653940af047fd47e1ddf88dc363a1115 Mon Sep 17 00:00:00 2001 From: nothingbutsyntaxerror Date: Fri, 19 Dec 2025 08:54:43 +0000 Subject: [PATCH 8/8] chore: disable prettier for legacy integration tests --- src/test/cli.integration.spec.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/cli.integration.spec.ts b/src/test/cli.integration.spec.ts index 14a0525..7775225 100644 --- a/src/test/cli.integration.spec.ts +++ b/src/test/cli.integration.spec.ts @@ -1,3 +1,5 @@ +/* eslint-disable prettier/prettier */ + import { fail, notStrictEqual, ok, strictEqual } from 'assert'; import { join } from 'path'; import { load } from '../config';