@shapeshift-labs/frontier-lang-cli 0.3.15 → 0.3.16

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
@@ -7,6 +7,7 @@ frontier-lang check app.frontier --strict-effects
7
7
  frontier-lang emit app.frontier --target rust --out generated.rs
8
8
  frontier-lang capabilities app.frontier --target typescript --platform node
9
9
  frontier-lang import src/todo.ts --sidecar --out native-import.json
10
+ frontier-lang native-diff src/todo.before.ts --after src/todo.after.ts --out native-change-set.json
10
11
  frontier-lang project-native native-import.json --source-only --out restored.ts
11
12
  frontier-lang native-coverage src/todo.ts
12
13
  ```
@@ -193,7 +194,7 @@ npm install -g @shapeshift-labs/frontier-lang-cli
193
194
  frontier-lang check examples/todo.frontier
194
195
  ```
195
196
 
196
- Commands: `parse`, `check`, `hash`, `ast`, `capabilities`, `to-json`, `from-json`, `import`, `project-native`, `native-coverage`, `roundtrip`, `corpus-roundtrip`, `emit`, `emit-ts`, `emit-js`, `emit-rust`, `emit-python`, and `emit-c`.
197
+ Commands: `parse`, `check`, `hash`, `ast`, `capabilities`, `to-json`, `from-json`, `import`, `project-native`, `native-coverage`, `native-diff`, `roundtrip`, `corpus-roundtrip`, `emit`, `emit-ts`, `emit-js`, `emit-rust`, `emit-python`, and `emit-c`.
197
198
 
198
199
  ```sh
199
200
  frontier-lang emit app.frontier --target rust --out app.rs
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ import {
11
11
  createNativeImportCoverageMatrix,
12
12
  createSemanticImportSidecar,
13
13
  createUniversalAstFromDocument,
14
+ diffNativeSources,
14
15
  importNativeSource,
15
16
  projectNativeImportToSource,
16
17
  projectFrontierAst,
@@ -58,6 +59,27 @@ export async function runCli(argv = process.argv.slice(2), io = console) {
58
59
  const imported = importNativeFile(file, source, rest, { language });
59
60
  return outputMaybeFile(io, rest, createNativeImportCoverageMatrix({ imports: [imported] }));
60
61
  }
62
+ if (command === 'native-diff') {
63
+ const afterPath = readOption(rest, '--after');
64
+ if (!afterPath) throw new Error('native-diff requires --after <file>');
65
+ const afterSource = readFileSync(afterPath, 'utf8');
66
+ const language = readOption(rest, '--language') ?? inferLanguage(afterPath) ?? inferLanguage(file);
67
+ return outputMaybeFile(io, rest, diffNativeSources({
68
+ id: readOption(rest, '--id'),
69
+ language,
70
+ parser: readOption(rest, '--parser'),
71
+ sourcePath: readOption(rest, '--source-path') ?? afterPath,
72
+ beforeSourceText: source,
73
+ afterSourceText: afterSource,
74
+ beforeSourceHash: readOption(rest, '--before-source-hash'),
75
+ afterSourceHash: readOption(rest, '--after-source-hash'),
76
+ regionPrefix: readOption(rest, '--region-prefix'),
77
+ evidenceId: readOption(rest, '--evidence-id'),
78
+ patchId: readOption(rest, '--patch-id'),
79
+ mergeCandidateId: readOption(rest, '--merge-candidate-id'),
80
+ metadata: { cli: true, beforePath: file, afterPath }
81
+ }));
82
+ }
61
83
  const document = file ? parseFrontierFile(file, source) : parseFrontierSource(source);
62
84
  if (command === 'to-json') {
63
85
  return io.log(writeUniversalAstJson(createUniversalAstFromDocument(document, {
@@ -319,7 +341,7 @@ function idFragment(value) {
319
341
  return String(value ?? 'unknown').replace(/[^A-Za-z0-9]+/g, '_').replace(/^_+|_+$/g, '').toLowerCase() || 'unknown';
320
342
  }
321
343
 
322
- function help(io) { io.log('frontier-lang <parse|check|hash|ast|capabilities|to-json|from-json|import|project-native|native-coverage|roundtrip|corpus-roundtrip|emit|emit-ts|emit-js|emit-rust|emit-python|emit-c> <file> [--target target] [--language language] [--parser parser] [--platform platform] [--ast] [--sidecar] [--sidecar-only] [--source-only] [--stubs] [--out file] [--strict-effects]'); }
344
+ function help(io) { io.log('frontier-lang <parse|check|hash|ast|capabilities|to-json|from-json|import|project-native|native-coverage|native-diff|roundtrip|corpus-roundtrip|emit|emit-ts|emit-js|emit-rust|emit-python|emit-c> <file> [--after file] [--target target] [--language language] [--parser parser] [--platform platform] [--ast] [--sidecar] [--sidecar-only] [--source-only] [--stubs] [--out file] [--strict-effects]'); }
323
345
  function readOption(args, flag) { const index = args.indexOf(flag); return index >= 0 ? args[index + 1] : undefined; }
324
346
  function readIntegerOption(args, flag) {
325
347
  const value = readOption(args, flag);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshift-labs/frontier-lang-cli",
3
- "version": "0.3.15",
3
+ "version": "0.3.16",
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",
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@shapeshift-labs/frontier-lang-checker": "0.3.4",
57
- "@shapeshift-labs/frontier-lang-compiler": "0.2.16",
57
+ "@shapeshift-labs/frontier-lang-compiler": "0.2.18",
58
58
  "@shapeshift-labs/frontier-lang-kernel": "0.3.4",
59
59
  "@shapeshift-labs/frontier-lang-parser": "0.3.4"
60
60
  },