eolang 0.2.3 → 0.4.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/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
@@ -16,18 +16,20 @@ in the current directory:
16
16
 
17
17
  ```
18
18
  [args...] > hello
19
- Q.org.eolang.io.stdout > @
19
+ QQ.io.stdout > @
20
20
  "Hello, world!\n"
21
21
  ```
22
22
 
23
23
  Then, you run it:
24
24
 
25
25
  ```
26
- $ eoc run hello
26
+ $ eoc dataize hello
27
27
  ```
28
28
 
29
29
  That's it.
30
30
 
31
+ ## Commands
32
+
31
33
  You can also do many other things with `eoc` commands
32
34
  (the flow is explained in [this blog post](https://www.yegor256.com/2021/10/21/objectionary.html)):
33
35
 
@@ -37,15 +39,16 @@ You can also do many other things with `eoc` commands
37
39
  * `compile` converts target language to binaries
38
40
  * `link` puts all binaries together into a single executable binary
39
41
  * `dataize` executes the binary and dataize a single object
42
+ * `test` executes all visible unit tests
40
43
 
41
- There are also commands that help manipulate with XMIR and EO sources:
44
+ There are also commands that help manipulate with XMIR and EO sources (some of them are not implemented as of yet):
42
45
 
43
46
  * `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
47
+ * <del>`translate` converts Java/C++/Python/etc. program to EO program</del>
48
+ * <del>`demu` removes `cage` and `memory` objects</del>
49
+ * <del>`dejump` removes `goto` objects</del>
50
+ * <del>`infer` suggests object names where it's possible to infer them</del>
51
+ * <del>`flatten` moves inner objects to upper level</del>
49
52
 
50
53
  This command line toolkit simply integrates other tools available in
51
54
  [@objectionary](https://github.com/objectionary) GitHub organization.
@@ -60,4 +63,4 @@ If you want to run a single test:
60
63
  $ npm test -- test/test_mvnw.js
61
64
  ```
62
65
 
63
- Then, make a pull request.
66
+ Then, make a pull request.
@@ -0,0 +1,16 @@
1
+ [![grunt](https://github.com/objectionary/eoc/actions/workflows/itest.yml/badge.svg)](https://github.com/objectionary/eoc/actions/workflows/itest.yml)
2
+
3
+ There is a simple integration test here. Just run this to make sure
4
+ it works:
5
+
6
+ ```
7
+ $ ../src/eoc.js dataize program
8
+ ```
9
+
10
+ Then, you can execute the unit tests too:
11
+
12
+ ```
13
+ $ ../src/eoc.js test
14
+ ```
15
+
16
+ If doesn't work, submit an issue.
@@ -0,0 +1,27 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2022 Yegor Bugayenko
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included
13
+ # in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ +alias story
24
+
25
+ [args...] > program
26
+ QQ.io.stdout > @
27
+ story
@@ -0,0 +1,31 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2022 Yegor Bugayenko
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included
13
+ # in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ +junit
24
+ +alias org.eolang.hamcrest.assert-that
25
+ +alias story
26
+
27
+ [] > story-is-long-enough
28
+ assert-that > @
29
+ story.length
30
+ $.is
31
+ $.greater-than 1
package/itest/story.eo ADDED
@@ -0,0 +1,29 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2022 Yegor Bugayenko
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included
13
+ # in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ [] > story
24
+ QQ.txt.sprintf > @
25
+ "Hello, Mr. #%d!\n"
26
+ as-int.
27
+ times.
28
+ random
29
+ 100.0
package/mvnw/pom.xml CHANGED
@@ -27,6 +27,10 @@ SOFTWARE.
27
27
  <groupId>org.eolang</groupId>
28
28
  <artifactId>eoc</artifactId>
29
29
  <version>1.0-SNAPSHOT</version>
30
+ <properties>
31
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
32
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
33
+ </properties>
30
34
  <dependencies>
31
35
  <dependency>
32
36
  <groupId>org.junit.jupiter</groupId>
@@ -44,6 +48,7 @@ SOFTWARE.
44
48
  <sourceDirectory>${eo.generatedDir}</sourceDirectory>
45
49
  <directory>${eo.targetDir}</directory>
46
50
  <outputDirectory>${eo.targetDir}/classes</outputDirectory>
51
+ <testOutputDirectory>${eo.targetDir}/classes</testOutputDirectory>
47
52
  <plugins>
48
53
  <plugin>
49
54
  <groupId>org.eolang</groupId>
@@ -72,6 +77,13 @@ SOFTWARE.
72
77
  </archive>
73
78
  </configuration>
74
79
  </plugin>
80
+ <plugin>
81
+ <artifactId>maven-surefire-plugin</artifactId>
82
+ <version>3.0.0-M7</version>
83
+ <configuration>
84
+ <failIfNoTests>true</failIfNoTests>
85
+ </configuration>
86
+ </plugin>
75
87
  </plugins>
76
88
  </build>
77
89
  </project>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eolang",
3
- "version": "0.2.3",
3
+ "version": "0.4.1",
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"
@@ -1,4 +1,3 @@
1
- #! /usr/bin/env node
2
1
  /*
3
2
  * The MIT License (MIT)
4
3
  *
@@ -33,6 +32,7 @@ const mvnwSync = require('../mvnw');
33
32
  module.exports = function assemble(opts) {
34
33
  mvnwSync([
35
34
  'eo:assemble',
35
+ opts.verbose ? '' : '--quiet',
36
36
  `-Deo.targetDir=${path.resolve(opts.target)}`,
37
37
  `-Deo.outputDir=${path.resolve(opts.target, 'classes')}`,
38
38
  `-Deo.foreign=${path.resolve(opts.target, 'eo-foreign.csv')}`,
@@ -40,4 +40,5 @@ module.exports = function assemble(opts) {
40
40
  `-Deo.placed=${path.resolve(opts.target, 'eo-placed.csv')}`,
41
41
  `-Deo.placedFormat=csv`,
42
42
  ]);
43
+ console.info('EO program assembled in %s', path.resolve(opts.target));
43
44
  };
@@ -1,4 +1,3 @@
1
- #! /usr/bin/env node
2
1
  /*
3
2
  * The MIT License (MIT)
4
3
  *
@@ -1,4 +1,3 @@
1
- #! /usr/bin/env node
2
1
  /*
3
2
  * The MIT License (MIT)
4
3
  *
@@ -33,4 +32,5 @@ const path = require('path');
33
32
  module.exports = function clean(opts) {
34
33
  const home = path.resolve(opts.target);
35
34
  fs.rmSync(home, {recursive: true, force: true});
35
+ console.debug('The directory %s deleted', home);
36
36
  };
@@ -1,4 +1,3 @@
1
- #! /usr/bin/env node
2
1
  /*
3
2
  * The MIT License (MIT)
4
3
  *
@@ -31,11 +30,14 @@ const path = require('path');
31
30
  * @param {Hash} opts - All options
32
31
  */
33
32
  module.exports = function compile(opts) {
33
+ const target = path.resolve(opts.target);
34
34
  mvnwSync([
35
35
  'compiler:compile',
36
+ opts.verbose ? '' : '--quiet',
36
37
  `-Dmaven.compiler.source=1.8`,
37
38
  `-Dmaven.compiler.target=1.8`,
38
- `-Deo.targetDir=${path.resolve(opts.target)}`,
39
+ `-Deo.targetDir=${target}`,
39
40
  `-Deo.generatedDir=${path.resolve(opts.target, 'generated-sources')}`,
40
41
  ]);
42
+ console.info('Java .class files compiled into %s', target);
41
43
  };
@@ -1,4 +1,3 @@
1
- #! /usr/bin/env node
2
1
  /*
3
2
  * The MIT License (MIT)
4
3
  *
@@ -34,7 +33,11 @@ const path = require('path');
34
33
  module.exports = function dataize(obj, opts) {
35
34
  spawn(
36
35
  `java`,
37
- ['-jar', path.resolve(opts.target, 'eoc.jar'), obj],
36
+ [
37
+ '-Dfile.encoding=UTF-8',
38
+ '-jar', path.resolve(opts.target, 'eoc.jar'),
39
+ obj,
40
+ ],
38
41
  {stdio: 'inherit'}
39
42
  );
40
43
  };
@@ -1,4 +1,3 @@
1
- #! /usr/bin/env node
2
1
  /*
3
2
  * The MIT License (MIT)
4
3
  *
@@ -33,6 +32,8 @@ const path = require('path');
33
32
  module.exports = function link(opts) {
34
33
  mvnwSync([
35
34
  'jar:jar',
35
+ opts.verbose ? '' : '--quiet',
36
36
  `-Deo.targetDir=${path.resolve(opts.target)}`,
37
37
  ]);
38
+ console.info('Executable JAR created at %s', path.resolve(opts.target, 'eoc.jar'));
38
39
  };
@@ -1,4 +1,3 @@
1
- #! /usr/bin/env node
2
1
  /*
3
2
  * The MIT License (MIT)
4
3
  *
@@ -31,11 +30,14 @@ const path = require('path');
31
30
  * @param {Hash} opts - All options
32
31
  */
33
32
  module.exports = function register(opts) {
33
+ const foreign = path.resolve(opts.target, 'eo-foreign.csv');
34
34
  mvnwSync([
35
35
  'eo:register',
36
+ opts.verbose ? '' : '--quiet',
36
37
  `-Deo.targetDir=${path.resolve(opts.target)}`,
37
38
  `-Deo.sourcesDir=${path.resolve(opts.sources)}`,
38
- `-Deo.foreign=${path.resolve(opts.target, 'eo-foreign.csv')}`,
39
+ `-Deo.foreign=${foreign}`,
39
40
  `-Deo.foreignFormat=csv`,
40
41
  ]);
42
+ console.info('EO objects registered in %s', foreign);
41
43
  };
@@ -0,0 +1,37 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2022 Yegor Bugayenko
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 mvnwSync = require('../mvnw');
26
+ const path = require('path');
27
+
28
+ /**
29
+ * Command to run all available unit tests.
30
+ * @param {Hash} opts - All options
31
+ */
32
+ module.exports = function test(opts) {
33
+ mvnwSync([
34
+ 'surefire:test',
35
+ `-Deo.targetDir=${path.resolve(opts.target)}`,
36
+ ]);
37
+ };
@@ -1,4 +1,3 @@
1
- #! /usr/bin/env node
2
1
  /*
3
2
  * The MIT License (MIT)
4
3
  *
@@ -31,11 +30,14 @@ const path = require('path');
31
30
  * @param {Hash} opts - All options
32
31
  */
33
32
  module.exports = function transpile(opts) {
33
+ const sources = path.resolve(opts.target, 'generated-sources');
34
34
  mvnwSync([
35
35
  'eo:transpile',
36
+ opts.verbose ? '' : '--quiet',
36
37
  `-Deo.targetDir=${path.resolve(opts.target)}`,
37
- `-Deo.generatedDir=${path.resolve(opts.target, 'generated-sources')}`,
38
+ `-Deo.generatedDir=${sources}`,
38
39
  `-Deo.foreign=${path.resolve(opts.target, 'eo-foreign.csv')}`,
39
40
  `-Deo.foreignFormat=csv`,
40
41
  ]);
42
+ console.info('Java sources generated in %s', sources);
41
43
  };
package/src/eoc.js CHANGED
@@ -23,8 +23,23 @@
23
23
  * SOFTWARE.
24
24
  */
25
25
 
26
- const {Command} = require('commander');
27
- const program = new Command();
26
+ const {program} = require('commander');
27
+ const tinted = require('./tinted-console');
28
+ const audit = require('./commands/audit');
29
+ const clean = require('./commands/clean');
30
+ const assemble = require('./commands/assemble');
31
+ const register = require('./commands/register');
32
+ const transpile = require('./commands/transpile');
33
+ const compile = require('./commands/compile');
34
+ const link = require('./commands/link');
35
+ const dataize = require('./commands/dataize');
36
+ const test = require('./commands/test');
37
+
38
+ if (process.argv.includes('--verbose')) {
39
+ tinted.enable('debug');
40
+ console.debug('Debug output is turned ON');
41
+ console.info('INFO');
42
+ }
28
43
 
29
44
  program
30
45
  .name('eoc')
@@ -33,79 +48,100 @@ program
33
48
 
34
49
  program
35
50
  .option('-s, --sources <path>', 'directory with .EO sources', '.')
36
- .option('-t, --target <path>', 'directory with all generated files', '.eoc');
51
+ .option('-t, --target <path>', 'directory with all generated files', '.eoc')
52
+ .option('--alone', 'just run a single command without dependencies')
53
+ .option('--verbose', 'print debug messages and full output of child processes');
37
54
 
38
55
  program.command('audit')
39
56
  .description('inspects all packages and reports their status')
40
- .action((str, options) => {
41
- const audit = require('./commands/audit');
57
+ .action((str, opts) => {
42
58
  audit(program.opts());
43
59
  });
44
60
 
45
61
  program.command('clean')
46
62
  .description('delete all temporary files')
47
- .action((str, options) => {
48
- const clean = require('./commands/clean');
63
+ .action((str, opts) => {
49
64
  clean(program.opts());
50
65
  });
51
66
 
52
67
  program.command('register')
53
68
  .description('register all visible EO source files')
54
- .action((str, options) => {
55
- const register = require('./commands/register');
69
+ .action((str, opts) => {
56
70
  register(program.opts());
57
71
  });
58
72
 
59
73
  program.command('assemble')
60
74
  .description('parse EO files into XMIR and join them with required dependencies')
61
- .action((str, options) => {
62
- const assemble = require('./commands/assemble');
75
+ .action((str, opts) => {
76
+ if (program.opts().alone == undefined) {
77
+ register(program.opts());
78
+ }
63
79
  assemble(program.opts());
64
80
  });
65
81
 
66
82
  program.command('transpile')
67
83
  .description('converts EO files into target language')
68
- .action((str, options) => {
69
- const transpile = require('./commands/transpile');
84
+ .action((str, opts) => {
85
+ if (program.opts().alone == undefined) {
86
+ register(program.opts());
87
+ assemble(program.opts());
88
+ }
70
89
  transpile(program.opts());
71
90
  });
72
91
 
73
92
  program.command('compile')
74
93
  .description('compiles target language sources into binaries')
75
- .action((str, options) => {
76
- const compile = require('./commands/compile');
94
+ .action((str, opts) => {
95
+ if (program.opts().alone == undefined) {
96
+ register(program.opts());
97
+ assemble(program.opts());
98
+ transpile(program.opts());
99
+ }
77
100
  compile(program.opts());
78
101
  });
79
102
 
80
103
  program.command('link')
81
104
  .description('link together all binaries into a single executable binary')
82
- .action((str, options) => {
83
- const link = require('./commands/link');
105
+ .action((str, opts) => {
106
+ if (program.opts().alone == undefined) {
107
+ register(program.opts());
108
+ assemble(program.opts());
109
+ transpile(program.opts());
110
+ compile(program.opts());
111
+ }
84
112
  link(program.opts());
85
113
  });
86
114
 
87
115
  program.command('dataize')
88
116
  .description('run the single executable binary and dataize an object')
89
- .action((str, options) => {
90
- const dataize = require('./commands/dataize');
117
+ .action((str, opts) => {
118
+ if (program.opts().alone == undefined) {
119
+ register(program.opts());
120
+ assemble(program.opts());
121
+ transpile(program.opts());
122
+ compile(program.opts());
123
+ link(program.opts());
124
+ }
91
125
  dataize(program.args[1], program.opts());
92
126
  });
93
127
 
94
- program.command('run')
95
- .description('register, assemble, transpile, compile, link, and dataize an object')
96
- .action((str, options) => {
97
- const register = require('./commands/register');
98
- register(program.opts());
99
- const assemble = require('./commands/assemble');
100
- assemble(program.opts());
101
- const transpile = require('./commands/transpile');
102
- transpile(program.opts());
103
- const compile = require('./commands/compile');
104
- compile(program.opts());
105
- const link = require('./commands/link');
106
- link(program.opts());
107
- const dataize = require('./commands/dataize');
108
- dataize(program.args[1], program.opts());
128
+ program.command('test')
129
+ .description('run all visible unit tests')
130
+ .action((str, opts) => {
131
+ if (program.opts().alone == undefined) {
132
+ register(program.opts());
133
+ assemble(program.opts());
134
+ transpile(program.opts());
135
+ compile(program.opts());
136
+ link(program.opts());
137
+ }
138
+ test(program.opts());
109
139
  });
110
140
 
111
- program.parse();
141
+ try {
142
+ program.parse(process.argv);
143
+ } catch (e) {
144
+ console.error(e.message);
145
+ console.debug(e.stack);
146
+ process.exit(1);
147
+ }
package/src/mvnw.js CHANGED
@@ -1,4 +1,3 @@
1
- #! /usr/bin/env node
2
1
  /*
3
2
  * The MIT License (MIT)
4
3
  *
@@ -46,9 +45,9 @@ function latest() {
46
45
  }
47
46
  const xml = new XMLParser().parse(xhr.responseText);
48
47
  version = xml.metadata.versioning.release;
49
- console.log('The latest version of ' + repo + ' at ' + url + ' is ' + version);
48
+ console.debug('The latest version of %s at %s is %s', repo, url, version);
50
49
  }
51
- console.log('Current version of ' + repo + ' is ' + version);
50
+ console.debug('Current version of %s is %s', repo, version);
52
51
  return version;
53
52
  }
54
53
 
@@ -58,8 +57,10 @@ function latest() {
58
57
  */
59
58
  module.exports = function mvnwSync(args) {
60
59
  const home = path.resolve(__dirname, '../mvnw');
61
- const bin = path.resolve(home, 'mvnw');
62
- const params = args.concat([
60
+ const bin = path.resolve(home, 'mvnw') + (process.platform == 'win32' ? '.cmd' : '');
61
+ const params = args.filter(function(t) {
62
+ return t != '';
63
+ }).concat([
63
64
  '-Deo.version=' + latest(),
64
65
  '--errors',
65
66
  '--batch-mode',
@@ -67,9 +68,23 @@ module.exports = function mvnwSync(args) {
67
68
  '--fail-fast',
68
69
  ]);
69
70
  const cmd = bin + ' ' + params.join(' ');
70
- console.log('+ ' + cmd);
71
- const result = spawnSync(bin, params, {cwd: home, stdio: 'inherit'});
71
+ console.debug('+ %s', cmd);
72
+ const result = spawnSync(
73
+ bin,
74
+ process.platform == 'win32' ? params.map((p) => `"${p}"`) : params,
75
+ {
76
+ cwd: home,
77
+ stdio: 'inherit',
78
+ shell: (
79
+ process.platform == 'win32'
80
+ ?
81
+ 'C:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe'
82
+ :
83
+ undefined
84
+ ),
85
+ }
86
+ );
72
87
  if (result.status != 0) {
73
- throw new Error('Exit code: ' + result.status);
88
+ throw new Error('The command "' + cmd + '" exited with #' + result.status + ' code');
74
89
  }
75
90
  };
@@ -0,0 +1,73 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2022 Yegor Bugayenko
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 safe = require('colors/safe');
26
+ const util = require('node:util');
27
+
28
+ const levels = {
29
+ 'trace': false,
30
+ 'debug': false,
31
+ 'info': true,
32
+ 'warn': true,
33
+ 'error': true,
34
+ };
35
+
36
+ const colors = {
37
+ 'trace': 'gray',
38
+ 'debug': 'gray',
39
+ 'info': 'white',
40
+ 'warn': 'orange',
41
+ 'error': 'red',
42
+ };
43
+
44
+ for (const level in levels) {
45
+ if (levels.hasOwnProperty(level)) {
46
+ const lvl = level;
47
+ const before = console[lvl];
48
+ console[level] = function(...args) {
49
+ if (!levels[lvl]) {
50
+ return;
51
+ }
52
+ before.call(
53
+ before,
54
+ safe[colors[lvl]](util.format(...args))
55
+ );
56
+ };
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Enable this particular logging level.
62
+ * @param {String} level - The level to enable
63
+ */
64
+ module.exports.enable = function enable(level) {
65
+ for (const key in levels) {
66
+ if (levels.hasOwnProperty(level)) {
67
+ levels[key] = true;
68
+ if (key === level) {
69
+ break;
70
+ }
71
+ }
72
+ }
73
+ };
package/src/version.js CHANGED
@@ -1,4 +1,3 @@
1
- #! /usr/bin/env node
2
1
  /*
3
2
  * The MIT License (MIT)
4
3
  *
@@ -23,4 +22,4 @@
23
22
  * SOFTWARE.
24
23
  */
25
24
 
26
- module.exports = '0.2.3';
25
+ module.exports = '0.4.1';