lawspec 0.30.0 → 0.31.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/CHANGELOG.md +377 -1
- package/README.md +9 -3
- package/api.mjs +1 -0
- package/beam-doctor.mjs +2 -2
- package/bin/lawspec.mjs +93 -95
- package/build.json +497 -405
- package/component-packages.mjs +339 -0
- package/component.d.ts +46 -0
- package/component.mjs +208 -0
- package/core.wasm +2 -2
- package/core_jsffi.js +5 -5
- package/examples/native-payments/clojure/lawspec.edn +48 -0
- package/examples/native-payments/clojure/src/domain/payments.clj +1 -1
- package/examples/native-payments/clojure/test/domain/payment_generators.clj +1 -1
- package/examples/native-payments/csharp/lawspec.edn +48 -0
- package/examples/native-payments/elixir/lawspec.edn +123 -0
- package/examples/native-payments/erlang/lawspec.edn +128 -0
- package/examples/native-payments/fsharp/lawspec.edn +123 -0
- package/examples/native-payments/gleam/lawspec.edn +123 -0
- package/examples/native-payments/go/lawspec.edn +123 -0
- package/examples/native-payments/groovy/lawspec.edn +123 -0
- package/examples/native-payments/haskell/lawspec.edn +123 -0
- package/examples/native-payments/java/lawspec.edn +123 -0
- package/examples/native-payments/javascript/lawspec.edn +123 -0
- package/examples/native-payments/kotlin/lawspec.edn +123 -0
- package/examples/native-payments/prolog/lawspec.edn +48 -0
- package/examples/native-payments/python/lawspec.edn +123 -0
- package/examples/native-payments/rust/lawspec.edn +124 -0
- package/examples/native-payments/scala/lawspec.edn +123 -0
- package/examples/native-payments/swift/lawspec.edn +123 -0
- package/examples/native-payments/typescript/lawspec.edn +123 -0
- package/examples/packages/orders/lawspec.edn +25 -0
- package/examples/packages/shop-domain/lawspec.edn +13 -0
- package/examples/packages/shop-tax-1/lawspec.edn +9 -0
- package/examples/packages/shop-tax-2/lawspec.edn +9 -0
- package/examples/specs/handler_bindings.lawspec +2 -2
- package/files.mjs +2 -1
- package/go.mod +4 -0
- package/index.d.ts +135 -2
- package/input-files.mjs +47 -0
- package/launcher.mjs +33 -13
- package/lsp.mjs +10 -5
- package/native-evidence.mjs +50 -15
- package/native-examples.mjs +8 -7
- package/native-host.mjs +71 -0
- package/package.json +8 -3
- package/proof.d.ts +8 -2
- package/proof.mjs +183 -31
- package/scala-build-state.mjs +59 -0
- package/templates.mjs +242 -2
- package/test-command.mjs +192 -60
- package/builtin-data-names.mjs +0 -73
- package/examples/native-payments/clojure/lawspec.json +0 -62
- package/examples/native-payments/csharp/lawspec.json +0 -62
- package/examples/native-payments/elixir/lawspec.json +0 -160
- package/examples/native-payments/erlang/lawspec.json +0 -159
- package/examples/native-payments/fsharp/lawspec.json +0 -178
- package/examples/native-payments/gleam/lawspec.json +0 -160
- package/examples/native-payments/go/lawspec.json +0 -147
- package/examples/native-payments/groovy/lawspec.json +0 -176
- package/examples/native-payments/haskell/lawspec.json +0 -160
- package/examples/native-payments/java/lawspec.json +0 -176
- package/examples/native-payments/javascript/lawspec.json +0 -160
- package/examples/native-payments/kotlin/lawspec.json +0 -176
- package/examples/native-payments/prolog/lawspec.json +0 -20
- package/examples/native-payments/python/lawspec.json +0 -160
- package/examples/native-payments/rust/lawspec.json +0 -178
- package/examples/native-payments/scala/lawspec.json +0 -176
- package/examples/native-payments/swift/lawspec.json +0 -165
- package/examples/native-payments/typescript/lawspec.json +0 -160
- package/examples/packages/orders/lawspec.json +0 -27
- package/examples/packages/shop-domain/lawspec-package.json +0 -7
- package/examples/packages/shop-tax-1/lawspec-package.json +0 -5
- package/examples/packages/shop-tax-2/lawspec-package.json +0 -5
- package/explain.mjs +0 -114
- package/expression-presentation.mjs +0 -333
- package/positional-fields.mjs +0 -13
- package/typed-presentation.mjs +0 -165
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Generated from templates/npm/scala-build-state.mjs by lawspec-dev generate. Do not edit.
|
|
2
|
+
// Preserve failed compiler state before an adapter restore or another build
|
|
3
|
+
// changes it. These diagnostics are not completed native execution evidence.
|
|
4
|
+
import {mkdir,readFile,readdir,realpath,stat,writeFile} from 'node:fs/promises';
|
|
5
|
+
import {randomUUID} from 'node:crypto';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
|
|
8
|
+
export const isScalaCompilationFailure = output =>
|
|
9
|
+
/error compiling project|compilation failed|unexpected error when (?:compiling|copying)/i.test(output);
|
|
10
|
+
|
|
11
|
+
export async function captureScalaBuildFailure({root,command,args,output,phase='native'}) {
|
|
12
|
+
try {
|
|
13
|
+
root=await realpath(root);
|
|
14
|
+
if(!(await stat(root)).isDirectory())return null;
|
|
15
|
+
const directory=path.join(root,'.lawspec','scala-build-failures',randomUUID());
|
|
16
|
+
await mkdir(directory,{recursive:true});
|
|
17
|
+
const inventory=[],configurations=[],errors=[];
|
|
18
|
+
const build=path.join(root,'.scala-build');
|
|
19
|
+
async function visit(folder) {
|
|
20
|
+
const entries=await readdir(folder,{withFileTypes:true}).catch(error=>{
|
|
21
|
+
if(error.code!=='ENOENT')errors.push({path:path.relative(root,folder),code:error.code});
|
|
22
|
+
return [];
|
|
23
|
+
});
|
|
24
|
+
for(const entry of entries.sort((a,b)=>a.name.localeCompare(b.name))) {
|
|
25
|
+
const file=path.join(folder,entry.name),relative=path.relative(root,file);
|
|
26
|
+
// A symlink may point to another client's output or outside this
|
|
27
|
+
// project. Record its presence without walking through it.
|
|
28
|
+
if(entry.isSymbolicLink()){inventory.push({path:relative,kind:'symlink'});continue;}
|
|
29
|
+
if(entry.isDirectory()){await visit(file);continue;}
|
|
30
|
+
if(!entry.isFile())continue;
|
|
31
|
+
if(/\.(?:class|tasty|betasty|sig)$/.test(entry.name)) {
|
|
32
|
+
const info=await stat(file).catch(error=>{errors.push({path:relative,code:error.code});return null;});
|
|
33
|
+
if(info)inventory.push({path:relative,bytes:info.size,modified:info.mtime.toISOString()});
|
|
34
|
+
}
|
|
35
|
+
if(path.basename(folder)==='.bloop'&&entry.name.endsWith('.json')) {
|
|
36
|
+
const raw=await readFile(file,'utf8').catch(error=>{errors.push({path:relative,code:error.code});return null;});
|
|
37
|
+
if(raw!==null) {
|
|
38
|
+
await writeFile(path.join(directory,entry.name),raw);
|
|
39
|
+
try {
|
|
40
|
+
const {project}=JSON.parse(raw);
|
|
41
|
+
configurations.push({file:relative,name:project?.name,directory:project?.directory,
|
|
42
|
+
workspaceDir:project?.workspaceDir,classesDir:project?.classesDir,
|
|
43
|
+
sources:project?.sources,dependencies:project?.dependencies,classpath:project?.classpath});
|
|
44
|
+
}catch{errors.push({path:relative,code:'invalid-json'});}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
await visit(build);
|
|
50
|
+
const lines=output.replace(/\x1b\[[0-9;]*m/g,'').split('\n');
|
|
51
|
+
const first=lines.findIndex(line=>/\[error\]|error:/i.test(line));
|
|
52
|
+
const state={version:1,capturedAt:new Date().toISOString(),root,phase,
|
|
53
|
+
command,args,firstCompilerError:first<0?[]:lines.slice(Math.max(0,first-2),first+18),
|
|
54
|
+
configurations,inventory,errors};
|
|
55
|
+
await writeFile(path.join(directory,'state.json'),JSON.stringify(state,null,2)+'\n');
|
|
56
|
+
await writeFile(path.join(directory,'compiler.log'),output);
|
|
57
|
+
return directory;
|
|
58
|
+
}catch{return null;} // Capture failure must never replace the compiler result.
|
|
59
|
+
}
|
package/templates.mjs
CHANGED
|
@@ -142,6 +142,246 @@ export const targetLabels = [
|
|
|
142
142
|
]
|
|
143
143
|
];
|
|
144
144
|
|
|
145
|
+
export const presentationChecks = {
|
|
146
|
+
"java": [
|
|
147
|
+
{
|
|
148
|
+
"command": "mvn",
|
|
149
|
+
"args": [
|
|
150
|
+
"-q",
|
|
151
|
+
"test-compile"
|
|
152
|
+
],
|
|
153
|
+
"suffix": null,
|
|
154
|
+
"each": false,
|
|
155
|
+
"environment": {}
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
"python": [
|
|
159
|
+
{
|
|
160
|
+
"command": "python3",
|
|
161
|
+
"args": [
|
|
162
|
+
"-B",
|
|
163
|
+
"-c",
|
|
164
|
+
"import ast,pathlib,sys; [ast.parse(pathlib.Path(p).read_text(),filename=p) for p in sys.argv[1:]]"
|
|
165
|
+
],
|
|
166
|
+
"suffix": ".py",
|
|
167
|
+
"each": false,
|
|
168
|
+
"environment": {}
|
|
169
|
+
}
|
|
170
|
+
],
|
|
171
|
+
"javascript": [
|
|
172
|
+
{
|
|
173
|
+
"command": "node",
|
|
174
|
+
"args": [
|
|
175
|
+
"--check"
|
|
176
|
+
],
|
|
177
|
+
"suffix": ".mjs",
|
|
178
|
+
"each": true,
|
|
179
|
+
"environment": {}
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
"typescript": [
|
|
183
|
+
{
|
|
184
|
+
"command": "npm",
|
|
185
|
+
"args": [
|
|
186
|
+
"exec",
|
|
187
|
+
"--",
|
|
188
|
+
"tsc",
|
|
189
|
+
"-p",
|
|
190
|
+
"tsconfig.json"
|
|
191
|
+
],
|
|
192
|
+
"suffix": null,
|
|
193
|
+
"each": false,
|
|
194
|
+
"environment": {}
|
|
195
|
+
}
|
|
196
|
+
],
|
|
197
|
+
"go": [
|
|
198
|
+
{
|
|
199
|
+
"command": "go",
|
|
200
|
+
"args": [
|
|
201
|
+
"test",
|
|
202
|
+
"./...",
|
|
203
|
+
"-run",
|
|
204
|
+
"^$"
|
|
205
|
+
],
|
|
206
|
+
"suffix": null,
|
|
207
|
+
"each": false,
|
|
208
|
+
"environment": {}
|
|
209
|
+
}
|
|
210
|
+
],
|
|
211
|
+
"haskell": [
|
|
212
|
+
{
|
|
213
|
+
"command": "stack",
|
|
214
|
+
"args": [
|
|
215
|
+
"--no-terminal",
|
|
216
|
+
"build",
|
|
217
|
+
"--test",
|
|
218
|
+
"--no-run-tests"
|
|
219
|
+
],
|
|
220
|
+
"suffix": null,
|
|
221
|
+
"each": false,
|
|
222
|
+
"environment": {}
|
|
223
|
+
}
|
|
224
|
+
],
|
|
225
|
+
"kotlin": [
|
|
226
|
+
{
|
|
227
|
+
"command": "gradle",
|
|
228
|
+
"args": [
|
|
229
|
+
"testClasses",
|
|
230
|
+
"--console=plain"
|
|
231
|
+
],
|
|
232
|
+
"suffix": null,
|
|
233
|
+
"each": false,
|
|
234
|
+
"environment": {}
|
|
235
|
+
}
|
|
236
|
+
],
|
|
237
|
+
"rust": [
|
|
238
|
+
{
|
|
239
|
+
"command": "cargo",
|
|
240
|
+
"args": [
|
|
241
|
+
"test",
|
|
242
|
+
"--no-run"
|
|
243
|
+
],
|
|
244
|
+
"suffix": null,
|
|
245
|
+
"each": false,
|
|
246
|
+
"environment": {}
|
|
247
|
+
}
|
|
248
|
+
],
|
|
249
|
+
"erlang": [
|
|
250
|
+
{
|
|
251
|
+
"command": "rebar3",
|
|
252
|
+
"args": [
|
|
253
|
+
"as",
|
|
254
|
+
"test",
|
|
255
|
+
"compile"
|
|
256
|
+
],
|
|
257
|
+
"suffix": null,
|
|
258
|
+
"each": false,
|
|
259
|
+
"environment": {}
|
|
260
|
+
}
|
|
261
|
+
],
|
|
262
|
+
"elixir": [
|
|
263
|
+
{
|
|
264
|
+
"command": "mix",
|
|
265
|
+
"args": [
|
|
266
|
+
"compile"
|
|
267
|
+
],
|
|
268
|
+
"suffix": null,
|
|
269
|
+
"each": false,
|
|
270
|
+
"environment": {
|
|
271
|
+
"MIX_ENV": "test"
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
],
|
|
275
|
+
"gleam": [
|
|
276
|
+
{
|
|
277
|
+
"command": "gleam",
|
|
278
|
+
"args": [
|
|
279
|
+
"build"
|
|
280
|
+
],
|
|
281
|
+
"suffix": null,
|
|
282
|
+
"each": false,
|
|
283
|
+
"environment": {}
|
|
284
|
+
}
|
|
285
|
+
],
|
|
286
|
+
"fsharp": [
|
|
287
|
+
{
|
|
288
|
+
"command": "dotnet",
|
|
289
|
+
"args": [
|
|
290
|
+
"build"
|
|
291
|
+
],
|
|
292
|
+
"suffix": null,
|
|
293
|
+
"each": false,
|
|
294
|
+
"environment": {}
|
|
295
|
+
}
|
|
296
|
+
],
|
|
297
|
+
"csharp": [
|
|
298
|
+
{
|
|
299
|
+
"command": "dotnet",
|
|
300
|
+
"args": [
|
|
301
|
+
"build"
|
|
302
|
+
],
|
|
303
|
+
"suffix": null,
|
|
304
|
+
"each": false,
|
|
305
|
+
"environment": {}
|
|
306
|
+
}
|
|
307
|
+
],
|
|
308
|
+
"scala": [
|
|
309
|
+
{
|
|
310
|
+
"command": "scala",
|
|
311
|
+
"args": [
|
|
312
|
+
"compile",
|
|
313
|
+
"--test",
|
|
314
|
+
"."
|
|
315
|
+
],
|
|
316
|
+
"suffix": null,
|
|
317
|
+
"each": false,
|
|
318
|
+
"environment": {}
|
|
319
|
+
}
|
|
320
|
+
],
|
|
321
|
+
"groovy": [
|
|
322
|
+
{
|
|
323
|
+
"command": "gradle",
|
|
324
|
+
"args": [
|
|
325
|
+
"testClasses",
|
|
326
|
+
"--console=plain"
|
|
327
|
+
],
|
|
328
|
+
"suffix": null,
|
|
329
|
+
"each": false,
|
|
330
|
+
"environment": {}
|
|
331
|
+
}
|
|
332
|
+
],
|
|
333
|
+
"clojure": [
|
|
334
|
+
{
|
|
335
|
+
"command": "clojure",
|
|
336
|
+
"args": [
|
|
337
|
+
"-M",
|
|
338
|
+
"-e",
|
|
339
|
+
"(require 'lawspec.build) (lawspec.build/compile-java! true) (shutdown-agents)"
|
|
340
|
+
],
|
|
341
|
+
"suffix": null,
|
|
342
|
+
"each": false,
|
|
343
|
+
"environment": {}
|
|
344
|
+
}
|
|
345
|
+
],
|
|
346
|
+
"swift": [
|
|
347
|
+
{
|
|
348
|
+
"command": "swift",
|
|
349
|
+
"args": [
|
|
350
|
+
"build",
|
|
351
|
+
"--build-tests"
|
|
352
|
+
],
|
|
353
|
+
"suffix": null,
|
|
354
|
+
"each": false,
|
|
355
|
+
"environment": {}
|
|
356
|
+
}
|
|
357
|
+
],
|
|
358
|
+
"prolog": [
|
|
359
|
+
{
|
|
360
|
+
"command": "python3",
|
|
361
|
+
"args": [
|
|
362
|
+
"-B",
|
|
363
|
+
"-c",
|
|
364
|
+
"import ast,pathlib,sys; [ast.parse(pathlib.Path(p).read_text(),filename=p) for p in sys.argv[1:]]"
|
|
365
|
+
],
|
|
366
|
+
"suffix": ".py",
|
|
367
|
+
"each": false,
|
|
368
|
+
"environment": {}
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
"command": "swipl",
|
|
372
|
+
"args": [
|
|
373
|
+
"-q",
|
|
374
|
+
"-g",
|
|
375
|
+
"halt",
|
|
376
|
+
"-s"
|
|
377
|
+
],
|
|
378
|
+
"suffix": ".pl",
|
|
379
|
+
"each": true,
|
|
380
|
+
"environment": {}
|
|
381
|
+
}
|
|
382
|
+
]
|
|
383
|
+
};
|
|
384
|
+
|
|
145
385
|
export const commands = {
|
|
146
386
|
"java": "mvn test",
|
|
147
387
|
"python": "python -m pytest",
|
|
@@ -356,10 +596,10 @@ const scaffolds = {
|
|
|
356
596
|
},
|
|
357
597
|
"swift": {
|
|
358
598
|
"readable": {
|
|
359
|
-
"Package.swift": "// swift-tools-version: 6.2\nimport PackageDescription\n\nlet package = Package(\n
|
|
599
|
+
"Package.swift": "// swift-tools-version: 6.2\nimport PackageDescription\n\nlet package = Package(\n name: \"Example\",\n platforms: [.macOS(.v26)],\n targets: [\n .target(name: \"LawSpecRuntime\", path: \"lawspec/LawSpecRuntime\"),\n .target(\n name: \"LawSpecTesting\", dependencies: [\"LawSpecRuntime\"], path: \"lawspec/LawSpecTesting\"),\n .target(name: \"App\", dependencies: [\"LawSpecRuntime\"], path: \"src\"),\n .testTarget(\n name: \"AppTests\", dependencies: [\"App\", \"LawSpecRuntime\", \"LawSpecTesting\"], path: \"tests\"),\n ]\n)\n"
|
|
360
600
|
},
|
|
361
601
|
"compact": {
|
|
362
|
-
"Package.swift": "// swift-tools-version: 6.2\nimport PackageDescription\nlet package = Package(\n
|
|
602
|
+
"Package.swift": "// swift-tools-version: 6.2\nimport PackageDescription\nlet package = Package(\n name: \"Example\",\n platforms: [.macOS(.v26)],\n targets: [\n .target(name: \"LawSpecRuntime\", path: \"lawspec/LawSpecRuntime\"),\n .target(\n name: \"LawSpecTesting\", dependencies: [\"LawSpecRuntime\"], path: \"lawspec/LawSpecTesting\"),\n .target(name: \"App\", dependencies: [\"LawSpecRuntime\"], path: \"src\"),\n .testTarget(\n name: \"AppTests\", dependencies: [\"App\", \"LawSpecRuntime\", \"LawSpecTesting\"], path: \"tests\"),\n ]\n)\n"
|
|
363
603
|
}
|
|
364
604
|
},
|
|
365
605
|
"prolog": {
|