From a99bf1bba3bf1dae6a33620db964dab0fccb0442 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 25 Nov 2021 18:13:14 +0000 Subject: [PATCH] Updating scripts to allow opening in the browser when generated. --- package.json | 1 + packages/server/package.json | 3 ++- packages/server/scripts/docs/generate.js | 7 ++++++- packages/server/yarn.lock | 22 ++++++++++++++-------- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index f863f3f440..e0b567ce59 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "build:docker:selfhost": "lerna run build:docker && cd hosting/scripts/linux/ && ./release-to-docker-hub.sh latest && cd -", "build:docker:develop": "node scripts/pinVersions && lerna run build:docker && cd hosting/scripts/linux/ && ./release-to-docker-hub.sh develop && cd -", "build:docker:airgap": "node hosting/scripts/airgapped/airgappedDockerBuild", + "build:docs": "lerna run build:docs", "release:helm": "./scripts/release_helm_chart.sh", "env:multi:enable": "lerna run env:multi:enable", "env:multi:disable": "lerna run env:multi:disable", diff --git a/packages/server/package.json b/packages/server/package.json index 7712c7c748..bc6de5c92f 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -15,6 +15,7 @@ "test:watch": "jest --watch", "predocker": "copyfiles -f ../client/dist/budibase-client.js ../client/manifest.json client", "build:docker": "yarn run predocker && docker build . -t app-service --label version=$BUDIBASE_RELEASE_VERSION", + "build:docs": "node ./scripts/docs/generate.js open", "run:docker": "node dist/index.js", "dev:stack:up": "node scripts/dev/manage.js up", "dev:stack:down": "node scripts/dev/manage.js down", @@ -106,7 +107,7 @@ "mssql": "6.2.3", "mysql2": "^2.3.1", "node-fetch": "2.6.0", - "open": "7.3.0", + "open": "^8.4.0", "pg": "8.5.1", "pino-pretty": "4.0.0", "posthog-node": "^1.1.4", diff --git a/packages/server/scripts/docs/generate.js b/packages/server/scripts/docs/generate.js index 3006e6cca6..8465f9afd6 100644 --- a/packages/server/scripts/docs/generate.js +++ b/packages/server/scripts/docs/generate.js @@ -2,6 +2,7 @@ const fs = require("fs") const { join } = require("path") const { createDoc } = require("apidoc") const packageJson = require("../../package.json") +const open = require("open") const config = { name: "Budibase API", @@ -10,6 +11,7 @@ const config = { title: "Budibase app service API", } +const shouldOpen = process.argv[2] const disallowed = [] function filter(parsedRouteFiles) { @@ -25,7 +27,7 @@ function filter(parsedRouteFiles) { } } -function generate() { +async function generate() { // start by writing a config file const configPath = join(__dirname, "config.json") fs.writeFileSync(configPath, JSON.stringify(config)) @@ -52,6 +54,9 @@ function generate() { } // delete the temporary config file fs.unlinkSync(configPath) + if (shouldOpen === "open") { + await open(join(assetsPath, "index.html"), { wait: false }) + } } generate() diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index 1686e38a40..32eabd7c4c 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -4529,6 +4529,11 @@ deferred-leveldown@~5.3.0: abstract-leveldown "~6.2.1" inherits "^2.0.3" +define-lazy-prop@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz#3f7ae421129bcaaac9bc74905c98a0009ec9ee7f" + integrity sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og== + define-properties@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" @@ -6698,7 +6703,7 @@ is-descriptor@^1.0.0, is-descriptor@^1.0.2: is-data-descriptor "^1.0.0" kind-of "^6.0.2" -is-docker@^2.0.0: +is-docker@^2.0.0, is-docker@^2.1.1: version "2.2.1" resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa" integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ== @@ -6952,7 +6957,7 @@ is-windows@^1.0.2: resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA== -is-wsl@^2.1.1: +is-wsl@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271" integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww== @@ -9429,13 +9434,14 @@ only@~0.0.2: resolved "https://registry.yarnpkg.com/only/-/only-0.0.2.tgz#2afde84d03e50b9a8edc444e30610a70295edfb4" integrity sha1-Kv3oTQPlC5qO3EROMGEKcCle37Q= -open@7.3.0: - version "7.3.0" - resolved "https://registry.yarnpkg.com/open/-/open-7.3.0.tgz#45461fdee46444f3645b6e14eb3ca94b82e1be69" - integrity sha512-mgLwQIx2F/ye9SmbrUkurZCnkoXyXyu9EbHtJZrICjVAJfyMArdHp3KkixGdZx1ZHFPNIwl0DDM1dFFqXbTLZw== +open@^8.4.0: + version "8.4.0" + resolved "https://registry.yarnpkg.com/open/-/open-8.4.0.tgz#345321ae18f8138f82565a910fdc6b39e8c244f8" + integrity sha512-XgFPPM+B28FtCCgSb9I+s9szOC1vZRSwgWsRUA5ylIxRTgKozqjOCrVOqGsYABPYK5qnfqClxZTFBa8PKt2v6Q== dependencies: - is-docker "^2.0.0" - is-wsl "^2.1.1" + define-lazy-prop "^2.0.0" + is-docker "^2.1.1" + is-wsl "^2.2.0" opencollective-postinstall@^2.0.0: version "2.0.3"