Merge branch 'master' into develop

This commit is contained in:
olivermrbl
2022-08-29 15:47:17 +02:00
114 changed files with 1141 additions and 1099 deletions

View File

@@ -3,7 +3,10 @@
const fs = require("fs")
const OAS = require("oas-normalize")
const swaggerInline = require("swagger-inline")
const { exec } = require("child_process")
const { exec } = require("child_process");
const { exit } = require("process");
const isDryRun = process.argv.indexOf('--dry-run') !== -1;
// Storefront API
swaggerInline(
@@ -16,7 +19,9 @@ swaggerInline(
oas
.validate(true)
.then(() => {
fs.writeFileSync("./docs/api/store-spec3.json", gen)
if (!isDryRun) {
fs.writeFileSync("./docs/api/store-spec3.json", gen)
}
})
.catch((err) => {
console.log("Error in store")
@@ -32,13 +37,17 @@ swaggerInline(
format: "yaml",
}
).then((gen) => {
fs.writeFileSync("./docs/api/store-spec3.yaml", gen)
exec("rm -rf docs/api/store/ && yarn run -- redocly split docs/api/store-spec3.yaml --outDir=docs/api/store/", (error, stdout, stderr) => {
if (error) {
throw new Error(`error: ${error.message}`)
}
console.log(`${stderr || stdout}`);
});
if (!isDryRun) {
fs.writeFileSync("./docs/api/store-spec3.yaml", gen)
exec("rm -rf docs/api/store/ && yarn run -- redocly split docs/api/store-spec3.yaml --outDir=docs/api/store/", (error, stdout, stderr) => {
if (error) {
throw new Error(`error: ${error.message}`)
}
console.log(`${stderr || stdout}`);
});
} else {
console.log('No errors occurred while generating Store API Reference');
}
})
// Admin API
@@ -52,7 +61,9 @@ swaggerInline(
oas
.validate(true)
.then(() => {
fs.writeFileSync("./docs/api/admin-spec3.json", gen)
if (!isDryRun) {
fs.writeFileSync("./docs/api/admin-spec3.json", gen)
}
})
.catch((err) => {
console.log("Error in admin")
@@ -68,12 +79,16 @@ swaggerInline(
format: "yaml",
}
).then((gen) => {
fs.writeFileSync("./docs/api/admin-spec3.yaml", gen)
exec("rm -rf docs/api/admin/ && yarn run -- redocly split docs/api/admin-spec3.yaml --outDir=docs/api/admin/", (error, stdout, stderr) => {
if (error) {
throw new Error(`error: ${error.message}`)
}
console.log(`${stderr || stdout}`);
return;
});
if (!isDryRun) {
fs.writeFileSync("./docs/api/admin-spec3.yaml", gen)
exec("rm -rf docs/api/admin/ && yarn run -- redocly split docs/api/admin-spec3.yaml --outDir=docs/api/admin/", (error, stdout, stderr) => {
if (error) {
throw new Error(`error: ${error.message}`)
}
console.log(`${stderr || stdout}`);
return;
});
} else {
console.log('No errors occurred while generating Admin API Reference');
}
})