Moving to path instead

This commit is contained in:
Julien Lengrand-Lambert
2023-03-09 17:12:03 +01:00
parent a5572e49cd
commit 0206814206
5 changed files with 25 additions and 33 deletions

View File

@@ -10,15 +10,10 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Get changed files in the test folder
id: changed-files-specific
uses: tj-actions/changed-files@v35
with:
files: samples/*.yml
- name: push-adyen-collections-to-postman-javascript-action
id: process
uses: jlengrand/push-adyen-collections-to-postman-javascript-action@main
with:
postman-key: ${{ secrets.POSTMAN_API_KEY }}
workspace-id: ${{ secrets.POSTMAN_WORKSPACE_ID }}
files-changed: ${{ steps.changed-files-specific.outputs.all_changed_files }}
path-to-process: samples/*.yml

View File

@@ -7,8 +7,8 @@ inputs:
workspace-id:
description: 'Postman Workspace ID'
required: true
files-changed:
description: 'Files changed'
path-to-process:
description: 'Path to process'
required: true
runs:
using: 'node16'

20
dist/index.js vendored
View File

@@ -2996,9 +2996,9 @@ function getNameOfApi(filepath){
* @returns {Promise<Array.<string>>} a promise containing a list of filenames with the given extension
*/
async function getFilesInFolder(filepath, extension){
return fs.promises.readdir(filepath).then((files) => {
return external_fs_.promises.readdir(filepath).then((files) => {
return files.filter((file) => {
return path.extname(file) === extension;
return external_path_.extname(file) === extension;
});
});
}
@@ -3087,20 +3087,22 @@ function _groupBy(xs, key) {
async function run() {
try {
const postmanApiKey = core.getInput('postman-key');
const filesChanged = core.getInput('files-changed');
const pathToProcess = core.getInput('path-to-process');
const workspaceId = core.getInput('workspace-id');
const time = runParameters(postmanApiKey, workspaceId, filesChanged);
core.setOutput("time", time);
runParameters(postmanApiKey, workspaceId, pathToProcess);
} catch (error) {
core.setFailed(error.message);
}
}
async function runParameters(postmanApiKey, workspaceId, filesToProcess){
async function runParameters(postmanApiKey, workspaceId, pathToProcess){
const filesToProcessAsList = await getFilesInFolder(pathToProcess, ".json");
const apiFilesWithPath = filesToProcessAsList.map((file) => { return `${pathToProcess}/${file}`; });
console.log(`Files to process : ${filesToProcess}`);
console.log(`Path to process : ${pathToProcess}`);
console.log(`Files to process : ${apiFilesWithPath}`);
console.log(`Getting workspace ${workspaceId}!`);
@@ -3111,11 +3113,9 @@ async function runParameters(postmanApiKey, workspaceId, filesToProcess){
console.log(JSON.stringify(workspace));
console.log("-----");
const collections = workspace.workspace.collections;
const filesToProcessAsList = filesToProcess.split(' ');
const apisToProcess = filenamesToSet(filesToProcessAsList);
const apisToProcess = filenamesToSet(apiFilesWithPath);
const apisToProcessStructures = apisToProcess.map((api) => {
console.log(`Processing ${api}`);

View File

@@ -5,20 +5,22 @@ import * as utils from "./utils.js";
async function run() {
try {
const postmanApiKey = core.getInput('postman-key');
const filesChanged = core.getInput('files-changed');
const pathToProcess = core.getInput('path-to-process');
const workspaceId = core.getInput('workspace-id');
const time = runParameters(postmanApiKey, workspaceId, filesChanged);
core.setOutput("time", time);
runParameters(postmanApiKey, workspaceId, pathToProcess);
} catch (error) {
core.setFailed(error.message);
}
}
export async function runParameters(postmanApiKey, workspaceId, filesToProcess){
export async function runParameters(postmanApiKey, workspaceId, pathToProcess){
const filesToProcessAsList = await utils.getFilesInFolder(pathToProcess, ".json");
const apiFilesWithPath = filesToProcessAsList.map((file) => { return `${pathToProcess}/${file}`; });
console.log(`Files to process : ${filesToProcess}`);
console.log(`Path to process : ${pathToProcess}`);
console.log(`Files to process : ${apiFilesWithPath}`);
console.log(`Getting workspace ${workspaceId}!`);
@@ -29,11 +31,9 @@ export async function runParameters(postmanApiKey, workspaceId, filesToProcess){
console.log(JSON.stringify(workspace));
console.log("-----");
const collections = workspace.workspace.collections;
const filesToProcessAsList = filesToProcess.split(' ');
const apisToProcess = utils.filenamesToSet(filesToProcessAsList);
const apisToProcess = utils.filenamesToSet(apiFilesWithPath);
const apisToProcessStructures = apisToProcess.map((api) => {
console.log(`Processing ${api}`);

View File

@@ -13,15 +13,12 @@ dotenv.config();
* @param {string} path the path to the folder containing the API files to process
* @returns {Promise<void>} a promise that resolves when the function is done
*/
async function localRun(path) {
const apiFiles = await utils.getFilesInFolder(path, ".json");
const apiFilesWithPath = apiFiles.map((file) => { return `${path}/${file}`; });
const apiFilesWithPathAsString = apiFilesWithPath.join(" ");
async function localRun(pathToProcess) {
const POSTMAN_API_KEY = process.env.POSTMAN_API_KEY;
const POSTMAN_WORKSPACE_ID = process.env.POSTMAN_WORKSPACE_ID;
runParameters(POSTMAN_API_KEY, POSTMAN_WORKSPACE_ID, apiFilesWithPathAsString);
await runParameters(POSTMAN_API_KEY, POSTMAN_WORKSPACE_ID, pathToProcess);
}
localRun("../adyen-postman/postman/")