Skip to content

Commit

Permalink
chore(scripts): try experimental-strip-types [skip-bc] (#3764)
Browse files Browse the repository at this point in the history
  • Loading branch information
millotp authored Jan 9, 2025
1 parent b012ca8 commit 4f82b4b
Show file tree
Hide file tree
Showing 61 changed files with 231 additions and 247 deletions.
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_ENABLE_IMMUTABLE_INSTALLS=false 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: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
"build": "yarn build:eslint && yarn scripts:build",
"build:eslint": "yarn workspace eslint-plugin-automation-custom build && yarn install",
"clean": "rm -rf **/dist **/build **/.build **/node_modules **/.gradle **/vendor **/bin **/obj **/__pycache__ || true",
"cli": "cd scripts && yarn build:cli && yarn start",
"cli": "yarn workspace scripts start",
"docker:setup": "./scripts/docker/setup.sh",
"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 $0 --fix",
Expand All @@ -40,7 +40,6 @@
"husky": "9.1.7",
"lint-staged": "15.3.0",
"oxlint": "0.11.1",
"pinst": "3.0.0",
"prettier": "3.4.2",
"prettier-plugin-java": "2.6.5",
"prettier-plugin-organize-imports": "4.1.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
10 changes: 5 additions & 5 deletions scripts/buildLanguages.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { existsSync } from 'node:fs';

import { createClientName, run, toAbsolutePath } from './common.js';
import { getLanguageFolder } from './config.js';
import { formatter } from './formatter.js';
import { createSpinner } from './spinners.js';
import type { Generator, Language } from './types.js';
import { createClientName, run, toAbsolutePath } from './common.ts';
import { getLanguageFolder } from './config.ts';
import { formatter } from './formatter.ts';
import { createSpinner } from './spinners.ts';
import type { Generator, Language } from './types.ts';

type BuildType = 'client' | 'guides' | '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.js';
import { exists } from './common.ts';

export class Cache {
folder: string;
Expand Down
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
12 changes: 6 additions & 6 deletions scripts/ci/codegen/createGitHubReleases.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import fsp from 'fs/promises';
import { ensureGitHubToken, getOctokit, OWNER, run, setVerbose, toAbsolutePath } from '../../common.js';
import { isPreRelease } from '../../release/versionsHistory.js';
import type { Language } from '../../types.js';
import { cloneRepository } from '../utils.js';
import { ensureGitHubToken, getOctokit, OWNER, run, setVerbose, toAbsolutePath } from '../../common.ts';
import { isPreRelease } from '../../release/versionsHistory.ts';
import type { Language } from '../../types.ts';
import { cloneRepository } from '../utils.ts';

import { resolve } from 'path';
import { stripCommitMessage } from '../../release/common.js';
import { commitStartRelease } from './text.js';
import { stripCommitMessage } from '../../release/common.ts';
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,9 +1,9 @@
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
10 changes: 5 additions & 5 deletions scripts/ci/codegen/pushToRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import {
run,
setVerbose,
toAbsolutePath,
} from '../../common.js';
import { getNbGitDiff } from '../utils.js';
import { GuidesToPush, pushToRepositoryConfiguration, RepositoryConfiguration, SpecsToPush } from './types.js';
} from '../../common.ts';
import { getNbGitDiff } from '../utils.ts';
import { GuidesToPush, pushToRepositoryConfiguration, RepositoryConfiguration, SpecsToPush } from './types.ts';

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

async function handleSpecFiles(spec: SpecsToPush, tempGitDir: string): Promise<void> {
const pathToSpecs = toAbsolutePath(`${tempGitDir}/${spec.output}`);
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 @@ -11,13 +11,13 @@ import {
run,
setVerbose,
toAbsolutePath,
} 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,11 +1,11 @@
import type { components } from '@octokit/openapi-types';

import { exists, getOctokit, run, setVerbose, toAbsolutePath } from '../../common.js';
import { getClientsConfigField, getLanguageFolder } from '../../config.js';
import { getTargetBranch } from '../../release/common.js';
import type { Language } from '../../types.js';
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.js';
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 @@ -2,11 +2,11 @@ import fsp from 'fs/promises';

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

import { CLIENTS, createClientName, exists, GENERATORS, LANGUAGES, toAbsolutePath } from '../../common.js';
import { getClientsConfigField, getLanguageFolder, getTestExtension, getTestOutputFolder } from '../../config.js';
import { CLIENTS, createClientName, exists, GENERATORS, LANGUAGES, toAbsolutePath } from '../../common.ts';
import { getClientsConfigField, getLanguageFolder, getTestExtension, getTestOutputFolder } 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,6 +1,6 @@
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,9 +1,9 @@
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
30 changes: 15 additions & 15 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 { buildLanguages } from '../buildLanguages.js';
import { CI, CLIENTS, LANGUAGES, run, setVerbose, toAbsolutePath } 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/index.js';
import { docsGenerateMany } from '../docs/generate.js';
import { formatter } from '../formatter.js';
import { generate } from '../generate.js';
import { playground } from '../playground.js';
import { createReleasePR } from '../release/createReleasePR.js';
import { buildSpecs } from '../specs/index.js';
import type { Language } from '../types.js';
import { buildLanguages } from '../buildLanguages.ts';
import { CI, CLIENTS, LANGUAGES, run, setVerbose, toAbsolutePath } 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 { docsGenerateMany } from '../docs/generate.ts';
import { formatter } from '../formatter.ts';
import { generate } from '../generate.ts';
import { playground } from '../playground.ts';
import { createReleasePR } from '../release/createReleasePR.ts';
import { buildSpecs } from '../specs/index.ts';
import type { Language } from '../types.ts';

import { existsSync } from 'node:fs';
import type { LangArg } from './utils.js';
import { ALL, generatorList, getClientChoices, PROMPT_CLIENTS, PROMPT_LANGUAGES, transformSelection } from './utils.js';
import type { LangArg } from './utils.ts';
import { ALL, generatorList, getClientChoices, PROMPT_CLIENTS, PROMPT_LANGUAGES, transformSelection } 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
22 changes: 10 additions & 12 deletions scripts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@ import type { ExecaError } from 'execa';
import { execa, execaCommand } 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.js';
import { getDockerImage } from './config.js';
import { generateOpenapitools } from './pre-gen/index.js';
import { getGitAuthor } from './release/common.js';
import { buildSpecs } from './specs/index.js';
import { createSpinner } from './spinners.js';
import type { Generator, GeneratorMode, Language, RunOptions } from './types.js';

export const fullReleaseConfig = releaseConfig;
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 MAIN_BRANCH = releaseConfig.mainBranch;
export const OWNER = releaseConfig.owner;
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.js';
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
24 changes: 12 additions & 12 deletions scripts/cts/runCts.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
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 { printBenchmarkReport } from './testServer/benchmark.js';
import { assertChunkWrapperValid } from './testServer/chunkWrapper.js';
import { startTestServer } from './testServer/index.js';
import { assertValidReplaceAllObjects } from './testServer/replaceAllObjects.js';
import { assertValidReplaceAllObjectsFailed } from './testServer/replaceAllObjectsFailed.js';
import { assertValidReplaceAllObjectsScopes } from './testServer/replaceAllObjectsScopes.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 { assertValidReplaceAllObjectsFailed } from './testServer/replaceAllObjectsFailed.ts';
import { assertValidReplaceAllObjectsScopes } from './testServer/replaceAllObjectsScopes.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 './index.js';
import { setupServer } from './index.ts';

// Checks that the client sends a different API key after the first request.
function addRoutes(app: Express): void {
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 @@ -6,9 +6,9 @@ import chalk from 'chalk';
import type { Express } from 'express';
import express from 'express';

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

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

const benchmarkStatus: Record<
string,
Expand Down
Loading

0 comments on commit 4f82b4b

Please sign in to comment.