-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tweak the esbuild define config to set the git info in the api build. The `define` api only replaces the exact token, where it finds it seperated by whitespace, with the exact value provided. So the key `VERSION` was not matching on `env.VERSION`, so our envAll function now sets these values on the env for us by pulling them from magic globals that esbuild will set. I removed the `define` config for ENV. This was not getting applied. Now we pass the ENV to the build step in CI, and miniflare gets it from the .env file. ```console ❯ curl "https://api.web3.storage/version" {"mode":"rw"} ❯ curl "http://127.0.0.1:8787/version" {"version":"web3-api@5.1.4-dev+9068490","commit":"9068490aaa4dbe037e8e6aa9eaad706a46f11aed","branch":"main","mode":"rw"} ``` see: https://esbuild.github.io/api/#define fixes: #1016 License: (Apache-2.0 AND MIT) Signed-off-by: Oli Evans <oli@tableflip.io>
- Loading branch information
Showing
5 changed files
with
31 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
/* eslint-env mocha */ | ||
import assert from 'assert' | ||
import fs from 'fs' | ||
import path from 'path' | ||
import { fileURLToPath } from 'url' | ||
import git from 'git-rev-sync' | ||
import fetch from '@web-std/fetch' | ||
import { endpoint } from './scripts/constants.js' | ||
import { | ||
VERSION, | ||
COMMITHASH, | ||
BRANCH, | ||
MAINTENANCE_MODE | ||
} from './scripts/worker-globals.js' | ||
import { MAINTENANCE_MODE } from './scripts/worker-globals.js' | ||
|
||
const __dirname = path.dirname(fileURLToPath(import.meta.url)) | ||
const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8')) | ||
|
||
describe('GET /version', () => { | ||
it('retrieves version', async () => { | ||
const res = await fetch(new URL('version/', endpoint)) | ||
assert(res.ok) | ||
const { version, commit, branch, mode } = await res.json() | ||
assert.strictEqual(version, VERSION) | ||
assert.strictEqual(commit, COMMITHASH) | ||
assert.strictEqual(branch, BRANCH) | ||
assert.strictEqual(version, pkg.version) | ||
assert.strictEqual(commit, git.long(__dirname)) | ||
assert.strictEqual(branch, git.branch(__dirname)) | ||
assert.strictEqual(mode, MAINTENANCE_MODE) | ||
}) | ||
}) |