eolang 0.1.0 → 0.2.2
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 +13 -0
- package/mvnw/pom.xml +4 -1
- package/package.json +11 -3
- package/src/commands/assemble.js +2 -2
- package/src/commands/audit.js +34 -0
- package/src/commands/compile.js +2 -2
- package/src/commands/link.js +2 -2
- package/src/commands/register.js +2 -2
- package/src/commands/transpile.js +2 -2
- package/src/eoc.js +9 -2
- package/src/mvnw.js +41 -6
- package/src/version.js +1 -1
package/README.md
CHANGED
|
@@ -40,6 +40,7 @@ You can also do many other things with `eoc` commands
|
|
|
40
40
|
|
|
41
41
|
There are also commands that help manipulate with XMIR and EO sources:
|
|
42
42
|
|
|
43
|
+
* `audit` inspects all packages and report their status
|
|
43
44
|
* `translate` converts Java/C++/Python/etc. program to EO program
|
|
44
45
|
* `demu` removes `cage` and `memory` objects
|
|
45
46
|
* `dejump` removes `goto` objects
|
|
@@ -48,3 +49,15 @@ There are also commands that help manipulate with XMIR and EO sources:
|
|
|
48
49
|
|
|
49
50
|
This command line toolkit simply integrates other tools available in
|
|
50
51
|
[@objectionary](https://github.com/objectionary) GitHub organization.
|
|
52
|
+
|
|
53
|
+
## How to Contribute
|
|
54
|
+
|
|
55
|
+
First, run `npm install`. Then, run `grunt`. All tests should pass.
|
|
56
|
+
|
|
57
|
+
If you want to run a single test:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
$ npm test -- test/test_mvnw.js
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Then, make a pull request.
|
package/mvnw/pom.xml
CHANGED
|
@@ -36,7 +36,10 @@ SOFTWARE.
|
|
|
36
36
|
<plugin>
|
|
37
37
|
<groupId>org.eolang</groupId>
|
|
38
38
|
<artifactId>eo-maven-plugin</artifactId>
|
|
39
|
-
<version
|
|
39
|
+
<version>${eo.version}</version>
|
|
40
|
+
<configuration>
|
|
41
|
+
<excludeSources>.eoc/**</excludeSources>
|
|
42
|
+
</configuration>
|
|
40
43
|
</plugin>
|
|
41
44
|
<plugin>
|
|
42
45
|
<artifactId>maven-compiler-plugin</artifactId>
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eolang",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"author": "Yegor Bugayenko",
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"author": "Yegor Bugayenko <yegor256@gmail.com> (https://www.yegor256.com/)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "objectionary/eoc",
|
|
7
|
+
"description": "A collection of command line tools for EOLANG: compiling, parsing, transpiling to other languages, optimizing, and analyzing",
|
|
8
|
+
"homepage": "https://github.com/objectionary/eoc",
|
|
7
9
|
"keywords": [
|
|
8
10
|
"cli",
|
|
9
11
|
"command",
|
|
@@ -14,11 +16,14 @@
|
|
|
14
16
|
"objectionary",
|
|
15
17
|
"oop"
|
|
16
18
|
],
|
|
19
|
+
"main": "eoc",
|
|
17
20
|
"bin": {
|
|
18
21
|
"eoc": "./src/eoc.js"
|
|
19
22
|
},
|
|
20
23
|
"dependencies": {
|
|
21
|
-
"commander": "9.2.0"
|
|
24
|
+
"commander": "9.2.0",
|
|
25
|
+
"fast-xml-parser": "4.0.0",
|
|
26
|
+
"xmlhttprequest": "1.8.0"
|
|
22
27
|
},
|
|
23
28
|
"devDependencies": {
|
|
24
29
|
"eslint": "5.15.3",
|
|
@@ -28,5 +33,8 @@
|
|
|
28
33
|
"grunt-eslint": "21.0.0",
|
|
29
34
|
"grunt-mocha-cli": "7.0.0",
|
|
30
35
|
"mocha": "^10.0.0"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"test": "mocha --timeout 120000"
|
|
31
39
|
}
|
|
32
40
|
}
|
package/src/commands/assemble.js
CHANGED
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
const path = require('path');
|
|
27
|
-
const
|
|
27
|
+
const mvnwSync = require('../mvnw');
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Command to assemble .XMIR files.
|
|
31
31
|
* @param {Hash} opts - All options
|
|
32
32
|
*/
|
|
33
33
|
module.exports = function assemble(opts) {
|
|
34
|
-
|
|
34
|
+
mvnwSync([
|
|
35
35
|
'eo:assemble',
|
|
36
36
|
`-Deo.targetDir=${path.resolve(opts.target)}`,
|
|
37
37
|
`-Deo.outputDir=${path.resolve(opts.target, 'classes')}`,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* The MIT License (MIT)
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2022 Yegor Bugayenko
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included
|
|
15
|
+
* in all copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const mvnwSync = require('../mvnw');
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Command to audit all packages.
|
|
30
|
+
* @param {Hash} opts - All options
|
|
31
|
+
*/
|
|
32
|
+
module.exports = function audit(opts) {
|
|
33
|
+
mvnwSync(['--version']);
|
|
34
|
+
};
|
package/src/commands/compile.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
const
|
|
26
|
+
const mvnwSync = require('../mvnw');
|
|
27
27
|
const path = require('path');
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -31,7 +31,7 @@ const path = require('path');
|
|
|
31
31
|
* @param {Hash} opts - All options
|
|
32
32
|
*/
|
|
33
33
|
module.exports = function compile(opts) {
|
|
34
|
-
|
|
34
|
+
mvnwSync([
|
|
35
35
|
'compiler:compile',
|
|
36
36
|
`-Dmaven.compiler.source=1.8`,
|
|
37
37
|
`-Dmaven.compiler.target=1.8`,
|
package/src/commands/link.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
const
|
|
26
|
+
const mvnwSync = require('../mvnw');
|
|
27
27
|
const path = require('path');
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -31,7 +31,7 @@ const path = require('path');
|
|
|
31
31
|
* @param {Hash} opts - All options
|
|
32
32
|
*/
|
|
33
33
|
module.exports = function link(opts) {
|
|
34
|
-
|
|
34
|
+
mvnwSync([
|
|
35
35
|
'jar:jar',
|
|
36
36
|
`-Deo.targetDir=${path.resolve(opts.target)}`,
|
|
37
37
|
]);
|
package/src/commands/register.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
const
|
|
26
|
+
const mvnwSync = require('../mvnw');
|
|
27
27
|
const path = require('path');
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -31,7 +31,7 @@ const path = require('path');
|
|
|
31
31
|
* @param {Hash} opts - All options
|
|
32
32
|
*/
|
|
33
33
|
module.exports = function register(opts) {
|
|
34
|
-
|
|
34
|
+
mvnwSync([
|
|
35
35
|
'eo:register',
|
|
36
36
|
`-Deo.targetDir=${path.resolve(opts.target)}`,
|
|
37
37
|
`-Deo.sourcesDir=${path.resolve(opts.sources)}`,
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
const
|
|
26
|
+
const mvnwSync = require('../mvnw');
|
|
27
27
|
const path = require('path');
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -31,7 +31,7 @@ const path = require('path');
|
|
|
31
31
|
* @param {Hash} opts - All options
|
|
32
32
|
*/
|
|
33
33
|
module.exports = function transpile(opts) {
|
|
34
|
-
|
|
34
|
+
mvnwSync([
|
|
35
35
|
'eo:transpile',
|
|
36
36
|
`-Deo.targetDir=${path.resolve(opts.target)}`,
|
|
37
37
|
`-Deo.generatedDir=${path.resolve(opts.target, 'generated-sources')}`,
|
package/src/eoc.js
CHANGED
|
@@ -35,11 +35,18 @@ program
|
|
|
35
35
|
.option('-s, --sources <path>', 'directory with .EO sources', '.')
|
|
36
36
|
.option('-t, --target <path>', 'directory with all generated files', '.eoc');
|
|
37
37
|
|
|
38
|
+
program.command('audit')
|
|
39
|
+
.description('inspects all packages and reports their status')
|
|
40
|
+
.action((str, options) => {
|
|
41
|
+
const audit = require('./commands/audit');
|
|
42
|
+
audit(program.opts());
|
|
43
|
+
});
|
|
44
|
+
|
|
38
45
|
program.command('clean')
|
|
39
46
|
.description('delete all temporary files')
|
|
40
47
|
.action((str, options) => {
|
|
41
|
-
const
|
|
42
|
-
|
|
48
|
+
const clean = require('./commands/clean');
|
|
49
|
+
clean(program.opts());
|
|
43
50
|
});
|
|
44
51
|
|
|
45
52
|
program.command('register')
|
package/src/mvnw.js
CHANGED
|
@@ -25,16 +25,51 @@
|
|
|
25
25
|
|
|
26
26
|
const path = require('path');
|
|
27
27
|
const {spawnSync} = require('child_process');
|
|
28
|
+
const XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
|
|
29
|
+
const {XMLParser} = require('fast-xml-parser');
|
|
30
|
+
|
|
31
|
+
let version = '';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Load the latest version from GitHub releases.
|
|
35
|
+
* @return {String} Latest version, for example '0.23.1'
|
|
36
|
+
*/
|
|
37
|
+
function latest() {
|
|
38
|
+
const repo = 'org/eolang/eo-maven-plugin';
|
|
39
|
+
if (version === '') {
|
|
40
|
+
const url = 'https://repo.maven.apache.org/maven2/' + repo + '/maven-metadata.xml';
|
|
41
|
+
const xhr = new XMLHttpRequest();
|
|
42
|
+
xhr.open('GET', url, false);
|
|
43
|
+
xhr.send(null);
|
|
44
|
+
if (xhr.status != 200) {
|
|
45
|
+
throw new Error('Invalid response status ' + xhr.status + ' from ' + url);
|
|
46
|
+
}
|
|
47
|
+
const xml = new XMLParser().parse(xhr.responseText);
|
|
48
|
+
version = xml.metadata.versioning.release;
|
|
49
|
+
console.log('The latest version of ' + repo + ' at ' + url + ' is ' + version);
|
|
50
|
+
}
|
|
51
|
+
console.log('Current version of ' + repo + ' is ' + version);
|
|
52
|
+
return version;
|
|
53
|
+
}
|
|
28
54
|
|
|
29
55
|
/**
|
|
30
56
|
* Run mvnw with provided commands.
|
|
31
57
|
* @param {Hash} args - All arguments to pass to it
|
|
32
58
|
*/
|
|
33
|
-
module.exports = function
|
|
59
|
+
module.exports = function mvnwSync(args) {
|
|
34
60
|
const home = path.resolve(__dirname, '../mvnw');
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
61
|
+
const bin = path.resolve(home, 'mvnw');
|
|
62
|
+
const params = args.concat([
|
|
63
|
+
'-Deo.version=' + latest(),
|
|
64
|
+
'--errors',
|
|
65
|
+
'--batch-mode',
|
|
66
|
+
'--update-snapshots',
|
|
67
|
+
'--fail-fast',
|
|
68
|
+
]);
|
|
69
|
+
const cmd = bin + ' ' + params.join(' ');
|
|
70
|
+
console.log('+ ' + cmd);
|
|
71
|
+
const result = spawnSync(bin, params, {cwd: home, stdio: 'inherit'});
|
|
72
|
+
if (result.status != 0) {
|
|
73
|
+
throw new Error('Exit code: ' + result.status);
|
|
74
|
+
}
|
|
40
75
|
};
|
package/src/version.js
CHANGED