Skip to content

Commit 24904ae

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): OpenAPI spec update via Stainless API (#400)
1 parent 55335d1 commit 24904ae

File tree

13 files changed

+73
-76
lines changed

13 files changed

+73
-76
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 1259
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-db82dd88520065dc6282d55691c415867cb115705691731e45ed70570bf0b2c4.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-91fa0a3e121d10cf3cb049619ba9e0cf6116612ec2ef75672fcef911ad371eaf.yml

bin/check-test-server

Lines changed: 0 additions & 50 deletions
This file was deleted.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
"private": false,
1616
"scripts": {
1717
"test": "./scripts/test",
18-
"build": "bash ./build",
18+
"build": "./scripts/build",
1919
"prepack": "echo 'to pack, run yarn build && (cd dist; yarn pack)' && exit 1",
2020
"prepublishOnly": "echo 'to publish, run yarn build && (cd dist; yarn publish)' && exit 1",
2121
"format": "prettier --write --cache --cache-strategy metadata . !dist",
22-
"prepare": "if ./scripts/check-is-in-git-install.sh; then npm run build; fi",
22+
"prepare": "if ./scripts/utils/check-is-in-git-install.sh; then ./scripts/build; fi",
2323
"tsn": "ts-node -r tsconfig-paths/register",
24-
"lint": "eslint --ext ts,js .",
24+
"lint": "./scripts/lint",
2525
"fix": "eslint --fix --ext ts,js ."
2626
},
2727
"dependencies": {

scripts/bootstrap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
cd "$(dirname "$0")/.."
6+
7+
PACKAGE_MANAGER=$(command -v yarn >/dev/null 2>&1 && echo "yarn" || echo "npm")
8+
9+
$PACKAGE_MANAGER install

build renamed to scripts/build

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/usr/bin/env bash
2+
23
set -exuo pipefail
34

4-
node scripts/check-version.cjs
5+
cd "$(dirname "$0")/.."
6+
7+
node scripts/utils/check-version.cjs
58

69
# Build into dist and will publish the package from there,
710
# so that src/resources/foo.ts becomes <package root>/resources/foo.js
@@ -22,7 +25,7 @@ if [ -e "bin/cli" ]; then
2225
fi
2326
# this converts the export map paths for the dist directory
2427
# and does a few other minor things
25-
node scripts/make-dist-package-json.cjs > dist/package.json
28+
node scripts/utils/make-dist-package-json.cjs > dist/package.json
2629

2730
# build to .js/.mjs/.d.ts files
2831
npm exec tsc-multi
@@ -32,22 +35,22 @@ cp src/_shims/auto/*.{d.ts,js,mjs} dist/_shims/auto
3235
# we need to add exports = module.exports = Cloudflare Node to index.js;
3336
# No way to get that from index.ts because it would cause compile errors
3437
# when building .mjs
35-
node scripts/fix-index-exports.cjs
38+
node scripts/utils/fix-index-exports.cjs
3639
# with "moduleResolution": "nodenext", if ESM resolves to index.d.ts,
3740
# it'll have TS errors on the default import. But if it resolves to
3841
# index.d.mts the default import will work (even though both files have
3942
# the same export default statement)
4043
cp dist/index.d.ts dist/index.d.mts
4144
cp tsconfig.dist-src.json dist/src/tsconfig.json
4245

43-
node scripts/postprocess-files.cjs
46+
node scripts/utils/postprocess-files.cjs
4447

4548
# make sure that nothing crashes when we require the output CJS or
4649
# import the output ESM
4750
(cd dist && node -e 'require("cloudflare")')
4851
(cd dist && node -e 'import("cloudflare")' --input-type=module)
4952

50-
if command -v deno &> /dev/null && [ -e ./build-deno ]
53+
if command -v deno &> /dev/null && [ -e ./scripts/build-deno ]
5154
then
52-
./build-deno
55+
./scripts/build-deno
5356
fi

scripts/lint

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
cd "$(dirname "$0")/.."
6+
7+
./node_modules/.bin/eslint --ext ts,js .

scripts/mock

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/usr/bin/env bash
22

3-
if [ -z "$1" ]; then
3+
set -e
4+
5+
cd "$(dirname "$0")/.."
6+
7+
if [ -n "$1" ]; then
48
URL="$1"
59
shift
610
else
@@ -15,7 +19,7 @@ fi
1519

1620
# Run prism mock on the given spec
1721
if [ "$1" == "--daemon" ]; then
18-
npm exec prism mock "$URL" &> .prism.log &
22+
npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL" &> .prism.log &
1923

2024
# Wait for server to come online
2125
while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do
@@ -30,5 +34,5 @@ if [ "$1" == "--daemon" ]; then
3034

3135
echo
3236
else
33-
npm exec prism mock "$URL"
37+
npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL"
3438
fi

scripts/test

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
#!/usr/bin/env bash
22

3+
set -e
4+
5+
cd "$(dirname "$0")/.."
6+
7+
RED='\033[0;31m'
8+
GREEN='\033[0;32m'
9+
YELLOW='\033[0;33m'
10+
NC='\033[0m' # No Color
11+
312
function prism_is_running() {
413
curl --silent "http://localhost:4010" >/dev/null 2>&1
514
}
@@ -12,17 +21,32 @@ kill_server_on_port() {
1221
fi
1322
}
1423

15-
if ! prism_is_running; then
24+
function is_overriding_api_base_url() {
25+
[ -n "$TEST_API_BASE_URL" ]
26+
}
27+
28+
if ! is_overriding_api_base_url && ! prism_is_running ; then
1629
# When we exit this script, make sure to kill the background mock server process
1730
trap 'kill_server_on_port 4010' EXIT
1831

1932
# Start the dev server
20-
./scripts/mock --daemon
33+
./scripts/mock --daemon &> /dev/null
34+
fi
2135

22-
# Sanity check and print a nice error message
23-
if ! ./bin/check-test-server; then
24-
exit
25-
fi
36+
if ! prism_is_running ; then
37+
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server"
38+
echo -e "running against your OpenAPI spec."
39+
echo
40+
echo -e "To run the server, pass in the path or url of your OpenAPI"
41+
echo -e "spec to the prism command:"
42+
echo
43+
echo -e " \$ ${YELLOW}npm exec prism mock path/to/your.openapi.yml${NC}"
44+
echo
45+
46+
exit 1
47+
else
48+
echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}"
49+
echo
2650
fi
2751

2852
# Run tests
File renamed without changes.

scripts/check-version.cjs renamed to scripts/utils/check-version.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ const fs = require('fs');
22
const path = require('path');
33

44
const main = () => {
5-
const pkg = require('../package.json');
5+
const pkg = require('../../package.json');
66
const version = pkg['version'];
77
if (!version) throw 'The version property is not set in the package.json file';
88
if (typeof version !== 'string') {
99
throw `Unexpected type for the package.json version field; got ${typeof version}, expected string`;
1010
}
1111

12-
const versionFile = path.resolve(__dirname, '..', 'src', 'version.ts');
12+
const versionFile = path.resolve(__dirname, '..', '..', 'src', 'version.ts');
1313
const contents = fs.readFileSync(versionFile, 'utf8');
1414
const output = contents.replace(/(export const VERSION = ')(.*)(')/g, `$1${version}$3`);
1515
fs.writeFileSync(versionFile, output);

0 commit comments

Comments
 (0)