@shapeshift-labs/frontier-lang-cli 0.3.2 → 0.3.4

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.
Files changed (2) hide show
  1. package/dist/index.js +10 -4
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -28,11 +28,12 @@ export async function runCli(argv = process.argv.slice(2), io = console) {
28
28
  }
29
29
  if (command === 'import') {
30
30
  const language = readOption(rest, '--language') ?? inferLanguage(file);
31
- return output(io, importNativeSource({
31
+ return outputMaybeFile(io, rest, importNativeSource({
32
32
  language,
33
33
  parser: readOption(rest, '--parser'),
34
34
  sourcePath: file,
35
35
  sourceHash: readOption(rest, '--source-hash'),
36
+ sourceText: source,
36
37
  nativeAstMetadata: { sourceBytes: source.length }
37
38
  }));
38
39
  }
@@ -50,7 +51,7 @@ export async function runCli(argv = process.argv.slice(2), io = console) {
50
51
  evidence: [{ id: 'frontier_lang_cli_roundtrip', kind: 'test', status: 'passed', path: file, summary: `Parsed Frontier source and emitted ${target}.` }]
51
52
  });
52
53
  const result = compileFrontierDocument(envelope.document, { target, check: { strictEffects: rest.includes('--strict-effects') } });
53
- return output(io, {
54
+ return outputMaybeFile(io, rest, {
54
55
  ok: result.ok,
55
56
  target: result.target,
56
57
  hash: result.hash,
@@ -59,8 +60,8 @@ export async function runCli(argv = process.argv.slice(2), io = console) {
59
60
  output: result.output
60
61
  });
61
62
  }
62
- if (command === 'parse') return output(io, document);
63
- if (command === 'check') return output(io, checkDocument(document, { strictEffects: rest.includes('--strict-effects') }));
63
+ if (command === 'parse') return outputMaybeFile(io, rest, document);
64
+ if (command === 'check') return outputMaybeFile(io, rest, checkDocument(document, { strictEffects: rest.includes('--strict-effects') }));
64
65
  if (command === 'hash') return io.log(hashDocumentBase(document));
65
66
  if (command === 'ast') {
66
67
  const target = readOption(rest, '--target') ?? 'typescript';
@@ -86,6 +87,11 @@ export async function runCli(argv = process.argv.slice(2), io = console) {
86
87
  throw new Error(`Unknown command: ${command}`);
87
88
  }
88
89
  function output(io, value) { io.log(JSON.stringify(value, null, 2)); }
90
+ function outputMaybeFile(io, args, value) {
91
+ const json = JSON.stringify(value, null, 2);
92
+ const outIndex = args.indexOf('--out');
93
+ if (outIndex >= 0 && args[outIndex + 1]) writeFileSync(args[outIndex + 1], json + '\n'); else io.log(json);
94
+ }
89
95
  function help(io) { io.log('frontier-lang <parse|check|hash|ast|capabilities|to-json|from-json|import|roundtrip|emit|emit-ts|emit-js|emit-rust|emit-python|emit-c> <file> [--target target] [--language language] [--parser parser] [--platform platform] [--ast] [--out file] [--strict-effects]'); }
90
96
  function readOption(args, flag) { const index = args.indexOf(flag); return index >= 0 ? args[index + 1] : undefined; }
91
97
  function inferLanguage(file) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshift-labs/frontier-lang-cli",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Command line interface for parsing, checking, hashing, and emitting Frontier Lang projects.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -53,10 +53,10 @@
53
53
  "access": "public"
54
54
  },
55
55
  "dependencies": {
56
- "@shapeshift-labs/frontier-lang-checker": "0.3.0",
57
- "@shapeshift-labs/frontier-lang-compiler": "0.2.2",
56
+ "@shapeshift-labs/frontier-lang-checker": "0.3.1",
57
+ "@shapeshift-labs/frontier-lang-compiler": "0.2.4",
58
58
  "@shapeshift-labs/frontier-lang-kernel": "0.3.1",
59
- "@shapeshift-labs/frontier-lang-parser": "0.3.0"
59
+ "@shapeshift-labs/frontier-lang-parser": "0.3.1"
60
60
  },
61
61
  "bin": {
62
62
  "frontier-lang": "dist/index.js"