Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 3.2.0 #372

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
c21073a
feat(api): OpenAPI spec update via Stainless API (#371)
stainless-app[bot] Apr 24, 2024
647a603
feat(api): OpenAPI spec update via Stainless API (#373)
stainless-app[bot] Apr 24, 2024
fca6253
feat(api): update via SDK Studio (#374)
stainless-app[bot] Apr 25, 2024
2157ac0
feat(api): OpenAPI spec update via Stainless API (#375)
stainless-app[bot] Apr 26, 2024
1039d82
feat(api): OpenAPI spec update via Stainless API (#376)
stainless-app[bot] Apr 26, 2024
2b86d84
feat(api): OpenAPI spec update via Stainless API (#377)
stainless-app[bot] Apr 26, 2024
978f0f2
feat(api): OpenAPI spec update via Stainless API (#378)
stainless-app[bot] Apr 26, 2024
ccfef79
feat(api): OpenAPI spec update via Stainless API (#379)
stainless-app[bot] Apr 27, 2024
2747929
feat(api): OpenAPI spec update via Stainless API (#380)
stainless-app[bot] Apr 27, 2024
090e4dd
feat(api): update via SDK Studio (#381)
stainless-app[bot] Apr 29, 2024
3e8cfb1
feat(api): OpenAPI spec update via Stainless API (#382)
stainless-app[bot] Apr 29, 2024
07bb075
feat(api): OpenAPI spec update via Stainless API (#383)
stainless-app[bot] Apr 29, 2024
0d4a136
feat(api): OpenAPI spec update via Stainless API (#384)
stainless-app[bot] Apr 29, 2024
7c50283
feat(api): OpenAPI spec update via Stainless API (#385)
stainless-app[bot] Apr 29, 2024
8311d11
feat(api): OpenAPI spec update via Stainless API (#386)
stainless-app[bot] Apr 29, 2024
b9b9b02
feat(api): OpenAPI spec update via Stainless API (#387)
stainless-app[bot] Apr 29, 2024
2e6c806
feat(api): OpenAPI spec update via Stainless API (#388)
stainless-app[bot] Apr 29, 2024
3fc0ac5
feat(api): OpenAPI spec update via Stainless API (#389)
stainless-app[bot] Apr 29, 2024
760e64f
feat(api): OpenAPI spec update via Stainless API (#390)
stainless-app[bot] Apr 29, 2024
9073c8d
feat(api): OpenAPI spec update via Stainless API (#391)
stainless-app[bot] Apr 29, 2024
225612e
feat(api): OpenAPI spec update via Stainless API (#392)
stainless-app[bot] Apr 29, 2024
431d2a9
feat(api): update via SDK Studio (#393)
stainless-app[bot] Apr 29, 2024
d65f036
feat(api): OpenAPI spec update via Stainless API (#394)
stainless-app[bot] Apr 30, 2024
510511c
feat(api): OpenAPI spec update via Stainless API (#395)
stainless-app[bot] Apr 30, 2024
cd783f4
feat(api): OpenAPI spec update via Stainless API (#396)
stainless-app[bot] Apr 30, 2024
07cd648
feat(api): OpenAPI spec update via Stainless API (#397)
stainless-app[bot] Apr 30, 2024
cc4e28a
feat(api): OpenAPI spec update via Stainless API (#398)
stainless-app[bot] Apr 30, 2024
47c297a
feat(api): OpenAPI spec update via Stainless API (#399)
stainless-app[bot] Apr 30, 2024
dbae367
feat(api): OpenAPI spec update via Stainless API (#400)
stainless-app[bot] Apr 30, 2024
1f61499
feat(api): OpenAPI spec update via Stainless API (#401)
stainless-app[bot] Apr 30, 2024
489f647
feat(api): OpenAPI spec update via Stainless API (#402)
stainless-app[bot] Apr 30, 2024
2c689ad
feat(api): OpenAPI spec update via Stainless API (#403)
stainless-app[bot] Apr 30, 2024
9e7bbfe
feat(api): OpenAPI spec update via Stainless API (#404)
stainless-app[bot] Apr 30, 2024
c8d13ee
feat(api): OpenAPI spec update via Stainless API (#405)
stainless-app[bot] Apr 30, 2024
f5861eb
feat(api): OpenAPI spec update via Stainless API (#406)
stainless-app[bot] Apr 30, 2024
c7f67d4
feat(api): OpenAPI spec update via Stainless API (#407)
stainless-app[bot] Apr 30, 2024
02090a6
feat(api): OpenAPI spec update via Stainless API (#408)
stainless-app[bot] Apr 30, 2024
b03d041
feat(api): OpenAPI spec update via Stainless API (#409)
stainless-app[bot] Apr 30, 2024
bc63dee
feat(api): OpenAPI spec update via Stainless API (#410)
stainless-app[bot] Apr 30, 2024
67a0730
feat(api): OpenAPI spec update via Stainless API (#411)
stainless-app[bot] Apr 30, 2024
d31d5d6
chore: rebuild project due to oas spec rename (#412)
stainless-app[bot] Apr 30, 2024
ce41a47
feat(api): OpenAPI spec update via Stainless API (#414)
stainless-app[bot] Apr 30, 2024
8ad7042
feat(api): update via SDK Studio (#415)
stainless-app[bot] May 1, 2024
cdf4ee4
feat(api): OpenAPI spec update via Stainless API (#416)
stainless-app[bot] May 1, 2024
bbacffe
feat(api): OpenAPI spec update via Stainless API (#417)
stainless-app[bot] May 1, 2024
9256d06
feat(api): OpenAPI spec update via Stainless API (#418)
stainless-app[bot] May 1, 2024
5628bc9
feat(api): OpenAPI spec update via Stainless API (#419)
stainless-app[bot] May 1, 2024
66f7bb6
feat(api): OpenAPI spec update via Stainless API (#420)
stainless-app[bot] May 1, 2024
d8bd619
feat(api): update via SDK Studio (#421)
stainless-app[bot] May 1, 2024
e9c649d
feat(api): OpenAPI spec update via Stainless API (#422)
stainless-app[bot] May 1, 2024
fb7e704
feat(api): OpenAPI spec update via Stainless API (#423)
stainless-app[bot] May 1, 2024
85f4e21
feat(api): OpenAPI spec update via Stainless API (#424)
stainless-app[bot] May 1, 2024
267a17d
feat(api): OpenAPI spec update via Stainless API (#425)
stainless-app[bot] May 1, 2024
071102f
feat(api): OpenAPI spec update via Stainless API (#426)
stainless-app[bot] May 1, 2024
d7993dc
feat(api): OpenAPI spec update via Stainless API (#427)
stainless-app[bot] May 2, 2024
3e39431
feat(api): OpenAPI spec update via Stainless API (#428)
stainless-app[bot] May 2, 2024
9c2b961
feat(api): update via SDK Studio (#429)
stainless-app[bot] May 2, 2024
10f0c5c
feat(api): OpenAPI spec update via Stainless API (#430)
stainless-app[bot] May 2, 2024
73b2a0c
feat(api): update via SDK Studio (#431)
stainless-app[bot] May 2, 2024
bbb1c62
feat(api): OpenAPI spec update via Stainless API (#432)
stainless-app[bot] May 2, 2024
fbb0c43
feat(api): OpenAPI spec update via Stainless API (#433)
stainless-app[bot] May 2, 2024
7255fec
feat(api): OpenAPI spec update via Stainless API (#434)
stainless-app[bot] May 2, 2024
77d7da9
feat(api): OpenAPI spec update via Stainless API (#435)
stainless-app[bot] May 2, 2024
04d5bd8
feat(api): OpenAPI spec update via Stainless API (#436)
stainless-app[bot] May 2, 2024
4333b34
feat(api): OpenAPI spec update via Stainless API (#437)
stainless-app[bot] May 2, 2024
69a59ad
feat(api): OpenAPI spec update via Stainless API (#438)
stainless-app[bot] May 2, 2024
1e391f9
feat(api): OpenAPI spec update via Stainless API (#439)
stainless-app[bot] May 2, 2024
8b87eb0
feat(api): OpenAPI spec update via Stainless API (#440)
stainless-app[bot] May 2, 2024
13f3d4f
feat(api): OpenAPI spec update via Stainless API (#441)
stainless-app[bot] May 2, 2024
257c3dd
feat(api): OpenAPI spec update via Stainless API (#442)
stainless-app[bot] May 2, 2024
bf1020a
feat(api): OpenAPI spec update via Stainless API (#443)
stainless-app[bot] May 2, 2024
82a0638
feat(api): OpenAPI spec update via Stainless API (#444)
stainless-app[bot] May 2, 2024
803eafe
feat(api): OpenAPI spec update via Stainless API (#445)
stainless-app[bot] May 2, 2024
67aee8d
feat(api): OpenAPI spec update via Stainless API (#446)
stainless-app[bot] May 2, 2024
7d8dfd2
feat(api): OpenAPI spec update via Stainless API (#447)
stainless-app[bot] May 2, 2024
b3c75c1
feat(api): OpenAPI spec update via Stainless API (#448)
stainless-app[bot] May 2, 2024
2d9a628
feat(api): OpenAPI spec update via Stainless API (#449)
stainless-app[bot] May 2, 2024
fd20a92
feat(api): OpenAPI spec update via Stainless API (#450)
stainless-app[bot] May 2, 2024
aefafc0
feat(api): OpenAPI spec update via Stainless API (#451)
stainless-app[bot] May 2, 2024
c93b6cc
feat(api): OpenAPI spec update via Stainless API (#452)
stainless-app[bot] May 2, 2024
6a27c88
feat(api): OpenAPI spec update via Stainless API (#453)
stainless-app[bot] May 2, 2024
3550554
feat(api): OpenAPI spec update via Stainless API (#454)
stainless-app[bot] May 2, 2024
12127fa
feat(api): OpenAPI spec update via Stainless API (#455)
stainless-app[bot] May 2, 2024
ce279c8
feat(api): OpenAPI spec update via Stainless API (#456)
stainless-app[bot] May 2, 2024
30f343d
feat(api): OpenAPI spec update via Stainless API (#457)
stainless-app[bot] May 2, 2024
d5cc4a3
feat(api): OpenAPI spec update via Stainless API (#458)
stainless-app[bot] May 2, 2024
6de950d
feat(api): OpenAPI spec update via Stainless API (#459)
stainless-app[bot] May 2, 2024
ed49803
feat(api): OpenAPI spec update via Stainless API (#460)
stainless-app[bot] May 2, 2024
e4ab4f1
feat(api): OpenAPI spec update via Stainless API (#461)
stainless-app[bot] May 3, 2024
fe45910
feat(api): OpenAPI spec update via Stainless API (#462)
stainless-app[bot] May 3, 2024
a479255
feat(api): OpenAPI spec update via Stainless API (#463)
stainless-app[bot] May 3, 2024
68d5d52
feat(api): OpenAPI spec update via Stainless API (#464)
stainless-app[bot] May 3, 2024
09a52c2
feat(api): OpenAPI spec update via Stainless API (#465)
stainless-app[bot] May 3, 2024
c4e3a10
feat(api): OpenAPI spec update via Stainless API (#466)
stainless-app[bot] May 4, 2024
35375e6
feat(api): OpenAPI spec update via Stainless API (#467)
stainless-app[bot] May 4, 2024
71b3707
feat(api): update via SDK Studio (#468)
stainless-app[bot] May 6, 2024
fac8095
feat(api): update via SDK Studio (#469)
stainless-app[bot] May 6, 2024
08332a0
feat(api): OpenAPI spec update via Stainless API (#470)
stainless-app[bot] May 6, 2024
f28f0d7
feat(api): OpenAPI spec update via Stainless API (#471)
stainless-app[bot] May 6, 2024
edf2a7e
feat(api): update via SDK Studio (#472)
stainless-app[bot] May 6, 2024
e071e59
feat(api): OpenAPI spec update via Stainless API (#473)
stainless-app[bot] May 6, 2024
b369a83
feat(api): OpenAPI spec update via Stainless API (#474)
stainless-app[bot] May 6, 2024
17ee89e
feat(api): OpenAPI spec update via Stainless API (#475)
stainless-app[bot] May 6, 2024
0803b5b
feat(api): OpenAPI spec update via Stainless API (#476)
stainless-app[bot] May 6, 2024
486a19d
feat(api): OpenAPI spec update via Stainless API (#477)
stainless-app[bot] May 6, 2024
546e3e0
feat(api): update via SDK Studio (#479)
stainless-app[bot] May 7, 2024
d498b37
feat(api): update via SDK Studio (#480)
stainless-app[bot] May 7, 2024
7363259
feat(api): update via SDK Studio (#481)
stainless-app[bot] May 7, 2024
5c55bee
feat(api): update via SDK Studio (#482)
stainless-app[bot] May 7, 2024
b27aa06
feat(api): update via SDK Studio (#483)
stainless-app[bot] May 7, 2024
bc21852
feat(api): update via SDK Studio (#484)
stainless-app[bot] May 7, 2024
72c9a7a
feat(api): update via SDK Studio (#485)
stainless-app[bot] May 7, 2024
a114625
feat(api): update via SDK Studio (#486)
stainless-app[bot] May 7, 2024
67f7f49
feat(api): update via SDK Studio (#487)
stainless-app[bot] May 7, 2024
c2df805
feat(api): update via SDK Studio (#488)
stainless-app[bot] May 7, 2024
010ad14
feat(api): update via SDK Studio (#489)
stainless-app[bot] May 7, 2024
06d9aa2
feat(api): update via SDK Studio (#490)
stainless-app[bot] May 7, 2024
4224579
feat(api): update via SDK Studio (#491)
stainless-app[bot] May 7, 2024
d7d3d3c
feat(api): update via SDK Studio (#492)
stainless-app[bot] May 7, 2024
807a650
feat(api): update via SDK Studio (#494)
stainless-app[bot] May 8, 2024
06e1c13
feat(api): update via SDK Studio (#495)
stainless-app[bot] May 8, 2024
09d00fd
release: 3.2.0
stainless-app[bot] May 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,23 @@ jobs:
- name: Check types
run: |
yarn build
test:
name: test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Bootstrap
run: ./scripts/bootstrap

- name: Run tests
run: ./scripts/test
examples:
name: examples
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
if: github.repository == 'cloudflare/cloudflare-typescript' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Check release environment
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
yarn-error.log
codegen.log
Brewfile.lock.json
dist
/deno
/*.tgz
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "3.1.0"
".": "3.2.0"
}
3 changes: 2 additions & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
configured_endpoints: 1266
configured_endpoints: 1274
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-07ec76fab00de3d6227209faf0af1ed586cde9e2f243c13d3db555da20f13d99.yml
1 change: 1 addition & 0 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
brew "node"
132 changes: 132 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

180 changes: 116 additions & 64 deletions api.md

Large diffs are not rendered by default.

50 changes: 0 additions & 50 deletions bin/check-test-server

This file was deleted.

1 change: 1 addition & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const config: JestConfigWithTsJest = {
'<rootDir>/deno/',
'<rootDir>/deno_tests/',
],
testPathIgnorePatterns: ['scripts'],
};

export default config;
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cloudflare",
"version": "3.1.0",
"version": "3.2.0",
"description": "The official TypeScript library for the Cloudflare API",
"author": "Cloudflare <[email protected]>",
"types": "dist/index.d.ts",
Expand All @@ -14,14 +14,14 @@
],
"private": false,
"scripts": {
"test": "bin/check-test-server && yarn jest",
"build": "bash ./build",
"test": "./scripts/test",
"build": "./scripts/build",
"prepack": "echo 'to pack, run yarn build && (cd dist; yarn pack)' && exit 1",
"prepublishOnly": "echo 'to publish, run yarn build && (cd dist; yarn publish)' && exit 1",
"format": "prettier --write --cache --cache-strategy metadata . !dist",
"prepare": "if ./scripts/check-is-in-git-install.sh; then npm run build; fi",
"prepare": "if ./scripts/utils/check-is-in-git-install.sh; then ./scripts/build; fi",
"tsn": "ts-node -r tsconfig-paths/register",
"lint": "eslint --ext ts,js .",
"lint": "./scripts/lint",
"fix": "eslint --fix --ext ts,js ."
},
"dependencies": {
Expand Down
18 changes: 18 additions & 0 deletions scripts/bootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then
brew bundle check >/dev/null 2>&1 || {
echo "==> Installing Homebrew dependencies…"
brew bundle
}
fi

echo "==> Installing Node dependencies…"

PACKAGE_MANAGER=$(command -v yarn >/dev/null 2>&1 && echo "yarn" || echo "npm")

$PACKAGE_MANAGER install
15 changes: 9 additions & 6 deletions build → scripts/build
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/usr/bin/env bash

set -exuo pipefail

node scripts/check-version.cjs
cd "$(dirname "$0")/.."

node scripts/utils/check-version.cjs

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

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

node scripts/postprocess-files.cjs
node scripts/utils/postprocess-files.cjs

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

if command -v deno &> /dev/null && [ -e ./build-deno ]
if command -v deno &> /dev/null && [ -e ./scripts/build-deno ]
then
./build-deno
./scripts/build-deno
fi
7 changes: 7 additions & 0 deletions scripts/lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

./node_modules/.bin/eslint --ext ts,js .
41 changes: 41 additions & 0 deletions scripts/mock
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

if [[ -n "$1" && "$1" != '--'* ]]; then
URL="$1"
shift
else
URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)"
fi

# Check if the URL is empty
if [ -z "$URL" ]; then
echo "Error: No OpenAPI spec path/url provided or found in .stats.yml"
exit 1
fi

echo "==> Starting mock server with URL ${URL}"

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

# Wait for server to come online
echo -n "Waiting for server"
while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do
echo -n "."
sleep 0.1
done

if grep -q "✖ fatal" ".prism.log"; then
cat .prism.log
exit 1
fi

echo
else
npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL"
fi
57 changes: 57 additions & 0 deletions scripts/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color

function prism_is_running() {
curl --silent "http://localhost:4010" >/dev/null 2>&1
}

kill_server_on_port() {
pids=$(lsof -t -i tcp:"$1" || echo "")
if [ "$pids" != "" ]; then
kill "$pids"
echo "Stopped $pids."
fi
}

function is_overriding_api_base_url() {
[ -n "$TEST_API_BASE_URL" ]
}

if ! is_overriding_api_base_url && ! prism_is_running ; then
# When we exit this script, make sure to kill the background mock server process
trap 'kill_server_on_port 4010' EXIT

# Start the dev server
./scripts/mock --daemon
fi

if is_overriding_api_base_url ; then
echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}"
echo
elif ! prism_is_running ; then
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server"
echo -e "running against your OpenAPI spec."
echo
echo -e "To run the server, pass in the path or url of your OpenAPI"
echo -e "spec to the prism command:"
echo
echo -e " \$ ${YELLOW}npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock path/to/your.openapi.yml${NC}"
echo

exit 1
else
echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}"
echo
fi

# Run tests
echo "==> Running tests"
./node_modules/.bin/jest "$@"
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ const fs = require('fs');
const path = require('path');

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

const versionFile = path.resolve(__dirname, '..', 'src', 'version.ts');
const versionFile = path.resolve(__dirname, '..', '..', 'src', 'version.ts');
const contents = fs.readFileSync(versionFile, 'utf8');
const output = contents.replace(/(export const VERSION = ')(.*)(')/g, `$1${version}$3`);
fs.writeFileSync(versionFile, output);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const path = require('path');
const indexJs =
process.env['DIST_PATH'] ?
path.resolve(process.env['DIST_PATH'], 'index.js')
: path.resolve(__dirname, '..', 'dist', 'index.js');
: path.resolve(__dirname, '..', '..', 'dist', 'index.js');

let before = fs.readFileSync(indexJs, 'utf8');
let after = before.replace(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const pkgJson = require(process.env['PKG_JSON_PATH'] || '../package.json');
const pkgJson = require(process.env['PKG_JSON_PATH'] || '../../package.json');

function processExportMap(m) {
for (const key in m) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ const fs = require('fs');
const path = require('path');
const { parse } = require('@typescript-eslint/parser');

const pkgImportPath = process.env['PKG_IMPORT_PATH'] ?? 'cloudflare/'
const pkgImportPath = process.env['PKG_IMPORT_PATH'] ?? 'cloudflare/';

const distDir =
process.env['DIST_PATH'] ?
path.resolve(process.env['DIST_PATH'])
: path.resolve(__dirname, '..', 'dist');
: path.resolve(__dirname, '..', '..', 'dist');
const distSrcDir = path.join(distDir, 'src');

/**
Expand Down Expand Up @@ -103,7 +103,7 @@ async function* walk(dir) {
}

async function postprocess() {
for await (const file of walk(path.resolve(__dirname, '..', 'dist'))) {
for await (const file of walk(path.resolve(__dirname, '..', '..', 'dist'))) {
if (!/\.([cm]?js|(\.d)?[cm]?ts)$/.test(file)) continue;

const code = await fs.promises.readFile(file, 'utf8');
Expand Down
Loading