mirror of
https://github.com/jlengrand/push-adyen-collections-to-postman-javascript-action.git
synced 2026-03-10 00:31:23 +00:00
Moving to path instead
This commit is contained in:
7
.github/workflows/sampletest.yml
vendored
7
.github/workflows/sampletest.yml
vendored
@@ -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
|
||||
@@ -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'
|
||||
|
||||
22
dist/index.js
vendored
22
dist/index.js
vendored
@@ -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,21 +3087,23 @@ 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(`Path to process : ${pathToProcess}`);
|
||||
console.log(`Files to process : ${apiFilesWithPath}`);
|
||||
|
||||
console.log(`Files to process : ${filesToProcess}`);
|
||||
|
||||
console.log(`Getting workspace ${workspaceId}!`);
|
||||
|
||||
console.log("-----");
|
||||
@@ -3110,12 +3112,10 @@ 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}`);
|
||||
|
||||
18
index.js
18
index.js
@@ -5,21 +5,23 @@ 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(`Path to process : ${pathToProcess}`);
|
||||
console.log(`Files to process : ${apiFilesWithPath}`);
|
||||
|
||||
console.log(`Files to process : ${filesToProcess}`);
|
||||
|
||||
console.log(`Getting workspace ${workspaceId}!`);
|
||||
|
||||
console.log("-----");
|
||||
@@ -28,12 +30,10 @@ 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}`);
|
||||
|
||||
@@ -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/")
|
||||
|
||||
Reference in New Issue
Block a user