Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(scripts): try experimental-strip-types #3764

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
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
4 changes: 0 additions & 4 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ runs:
shell: bash
run: YARN_ENABLE_HARDENED_MODE=0 yarn install

- name: Build scripts
shell: bash
run: yarn workspace scripts build:cli

# JavaScript client deps
- name: Get yarn js-client cache directory path
if: ${{ inputs.language == 'javascript' }}
Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"fix:json": "eslint --ext=json . --fix",
"fix:mustache": "eslint --ext=mustache templates/**/tests/ --fix",
"github-actions:lint": "eslint --ext=yml .github/",
"postinstall": "husky && yarn workspace eslint-plugin-automation-custom build && yarn workspace scripts build:cli",
"postinstall": "husky && yarn workspace eslint-plugin-automation-custom build",
"playground:browser": "yarn workspace javascript-browser-playground start",
"scripts:build": "yarn workspace scripts build",
"scripts:build": "yarn workspace scripts build:actions",
"scripts:lint": "yarn workspace scripts lint",
"scripts:test": "yarn workspace scripts test",
"specs:fix": "eslint --ext=yml specs/$0 --fix",
Expand All @@ -28,8 +28,6 @@
"website:build": "bash scripts/website/build.sh"
},
"devDependencies": {
"@babel/core": "7.25.2",
"@babel/eslint-parser": "7.25.1",
"@eslint-community/eslint-plugin-eslint-comments": "4.4.0",
"@openapitools/openapi-generator-cli": "2.13.5",
"@redocly/cli": "1.25.2",
Expand All @@ -50,7 +48,6 @@
"eslint-plugin-yml": "1.14.0",
"husky": "9.1.6",
"lint-staged": "15.2.10",
"pinst": "3.0.0",
"prettier": "3.3.3",
"prettier-plugin-java": "2.6.4",
"renovate-config-algolia": "2.1.10",
Expand Down
3 changes: 1 addition & 2 deletions scripts/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ module.exports = {
'ignorePackages',
{
js: 'never',
ts: 'never',
mjs: 'never',
ts: 'always',
},
],
'@typescript-eslint/sort-type-union-intersection-members': 0,
Expand Down
4 changes: 2 additions & 2 deletions scripts/__tests__/common.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { execa } from 'execa';
import { afterEach, describe, expect, it, vi } from 'vitest';

import { capitalize, createClientName, gitCommit } from '../common.js';
import { getClientsConfigField } from '../config.js';
import { capitalize, createClientName, gitCommit } from '../common.ts';
import { getClientsConfigField } from '../config.ts';

vi.mock('execa', () => {
return {
Expand Down
8 changes: 4 additions & 4 deletions scripts/buildClients.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { run } from './common.js';
import { getLanguageFolder } from './config.js';
import { createSpinner } from './spinners.js';
import type { Generator, Language } from './types.js';
import { run } from './common.ts';
import { getLanguageFolder } from './config.ts';
import { createSpinner } from './spinners.ts';
import type { Generator, Language } from './types.ts';

type BuildType = 'client' | 'playground' | 'snippets';

Expand Down
2 changes: 1 addition & 1 deletion scripts/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fsp from 'fs/promises';

import { hashElement } from 'folder-hash';

import { exists } from './common';
import { exists } from './common.ts';

export class Cache {
folder: string;
Expand Down
172 changes: 86 additions & 86 deletions scripts/ci/actions/restore-artifacts/builddir/index.cjs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions scripts/ci/codegen/__tests__/codegen.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { describe, expect, it, vi } from 'vitest';

import { pushGeneratedCode } from '../pushGeneratedCode.js';
import { pushGeneratedCode } from '../pushGeneratedCode.ts';

vi.mock('../../../common.js', async (importOriginal) => {
const mod = await importOriginal<typeof import('../../../common.js')>();
vi.mock('../../../common.ts', async (importOriginal) => {
const mod = await importOriginal<typeof import('../../../common.ts')>();
return {
...mod,
run: vi.fn().mockResolvedValue(''),
Expand Down
4 changes: 2 additions & 2 deletions scripts/ci/codegen/__tests__/spreadGeneration.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest';

import { cleanUpCommitMessage } from '../spreadGeneration.js';
import text from '../text.js';
import { cleanUpCommitMessage } from '../spreadGeneration.ts';
import text from '../text.ts';

describe('spread generation', () => {
describe('cleanUpCommitMessage', () => {
Expand Down
10 changes: 5 additions & 5 deletions scripts/ci/codegen/createGitHubReleases.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable no-console */

import { ensureGitHubToken, getOctokit, OWNER, run, setVerbose, toAbsolutePath } from '../../common';
import { isPreRelease } from '../../release/sla';
import type { Language } from '../../types';
import { cloneRepository } from '../utils';
import { ensureGitHubToken, getOctokit, OWNER, run, setVerbose, toAbsolutePath } from '../../common.ts';
import { isPreRelease } from '../../release/sla.ts';
import type { Language } from '../../types.ts';
import { cloneRepository } from '../utils.ts';

import { commitStartRelease } from './text';
import { commitStartRelease } from './text.ts';

async function createGitHubRelease(lang: Language): Promise<void> {
// **Full Changelog**:
Expand Down
6 changes: 3 additions & 3 deletions scripts/ci/codegen/pushGeneratedCode.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable no-console */
import { setOutput } from '@actions/core';

import { configureGitHubAuthor, ensureGitHubToken, MAIN_BRANCH, run } from '../../common.js';
import { getNbGitDiff } from '../utils.js';
import { configureGitHubAuthor, ensureGitHubToken, MAIN_BRANCH, run } from '../../common.ts';
import { getNbGitDiff } from '../utils.ts';

import text, { commitStartPrepareRelease } from './text.js';
import text, { commitStartPrepareRelease } from './text.ts';

async function isUpToDate(baseBranch: string): Promise<boolean> {
await run('git fetch origin');
Expand Down
6 changes: 3 additions & 3 deletions scripts/ci/codegen/pushToAlgoliaDoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import {
getOctokit,
setVerbose,
gitBranchExists,
} from '../../common.js';
import { getNbGitDiff } from '../utils.js';
} from '../../common.ts';
import { getNbGitDiff } from '../utils.ts';

import { commitStartRelease } from './text.js';
import { commitStartRelease } from './text.ts';

async function pushToAlgoliaDoc(): Promise<void> {
const githubToken = ensureGitHubToken();
Expand Down
12 changes: 6 additions & 6 deletions scripts/ci/codegen/spreadGeneration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import {
ensureGitHubToken,
configureGitHubAuthor,
setVerbose,
} from '../../common.js';
import { getLanguageFolder, getPackageVersionDefault } from '../../config.js';
import { getNewReleasedTag } from '../../release/common.js';
import type { Language } from '../../types.js';
import { cloneRepository, getNbGitDiff } from '../utils.js';
} from '../../common.ts';
import { getLanguageFolder, getPackageVersionDefault } from '../../config.ts';
import { getNewReleasedTag } from '../../release/common.ts';
import type { Language } from '../../types.ts';
import { cloneRepository, getNbGitDiff } from '../utils.ts';

import text, { commitStartRelease } from './text.js';
import text, { commitStartRelease } from './text.ts';

export function cleanUpCommitMessage(commitMessage: string, version: string): string {
if (commitMessage.startsWith(commitStartRelease)) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci/codegen/text.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TODAY } from '../../common.js';
import { TODAY } from '../../common.ts';

export const commitStartPrepareRelease = 'chore: prepare release';
export const commitStartRelease = 'chore: release';
Expand Down
10 changes: 5 additions & 5 deletions scripts/ci/codegen/waitForAllReleases.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* eslint-disable no-console */
import type { components } from '@octokit/openapi-types';

import { exists, getOctokit, run, setVerbose, toAbsolutePath } from '../../common';
import { getClientsConfigField, getLanguageFolder } from '../../config';
import { getTargetBranch } from '../../release/common';
import type { Language } from '../../types';
import { exists, getOctokit, run, setVerbose, toAbsolutePath } from '../../common.ts';
import { getClientsConfigField, getLanguageFolder } from '../../config.ts';
import { getTargetBranch } from '../../release/common.ts';
import type { Language } from '../../types.ts';

import { commitStartRelease } from './text';
import { commitStartRelease } from './text.ts';

type Run = {
language: Language;
Expand Down
8 changes: 4 additions & 4 deletions scripts/ci/githubActions/createMatrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import fsp from 'fs/promises';

import { setOutput } from '@actions/core';

import { CLIENTS, createClientName, exists, GENERATORS, LANGUAGES, toAbsolutePath } from '../../common.js';
import { getLanguageFolder, getTestExtension, getTestOutputFolder, getClientsConfigField } from '../../config.js';
import { CLIENTS, createClientName, exists, GENERATORS, LANGUAGES, toAbsolutePath } from '../../common.ts';
import { getLanguageFolder, getTestExtension, getTestOutputFolder, getClientsConfigField } from '../../config.ts';

import type { ClientMatrix, CreateMatrix, ToRunMatrix } from './types.js';
import { COMMON_DEPENDENCIES, DEPENDENCIES, isBaseChanged } from './utils.js';
import type { ClientMatrix, CreateMatrix, ToRunMatrix } from './types.ts';
import { COMMON_DEPENDENCIES, DEPENDENCIES, isBaseChanged } from './utils.ts';

// This empty matrix is required by the CI, otherwise it throws
const EMPTY_MATRIX = { client: ['no-run'] };
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci/githubActions/setRunVariables.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
import * as core from '@actions/core';

import { DEPENDENCIES, isBaseChanged } from './utils.js';
import { DEPENDENCIES, isBaseChanged } from './utils.ts';

/**
* Outputs variables used in the CI to determine if a job should run.
Expand Down
8 changes: 4 additions & 4 deletions scripts/ci/githubActions/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable no-console */
import * as core from '@actions/core';

import { LANGUAGES } from '../../common.js';
import { getLanguageFolder } from '../../config.js';
import type { Language } from '../../types.js';
import { getNbGitDiff } from '../utils.js';
import { LANGUAGES } from '../../common.ts';
import { getLanguageFolder } from '../../config.ts';
import type { Language } from '../../types.ts';
import { getNbGitDiff } from '../utils.ts';

export const COMMON_DEPENDENCIES = {
GITHUB_ACTIONS_CHANGED: ['.github/actions', '.github/workflows'],
Expand Down
8 changes: 4 additions & 4 deletions scripts/ci/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import fsp from 'fs/promises';
import { resolve } from 'path';

import { run } from '../common.js';
import { getGitHubUrl } from '../config.js';
import { getTargetBranch } from '../release/common.js';
import type { Language } from '../types.js';
import { run } from '../common.ts';
import { getGitHubUrl } from '../config.ts';
import { getTargetBranch } from '../release/common.ts';
import type { Language } from '../types.ts';

/**
* Returns the number of diff between a `branch` and its `HEAD` for the given `path`.
Expand Down
34 changes: 17 additions & 17 deletions scripts/cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { Argument, program } from 'commander';
import semver from 'semver';

import { buildClients, buildPlaygrounds, buildSnippets } from '../buildClients.js';
import { CI, CLIENTS, LANGUAGES, run, setVerbose } from '../common.js';
import { getLanguageFolder } from '../config.js';
import { ctsGenerateMany } from '../cts/generate.js';
import { runCts } from '../cts/runCts.js';
import { startTestServer } from '../cts/testServer';
import { formatter } from '../formatter.js';
import { generate } from '../generate.js';
import { playground } from '../playground.js';
import { createReleasePR } from '../release/createReleasePR.js';
import { generateSLA } from '../release/sla.js';
import { snippetsGenerateMany } from '../snippets/generate.js';
import { buildSpecs } from '../specs';
import type { Language } from '../types.js';

import type { LangArg } from './utils.js';
import { ALL, getClientChoices, generatorList, transformSelection, PROMPT_CLIENTS, PROMPT_LANGUAGES } from './utils.js';
import { buildClients, buildPlaygrounds, buildSnippets } from '../buildClients.ts';
import { CI, CLIENTS, LANGUAGES, run, setVerbose } from '../common.ts';
import { getLanguageFolder } from '../config.ts';
import { ctsGenerateMany } from '../cts/generate.ts';
import { runCts } from '../cts/runCts.ts';
import { startTestServer } from '../cts/testServer/index.ts';
import { formatter } from '../formatter.ts';
import { generate } from '../generate.ts';
import { playground } from '../playground.ts';
import { createReleasePR } from '../release/createReleasePR.ts';
import { generateSLA } from '../release/sla.ts';
import { snippetsGenerateMany } from '../snippets/generate.ts';
import { buildSpecs } from '../specs/index.ts';
import type { Language } from '../types.ts';

import type { LangArg } from './utils.ts';
import { ALL, getClientChoices, generatorList, transformSelection, PROMPT_CLIENTS, PROMPT_LANGUAGES } from './utils.ts';

const args = {
language: new Argument('[language]', 'The language').choices(PROMPT_LANGUAGES),
Expand Down
4 changes: 2 additions & 2 deletions scripts/cli/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CLIENTS, GENERATORS, LANGUAGES } from '../common.js';
import type { Generator, Language } from '../types.js';
import { CLIENTS, GENERATORS, LANGUAGES } from '../common.ts';
import type { Generator, Language } from '../types.ts';

export const ALL = 'all';
export const PROMPT_LANGUAGES = [ALL, ...LANGUAGES];
Expand Down
20 changes: 10 additions & 10 deletions scripts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import { execaCommand, execa } from 'execa';
import type { ExecaError } from 'execa';
import { remove } from 'fs-extra';

import clientsConfig from '../config/clients.config.json' assert { type: 'json' };
import releaseConfig from '../config/release.config.json' assert { type: 'json' };

import { Cache } from './cache';
import { getDockerImage } from './config';
import { generateOpenapitools } from './pre-gen';
import { getGitAuthor } from './release/common.js';
import { buildSpecs } from './specs';
import { createSpinner } from './spinners.js';
import type { Generator, GeneratorMode, Language, RunOptions } from './types.js';
import clientsConfig from '../config/clients.config.json' with { type: 'json' };
import releaseConfig from '../config/release.config.json' with { type: 'json' };

import { Cache } from './cache.ts';
import { getDockerImage } from './config.ts';
import { generateOpenapitools } from './pre-gen/index.ts';
import { getGitAuthor } from './release/common.ts';
import { buildSpecs } from './specs/index.ts';
import { createSpinner } from './spinners.ts';
import type { Generator, GeneratorMode, Language, RunOptions } from './types.ts';

export const fullReleaseConfig = releaseConfig;

Expand Down
6 changes: 3 additions & 3 deletions scripts/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import clientsConfig from '../config/clients.config.json' assert { type: 'json' };
import clientsConfig from '../config/clients.config.json' with { type: 'json' };

import { CI } from './common';
import type { Language, LanguageConfig } from './types.js';
import { CI } from './common.ts';
import type { Language, LanguageConfig } from './types.ts';

export function getClientsConfigField(
language: Language,
Expand Down
8 changes: 4 additions & 4 deletions scripts/cts/generate.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { callGenerator, run, setupAndGen } from '../common.js';
import { getTestOutputFolder } from '../config.js';
import { formatter } from '../formatter.js';
import type { Generator } from '../types.js';
import { callGenerator, run, setupAndGen } from '../common.ts';
import { getTestOutputFolder } from '../config.ts';
import { formatter } from '../formatter.ts';
import type { Generator } from '../types.ts';

export async function ctsGenerateMany(generators: Generator[], languageVersion = ''): Promise<void> {
await setupAndGen(
Expand Down
20 changes: 10 additions & 10 deletions scripts/cts/runCts.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import fsp from 'fs/promises';

import { exists, isVerbose, run, runComposerInstall, toAbsolutePath } from '../common.js';
import { getTestOutputFolder } from '../config.js';
import { createSpinner } from '../spinners.js';
import type { Language } from '../types.js';
import { exists, isVerbose, run, runComposerInstall, toAbsolutePath } from '../common.ts';
import { getTestOutputFolder } from '../config.ts';
import { createSpinner } from '../spinners.ts';
import type { Language } from '../types.ts';

import { startTestServer } from './testServer';
import { printBenchmarkReport } from './testServer/benchmark.js';
import { assertChunkWrapperValid } from './testServer/chunkWrapper.js';
import { assertValidReplaceAllObjects } from './testServer/replaceAllObjects.js';
import { assertValidTimeouts } from './testServer/timeout.js';
import { assertValidWaitForApiKey } from './testServer/waitFor.js';
import { printBenchmarkReport } from './testServer/benchmark.ts';
import { assertChunkWrapperValid } from './testServer/chunkWrapper.ts';
import { startTestServer } from './testServer/index.ts';
import { assertValidReplaceAllObjects } from './testServer/replaceAllObjects.ts';
import { assertValidTimeouts } from './testServer/timeout.ts';
import { assertValidWaitForApiKey } from './testServer/waitFor.ts';

export type CTSType = 'benchmark' | 'client' | 'e2e' | 'requests';

Expand Down
2 changes: 1 addition & 1 deletion scripts/cts/testServer/apiKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Server } from 'http';
import { expect } from 'chai';
import type { Express, Request, Response } from 'express';

import { setupServer } from '.';
import { setupServer } from './index.ts';

function addRoutes(app: Express): void {
app.get('/check-api-key/1', (req: Request, res: Response) => {
Expand Down
4 changes: 2 additions & 2 deletions scripts/cts/testServer/benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import chalk from 'chalk';
import express from 'express';
import type { Express } from 'express';

import { CI, toAbsolutePath } from '../../common';
import { CI, toAbsolutePath } from '../../common.ts';

import { setupServer } from '.';
import { setupServer } from './index.ts';

const benchmarkStatus: Record<
string,
Expand Down
Loading
Loading