lawspec 0.20.1 → 0.22.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +361 -2
  2. package/README.md +3 -3
  3. package/beam-coverage.mjs +160 -0
  4. package/beam-doctor.mjs +306 -0
  5. package/bin/lawspec.mjs +306 -38
  6. package/build.json +492 -106
  7. package/compatibility.json +17 -0
  8. package/core.wasm +0 -0
  9. package/core_jsffi.js +2 -2
  10. package/doctor.mjs +7 -1
  11. package/examples/native-payments/elixir/lawspec.json +149 -0
  12. package/examples/native-payments/elixir/lib/payments_domain.ex +54 -0
  13. package/examples/native-payments/elixir/test/support/payment_generators.ex +9 -0
  14. package/examples/native-payments/erlang/include/payments_domain.hrl +2 -0
  15. package/examples/native-payments/erlang/lawspec.json +148 -0
  16. package/examples/native-payments/erlang/src/payments_domain.erl +21 -0
  17. package/examples/native-payments/erlang/test/payment_generators.erl +10 -0
  18. package/examples/native-payments/gleam/lawspec.json +149 -0
  19. package/examples/native-payments/gleam/prepare.mjs +48 -0
  20. package/examples/native-payments/gleam/src/payments_domain.gleam +32 -0
  21. package/examples/native-payments/gleam/test/payment_generators.gleam +13 -0
  22. package/examples/specs/abilities.lawspec +103 -0
  23. package/examples/specs/ability_imports.lawspec +107 -0
  24. package/examples/specs/builtins.lawspec +121 -0
  25. package/examples/specs/crypto.lawspec +51 -0
  26. package/examples/specs/distribution.lawspec +29 -0
  27. package/examples/specs/failures.lawspec +96 -0
  28. package/examples/specs/handler_bindings.lawspec +65 -0
  29. package/examples/specs/harness.lawspec +75 -0
  30. package/examples/specs/harness_testing.lawspec +45 -0
  31. package/examples/specs/matchers.lawspec +112 -0
  32. package/examples/specs/resources.lawspec +116 -0
  33. package/examples/specs/scheduling_order.lawspec +18 -0
  34. package/examples/specs/scheduling_overlap.lawspec +14 -0
  35. package/examples/specs/tables.lawspec +64 -0
  36. package/failure-database.mjs +46 -0
  37. package/index.d.ts +12 -1
  38. package/native-examples.mjs +7 -2
  39. package/package.json +1 -1
  40. package/templates.mjs +105 -16
  41. package/test-command.mjs +316 -35
@@ -91,6 +91,23 @@
91
91
  "2.3.22"
92
92
  ]
93
93
  },
