Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
pull_request:
push:
branches:
- main

jobs:
test-and-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test

- name: Build
run: npm run build
3 changes: 3 additions & 0 deletions apim-github-action-demo.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"folders": [
{
"path": "."
},
{
"path": "../apim-github-action-demo-demo"
}
],
"settings": {}
Expand Down
36 changes: 25 additions & 11 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -687,9 +687,33 @@ function resolvePointer(root, pointer) {

module.exports = {
buildProjectFromOpenApi,
normalizeKeyStr,
selectOperations,
pickBaseServer,
mergeProject,
};


/***/ }),

/***/ 880:
/***/ ((module) => {



function parseBoolean(value, defaultValue) {
if (value === "") return defaultValue;
return ["1", "true", "yes", "on"].includes(value.toLowerCase());
}

function summarizeDocument(document) {
if (!document || typeof document !== "object") return "<non-object>";
const topKeys = Object.keys(document).slice(0, 12);
return `keys=${topKeys.join(",")}`;
}

module.exports = { parseBoolean, summarizeDocument };

/***/ })

/******/ });
Expand Down Expand Up @@ -742,6 +766,7 @@ const os = __nccwpck_require__(37);
const { execFile } = __nccwpck_require__(81);
const { promisify } = __nccwpck_require__(837);
const { buildProjectFromOpenApi } = __nccwpck_require__(465);
const { parseBoolean, summarizeDocument } = __nccwpck_require__(880);

const execFileAsync = promisify(execFile);

Expand All @@ -754,11 +779,6 @@ function getInput(name, options = {}) {
return value || "";
}

function parseBoolean(value, defaultValue) {
if (value === "") return defaultValue;
return ["1", "true", "yes", "on"].includes(value.toLowerCase());
}

function fileExists(filePath) {
try {
fs.accessSync(filePath, fs.constants.F_OK);
Expand Down Expand Up @@ -961,12 +981,6 @@ async function uploadDocument(document, token, endpoint) {
return response.text();
}

function summarizeDocument(document) {
if (!document || typeof document !== "object") return "<non-object>";
const topKeys = Object.keys(document).slice(0, 12);
return `keys=${topKeys.join(",")}`;
}

async function run() {
const fileInput = getInput("file");
const templateInput = getInput("template");
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"type": "commonjs",
"main": "dist/index.js",
"scripts": {
"build": "ncc build src/index.js -o dist"
"build": "ncc build src/index.js -o dist",
"test": "node --test test/openapi.test.js test/utils.test.js"
},
"devDependencies": {
"@vercel/ncc": "0.38.1"
Expand Down
12 changes: 1 addition & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const os = require("os");
const { execFile } = require("child_process");
const { promisify } = require("util");
const { buildProjectFromOpenApi } = require("./openapi");
const { parseBoolean, summarizeDocument } = require("./utils");

const execFileAsync = promisify(execFile);

Expand All @@ -19,11 +20,6 @@ function getInput(name, options = {}) {
return value || "";
}

function parseBoolean(value, defaultValue) {
if (value === "") return defaultValue;
return ["1", "true", "yes", "on"].includes(value.toLowerCase());
}

function fileExists(filePath) {
try {
fs.accessSync(filePath, fs.constants.F_OK);
Expand Down Expand Up @@ -226,12 +222,6 @@ async function uploadDocument(document, token, endpoint) {
return response.text();
}

function summarizeDocument(document) {
if (!document || typeof document !== "object") return "<non-object>";
const topKeys = Object.keys(document).slice(0, 12);
return `keys=${topKeys.join(",")}`;
}

async function run() {
const fileInput = getInput("file");
const templateInput = getInput("template");
Expand Down
4 changes: 4 additions & 0 deletions src/openapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -638,4 +638,8 @@ function resolvePointer(root, pointer) {

module.exports = {
buildProjectFromOpenApi,
normalizeKeyStr,
selectOperations,
pickBaseServer,
mergeProject,
};
14 changes: 14 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use strict";

function parseBoolean(value, defaultValue) {
if (value === "") return defaultValue;
return ["1", "true", "yes", "on"].includes(value.toLowerCase());
}

function summarizeDocument(document) {
if (!document || typeof document !== "object") return "<non-object>";
const topKeys = Object.keys(document).slice(0, 12);
return `keys=${topKeys.join(",")}`;
}

module.exports = { parseBoolean, summarizeDocument };
Loading
Loading