eolang 0.34.1 → 0.35.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/.markdownlint.json +4 -2
- package/CLAUDE.md +5 -0
- package/Formula/eolang.rb +3 -3
- package/Formula/eolang@0.32.0.rb +3 -3
- package/Formula/eolang@0.32.1.rb +3 -3
- package/Formula/eolang@0.33.0.rb +3 -3
- package/README.md +7 -5
- package/eo-version.txt +1 -1
- package/home-tag.txt +1 -1
- package/mvnw/.mvn/wrapper/maven-wrapper.properties +1 -1
- package/mvnw/dependency-reduced-pom.xml +1 -5
- package/mvnw/pom.xml +1 -5
- package/package.json +2 -2
- package/renovate.json +3 -0
- package/src/commands/docs.js +2 -19
- package/src/commands/java/pipeline.js +0 -1
- package/src/commands/lint.js +1 -1
- package/src/commands/normalize.js +64 -0
- package/src/commands/parse.js +0 -1
- package/src/commands/register.js +0 -1
- package/src/eoc.js +10 -20
- package/src/files.js +61 -0
- package/src/version.js +2 -2
- package/src/commands/sodg.js +0 -45
package/.markdownlint.json
CHANGED
package/CLAUDE.md
ADDED
package/Formula/eolang.rb
CHANGED
|
@@ -7,9 +7,9 @@ require "language/node"
|
|
|
7
7
|
class Eolang < Formula
|
|
8
8
|
desc "Command-line Tool-Kit"
|
|
9
9
|
homepage "https://github.com/objectionary/eoc"
|
|
10
|
-
url "https://github.com/objectionary/eoc/archive/refs/tags/0.34.
|
|
11
|
-
version "0.
|
|
12
|
-
sha256 "
|
|
10
|
+
url "https://github.com/objectionary/eoc/archive/refs/tags/0.34.1.tar.gz"
|
|
11
|
+
version "0.34.1"
|
|
12
|
+
sha256 "ecf7f19115086fadbe1785b789378928d81dc8f0e3aa154b268f3a747c80fd01"
|
|
13
13
|
license "MIT"
|
|
14
14
|
|
|
15
15
|
depends_on "node"
|
package/Formula/eolang@0.32.0.rb
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
#
|
|
5
5
|
|
|
6
6
|
require "language/node"
|
|
7
|
-
class
|
|
7
|
+
class EolangAT0320 < Formula
|
|
8
8
|
desc "Command-line Tool-Kit"
|
|
9
9
|
homepage "https://github.com/objectionary/eoc"
|
|
10
|
-
url "https://github.com/objectionary/eoc/archive/refs/tags/0.
|
|
10
|
+
url "https://github.com/objectionary/eoc/archive/refs/tags/0.32.0.tar.gz"
|
|
11
11
|
version "0.32.0"
|
|
12
|
-
sha256 "
|
|
12
|
+
sha256 "a24da178f48e1e64280aa467fd97986d9456a25ea023525bf36a9308ec1a4cea"
|
|
13
13
|
license "MIT"
|
|
14
14
|
|
|
15
15
|
depends_on "node"
|
package/Formula/eolang@0.32.1.rb
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
#
|
|
5
5
|
|
|
6
6
|
require "language/node"
|
|
7
|
-
class
|
|
7
|
+
class EolangAT0321 < Formula
|
|
8
8
|
desc "Command-line Tool-Kit"
|
|
9
9
|
homepage "https://github.com/objectionary/eoc"
|
|
10
|
-
url "https://github.com/objectionary/eoc/archive/refs/tags/0.
|
|
10
|
+
url "https://github.com/objectionary/eoc/archive/refs/tags/0.32.1.tar.gz"
|
|
11
11
|
version "0.32.1"
|
|
12
|
-
sha256 "
|
|
12
|
+
sha256 "6770b4eb3068b5675e2f8c1cce580693f2ad844c6f9472fd2e236f81ba356ab2"
|
|
13
13
|
license "MIT"
|
|
14
14
|
|
|
15
15
|
depends_on "node"
|
package/Formula/eolang@0.33.0.rb
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
#
|
|
5
5
|
|
|
6
6
|
require "language/node"
|
|
7
|
-
class
|
|
7
|
+
class EolangAT0330 < Formula
|
|
8
8
|
desc "Command-line Tool-Kit"
|
|
9
9
|
homepage "https://github.com/objectionary/eoc"
|
|
10
|
-
url "https://github.com/objectionary/eoc/archive/refs/tags/0.
|
|
10
|
+
url "https://github.com/objectionary/eoc/archive/refs/tags/0.33.0.tar.gz"
|
|
11
11
|
version "0.33.0"
|
|
12
|
-
sha256 "
|
|
12
|
+
sha256 "6e01b4d88ba92018c359fa0bffc3a23742610de454107a7605cd2eecb9ba9a33"
|
|
13
13
|
license "MIT"
|
|
14
14
|
|
|
15
15
|
depends_on "node"
|
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
[](https://codecov.io/gh/objectionary/eoc)
|
|
10
10
|
[](https://hitsofcode.com/view/github/objectionary/eoc)
|
|
11
11
|
[](https://github.com/objectionary/eoc/blob/master/LICENSE.txt)
|
|
12
|
+
[](https://github.com/objectionary/eoc/releases/tag/0.34.1)
|
|
12
13
|
|
|
13
14
|
This is a command-line tool-kit for [EO](https://www.eolang.org)
|
|
14
15
|
programming languages, allowing you to compile EO programs, test, dataize,
|
|
@@ -19,14 +20,14 @@ First, you install [npm][npm-install] and [Java SE][java-se].
|
|
|
19
20
|
Then, you install [eolang][npm] package, using [npm][npm-install]:
|
|
20
21
|
|
|
21
22
|
```bash
|
|
22
|
-
npm install -g eolang@0.
|
|
23
|
+
npm install -g eolang@0.35.0
|
|
23
24
|
```
|
|
24
25
|
|
|
25
26
|
You can also use [Homebrew] (on macOS):
|
|
26
27
|
|
|
27
28
|
```bash
|
|
28
29
|
brew tap objectionary/eoc https://github.com/objectionary/eoc
|
|
29
|
-
brew install objectionary/eoc/eolang@0.
|
|
30
|
+
brew install objectionary/eoc/eolang@0.35.0
|
|
30
31
|
```
|
|
31
32
|
|
|
32
33
|
Or install it via [Nix flakes](https://nixos.wiki/wiki/Flakes):
|
|
@@ -97,7 +98,7 @@ in the current directory:
|
|
|
97
98
|
```eo
|
|
98
99
|
# My first object in EO!
|
|
99
100
|
[args] > hello
|
|
100
|
-
|
|
101
|
+
io.stdout > @
|
|
101
102
|
"Hello, world!\n"
|
|
102
103
|
```
|
|
103
104
|
|
|
@@ -135,13 +136,15 @@ There are also commands that help manipulate with XMIR and EO sources
|
|
|
135
136
|
|
|
136
137
|
* `audit` inspects all required packages and reports their status
|
|
137
138
|
* `foreign` inspects all objects found in the program after the `assemble` step
|
|
138
|
-
* `sodg` generates `.sodg` from `.xmir`, further rederable as XML or [Dot][dot]
|
|
139
139
|
* `print` generates `.eo` files from `.xmir` files
|
|
140
140
|
* `generate_comments` generates `.json` files with LLM-generated
|
|
141
141
|
documentation for `.eo` structures
|
|
142
142
|
* `docs` generates HTML documentation from `.xmir` files
|
|
143
143
|
* `latex` generates `.tex` files from `.eo` sources
|
|
144
144
|
* `fmt` formats `.eo` files in the source directory
|
|
145
|
+
* `normalize` normalizes `.eo` files via phi-calculus rewriting using
|
|
146
|
+
[phino](https://github.com/objectionary/phino) (must be installed separately);
|
|
147
|
+
original files are saved to `.eoc/before-normalize/` for debugging
|
|
145
148
|
* ~~`translate` converts Java/C++/Python/etc. program to EO program~~
|
|
146
149
|
* ~~`demu` removes `cage` and `memory` objects~~
|
|
147
150
|
* ~~`dejump` removes `goto` objects~~
|
|
@@ -201,6 +204,5 @@ a pull request.
|
|
|
201
204
|
[npm]: https://www.npmjs.com/package/eolang
|
|
202
205
|
[java-se]: https://www.oracle.com/java/technologies/downloads/
|
|
203
206
|
[npm-install]: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
|
|
204
|
-
[dot]: https://en.wikipedia.org/wiki/DOT_%28graph_description_language%29
|
|
205
207
|
[blog]: https://www.yegor256.com/2021/10/21/objectionary.html
|
|
206
208
|
[Homebrew]: https://brew.sh/
|
package/eo-version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.61.0
|
package/home-tag.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.59.
|
|
1
|
+
0.59.7
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
# SPDX-FileCopyrightText: Copyright (c) 2022-2026 Objectionary.com
|
|
2
2
|
# SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.
|
|
4
|
+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.14/apache-maven-3.9.14-bin.zip
|
|
@@ -35,8 +35,6 @@
|
|
|
35
35
|
<version>${eo.version}</version>
|
|
36
36
|
<configuration>
|
|
37
37
|
<excludeSources>**/.eoc/**</excludeSources>
|
|
38
|
-
<sodgIncludes>${eo.sodgIncludes}</sodgIncludes>
|
|
39
|
-
<sodgExcludes>${eo.sodgIncludes},**/*-test.eo</sodgExcludes>
|
|
40
38
|
<foreign>${project.build.directory}/eo-foreign.json</foreign>
|
|
41
39
|
<foreignFormat>json</foreignFormat>
|
|
42
40
|
</configuration>
|
|
@@ -75,7 +73,7 @@
|
|
|
75
73
|
</plugin>
|
|
76
74
|
<plugin>
|
|
77
75
|
<artifactId>maven-shade-plugin</artifactId>
|
|
78
|
-
<version>3.6.
|
|
76
|
+
<version>3.6.2</version>
|
|
79
77
|
</plugin>
|
|
80
78
|
<plugin>
|
|
81
79
|
<artifactId>maven-surefire-plugin</artifactId>
|
|
@@ -97,8 +95,6 @@
|
|
|
97
95
|
<version>${eo.version}</version>
|
|
98
96
|
<configuration>
|
|
99
97
|
<excludeSources>**/.eoc/**</excludeSources>
|
|
100
|
-
<sodgIncludes>${eo.sodgIncludes},**/*-test.eo</sodgIncludes>
|
|
101
|
-
<sodgExcludes>${eo.sodgExcludes}</sodgExcludes>
|
|
102
98
|
<foreign>${project.build.directory}/eo-foreign.json</foreign>
|
|
103
99
|
<foreignFormat>json</foreignFormat>
|
|
104
100
|
</configuration>
|
package/mvnw/pom.xml
CHANGED
|
@@ -56,8 +56,6 @@
|
|
|
56
56
|
<version>${eo.version}</version>
|
|
57
57
|
<configuration>
|
|
58
58
|
<excludeSources>**/.eoc/**</excludeSources>
|
|
59
|
-
<sodgIncludes>${eo.sodgIncludes}</sodgIncludes>
|
|
60
|
-
<sodgExcludes>${eo.sodgIncludes},**/*-test.eo</sodgExcludes>
|
|
61
59
|
<foreign>${project.build.directory}/eo-foreign.json</foreign>
|
|
62
60
|
<foreignFormat>json</foreignFormat>
|
|
63
61
|
</configuration>
|
|
@@ -96,7 +94,7 @@
|
|
|
96
94
|
</plugin>
|
|
97
95
|
<plugin>
|
|
98
96
|
<artifactId>maven-shade-plugin</artifactId>
|
|
99
|
-
<version>3.6.
|
|
97
|
+
<version>3.6.2</version>
|
|
100
98
|
</plugin>
|
|
101
99
|
<plugin>
|
|
102
100
|
<artifactId>maven-surefire-plugin</artifactId>
|
|
@@ -137,8 +135,6 @@
|
|
|
137
135
|
<version>${eo.version}</version>
|
|
138
136
|
<configuration>
|
|
139
137
|
<excludeSources>**/.eoc/**</excludeSources>
|
|
140
|
-
<sodgIncludes>${eo.sodgIncludes},**/*-test.eo</sodgIncludes>
|
|
141
|
-
<sodgExcludes>${eo.sodgExcludes}</sodgExcludes>
|
|
142
138
|
<foreign>${project.build.directory}/eo-foreign.json</foreign>
|
|
143
139
|
<foreignFormat>json</foreignFormat>
|
|
144
140
|
</configuration>
|
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"grunt": "^1.6.1",
|
|
26
26
|
"grunt-contrib-clean": "^2.0.1",
|
|
27
27
|
"grunt-eslint": "^26.0.0",
|
|
28
|
-
"grunt-mocha-
|
|
28
|
+
"grunt-mocha-test": "^0.13.3",
|
|
29
29
|
"istanbul": "^0.4.5",
|
|
30
30
|
"mocha": "^11.7.5",
|
|
31
31
|
"nyc": "^18.0.0",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"postinstall": "node scripts/postinstall.js",
|
|
75
75
|
"test": "mocha 'test/**/*.js' --timeout 1200000"
|
|
76
76
|
},
|
|
77
|
-
"version": "0.
|
|
77
|
+
"version": "0.35.1"
|
|
78
78
|
}
|
package/renovate.json
CHANGED
package/src/commands/docs.js
CHANGED
|
@@ -8,25 +8,8 @@ const path = require('path');
|
|
|
8
8
|
const SaxonJS = require('saxon-js');
|
|
9
9
|
const { marked } = require('marked');
|
|
10
10
|
const {elapsed} = require('../elapsed');
|
|
11
|
+
const {findFiles} = require('../files');
|
|
11
12
|
|
|
12
|
-
/**
|
|
13
|
-
* Recursively reads all .xmir files from a directory.
|
|
14
|
-
* @param {string} dir - Directory path
|
|
15
|
-
* @return {string[]} Array of file paths
|
|
16
|
-
*/
|
|
17
|
-
function readXmirsRecursively(dir) {
|
|
18
|
-
const files = [];
|
|
19
|
-
const entries = fs.readdirSync(dir, {withFileTypes: true});
|
|
20
|
-
for (const entry of entries) {
|
|
21
|
-
const full = path.join(dir, entry.name);
|
|
22
|
-
if (entry.isDirectory()) {
|
|
23
|
-
files.push(...readXmirsRecursively(full));
|
|
24
|
-
} else if (entry.name.endsWith('.xmir')) {
|
|
25
|
-
files.push(full);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return files;
|
|
29
|
-
}
|
|
30
13
|
|
|
31
14
|
/**
|
|
32
15
|
* Applies XSLT to XMIR
|
|
@@ -136,7 +119,7 @@ module.exports = function(opts) {
|
|
|
136
119
|
fs.writeFileSync(css, '');
|
|
137
120
|
const packages_info = {};
|
|
138
121
|
const all_xmir_htmls = [];
|
|
139
|
-
const xmirs =
|
|
122
|
+
const xmirs = findFiles(input, '.xmir');
|
|
140
123
|
for (const xmir of xmirs) {
|
|
141
124
|
const relative = path.relative(input, xmir);
|
|
142
125
|
const name = path.parse(xmir).name;
|
package/src/commands/lint.js
CHANGED
|
@@ -15,7 +15,7 @@ const semver = require('semver');
|
|
|
15
15
|
* @return {Promise} of assemble task
|
|
16
16
|
*/
|
|
17
17
|
module.exports = function(opts) {
|
|
18
|
-
const extra =
|
|
18
|
+
const extra = extras(opts);
|
|
19
19
|
return elapsed(async (tracked) => {
|
|
20
20
|
if (goals(opts)[0] === 'eo:lint') {
|
|
21
21
|
try {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SPDX-FileCopyrightText: Copyright (c) 2022-2026 Objectionary.com
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const {execSync} = require('child_process');
|
|
8
|
+
const {mvnw, flags} = require('../mvnw');
|
|
9
|
+
const {elapsed} = require('../elapsed');
|
|
10
|
+
const {findFiles, saveFile, copyDir} = require('../files');
|
|
11
|
+
const relative = require('relative');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Command to normalize .EO files via phi-calculus using phino.
|
|
15
|
+
* Runs parse, converts XMIR → .phi → normalize → .phi → XMIR → .eo.
|
|
16
|
+
* Original .eo files are saved to .eoc/before-normalize/ for debugging.
|
|
17
|
+
* Fails if phino is not installed.
|
|
18
|
+
* @param {Object} opts - All options
|
|
19
|
+
* @return {Promise} of normalize task
|
|
20
|
+
*/
|
|
21
|
+
module.exports = function(opts) {
|
|
22
|
+
if (opts.sources === undefined) {
|
|
23
|
+
throw new Error('Sources directory is not specified. Please provide it with --sources option.');
|
|
24
|
+
}
|
|
25
|
+
if (opts.target === undefined) {
|
|
26
|
+
throw new Error('Target directory is not specified. Please provide it with --target option.');
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
execSync('phino --version', {stdio: 'pipe'});
|
|
30
|
+
} catch (e) {
|
|
31
|
+
throw new Error('phino is not installed, see https://github.com/objectionary/phino', {cause: e});
|
|
32
|
+
}
|
|
33
|
+
const sources = path.resolve(opts.sources);
|
|
34
|
+
const target = path.resolve(opts.target);
|
|
35
|
+
return elapsed(async (tracked) => {
|
|
36
|
+
copyDir(sources, path.join(target, 'before-normalize'), '.eo');
|
|
37
|
+
const parsed = path.join(target, '1-parse');
|
|
38
|
+
const normed = path.join(target, 'xmir-normalized');
|
|
39
|
+
const xmirs = findFiles(parsed, '.xmir');
|
|
40
|
+
console.debug('Found %d XMIR file(s) to normalize', xmirs.length);
|
|
41
|
+
for (const xmir of xmirs) {
|
|
42
|
+
const rel = path.relative(parsed, xmir);
|
|
43
|
+
console.debug('Normalizing %s', rel);
|
|
44
|
+
const ts = Date.now();
|
|
45
|
+
const out = execSync(
|
|
46
|
+
`phino rewrite --input=xmir --output=xmir --normalize ${xmir}`,
|
|
47
|
+
{stdio: ['pipe', 'pipe', 'pipe']}
|
|
48
|
+
);
|
|
49
|
+
console.debug('Normalized in %dms', Date.now() - ts);
|
|
50
|
+
saveFile(normed, rel, out);
|
|
51
|
+
}
|
|
52
|
+
const r = await mvnw(
|
|
53
|
+
['eo:print']
|
|
54
|
+
.concat(flags(opts))
|
|
55
|
+
.concat([
|
|
56
|
+
`-Deo.printSourcesDir=${normed}`,
|
|
57
|
+
`-Deo.printOutputDir=${sources}`,
|
|
58
|
+
]),
|
|
59
|
+
opts.target, opts.batch
|
|
60
|
+
);
|
|
61
|
+
tracked.print(`EO files normalized in ${relative(sources)}`);
|
|
62
|
+
return r;
|
|
63
|
+
});
|
|
64
|
+
};
|
package/src/commands/parse.js
CHANGED
package/src/commands/register.js
CHANGED
package/src/eoc.js
CHANGED
|
@@ -26,13 +26,13 @@ const {program} = require('commander'),
|
|
|
26
26
|
parse: require('./commands/parse'),
|
|
27
27
|
print: require('./commands/print'),
|
|
28
28
|
register: require('./commands/register'),
|
|
29
|
-
sodg: require('./commands/sodg'),
|
|
30
29
|
lint: require('./commands/lint'),
|
|
31
30
|
docs: require('./commands/docs'),
|
|
32
31
|
generate_comments: require('./commands/generate_comments'),
|
|
33
32
|
jeo_disassemble: require('./commands/jeo/disassemble'),
|
|
34
33
|
jeo_assemble: require('./commands/jeo/assemble'),
|
|
35
34
|
latex: require('./commands/latex'),
|
|
35
|
+
normalize: require('./commands/normalize'),
|
|
36
36
|
},
|
|
37
37
|
commands = {
|
|
38
38
|
[language.java]: {
|
|
@@ -165,25 +165,6 @@ program.command('assemble')
|
|
|
165
165
|
}
|
|
166
166
|
});
|
|
167
167
|
|
|
168
|
-
program.command('sodg')
|
|
169
|
-
.description('Generate SODG files from XMIR')
|
|
170
|
-
.option('--xml', 'Generate .sodg.xml files')
|
|
171
|
-
.option('--xembly', 'Generate .sodg.xe files')
|
|
172
|
-
.option('--graph', 'Generate .sodg.graph files')
|
|
173
|
-
.option('--dot', 'Generate .sodg.dot files')
|
|
174
|
-
.option('--include <names>', 'Generate SODG for these object names (using mask)', '**')
|
|
175
|
-
.option('--exclude <names>', 'Don\'t generate SODG for these objects')
|
|
176
|
-
.action(async (str, opts) => {
|
|
177
|
-
pin(program.opts());
|
|
178
|
-
clear(str);
|
|
179
|
-
if (program.opts().alone === undefined) {
|
|
180
|
-
await pipe()(coms(), ['register', 'assemble'], program.opts());
|
|
181
|
-
await coms().sodg({...program.opts(), ...str});
|
|
182
|
-
} else {
|
|
183
|
-
await coms().sodg({...program.opts(), ...str});
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
|
|
187
168
|
program.command('print')
|
|
188
169
|
.description('Generate EO files from XMIR files')
|
|
189
170
|
.option(
|
|
@@ -371,6 +352,15 @@ program.command('latex')
|
|
|
371
352
|
await coms().latex(program.opts());
|
|
372
353
|
});
|
|
373
354
|
|
|
355
|
+
program.command('normalize')
|
|
356
|
+
.description('Normalize EO files using phi-calculus normalization via phino')
|
|
357
|
+
.action(async (str, opts) => {
|
|
358
|
+
pin(program.opts());
|
|
359
|
+
clear(str);
|
|
360
|
+
await pipe()(coms(), ['register', 'parse'], program.opts());
|
|
361
|
+
await coms().normalize(program.opts());
|
|
362
|
+
});
|
|
363
|
+
|
|
374
364
|
program.command('fmt')
|
|
375
365
|
.description('Format EO files in the source directory')
|
|
376
366
|
.action(async (str, opts) => {
|
package/src/files.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SPDX-FileCopyrightText: Copyright (c) 2022-2026 Objectionary.com
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Recursively find all files with given extension in a directory.
|
|
11
|
+
* @param {string} dir - Directory to search
|
|
12
|
+
* @param {string} ext - File extension including dot (e.g. '.xmir')
|
|
13
|
+
* @return {Array.<string>} List of absolute file paths
|
|
14
|
+
*/
|
|
15
|
+
function findFiles(dir, ext) {
|
|
16
|
+
if (!fs.existsSync(dir)) {return [];}
|
|
17
|
+
const result = [];
|
|
18
|
+
for (const entry of fs.readdirSync(dir, {withFileTypes: true})) {
|
|
19
|
+
const full = path.join(dir, entry.name);
|
|
20
|
+
if (entry.isDirectory()) {
|
|
21
|
+
result.push(...findFiles(full, ext));
|
|
22
|
+
} else if (entry.name.endsWith(ext)) {
|
|
23
|
+
result.push(full);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Write content to a file, creating parent directories as needed.
|
|
31
|
+
* @param {string} dir - Parent directory
|
|
32
|
+
* @param {string} name - File name relative to dir
|
|
33
|
+
* @param {Buffer} content - File content
|
|
34
|
+
*/
|
|
35
|
+
function saveFile(dir, name, content) {
|
|
36
|
+
const file = path.join(dir, name);
|
|
37
|
+
fs.mkdirSync(path.dirname(file), {recursive: true});
|
|
38
|
+
fs.writeFileSync(file, content);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Recursively copy files with given extension from src to dst directory.
|
|
43
|
+
* @param {string} src - Source directory
|
|
44
|
+
* @param {string} dst - Destination directory
|
|
45
|
+
* @param {string} ext - File extension filter (e.g. '.eo'), or empty for all files
|
|
46
|
+
*/
|
|
47
|
+
function copyDir(src, dst, ext) {
|
|
48
|
+
if (!fs.existsSync(src)) {return;}
|
|
49
|
+
fs.mkdirSync(dst, {recursive: true});
|
|
50
|
+
for (const entry of fs.readdirSync(src, {withFileTypes: true})) {
|
|
51
|
+
const source = path.join(src, entry.name);
|
|
52
|
+
const dest = path.join(dst, entry.name);
|
|
53
|
+
if (entry.isDirectory()) {
|
|
54
|
+
copyDir(source, dest, ext);
|
|
55
|
+
} else if (!ext || entry.name.endsWith(ext)) {
|
|
56
|
+
fs.copyFileSync(source, dest);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = {findFiles, saveFile, copyDir};
|
package/src/version.js
CHANGED
package/src/commands/sodg.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* SPDX-FileCopyrightText: Copyright (c) 2022-2026 Objectionary.com
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
const rel = require('relative');
|
|
7
|
-
const path = require('path');
|
|
8
|
-
const {mvnw, flags} = require('../mvnw');
|
|
9
|
-
const {elapsed} = require('../elapsed');
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Generate SODG files from XMIR.
|
|
13
|
-
* @param {Hash} opts - All options
|
|
14
|
-
* @return {Promise} of sodg task
|
|
15
|
-
*/
|
|
16
|
-
module.exports = function(opts) {
|
|
17
|
-
return elapsed(async (tracked) => {
|
|
18
|
-
const argv = ['eo:sodg'].concat(flags(opts));
|
|
19
|
-
argv.push(`-Deo.sodgIncludes=${opts.include}`);
|
|
20
|
-
if (opts.exclude) {
|
|
21
|
-
argv.push(`-Deo.sodgExcludes=${opts.exclude}`);
|
|
22
|
-
}
|
|
23
|
-
if (opts.xml) {
|
|
24
|
-
argv.push('-Deo.generateSodgXmlFiles');
|
|
25
|
-
}
|
|
26
|
-
if (opts.xembly) {
|
|
27
|
-
argv.push('-Deo.generateSodgXmlFiles');
|
|
28
|
-
argv.push('-Deo.generateXemblyFiles');
|
|
29
|
-
}
|
|
30
|
-
if (opts.graph) {
|
|
31
|
-
argv.push('-Deo.generateSodgXmlFiles');
|
|
32
|
-
argv.push('-Deo.generateXemblyFiles');
|
|
33
|
-
argv.push('-Deo.generateGraphFiles');
|
|
34
|
-
}
|
|
35
|
-
if (opts.dot) {
|
|
36
|
-
argv.push('-Deo.generateSodgXmlFiles');
|
|
37
|
-
argv.push('-Deo.generateXemblyFiles');
|
|
38
|
-
argv.push('-Deo.generateGraphFiles');
|
|
39
|
-
argv.push('-Deo.generateDotFiles');
|
|
40
|
-
}
|
|
41
|
-
const r = await mvnw(argv, opts.target, opts.batch);
|
|
42
|
-
tracked.print(`SODG files generated in ${rel(path.resolve(opts.target))}`);
|
|
43
|
-
return r;
|
|
44
|
-
});
|
|
45
|
-
};
|