Skip to content

Commit 7320f31

Browse files
Merge pull request #1677 from friederbluemle/update-prettier
2 parents eda7bf2 + 5e5c54f commit 7320f31

File tree

599 files changed

+24453
-24055
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

599 files changed

+24453
-24055
lines changed

.prettierrc.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
22
"singleQuote": true,
3-
"semi": false,
4-
"trailingComma": "es5"
3+
"trailingComma": "all"
54
}

ern-api-gen/src/AbstractGenerator.ts

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
import { log } from 'ern-core'
2-
import _F from './java/File'
3-
import fs from 'fs'
4-
import path from 'path'
1+
import { log } from 'ern-core';
2+
import _F from './java/File';
3+
import fs from 'fs';
4+
import path from 'path';
55

6-
const File = _F
6+
const File = _F;
77

8-
const ABSTRACT_SEARCH_PATHS = [path.join(__dirname, '..', 'resources')]
8+
const ABSTRACT_SEARCH_PATHS = [path.join(__dirname, '..', 'resources')];
99

1010
export default class AbstractGenerator {
11-
public static SEARCH_PATHS = ABSTRACT_SEARCH_PATHS
11+
public static SEARCH_PATHS = ABSTRACT_SEARCH_PATHS;
1212

1313
public writeToFile(filename, contents) {
14-
log.info('writing file ' + filename)
15-
const f = new File(filename)
16-
f.getParentFile().mkdirs()
17-
return fs.writeFileSync(f.getPath(), contents, 'utf8')
14+
log.info('writing file ' + filename);
15+
const f = new File(filename);
16+
f.getParentFile().mkdirs();
17+
return fs.writeFileSync(f.getPath(), contents, 'utf8');
1818
}
1919

2020
public readTemplate(name) {
21-
const reader = this.getTemplateReader(name)
21+
const reader = this.getTemplateReader(name);
2222
if (reader == null) {
23-
throw new Error(`no file found for "${name}"`)
23+
throw new Error(`no file found for "${name}"`);
2424
}
25-
return reader
25+
return reader;
2626
}
2727

2828
public getTemplateReader(name) {
29-
const f = this._resolveFilePath(name)
29+
const f = this._resolveFilePath(name);
3030
if (f == null) {
31-
throw new Error("can't load template " + name)
31+
throw new Error("can't load template " + name);
3232
}
3333
try {
34-
return fs.readFileSync(f, 'utf-8')
34+
return fs.readFileSync(f, 'utf-8');
3535
} catch (e) {
36-
log.trace(e)
36+
log.trace(e);
3737
}
3838
}
3939

@@ -48,73 +48,73 @@ export default class AbstractGenerator {
4848
* @return String Full template file path
4949
*/
5050
public getFullTemplateFile(config, templateFile) {
51-
const library = config.getLibrary()
51+
const library = config.getLibrary();
5252
if (library) {
5353
const libTemplateFile = this._resolveFilePath(
5454
config.embeddedTemplateDir(),
5555
'libraries',
5656
library,
57-
templateFile
58-
)
57+
templateFile,
58+
);
5959
if (libTemplateFile != null) {
60-
return libTemplateFile
60+
return libTemplateFile;
6161
}
6262
}
6363

6464
const embeddedTemplate = this._resolveFilePath(
6565
config.embeddedTemplateDir(),
66-
templateFile
67-
)
66+
templateFile,
67+
);
6868
if (embeddedTemplate != null) {
69-
return embeddedTemplate
69+
return embeddedTemplate;
7070
}
7171

72-
const template = this._resolveFilePath(config.templateDir(), templateFile)
72+
const template = this._resolveFilePath(config.templateDir(), templateFile);
7373
if (template != null) {
74-
return template
74+
return template;
7575
}
7676
}
7777

7878
public readResourceContents(resourceFilePath) {
79-
const file = this._resolveFilePath(resourceFilePath)
79+
const file = this._resolveFilePath(resourceFilePath);
8080
if (file == null) {
81-
log.warn(`Could not resolve ${resourceFilePath}`)
82-
return
81+
log.warn(`Could not resolve ${resourceFilePath}`);
82+
return;
8383
}
8484

85-
return fs.readFileSync(file, 'utf8')
85+
return fs.readFileSync(file, 'utf8');
8686
}
8787

