eliscript 0.0.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/LICENSE +674 -0
- package/README.md +135 -0
- package/bin/eliscript +16 -0
- package/bin/eliscript-bootstrap +15 -0
- package/bin/eliscript-build +15 -0
- package/bin/eliscript-check +15 -0
- package/bin/eliscript-eval +15 -0
- package/bin/eliscript-format +15 -0
- package/bin/eliscript-org +10 -0
- package/bin/eliscript-portable +17 -0
- package/bin/eliscript-seed +10 -0
- package/bin/eliscript-seed-build +10 -0
- package/bin/eliscript-watch +15 -0
- package/bootstrap/README.md +100 -0
- package/bootstrap/compiler/analyzer.eli +1426 -0
- package/bootstrap/compiler/compiler.eli +472 -0
- package/bootstrap/compiler/emitter.eli +1745 -0
- package/bootstrap/compiler/expander.eli +2522 -0
- package/bootstrap/compiler/formatter.eli +359 -0
- package/bootstrap/compiler/ir.eli +297 -0
- package/bootstrap/compiler/lower.eli +661 -0
- package/bootstrap/compiler/project.eli +1120 -0
- package/bootstrap/compiler/reader.eli +321 -0
- package/bootstrap/compiler/source-map.eli +165 -0
- package/bootstrap/compiler/symbol.eli +92 -0
- package/bootstrap/compiler/syntax.eli +54 -0
- package/bootstrap/compiler/transient-analysis.eli +825 -0
- package/bootstrap/host/build.mjs +28 -0
- package/bootstrap/host/bun.mjs +282 -0
- package/bootstrap/host/check-cli.mjs +163 -0
- package/bootstrap/host/eliscript-cli.mjs +36 -0
- package/bootstrap/host/evaluation-cli.mjs +401 -0
- package/bootstrap/host/evaluation.mjs +560 -0
- package/bootstrap/host/format-cli.mjs +139 -0
- package/bootstrap/host/project-cli.mjs +295 -0
- package/bootstrap/host/project.mjs +1080 -0
- package/bootstrap/host/watch-cli.mjs +129 -0
- package/bootstrap/host/watch.mjs +267 -0
- package/browser/host.mjs +357 -0
- package/browser/worker.mjs +60 -0
- package/compiler/README.md +118 -0
- package/compiler/eliscript-analyzer.el +716 -0
- package/compiler/eliscript-cli.el +108 -0
- package/compiler/eliscript-diagnostic.el +158 -0
- package/compiler/eliscript-emitter.el +1351 -0
- package/compiler/eliscript-evaluation.el +259 -0
- package/compiler/eliscript-expander.el +1630 -0
- package/compiler/eliscript-form.el +79 -0
- package/compiler/eliscript-ir-emitter.el +1460 -0
- package/compiler/eliscript-ir.el +356 -0
- package/compiler/eliscript-lower.el +463 -0
- package/compiler/eliscript-macro-eval.el +811 -0
- package/compiler/eliscript-parameters.el +324 -0
- package/compiler/eliscript-portable.el +492 -0
- package/compiler/eliscript-project-cli.el +156 -0
- package/compiler/eliscript-project.el +1676 -0
- package/compiler/eliscript-reader.el +421 -0
- package/compiler/eliscript-source-map.el +192 -0
- package/compiler/eliscript-symbol.el +101 -0
- package/compiler/eliscript-transient-analysis.el +817 -0
- package/compiler/eliscript.el +239 -0
- package/dist/bootstrap/analyzer.mjs +968 -0
- package/dist/bootstrap/analyzer.mjs.map +1 -0
- package/dist/bootstrap/compiler.mjs +228 -0
- package/dist/bootstrap/compiler.mjs.map +1 -0
- package/dist/bootstrap/emitter.mjs +1173 -0
- package/dist/bootstrap/emitter.mjs.map +1 -0
- package/dist/bootstrap/expander.mjs +1469 -0
- package/dist/bootstrap/expander.mjs.map +1 -0
- package/dist/bootstrap/formatter.mjs +304 -0
- package/dist/bootstrap/formatter.mjs.map +1 -0
- package/dist/bootstrap/ir.mjs +193 -0
- package/dist/bootstrap/ir.mjs.map +1 -0
- package/dist/bootstrap/lower.mjs +344 -0
- package/dist/bootstrap/lower.mjs.map +1 -0
- package/dist/bootstrap/project.mjs +585 -0
- package/dist/bootstrap/project.mjs.map +1 -0
- package/dist/bootstrap/reader.mjs +259 -0
- package/dist/bootstrap/reader.mjs.map +1 -0
- package/dist/bootstrap/source-map.mjs +154 -0
- package/dist/bootstrap/source-map.mjs.map +1 -0
- package/dist/bootstrap/symbol.mjs +74 -0
- package/dist/bootstrap/symbol.mjs.map +1 -0
- package/dist/bootstrap/syntax.mjs +38 -0
- package/dist/bootstrap/syntax.mjs.map +1 -0
- package/dist/bootstrap/transient-analysis.mjs +660 -0
- package/dist/bootstrap/transient-analysis.mjs.map +1 -0
- package/dist/browser/compiler.js +6491 -0
- package/editor/README.md +83 -0
- package/editor/eliscript-mode.el +878 -0
- package/editor/eliscript-repl.el +501 -0
- package/package.json +163 -0
- package/platform/README.md +48 -0
- package/platform/browser.mjs +204 -0
- package/platform/worker.mjs +166 -0
- package/runtime/README.md +296 -0
- package/runtime/core/collection-internals.mjs +512 -0
- package/runtime/core/collection.mjs +645 -0
- package/runtime/core/data-text.mjs +532 -0
- package/runtime/core/data.mjs +268 -0
- package/runtime/core/identifier.mjs +314 -0
- package/runtime/core/lazy-sequence.mjs +244 -0
- package/runtime/core/list-internals.mjs +18 -0
- package/runtime/core/list.mjs +273 -0
- package/runtime/core/map-internals.mjs +793 -0
- package/runtime/core/map.mjs +394 -0
- package/runtime/core/metadata-internals.mjs +14 -0
- package/runtime/core/metadata.mjs +44 -0
- package/runtime/core/object-impl.mjs +65 -0
- package/runtime/core/object-impl.mjs.map +1 -0
- package/runtime/core/object.mjs +13 -0
- package/runtime/core/order.mjs +234 -0
- package/runtime/core/persistent-kind.mjs +43 -0
- package/runtime/core/protocol-error.mjs +36 -0
- package/runtime/core/protocol-impl.mjs +326 -0
- package/runtime/core/protocol-impl.mjs.map +1 -0
- package/runtime/core/protocol.mjs +14 -0
- package/runtime/core/queue-internals.mjs +27 -0
- package/runtime/core/queue.mjs +238 -0
- package/runtime/core/record.mjs +346 -0
- package/runtime/core/regex.mjs +184 -0
- package/runtime/core/sequence.mjs +632 -0
- package/runtime/core/set-algebra.mjs +287 -0
- package/runtime/core/set-internals.mjs +33 -0
- package/runtime/core/set.mjs +378 -0
- package/runtime/core/sorted-internals.mjs +215 -0
- package/runtime/core/sorted.mjs +598 -0
- package/runtime/core/text-impl.mjs +95 -0
- package/runtime/core/text-impl.mjs.map +1 -0
- package/runtime/core/text.mjs +15 -0
- package/runtime/core/transducer.mjs +668 -0
- package/runtime/core/transient-internals.mjs +38 -0
- package/runtime/core/transient.mjs +53 -0
- package/runtime/core/truth.mjs +3 -0
- package/runtime/core/type.mjs +262 -0
- package/runtime/core/value-internals.mjs +188 -0
- package/runtime/core/value.mjs +93 -0
- package/runtime/core/vector-internals.mjs +102 -0
- package/runtime/core/vector.mjs +951 -0
- package/runtime/literals.mjs +34 -0
- package/runtime/source-mapping.mjs +220 -0
- package/runtime/testing/list.mjs +52 -0
- package/runtime/testing/map.mjs +145 -0
- package/runtime/testing/queue.mjs +49 -0
- package/runtime/testing/set.mjs +61 -0
- package/runtime/testing/sorted.mjs +105 -0
- package/runtime/testing/value.mjs +17 -0
- package/runtime/testing/vector.mjs +102 -0
- package/runtime/worker-value-codec.mjs +565 -0
- package/runtime/worker-value-stream.mjs +786 -0
- package/runtime/worker.mjs +975 -0
- package/stdlib/README.md +774 -0
- package/stdlib/bit.eli +36 -0
- package/stdlib/core/collection.eli +134 -0
- package/stdlib/core/data-text.eli +16 -0
- package/stdlib/core/data.eli +306 -0
- package/stdlib/core/identifier.eli +32 -0
- package/stdlib/core/lazy-sequence.eli +63 -0
- package/stdlib/core/metadata.eli +20 -0
- package/stdlib/core/object.eli +89 -0
- package/stdlib/core/order.eli +133 -0
- package/stdlib/core/protocol.eli +387 -0
- package/stdlib/core/record.eli +16 -0
- package/stdlib/core/regex.eli +17 -0
- package/stdlib/core/seq.eli +701 -0
- package/stdlib/core/set.eli +312 -0
- package/stdlib/core/sorted.eli +53 -0
- package/stdlib/core/text.eli +103 -0
- package/stdlib/core/transducer.eli +59 -0
- package/stdlib/core/transient.eli +24 -0
- package/stdlib/core/type.eli +19 -0
- package/stdlib/core/walk.eli +195 -0
- package/stdlib/core/zipper.eli +508 -0
- package/stdlib/data-text.eli +1092 -0
- package/stdlib/data.eli +42 -0
- package/stdlib/deferred.eli +70 -0
- package/stdlib/function.eli +120 -0
- package/stdlib/hierarchy.eli +245 -0
- package/stdlib/identifier.eli +147 -0
- package/stdlib/interop/js.eli +616 -0
- package/stdlib/json.eli +870 -0
- package/stdlib/metadata.eli +56 -0
- package/stdlib/multimethod.eli +464 -0
- package/stdlib/numeric.eli +193 -0
- package/stdlib/object.eli +96 -0
- package/stdlib/persistent-list.eli +145 -0
- package/stdlib/persistent-map.eli +724 -0
- package/stdlib/persistent-queue.eli +32 -0
- package/stdlib/persistent-set.eli +236 -0
- package/stdlib/persistent-vector.eli +342 -0
- package/stdlib/result.eli +141 -0
- package/stdlib/sequence.eli +106 -0
- package/stdlib/state/atom.eli +265 -0
- package/stdlib/text.eli +88 -0
- package/stdlib/value.eli +325 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { readFile, realpath, stat } from "node:fs/promises";
|
|
4
|
+
import { dirname, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
diagnosticFromError,
|
|
9
|
+
loadCompiler,
|
|
10
|
+
renderDiagnostic,
|
|
11
|
+
requestedDiagnosticFormat,
|
|
12
|
+
} from "./bun.mjs";
|
|
13
|
+
import { executeBuild } from "./build.mjs";
|
|
14
|
+
|
|
15
|
+
const usage = `Usage: eliscript-build [OPTIONS] [ENTRY ...]
|
|
16
|
+
|
|
17
|
+
Options:
|
|
18
|
+
--out-dir DIR Write the generated module tree to DIR
|
|
19
|
+
--config FILE Read a versioned project request from FILE
|
|
20
|
+
--root DIR Contain local source imports below DIR
|
|
21
|
+
--portable NAME Emit NAME and its transitive portable closure
|
|
22
|
+
--stdin-file FILE Use standard input as the current contents of FILE
|
|
23
|
+
--no-cache Disable cache reads for this build
|
|
24
|
+
--json Print the versioned build decision report
|
|
25
|
+
--diagnostic-format human|json
|
|
26
|
+
Select human-readable or JSON failures
|
|
27
|
+
-h, --help Show this help
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
function configurationError(message, filename) {
|
|
31
|
+
const error = new Error(message);
|
|
32
|
+
error.eliscriptDiagnostic = {
|
|
33
|
+
format: "eliscript-diagnostic",
|
|
34
|
+
version: 1,
|
|
35
|
+
code: "ELI-B0002",
|
|
36
|
+
severity: "error",
|
|
37
|
+
phase: "project-config",
|
|
38
|
+
message,
|
|
39
|
+
...(filename ? { location: { file: filename } } : {}),
|
|
40
|
+
};
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function skipWhitespace(source, start) {
|
|
45
|
+
let index = start;
|
|
46
|
+
while (index < source.length && /[\t\n\r ]/u.test(source[index])) index += 1;
|
|
47
|
+
return index;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function scanString(source, start) {
|
|
51
|
+
let index = start + 1;
|
|
52
|
+
while (index < source.length) {
|
|
53
|
+
if (source[index] === "\\") {
|
|
54
|
+
index += 2;
|
|
55
|
+
} else if (source[index] === '"') {
|
|
56
|
+
return index + 1;
|
|
57
|
+
} else {
|
|
58
|
+
index += 1;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return source.length;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function scanValue(source, start) {
|
|
65
|
+
const index = skipWhitespace(source, start);
|
|
66
|
+
if (source[index] === "{") return scanObject(source, index);
|
|
67
|
+
if (source[index] === "[") return scanArray(source, index);
|
|
68
|
+
if (source[index] === '"') return scanString(source, index);
|
|
69
|
+
let end = index;
|
|
70
|
+
while (end < source.length && !/[\s,\]}]/u.test(source[end])) end += 1;
|
|
71
|
+
return end;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function scanObject(source, start) {
|
|
75
|
+
const keys = new Set();
|
|
76
|
+
let index = skipWhitespace(source, start + 1);
|
|
77
|
+
if (source[index] === "}") return index + 1;
|
|
78
|
+
while (index < source.length) {
|
|
79
|
+
const keyEnd = scanString(source, index);
|
|
80
|
+
const key = JSON.parse(source.slice(index, keyEnd));
|
|
81
|
+
if (keys.has(key)) configurationError(`duplicate configuration key: ${key}`);
|
|
82
|
+
keys.add(key);
|
|
83
|
+
index = skipWhitespace(source, keyEnd);
|
|
84
|
+
index = scanValue(source, skipWhitespace(source, index + 1));
|
|
85
|
+
index = skipWhitespace(source, index);
|
|
86
|
+
if (source[index] === "}") return index + 1;
|
|
87
|
+
index = skipWhitespace(source, index + 1);
|
|
88
|
+
}
|
|
89
|
+
return index;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function scanArray(source, start) {
|
|
93
|
+
let index = skipWhitespace(source, start + 1);
|
|
94
|
+
if (source[index] === "]") return index + 1;
|
|
95
|
+
while (index < source.length) {
|
|
96
|
+
index = scanValue(source, index);
|
|
97
|
+
index = skipWhitespace(source, index);
|
|
98
|
+
if (source[index] === "]") return index + 1;
|
|
99
|
+
index = skipWhitespace(source, index + 1);
|
|
100
|
+
}
|
|
101
|
+
return index;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function parseConfigurationJson(source, filename) {
|
|
105
|
+
let value;
|
|
106
|
+
try {
|
|
107
|
+
value = JSON.parse(source);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
configurationError(`invalid JSON: ${error.message}`, filename);
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
scanValue(source, 0);
|
|
113
|
+
} catch (error) {
|
|
114
|
+
if (error?.eliscriptDiagnostic) {
|
|
115
|
+
if (filename) error.eliscriptDiagnostic.location = { file: filename };
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
return value;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function parseArguments(arguments_) {
|
|
124
|
+
const argumentsList = [...arguments_];
|
|
125
|
+
if (argumentsList[0] === "--") argumentsList.shift();
|
|
126
|
+
const portableEntries = [];
|
|
127
|
+
const entries = [];
|
|
128
|
+
let outDir;
|
|
129
|
+
let root;
|
|
130
|
+
let configuration;
|
|
131
|
+
let stdinFile;
|
|
132
|
+
let useCache = true;
|
|
133
|
+
let jsonReport = false;
|
|
134
|
+
let diagnosticFormat = "human";
|
|
135
|
+
|
|
136
|
+
while (argumentsList.length > 0) {
|
|
137
|
+
const argument = argumentsList.shift();
|
|
138
|
+
if (argument === "-h" || argument === "--help") return { help: true };
|
|
139
|
+
if (argument === "--out-dir") {
|
|
140
|
+
if (argumentsList.length === 0) throw new Error(`${argument} requires a directory`);
|
|
141
|
+
outDir = argumentsList.shift();
|
|
142
|
+
} else if (argument === "--config") {
|
|
143
|
+
if (argumentsList.length === 0) throw new Error(`${argument} requires a file`);
|
|
144
|
+
if (configuration !== undefined) {
|
|
145
|
+
throw new Error("multiple --config files are not supported");
|
|
146
|
+
}
|
|
147
|
+
configuration = argumentsList.shift();
|
|
148
|
+
} else if (argument === "--root") {
|
|
149
|
+
if (argumentsList.length === 0) throw new Error(`${argument} requires a directory`);
|
|
150
|
+
root = argumentsList.shift();
|
|
151
|
+
} else if (argument === "--portable") {
|
|
152
|
+
if (argumentsList.length === 0) throw new Error(`${argument} requires an entry name`);
|
|
153
|
+
portableEntries.push(argumentsList.shift());
|
|
154
|
+
} else if (argument === "--stdin-file") {
|
|
155
|
+
if (argumentsList.length === 0) throw new Error(`${argument} requires a file`);
|
|
156
|
+
if (stdinFile !== undefined) {
|
|
157
|
+
throw new Error("multiple --stdin-file values are not supported");
|
|
158
|
+
}
|
|
159
|
+
stdinFile = argumentsList.shift();
|
|
160
|
+
} else if (argument === "--no-cache") {
|
|
161
|
+
useCache = false;
|
|
162
|
+
} else if (argument === "--json") {
|
|
163
|
+
jsonReport = true;
|
|
164
|
+
} else if (argument === "--diagnostic-format") {
|
|
165
|
+
if (argumentsList.length === 0) {
|
|
166
|
+
throw new Error(`${argument} requires human or json`);
|
|
167
|
+
}
|
|
168
|
+
diagnosticFormat = argumentsList.shift();
|
|
169
|
+
if (diagnosticFormat !== "human" && diagnosticFormat !== "json") {
|
|
170
|
+
throw new Error(`unsupported diagnostic format: ${diagnosticFormat}`);
|
|
171
|
+
}
|
|
172
|
+
} else if (argument.startsWith("-")) {
|
|
173
|
+
throw new Error(`unknown option: ${argument}`);
|
|
174
|
+
} else {
|
|
175
|
+
entries.push(argument);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (configuration === undefined) {
|
|
180
|
+
if (entries.length === 0) throw new Error("missing entry file");
|
|
181
|
+
if (outDir === undefined) throw new Error("missing --out-dir");
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
entry: entries.length === 1 ? entries[0] : undefined,
|
|
185
|
+
entries: entries.length > 1 ? entries : undefined,
|
|
186
|
+
outDir,
|
|
187
|
+
root,
|
|
188
|
+
portableEntries,
|
|
189
|
+
useCache,
|
|
190
|
+
jsonReport,
|
|
191
|
+
diagnosticFormat,
|
|
192
|
+
configuration,
|
|
193
|
+
stdinFile,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export async function readProjectConfiguration(filename, compiler) {
|
|
198
|
+
const expanded = resolve(filename);
|
|
199
|
+
let canonical;
|
|
200
|
+
try {
|
|
201
|
+
if (!(await stat(expanded)).isFile()) throw new Error("not a file");
|
|
202
|
+
canonical = await realpath(expanded);
|
|
203
|
+
} catch {
|
|
204
|
+
configurationError("configuration file does not exist", expanded);
|
|
205
|
+
}
|
|
206
|
+
const source = await readFile(canonical, "utf8");
|
|
207
|
+
const parsed = parseConfigurationJson(source, canonical);
|
|
208
|
+
const configuration = compiler.project_configuration(parsed, canonical);
|
|
209
|
+
const directory = dirname(canonical);
|
|
210
|
+
const root = resolve(directory, configuration.sourceRoot);
|
|
211
|
+
return {
|
|
212
|
+
...(configuration.version === 2
|
|
213
|
+
? { entries: configuration.entries.map((entry) => resolve(root, entry)) }
|
|
214
|
+
: { entry: resolve(root, configuration.entry) }),
|
|
215
|
+
outDir: resolve(directory, configuration.outDir),
|
|
216
|
+
root,
|
|
217
|
+
portableEntries: [...configuration.portableEntries],
|
|
218
|
+
macroCapabilities: [...configuration.macroCapabilities],
|
|
219
|
+
macroFileDependencies: [...configuration.macroFileDependencies],
|
|
220
|
+
useCache: configuration.cache,
|
|
221
|
+
configuration: canonical,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export async function execute(arguments_, options = {}) {
|
|
226
|
+
const parsed = parseArguments(arguments_);
|
|
227
|
+
if (parsed.help) return { help: true };
|
|
228
|
+
let request;
|
|
229
|
+
if (parsed.configuration !== undefined) {
|
|
230
|
+
const compiler = await loadCompiler(options.moduleDirectory);
|
|
231
|
+
request = await readProjectConfiguration(parsed.configuration, compiler);
|
|
232
|
+
if (parsed.entries !== undefined) {
|
|
233
|
+
request.entries = parsed.entries;
|
|
234
|
+
delete request.entry;
|
|
235
|
+
} else if (parsed.entry !== undefined) {
|
|
236
|
+
request.entry = parsed.entry;
|
|
237
|
+
delete request.entries;
|
|
238
|
+
}
|
|
239
|
+
if (parsed.outDir !== undefined) request.outDir = parsed.outDir;
|
|
240
|
+
if (parsed.root !== undefined) request.root = parsed.root;
|
|
241
|
+
if (parsed.portableEntries.length > 0) {
|
|
242
|
+
request.portableEntries = parsed.portableEntries;
|
|
243
|
+
}
|
|
244
|
+
if (!parsed.useCache) request.useCache = false;
|
|
245
|
+
} else {
|
|
246
|
+
request = {
|
|
247
|
+
entry: parsed.entry,
|
|
248
|
+
entries: parsed.entries,
|
|
249
|
+
outDir: parsed.outDir,
|
|
250
|
+
root: parsed.root,
|
|
251
|
+
portableEntries: parsed.portableEntries,
|
|
252
|
+
macroCapabilities: [],
|
|
253
|
+
macroFileDependencies: [],
|
|
254
|
+
useCache: parsed.useCache,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
let sourceOverrides;
|
|
258
|
+
if (parsed.stdinFile !== undefined) {
|
|
259
|
+
const sourceText = options.stdinSource ?? await readFile(0, "utf8");
|
|
260
|
+
sourceOverrides = { [resolve(parsed.stdinFile)]: sourceText };
|
|
261
|
+
}
|
|
262
|
+
const result = await executeBuild({
|
|
263
|
+
mode: "project",
|
|
264
|
+
...request,
|
|
265
|
+
sourceOverrides,
|
|
266
|
+
moduleDirectory: options.moduleDirectory,
|
|
267
|
+
});
|
|
268
|
+
return { result, jsonReport: parsed.jsonReport };
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export async function main(arguments_ = process.argv.slice(2)) {
|
|
272
|
+
const execution = await execute(arguments_);
|
|
273
|
+
if (execution.help) {
|
|
274
|
+
process.stdout.write(usage);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
process.stdout.write(execution.jsonReport
|
|
278
|
+
? `${JSON.stringify(execution.result.report)}\n`
|
|
279
|
+
: `${execution.result.entryOutputs.join("\n")}\n`);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const isMain = process.argv[1] !== undefined &&
|
|
283
|
+
resolve(process.argv[1]) === fileURLToPath(import.meta.url);
|
|
284
|
+
if (isMain) {
|
|
285
|
+
const outputFormat = requestedDiagnosticFormat(process.argv.slice(2));
|
|
286
|
+
main().catch((error) => {
|
|
287
|
+
const diagnostic = diagnosticFromError(error);
|
|
288
|
+
if (outputFormat === "json") {
|
|
289
|
+
console.error(JSON.stringify(diagnostic));
|
|
290
|
+
} else {
|
|
291
|
+
console.error(`eliscript-build: ${renderDiagnostic(diagnostic)}`);
|
|
292
|
+
}
|
|
293
|
+
process.exitCode = 1;
|
|
294
|
+
});
|
|
295
|
+
}
|