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
5 changes: 2 additions & 3 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
"ignore": [
"website",
"example-*",
"rust-example-*",
"dev-test*",
"@graphql-codegen/client-preset-swc-plugin",
"example-apollo-client-swc-plugin",
"example-react-nextjs-swr"
"@graphql-codegen/client-preset-swc-plugin"
],
"changelog": [
"@changesets/changelog-github",
Expand Down
3 changes: 2 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,10 @@ export default [

// Scripts and config files
{
files: ['scripts/*.{ts,js}', 'prettier.config.cjs'],
files: ['scripts/*.{mjs,ts,js}', 'prettier.config.cjs'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
'no-console': 'off',
},
},
];
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"scripts": {
"prebuild": "rimraf dist/ .bob/ tsconfig.tsbuildinfo",
"build": "bob build",
"postbuild": "pnpm fix-bins",
"postbuild": "pnpm fix-bins && pnpm inject-cli-version",
"clean": "rimraf node_modules/",
"dev-test:generate": "pnpm --filter=\"dev-test*\" generate",
"dev-test:generate:cjs": "pnpm --filter=\"dev-test*\" generate:cjs",
Expand All @@ -21,6 +21,7 @@
"examples:codegen": "pnpm --filter=\"example-*\" codegen",
"examples:test:end2end": "pnpm --filter=\"example-*\" --workspace-concurrency=1 test:end2end",
"fix-bins": "node scripts/fix-bin.js",
"inject-cli-version": "node scripts/inject-cli-version.mjs",
"postinstall": "husky install",
"lint": "eslint --cache .",
"lint:ci": "eslint --cache --output-file eslint_report.json --format json .",
Expand Down
8 changes: 8 additions & 0 deletions packages/graphql-codegen-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @graphql-codegen/cli

## 7.1.1

### Patch Changes

- [#10858](https://github.com/dotansimha/graphql-code-generator/pull/10858)
[`3fa901b`](https://github.com/dotansimha/graphql-code-generator/commit/3fa901b23ad6d3ef0522d2d8121d654bcacbd65d)
Thanks [@eddeee888](https://github.com/eddeee888)! - Fix --version flag

## 7.1.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-codegen-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-codegen/cli",
"version": "7.1.0",
"version": "7.1.1",
"type": "module",
"repository": {
"type": "git",
Expand Down
3 changes: 2 additions & 1 deletion packages/graphql-codegen-cli/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
loadDocuments,
loadSchema,
} from './load.js';
import { version } from './version.js';

const { lstat } = promises;

Expand Down Expand Up @@ -283,7 +284,7 @@ export function buildOptions() {
}

export function parseArgv(argv = process.argv): YamlCliFlags {
return yargs(argv).options(buildOptions()).parse(argv) as any;
return yargs(argv).version(version).options(buildOptions()).parse(argv) as any;
}

export async function createContext(
Expand Down
1 change: 1 addition & 0 deletions packages/graphql-codegen-cli/src/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const version = '__VERSION__';
2 changes: 0 additions & 2 deletions scripts/fix-bin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable import/no-extraneous-dependencies */
// @ts-check
const fs = require('fs-extra');
const path = require('path');
const fg = require('fast-glob');
Expand Down
33 changes: 33 additions & 0 deletions scripts/inject-cli-version.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
import * as url from 'node:url';

/**
* This script injects the `@graphql-codegen/cli` version after building,
* so at runtime, we don't have to import `package.json` file for the package version.
*/

const __dirname = url.fileURLToPath(new url.URL('.', import.meta.url));

const packageJsonFile = path.resolve(__dirname, '../packages/graphql-codegen-cli/package.json');
const versionFiles = [
path.resolve(__dirname, '../packages/graphql-codegen-cli/dist/cjs/version.js'),
path.resolve(__dirname, '../packages/graphql-codegen-cli/dist/esm/version.js'),
];

const packageJson = JSON.parse(fs.readFileSync(packageJsonFile, 'utf8'));

for (const versionFile of versionFiles) {
const versionFileContent = fs.readFileSync(versionFile, 'utf8');
fs.writeFileSync(
versionFile,
versionFileContent.replace('__VERSION__', packageJson.version || 'unknown'),
'utf8',
);

const updatedVersionContent = fs.readFileSync(versionFile, 'utf8');

console.log('***');
console.log(`Updated ${versionFile} content:\n"${updatedVersionContent}"`);
console.log('***');
}
1 change: 0 additions & 1 deletion scripts/match-graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const pkg = require(pkgPath);
const version = argv[2];

if (pkg.devDependencies.graphql?.startsWith(version)) {
// eslint-disable-next-line no-console
console.info(`GraphQL v${version} is match! Skipping.`);
return;
}
Expand Down
Loading