mirror of
https://github.com/jlengrand/push-adyen-collections-to-postman-javascript-action.git
synced 2026-03-10 08:41: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
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 2
|
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
|
- name: push-adyen-collections-to-postman-javascript-action
|
||||||
id: process
|
id: process
|
||||||
uses: jlengrand/push-adyen-collections-to-postman-javascript-action@main
|
uses: jlengrand/push-adyen-collections-to-postman-javascript-action@main
|
||||||
with:
|
with:
|
||||||
postman-key: ${{ secrets.POSTMAN_API_KEY }}
|
postman-key: ${{ secrets.POSTMAN_API_KEY }}
|
||||||
workspace-id: ${{ secrets.POSTMAN_WORKSPACE_ID }}
|
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:
|
workspace-id:
|
||||||
description: 'Postman Workspace ID'
|
description: 'Postman Workspace ID'
|
||||||
required: true
|
required: true
|
||||||
files-changed:
|
path-to-process:
|
||||||
description: 'Files changed'
|
description: 'Path to process'
|
||||||
required: true
|
required: true
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node16'
|
||||||
|
|||||||
20
dist/index.js
vendored
20
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
|
* @returns {Promise<Array.<string>>} a promise containing a list of filenames with the given extension
|
||||||
*/
|
*/
|
||||||
async function getFilesInFolder(filepath, 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 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() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
const postmanApiKey = core.getInput('postman-key');
|
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 workspaceId = core.getInput('workspace-id');
|
||||||
|
|
||||||
const time = runParameters(postmanApiKey, workspaceId, filesChanged);
|
runParameters(postmanApiKey, workspaceId, pathToProcess);
|
||||||
core.setOutput("time", time);
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
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}!`);
|
console.log(`Getting workspace ${workspaceId}!`);
|
||||||
|
|
||||||
@@ -3111,11 +3113,9 @@ async function runParameters(postmanApiKey, workspaceId, filesToProcess){
|
|||||||
console.log(JSON.stringify(workspace));
|
console.log(JSON.stringify(workspace));
|
||||||
console.log("-----");
|
console.log("-----");
|
||||||
|
|
||||||
|
|
||||||
const collections = workspace.workspace.collections;
|
const collections = workspace.workspace.collections;
|
||||||
|
|
||||||
const filesToProcessAsList = filesToProcess.split(' ');
|
const apisToProcess = filenamesToSet(apiFilesWithPath);
|
||||||
const apisToProcess = filenamesToSet(filesToProcessAsList);
|
|
||||||
|
|
||||||
const apisToProcessStructures = apisToProcess.map((api) => {
|
const apisToProcessStructures = apisToProcess.map((api) => {
|
||||||
console.log(`Processing ${api}`);
|
console.log(`Processing ${api}`);
|
||||||
|
|||||||
16
index.js
16
index.js
@@ -5,20 +5,22 @@ import * as utils from "./utils.js";
|
|||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
const postmanApiKey = core.getInput('postman-key');
|
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 workspaceId = core.getInput('workspace-id');
|
||||||
|
|
||||||
const time = runParameters(postmanApiKey, workspaceId, filesChanged);
|
runParameters(postmanApiKey, workspaceId, pathToProcess);
|
||||||
core.setOutput("time", time);
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
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}!`);
|
console.log(`Getting workspace ${workspaceId}!`);
|
||||||
|
|
||||||
@@ -29,11 +31,9 @@ export async function runParameters(postmanApiKey, workspaceId, filesToProcess){
|
|||||||
console.log(JSON.stringify(workspace));
|
console.log(JSON.stringify(workspace));
|
||||||
console.log("-----");
|
console.log("-----");
|
||||||
|
|
||||||
|
|
||||||
const collections = workspace.workspace.collections;
|
const collections = workspace.workspace.collections;
|
||||||
|
|
||||||
const filesToProcessAsList = filesToProcess.split(' ');
|
const apisToProcess = utils.filenamesToSet(apiFilesWithPath);
|
||||||
const apisToProcess = utils.filenamesToSet(filesToProcessAsList);
|
|
||||||
|
|
||||||
const apisToProcessStructures = apisToProcess.map((api) => {
|
const apisToProcessStructures = apisToProcess.map((api) => {
|
||||||
console.log(`Processing ${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
|
* @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
|
* @returns {Promise<void>} a promise that resolves when the function is done
|
||||||
*/
|
*/
|
||||||
async function localRun(path) {
|
async function localRun(pathToProcess) {
|
||||||
const apiFiles = await utils.getFilesInFolder(path, ".json");
|
|
||||||
const apiFilesWithPath = apiFiles.map((file) => { return `${path}/${file}`; });
|
|
||||||
const apiFilesWithPathAsString = apiFilesWithPath.join(" ");
|
|
||||||
|
|
||||||
const POSTMAN_API_KEY = process.env.POSTMAN_API_KEY;
|
const POSTMAN_API_KEY = process.env.POSTMAN_API_KEY;
|
||||||
const POSTMAN_WORKSPACE_ID = process.env.POSTMAN_WORKSPACE_ID;
|
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/")
|
localRun("../adyen-postman/postman/")
|
||||||
|
|||||||
Reference in New Issue
Block a user