diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e6a508..6da04be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,7 +56,7 @@ jobs: id: test-action uses: ./ with: - file_path: ../src/ + project_path: ../src/ - name: Print Output Summary id: output-summary diff --git a/TODO.md b/TODO.md deleted file mode 100644 index eebef16..0000000 --- a/TODO.md +++ /dev/null @@ -1,8 +0,0 @@ -# TODO - -- [x] add unit tests -- [x] update action.yml descriptions -- [x] update README.md -- [x] add more examples -- [x] add release workflow -- [ ] refactor file_path to project_path diff --git a/__tests__/fta.test.ts b/__tests__/fta.test.ts index 606802e..a0cf04f 100644 --- a/__tests__/fta.test.ts +++ b/__tests__/fta.test.ts @@ -6,17 +6,17 @@ import * as fta from '../src/fta' import { expect } from '@jest/globals' describe('wait.ts', () => { - it('throws on invalid file_path', async () => { - const file_path = '' - await expect(fta.run(file_path)).rejects.toThrow( - 'Param `file_path` does not exist' + it('throws on invalid project_path', async () => { + const project_path = '' + await expect(fta.run(project_path)).rejects.toThrow( + 'Param `project_path` does not exist' ) }) - it('throws on non-existent file_path', async () => { - const file_path = 'non-existent-file' - await expect(fta.run(file_path)).rejects.toThrow( - 'Param `file_path` does not exist' + it('throws on non-existent project_path', async () => { + const project_path = 'non-existent-file' + await expect(fta.run(project_path)).rejects.toThrow( + 'Param `project_path` does not exist' ) }) }) diff --git a/action.yml b/action.yml index 9df7b7f..e0ca04d 100644 --- a/action.yml +++ b/action.yml @@ -17,7 +17,7 @@ branding: # Define your inputs here inputs: - file_path: + project_path: description: 'Path to the project to analyze' required: true default: './src/' diff --git a/dist/fta/run.d.ts b/dist/fta/run.d.ts index e04fb34..cf2af09 100644 --- a/dist/fta/run.d.ts +++ b/dist/fta/run.d.ts @@ -2,10 +2,10 @@ import { ActionOptions, ActionOutput } from './types'; /** * Run Fast TypeScript Analysis (FTA) on a file * @description wrap the fta-cli package to run the fta command - * @param {string} file_path - path to the file to analyze + * @param {string} project_path - path to the file to analyze * @param {string} config_path - path to the config file * @param {string} output_path - path to the output file * @param {Partial} options - options to override the config file * @returns {Promise} - the output of the fta command **/ -export declare function run(file_path?: string, config_path?: string, output_path?: string, options?: Partial | null): Promise; +export declare function run(project_path?: string, config_path?: string, output_path?: string, options?: Partial | null): Promise; diff --git a/dist/index.js b/dist/index.js index 292eb90..250d2de 100644 --- a/dist/index.js +++ b/dist/index.js @@ -24944,15 +24944,15 @@ const output_1 = __nccwpck_require__(9599); /** * Run Fast TypeScript Analysis (FTA) on a file * @description wrap the fta-cli package to run the fta command - * @param {string} file_path - path to the file to analyze + * @param {string} project_path - path to the file to analyze * @param {string} config_path - path to the config file * @param {string} output_path - path to the output file * @param {Partial} options - options to override the config file * @returns {Promise} - the output of the fta command **/ -async function run(file_path, config_path, output_path, options = null) { - if (!file_path) { - file_path = options_1.defaultInput.filePath; +async function run(project_path, config_path, output_path, options = null) { + if (!project_path) { + project_path = options_1.defaultInput.filePath; } if (!config_path) { config_path = options_1.defaultInput.configPath; @@ -24960,8 +24960,8 @@ async function run(file_path, config_path, output_path, options = null) { if (!output_path) { output_path = options_1.defaultInput.outputPath; } - if (!fs_1.default.existsSync(path_1.default.join(__dirname, file_path))) - throw new Error('Param `file_path` does not exist'); + if (!fs_1.default.existsSync(path_1.default.join(__dirname, project_path))) + throw new Error('Param `project_path` does not exist'); // use --format over --json shorthand fta cli cmd if (options?.json && options?.format !== 'json') { options.format = 'json'; @@ -25065,7 +25065,7 @@ async function run(file_path, config_path, output_path, options = null) { // details is the output of the fta command with the format option // details are also saved to a file in the github action const configFile = path_1.default.join(__dirname, config_1.TMP_CONFIG_FILE); - const filePath = path_1.default.join(__dirname, file_path); + const filePath = path_1.default.join(__dirname, project_path); const details = (0, child_process_1.execSync)(`npm exec --package=fta-cli -c 'fta ${filePath} --config-path ${configFile} --format ${mappedOptions.format}'`).toString(); // summary is the output of the fta command with the table format option // to have a quick look at the results @@ -25170,7 +25170,7 @@ const fta = __importStar(__nccwpck_require__(3607)); */ async function run() { try { - const file_path = core.getInput('file_path'); + const project_path = core.getInput('project_path'); const config_path = core.getInput('config_path'); const output_path = core.getInput('output_path'); // fta options @@ -25185,7 +25185,7 @@ async function run() { const extensions = core.getInput('extensions'); // Debug logs are only output if the `ACTIONS_STEP_DEBUG` secret is true if (process.env.ACTIONS_STEP_DEBUG === 'true') { - core.debug(`Input 'file_path' is: ${file_path}`); + core.debug(`Input 'project_path' is: ${project_path}`); core.debug(`Input 'config_path' is: ${config_path}`); core.debug(`Input 'output_path' is: ${output_path}`); // fta options @@ -25201,7 +25201,7 @@ async function run() { // Log the current timestamp, wait, then log the new timestamp core.debug(new Date().toTimeString()); } - const output = await fta.run(file_path, config_path, output_path, { + const output = await fta.run(project_path, config_path, output_path, { format, json, outputLimit: output_limit, diff --git a/src/fta/run.test.ts b/src/fta/run.test.ts index e029fd2..5d267e9 100644 --- a/src/fta/run.test.ts +++ b/src/fta/run.test.ts @@ -75,10 +75,10 @@ describe('run function', () => { expect(result).toHaveProperty('summary') }) - it('should throw an error if file_path does not exist', async () => { + it('should throw an error if project_path does not exist', async () => { mockFsExistsSync.mockReturnValueOnce(false) - await expect(run()).rejects.toThrow('Param `file_path` does not exist') + await expect(run()).rejects.toThrow('Param `project_path` does not exist') }) it('should throw an error if config_path does not exist', async () => { diff --git a/src/fta/run.ts b/src/fta/run.ts index a63d8f3..bbee220 100644 --- a/src/fta/run.ts +++ b/src/fta/run.ts @@ -14,20 +14,20 @@ import { writeOutput } from './output' /** * Run Fast TypeScript Analysis (FTA) on a file * @description wrap the fta-cli package to run the fta command - * @param {string} file_path - path to the file to analyze + * @param {string} project_path - path to the file to analyze * @param {string} config_path - path to the config file * @param {string} output_path - path to the output file * @param {Partial} options - options to override the config file * @returns {Promise} - the output of the fta command **/ export async function run( - file_path?: string, + project_path?: string, config_path?: string, output_path?: string, options: Partial | null = null ): Promise { - if (!file_path) { - file_path = defaultInput.filePath + if (!project_path) { + project_path = defaultInput.filePath } if (!config_path) { config_path = defaultInput.configPath @@ -36,8 +36,8 @@ export async function run( output_path = defaultInput.outputPath } - if (!fs.existsSync(path.join(__dirname, file_path))) - throw new Error('Param `file_path` does not exist') + if (!fs.existsSync(path.join(__dirname, project_path))) + throw new Error('Param `project_path` does not exist') // use --format over --json shorthand fta cli cmd if (options?.json && options?.format !== 'json') { @@ -147,7 +147,7 @@ export async function run( // details is the output of the fta command with the format option // details are also saved to a file in the github action const configFile = path.join(__dirname, TMP_CONFIG_FILE) - const filePath = path.join(__dirname, file_path) + const filePath = path.join(__dirname, project_path) const details = execSync( `npm exec --package=fta-cli -c 'fta ${filePath} --config-path ${configFile} --format ${mappedOptions.format}'` ).toString() diff --git a/src/main.ts b/src/main.ts index 8887abd..d3f1e62 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,7 +6,7 @@ import * as fta from './fta' */ export async function run(): Promise { try { - const file_path: string = core.getInput('file_path') + const project_path: string = core.getInput('project_path') const config_path: string = core.getInput('config_path') const output_path: string = core.getInput('output_path') // fta options @@ -22,7 +22,7 @@ export async function run(): Promise { // Debug logs are only output if the `ACTIONS_STEP_DEBUG` secret is true if (process.env.ACTIONS_STEP_DEBUG === 'true') { - core.debug(`Input 'file_path' is: ${file_path}`) + core.debug(`Input 'project_path' is: ${project_path}`) core.debug(`Input 'config_path' is: ${config_path}`) core.debug(`Input 'output_path' is: ${output_path}`) // fta options @@ -38,7 +38,7 @@ export async function run(): Promise { // Log the current timestamp, wait, then log the new timestamp core.debug(new Date().toTimeString()) } - const output = await fta.run(file_path, config_path, output_path, { + const output = await fta.run(project_path, config_path, output_path, { format, json, outputLimit: output_limit,