From 7f3ac23bfc6b5ef5849a9f52011f2610661f9d19 Mon Sep 17 00:00:00 2001 From: Renato Vicente Date: Sat, 11 May 2024 00:57:44 +0200 Subject: [PATCH] feat: update naming for config file --- .github/workflows/auto-label.yml | 5 ++++- src/__mock__/config/{config.json => auto-label.json} | 0 src/__mock__/config/{config.json5 => auto-label.json5} | 0 src/__mock__/config/{config.jsonc => auto-label.jsonc} | 0 src/domain/getConfigFile.ts | 2 +- src/domain/getLabelConfigs.spec.ts | 8 ++++---- src/domain/getLabelConfigs.ts | 2 +- 7 files changed, 10 insertions(+), 7 deletions(-) rename src/__mock__/config/{config.json => auto-label.json} (100%) rename src/__mock__/config/{config.json5 => auto-label.json5} (100%) rename src/__mock__/config/{config.jsonc => auto-label.jsonc} (100%) diff --git a/.github/workflows/auto-label.yml b/.github/workflows/auto-label.yml index 6c05670..623482e 100644 --- a/.github/workflows/auto-label.yml +++ b/.github/workflows/auto-label.yml @@ -10,7 +10,10 @@ jobs: - uses: actions/checkout@v4 with: sparse-checkout: | - .github/workflows/auto-label.json5 + .github/workflows/ + # .github/workflows/auto-label.json5 + # .github/workflows/auto-label.jsonc + # .github/workflows/auto-label.json sparse-checkout-cone-mode: false - uses: Renato66/auto-label@main with: diff --git a/src/__mock__/config/config.json b/src/__mock__/config/auto-label.json similarity index 100% rename from src/__mock__/config/config.json rename to src/__mock__/config/auto-label.json diff --git a/src/__mock__/config/config.json5 b/src/__mock__/config/auto-label.json5 similarity index 100% rename from src/__mock__/config/config.json5 rename to src/__mock__/config/auto-label.json5 diff --git a/src/__mock__/config/config.jsonc b/src/__mock__/config/auto-label.jsonc similarity index 100% rename from src/__mock__/config/config.jsonc rename to src/__mock__/config/auto-label.jsonc diff --git a/src/domain/getConfigFile.ts b/src/domain/getConfigFile.ts index 6f13de4..b1ae52c 100644 --- a/src/domain/getConfigFile.ts +++ b/src/domain/getConfigFile.ts @@ -11,7 +11,7 @@ export type Config = { export const getConfigFile = (): Config => { const configPath = getInput( 'configuration-file', - '.github/workflows/auto-label.json5' + '.github/workflows/' ) const labelsNotAllowed = getInput('labels-not-allowed', []) const defaultLabels = getInput('default-labels', []) diff --git a/src/domain/getLabelConfigs.spec.ts b/src/domain/getLabelConfigs.spec.ts index d433000..ab951f6 100644 --- a/src/domain/getLabelConfigs.spec.ts +++ b/src/domain/getLabelConfigs.spec.ts @@ -14,8 +14,8 @@ const defaultConfig = { describe('getLabelConfigs', () => { test('should return label configurations from a valid JSON folder path', () => { const options = [ - `${configurationPath}/valid/`, - `${configurationPath}/valid` + `${configurationPath}/`, + `${configurationPath}` ] options.forEach((elem) => { const result = getLabelConfigs(elem) @@ -24,12 +24,12 @@ describe('getLabelConfigs', () => { }) test('should return label configurations from a valid JSONC file path', () => { - const result = getLabelConfigs(`${configurationPath}/config.jsonc`) + const result = getLabelConfigs(`${configurationPath}/auto-label.jsonc`) expect(result).toEqual(defaultConfig) }) test('should return label configurations from a valid JSON5 file path', () => { - const result = getLabelConfigs(`${configurationPath}/config.json5`) + const result = getLabelConfigs(`${configurationPath}/auto-label.json5`) expect(result).toEqual(defaultConfig) }) diff --git a/src/domain/getLabelConfigs.ts b/src/domain/getLabelConfigs.ts index 4218a0e..ab19199 100644 --- a/src/domain/getLabelConfigs.ts +++ b/src/domain/getLabelConfigs.ts @@ -12,7 +12,7 @@ const getFilePath = (configurationPath: string): string | undefined => { return repoPath if (!configurationPath.includes('.json')) { const allFiles = fs.readdirSync(repoPath) - const files = allFiles.filter((elem) => jsonTypes.includes(elem)) + const files = allFiles.filter((elem) => jsonTypes.map(elem => `auto-label.${elem}`).includes(elem)) if (!files.length) return return `${repoPath}/${files[0]}`.replace('//', '/') }