8888
public embeddedTemplateExists(name) {
89-
const f = this._resolveFile(name)
90-
return f != null
89+
const f = this._resolveFile(name);
90+
return f != null;
9191
}
9292

9393
public getCPResourcePath(name) {
9494
if (!('/' === File.separator)) {
95-
return name.replace(new RegExp(File.separator, 'g'), '/')
95+
return name.replace(new RegExp(File.separator, 'g'), '/');
9696
}
97-
return name
97+
return name;
9898
}
9999

100100
protected _resolveFilePath(...paths) {
101-
const f = this._resolveFile(...paths)
101+
const f = this._resolveFile(...paths);
102102
if (f == null) {
103-
return
103+
return;
104104
}
105-
return f.getAbsolutePath()
105+
return f.getAbsolutePath();
106106
}
107107

108108
protected _resolveFile(...paths) {
109109
for (const p of AbstractGenerator.SEARCH_PATHS) {
110-
const file = new File(p, ...paths)
110+
const file = new File(p, ...paths);
111111
if (file.exists()) {
112-
return file
112+
return file;
113113
}
114114
}
115-
const last = new File(paths.shift(), ...paths)
115+
const last = new File(paths.shift(), ...paths);
116116
if (last.exists()) {
117-
return last
117+
return last;
118118
}
119119
}
120120
}

ern-api-gen/src/ApiGenUtils.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import CodegenConfigurator from './config/CodegenConfigurator'
2-
import DefaultGenerator from './DefaultGenerator'
1+
import CodegenConfigurator from './config/CodegenConfigurator';
2+
import DefaultGenerator from './DefaultGenerator';
33

