|
1 | 1 | /* eslint-disable no-console */
|
2 | 2 | import fs from 'fs';
|
| 3 | +import path from 'path'; |
3 | 4 |
|
4 | 5 | import dotenv from 'dotenv';
|
5 | 6 | import execa from 'execa';
|
6 | 7 |
|
7 | 8 | import openapitools from '../../openapitools.json';
|
8 | 9 |
|
9 |
| -import { MAIN_BRANCH, OWNER, REPO, run, getMarkdownSection } from './common'; |
| 10 | +import type { Run } from './common'; |
| 11 | +import { |
| 12 | + MAIN_BRANCH, |
| 13 | + OWNER, |
| 14 | + REPO, |
| 15 | + run as runOriginal, |
| 16 | + getMarkdownSection, |
| 17 | +} from './common'; |
10 | 18 | import TEXT from './text';
|
11 | 19 |
|
| 20 | +// This script is run by `yarn workspace ...`, which means the current working directory is `./script` |
| 21 | +const ROOT_DIR = path.resolve(process.cwd(), '..'); |
| 22 | + |
12 | 23 | dotenv.config();
|
13 | 24 |
|
| 25 | +const run: Run = (command, options = {}) => |
| 26 | + runOriginal(command, { cwd: ROOT_DIR, ...options }); |
| 27 | + |
14 | 28 | if (!process.env.GITHUB_TOKEN) {
|
15 | 29 | throw new Error('Environment variable `GITHUB_TOKEN` does not exist.');
|
16 | 30 | }
|
@@ -70,12 +84,15 @@ Object.keys(openapitools['generator-cli'].generators).forEach((client) => {
|
70 | 84 | ].additionalProperties.packageVersion = versionsToRelease[lang].next;
|
71 | 85 | }
|
72 | 86 | });
|
73 |
| -fs.writeFileSync('openapitools.json', JSON.stringify(openapitools, null, 2)); |
| 87 | +fs.writeFileSync( |
| 88 | + path.resolve(ROOT_DIR, 'openapitools.json'), |
| 89 | + JSON.stringify(openapitools, null, 2) |
| 90 | +); |
74 | 91 |
|
75 | 92 | // update changelogs
|
76 | 93 | new Set([...Object.keys(versionsToRelease), ...langsToUpdateRepo]).forEach(
|
77 | 94 | (lang) => {
|
78 |
| - const filePath = `doc/changelogs/${lang}.md`; |
| 95 | + const filePath = path.resolve(ROOT_DIR, `doc/changelogs/${lang}.md`); |
79 | 96 | const header = versionsToRelease[lang!]
|
80 | 97 | ? `## ${versionsToRelease[lang!].next}`
|
81 | 98 | : `## ${new Date().toISOString().split('T')[0]}`;
|
|
0 commit comments