eolang 0.3.0 → 0.4.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/CITATION.cff ADDED
@@ -0,0 +1,11 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use this software, please cite it as below."
3
+ authors:
4
+ - family-names: "Bugayenko"
5
+ given-names: "Yegor"
6
+ orcid: "https://orcid.org/0000-0001-6370-0678"
7
+ title: "EOLANG and 𝜑-calculus"
8
+ version: 0.23.0
9
+ doi: 10.48550/arXiv.2111.13384
10
+ date-released: 2022-05-09
11
+ url: "https://github.com/objectionary/eoc"
package/README.md CHANGED
@@ -37,15 +37,16 @@ You can also do many other things with `eoc` commands
37
37
  * `compile` converts target language to binaries
38
38
  * `link` puts all binaries together into a single executable binary
39
39
  * `dataize` executes the binary and dataize a single object
40
+ * `test` executes all visible unit tests
40
41
 
41
- There are also commands that help manipulate with XMIR and EO sources:
42
+ There are also commands that help manipulate with XMIR and EO sources (some of them are not implemented as of yet):
42
43
 
43
44
  * `audit` inspects all packages and report their status
44
- * `translate` converts Java/C++/Python/etc. program to EO program
45
- * `demu` removes `cage` and `memory` objects
46
- * `dejump` removes `goto` objects
47
- * `infer` suggests object names where it's possible to infer them
48
- * `flatten` moves inner objects to upper level
45
+ * <del>`translate` converts Java/C++/Python/etc. program to EO program</del>
46
+ * <del>`demu` removes `cage` and `memory` objects</del>
47
+ * <del>`dejump` removes `goto` objects</del>
48
+ * <del>`infer` suggests object names where it's possible to infer them</del>
49
+ * <del>`flatten` moves inner objects to upper level</del>
49
50
 
50
51
  This command line toolkit simply integrates other tools available in