94
+ "erlang": {
95
+ "otp": ["29", "30"],
96
+ "rebar3": ["3.27.1", "3.28"],
97
+ "proper": ["1.5.0", "1.5.1"]
98
+ },
99
+ "elixir": {
100
+ "otp": ["29", "30"],
101
+ "elixir": ["1.20", "1.21"],
102
+ "stream_data": ["1.4.0", "1.4.1"]
103
+ },
104
+ "gleam": {
105
+ "otp": ["29", "30"],
106
+ "gleam": ["1.18", "1.20"],
107
+ "gleam_stdlib": ["1.0.5", "1.0.6"],
108
+ "gleeunit": ["1.11.0", "1.11.1"],
109
+ "qcheck": ["1.0.5", "1.0.6"]
110
+ },
94
111
  "rust": {
95
112
  "rust": [
96
113
  "1.85",
package/core.wasm CHANGED
Binary file
package/core_jsffi.js CHANGED
@@ -98,8 +98,8 @@ ZC20ZCghczminternalZCGHCziInternalziWasmziPrimziExportsZC: ($1) => {$1.throwTo =
98
98
  ZC21ZCghczminternalZCGHCziInternalziWasmziPrimziExportsZC: ($1,$2) => {$1.throwTo = (err) => __exports.rts_promiseThrowTo($2, err);},
99
99
  ZC22ZCghczminternalZCGHCziInternalziWasmziPrimziExportsZC: () => {let res, rej; const p = new Promise((resolve, reject) => { res = resolve; rej = reject; }); p.resolve = res; p.reject = rej; return p;},
100
100
  ZC0ZCghczminternalZCGHCziInternalziWasmziPrimziTypesZC: ($1) => (`${$1.stack ? $1.stack : $1}`),
101
- ZC1ZCghczminternalZCGHCziInternalziWasmziPrimziTypesZC: ($1,$2) => ((new TextDecoder('utf-8', {fatal: true})).decode(new Uint8Array(__exports.memory.buffer, $1, $2))),
102
- ZC2ZCghczminternalZCGHCziInternalziWasmziPrimziTypesZC: ($1,$2,$3) => ((new TextEncoder()).encodeInto($1, new Uint8Array(__exports.memory.buffer, $2, $3)).written),
101
+ ZC1ZCghczminternalZCGHCziInternalziWasmziPrimziTypesZC: ($1,$2) => ((new TextDecoder('utf-8', {fatal: true})).decode(new Uint8Array(__exports.memory.buffer, $1 >>> 0, $2))),
102
+ ZC2ZCghczminternalZCGHCziInternalziWasmziPrimziTypesZC: ($1,$2,$3) => ((new TextEncoder()).encodeInto($1, new Uint8Array(__exports.memory.buffer, $2 >>> 0, $3)).written),
103
103
  ZC3ZCghczminternalZCGHCziInternalziWasmziPrimziTypesZC: ($1) => ($1.length),
104
104
  ZC4ZCghczminternalZCGHCziInternalziWasmziPrimziTypesZC: ($1) => {try { __ghc_wasm_jsffi_finalization_registry.unregister($1); } catch {}},
105
105
  ZC18ZCghczminternalZCGHCziInternalziWasmziPrimziImportsZC: ($1,$2) => ($1.then(() => __exports.rts_promiseResolveUnit($2), err => __exports.rts_promiseReject($2, err))),
package/doctor.mjs CHANGED
@@ -14,6 +14,7 @@ import path from "node:path";
14
14
  import os from "node:os";
15
15
  import { fileURLToPath } from "node:url";
16
16
  import { setup } from "./templates.mjs";
17
+ import { beamDoctor } from "./beam-doctor.mjs";
17
18
  const exec = promisify(execFile);
18
19
  const profiles = JSON.parse(
19
20
  await readFile(new URL("./compatibility.json", import.meta.url), "utf8"),
@@ -81,6 +82,7 @@ export async function doctor(target, root, plannedArtifacts = []) {
81
82
  try {
82
83
  requireThat(major(process.versions.node) >= 22, "Node 22+ is required");
83
84
  const versions = {};
85
+ let coverage;
84
86
  if (["javascript", "typescript"].includes(name)) {
85
87
  const pkg = JSON.parse(
86
88
  await readFile(path.join(root, "package.json"), "utf8"),
@@ -461,13 +463,17 @@ export async function doctor(target, root, plannedArtifacts = []) {
461
463
  } finally {
462
464
  await rm(tmp, { recursive: true, force: true });
463
465
  }
466
+ } else if (["erlang", "elixir", "gleam"].includes(name)) {
467
+ const beam = await beamDoctor(target, root, plannedArtifacts, run);
468
+ Object.assign(versions, beam.versions);
469
+ coverage = beam.coverage;
464
470
  } else throw new Error(`Unsupported target ${name}`);
465
471
  for (const dependency of Object.keys(profiles[name] || {}))
466
472
  requireThat(
467
473
  supported(name, dependency, versions[dependency]),
468
474
  `${dependency} ${versions[dependency] || "(unknown)"} is outside the verified ${name} profile [${profiles[name][dependency].join(", ")})`,
469
475
  );
470
- return { target: name, ok: true, versions };
476
+ return { target: name, ok: true, versions, ...(coverage ? {coverage} : {}) };
471
477
  } catch (error) {
472
478
  return {
473
479
  target: name,
@@ -0,0 +1,149 @@
1
+ {
2
+ "version": 1,
3
+ "sources": [
4
+ "laws"
5
+ ],
6
+ "machineBits": 64,
7
+ "targets": [
8
+ {
9
+ "language": "elixir",
10
+ "root": ".",
11
+ "nativeBindings": {
12
+ "types": [
13
+ {
14
+ "type": "example.payments::type::Currency",
15
+ "native": [
16
+ "PaymentsDomain",
17
+ "CurrencyCode"
18
+ ],
19
+ "constructors": [
20
+ {
21
+ "constructor": "USD",
22
+ "native": [
23
+ "PaymentsDomain",
24
+ "Dollars"
25
+ ],
26
+ "style": "unit",
27
+ "fields": []
28
+ },
29
+ {
30
+ "constructor": "EUR",
31
+ "native": [
32
+ "PaymentsDomain",
33
+ "Euros"
34
+ ],
35
+ "style": "unit",
36
+ "fields": []
37
+ },
38
+ {
39
+ "constructor": "GBP",
40
+ "native": [
41
+ "PaymentsDomain",
42
+ "Pounds"
43
+ ],
44
+ "style": "unit",
45
+ "fields": []
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "type": "example.payments::type::Money",
51
+ "native": [
52
+ "PaymentsDomain",
53
+ "Price"
54
+ ],
55
+ "constructors": [
56
+ {
57
+ "constructor": "Money",
58
+ "native": [
59
+ "PaymentsDomain",
60
+ "Price"
61
+ ],
62
+ "style": "record",
63
+ "fields": [
64
+ {
65
+ "field": "amount",
66
+ "native": "major"
67
+ },
68
+ {
69
+ "field": "currency",
70
+ "native": "unit"
71
+ }
72
+ ]
73
+ }
74
+ ]
75
+ },
76
+ {
77
+ "type": "example.payments::type::Payment",
78
+ "native": [
79
+ "PaymentsDomain",
80
+ "PaymentStatus"
81
+ ],
82
+ "constructors": [
83
+ {
84
+ "constructor": "Paid",
85
+ "native": [
86
+ "PaymentsDomain",
87
+ "Settled"
88
+ ],
89
+ "style": "variant",
90
+ "fields": [
91
+ {
92
+ "field": "value",
93
+ "native": "price"
94
+ }
95
+ ]
96
+ },
97
+ {
98
+ "constructor": "Declined",
99
+ "native": [
100
+ "PaymentsDomain",
101
+ "Rejected"
102
+ ],
103
+ "style": "variant",
104
+ "fields": [
105
+ {
106
+ "field": "reason",
107
+ "native": "explanation"
108
+ }
109
+ ]
110
+ }
111
+ ]
112
+ }
113
+ ],
114
+ "functions": [
115
+ {
116
+ "declaration": "example.payments::addFee",
117
+ "native": [
118
+ "PaymentsDomain",
119
+ "apply_fee"
120
+ ]
121
+ },
122
+ {
123
+ "declaration": "example.payments::roundTrip",
124
+ "native": [
125
+ "PaymentsDomain",
126
+ "restore"
127
+ ]
128
+ },
129
+ {
130
+ "declaration": "example.payments::archive",
131
+ "native": [
132
+ "PaymentsDomain",
133
+ "store"
134
+ ]
135
+ }
136
+ ],
137
+ "generators": [
138
+ {
139
+ "type": "example.payments::type::Money",
140
+ "factory": [
141
+ "PaymentGenerators",
142
+ "prices"
143
+ ]
144
+ }
145
+ ]
146
+ }
147
+ }
148
+ ]
149
+ }
@@ -0,0 +1,54 @@
1
+ defmodule PaymentsDomain.Dollars do
2
+ defstruct []
3
+ @type t :: %__MODULE__{}
4
+ end
5
+
6
+ defmodule PaymentsDomain.Euros do
7
+ defstruct []
8
+ @type t :: %__MODULE__{}
9
+ end
10
+
11
+ defmodule PaymentsDomain.Pounds do
12
+ defstruct []
13
+ @type t :: %__MODULE__{}
14
+ end
15
+
16
+ defmodule PaymentsDomain.CurrencyCode do
17
+ @type t :: PaymentsDomain.Dollars.t() | PaymentsDomain.Euros.t() | PaymentsDomain.Pounds.t()
18
+ end
19
+
20
+ defmodule PaymentsDomain.Price do
21
+ # Application field names and order deliberately differ from the specification.
22
+ defstruct [:unit, :major]
23
+ @type t :: %__MODULE__{unit: PaymentsDomain.CurrencyCode.t(), major: :lawspec_beam_scalar.decimal()}
24
+ end
25
+
26
+ defmodule PaymentsDomain.Settled do
27
+ defstruct [:price]
28
+ @type t :: %__MODULE__{price: PaymentsDomain.Price.t()}
29
+ end
30
+
31
+ defmodule PaymentsDomain.Rejected do
32
+ defstruct [:explanation]
33
+ @type t :: %__MODULE__{explanation: String.t()}
34
+ end
35
+
36
+ defmodule PaymentsDomain.PaymentStatus do
37
+ @type t :: PaymentsDomain.Settled.t() | PaymentsDomain.Rejected.t()
38
+ end
39
+
40
+ defmodule PaymentsDomain do
41
+ alias PaymentsDomain.{Price, PaymentStatus}
42
+
43
+ @spec apply_fee(Price.t()) :: Price.t()
44
+ def apply_fee(%Price{major: amount} = price) do
45
+ fee = :lawspec_beam_scalar.decimal(2, -1)
46
+ %{price | major: :lawspec_beam_scalar.binary("+", amount, fee, "Decimal", "Decimal")}
47
+ end
48
+
49
+ @spec restore(PaymentStatus.t()) :: PaymentStatus.t()
50
+ def restore(payment), do: payment
51
+
52
+ @spec store([:nothing | {:just, PaymentStatus.t()}]) :: [:nothing | {:just, PaymentStatus.t()}]
53
+ def store(payments), do: payments
54
+ end
@@ -0,0 +1,9 @@
1
+ defmodule PaymentGenerators do
2
+ # StreamData.map preserves the integer generator's native shrink tree.
3
+ def prices do
4
+ StreamData.map(StreamData.integer(100..200), fn cents ->
5
+ %PaymentsDomain.Price{unit: %PaymentsDomain.Euros{},
6
+ major: :lawspec_beam_scalar.decimal(cents, -2)}
7
+ end)
8
+ end
9
+ end
@@ -0,0 +1,2 @@
1
+ %% Application field order deliberately differs from the specification.
2
+ -record(price, {unit, major}).
@@ -0,0 +1,148 @@
1
+ {
2
+ "version": 1,
3
+ "sources": [
4
+ "laws"
5
+ ],
6
+ "machineBits": 64,
7
+ "targets": [
8
+ {
9
+ "language": "erlang",
10
+ "root": ".",
11
+ "nativeBindings": {
12
+ "types": [
13
+ {
14
+ "type": "example.payments::type::Currency",
15
+ "native": [
16
+ "payments_domain",
17
+ "currency_code"
18
+ ],
19
+ "constructors": [
20
+ {
21
+ "constructor": "USD",
22
+ "native": [
23
+ "dollars"
24
+ ],
25
+ "style": "unit",
26
+ "fields": []
27
+ },
28
+ {
29
+ "constructor": "EUR",
30
+ "native": [
31
+ "euros"
32
+ ],
33
+ "style": "unit",
34
+ "fields": []
35
+ },
36
+ {
37
+ "constructor": "GBP",
38
+ "native": [
39
+ "pounds"
40
+ ],
41
+ "style": "unit",
42
+ "fields": []
43
+ }
44
+ ]
45
+ },
46
+ {
47
+ "type": "example.payments::type::Money",
48
+ "native": [
49
+ "payments_domain",
50
+ "price"
51
+ ],
52
+ "constructors": [
53
+ {
54
+ "constructor": "Money",
55
+ "native": [
56
+ "price"
57
+ ],
58
+ "style": "record",
59
+ "fields": [
60
+ {
61
+ "field": "amount",
62
+ "native": "major"
63
+ },
64
+ {
65
+ "field": "currency",
66
+ "native": "unit"
67
+ }
68
+ ]
69
+ }
70
+ ]
71
+ },
72
+ {
73
+ "type": "example.payments::type::Payment",
74
+ "native": [
75
+ "payments_domain",
76
+ "payment_status"
77
+ ],
78
+ "constructors": [
79
+ {
80
+ "constructor": "Paid",
81
+ "native": [
82
+ "settled"
83
+ ],
84
+ "style": "variant",
85
+ "fields": [
86
+ {
87
+ "field": "value",
88
+ "native": "price"
89
+ }
90
+ ]
91
+ },
92
+ {
93
+ "constructor": "Declined",
94
+ "native": [
95
+ "rejected"
96
+ ],
97
+ "style": "variant",
98
+ "fields": [
99
+ {
100
+ "field": "reason",
101
+ "native": "explanation"
102
+ }
103
+ ]
104
+ }
105
+ ]
106
+ }
107
+ ],
108
+ "functions": [
109
+ {
110
+ "declaration": "example.payments::addFee",
111
+ "native": [
112
+ "payments_domain",
113
+ "apply_fee"
114
+ ]
115
+ },
116
+ {
117
+ "declaration": "example.payments::roundTrip",
118
+ "native": [
119
+ "payments_domain",
120
+ "restore"
121
+ ]
122
+ },
123
+ {
124
+ "declaration": "example.payments::archive",
125
+ "native": [
126
+ "payments_domain",
127
+ "store"
128
+ ]
129
+ }
130
+ ],
131
+ "generators": [
132
+ {
133
+ "type": "example.payments::type::Money",
134
+ "factory": [
135
+ "payment_generators",
136
+ "prices"
137
+ ]
138
+ }
139
+ ],
140
+ "erlangIncludes": [
141
+ {
142
+ "path": "payments_domain.hrl"
143
+ }
144
+ ]
145
+ }
146
+ }
147
+ ]
148
+ }
@@ -0,0 +1,21 @@
1
+ %% Application-owned payment types; no generated domain declarations.
2
+ -module(payments_domain).
3
+ -export([apply_fee/1, restore/1, store/1]).
4
+ -export_type([currency_code/0, price/0, payment_status/0]).
5
+ -include("payments_domain.hrl").
6
+
7
+ -type currency_code() :: dollars | euros | pounds.
8
+ -type price() :: #price{unit :: currency_code(), major :: lawspec_beam_scalar:decimal()}.
9
+ -type payment_status() :: {settled, price()} | {rejected, binary()}.
10
+
11
+ -spec apply_fee(price()) -> price().
12
+ apply_fee(#price{major = Amount} = Price) ->
13
+ Fee = lawspec_beam_scalar:decimal(2, -1),
14
+ Price#price{major = lawspec_beam_scalar:binary(
15
+ <<"+">>, Amount, Fee, <<"Decimal">>, <<"Decimal">>)}.
16
+
17
+ -spec restore(payment_status()) -> payment_status().
18
+ restore(Payment) -> Payment.
19
+
20
+ -spec store([nothing | {just, payment_status()}]) -> [nothing | {just, payment_status()}].
21
+ store(Payments) -> Payments.
@@ -0,0 +1,10 @@
1
+ %% PropEr's native bind retains shrinking of the integer number of cents.
2
+ -module(payment_generators).
3
+ -export([prices/0]).
4
+ -include("payments_domain.hrl").
5
+
6
+ prices() ->
7
+ proper_types:bind(proper_types:integer(100, 200), fun(Cents) ->
8
+ proper_types:exactly(#price{unit = euros,
9
+ major = lawspec_beam_scalar:decimal(Cents, -2)})
10
+ end, false).
@@ -0,0 +1,149 @@
1
+ {
2
+ "version": 1,
3
+ "sources": [
4
+ "laws"
5
+ ],
6
+ "machineBits": 64,
7
+ "targets": [
8
+ {
9
+ "language": "gleam",
10
+ "root": ".",
11
+ "nativeBindings": {
12
+ "types": [
13
+ {
14
+ "type": "example.payments::type::Currency",
15
+ "native": [
16
+ "payments_domain",
17
+ "CurrencyCode"
18
+ ],
19
+ "constructors": [
20
+ {
21
+ "constructor": "USD",
22
+ "native": [
23
+ "payments_domain",
24
+ "Dollars"
25
+ ],
26
+ "style": "unit",
27
+ "fields": []
28
+ },
29
+ {
30
+ "constructor": "EUR",
31
+ "native": [
32
+ "payments_domain",
33
+ "Euros"
34
+ ],
35
+ "style": "unit",
36
+ "fields": []
37
+ },
38
+ {
39
+ "constructor": "GBP",
40
+ "native": [
41
+ "payments_domain",
42
+ "Pounds"
43
+ ],
44
+ "style": "unit",
45
+ "fields": []
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "type": "example.payments::type::Money",
51
+ "native": [
52
+ "payments_domain",
53
+ "Price"
54
+ ],
55
+ "constructors": [
56
+ {
57
+ "constructor": "Money",
58
+ "native": [
59
+ "payments_domain",
60
+ "Price"
61
+ ],
62
+ "style": "record",
63
+ "fields": [
64
+ {
65
+ "field": "amount",
66
+ "native": "major"
67
+ },
68
+ {
69
+ "field": "currency",
70
+ "native": "unit"
71
+ }
72
+ ]
73
+ }
74
+ ]
75
+ },
76
+ {
77
+ "type": "example.payments::type::Payment",
78
+ "native": [
79
+ "payments_domain",
80
+ "PaymentStatus"
81
+ ],
82
+ "constructors": [
83
+ {
84
+ "constructor": "Paid",
85
+ "native": [
86
+ "payments_domain",
87
+ "Settled"
88
+ ],
89
+ "style": "variant",
90
+ "fields": [
91
+ {
92
+ "field": "value",
93
+ "native": "price"
94
+ }
95
+ ]
96
+ },
97
+ {
98
+ "constructor": "Declined",
99
+ "native": [
100
+ "payments_domain",
101
+ "Rejected"
102
+ ],
103
+ "style": "variant",
104
+ "fields": [
105
+ {
106
+ "field": "reason",
107
+ "native": "explanation"
108
+ }
109
+ ]
110
+ }
111
+ ]
112
+ }
113
+ ],
114
+ "functions": [
115
+ {
116
+ "declaration": "example.payments::addFee",
117
+ "native": [
118
+ "payments_domain",
119
+ "apply_fee"
120
+ ]
121
+ },
122
+ {
123
+ "declaration": "example.payments::roundTrip",
124
+ "native": [
125
+ "payments_domain",
126
+ "restore"
127
+ ]
128
+ },
129
+ {
130
+ "declaration": "example.payments::archive",
131
+ "native": [
132
+ "payments_domain",
133
+ "store"
134
+ ]
135
+ }
136
+ ],
137
+ "generators": [
138
+ {
139
+ "type": "example.payments::type::Money",
140
+ "factory": [
141
+ "payment_generators",
142
+ "prices"
143
+ ]
144
+ }
145
+ ]
146
+ }
147
+ }
148
+ ]
149
+ }
@@ -0,0 +1,48 @@
1
+ // Compile dependencies before LawSpec generates the runtime imported by the app.
2
+ import {execFile} from 'node:child_process';
3
+ import {promisify} from 'node:util';
4
+ import {cp, mkdir, mkdtemp, readFile, readdir, rm} from 'node:fs/promises';
5
+ import path from 'node:path';
6
+ import {fileURLToPath} from 'node:url';
7
+
8
+ const exec = promisify(execFile);
9
+ const root = path.dirname(fileURLToPath(import.meta.url));
10
+ await mkdir(path.join(root, '.lawspec'), {recursive: true});
11
+ const temporary = await mkdtemp(path.join(root, '.lawspec/dependencies-'));
12
+ try {
13
+ // Use the project's actual dependency requirements and lock file, with empty
14
+ // application roots. Application code remains in place throughout setup.
15
+ await mkdir(path.join(temporary, 'src'), {recursive: true});
16
+ await mkdir(path.join(temporary, 'test-support/src'), {recursive: true});
17
+ for (const file of ['gleam.toml', 'test-support/gleam.toml'])
18
+ await cp(path.join(root, file), path.join(temporary, file));
19
+ try { await cp(path.join(root, 'manifest.toml'), path.join(temporary, 'manifest.toml')); }
20
+ catch (error) { if (error.code !== 'ENOENT') throw error; }
21
+ // Reuse downloaded packages when available, including fully offline setups.
22
+ try { await cp(path.join(root, 'build/packages'), path.join(temporary, 'build/packages'), {recursive: true}); }
23
+ catch (error) { if (error.code !== 'ENOENT') throw error; }
24
+
25
+ const {stdout, stderr} = await exec('gleam', ['build'], {cwd: temporary,
26
+ timeout: 300000, maxBuffer: 8 * 1024 * 1024});
27
+ process.stdout.write(stdout);
28
+ process.stderr.write(stderr);
29
+ const information = path.join(temporary, 'package.json');
30
+ await exec('gleam', ['export', 'package-information', '--out', information], {cwd: temporary});
31
+ const application = JSON.parse(await readFile(information, 'utf8'))['gleam.toml'].name;
32
+
33
+ await mkdir(path.join(root, 'build/dev/erlang'), {recursive: true});
34
+ await cp(path.join(temporary, 'build/packages'), path.join(root, 'build/packages'), {recursive: true});
35
+ for (const entry of await readdir(path.join(temporary, 'build/dev/erlang'), {withFileTypes: true})) {
36
+ if (!entry.isDirectory() || [application, 'lawspec_test_support'].includes(entry.name)) continue;
37
+ await cp(path.join(temporary, 'build/dev/erlang', entry.name),
38
+ path.join(root, 'build/dev/erlang', entry.name), {recursive: true});
39
+ }
40
+ await cp(path.join(temporary, 'manifest.toml'), path.join(root, 'manifest.toml'));
41
+ console.log('Dependencies compiled. Run lawspec generate, then gleam test.');
42
+ } catch (error) {
43
+ process.stderr.write(error.stdout ?? '');
44
+ process.stderr.write(error.stderr ?? '');
45
+ throw error;
46
+ } finally {
47
+ await rm(temporary, {recursive: true, force: true});
48
+ }