Skip to content

Commit

Permalink
Merge branch 'main' into feat/customRequest-cts
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts authored Apr 4, 2022
2 parents 558cbf0 + b607c5f commit 370a7ac
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
6 changes: 5 additions & 1 deletion scripts/ci/codegen/spreadGeneration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/* eslint-disable no-console */
import { copy } from 'fs-extra';

import {
emptyDirExceptForDotGit,
gitBranchExists,
gitCommit,
LANGUAGES,
Expand Down Expand Up @@ -71,7 +74,8 @@ async function spreadGeneration(): Promise<void> {
});

const clientPath = toAbsolutePath(getLanguageFolder(lang));
await run(`cp -r ${clientPath}/ ${tempGitDir}`);
await emptyDirExceptForDotGit(tempGitDir);
await copy(clientPath, tempGitDir, { preserveTimestamps: true });

await configureGitHubAuthor(tempGitDir);
await run(`git add .`, { cwd: tempGitDir });
Expand Down
9 changes: 9 additions & 0 deletions scripts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from 'path';

import execa from 'execa'; // https://github.com/sindresorhus/execa/tree/v5.1.1
import { hashElement } from 'folder-hash';
import { remove } from 'fs-extra';

import openapitools from '../openapitools.json';

Expand Down Expand Up @@ -280,3 +281,11 @@ export async function buildCustomGenerators(verbose: boolean): Promise<void> {
export async function gitBranchExists(branchName: string): Promise<boolean> {
return Boolean(await run(`git ls-remote --heads origin ${branchName}`));
}

export async function emptyDirExceptForDotGit(dir: string): Promise<void> {
for (const file of await fsp.readdir(dir)) {
if (file !== '.git') {
await remove(path.resolve(dir, file));
}
}
}
12 changes: 2 additions & 10 deletions scripts/release/process-release.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* eslint-disable no-console */
import fsp from 'fs/promises';
import path from 'path';

import dotenv from 'dotenv';
import execa from 'execa';
import { copy, remove } from 'fs-extra';
import { copy } from 'fs-extra';
import semver from 'semver';
import type { ReleaseType } from 'semver';

Expand All @@ -16,6 +15,7 @@ import {
exists,
getGitHubUrl,
gitCommit,
emptyDirExceptForDotGit,
} from '../common';
import { getLanguageFolder } from '../config';

Expand Down Expand Up @@ -127,14 +127,6 @@ async function updateOpenApiTools(
);
}

async function emptyDirExceptForDotGit(dir: string): Promise<void> {
for (const file of await fsp.readdir(dir)) {
if (file !== '.git') {
await remove(path.resolve(dir, file));
}
}
}

async function updateChangelog({
lang,
issueBody,
Expand Down

0 comments on commit 370a7ac

Please sign in to comment.