eolang 0.2.3 → 0.3.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 CHANGED
@@ -16,14 +16,14 @@ 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.
@@ -60,4 +60,4 @@ If you want to run a single test:
60
60
  $ npm test -- test/test_mvnw.js
61
61
  ```
62
62
 
63
- Then, make a pull request.
63
+ 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 here. Just run this to make sure
4
+ it works:
5
+
6
+ ```
7
+ $ ../src/eoc.js dataize foo.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
@@ -44,6 +44,7 @@ SOFTWARE.
44
44
  <sourceDirectory>${eo.generatedDir}</sourceDirectory>
45
45
  <directory>${eo.targetDir}</directory>
46
46
  <outputDirectory>${eo.targetDir}/classes</outputDirectory>
47
+ <testOutputDirectory>${eo.targetDir}/classes</testOutputDirectory>
47
48
  <plugins>
48
49
  <plugin>
49
50
  <groupId>org.eolang</groupId>
@@ -72,6 +73,13 @@ SOFTWARE.
72
73
  </archive>
73
74
  </configuration>
74
75
  </plugin>
76
+ <plugin>
77
+ <artifactId>maven-surefire-plugin</artifactId>
78
+ <version>3.0.0-M7</version>
79
+ <configuration>
80
+ <failIfNoTests>true</failIfNoTests>
81
+ </configuration>
82
+ </plugin>
75
83
  </plugins>
76
84
  </build>
77
85
  </project>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eolang",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "author": "Yegor Bugayenko <yegor256@gmail.com> (https://www.yegor256.com/)",
5
5
  "license": "MIT",
6
6
  "repository": "objectionary/eoc",
@@ -0,0 +1,38 @@
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
+ const path = require('path');
28
+
29
+ /**
30
+ * Command to run all available unit tests.
31
+ * @param {Hash} opts - All options
32
+ */
33
+ module.exports = function test(opts) {
34
+ mvnwSync([
35
+ 'surefire:test',
36
+ `-Deo.targetDir=${path.resolve(opts.target)}`,
37
+ ]);
38
+ };
package/src/eoc.js CHANGED
@@ -26,6 +26,16 @@
26
26
  const {Command} = require('commander');
27
27
  const program = new Command();
28
28
 
29
+ const audit = require('./commands/audit');
30
+ const clean = require('./commands/clean');
31
+ const assemble = require('./commands/assemble');
32
+ const register = require('./commands/register');
33
+ const transpile = require('./commands/transpile');
34
+ const compile = require('./commands/compile');
35
+ const link = require('./commands/link');
36
+ const dataize = require('./commands/dataize');
37
+ const test = require('./commands/test');
38
+
29
39
  program
30
40
  .name('eoc')
31
41
  .description('EO command-line toolkit')
@@ -33,79 +43,98 @@ program
33
43
 
34
44
  program
35
45
  .option('-s, --sources <path>', 'directory with .EO sources', '.')
36
- .option('-t, --target <path>', 'directory with all generated files', '.eoc');
46
+ .option('-t, --target <path>', 'directory with all generated files', '.eoc')
47
+ .option('--alone', 'just run a single command without dependencies');
37
48
 
38
49
  program.command('audit')
39
50
  .description('inspects all packages and reports their status')
40
- .action((str, options) => {
41
- const audit = require('./commands/audit');
51
+ .action((str, opts) => {
42
52
  audit(program.opts());
43
53
  });
44
54
 
45
55
  program.command('clean')
46
56
  .description('delete all temporary files')
47
- .action((str, options) => {
48
- const clean = require('./commands/clean');
57
+ .action((str, opts) => {
49
58
  clean(program.opts());
50
59
  });
51
60
 
52
61
  program.command('register')
53
62
  .description('register all visible EO source files')
54
- .action((str, options) => {
55
- const register = require('./commands/register');
63
+ .action((str, opts) => {
56
64
  register(program.opts());
57
65
  });
58
66
 
59
67
  program.command('assemble')
60
68
  .description('parse EO files into XMIR and join them with required dependencies')
61
- .action((str, options) => {
62
- const assemble = require('./commands/assemble');
69
+ .action((str, opts) => {
70
+ if (program.opts().alone == undefined) {
71
+ register(program.opts());
72
+ }
63
73
  assemble(program.opts());
64
74
  });
65
75
 
66
76
  program.command('transpile')
67
77
  .description('converts EO files into target language')
68
- .action((str, options) => {
69
- const transpile = require('./commands/transpile');
78
+ .action((str, opts) => {
79
+ if (program.opts().alone == undefined) {
80
+ register(program.opts());
81
+ assemble(program.opts());
82
+ }
70
83
  transpile(program.opts());
71
84
  });
72
85
 
73
86
  program.command('compile')
74
87
  .description('compiles target language sources into binaries')
75
- .action((str, options) => {
76
- const compile = require('./commands/compile');
88
+ .action((str, opts) => {
89
+ if (program.opts().alone == undefined) {
90
+ register(program.opts());
91
+ assemble(program.opts());
92
+ transpile(program.opts());
93
+ }
77
94
  compile(program.opts());
78
95
  });
79
96
 
80
97
  program.command('link')
81
98
  .description('link together all binaries into a single executable binary')
82
- .action((str, options) => {
83
- const link = require('./commands/link');
99
+ .action((str, opts) => {
100
+ if (program.opts().alone == undefined) {
101
+ register(program.opts());
102
+ assemble(program.opts());
103
+ transpile(program.opts());
104
+ compile(program.opts());
105
+ }
84
106
  link(program.opts());
85
107
  });
86
108
 
87
109
  program.command('dataize')
88
110
  .description('run the single executable binary and dataize an object')
89
- .action((str, options) => {
90
- const dataize = require('./commands/dataize');
111
+ .action((str, opts) => {
112
+ if (program.opts().alone == undefined) {
113
+ register(program.opts());
114
+ assemble(program.opts());
115
+ transpile(program.opts());
116
+ compile(program.opts());
117
+ link(program.opts());
118
+ }
91
119
  dataize(program.args[1], program.opts());
92
120
  });
93
121
 
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());
122
+ program.command('test')
123
+ .description('run all visible unit tests')
124
+ .action((str, opts) => {
125
+ if (program.opts().alone == undefined) {
126
+ register(program.opts());
127
+ assemble(program.opts());
128
+ transpile(program.opts());
129
+ compile(program.opts());
130
+ link(program.opts());
131
+ }
132
+ test(program.opts());
109
133
  });
110
134
 
111
- program.parse();
135
+ try {
136
+ program.parse(process.argv);
137
+ } catch (e) {
138
+ console.log('eoc failed: "' + e.message + '"');
139
+ process.exit(1);
140
+ }
package/src/mvnw.js CHANGED
@@ -70,6 +70,6 @@ module.exports = function mvnwSync(args) {
70
70
  console.log('+ ' + cmd);
71
71
  const result = spawnSync(bin, params, {cwd: home, stdio: 'inherit'});
72
72
  if (result.status != 0) {
73
- throw new Error('Exit code: ' + result.status);
73
+ throw new Error('The command "' + cmd + '" exited with #' + result.status + ' code');
74
74
  }
75
75
  };
package/src/version.js CHANGED
@@ -23,4 +23,4 @@
23
23
  * SOFTWARE.
24
24
  */
25
25
 
26
- module.exports = '0.2.3';
26
+ module.exports = '0.3.0';