Skip to content

Commit

Permalink
Merge pull request #17 from Exabyte-io/feat/SOF-6398-1
Browse files Browse the repository at this point in the history
SOF-6398-1: prettier reformat
  • Loading branch information
timurbazhirov authored Nov 18, 2022
2 parents 6542756 + 9f1d7f8 commit bfdf016
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 27 deletions.
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"singleQuote": false,
"printWidth": 100,
"trailingComma": "all",
"tabWidth": 4
}

36 changes: 33 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
"description": "Application DEfinitions",
"scripts": {
"test": "nyc --reporter=text mocha --recursive --bail --require @babel/register/lib --require tests/setup.js tests",
"lint": "eslint src tests",
"lint:fix": "eslint --fix --cache src tests",
"lint": "eslint src tests && prettier --write src tests",
"lint:fix": "eslint --fix --cache src tests && prettier --write src tests",
"transpile": "babel --out-dir dist src",
"postinstall": "npm run transpile",
"prettier": "prettier --check src tests",
"prepare": "husky install"
},
"repository": {
Expand Down Expand Up @@ -45,14 +46,16 @@
},
"devDependencies": {
"@exabyte-io/code.js": "2022.11.11-0",
"@exabyte-io/eslint-config": "^2022.11.16-0",
"@exabyte-io/eslint-config": "^2022.11.17-0",
"@exabyte-io/made.js": "2022.6.15-0",
"chai": "^4.3.4",
"eslint": "7.32.0",
"eslint-config-airbnb": "19.0.2",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "2.25.3",
"eslint-plugin-jsdoc": "37.1.0",
"eslint-plugin-jsx-a11y": "6.5.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "7.30.0",
"eslint-plugin-simple-import-sort": "7.0.0",
"husky": "^7.0.4",
Expand All @@ -69,6 +72,7 @@
"node": ">=12.0.0"
},
"lint-staged": {
"*.js": "eslint --cache --fix"
"*.js": "eslint --cache --fix",
"*.{js,css}": "prettier --write"
}
}
4 changes: 1 addition & 3 deletions src/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ export class Application extends NamedDefaultableInMemoryEntity {
get executables() {
const tree = getAppTree(this.prop("name"));
return Object.keys(tree).map((key) => {
return new this.constructor.Executable(
{ ...tree[key], name: key },
);
return new this.constructor.Executable({ ...tree[key], name: key });
});
}

Expand Down
4 changes: 3 additions & 1 deletion src/flavor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { mix } from "mixwith";
import { Template } from "./template";

export class Flavor extends mix(NamedDefaultableInMemoryEntity).with(RuntimeItemsMixin) {
get input() { return this.prop("input", []); }
get input() {
return this.prop("input", []);
}

// TODO : prevent this from running in client
get inputAsTemplates() {
Expand Down
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {
allApplications, allowedMonitors, allowedResults, allTemplates,
allApplications,
allowedMonitors,
allowedResults,
allTemplates,
} from "@exabyte-io/application-flavors.js";

import { Application } from "./application";
Expand Down
14 changes: 7 additions & 7 deletions src/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ export class Template extends NamedInMemoryEntity {

render(externalContext) {
const renderingContext = this.getRenderingContext(externalContext);
let template,
rendered;
let template, rendered;
if (!this.isManuallyChanged) {
try {
template = jinja.compile(this.content);
Expand Down Expand Up @@ -85,9 +84,10 @@ export class Template extends NamedInMemoryEntity {

static fromFlavor(appName, execName, inputName) {
const filtered = allTemplates.filter(
(temp) => temp.applicationName === appName
&& temp.executableName === execName
&& temp.name === inputName,
(temp) =>
temp.applicationName === appName &&
temp.executableName === execName &&
temp.name === inputName,
);
if (filtered.length !== 1) {
console.log(
Expand All @@ -105,8 +105,8 @@ export class Template extends NamedInMemoryEntity {
getContextProvidersAsClassInstances(providerContext) {
const me = this;
return this.contextProviders.map((p) => {
const { constructor, config } = me.constructor.providerRegistry
.findProviderInstanceByName(p.name);
const { constructor, config } =
me.constructor.providerRegistry.findProviderInstanceByName(p.name);
const clsInstance = new constructor({
...config,
context: providerContext,
Expand Down
17 changes: 9 additions & 8 deletions src/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ export function getAllApplications(cls = null) {
const applicationsArray = [];
allApplications.forEach((appName) => {
applicationsTree[appName] = {};
const {
versions, defaultVersion, build = "Default", ...appData
} = getAppData(appName);
const { versions, defaultVersion, build = "Default", ...appData } = getAppData(appName);
applicationsTree[appName].defaultVersion = defaultVersion;
versions.forEach((options) => {
const { version } = options;
Expand All @@ -40,9 +38,7 @@ export function getAllApplications(cls = null) {
* @param build {String} the build to use (optional, defaults to Default)
* @return {*} an application
*/
export function getApplication({
applicationsTree, name, version = null, build = "Default",
}) {
export function getApplication({ applicationsTree, name, version = null, build = "Default" }) {
const app = applicationsTree[name];
// eslint-disable-next-line no-param-reassign
if (!version) version = app.defaultVersion;
Expand All @@ -60,7 +56,10 @@ const { applicationsTree } = getAllApplications(null);
*/
export function getApplicationConfig({ name, version = null, build = "Default" }) {
return getApplication({
applicationsTree, name, version, build,
applicationsTree,
name,
version,
build,
});
}

Expand All @@ -72,7 +71,9 @@ export function getApplicationConfig({ name, version = null, build = "Default" }
*/
export function getExecutableConfig({ appName, execName }) {
const appTree = getAppTree(appName);
Object.entries(appTree).forEach(([name, exec]) => { exec.name = name; });
Object.entries(appTree).forEach(([name, exec]) => {
exec.name = name;
});
if (!execName) return getOneMatchFromObject(appTree, "isDefault", true);
return appTree[execName];
}
Expand Down

0 comments on commit bfdf016

Please sign in to comment.