eolang 0.2.0 → 0.2.1

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 CHANGED
@@ -49,3 +49,15 @@ There are also commands that help manipulate with XMIR and EO sources:
49
49
 
50
50
  This command line toolkit simply integrates other tools available in
51
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,7 @@ SOFTWARE.
36
36
  <plugin>
37
37
  <groupId>org.eolang</groupId>
38
38
  <artifactId>eo-maven-plugin</artifactId>
39
- <version>0.23.1</version>
39
+ <version>${eo.version}</version>
40
40
  </plugin>
41
41
  <plugin>
42
42
  <artifactId>maven-compiler-plugin</artifactId>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eolang",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "author": "Yegor Bugayenko <yegor256@gmail.com> (https://www.yegor256.com/)",
5
5
  "license": "MIT",
6
6
  "repository": "objectionary/eoc",
@@ -21,7 +21,9 @@
21
21
  "eoc": "./src/eoc.js"
22
22
  },
23
23
  "dependencies": {
24
- "commander": "9.2.0"
24
+ "commander": "9.2.0",
25
+ "fast-xml-parser": "4.0.0",
26
+ "xmlhttprequest": "1.8.0"
25
27
  },
26
28
  "devDependencies": {
27
29
  "eslint": "5.15.3",
@@ -31,5 +33,8 @@
31
33
  "grunt-eslint": "21.0.0",
32
34
  "grunt-mocha-cli": "7.0.0",
33
35
  "mocha": "^10.0.0"
36
+ },
37
+ "scripts": {
38
+ "test": "mocha --timeout 120000"
34
39
  }
35
40
  }
@@ -24,14 +24,14 @@
24
24
  */
25
25
 
26
26
  const path = require('path');
27
- const mvnw = require('../mvnw');
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
- mvnw([
34
+ mvnwSync([
35
35
  'eo:assemble',
36
36
  `-Deo.targetDir=${path.resolve(opts.target)}`,
37
37
  `-Deo.outputDir=${path.resolve(opts.target, 'classes')}`,
@@ -23,12 +23,12 @@
23
23
  * SOFTWARE.
24
24
  */
25
25
 
26
- const mvnw = require('../mvnw');
26
+ const mvnwSync = require('../mvnw');
27
27
 
28
28
  /**
29
29
  * Command to audit all packages.
30
30
  * @param {Hash} opts - All options
31
31
  */
32
32
  module.exports = function audit(opts) {
33
- mvnw(['--version']);
33
+ mvnwSync(['--version']);
34
34
  };
@@ -23,7 +23,7 @@
23
23
  * SOFTWARE.
24
24
  */
25
25
 
26
- const mvnw = require('../mvnw');
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
- mvnw([
34
+ mvnwSync([
35
35
  'compiler:compile',
36
36
  `-Dmaven.compiler.source=1.8`,
37
37
  `-Dmaven.compiler.target=1.8`,
@@ -23,7 +23,7 @@
23
23
  * SOFTWARE.
24
24
  */
25
25
 
26
- const mvnw = require('../mvnw');
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
- mvnw([
34
+ mvnwSync([
35
35
  'jar:jar',
36
36
  `-Deo.targetDir=${path.resolve(opts.target)}`,
37
37
  ]);
@@ -23,7 +23,7 @@
23
23
  * SOFTWARE.
24
24
  */
25
25
 
26
- const mvnw = require('../mvnw');
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
- mvnw([
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 mvnw = require('../mvnw');
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
- mvnw([
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/mvnw.js CHANGED
@@ -25,16 +25,45 @@
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 mvnw(args) {
59
+ module.exports = function mvnwSync(args) {
34
60
  const home = path.resolve(__dirname, '../mvnw');
35
- spawnSync(
36
- path.resolve(home, 'mvnw'),
37
- args,
38
- {cwd: home, stdio: 'inherit'}
39
- );
61
+ const bin = path.resolve(home, 'mvnw');
62
+ const params = args.concat(['-Deo.version=' + latest()]);
63
+ const cmd = bin + ' ' + params.join(' ');
64
+ console.log('+ ' + cmd);
65
+ const result = spawnSync(bin, params, {cwd: home, stdio: 'inherit'});
66
+ if (result.status != 0) {
67
+ throw new Error('Exit code: ' + result.status);
68
+ }
40
69
  };
package/src/version.js CHANGED
@@ -23,4 +23,4 @@
23
23
  * SOFTWARE.
24
24
  */
25
25
 
26
- module.exports = '0.2.0';
26
+ module.exports = '0.2.1';