Skip to content

Commit 738a74d

Browse files
brollbFormat Bot
andauthored
Switch from prettier to deno fmt (#57)
* Switch from prettier to deno fmt * Fix code formatting --------- Co-authored-by: Format Bot <format-bot@netsblox.org>
1 parent 52b1b8a commit 738a74d

39 files changed

Lines changed: 7887 additions & 7833 deletions

.github/workflows/CI.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ jobs:
3434
- name: "Run Tests"
3535
run: npm test
3636

37-
prettify:
38-
name: "Prettify (Using Prettier)"
37+
format:
38+
name: "Format (deno fmt)"
3939
runs-on: "ubuntu-latest"
4040

4141
steps:
@@ -44,6 +44,21 @@ jobs:
4444
with:
4545
ref: ${{ github.head_ref }}
4646

47-
- uses: creyD/prettier_action@v4.2
47+
- name: Install Deno
48+
uses: denoland/setup-deno@v1
4849
with:
49-
prettier_options: --write **/*.{js,ts} --ignore-path ./.gitignore
50+
deno-version: v1.x
51+
- name: Format with Deno
52+
id: deno-fmt
53+
run: deno fmt
54+
- name: Check for modified files
55+
id: git-check
56+
run: echo "modified=$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)" >> $GITHUB_OUTPUT
57+
- name: Push changes
58+
if: steps.git-check.outputs.modified == 'true'
59+
run: |
60+
git config --global user.name 'Format Bot'
61+
git config --global user.email 'format-bot@netsblox.org'
62+
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
63+
git commit -am "Fix code formatting"
64+
git push

.prettierrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
"singleQuote": true,
66
"trailingComma": "es5",
77
"bracketSpacing": true
8-
}
8+
}

README.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
11
# webgme-json-importer
2-
This repo contains a utilities for importing/exporting models as JSON. The main utility is the [JSON Importer](./src/common/JSONImporter.js) which enables a WebGME node to be synchronized with a JSON representation of the target state. This has been primarily used for programmatically creating (and updating) metamodels based off of an external representation. In these cases, the workflow is:
2+
3+
This repo contains a utilities for importing/exporting models as JSON. The main
4+
utility is the [JSON Importer](./src/common/JSONImporter.js) which enables a
5+
WebGME node to be synchronized with a JSON representation of the target state.
6+
This has been primarily used for programmatically creating (and updating)
7+
metamodels based off of an external representation. In these cases, the workflow
8+
is:
9+
310
- extract the language specification from the target domain
4-
- transform the specification into the expected JSON representation (documentation available [here](./src/common/)).
5-
- import the JSON representation into a project. If you first create a node to contain the language elements (conventionally named "Language"), this can be as simple as selecting this node and running the "SetStateFromJSON" plugin).
11+
- transform the specification into the expected JSON representation
12+
(documentation available [here](./src/common/)).
13+
- import the JSON representation into a project. If you first create a node to
14+
contain the language elements (conventionally named "Language"), this can be
15+
as simple as selecting this node and running the "SetStateFromJSON" plugin).
616

717
For examples, check out the examples directory.
818

919
## Installation
20+
1021
First, install the webgme-json-importer following:
22+
1123
- [NodeJS](https://nodejs.org/en/) (LTS recommended)
1224
- [MongoDB](https://www.mongodb.com/)
1325

14-
Second, start mongodb locally by running the `mongod` executable in your mongodb installation (you may need to create a `data` directory or set `--dbpath`).
26+
Second, start mongodb locally by running the `mongod` executable in your mongodb
27+
installation (you may need to create a `data` directory or set `--dbpath`).
1528

16-
Then, install dependencies with `npm install` and start the server with `npm start`. Finally, navigate to `http://localhost:8888` to start using webgme-json-importer!
29+
Then, install dependencies with `npm install` and start the server with
30+
`npm start`. Finally, navigate to `http://localhost:8888` to start using
31+
webgme-json-importer!
1732

1833
## Specification
34+
1935
The (informal) JSON specification can be found [here](./src/common/README.md).

app.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// jshint node: true
2-
'use strict';
2+
"use strict";
33
process.chdir(__dirname);
44

5-
var gmeConfig = require('./config'),
6-
webgme = require('webgme'),
7-
myServer;
5+
var gmeConfig = require("./config"),
6+
webgme = require("webgme"),
7+
myServer;
88

99
webgme.addToRequireJsPaths(gmeConfig);
1010

1111
myServer = new webgme.standaloneServer(gmeConfig);
1212
myServer.start(function () {
13-
//console.log('server up');
13+
//console.log('server up');
1414
});

benches/README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
# webgme-json-importer benchmarks
2-
This section benchmarks the performance of different `webgme-json-importer` functionalities.
32

4-
`run-benchmarks` command line utility can be used to run a particular benchmark (or all benchmarks).
3+
This section benchmarks the performance of different `webgme-json-importer`
4+
functionalities.
5+
6+
`run-benchmarks` command line utility can be used to run a particular benchmark
7+
(or all benchmarks).
58

69
## Usage
10+
711
from the root of the repository, run the following command:
812

913
```shell
10-
benches/run-benchmarks -n applyGuidSubtree # Runs the annotation import benchmark with guids as selectors
14+
benches/run-benchmarks -n applyGuidSubtree # Runs the annotation import benchmark with guids as selectors
1115
```
16+
1217
## Details
18+
1319
```shell
1420
$ benches/run-benchmarks --help
1521
Usage: WJI benchmark [options]
1622

1723
Options:
1824
-n --benchmark-name <name> the benchmark to run (choices: "guidSelectors", "applyGuidSubtree", "all", default: "all")
1925
-h, --help display help for command
20-
```
26+
```

benches/benchmark.js

Lines changed: 92 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,109 @@
1-
const Benchmark = require('benchmark');
1+
const Benchmark = require("benchmark");
22

3-
const testFixture = require('../test/globals');
4-
const _ = testFixture.requirejs('underscore');
5-
const Core = testFixture.requirejs('common/core/coreQ');
6-
const Importer = testFixture.requirejs('webgme-json-importer/JSONImporter');
3+
const testFixture = require("../test/globals");
4+
const _ = testFixture.requirejs("underscore");
5+
const Core = testFixture.requirejs("common/core/coreQ");
6+
const Importer = testFixture.requirejs("webgme-json-importer/JSONImporter");
77
const gmeConfig = testFixture.getGmeConfig();
88
const Q = testFixture.Q;
9-
const logger = testFixture.logger.fork('JSONImporter');
10-
const projectName = 'testProject';
9+
const logger = testFixture.logger.fork("JSONImporter");
10+
const projectName = "testProject";
1111

1212
// let
1313

1414
class WJIBenchmark {
15-
constructor(projectSeedName, callable) {
16-
this.projectSeedName = projectSeedName;
17-
this.project = null;
18-
this.gmeAuth = null;
19-
this.storage = null;
20-
this.commitHash = null;
21-
this.core = null;
22-
this.branchCounter = 1;
23-
this.callable = callable;
24-
this.suite = new Benchmark.Suite();
25-
}
15+
constructor(projectSeedName, callable) {
16+
this.projectSeedName = projectSeedName;
17+
this.project = null;
18+
this.gmeAuth = null;
19+
this.storage = null;
20+
this.commitHash = null;
21+
this.core = null;
22+
this.branchCounter = 1;
23+
this.callable = callable;
24+
this.suite = new Benchmark.Suite();
25+
}
2626

27-
async getNewRootNode() {
28-
const branchName = 'test' + this.branchCounter++;
29-
await this.project.createBranch(branchName, this.commitHash);
30-
const branchHash = await this.project.getBranchHash(branchName);
31-
const commit = await Q.ninvoke(this.project, 'loadObject', branchHash);
32-
return await Q.ninvoke(this.core, 'loadRoot', commit.root);
33-
}
27+
async getNewRootNode() {
28+
const branchName = "test" + this.branchCounter++;
29+
await this.project.createBranch(branchName, this.commitHash);
30+
const branchHash = await this.project.getBranchHash(branchName);
31+
const commit = await Q.ninvoke(this.project, "loadObject", branchHash);
32+
return await Q.ninvoke(this.core, "loadRoot", commit.root);
33+
}
3434

35-
async getNewProject() {
36-
const root = await this.getNewRootNode(this.core);
37-
const fco = await this.core.loadByPath(root, '/1');
38-
const importer = new Importer(this.core, root);
39-
return {
40-
root,
41-
fco,
42-
importer,
43-
};
44-
}
35+
async getNewProject() {
36+
const root = await this.getNewRootNode(this.core);
37+
const fco = await this.core.loadByPath(root, "/1");
38+
const importer = new Importer(this.core, root);
39+
return {
40+
root,
41+
fco,
42+
importer,
43+
};
44+
}
4545

46-
async before() {
47-
await this._setupGME();
48-
}
46+
async before() {
47+
await this._setupGME();
48+
}
4949

50-
async _setupGME() {
51-
this.gmeAuth = await testFixture.clearDBAndGetGMEAuth(
52-
gmeConfig,
53-
projectName
54-
);
55-
this.storage = testFixture.getMemoryStorage(
56-
logger,
57-
gmeConfig,
58-
this.gmeAuth
59-
);
60-
await this.storage.openDatabase();
61-
const importParam = {
62-
projectSeed: testFixture.path.join(
63-
testFixture.TESTS_SEED_DIR,
64-
this.projectSeedName,
65-
`${this.projectSeedName}.webgmex`
66-
),
67-
projectName: projectName,
68-
branchName: 'master',
69-
logger: logger,
70-
gmeConfig: gmeConfig,
71-
};
50+
async _setupGME() {
51+
this.gmeAuth = await testFixture.clearDBAndGetGMEAuth(
52+
gmeConfig,
53+
projectName,
54+
);
55+
this.storage = testFixture.getMemoryStorage(
56+
logger,
57+
gmeConfig,
58+
this.gmeAuth,
59+
);
60+
await this.storage.openDatabase();
61+
const importParam = {
62+
projectSeed: testFixture.path.join(
63+
testFixture.TESTS_SEED_DIR,
64+
this.projectSeedName,
65+
`${this.projectSeedName}.webgmex`,
66+
),
67+
projectName: projectName,
68+
branchName: "master",
69+
logger: logger,
70+
gmeConfig: gmeConfig,
71+
};
7272

73-
const importResult = await testFixture.importProject(
74-
this.storage,
75-
importParam
76-
);
77-
this.project = importResult.project;
78-
this.core = new Core(this.project, {
79-
globConf: gmeConfig,
80-
logger: logger.fork('core'),
81-
});
82-
this.commitHash = importResult.commitHash;
83-
}
73+
const importResult = await testFixture.importProject(
74+
this.storage,
75+
importParam,
76+
);
77+
this.project = importResult.project;
78+
this.core = new Core(this.project, {
79+
globConf: gmeConfig,
80+
logger: logger.fork("core"),
81+
});
82+
this.commitHash = importResult.commitHash;
83+
}
8484

85-
async after() {
86-
await this.storage.closeDatabase();
87-
await this.gmeAuth.unload();
88-
}
85+
async after() {
86+
await this.storage.closeDatabase();
87+
await this.gmeAuth.unload();
88+
}
8989

90-
async run() {
91-
await this.before();
92-
const { root, fco, importer } = await this.getNewProject();
93-
await this.callable({
94-
root,
95-
fco,
96-
importer,
97-
core: this.core,
98-
suite: this.suite,
99-
});
100-
this.suite
101-
.on('complete', function () {
102-
this.forEach((bench) => console.log(bench.stats));
103-
})
104-
.run({ async: true }); // runAsync
105-
await this.after();
106-
}
90+
async run() {
91+
await this.before();
92+
const { root, fco, importer } = await this.getNewProject();
93+
await this.callable({
94+
root,
95+
fco,
96+
importer,
97+
core: this.core,
98+
suite: this.suite,
99+
});
100+
this.suite
101+
.on("complete", function () {
102+
this.forEach((bench) => console.log(bench.stats));
103+
})
104+
.run({ async: true }); // runAsync
105+
await this.after();
106+
}
107107
}
108108

109109
module.exports = WJIBenchmark;

config/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
# WebGME Configuration Settings
2-
On `npm start`, the webgme app will load `config.default.js` which will override the configuration [defaults](https://github.com/webgme/webgme/tree/master/config).
32

4-
If `NODE_ENV` is set, it will first try to load the configuration settings from `config/config.ENV.js` where `ENV` is the value of `NODE_ENV`. For example,
3+
On `npm start`, the webgme app will load `config.default.js` which will override
4+
the configuration
5+
[defaults](https://github.com/webgme/webgme/tree/master/config).
6+
7+
If `NODE_ENV` is set, it will first try to load the configuration settings from
8+
`config/config.ENV.js` where `ENV` is the value of `NODE_ENV`. For example,
9+
510
```
611
NODE_ENV=debug npm start
712
```
8-
will load the configuration settings from `config/config.debug.js` if it exists and fallback to `config/config.default.js` otherwise
13+
14+
will load the configuration settings from `config/config.debug.js` if it exists
15+
and fallback to `config/config.default.js` otherwise

config/config.default.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
'use strict';
1+
"use strict";
22

3-
var config = require('./config.webgme'),
4-
validateConfig = require('webgme/config/validator');
3+
var config = require("./config.webgme"),
4+
validateConfig = require("webgme/config/validator");
55

66
// Add/overwrite any additional settings here
77
// config.server.port = 8080;

config/config.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* @author lattmann / https://github.com/lattmann
44
*/
55

6-
var config = require('./config.default');
6+
var config = require("./config.default");
77

88
config.server.port = 9001;
9-
config.mongo.uri = 'mongodb://127.0.0.1:27017/webgme_tests';
9+
config.mongo.uri = "mongodb://127.0.0.1:27017/webgme_tests";
1010

1111
module.exports = config;

0 commit comments

Comments
 (0)