44
export default class ApiGenUtils {
55
/**
@@ -11,44 +11,44 @@ export default class ApiGenUtils {
1111
inputSpec: swaggerSchemaFile,
1212
lang: 'ERNAndroid', // Using android as a reference language, apiName, requests and responses will be same for all the langs.
1313
outputDir: 'fake',
14-
}
15-
const cc = new CodegenConfigurator(config)
16-
const opts = await cc.toClientOptInput()
17-
const generator = new DefaultGenerator().opts(opts)
18-
const apis = generator.processPaths(generator.swagger.getPaths()).value
14+
};
15+
const cc = new CodegenConfigurator(config);
16+
const opts = await cc.toClientOptInput();
17+
const generator = new DefaultGenerator().opts(opts);
18+
const apis = generator.processPaths(generator.swagger.getPaths()).value;
1919

2020
const result: Array<{
21-
apiName: string
22-
requests: string[]
23-
events: string[]
24-
}> = []
21+
apiName: string;
22+
requests: string[];
23+
events: string[];
24+
}> = [];
2525
for (const apiKey in apis) {
2626
if (apis.hasOwnProperty(apiKey)) {
2727
const {
2828
requests,
2929
events,
30-
} = ApiGenUtils.generateApiEventsAndRequestNames(apis[apiKey])
31-
result.push({ apiName: apiKey, requests, events })
30+
} = ApiGenUtils.generateApiEventsAndRequestNames(apis[apiKey]);
31+
result.push({ apiName: apiKey, requests, events });
3232
}
3333
}
34-
return result
34+
return result;
3535
} catch (e) {
36-
throw new Error(`Unable to extract the apis: ${e}`)
36+
throw new Error(`Unable to extract the apis: ${e}`);
3737
}
3838
}
3939

4040
public static generateApiEventsAndRequestNames(
41-
api: any
41+
api: any,
4242
): { requests: string[]; events: string[] } {
43-
const requests: string[] = []
44-
const events: string[] = []
43+
const requests: string[] = [];
44+
const events: string[] = [];
4545
for (const key in api) {
4646
if (api.hasOwnProperty(key) && api[key].httpMethod === `EVENT`) {
47-
events.push(api[key].camelizedNickName)
47+
events.push(api[key].camelizedNickName);
4848
} else {
49-
requests.push(api[key].camelizedNickName)
49+
requests.push(api[key].camelizedNickName);
5050
}
5151
}
52-
return { requests, events }
52+
return { requests, events };
5353
}
5454
}

ern-api-gen/src/CliOption.ts

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,99 @@
11
/* tslint:disable:variable-name */
2-
import { BooleanProperty, StringProperty } from './models/properties'
3-
import { newHashMap } from './java/javaUtil'
4-
import StringBuilder from './java/StringBuilder'
2+
import { BooleanProperty, StringProperty } from './models/properties';
3+
import { newHashMap } from './java/javaUtil';
4+
import StringBuilder from './java/StringBuilder';
55

66
export default class CliOption {
77
public static newBoolean(opt, description) {
88
return new CliOption(opt, description, BooleanProperty.TYPE).defaultValue(
9-
'false'
10-
)
9+
'false',
10+
);
1111
}
1212

1313
public static newString(opt, description) {
14-
return new CliOption(opt, description, StringProperty.TYPE)
14+
return new CliOption(opt, description, StringProperty.TYPE);
1515
}
1616

17-
private opt
18-
private description
19-
private enumValues
20-
private type
21-
private __defaultValue
17+
private opt;
18+
private description;
19+
private enumValues;
20+
private type;
21+
private __defaultValue;
2222

2323
public constructor(
2424
opt,
2525
description,
2626
type = StringProperty.TYPE,
2727
short?: any,
2828
enumValues?: any,
29-
required?: any
29+
required?: any,
3030
) {
31-
this.opt = opt
32-
this.description = description
33-
this.type = type
31+
this.opt = opt;
32+
this.description = description;
33+
this.type = type;
3434
}
3535

3636
public getOpt() {
37-
return this.opt
37+
return this.opt;
3838
}
3939

4040
public getDescription() {
41-
return this.description
41+
return this.description;
4242
}
4343

4444
public setDescription(description) {
45-
this.description = description
45+
this.description = description;
4646
}
4747

4848
public getType() {
49-
return this.type
49+
return this.type;
5050
}
5151

5252
public setType(type) {
53-
this.type = type
53+
this.type = type;
5454
}
5555

5656
public getDefault() {
57-
return this.__defaultValue
57+
return this.__defaultValue;
5858
}
5959

6060
public setDefault(defaultValue) {
61-
this.__defaultValue = defaultValue
61+
this.__defaultValue = defaultValue;
6262
}
6363

6464
public defaultValue(defaultValue) {
65-
this.__defaultValue = defaultValue
66-
return this
65+
this.__defaultValue = defaultValue;
66+
return this;
6767
}
6868

6969
public addEnum(value, description) {
7070
if (this.enumValues == null) {
71-
this.enumValues = newHashMap()
71+
this.enumValues = newHashMap();
7272
}
7373
if (!this.enumValues.containsKey(value)) {
74-
this.enumValues.put(value, description)
74+
this.enumValues.put(value, description);
7575
}
76-
return this
76+
return this;
7777
}
7878

7979
public getEnum() {
80-
return this.enumValues
80+
return this.enumValues;
8181
}
8282

8383
public setEnum(enumValues) {
84-
this.enumValues = enumValues
84+
this.enumValues = enumValues;
8585
}
8686

8787
public getOptionHelp() {
88-
const sb = StringBuilder(this.description)
88+
const sb = StringBuilder(this.description);
8989
if (this.__defaultValue != null) {
90-
sb.append(' (Default: ')
91-
.append(this.__defaultValue)
92-
.append(')')
90+
sb.append(' (Default: ').append(this.__defaultValue).append(')');
9391
}
9492
if (this.enumValues != null) {
9593
for (const [key, value] of this.enumValues) {
96-
sb.append('\n ')
97-
.append(key)
98-
.append(' - ')
99-
.append(value)
94+
sb.append('\n ').append(key).append(' - ').append(value);
10095
}
10196
}
102-
return sb.toString()
97+
return sb.toString();
10398
}
10499
}

0 commit comments

Comments
 (0)