Skip to content

Commit

Permalink
chore!: upgrade @liangskyli/utils
Browse files Browse the repository at this point in the history
BREAKING CHANGE: prettierData from async to sync
  • Loading branch information
liangskyli committed May 1, 2023
1 parent 26266d5 commit 28e6105
Show file tree
Hide file tree
Showing 10 changed files with 1,832 additions and 5,067 deletions.
2 changes: 1 addition & 1 deletion packages/openapi-gen-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"update:deps": "pnpm update --interactive --latest"
},
"dependencies": {
"@liangskyli/utils": "^2.0.0-beta.0",
"@liangskyli/utils": "^2.0.0-beta.2",
"axios": "^1.3.6",
"commander": "^10.0.1",
"fs-extra": "^11.1.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/openapi-gen-ts/src/gen/file/gen-interface-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ export class GenInterfaceApi {
return this.interfaceAPIType.join('');
}

public async writeFile() {
public writeFile() {
const { genTsAbsolutePath, prettierOptions } = this.opts;
const interfaceAPITypeAbsolutePath = path.join(
genTsAbsolutePath,
'interface-api.ts',
);

await writePrettierFile({
writePrettierFile({
prettierOptions,
absolutePath: interfaceAPITypeAbsolutePath,
data: this.toString(),
Expand Down
4 changes: 2 additions & 2 deletions packages/openapi-gen-ts/src/gen/file/gen-request-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ export class GenRequestApi {
return this.requestAPI.join('');
}

public async writeFile() {
public writeFile() {
const { genTsAbsolutePath, prettierOptions } = this.opts;

const requestAPIAbsolutePath = path.join(
genTsAbsolutePath,
'request-api.ts',
);

await writePrettierFile({
writePrettierFile({
prettierOptions,
absolutePath: requestAPIAbsolutePath,
data: this.toString(),
Expand Down
4 changes: 2 additions & 2 deletions packages/openapi-gen-ts/src/gen/file/gen-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ export class GenRequest {
this.requestString = requestData.join('');
}

public async writeFile() {
public writeFile() {
const { genTsAbsolutePath, prettierOptions } = this.opts;
const requestDataAbsolutePath = path.join(genTsAbsolutePath, 'request.ts');

await writePrettierFile({
writePrettierFile({
prettierOptions,
absolutePath: requestDataAbsolutePath,
data: this.requestString,
Expand Down
4 changes: 2 additions & 2 deletions packages/openapi-gen-ts/src/gen/file/gen-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ export class GenSchema {
return prettierOptions;
}

public async writeFile() {
public writeFile() {
const { genTsAbsolutePath } = this.opts;
const schemaPath = path.join(genTsAbsolutePath, 'schema.json');

await writePrettierFile({
writePrettierFile({
prettierOptions: this.getPrettierOptions(),
absolutePath: schemaPath,
data: this.toString(),
Expand Down
4 changes: 2 additions & 2 deletions packages/openapi-gen-ts/src/gen/file/gen-ts-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export class GenTsSchema {
});
}

public async writeFile() {
public writeFile() {
const { genTsAbsolutePath, prettierOptions } = this.opts;
const tsSchemaPath = path.join(genTsAbsolutePath, 'ts-schema.ts');

await writePrettierFile({
writePrettierFile({
prettierOptions,
absolutePath: tsSchemaPath,
data: this.schemaString,
Expand Down
8 changes: 4 additions & 4 deletions packages/openapi-gen-ts/src/gen/gen-interface-request-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export type IReturnTypeProcessMethodMediaData = ReturnType<
typeof processMethodMediaData
>;

const genInterfaceRequestFile = async (opts: IGenInterfaceRequestFile) => {
const genInterfaceRequestFile = (opts: IGenInterfaceRequestFile) => {
const {
genTsAbsolutePath,
prettierOptions,
Expand All @@ -87,7 +87,7 @@ const genInterfaceRequestFile = async (opts: IGenInterfaceRequestFile) => {
if (!requestFilePath) {
requestParamsType = 'AxiosRequestConfig';
const genRequest = new GenRequest({ genTsAbsolutePath, prettierOptions });
await genRequest.writeFile();
genRequest.writeFile();
}

const genInterfaceAPIType = new GenInterfaceApi({
Expand Down Expand Up @@ -124,8 +124,8 @@ const genInterfaceRequestFile = async (opts: IGenInterfaceRequestFile) => {
});
}

await genInterfaceAPIType.writeFile();
await genRequestAPI.writeFile();
genInterfaceAPIType.writeFile();
genRequestAPI.writeFile();
};

export { genInterfaceRequestFile };
6 changes: 3 additions & 3 deletions packages/openapi-gen-ts/src/gen/generator-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const generatorFile = async (opts: IGeneratorFile) => {
prettierOptions,
});
await genTsSchema.generator();
const tsSchemaPath = await genTsSchema.writeFile();
const tsSchemaPath = genTsSchema.writeFile();

// 生成schema file
const genSchema = new GenSchema({
Expand All @@ -37,11 +37,11 @@ const generatorFile = async (opts: IGeneratorFile) => {
prettierOptions,
typescriptJsonSchemaOptions,
});
await genSchema.writeFile();
genSchema.writeFile();
const schemaDefinition = genSchema.schemaDefinition;

// 生成接口(请求,类型)文件
await genInterfaceRequestFile({
genInterfaceRequestFile({
genTsAbsolutePath,
prettierOptions,
requestFile,
Expand Down
4 changes: 2 additions & 2 deletions packages/openapi-gen-ts/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ type IWriteFileOpts = {
data: string;
successTip: string;
};
export const writePrettierFile = async (opts: IWriteFileOpts) => {
export const writePrettierFile = (opts: IWriteFileOpts) => {
const { absolutePath, prettierOptions, data, successTip } = opts;

fs.writeFileSync(
absolutePath,
await prettierData(data, copyOptions(prettierOptions)),
prettierData(data, copyOptions(prettierOptions)),
);

console.info(colors.green(successTip));
Expand Down
Loading

0 comments on commit 28e6105

Please sign in to comment.