Skip to content

chore(ci): spread code correctly #326

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

Merged
merged 1 commit into from
Apr 4, 2022
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
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