Skip to content
Draft
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
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
npx changeset version
npm i
node scripts/post-changeset.js
node scripts/refresh-ejected-example.mjs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ describe('validateGenerators', () => {
validateGenerators(['php'], { runtime: 'inline', argsStyle: 'grouped' }, undefined, 'split');
const messages = warn.mock.calls.map(([message]) => message).join('');
expect(messages).toContain('the "php" generator ignores outputMode');
expect(messages).toContain('the "php" generator ignores runtime');
expect(messages).toContain('the "php" generator ignores argsStyle');
// `runtime` applies to every runtime-embedding generator since module mode landed.
expect(messages).not.toContain('ignores runtime');

// Defaults must stay quiet: only an EXPLICIT option warns.
warn.mockClear();
Expand Down
10 changes: 5 additions & 5 deletions packages/client-generator/src/generators/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ function tanstackQuery(framework: 'react' | 'vue' | 'svelte' | 'solid'): Builtin
}

/**
* The TypeScript-only knobs a standalone language SDK cannot apply: it always emits
* one self-contained file with the runtime embedded, and each language passes inputs
* its own idiomatic way (keyword arguments, named arguments, a params struct).
* The TypeScript-only knobs a standalone language SDK cannot apply: the client is
* always one module (`runtime: module` adds its runtime files beside it), and each
* language passes inputs its own idiomatic way (keyword arguments, named arguments,
* a params struct).
*/
const LANGUAGE_SDK_NOT_APPLICABLE: BuiltinMeta['notApplicable'] = {
outputMode: 'it always emits one self-contained file',
runtime: 'the runtime is always embedded in the generated file',
outputMode: 'the client is always one module (`split` applies to the TypeScript client)',
argsStyle: "inputs follow the target language's own idiom",
importExt: 'the generated file has no relative imports',
};
Expand Down
38 changes: 38 additions & 0 deletions scripts/refresh-ejected-example.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Re-stamp the checked-in ejected-generator example with the current
// @redocly/client-generator version. The example is a frozen user copy, and its
// `requiresGenerator: '^<version>'` caret range treats a 0.x minor bump as breaking
// (deliberately), so a release that bumps the package would otherwise fail the
// examples job with "Generator 'php' needs @redocly/client-generator ^<old>".
// Runs from the release workflow's `version` block, after `changeset version`.

import { readdirSync, readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';

const { version } = JSON.parse(readFileSync('packages/client-generator/package.json', 'utf-8'));
const generatorsDir = 'tests/e2e/generate-client/examples/ejected-generator/generators';

const HEADER = /Ejected from @redocly\/client-generator@\d+\.\d+\.\d+(?:-[\w.]+)?/g;
const REQUIRES = /requiresGenerator: '\^\d+\.\d+\.\d+(?:-[\w.]+)?'/g;

let touched = 0;
for (const entry of readdirSync(generatorsDir, { withFileTypes: true })) {
if (!entry.isDirectory()) continue;
const dir = join(generatorsDir, entry.name);
for (const name of readdirSync(dir)) {
if (!name.endsWith('.ts')) continue;
const path = join(dir, name);
const source = readFileSync(path, 'utf-8');
const updated = source
.replaceAll(HEADER, `Ejected from @redocly/client-generator@${version}`)
.replaceAll(REQUIRES, `requiresGenerator: '^${version}'`);
if (updated !== source) {
writeFileSync(path, updated, 'utf-8');
touched++;
}
}
}
console.log(
touched === 0
? `refresh-ejected-example: already at ${version}, nothing to do`
: `refresh-ejected-example: stamped ${touched} file(s) with ${version}`
);
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Ejected from @redocly/client-generator@0.3.7 — the built-in "php" generator.
// Ejected from @redocly/client-generator@0.3.8 — the built-in "php" generator.
// This file is yours: edit freely; the generated client stays machine-owned and is
// rebuilt by `redocly generate-client`. Newer generator versions merge in with
// `redocly eject-generator php --update`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Ejected from @redocly/client-generator@0.3.7 — the built-in "php" generator.
// Ejected from @redocly/client-generator@0.3.8 — the built-in "php" generator.
// This file is yours: edit freely; the generated client stays machine-owned and is
// rebuilt by `redocly generate-client`. Newer generator versions merge in with
// `redocly eject-generator php --update`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Ejected from @redocly/client-generator@0.3.7 — the built-in "php" generator.
// Ejected from @redocly/client-generator@0.3.8 — the built-in "php" generator.
// This file is yours: edit freely; the generated client stays machine-owned and is
// rebuilt by `redocly generate-client`. Newer generator versions merge in with
// `redocly eject-generator php --update`.
Expand Down Expand Up @@ -211,10 +211,9 @@ export default {
docs: phpDocs,
errorModes: ["throw"],
notApplicable: {
"outputMode": "it always emits one self-contained file",
"runtime": "the runtime is always embedded in the generated file",
"outputMode": "the client is always one module (`split` applies to the TypeScript client)",
"argsStyle": "inputs follow the target language's own idiom",
"importExt": "the generated file has no relative imports"
},
requiresGenerator: '^0.3.7',
requiresGenerator: '^0.3.8',
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Ejected from @redocly/client-generator@0.3.7 — the built-in "php" generator.
// Ejected from @redocly/client-generator@0.3.8 — the built-in "php" generator.
// This file is yours: edit freely; the generated client stays machine-owned and is
// rebuilt by `redocly generate-client`. Newer generator versions merge in with
// `redocly eject-generator php --update`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Ejected from @redocly/client-generator@0.3.7 — the built-in "php" generator.
// Ejected from @redocly/client-generator@0.3.8 — the built-in "php" generator.
// This file is yours: edit freely; the generated client stays machine-owned and is
// rebuilt by `redocly generate-client`. Newer generator versions merge in with
// `redocly eject-generator php --update`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Ejected from @redocly/client-generator@0.3.7 — the built-in "php" generator.
// Ejected from @redocly/client-generator@0.3.8 — the built-in "php" generator.
// This file is yours: edit freely; the generated client stays machine-owned and is
// rebuilt by `redocly generate-client`. Newer generator versions merge in with
// `redocly eject-generator php --update`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Ejected from @redocly/client-generator@0.3.7 — the built-in "php" generator.
// Ejected from @redocly/client-generator@0.3.8 — the built-in "php" generator.
// This file is yours: edit freely; the generated client stays machine-owned and is
// rebuilt by `redocly generate-client`. Newer generator versions merge in with
// `redocly eject-generator php --update`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Ejected from @redocly/client-generator@0.3.7 — the built-in "php" generator.
// Ejected from @redocly/client-generator@0.3.8 — the built-in "php" generator.
// This file is yours: edit freely; the generated client stays machine-owned and is
// rebuilt by `redocly generate-client`. Newer generator versions merge in with
// `redocly eject-generator php --update`.
Expand Down
Loading