eolang 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -11
- package/eo-version.txt +1 -1
- package/package.json +5 -4
- package/src/commands/{compile.js → java/compile.js} +2 -2
- package/src/commands/{dataize.js → java/dataize.js} +1 -1
- package/src/commands/{link.js → java/link.js} +2 -2
- package/src/commands/{test.js → java/test.js} +2 -2
- package/src/commands/{transpile.js → java/transpile.js} +2 -2
- package/src/commands/js/compile.js +35 -0
- package/src/commands/js/dataize.js +39 -0
- package/src/commands/js/link.js +41 -0
- package/src/commands/js/test.js +34 -0
- package/src/commands/js/transpile.js +39 -0
- package/src/eo2jsw.js +43 -0
- package/src/eoc.js +57 -24
- package/src/mvnw.js +4 -6
- package/src/version.js +2 -2
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# EOLANG Command Line
|
|
1
|
+
# EOLANG Command Line Took-Kit
|
|
2
2
|
|
|
3
3
|
[](https://www.elegantobjects.org)
|
|
4
4
|
[](https://www.jetbrains.com/idea/)
|
|
@@ -9,11 +9,9 @@
|
|
|
9
9
|
[](https://hitsofcode.com/view/github/objectionary/eoc)
|
|
10
10
|
[](https://github.com/objectionary/eoc/blob/master/LICENSE.txt)
|
|
11
11
|
|
|
12
|
-
First, you install
|
|
13
|
-
[npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
|
|
14
|
-
and [Java SE](https://www.oracle.com/java/technologies/downloads/).
|
|
12
|
+
First, you install [npm][npm-install] and [Java SE][java-se].
|
|
15
13
|
|
|
16
|
-
Then, you install [eolang]
|
|
14
|
+
Then, you install [eolang][npm] package:
|
|
17
15
|
|
|
18
16
|
```bash
|
|
19
17
|
npm install -g eolang
|
|
@@ -39,8 +37,7 @@ That's it.
|
|
|
39
37
|
## Commands
|
|
40
38
|
|
|
41
39
|
You can also do many other things with `eoc` commands
|
|
42
|
-
(the flow is explained in
|
|
43
|
-
[this blog post](https://www.yegor256.com/2021/10/21/objectionary.html)):
|
|
40
|
+
(the flow is explained in [this blog post][blog]):
|
|
44
41
|
|
|
45
42
|
* `register` finds necessary EO files and registers them in a JSON catalog
|
|
46
43
|
* `assemble` parses EO files into XMIR, optimizes them,
|
|
@@ -56,9 +53,7 @@ There are also commands that help manipulate with XMIR and EO sources
|
|
|
56
53
|
|
|
57
54
|
* `audit` inspects all required packages and reports their status
|
|
58
55
|
* `foreign` inspects all objects found in the program after `assemble` step
|
|
59
|
-
* `sodg` generates SODG from XMIR, further rederable
|
|
60
|
-
as XML or
|
|
61
|
-
[Dot](https://en.wikipedia.org/wiki/DOT_%28graph_description_language%29)
|
|
56
|
+
* `sodg` generates SODG from XMIR, further rederable as XML or [Dot][dot]
|
|
62
57
|
* `phi` generates PHI files from XMIR
|
|
63
58
|
* `unphi` generates XMIR files from PHI files
|
|
64
59
|
* `print` generates EO files from PHI files
|
|
@@ -69,7 +64,7 @@ There are also commands that help manipulate with XMIR and EO sources
|
|
|
69
64
|
* ~~`flatten` moves inner objects to upper level~~
|
|
70
65
|
|
|
71
66
|
This command line toolkit simply integrates other tools available in
|
|
72
|
-
[@objectionary](https://github.com/objectionary) GitHub organization.
|
|
67
|
+
the [@objectionary](https://github.com/objectionary) GitHub organization.
|
|
73
68
|
|
|
74
69
|
## How to Contribute
|
|
75
70
|
|
|
@@ -84,3 +79,9 @@ npm test -- test/test_mvnw.js
|
|
|
84
79
|
Make your changes and then
|
|
85
80
|
[make](https://www.yegor256.com/2014/04/15/github-guidelines.html)
|
|
86
81
|
a pull request.
|
|
82
|
+
|
|
83
|
+
[npm]: https://www.npmjs.com/package/eolang
|
|
84
|
+
[java-se]: https://www.oracle.com/java/technologies/downloads/
|
|
85
|
+
[npm-install]: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
|
|
86
|
+
[dot]: https://en.wikipedia.org/wiki/DOT_%28graph_description_language%29
|
|
87
|
+
[blog]: https://www.yegor256.com/2021/10/21/objectionary.html
|
package/eo-version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.38.
|
|
1
|
+
0.38.2
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eolang",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"author": "Yegor Bugayenko <yegor256@gmail.com> (https://www.yegor256.com/)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "objectionary/eoc",
|
|
@@ -32,15 +32,16 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"colors": "1.4.0",
|
|
34
34
|
"commander": "12.0.0",
|
|
35
|
+
"eo2js": "0.0.6",
|
|
35
36
|
"fast-xml-parser": "4.3.6",
|
|
36
|
-
"node": "
|
|
37
|
+
"node": "22.1.0",
|
|
37
38
|
"relative": "3.0.2",
|
|
38
|
-
"semver": "7.6.
|
|
39
|
+
"semver": "7.6.2",
|
|
39
40
|
"sync-request": "6.1.0",
|
|
40
41
|
"xmlhttprequest": "1.8.0"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"eslint": "9.
|
|
44
|
+
"eslint": "9.2.0",
|
|
44
45
|
"eslint-config-google": "0.14.0",
|
|
45
46
|
"grunt": "1.6.1",
|
|
46
47
|
"grunt-contrib-clean": "2.0.1",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
const rel = require('relative');
|
|
26
|
-
const {mvnw, flags} = require('
|
|
26
|
+
const {mvnw, flags} = require('../../mvnw');
|
|
27
27
|
const path = require('path');
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Command to compile target language into binaries.
|
|
31
|
-
* @param {
|
|
31
|
+
* @param {Object} opts - All options
|
|
32
32
|
* @return {Promise} of compile task
|
|
33
33
|
*/
|
|
34
34
|
module.exports = function(opts) {
|
|
@@ -29,7 +29,7 @@ const path = require('path');
|
|
|
29
29
|
* Runs the single executable binary.
|
|
30
30
|
* @param {String} obj - Name of object to dataize
|
|
31
31
|
* @param {Array} args - Arguments
|
|
32
|
-
* @param {
|
|
32
|
+
* @param {Object} opts - All options
|
|
33
33
|
*/
|
|
34
34
|
module.exports = function(obj, args, opts) {
|
|
35
35
|
const params = [
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
const rel = require('relative');
|
|
26
|
-
const {mvnw, flags} = require('
|
|
26
|
+
const {mvnw, flags} = require('../../mvnw');
|
|
27
27
|
const path = require('path');
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Command to link binaries into a single executable binary.
|
|
31
|
-
* @param {
|
|
31
|
+
* @param {Object} opts - All options
|
|
32
32
|
* @return {Promise} of link task
|
|
33
33
|
*/
|
|
34
34
|
module.exports = function(opts) {
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
const {mvnw, flags} = require('
|
|
25
|
+
const {mvnw, flags} = require('../../mvnw');
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Command to run all available unit tests.
|
|
29
|
-
* @param {
|
|
29
|
+
* @param {Object} opts - All options
|
|
30
30
|
* @return {Promise} of compile task
|
|
31
31
|
*/
|
|
32
32
|
module.exports = function(opts) {
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
const rel = require('relative');
|
|
26
|
-
const {mvnw, flags} = require('
|
|
26
|
+
const {mvnw, flags} = require('../../mvnw');
|
|
27
27
|
const path = require('path');
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Command to transpile XMIR files into target language.
|
|
31
|
-
* @param {
|
|
31
|
+
* @param {Object} opts - All options
|
|
32
32
|
* @return {Promise} of transpile task
|
|
33
33
|
*/
|
|
34
34
|
module.exports = function(opts) {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2022-2024 Objectionary.com
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included
|
|
14
|
+
* in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Command to compile target language into binaries.
|
|
27
|
+
* @param {Object} opts - All options
|
|
28
|
+
* @return {Promise} of compile task
|
|
29
|
+
*/
|
|
30
|
+
module.exports = function(opts) {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
console.info('Compile step is skipped for JavaScript');
|
|
33
|
+
resolve(opts);
|
|
34
|
+
});
|
|
35
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2022-2024 Objectionary.com
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included
|
|
14
|
+
* in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const eo2jsw = require('../../eo2jsw');
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Runs the single executable binary.
|
|
29
|
+
* @param {String} obj - Name of object to dataize
|
|
30
|
+
* @param {Array} args - Arguments
|
|
31
|
+
* @param {Object} opts - All options
|
|
32
|
+
* @return {Promise} of executed command
|
|
33
|
+
*/
|
|
34
|
+
module.exports = function(obj, args, opts) {
|
|
35
|
+
return eo2jsw(
|
|
36
|
+
['dataize', obj, ...args.filter((arg) => !arg.startsWith('-'))].join(' '),
|
|
37
|
+
{...opts, alone: true, project: 'project'}
|
|
38
|
+
);
|
|
39
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2022-2024 Objectionary.com
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included
|
|
14
|
+
* in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const rel = require('relative');
|
|
26
|
+
const path = require('path');
|
|
27
|
+
const eo2jsw = require('../../eo2jsw');
|
|
28
|
+
const {program} = require('commander');
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Command to create and build NPM project.
|
|
32
|
+
* @param {Object} opts - All options
|
|
33
|
+
* @return {Promise} of link task
|
|
34
|
+
*/
|
|
35
|
+
module.exports = function(opts) {
|
|
36
|
+
const tests = program.args[0] === 'test' || !!opts.tests;
|
|
37
|
+
return eo2jsw('link', {...opts, alone: true, project: 'project', tests}).then((r) => {
|
|
38
|
+
console.info(`NPM project generated in ${rel(path.resolve(opts.target, 'project'))}`);
|
|
39
|
+
return r;
|
|
40
|
+
});
|
|
41
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2022-2024 Objectionary.com
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included
|
|
14
|
+
* in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const eo2jsw = require('../../eo2jsw');
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Command to run all available unit tests.
|
|
29
|
+
* @param {Object} opts - All options
|
|
30
|
+
* @return {Promise} of compile task
|
|
31
|
+
*/
|
|
32
|
+
module.exports = function(opts) {
|
|
33
|
+
return eo2jsw('test', {...opts, alone: true, project: 'project'});
|
|
34
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2022-2024 Objectionary.com
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included
|
|
14
|
+
* in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const rel = require('relative');
|
|
26
|
+
const eo2jsw = require('../../eo2jsw');
|
|
27
|
+
const path = require('path');
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Command to transpile XMIR files into target language.
|
|
31
|
+
* @param {Object} opts - All options
|
|
32
|
+
* @return {Promise} of transpile task
|
|
33
|
+
*/
|
|
34
|
+
module.exports = function(opts) {
|
|
35
|
+
return eo2jsw('transpile', {...opts, alone: true, project: 'project'}).then((r) => {
|
|
36
|
+
console.info(`JS sources are generated in ${rel(path.resolve(opts.target, 'project'))}`);
|
|
37
|
+
return r;
|
|
38
|
+
});
|
|
39
|
+
};
|
package/src/eo2jsw.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const {execSync} = require('child_process');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Convert eoc arguments to appropriate eo2js flags
|
|
6
|
+
* @param {Object} args - eoc arguments
|
|
7
|
+
* @param {String} lib - Path to eo2js lib
|
|
8
|
+
* @return {Array.<String>} - Flags for eo2js
|
|
9
|
+
*/
|
|
10
|
+
const flags = function(args, lib) {
|
|
11
|
+
return [
|
|
12
|
+
'--target', args.target,
|
|
13
|
+
'--project', args.project || 'project',
|
|
14
|
+
'--foreign eo-foreign.json',
|
|
15
|
+
'--resources', path.resolve(lib, 'resources'),
|
|
16
|
+
args.alone ? '--alone' : '',
|
|
17
|
+
args.tests ? '--tests' : ''
|
|
18
|
+
];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Wrapper for eo2js.
|
|
23
|
+
* @param {String} command - Command to execute
|
|
24
|
+
* @param {Object} args - Command arguments
|
|
25
|
+
* @return {Promise<Array.<String>>}
|
|
26
|
+
*/
|
|
27
|
+
const eo2jsw = function(command, args) {
|
|
28
|
+
const lib = path.resolve(__dirname, '../node_modules/eo2js/src');
|
|
29
|
+
const bin = path.resolve(lib, 'eo2js.js');
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
execSync(
|
|
32
|
+
`node ${bin} ${command} ${flags(args, lib).filter((flag) => flag !== '').join(' ')}`,
|
|
33
|
+
{
|
|
34
|
+
timeout: 1200000,
|
|
35
|
+
windowsHide: true,
|
|
36
|
+
stdio: 'inherit'
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
resolve(args);
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
module.exports = eo2jsw;
|
package/src/eoc.js
CHANGED
|
@@ -35,12 +35,35 @@ const unphi = require('./commands/unphi');
|
|
|
35
35
|
const print = require('./commands/print');
|
|
36
36
|
const register = require('./commands/register');
|
|
37
37
|
const verify = require('./commands/verify');
|
|
38
|
-
const transpile = require('./commands/transpile');
|
|
39
|
-
const compile = require('./commands/compile');
|
|
40
|
-
const link = require('./commands/link');
|
|
41
|
-
const dataize = require('./commands/dataize');
|
|
42
38
|
const foreign = require('./commands/foreign');
|
|
43
|
-
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Target language option.
|
|
42
|
+
*/
|
|
43
|
+
const language = {
|
|
44
|
+
java: 'Java',
|
|
45
|
+
js: 'JavaScript',
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Platform dependent commands.
|
|
50
|
+
*/
|
|
51
|
+
const commands = {
|
|
52
|
+
[language.java]: {
|
|
53
|
+
transpile: require('./commands/java/transpile'),
|
|
54
|
+
link: require('./commands/java/link'),
|
|
55
|
+
compile: require('./commands/java/compile'),
|
|
56
|
+
dataize: require('./commands/java/dataize'),
|
|
57
|
+
test: require('./commands/java/test')
|
|
58
|
+
},
|
|
59
|
+
[language.js]: {
|
|
60
|
+
transpile: require('./commands/js/transpile'),
|
|
61
|
+
link: require('./commands/js/link'),
|
|
62
|
+
compile: require('./commands/js/compile'),
|
|
63
|
+
dataize: require('./commands/js/dataize'),
|
|
64
|
+
test: require('./commands/js/test')
|
|
65
|
+
}
|
|
66
|
+
};
|
|
44
67
|
|
|
45
68
|
if (process.argv.includes('--verbose')) {
|
|
46
69
|
tinted.enable('debug');
|
|
@@ -77,6 +100,7 @@ program
|
|
|
77
100
|
.option('--parser <version>', 'Set the version of EO parser to use', parser)
|
|
78
101
|
.option('--latest', 'Use the latest parser version from Maven Central')
|
|
79
102
|
.option('--alone', 'Just run a single command without dependencies')
|
|
103
|
+
.option('-l, --language <name>', 'Language of target execution platform', language.java)
|
|
80
104
|
.option('-b, --batch', 'Run in batch mode, suppress interactive messages')
|
|
81
105
|
.option('--no-color', 'Disable colorization of console messages')
|
|
82
106
|
.option('--track-optimization-steps', 'Save intermediate XMIR files')
|
|
@@ -198,28 +222,30 @@ program.command('transpile')
|
|
|
198
222
|
.description('Convert EO files into target language')
|
|
199
223
|
.action((str, opts) => {
|
|
200
224
|
clear(str);
|
|
225
|
+
const lang = program.opts().language;
|
|
201
226
|
if (program.opts().alone == undefined) {
|
|
202
227
|
register(program.opts())
|
|
203
228
|
.then((r) => assemble(program.opts()))
|
|
204
229
|
.then((r) => verify(program.opts()))
|
|
205
|
-
.then((r) => transpile(program.opts()));
|
|
230
|
+
.then((r) => commands[lang].transpile(program.opts()));
|
|
206
231
|
} else {
|
|
207
|
-
transpile(program.opts());
|
|
232
|
+
commands[lang].transpile(program.opts());
|
|
208
233
|
}
|
|
209
234
|
});
|
|
210
235
|
|
|
211
236
|
program.command('compile')
|
|
212
237
|
.description('Compile target language sources into binaries')
|
|
213
238
|
.action((str, opts) => {
|
|
239
|
+
const lang = program.opts().language;
|
|
214
240
|
clear(str);
|
|
215
241
|
if (program.opts().alone == undefined) {
|
|
216
242
|
register(program.opts())
|
|
217
243
|
.then((r) => assemble(program.opts()))
|
|
218
244
|
.then((r) => verify(program.opts()))
|
|
219
|
-
.then((r) => transpile(program.opts()))
|
|
220
|
-
.then((r) => compile(program.opts()));
|
|
245
|
+
.then((r) => commands[lang].transpile(program.opts()))
|
|
246
|
+
.then((r) => commands[lang].compile(program.opts()));
|
|
221
247
|
} else {
|
|
222
|
-
compile(program.opts());
|
|
248
|
+
commands[lang].compile(program.opts());
|
|
223
249
|
}
|
|
224
250
|
});
|
|
225
251
|
|
|
@@ -227,15 +253,16 @@ program.command('link')
|
|
|
227
253
|
.description('Link together all binaries into a single executable binary')
|
|
228
254
|
.action((str, opts) => {
|
|
229
255
|
clear(str);
|
|
256
|
+
const lang = program.opts().language;
|
|
230
257
|
if (program.opts().alone == undefined) {
|
|
231
258
|
register(program.opts())
|
|
232
259
|
.then((r) => assemble(program.opts()))
|
|
233
260
|
.then((r) => verify(program.opts()))
|
|
234
|
-
.then((r) => transpile(program.opts()))
|
|
235
|
-
.then((r) => compile(program.opts()))
|
|
236
|
-
.then((r) => link(program.opts()));
|
|
261
|
+
.then((r) => commands[lang].transpile(program.opts()))
|
|
262
|
+
.then((r) => commands[lang].compile(program.opts()))
|
|
263
|
+
.then((r) => commands[lang].link(program.opts()));
|
|
237
264
|
} else {
|
|
238
|
-
link(program.opts());
|
|
265
|
+
commands[lang].link(program.opts());
|
|
239
266
|
}
|
|
240
267
|
});
|
|
241
268
|
|
|
@@ -244,16 +271,21 @@ program.command('dataize')
|
|
|
244
271
|
.option('--stack <size>', 'Change stack size', '1M')
|
|
245
272
|
.action((str, opts) => {
|
|
246
273
|
clear(str);
|
|
274
|
+
const lang = program.opts().language;
|
|
247
275
|
if (program.opts().alone == undefined) {
|
|
248
276
|
register(program.opts())
|
|
249
277
|
.then((r) => assemble(program.opts()))
|
|
250
278
|
.then((r) => verify(program.opts()))
|
|
251
|
-
.then((r) => transpile(program.opts()))
|
|
252
|
-
.then((r) => compile(program.opts()))
|
|
253
|
-
.then((r) => link(program.opts()))
|
|
254
|
-
.then((r) =>
|
|
279
|
+
.then((r) => commands[lang].transpile(program.opts()))
|
|
280
|
+
.then((r) => commands[lang].compile(program.opts()))
|
|
281
|
+
.then((r) => commands[lang].link(program.opts()))
|
|
282
|
+
.then((r) => commands[lang].dataize(
|
|
283
|
+
program.args[1], program.args.slice(2), {...program.opts(), ...str}
|
|
284
|
+
));
|
|
255
285
|
} else {
|
|
256
|
-
|
|
286
|
+
commands[lang].dataize(
|
|
287
|
+
program.args[1], program.args.slice(2), {...program.opts(), ...str}
|
|
288
|
+
);
|
|
257
289
|
}
|
|
258
290
|
});
|
|
259
291
|
|
|
@@ -261,16 +293,17 @@ program.command('test')
|
|
|
261
293
|
.description('Run all visible unit tests')
|
|
262
294
|
.action((str, opts) => {
|
|
263
295
|
clear(str);
|
|
296
|
+
const lang = program.opts().language;
|
|
264
297
|
if (program.opts().alone == undefined) {
|
|
265
298
|
register(program.opts())
|
|
266
299
|
.then((r) => assemble(program.opts()))
|
|
267
300
|
.then((r) => verify(program.opts()))
|
|
268
|
-
.then((r) => transpile(program.opts()))
|
|
269
|
-
.then((r) => compile(program.opts()))
|
|
270
|
-
.then((r) => link(program.opts()))
|
|
271
|
-
.then((r) => test(program.opts()));
|
|
301
|
+
.then((r) => commands[lang].transpile(program.opts()))
|
|
302
|
+
.then((r) => commands[lang].compile(program.opts()))
|
|
303
|
+
.then((r) => commands[lang].link(program.opts()))
|
|
304
|
+
.then((r) => commands[lang].test(program.opts()));
|
|
272
305
|
} else {
|
|
273
|
-
test(program.opts());
|
|
306
|
+
commands[lang].test(program.opts());
|
|
274
307
|
}
|
|
275
308
|
});
|
|
276
309
|
|
package/src/mvnw.js
CHANGED
|
@@ -46,7 +46,7 @@ let beginning;
|
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* Prepare options for Maven.
|
|
49
|
-
* @param {
|
|
49
|
+
* @param {Object} opts - Opts provided to the "eoc"
|
|
50
50
|
* @return {Array} of Maven options
|
|
51
51
|
*/
|
|
52
52
|
module.exports.flags = function(opts) {
|
|
@@ -72,9 +72,9 @@ module.exports.flags = function(opts) {
|
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* Run mvnw with provided commands.
|
|
75
|
-
* @param {
|
|
76
|
-
* @param {String} tgt - Path to the target directory
|
|
77
|
-
* @param {Boolean} batch - Is it batch mode (TRUE) or interactive (FALSE)?
|
|
75
|
+
* @param {Array.<String>} args - All arguments to pass to it
|
|
76
|
+
* @param {String} [tgt] - Path to the target directory
|
|
77
|
+
* @param {Boolean} [batch] - Is it batch mode (TRUE) or interactive (FALSE)?
|
|
78
78
|
* @return {Promise} of maven execution task
|
|
79
79
|
*/
|
|
80
80
|
module.exports.mvnw = function(args, tgt, batch) {
|
|
@@ -131,8 +131,6 @@ module.exports.mvnw = function(args, tgt, batch) {
|
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
133
|
* Starts mvnw execution status detection.
|
|
134
|
-
* @param {String} stage - A maven stage like assemble, compile, transpile, etc.
|
|
135
|
-
* @param {String} dir - Directory where to check progress - ./.eoc
|
|
136
134
|
*/
|
|
137
135
|
function start() {
|
|
138
136
|
running = true;
|
package/src/version.js
CHANGED