Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/setup-fern/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ runs:
- name: Install pinned Fern
shell: bash
run: |
npm install --prefix "$RUNNER_TEMP/vapi-fern" --no-save --no-audit --no-fund fern-api@5.169.0
npm install --prefix "$RUNNER_TEMP/vapi-fern" --no-save --no-audit --no-fund fern-api@5.216.0
echo "FERN_CLI_PATH=$RUNNER_TEMP/vapi-fern/node_modules/fern-api/cli.cjs" >> "$GITHUB_ENV"
- name: Test cache safeguards
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion fern/fern.config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"organization": "vapi",
"version": "5.169.0"
"version": "5.216.0"
}
6 changes: 3 additions & 3 deletions scripts/fern/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ original Fern commands also removes this optimization.
## Local verification

```sh
npm install --prefix /tmp/vapi-fern --no-save fern-api@5.169.0
npm install --prefix /tmp/vapi-fern --no-save fern-api@5.216.0
export FERN_CLI_PATH=/tmp/vapi-fern/node_modules/fern-api/cli.cjs
node --test scripts/fern/*.test.cjs
node scripts/fern/run.cjs check --local --log-level debug
node scripts/fern/run.cjs generate --docs --preview --log-level debug
```

The CLI compatibility tests exercise the installed bundle when `FERN_CLI_PATH` is set;
without it, the installed-bundle checks are skipped. The wrapper pins Fern 5.169.0
without it, the installed-bundle checks are skipped. The wrapper pins Fern 5.216.0
and verifies CLI SHA-256
`773ec0a808a2c4d03c894c81c6159f8e3fe8db5a873c287cdce5b140eed8b809`.
`acd2771ffed03658a03590ea9fa6ee764df52e52284665eb8574cd8efacb4923`.
The timing measurements below predate this upgrade.

Preview generation publishes remotely and requires separate authorization.
Expand Down
8 changes: 4 additions & 4 deletions scripts/fern/run.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const os = require('node:os');
const { spawnSync } = require('node:child_process');
const { digest } = require('./example-cache.cjs');

const VERSION = '5.169.0';
const CLI_SHA256 = '773ec0a808a2c4d03c894c81c6159f8e3fe8db5a873c287cdce5b140eed8b809';
const MARKER = 'function KOm({propertySchema:e,breadcrumbs:t,context:r,propertyId:n})';
const VERSION = '5.216.0';
const CLI_SHA256 = 'acd2771ffed03658a03590ea9fa6ee764df52e52284665eb8574cd8efacb4923';
const MARKER = 'function HQm({propertySchema:e,breadcrumbs:t,context:r,propertyId:n})';
const MEDIA_MARKER = 'generateOrValidateExample({schema:t,example:r,generateOptionalProperties:n,exampleGenerationStrategy:i})';

function inputDigest(root) {
Expand All @@ -27,7 +27,7 @@ function main() {
if (digest(source) !== CLI_SHA256 || source.split(MARKER).length !== 2 || source.split(MEDIA_MARKER).length !== 2) throw new Error('Unexpected Fern CLI contents. Refusing to apply the cache adapter.');
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), 'vapi-fern-'));
const patched = source
.replace(MARKER, 'function KOm(args){return globalThis.__vapiFernExamples(args,()=>vapiOriginalExamples(args))}function vapiOriginalExamples({propertySchema:e,breadcrumbs:t,context:r,propertyId:n})')
.replace(MARKER, 'function HQm(args){return globalThis.__vapiFernExamples(args,()=>vapiOriginalExamples(args))}function vapiOriginalExamples({propertySchema:e,breadcrumbs:t,context:r,propertyId:n})')
.replace(MEDIA_MARKER, 'generateOrValidateExample(args){return globalThis.__vapiFernExamples({context:this.context,breadcrumbs:this.breadcrumbs,mediaExampleArgs:args},()=>this.vapiOriginalMediaExample(args))}vapiOriginalMediaExample({schema:t,example:r,generateOptionalProperties:n,exampleGenerationStrategy:i})');
try {
const cli = path.join(temporary, 'fern.cjs');
Expand Down
10 changes: 5 additions & 5 deletions scripts/fern/run.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const vm = require('node:vm');
const { spawnSync } = require('node:child_process');
const { digest } = require('./example-cache.cjs');

const version = '5.169.0';
const checksum = '773ec0a808a2c4d03c894c81c6159f8e3fe8db5a873c287cdce5b140eed8b809';
const marker = 'function KOm({propertySchema:e,breadcrumbs:t,context:r,propertyId:n})';
const version = '5.216.0';
const checksum = 'acd2771ffed03658a03590ea9fa6ee764df52e52284665eb8574cd8efacb4923';
const marker = 'function HQm({propertySchema:e,breadcrumbs:t,context:r,propertyId:n})';
const mediaMarker = 'generateOrValidateExample({schema:t,example:r,generateOptionalProperties:n,exampleGenerationStrategy:i})';
const fixture = `${marker}{return e}class Media{${mediaMarker}{return t}}`;
const wrapper = fs.readFileSync(path.join(__dirname, 'run.cjs'), 'utf8');
Expand Down Expand Up @@ -80,7 +80,7 @@ test('both emitted wrappers call the cache and preserve original generation', ()
const patched = h.calls.writes[0][1];
const calls = [];
const context = { __vapiFernExamples(args, generate) { calls.push(args); return generate(); } };
const result = vm.runInNewContext(`${patched};[KOm({propertySchema:'property'}),new Media().generateOrValidateExample({schema:'media'})]`, context);
const result = vm.runInNewContext(`${patched};[HQm({propertySchema:'property'}),new Media().generateOrValidateExample({schema:'media'})]`, context);
assert.deepEqual(Array.from(result), ['property', 'media']);
assert.equal(calls.length, 2);
assert.equal(calls[0].propertySchema, 'property');
Expand Down Expand Up @@ -134,7 +134,7 @@ for (const args of [['--version'], ['--help'], ['check', '--help'], ['generate',
assert.equal(result.status, 0, result.stderr);
assert.match(result.stderr, /\[fern-example-cache\]/);
assert.ok(result.stdout.trim());
if (args[0] === '--version') assert.match(result.stdout, /5\.169\.0/);
if (args[0] === '--version') assert.match(result.stdout, /5\.216\.0/);
assert.deepEqual(fs.readdirSync(temporary), []);
});
}
Loading