51
52
  [@objectionary](https://github.com/objectionary) GitHub organization.
package/itest/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  [![grunt](https://github.com/objectionary/eoc/actions/workflows/itest.yml/badge.svg)](https://github.com/objectionary/eoc/actions/workflows/itest.yml)
2
2
 
3
- There is a simple integration here. Just run this to make sure
3
+ There is a simple integration test here. Just run this to make sure
4
4
  it works:
5
5
 
6
6
  ```
7
- $ ../src/eoc.js dataize foo.program
7
+ $ ../src/eoc.js dataize program
8
8
  ```
9
9
 
10
10
  Then, you can execute the unit tests too:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eolang",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "author": "Yegor Bugayenko <yegor256@gmail.com> (https://www.yegor256.com/)",
5
5
  "license": "MIT",
6
6
  "repository": "objectionary/eoc",
@@ -21,6 +21,7 @@
21
21
  "eoc": "./src/eoc.js"
22
22
  },
23
23
  "dependencies": {
24
+ "colors": "1.4.0",
24
25
  "commander": "9.2.0",
25
26
  "fast-xml-parser": "4.0.0",
26
27
  "xmlhttprequest": "1.8.0"
@@ -33,6 +33,7 @@ const mvnwSync = require('../mvnw');
33
33
  module.exports = function assemble(opts) {
34
34
  mvnwSync([
35
35
  'eo:assemble',
36
+ opts.verbose ? '' : '--quiet',
36
37
  `-Deo.targetDir=${path.resolve(opts.target)}`,
37
38
  `-Deo.outputDir=${path.resolve(opts.target, 'classes')}`,
38
39
  `-Deo.foreign=${path.resolve(opts.target, 'eo-foreign.csv')}`,
@@ -40,4 +41,5 @@ module.exports = function assemble(opts) {
40
41
  `-Deo.placed=${path.resolve(opts.target, 'eo-placed.csv')}`,
41
42
  `-Deo.placedFormat=csv`,
42
43
  ]);
44
+ console.info('EO program assembled in %s', path.resolve(opts.target));
43
45
  };
@@ -33,4 +33,5 @@ const path = require('path');
33
33
  module.exports = function clean(opts) {
34
34
  const home = path.resolve(opts.target);
35
35
  fs.rmSync(home, {recursive: true, force: true});
36
+ console.debug('The directory %s deleted', home);
36
37
  };
@@ -31,11 +31,14 @@ const path = require('path');
31
31
  * @param {Hash} opts - All options
32
32
  */
33
33
  module.exports = function compile(opts) {
34
+ const target = path.resolve(opts.target);
34
35
  mvnwSync([
35
36
  'compiler:compile',
37
+ opts.verbose ? '' : '--quiet',
36
38
  `-Dmaven.compiler.source=1.8`,
37
39
  `-Dmaven.compiler.target=1.8`,
38
- `-Deo.targetDir=${path.resolve(opts.target)}`,
40
+ `-Deo.targetDir=${target}`,
39
41
  `-Deo.generatedDir=${path.resolve(opts.target, 'generated-sources')}`,
40
42
  ]);
43
+ console.info('Java .class files compiled into %s', target);
41
44
  };
@@ -33,6 +33,8 @@ const path = require('path');
33
33
  module.exports = function link(opts) {
34
34
  mvnwSync([
35
35
  'jar:jar',
36
+ opts.verbose ? '' : '--quiet',
36
37
  `-Deo.targetDir=${path.resolve(opts.target)}`,
37
38
  ]);
39
+ console.info('Executable JAR created at %s', path.resolve(opts.target, 'eoc.jar'));
38
40
  };
@@ -31,11 +31,14 @@ const path = require('path');
31
31
  * @param {Hash} opts - All options
32
32
  */
33
33
  module.exports = function register(opts) {
34
+ const foreign = path.resolve(opts.target, 'eo-foreign.csv');
34
35
  mvnwSync([
35
36
  'eo:register',
37
+ opts.verbose ? '' : '--quiet',
36
38
  `-Deo.targetDir=${path.resolve(opts.target)}`,
37
39
  `-Deo.sourcesDir=${path.resolve(opts.sources)}`,
38
- `-Deo.foreign=${path.resolve(opts.target, 'eo-foreign.csv')}`,
40
+ `-Deo.foreign=${foreign}`,
39
41
  `-Deo.foreignFormat=csv`,
40
42
  ]);
43
+ console.info('EO objects registered in %s', foreign);
41
44
  };
@@ -31,11 +31,14 @@ const path = require('path');
31
31
  * @param {Hash} opts - All options
32
32
  */
33
33
  module.exports = function transpile(opts) {
34
+ const sources = path.resolve(opts.target, 'generated-sources');
34
35
  mvnwSync([
35
36
  'eo:transpile',
37
+ opts.verbose ? '' : '--quiet',
36
38
  `-Deo.targetDir=${path.resolve(opts.target)}`,
37
- `-Deo.generatedDir=${path.resolve(opts.target, 'generated-sources')}`,
39
+ `-Deo.generatedDir=${sources}`,
38
40
  `-Deo.foreign=${path.resolve(opts.target, 'eo-foreign.csv')}`,
39
41
  `-Deo.foreignFormat=csv`,
40
42
  ]);
43
+ console.info('Java sources generated in %s', sources);
41
44
  };
package/src/eoc.js CHANGED
@@ -23,9 +23,8 @@
23
23
  * SOFTWARE.
24
24
  */
25
25
 
26
- const {Command} = require('commander');
27
- const program = new Command();
28
-
26
+ const {program} = require('commander');
27
+ const tinted = require('./tinted-console');
29
28
  const audit = require('./commands/audit');
30
29
  const clean = require('./commands/clean');
31
30
  const assemble = require('./commands/assemble');
@@ -36,6 +35,12 @@ const link = require('./commands/link');
36
35
  const dataize = require('./commands/dataize');
37
36
  const test = require('./commands/test');
38
37
 
38
+ if (process.argv.includes('--verbose')) {
39
+ tinted.enable('debug');
40
+ console.debug('Debug output is turned ON');
41
+ console.info('INFO');
42
+ }
43
+
39
44
  program
40
45
  .name('eoc')
41
46
  .description('EO command-line toolkit')
@@ -44,7 +49,8 @@ program
44
49
  program
45
50
  .option('-s, --sources <path>', 'directory with .EO sources', '.')
46
51
  .option('-t, --target <path>', 'directory with all generated files', '.eoc')
47
- .option('--alone', 'just run a single command without dependencies');
52
+ .option('--alone', 'just run a single command without dependencies')
53
+ .option('--verbose', 'print debug messages and full output of child processes');
48
54
 
49
55
  program.command('audit')
50
56
  .description('inspects all packages and reports their status')
@@ -135,6 +141,7 @@ program.command('test')
135
141
  try {
136
142
  program.parse(process.argv);
137
143
  } catch (e) {
138
- console.log('eoc failed: "' + e.message + '"');
144
+ console.error(e.message);
145
+ console.debug(e.stack);
139
146
  process.exit(1);
140
147
  }
package/src/mvnw.js CHANGED
@@ -46,9 +46,9 @@ function latest() {
46
46
  }
47
47
  const xml = new XMLParser().parse(xhr.responseText);
48
48
  version = xml.metadata.versioning.release;
49
- console.log('The latest version of ' + repo + ' at ' + url + ' is ' + version);
49
+ console.debug('The latest version of %s at %s is %s', repo, url, version);
50
50
  }
51
- console.log('Current version of ' + repo + ' is ' + version);
51
+ console.debug('Current version of %s is %s', repo, version);
52
52
  return version;
53
53
  }
54
54
 
@@ -59,7 +59,9 @@ function latest() {
59
59
  module.exports = function mvnwSync(args) {
60
60
  const home = path.resolve(__dirname, '../mvnw');
61
61
  const bin = path.resolve(home, 'mvnw');
62
- const params = args.concat([
62
+ const params = args.filter(function(t) {
63
+ return t != '';
64
+ }).concat([
63
65
  '-Deo.version=' + latest(),
64
66
  '--errors',
65
67
  '--batch-mode',
@@ -67,7 +69,7 @@ module.exports = function mvnwSync(args) {
67
69
  '--fail-fast',
68
70
  ]);
69
71
  const cmd = bin + ' ' + params.join(' ');
70
- console.log('+ ' + cmd);
72
+ console.debug('+ %s', cmd);
71
73
  const result = spawnSync(bin, params, {cwd: home, stdio: 'inherit'});
72
74
  if (result.status != 0) {
73
75
  throw new Error('The command "' + cmd + '" exited with #' + result.status + ' code');
@@ -0,0 +1,74 @@
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 safe = require('colors/safe');
27
+ const util = require('node:util');
28
+
29
+ const levels = {
30
+ 'trace': false,
31
+ 'debug': false,
32
+ 'info': true,
33
+ 'warn': true,
34
+ 'error': true,
35
+ };
36
+
37
+ const colors = {
38
+ 'trace': 'gray',
39
+ 'debug': 'gray',
40
+ 'info': 'white',
41
+ 'warn': 'orange',
42
+ 'error': 'red',
43
+ };
44
+
45
+ for (const level in levels) {
46
+ if (levels.hasOwnProperty(level)) {
47
+ const lvl = level;
48
+ const before = console[lvl];
49
+ console[level] = function(...args) {
50
+ if (!levels[lvl]) {
51
+ return;
52
+ }
53
+ before.call(
54
+ before,
55
+ safe[colors[lvl]](util.format(...args))
56
+ );
57
+ };
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Enable this particular logging level.
63
+ * @param {String} level - The level to enable
64
+ */
65
+ module.exports.enable = function enable(level) {
66
+ for (const key in levels) {
67
+ if (levels.hasOwnProperty(level)) {
68
+ levels[key] = true;
69
+ if (key === level) {
70
+ break;
71
+ }
72
+ }
73
+ }
74
+ };
package/src/version.js CHANGED
@@ -23,4 +23,4 @@
23
23
  * SOFTWARE.
24
24
  */
25
25
 
26
- module.exports = '0.3.0';
26
+ module.exports = '0.4.0';