lawspec 0.31.0 → 0.31.3
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 +116 -1
- package/README.md +86 -4
- package/api.mjs +14 -9
- package/authoring.mjs +899 -0
- package/beam-coverage.mjs +190 -65
- package/beam-doctor.mjs +343 -124
- package/bin/lawspec.mjs +1955 -657
- package/build.json +135 -129
- package/component-packages.mjs +662 -176
- package/component.d.ts +82 -20
- package/component.mjs +317 -94
- package/core.wasm +2 -2
- package/core_jsffi.js +5 -5
- package/doctor.mjs +558 -299
- package/examples-command.mjs +44 -23
- package/failure-database.mjs +60 -17
- package/files.mjs +122 -62
- package/index.d.ts +585 -312
- package/input-files.mjs +90 -25
- package/launcher.mjs +72 -31
- package/learn/adapters.mjs +226 -0
- package/learn/app.mjs +1279 -0
- package/learn/assert.mjs +33 -0
- package/learn/assets.mjs +15 -0
- package/learn/browser-runtime.mjs +58 -0
- package/learn/bundle.mjs +118 -0
- package/learn/compile-worker.mjs +106 -0
- package/learn/compiler.mjs +230 -0
- package/learn/coverage.json +8259 -0
- package/learn/curriculum.json +2955 -0
- package/learn/fantomas-worker.mjs +25 -0
- package/learn/format-worker.mjs +148 -0
- package/learn/fsharp.mjs +83 -0
- package/learn/harness-host.mjs +22 -0
- package/learn/index.html +326 -0
- package/learn/lawspec-core.mjs +223 -0
- package/learn/lawspec-language.mjs +69 -0
- package/learn/node-test.mjs +11 -0
- package/learn/presentation.mjs +73 -0
- package/learn/runner.mjs +72 -0
- package/learn/sandbox-frame.html +34 -0
- package/learn/sandbox.mjs +91 -0
- package/learn/store.mjs +141 -0
- package/learn/story.mjs +42 -0
- package/learn/style-options.json +16 -0
- package/learn/style.css +1023 -0
- package/learn/theme.js +77 -0
- package/learn/typescript.mjs +53 -0
- package/learn/vendor/@fontsource-atkinson-hyperlegible-LICENSE.txt +93 -0
- package/learn/vendor/@fontsource-atkinson-hyperlegible-mono-LICENSE.txt +93 -0
- package/learn/vendor/@fontsource-overpass-LICENSE.txt +93 -0
- package/learn/vendor/assemblies.json +1 -0
- package/learn/vendor/editor-worker.js +30 -0
- package/learn/vendor/editor.css +1 -0
- package/learn/vendor/editor.mjs +931 -0
- package/learn/vendor/esbuild-wasm-LICENSE.txt +21 -0
- package/learn/vendor/esbuild.mjs +2683 -0
- package/learn/vendor/esbuild.wasm +0 -0
- package/learn/vendor/fable-library/Array.js +1347 -0
- package/learn/vendor/fable-library/Async.js +134 -0
- package/learn/vendor/fable-library/AsyncBuilder.js +183 -0
- package/learn/vendor/fable-library/BigInt.js +306 -0
- package/learn/vendor/fable-library/BitConverter.js +138 -0
- package/learn/vendor/fable-library/Boolean.js +22 -0
- package/learn/vendor/fable-library/CHANGELOG.md +242 -0
- package/learn/vendor/fable-library/Char.js +202 -0
- package/learn/vendor/fable-library/Choice.js +184 -0
- package/learn/vendor/fable-library/CollectionUtil.js +182 -0
- package/learn/vendor/fable-library/ConditionalWeakTable.js +21 -0
- package/learn/vendor/fable-library/Date.js +841 -0
- package/learn/vendor/fable-library/DateOffset.js +261 -0
- package/learn/vendor/fable-library/DateOnly.js +124 -0
- package/learn/vendor/fable-library/Decimal.js +238 -0
- package/learn/vendor/fable-library/Double.js +47 -0
- package/learn/vendor/fable-library/Encoding.js +185 -0
- package/learn/vendor/fable-library/Event.js +93 -0
- package/learn/vendor/fable-library/FSharp.Collections.js +45 -0
- package/learn/vendor/fable-library/FSharp.Core.CompilerServices.js +27 -0
- package/learn/vendor/fable-library/FSharp.Core.js +156 -0
- package/learn/vendor/fable-library/Global.js +29 -0
- package/learn/vendor/fable-library/Guid.js +161 -0
- package/learn/vendor/fable-library/Int32.js +135 -0
- package/learn/vendor/fable-library/List.js +1323 -0
- package/learn/vendor/fable-library/Long.js +47 -0
- package/learn/vendor/fable-library/MailboxProcessor.js +94 -0
- package/learn/vendor/fable-library/Map.js +1396 -0
- package/learn/vendor/fable-library/MapUtil.js +130 -0
- package/learn/vendor/fable-library/MutableMap.js +339 -0
- package/learn/vendor/fable-library/MutableSet.js +233 -0
- package/learn/vendor/fable-library/Native.js +14 -0
- package/learn/vendor/fable-library/Numeric.js +75 -0
- package/learn/vendor/fable-library/Observable.js +113 -0
- package/learn/vendor/fable-library/Option.js +104 -0
- package/learn/vendor/fable-library/README.md +3 -0
- package/learn/vendor/fable-library/Random.js +172 -0
- package/learn/vendor/fable-library/Range.js +45 -0
- package/learn/vendor/fable-library/Reflection.js +479 -0
- package/learn/vendor/fable-library/RegExp.js +141 -0
- package/learn/vendor/fable-library/Result.js +165 -0
- package/learn/vendor/fable-library/Seq.js +1417 -0
- package/learn/vendor/fable-library/Seq2.js +111 -0
- package/learn/vendor/fable-library/Set.js +1816 -0
- package/learn/vendor/fable-library/String.js +674 -0
- package/learn/vendor/fable-library/System.Collections.Generic.js +333 -0
- package/learn/vendor/fable-library/System.Text.js +200 -0
- package/learn/vendor/fable-library/System.js +289 -0
- package/learn/vendor/fable-library/TimeOnly.js +122 -0
- package/learn/vendor/fable-library/TimeSpan.js +180 -0
- package/learn/vendor/fable-library/Timer.js +67 -0
- package/learn/vendor/fable-library/Types.js +198 -0
- package/learn/vendor/fable-library/Unicode.13.0.0.js +4 -0
- package/learn/vendor/fable-library/Uri.js +165 -0
- package/learn/vendor/fable-library/Util.js +796 -0
- package/learn/vendor/fable-library/big.d.ts +338 -0
- package/learn/vendor/fable-library/lib/big.js +825 -0
- package/learn/vendor/fable-library/package.json +24 -0
- package/learn/vendor/fable-library/quotation.js +618 -0
- package/learn/vendor/fable.js +430 -0
- package/learn/vendor/fantomas/FSharp.Core.uawo19tl4c.wasm +0 -0
- package/learn/vendor/fantomas/Fantomas.Core.stnanlnpyw.wasm +0 -0
- package/learn/vendor/fantomas/Fantomas.FCS.lqohfu5o9y.wasm +0 -0
- package/learn/vendor/fantomas/LawSpec.Learn.Formatter.poiijdbsl9.wasm +0 -0
- package/learn/vendor/fantomas/Microsoft.CSharp.mp8lhr6rez.wasm +0 -0
- package/learn/vendor/fantomas/Microsoft.VisualBasic.0e5fchkecn.wasm +0 -0
- package/learn/vendor/fantomas/Microsoft.VisualBasic.Core.17wn27qal2.wasm +0 -0
- package/learn/vendor/fantomas/Microsoft.Win32.Primitives.9d566sle9e.wasm +0 -0
- package/learn/vendor/fantomas/Microsoft.Win32.Registry.52dy96yk8i.wasm +0 -0
- package/learn/vendor/fantomas/System.AppContext.jwujeh069z.wasm +0 -0
- package/learn/vendor/fantomas/System.Buffers.y0isk1x97h.wasm +0 -0
- package/learn/vendor/fantomas/System.Collections.Concurrent.x5koi7bzem.wasm +0 -0
- package/learn/vendor/fantomas/System.Collections.Immutable.diwg7advch.wasm +0 -0
- package/learn/vendor/fantomas/System.Collections.NonGeneric.4089xs440e.wasm +0 -0
- package/learn/vendor/fantomas/System.Collections.Specialized.hj81u7zblb.wasm +0 -0
- package/learn/vendor/fantomas/System.Collections.nvrdeoknr1.wasm +0 -0
- package/learn/vendor/fantomas/System.ComponentModel.Annotations.yatcnfjeuk.wasm +0 -0
- package/learn/vendor/fantomas/System.ComponentModel.DataAnnotations.led9l5awu3.wasm +0 -0
- package/learn/vendor/fantomas/System.ComponentModel.EventBasedAsync.hpvp6cf4de.wasm +0 -0
- package/learn/vendor/fantomas/System.ComponentModel.Primitives.v7cajwpaqo.wasm +0 -0
- package/learn/vendor/fantomas/System.ComponentModel.TypeConverter.xk1hnyt762.wasm +0 -0
- package/learn/vendor/fantomas/System.ComponentModel.rrnda1lucx.wasm +0 -0
- package/learn/vendor/fantomas/System.Configuration.bn9vghjcq8.wasm +0 -0
- package/learn/vendor/fantomas/System.Console.09ajpiafhz.wasm +0 -0
- package/learn/vendor/fantomas/System.Core.wc649o5mw9.wasm +0 -0
- package/learn/vendor/fantomas/System.Data.Common.s4cowzd9a9.wasm +0 -0
- package/learn/vendor/fantomas/System.Data.DataSetExtensions.5fm360ikxl.wasm +0 -0
- package/learn/vendor/fantomas/System.Data.fsu4j4t4jw.wasm +0 -0
- package/learn/vendor/fantomas/System.Diagnostics.Contracts.p74re5oxzn.wasm +0 -0
- package/learn/vendor/fantomas/System.Diagnostics.Debug.622sixg49n.wasm +0 -0
- package/learn/vendor/fantomas/System.Diagnostics.DiagnosticSource.2j35bc2g2b.wasm +0 -0
- package/learn/vendor/fantomas/System.Diagnostics.FileVersionInfo.7n0wdvltaa.wasm +0 -0
- package/learn/vendor/fantomas/System.Diagnostics.Process.8iffh49mew.wasm +0 -0
- package/learn/vendor/fantomas/System.Diagnostics.StackTrace.1yz88vico8.wasm +0 -0
- package/learn/vendor/fantomas/System.Diagnostics.TextWriterTraceListener.ua8iuh2vhj.wasm +0 -0
- package/learn/vendor/fantomas/System.Diagnostics.Tools.roy5445ugj.wasm +0 -0
- package/learn/vendor/fantomas/System.Diagnostics.TraceSource.6qx1ldzz7g.wasm +0 -0
- package/learn/vendor/fantomas/System.Diagnostics.Tracing.b4799zpaas.wasm +0 -0
- package/learn/vendor/fantomas/System.Drawing.8gcjjqj0pu.wasm +0 -0
- package/learn/vendor/fantomas/System.Drawing.Primitives.y2uveru2yk.wasm +0 -0
- package/learn/vendor/fantomas/System.Dynamic.Runtime.023zrvzh9x.wasm +0 -0
- package/learn/vendor/fantomas/System.Formats.Asn1.znpklkbgqv.wasm +0 -0
- package/learn/vendor/fantomas/System.Formats.Tar.5yybjepfi2.wasm +0 -0
- package/learn/vendor/fantomas/System.Globalization.Calendars.10g6hyjy3k.wasm +0 -0
- package/learn/vendor/fantomas/System.Globalization.Extensions.hrinfrismg.wasm +0 -0
- package/learn/vendor/fantomas/System.Globalization.uvs4rah8fk.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.4j645gw40d.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.Compression.2z7vdt6tfb.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.Compression.Brotli.fv80xs79j3.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.Compression.FileSystem.88jdddz3sw.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.Compression.ZipFile.jkn9avr4vo.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.FileSystem.AccessControl.yme0uhbu37.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.FileSystem.DriveInfo.qas7wf73rs.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.FileSystem.Primitives.d1jmhkzu0e.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.FileSystem.Watcher.z570derp0d.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.FileSystem.o6jtz51fup.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.IsolatedStorage.hqyeyb5ipe.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.MemoryMappedFiles.zhamjnusxd.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.Pipelines.wrmw5vws31.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.Pipes.AccessControl.qcancj8gj2.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.Pipes.zhcyguvwkr.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.UnmanagedMemoryStream.o8cpjnlard.wasm +0 -0
- package/learn/vendor/fantomas/System.Linq.AsyncEnumerable.hyc0b7okjw.wasm +0 -0
- package/learn/vendor/fantomas/System.Linq.Expressions.ldibvm0efj.wasm +0 -0
- package/learn/vendor/fantomas/System.Linq.Parallel.2buevezvch.wasm +0 -0
- package/learn/vendor/fantomas/System.Linq.Queryable.cvq43g1awj.wasm +0 -0
- package/learn/vendor/fantomas/System.Linq.lz6mvi0hm2.wasm +0 -0
- package/learn/vendor/fantomas/System.Memory.3jekerw0ga.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.Http.Json.8k237kkwec.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.Http.cityx2bvcl.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.HttpListener.s1jreclykx.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.Mail.cmlj4c0gto.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.NameResolution.q3gf18q13l.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.NetworkInformation.xaz5tjw7d0.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.Ping.a40atim1h0.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.Primitives.i88i20r8sr.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.Quic.hx06eo5xkj.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.Requests.hkjxlfe5f5.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.Security.ch34yya69o.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.ServerSentEvents.0u7o0jk3p1.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.ServicePoint.xbhxnytx4l.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.Sockets.hzgzlvkc9l.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.WebClient.84i8nwzbgu.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.WebHeaderCollection.326nl7s9g3.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.WebProxy.oq3mgkkqef.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.WebSockets.2cx1v74vg8.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.WebSockets.Client.rafzkktw8j.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.w1hpj3bo6r.wasm +0 -0
- package/learn/vendor/fantomas/System.Numerics.Vectors.oyv7biw9ux.wasm +0 -0
- package/learn/vendor/fantomas/System.Numerics.lyu36wqn19.wasm +0 -0
- package/learn/vendor/fantomas/System.ObjectModel.kxu80demuu.wasm +0 -0
- package/learn/vendor/fantomas/System.Private.CoreLib.1vy46s12u6.wasm +0 -0
- package/learn/vendor/fantomas/System.Private.DataContractSerialization.ao8k9iu77a.wasm +0 -0
- package/learn/vendor/fantomas/System.Private.Uri.itn0n2zjd0.wasm +0 -0
- package/learn/vendor/fantomas/System.Private.Xml.19nzpxrx8w.wasm +0 -0
- package/learn/vendor/fantomas/System.Private.Xml.Linq.tw5eq1hjvo.wasm +0 -0
- package/learn/vendor/fantomas/System.Reflection.DispatchProxy.7lajnj8s8c.wasm +0 -0
- package/learn/vendor/fantomas/System.Reflection.Emit.7liz9zln06.wasm +0 -0
- package/learn/vendor/fantomas/System.Reflection.Emit.ILGeneration.1ut3qgacw8.wasm +0 -0
- package/learn/vendor/fantomas/System.Reflection.Emit.Lightweight.d0gvllb1jj.wasm +0 -0
- package/learn/vendor/fantomas/System.Reflection.Extensions.zr5bhwfczd.wasm +0 -0
- package/learn/vendor/fantomas/System.Reflection.Metadata.ff6np6mz2j.wasm +0 -0
- package/learn/vendor/fantomas/System.Reflection.Primitives.igpmvwv78c.wasm +0 -0
- package/learn/vendor/fantomas/System.Reflection.TypeExtensions.qouojzlnp9.wasm +0 -0
- package/learn/vendor/fantomas/System.Reflection.mk3jyxvh13.wasm +0 -0
- package/learn/vendor/fantomas/System.Resources.Reader.41ppfyz2vc.wasm +0 -0
- package/learn/vendor/fantomas/System.Resources.ResourceManager.sfwvfmw1ea.wasm +0 -0
- package/learn/vendor/fantomas/System.Resources.Writer.3uvs9tp38z.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.CompilerServices.Unsafe.puz1xm53oc.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.CompilerServices.VisualC.9qdau315py.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.Extensions.i7gntui96b.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.Handles.00oxj4o6ov.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.InteropServices.JavaScript.9kq1vofond.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.InteropServices.RuntimeInformation.my7qeqbhfh.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.InteropServices.vqp80tnwc7.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.Intrinsics.u0samjybfo.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.Loader.n6zxw1b98a.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.Numerics.o40sjhz59x.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.Serialization.Formatters.1esvva4te3.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.Serialization.Json.4n7u09advh.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.Serialization.Primitives.xs2bo91wvk.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.Serialization.Xml.ny21jmziti.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.Serialization.qcxaur5wqs.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.odq454d6j9.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.AccessControl.8yfnzmqzaq.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Claims.8ogy0860de.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Cryptography.Algorithms.8zijp1svfw.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Cryptography.Cng.yxagtt77no.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Cryptography.Csp.uhfbvvau84.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Cryptography.Encoding.2ywrusvy8q.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Cryptography.OpenSsl.oa268u7i92.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Cryptography.Primitives.5uhvqe8puk.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Cryptography.X509Certificates.6i7pxilopt.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Cryptography.d0quqk1iyr.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Principal.Windows.gpqua4rz29.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Principal.i20kfklf3g.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.SecureString.x2y8tzci3c.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.e83vvh6sl2.wasm +0 -0
- package/learn/vendor/fantomas/System.ServiceModel.Web.poglliv2no.wasm +0 -0
- package/learn/vendor/fantomas/System.ServiceProcess.yro5uj2opo.wasm +0 -0
- package/learn/vendor/fantomas/System.Text.Encoding.CodePages.2wchx40i7z.wasm +0 -0
- package/learn/vendor/fantomas/System.Text.Encoding.Extensions.8utaw61kn5.wasm +0 -0
- package/learn/vendor/fantomas/System.Text.Encoding.cxdyfepnpj.wasm +0 -0
- package/learn/vendor/fantomas/System.Text.Encodings.Web.37ehbi7cye.wasm +0 -0
- package/learn/vendor/fantomas/System.Text.Json.ixiaa8hd3h.wasm +0 -0
- package/learn/vendor/fantomas/System.Text.RegularExpressions.2fhfmkk6vf.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.6pry74a050.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.AccessControl.76zfdfy8go.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.Channels.gpxnr01lmp.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.Overlapped.aqpl8tzdyc.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.Tasks.Dataflow.ytwttt7fzh.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.Tasks.Extensions.0deavcb00v.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.Tasks.Parallel.tjwtxugso0.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.Tasks.fu4qd5h3qy.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.Thread.klaua2by9m.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.ThreadPool.mkzm212njz.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.Timer.yp49llu5h2.wasm +0 -0
- package/learn/vendor/fantomas/System.Transactions.Local.vz6cgeh4w7.wasm +0 -0
- package/learn/vendor/fantomas/System.Transactions.ipwm3rsy66.wasm +0 -0
- package/learn/vendor/fantomas/System.ValueTuple.7ol6ljuhx8.wasm +0 -0
- package/learn/vendor/fantomas/System.Web.HttpUtility.itlvncjd96.wasm +0 -0
- package/learn/vendor/fantomas/System.Web.np8uzzakvl.wasm +0 -0
- package/learn/vendor/fantomas/System.Windows.18nzio44t3.wasm +0 -0
- package/learn/vendor/fantomas/System.Xml.45jprtg1pa.wasm +0 -0
- package/learn/vendor/fantomas/System.Xml.Linq.v9v8udncm1.wasm +0 -0
- package/learn/vendor/fantomas/System.Xml.ReaderWriter.a9mr08uzci.wasm +0 -0
- package/learn/vendor/fantomas/System.Xml.Serialization.03juoguwgc.wasm +0 -0
- package/learn/vendor/fantomas/System.Xml.XDocument.c9dhjnzqjb.wasm +0 -0
- package/learn/vendor/fantomas/System.Xml.XPath.XDocument.138b12i1pm.wasm +0 -0
- package/learn/vendor/fantomas/System.Xml.XPath.pvxm9341ce.wasm +0 -0
- package/learn/vendor/fantomas/System.Xml.XmlDocument.450wsyxvl0.wasm +0 -0
- package/learn/vendor/fantomas/System.Xml.XmlSerializer.y3t2n0tce7.wasm +0 -0
- package/learn/vendor/fantomas/System.gjriafnqmz.wasm +0 -0
- package/learn/vendor/fantomas/WindowsBase.8zsce9qxfb.wasm +0 -0
- package/learn/vendor/fantomas/cs/FSharp.Core.resources.9ehmavdel7.wasm +0 -0
- package/learn/vendor/fantomas/de/FSharp.Core.resources.2ofmxloa01.wasm +0 -0
- package/learn/vendor/fantomas/dotnet.js +1233 -0
- package/learn/vendor/fantomas/dotnet.native.b6l13xorvf.js +16 -0
- package/learn/vendor/fantomas/dotnet.native.rw4kynp763.wasm +0 -0
- package/learn/vendor/fantomas/dotnet.runtime.v06hirbjsv.js +4 -0
- package/learn/vendor/fantomas/es/FSharp.Core.resources.hkr5ggb4tr.wasm +0 -0
- package/learn/vendor/fantomas/fr/FSharp.Core.resources.43soen28ow.wasm +0 -0
- package/learn/vendor/fantomas/icudt_CJK.tjcz0u77k5.dat +0 -0
- package/learn/vendor/fantomas/icudt_EFIGS.tptq2av103.dat +0 -0
- package/learn/vendor/fantomas/icudt_no_CJK.lfu7j35m59.dat +0 -0
- package/learn/vendor/fantomas/it/FSharp.Core.resources.m60n5ls7oq.wasm +0 -0
- package/learn/vendor/fantomas/ja/FSharp.Core.resources.o6oof69v14.wasm +0 -0
- package/learn/vendor/fantomas/ko/FSharp.Core.resources.q6l4snlu9o.wasm +0 -0
- package/learn/vendor/fantomas/mscorlib.8ptuc08eli.wasm +0 -0
- package/learn/vendor/fantomas/netstandard.eymp85mooh.wasm +0 -0
- package/learn/vendor/fantomas/pl/FSharp.Core.resources.8bni0w6j8b.wasm +0 -0
- package/learn/vendor/fantomas/pt-BR/FSharp.Core.resources.k849vqm41u.wasm +0 -0
- package/learn/vendor/fantomas/ru/FSharp.Core.resources.jz9rhhtsla.wasm +0 -0
- package/learn/vendor/fantomas/tr/FSharp.Core.resources.wn6vbvjm1u.wasm +0 -0
- package/learn/vendor/fantomas/zh-Hans/FSharp.Core.resources.z7zzbso094.wasm +0 -0
- package/learn/vendor/fantomas/zh-Hant/FSharp.Core.resources.iammfsi7ls.wasm +0 -0
- package/learn/vendor/fast-check-LICENSE.txt +21 -0
- package/learn/vendor/fast-check.mjs +37 -0
- package/learn/vendor/fonts/atkinson-hyperlegible-latin-400-normal.woff2 +0 -0
- package/learn/vendor/fonts/atkinson-hyperlegible-latin-700-normal.woff2 +0 -0
- package/learn/vendor/fonts/atkinson-hyperlegible-mono-latin-400-normal.woff2 +0 -0
- package/learn/vendor/fonts/overpass-latin-600-normal.woff2 +0 -0
- package/learn/vendor/fonts/overpass-latin-700-normal.woff2 +0 -0
- package/learn/vendor/formatter-licenses/DotNet-LICENSE.txt +23 -0
- package/learn/vendor/formatter-licenses/DotNet-THIRD-PARTY-NOTICES.txt +1418 -0
- package/learn/vendor/formatter-licenses/FSharp-LICENSE.txt +23 -0
- package/learn/vendor/formatter-licenses/Fantomas-LICENSE.txt +202 -0
- package/learn/vendor/formatter-licenses/README.md +12 -0
- package/learn/vendor/manifest.json +1354 -0
- package/learn/vendor/metadata/Browser.Blob.dll +0 -0
- package/learn/vendor/metadata/Browser.Dom.dll +0 -0
- package/learn/vendor/metadata/Browser.Event.dll +0 -0
- package/learn/vendor/metadata/Browser.Gamepad.dll +0 -0
- package/learn/vendor/metadata/Browser.WebGL.dll +0 -0
- package/learn/vendor/metadata/Browser.WebStorage.dll +0 -0
- package/learn/vendor/metadata/FSharp.Core.dll +0 -0
- package/learn/vendor/metadata/Fable.Core.dll +0 -0
- package/learn/vendor/metadata/Fable.Repl.Lib.dll +0 -0
- package/learn/vendor/metadata/System.Collections.Concurrent.dll +0 -0
- package/learn/vendor/metadata/System.Collections.dll +0 -0
- package/learn/vendor/metadata/System.ComponentModel.Primitives.dll +0 -0
- package/learn/vendor/metadata/System.ComponentModel.TypeConverter.dll +0 -0
- package/learn/vendor/metadata/System.ComponentModel.dll +0 -0
- package/learn/vendor/metadata/System.Console.dll +0 -0
- package/learn/vendor/metadata/System.Core.dll +0 -0
- package/learn/vendor/metadata/System.Diagnostics.Debug.dll +0 -0
- package/learn/vendor/metadata/System.Diagnostics.Tools.dll +0 -0
- package/learn/vendor/metadata/System.Diagnostics.Tracing.dll +0 -0
- package/learn/vendor/metadata/System.Globalization.dll +0 -0
- package/learn/vendor/metadata/System.IO.dll +0 -0
- package/learn/vendor/metadata/System.Net.Requests.dll +0 -0
- package/learn/vendor/metadata/System.Net.WebClient.dll +0 -0
- package/learn/vendor/metadata/System.Numerics.dll +0 -0
- package/learn/vendor/metadata/System.Reflection.Extensions.dll +0 -0
- package/learn/vendor/metadata/System.Reflection.Metadata.dll +0 -0
- package/learn/vendor/metadata/System.Reflection.Primitives.dll +0 -0
- package/learn/vendor/metadata/System.Reflection.TypeExtensions.dll +0 -0
- package/learn/vendor/metadata/System.Reflection.dll +0 -0
- package/learn/vendor/metadata/System.Runtime.Extensions.dll +0 -0
- package/learn/vendor/metadata/System.Runtime.InteropServices.dll +0 -0
- package/learn/vendor/metadata/System.Runtime.Numerics.dll +0 -0
- package/learn/vendor/metadata/System.Runtime.dll +0 -0
- package/learn/vendor/metadata/System.Text.Encoding.Extensions.dll +0 -0
- package/learn/vendor/metadata/System.Text.Encoding.dll +0 -0
- package/learn/vendor/metadata/System.Text.RegularExpressions.dll +0 -0
- package/learn/vendor/metadata/System.Threading.Tasks.dll +0 -0
- package/learn/vendor/metadata/System.Threading.Thread.dll +0 -0
- package/learn/vendor/metadata/System.Threading.dll +0 -0
- package/learn/vendor/metadata/System.ValueTuple.dll +0 -0
- package/learn/vendor/metadata/System.dll +0 -0
- package/learn/vendor/metadata/mscorlib.dll +0 -0
- package/learn/vendor/metadata/netstandard.dll +0 -0
- package/learn/vendor/monaco-editor-LICENSE.txt +21 -0
- package/learn/vendor/prettier/babel.mjs +16 -0
- package/learn/vendor/prettier/brace-style.mjs +376 -0
- package/learn/vendor/prettier/estree.mjs +44 -0
- package/learn/vendor/prettier/standalone.mjs +29 -0
- package/learn/vendor/prettier/typescript.mjs +22 -0
- package/learn/vendor/prettier-LICENSE.txt +7 -0
- package/learn/vendor/prettier-plugin-brace-style-LICENSE.txt +21 -0
- package/learn/vendor/typescript-LICENSE.txt +55 -0
- package/learn/vendor/typescript-libs.json +1 -0
- package/learn/vendor/typescript.mjs +451 -0
- package/learn/vendor/zod-LICENSE.txt +21 -0
- package/learn/web-format.mjs +8 -0
- package/learn.mjs +126 -0
- package/lsp.mjs +444 -133
- package/mcp.mjs +250 -0
- package/native-evidence.mjs +668 -182
- package/native-examples.mjs +56 -19
- package/native-host.mjs +136 -42
- package/native-parsers/clojure.LICENSE +121 -0
- package/native-parsers/clojure.wasm +0 -0
- package/native-parsers/csharp.LICENSE +21 -0
- package/native-parsers/csharp.wasm +0 -0
- package/native-parsers/elixir.LICENSE +176 -0
- package/native-parsers/elixir.wasm +0 -0
- package/native-parsers/erlang.LICENSE +201 -0
- package/native-parsers/erlang.wasm +0 -0
- package/native-parsers/fsharp.LICENSE +21 -0
- package/native-parsers/fsharp.wasm +0 -0
- package/native-parsers/gleam.LICENSE +202 -0
- package/native-parsers/gleam.wasm +0 -0
- package/native-parsers/go.LICENSE +21 -0
- package/native-parsers/go.wasm +0 -0
- package/native-parsers/groovy.LICENSE +21 -0
- package/native-parsers/groovy.wasm +0 -0
- package/native-parsers/haskell.LICENSE +21 -0
- package/native-parsers/haskell.wasm +0 -0
- package/native-parsers/java.LICENSE +21 -0
- package/native-parsers/java.wasm +0 -0
- package/native-parsers/javascript.LICENSE +21 -0
- package/native-parsers/javascript.wasm +0 -0
- package/native-parsers/kotlin.LICENSE +9 -0
- package/native-parsers/kotlin.wasm +0 -0
- package/native-parsers/lock.json +114 -0
- package/native-parsers/prolog.LICENSE +21 -0
- package/native-parsers/prolog.wasm +0 -0
- package/native-parsers/python.LICENSE +21 -0
- package/native-parsers/python.wasm +0 -0
- package/native-parsers/rust.LICENSE +21 -0
- package/native-parsers/rust.wasm +0 -0
- package/native-parsers/scala.LICENSE +21 -0
- package/native-parsers/scala.wasm +0 -0
- package/native-parsers/swift.LICENSE +21 -0
- package/native-parsers/swift.wasm +0 -0
- package/native-parsers/typescript.LICENSE +21 -0
- package/native-parsers/typescript.wasm +0 -0
- package/node-events-reporter.mjs +41 -17
- package/package.json +5 -3
- package/project.mjs +338 -0
- package/proof.d.ts +93 -19
- package/proof.mjs +1538 -447
- package/read-only-hpack.mjs +6 -5
- package/scala-build-state.mjs +131 -41
- package/scala-coverage.mjs +57 -34
- package/scalars.mjs +23 -8
- package/templates.mjs +566 -617
- package/test-command.mjs +1671 -521
package/component-packages.mjs
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
// Generated from templates/npm/component-packages.mjs by lawspec-dev generate. Do not edit.
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
readFile,
|
|
4
|
+
writeFile,
|
|
5
|
+
mkdir,
|
|
6
|
+
readdir,
|
|
7
|
+
lstat,
|
|
8
|
+
realpath,
|
|
9
|
+
rename,
|
|
10
|
+
rm,
|
|
11
|
+
mkdtemp,
|
|
12
|
+
} from 'node:fs/promises';
|
|
3
13
|
import {execFile} from 'node:child_process';
|
|
4
14
|
import {promisify} from 'node:util';
|
|
5
15
|
import {Readable} from 'node:stream';
|
|
@@ -8,136 +18,303 @@ import os from 'node:os';
|
|
|
8
18
|
import {randomUUID} from 'node:crypto';
|
|
9
19
|
import path from 'node:path';
|
|
10
20
|
import * as tar from 'tar';
|
|
11
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
readManifest,
|
|
23
|
+
parseManifest,
|
|
24
|
+
writeManifest,
|
|
25
|
+
manifestName,
|
|
26
|
+
lockName,
|
|
27
|
+
packageVersions,
|
|
28
|
+
dependencyRanges,
|
|
29
|
+
contentDigest,
|
|
30
|
+
canonical,
|
|
31
|
+
} from './component.mjs';
|
|
12
32
|
import {collectSources, atomicWrite} from './files.mjs';
|
|
13
33
|
|
|
14
34
|
const exec = promisify(execFile);
|
|
15
|
-
const git = async (args, options = {}) =>
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
35
|
+
const git = async (args, options = {}) =>
|
|
36
|
+
(await exec('git', args, {maxBuffer: 128 * 1024 * 1024, ...options})).stdout;
|
|
37
|
+
const optional = async file =>
|
|
38
|
+
readFile(file, 'utf8').catch(error =>
|
|
39
|
+
{
|
|
40
|
+
if (error.code === 'ENOENT') return null;
|
|
41
|
+
throw error;
|
|
42
|
+
});
|
|
43
|
+
const inside = (root, file) =>
|
|
44
|
+
file === root || file.startsWith(root + path.sep);
|
|
45
|
+
const rangeOf = value => (typeof value === 'string' ? value : value.version);
|
|
19
46
|
|
|
20
|
-
function validateLock(lock)
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
47
|
+
function validateLock(lock)
|
|
48
|
+
{
|
|
49
|
+
const map = value =>
|
|
50
|
+
value && typeof value === 'object' && !Array.isArray(value);
|
|
51
|
+
const invalid = () =>
|
|
52
|
+
{
|
|
53
|
+
throw new Error(
|
|
54
|
+
'Invalid LawSpec lockfile; regenerate it with lawspec fetch',
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
if (
|
|
58
|
+
!map(lock) ||
|
|
59
|
+
lock.format !== 'lawspec-lock' ||
|
|
60
|
+
lock.version !== 1 ||
|
|
61
|
+
!map(lock.roots) ||
|
|
62
|
+
!map(lock.selections) ||
|
|
63
|
+
!Array.isArray(lock.packages)
|
|
64
|
+
)
|
|
65
|
+
invalid();
|
|
25
66
|
const ids = new Set();
|
|
26
|
-
for (const entry of lock.packages)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
67
|
+
for (const entry of lock.packages)
|
|
68
|
+
{
|
|
69
|
+
if (
|
|
70
|
+
!map(entry) ||
|
|
71
|
+
typeof entry.id !== 'string' ||
|
|
72
|
+
ids.has(entry.id) ||
|
|
73
|
+
typeof entry.name !== 'string' ||
|
|
74
|
+
typeof entry.version !== 'string' ||
|
|
75
|
+
!map(entry.dependencies) ||
|
|
76
|
+
!map(entry.source)
|
|
77
|
+
)
|
|
78
|
+
invalid();
|
|
30
79
|
ids.add(entry.id);
|
|
31
80
|
const source = entry.source;
|
|
32
|
-
if (source.kind === 'path')
|
|
33
|
-
|
|
34
|
-
if (typeof source.
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (
|
|
39
|
-
|
|
81
|
+
if (source.kind === 'path')
|
|
82
|
+
{
|
|
83
|
+
if (typeof source.path !== 'string') invalid();
|
|
84
|
+
}
|
|
85
|
+
else if (source.kind === 'embedded')
|
|
86
|
+
{
|
|
87
|
+
if (
|
|
88
|
+
typeof source.parent !== 'string' ||
|
|
89
|
+
typeof source.path !== 'string' ||
|
|
90
|
+
!/^[a-f0-9]{64}$/.test(entry.digest)
|
|
91
|
+
)
|
|
92
|
+
invalid();
|
|
93
|
+
}
|
|
94
|
+
else if (['git', 'archive'].includes(source.kind))
|
|
95
|
+
{
|
|
96
|
+
if (
|
|
97
|
+
typeof source.url !== 'string' ||
|
|
98
|
+
!/^[a-f0-9]{64}$/.test(entry.digest)
|
|
99
|
+
)
|
|
100
|
+
invalid();
|
|
101
|
+
if (source.kind === 'git' && !/^[a-f0-9]{40,64}$/.test(source.commit))
|
|
102
|
+
invalid();
|
|
103
|
+
if (source.kind === 'archive' && !/^[a-f0-9]{64}$/.test(source.sha256))
|
|
104
|
+
invalid();
|
|
105
|
+
}
|
|
106
|
+
else invalid();
|
|
40
107
|
}
|
|
41
108
|
for (const selection of Object.values(lock.selections))
|
|
42
|
-
if (
|
|
43
|
-
|
|
109
|
+
if (
|
|
110
|
+
!map(selection) ||
|
|
111
|
+
!Object.hasOwn(selection, 'request') ||
|
|
112
|
+
!ids.has(selection.package)
|
|
113
|
+
)
|
|
114
|
+
invalid();
|
|
115
|
+
for (const id of [
|
|
116
|
+
...Object.values(lock.roots),
|
|
117
|
+
...lock.packages.flatMap(entry => Object.values(entry.dependencies)),
|
|
118
|
+
])
|
|
44
119
|
if (!ids.has(id)) invalid();
|
|
45
120
|
}
|
|
46
121
|
|
|
47
|
-
async function filesUnder(root)
|
|
122
|
+
async function filesUnder(root)
|
|
123
|
+
{
|
|
48
124
|
const files = [];
|
|
49
|
-
async function walk(file, relative)
|
|
125
|
+
async function walk(file, relative)
|
|
126
|
+
{
|
|
50
127
|
const info = await lstat(file);
|
|
51
|
-
if (info.isSymbolicLink())
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
128
|
+
if (info.isSymbolicLink())
|
|
129
|
+
throw new Error(
|
|
130
|
+
`Contract packages cannot contain symbolic links: ${relative}`,
|
|
131
|
+
);
|
|
132
|
+
if (info.isDirectory())
|
|
133
|
+
{
|
|
134
|
+
for (const name of (await readdir(file)).sort())
|
|
135
|
+
{
|
|
136
|
+
if (
|
|
137
|
+
['.git', '.lawspec', 'node_modules', 'target', 'bin', 'obj'].includes(
|
|
138
|
+
name,
|
|
139
|
+
)
|
|
140
|
+
)
|
|
141
|
+
continue;
|
|
142
|
+
await walk(
|
|
143
|
+
path.join(file, name),
|
|
144
|
+
relative ? `${relative}/${name}` : name,
|
|
145
|
+
);
|
|
56
146
|
}
|
|
57
|
-
}
|
|
147
|
+
}
|
|
148
|
+
else if (info.isFile()) files.push(relative);
|
|
58
149
|
}
|
|
59
150
|
await walk(root, '');
|
|
60
151
|
return files;
|
|
61
152
|
}
|
|
62
153
|
|
|
63
|
-
export const resolvedPackageDigest = (content, dependencies) =>
|
|
154
|
+
export const resolvedPackageDigest = (content, dependencies) =>
|
|
155
|
+
Object.keys(dependencies).length
|
|
156
|
+
? contentDigest(canonical({content, dependencies}))
|
|
157
|
+
: content;
|
|
64
158
|
|
|
65
|
-
export async function packageDigest(root)
|
|
159
|
+
export async function packageDigest(root)
|
|
160
|
+
{
|
|
66
161
|
const manifest = await readManifest(path.join(root, manifestName));
|
|
67
162
|
const files = await packageFiles(root, manifest);
|
|
68
|
-
return contentDigest(
|
|
163
|
+
return contentDigest(
|
|
164
|
+
canonical(
|
|
165
|
+
await Promise.all(
|
|
166
|
+
files.map(async file => [
|
|
167
|
+
file,
|
|
168
|
+
contentDigest(await readFile(path.join(root, file))),
|
|
169
|
+
]),
|
|
170
|
+
),
|
|
171
|
+
),
|
|
172
|
+
);
|
|
69
173
|
}
|
|
70
174
|
|
|
71
|
-
async function packageFiles(
|
|
72
|
-
|
|
175
|
+
async function packageFiles(
|
|
176
|
+
root,
|
|
177
|
+
manifest,
|
|
178
|
+
{publish = false, packageRoot = root} = {},
|
|
179
|
+
ancestry = [],
|
|
180
|
+
)
|
|
181
|
+
{
|
|
182
|
+
if (ancestry.includes(root))
|
|
183
|
+
throw new Error(
|
|
184
|
+
'Package dependency cycle while collecting published files',
|
|
185
|
+
);
|
|
73
186
|
ancestry = [...ancestry, root];
|
|
74
187
|
const selected = new Set([manifestName]);
|
|
75
188
|
const realRoot = await realpath(root);
|
|
76
|
-
for (const entry of [...manifest.sources, ...(manifest.assets ?? [])])
|
|
189
|
+
for (const entry of [...manifest.sources, ...(manifest.assets ?? [])])
|
|
190
|
+
{
|
|
77
191
|
const location = path.resolve(root, entry);
|
|
78
192
|
if (!inside(root, location) || !inside(realRoot, await realpath(location)))
|
|
79
193
|
throw new Error(`Published package path leaves its root: ${entry}`);
|
|
80
194
|
await filesUnder(location);
|
|
81
195
|
}
|
|
82
196
|
const sources = await collectSources(root, manifest.sources, root);
|
|
83
|
-
for (const source of sources)
|
|
84
|
-
|
|
197
|
+
for (const source of sources)
|
|
198
|
+
{
|
|
199
|
+
if (!inside(root, path.resolve(root, source.path)))
|
|
200
|
+
throw new Error(
|
|
201
|
+
`Published package source leaves its root: ${source.path}`,
|
|
202
|
+
);
|
|
85
203
|
selected.add(source.path);
|
|
86
204
|
}
|
|
87
|
-
for (const entry of manifest.assets ?? [])
|
|
205
|
+
for (const entry of manifest.assets ?? [])
|
|
206
|
+
{
|
|
88
207
|
const location = path.resolve(root, entry);
|
|
89
|
-
if (!inside(root, location))
|
|
208
|
+
if (!inside(root, location))
|
|
209
|
+
throw new Error(`Published package asset leaves its root: ${entry}`);
|
|
90
210
|
const info = await lstat(location);
|
|
91
|
-
if (info.isSymbolicLink())
|
|
92
|
-
|
|
211
|
+
if (info.isSymbolicLink())
|
|
212
|
+
throw new Error(`Published package asset is a symbolic link: ${entry}`);
|
|
213
|
+
if (info.isDirectory())
|
|
214
|
+
for (const nested of await filesUnder(location))
|
|
215
|
+
selected.add(path.relative(root, path.join(location, nested)));
|
|
93
216
|
else selected.add(entry);
|
|
94
217
|
}
|
|
95
|
-
for (const dependency of Object.values(manifest.dependencies ?? {}))
|
|
218
|
+
for (const dependency of Object.values(manifest.dependencies ?? {}))
|
|
219
|
+
{
|
|
96
220
|
if (!dependency?.path) continue;
|
|
97
221
|
const location = path.resolve(root, dependency.path);
|
|
98
|
-
if (!inside(packageRoot, location))
|
|
99
|
-
|
|
222
|
+
if (!inside(packageRoot, location))
|
|
223
|
+
{
|
|
224
|
+
if (publish)
|
|
225
|
+
throw new Error(
|
|
226
|
+
`Published package dependency leaves its root: ${dependency.path}`,
|
|
227
|
+
);
|
|
100
228
|
continue;
|
|
101
229
|
}
|
|
102
|
-
if (!inside(await realpath(packageRoot), await realpath(location)))
|
|
230
|
+
if (!inside(await realpath(packageRoot), await realpath(location)))
|
|
231
|
+
throw new Error(
|
|
232
|
+
'Published dependency leaves its root through a symbolic link',
|
|
233
|
+
);
|
|
103
234
|
const nested = await readManifest(path.join(location, manifestName));
|
|
104
|
-
for (const file of await packageFiles(
|
|
235
|
+
for (const file of await packageFiles(
|
|
236
|
+
location,
|
|
237
|
+
nested,
|
|
238
|
+
{publish, packageRoot},
|
|
239
|
+
ancestry,
|
|
240
|
+
))
|
|
105
241
|
selected.add(path.relative(root, path.join(location, file)));
|
|
106
242
|
}
|
|
107
243
|
return [...selected].sort();
|
|
108
244
|
}
|
|
109
245
|
|
|
110
|
-
async function unpack(bytes, directory)
|
|
246
|
+
async function unpack(bytes, directory)
|
|
247
|
+
{
|
|
111
248
|
await mkdir(directory, {recursive: true});
|
|
112
249
|
let refused;
|
|
113
|
-
await pipeline(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
250
|
+
await pipeline(
|
|
251
|
+
Readable.from([bytes]),
|
|
252
|
+
tar.x({
|
|
253
|
+
cwd: directory,
|
|
254
|
+
strict: true,
|
|
255
|
+
preservePaths: false,
|
|
256
|
+
filter(name, entry)
|
|
257
|
+
{
|
|
258
|
+
const normalized = path.resolve(directory, name);
|
|
259
|
+
if (
|
|
260
|
+
path.isAbsolute(name) ||
|
|
261
|
+
name.split(/[\\/]/).includes('..') ||
|
|
262
|
+
!inside(directory, normalized) ||
|
|
263
|
+
!['File', 'Directory', 'OldFile', 'ContiguousFile'].includes(
|
|
264
|
+
entry.type,
|
|
265
|
+
)
|
|
266
|
+
)
|
|
267
|
+
{
|
|
268
|
+
refused = `Unsafe package archive entry: ${name}`;
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
return true;
|
|
272
|
+
},
|
|
273
|
+
}),
|
|
274
|
+
);
|
|
121
275
|
if (refused) throw new Error(refused);
|
|
122
276
|
}
|
|
123
277
|
|
|
124
|
-
export async function resolveDependencies(file, manifest, options = {})
|
|
278
|
+
export async function resolveDependencies(file, manifest, options = {})
|
|
279
|
+
{
|
|
125
280
|
const root = path.dirname(path.resolve(file));
|
|
126
|
-
const cache = path.resolve(
|
|
127
|
-
|
|
281
|
+
const cache = path.resolve(
|
|
282
|
+
process.env.LAWSPEC_CACHE_DIR ??
|
|
283
|
+
path.join(
|
|
284
|
+
process.env.XDG_CACHE_HOME ?? path.join(os.homedir(), '.cache'),
|
|
285
|
+
'lawspec',
|
|
286
|
+
'packages',
|
|
287
|
+
),
|
|
288
|
+
);
|
|
289
|
+
const readOnly = !!options.readOnly;
|
|
290
|
+
const locked = !!options.locked,
|
|
291
|
+
offline =
|
|
292
|
+
readOnly || !!options.offline || process.env.LAWSPEC_OFFLINE === '1';
|
|
128
293
|
const previousText = await optional(path.join(root, lockName));
|
|
129
|
-
const previous =
|
|
294
|
+
const previous =
|
|
295
|
+
previousText === null
|
|
296
|
+
? null
|
|
297
|
+
: parseManifest(previousText, path.join(root, lockName));
|
|
130
298
|
if (previous) validateLock(previous);
|
|
131
|
-
const oldSelections = previous?.selections ?? {},
|
|
132
|
-
|
|
299
|
+
const oldSelections = previous?.selections ?? {},
|
|
300
|
+
selections = {},
|
|
301
|
+
entries = new Map(),
|
|
302
|
+
packages = new Map(),
|
|
303
|
+
identities = new Map();
|
|
304
|
+
const local = new Map(),
|
|
305
|
+
localSeen = new Set(),
|
|
306
|
+
locations = new Map();
|
|
133
307
|
|
|
134
|
-
async function localCandidates(directory, owner)
|
|
135
|
-
|
|
308
|
+
async function localCandidates(directory, owner)
|
|
309
|
+
{
|
|
310
|
+
for (const name of owner.packages ?? [])
|
|
311
|
+
{
|
|
136
312
|
const location = path.resolve(directory, name);
|
|
137
313
|
if (localSeen.has(location)) continue;
|
|
138
314
|
localSeen.add(location);
|
|
139
315
|
const candidate = await readManifest(path.join(location, manifestName));
|
|
140
|
-
if (!candidate.package)
|
|
316
|
+
if (!candidate.package)
|
|
317
|
+
throw new Error(`${location}: expected a package identity`);
|
|
141
318
|
const list = local.get(candidate.package.name) ?? [];
|
|
142
319
|
list.push({directory: location, manifest: candidate});
|
|
143
320
|
local.set(candidate.package.name, list);
|
|
@@ -146,194 +323,503 @@ export async function resolveDependencies(file, manifest, options = {}) {
|
|
|
146
323
|
}
|
|
147
324
|
await localCandidates(root, manifest);
|
|
148
325
|
|
|
149
|
-
async function gitRepository(url)
|
|
326
|
+
async function gitRepository(url)
|
|
327
|
+
{
|
|
150
328
|
const repository = path.join(cache, 'git', contentDigest(url));
|
|
151
|
-
if (await optional(path.join(repository, 'HEAD')) !== null)
|
|
329
|
+
if ((await optional(path.join(repository, 'HEAD'))) !== null)
|
|
330
|
+
return repository;
|
|
152
331
|
await mkdir(path.dirname(repository), {recursive: true});
|
|
153
|
-
const temporary = await mkdtemp(
|
|
154
|
-
|
|
332
|
+
const temporary = await mkdtemp(
|
|
333
|
+
path.join(path.dirname(repository), '.initializing-'),
|
|
334
|
+
);
|
|
335
|
+
try
|
|
336
|
+
{
|
|
155
337
|
await git(['init', '--bare', '--quiet', temporary]);
|
|
156
|
-
try
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
338
|
+
try
|
|
339
|
+
{
|
|
340
|
+
await rename(temporary, repository);
|
|
341
|
+
}
|
|
342
|
+
catch (error)
|
|
343
|
+
{
|
|
344
|
+
if (!['EEXIST', 'ENOTEMPTY', 'EPERM'].includes(error.code)) throw error;
|
|
345
|
+
}
|
|
346
|
+
if ((await optional(path.join(repository, 'HEAD'))) === null)
|
|
347
|
+
throw new Error(
|
|
348
|
+
`Cached Git repository initialization did not complete: ${repository}`,
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
finally
|
|
352
|
+
{
|
|
353
|
+
await rm(temporary, {recursive: true, force: true});
|
|
354
|
+
}
|
|
161
355
|
return repository;
|
|
162
356
|
}
|
|
163
357
|
|
|
164
|
-
async function gitCheckout(source)
|
|
358
|
+
async function gitCheckout(source)
|
|
359
|
+
{
|
|
165
360
|
const repository = await gitRepository(source.url);
|
|
166
|
-
const present = await git([
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
361
|
+
const present = await git([
|
|
362
|
+
'--git-dir',
|
|
363
|
+
repository,
|
|
364
|
+
'cat-file',
|
|
365
|
+
'-e',
|
|
366
|
+
`${source.commit}^{commit}`,
|
|
367
|
+
]).then(
|
|
368
|
+
() => true,
|
|
369
|
+
() => false,
|
|
370
|
+
);
|
|
371
|
+
if (!present)
|
|
372
|
+
{
|
|
373
|
+
if (offline)
|
|
374
|
+
throw new Error(`Offline: Git revision ${source.commit} is not cached`);
|
|
375
|
+
await git([
|
|
376
|
+
'--git-dir',
|
|
377
|
+
repository,
|
|
378
|
+
'fetch',
|
|
379
|
+
'--quiet',
|
|
380
|
+
'--no-tags',
|
|
381
|
+
'--no-write-fetch-head',
|
|
382
|
+
'--',
|
|
383
|
+
source.url,
|
|
384
|
+
source.commit,
|
|
385
|
+
]);
|
|
170
386
|
}
|
|
171
|
-
return git(
|
|
387
|
+
return git(
|
|
388
|
+
[
|
|
389
|
+
'--git-dir',
|
|
390
|
+
repository,
|
|
391
|
+
'archive',
|
|
392
|
+
'--format=tar',
|
|
393
|
+
source.subdir ? `${source.commit}:${source.subdir}` : source.commit,
|
|
394
|
+
],
|
|
395
|
+
{encoding: 'buffer'},
|
|
396
|
+
);
|
|
172
397
|
}
|
|
173
398
|
|
|
174
|
-
async function downloaded(source, known)
|
|
175
|
-
|
|
176
|
-
|
|
399
|
+
async function downloaded(source, known)
|
|
400
|
+
{
|
|
401
|
+
const id = contentDigest(canonical(source)),
|
|
402
|
+
directory = path.join(cache, id),
|
|
403
|
+
marker = path.join(cache, id + '.sha256');
|
|
404
|
+
if ((await optional(path.join(directory, manifestName))) !== null)
|
|
405
|
+
{
|
|
177
406
|
const expected = known?.digest ?? (await optional(marker))?.trim();
|
|
178
|
-
if (expected)
|
|
179
|
-
|
|
180
|
-
|
|
407
|
+
if (expected)
|
|
408
|
+
{
|
|
409
|
+
if (
|
|
410
|
+
!/^[a-f0-9]{64}$/.test(expected) ||
|
|
411
|
+
(await packageDigest(directory)) !== expected
|
|
412
|
+
)
|
|
413
|
+
throw new Error(
|
|
414
|
+
`Cached contract content changed: ${known?.name ?? source.url}`,
|
|
415
|
+
);
|
|
416
|
+
if (!readOnly) await atomicWrite(marker, expected + '\n');
|
|
181
417
|
return {directory, source};
|
|
182
418
|
}
|
|
183
|
-
if (offline)
|
|
419
|
+
if (offline)
|
|
420
|
+
throw new Error(
|
|
421
|
+
`Offline: cached contract integrity is unavailable for ${source.url}`,
|
|
422
|
+
);
|
|
184
423
|
}
|
|
185
|
-
if (
|
|
424
|
+
if (readOnly)
|
|
425
|
+
throw new Error(
|
|
426
|
+
`Read-only dependency resolution requires a verified unpacked cache for ${source.url}; run lawspec fetch separately`,
|
|
427
|
+
);
|
|
428
|
+
if (offline && source.kind === 'archive')
|
|
429
|
+
throw new Error(`Offline: ${source.url} is not cached`);
|
|
186
430
|
let bytes;
|
|
187
431
|
if (source.kind === 'git') bytes = await gitCheckout(source);
|
|
188
|
-
else
|
|
432
|
+
else
|
|
433
|
+
{
|
|
189
434
|
const url = new URL(source.url);
|
|
190
|
-
if (
|
|
435
|
+
if (
|
|
436
|
+
url.protocol !== 'https:' &&
|
|
437
|
+
!(
|
|
438
|
+
url.protocol === 'http:' &&
|
|
439
|
+
['127.0.0.1', 'localhost', '[::1]'].includes(url.hostname)
|
|
440
|
+
)
|
|
441
|
+
)
|
|
191
442
|
throw new Error('Contract archives must use HTTPS');
|
|
192
443
|
const answer = await fetch(url);
|
|
193
|
-
if (!answer.ok)
|
|
444
|
+
if (!answer.ok)
|
|
445
|
+
throw new Error(
|
|
446
|
+
`Contract download failed: HTTP ${answer.status} for ${url}`,
|
|
447
|
+
);
|
|
194
448
|
bytes = Buffer.from(await answer.arrayBuffer());
|
|
195
|
-
if (contentDigest(bytes) !== source.sha256)
|
|
449
|
+
if (contentDigest(bytes) !== source.sha256)
|
|
450
|
+
throw new Error(`Contract archive SHA-256 mismatch: ${url}`);
|
|
196
451
|
}
|
|
197
452
|
await mkdir(cache, {recursive: true});
|
|
198
453
|
const temporary = await mkdtemp(path.join(cache, '.unpack-'));
|
|
199
|
-
try
|
|
454
|
+
try
|
|
455
|
+
{
|
|
200
456
|
await unpack(bytes, temporary);
|
|
201
457
|
await readManifest(path.join(temporary, manifestName));
|
|
202
458
|
const digest = await packageDigest(temporary);
|
|
203
|
-
try
|
|
204
|
-
|
|
205
|
-
|
|
459
|
+
try
|
|
460
|
+
{
|
|
461
|
+
await rename(temporary, directory);
|
|
462
|
+
}
|
|
463
|
+
catch (error)
|
|
464
|
+
{
|
|
465
|
+
if (!['EEXIST', 'ENOTEMPTY'].includes(error.code)) throw error;
|
|
466
|
+
}
|
|
467
|
+
if ((await packageDigest(directory)) !== digest)
|
|
468
|
+
throw new Error(`Cached contract content changed: ${source.url}`);
|
|
206
469
|
await atomicWrite(marker, digest + '\n');
|
|
207
|
-
}
|
|
208
|
-
|
|
470
|
+
}
|
|
471
|
+
finally
|
|
472
|
+
{
|
|
473
|
+
await rm(temporary, {recursive: true, force: true});
|
|
474
|
+
}
|
|
475
|
+
if (known && (await packageDigest(directory)) !== known.digest)
|
|
476
|
+
throw new Error(
|
|
477
|
+
`Downloaded contract content differs from lock: ${known.name}`,
|
|
478
|
+
);
|
|
209
479
|
return {directory, source};
|
|
210
480
|
}
|
|
211
481
|
|
|
212
|
-
function immutableOwner(owner)
|
|
482
|
+
function immutableOwner(owner)
|
|
483
|
+
{
|
|
213
484
|
let current = owner;
|
|
214
|
-
while (entries.get(current)?.source.kind === 'embedded')
|
|
215
|
-
|
|
485
|
+
while (entries.get(current)?.source.kind === 'embedded')
|
|
486
|
+
current = entries.get(current).source.parent;
|
|
487
|
+
return entries.has(current) && entries.get(current).source.kind !== 'path'
|
|
488
|
+
? current
|
|
489
|
+
: null;
|
|
216
490
|
}
|
|
217
491
|
|
|
218
|
-
async function localSource(location, owner)
|
|
492
|
+
async function localSource(location, owner)
|
|
493
|
+
{
|
|
219
494
|
const parent = immutableOwner(owner);
|
|
220
|
-
if (!parent)
|
|
495
|
+
if (!parent)
|
|
496
|
+
return {
|
|
497
|
+
directory: location,
|
|
498
|
+
source: {kind: 'path', path: path.relative(root, location) || '.'},
|
|
499
|
+
};
|
|
221
500
|
const directory = locations.get(parent);
|
|
222
|
-
if (
|
|
223
|
-
|
|
224
|
-
|
|
501
|
+
if (
|
|
502
|
+
!inside(directory, location) ||
|
|
503
|
+
!inside(await realpath(directory), await realpath(location))
|
|
504
|
+
)
|
|
505
|
+
throw new Error(
|
|
506
|
+
'Published package dependency leaves its downloaded root',
|
|
507
|
+
);
|
|
508
|
+
return {
|
|
509
|
+
directory: location,
|
|
510
|
+
source: {
|
|
511
|
+
kind: 'embedded',
|
|
512
|
+
parent,
|
|
513
|
+
path: path.relative(directory, location) || '.',
|
|
514
|
+
},
|
|
515
|
+
};
|
|
225
516
|
}
|
|
226
517
|
|
|
227
|
-
async function materialize(name, specification, directory, old, owner)
|
|
518
|
+
async function materialize(name, specification, directory, old, owner)
|
|
519
|
+
{
|
|
228
520
|
const refresh = options.update === true || options.update === name;
|
|
229
|
-
if (
|
|
521
|
+
if (
|
|
522
|
+
old &&
|
|
523
|
+
!refresh &&
|
|
524
|
+
canonical(old.request) === canonical(specification)
|
|
525
|
+
)
|
|
526
|
+
{
|
|
230
527
|
const entry = previous.packages.find(item => item.id === old.package);
|
|
231
|
-
if (!entry)
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
528
|
+
if (!entry)
|
|
529
|
+
throw new Error(`Lockfile references missing package ${old.package}`);
|
|
530
|
+
if (entry.source.kind === 'path')
|
|
531
|
+
{
|
|
532
|
+
if (immutableOwner(owner))
|
|
533
|
+
throw new Error(
|
|
534
|
+
'Lockfile contains a non-portable published path; run lawspec update',
|
|
535
|
+
);
|
|
536
|
+
return {
|
|
537
|
+
directory: path.resolve(root, entry.source.path),
|
|
538
|
+
source: entry.source,
|
|
539
|
+
};
|
|
235
540
|
}
|
|
236
|
-
if (entry.source.kind === 'embedded')
|
|
541
|
+
if (entry.source.kind === 'embedded')
|
|
542
|
+
{
|
|
237
543
|
const parent = locations.get(entry.source.parent);
|
|
238
|
-
if (!parent || entry.source.parent !== immutableOwner(owner))
|
|
239
|
-
|
|
240
|
-
|
|
544
|
+
if (!parent || entry.source.parent !== immutableOwner(owner))
|
|
545
|
+
throw new Error('Invalid embedded package parent in lockfile');
|
|
546
|
+
const loaded = await localSource(
|
|
547
|
+
path.resolve(parent, entry.source.path),
|
|
548
|
+
owner,
|
|
549
|
+
);
|
|
550
|
+
if ((await packageDigest(loaded.directory)) !== entry.digest)
|
|
551
|
+
throw new Error(`Cached embedded contract content changed: ${name}`);
|
|
241
552
|
return loaded;
|
|
242
553
|
}
|
|
243
554
|
return downloaded(entry.source, entry);
|
|
244
555
|
}
|
|
245
|
-
if (locked)
|
|
246
|
-
|
|
556
|
+
if (locked)
|
|
557
|
+
throw new Error(
|
|
558
|
+
`Lockfile must change for ${name}; run lawspec fetch without --locked`,
|
|
559
|
+
);
|
|
560
|
+
if (typeof specification === 'string')
|
|
561
|
+
{
|
|
247
562
|
const candidates = local.get(name) ?? [];
|
|
248
|
-
const accepted = await packageVersions(
|
|
249
|
-
|
|
250
|
-
|
|
563
|
+
const accepted = await packageVersions(
|
|
564
|
+
specification,
|
|
565
|
+
candidates.map(item => item.manifest.package.version),
|
|
566
|
+
);
|
|
567
|
+
const chosen = candidates.find(
|
|
568
|
+
item => item.manifest.package.version === accepted[0],
|
|
569
|
+
);
|
|
570
|
+
if (!chosen)
|
|
571
|
+
throw new Error(
|
|
572
|
+
`requires ${name} ${specification}, but ${candidates.length === 1 ? 'version ' + candidates[0].manifest.package.version + ' is supplied' : 'no supplied version satisfies it'}`,
|
|
573
|
+
);
|
|
251
574
|
return localSource(chosen.directory, owner);
|
|
252
575
|
}
|
|
253
|
-
if (specification.path)
|
|
576
|
+
if (specification.path)
|
|
577
|
+
{
|
|
254
578
|
const location = path.resolve(directory, specification.path);
|
|
255
579
|
return localSource(location, owner);
|
|
256
580
|
}
|
|
257
|
-
if (specification.archive)
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
581
|
+
if (specification.archive)
|
|
582
|
+
return downloaded({
|
|
583
|
+
kind: 'archive',
|
|
584
|
+
url: specification.archive,
|
|
585
|
+
sha256: specification.sha256,
|
|
586
|
+
});
|
|
587
|
+
if (offline)
|
|
588
|
+
throw new Error(`Offline: resolving ${name} requires a lockfile`);
|
|
589
|
+
let ref = specification.rev,
|
|
590
|
+
tagVersion;
|
|
591
|
+
if (!ref)
|
|
592
|
+
{
|
|
261
593
|
const prefix = specification.tagPrefix ?? 'v';
|
|
262
|
-
const tags = (
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
594
|
+
const tags = (
|
|
595
|
+
await git(['ls-remote', '--tags', '--refs', '--', specification.git])
|
|
596
|
+
)
|
|
597
|
+
.trim()
|
|
598
|
+
.split('\n')
|
|
599
|
+
.filter(Boolean)
|
|
600
|
+
.map(line =>
|
|
601
|
+
{
|
|
602
|
+
const [commit, tag] = line.split(/\s+/);
|
|
603
|
+
return {commit, tag: tag.replace('refs/tags/', '')};
|
|
604
|
+
})
|
|
605
|
+
.filter(
|
|
606
|
+
item =>
|
|
607
|
+
item.tag.startsWith(prefix) &&
|
|
608
|
+
/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(
|
|
609
|
+
item.tag.slice(prefix.length),
|
|
610
|
+
),
|
|
611
|
+
);
|
|
612
|
+
const versions = await packageVersions(
|
|
613
|
+
specification.version,
|
|
614
|
+
tags.map(item => item.tag.slice(prefix.length)),
|
|
615
|
+
);
|
|
616
|
+
const chosen = tags.find(
|
|
617
|
+
item => item.tag.slice(prefix.length) === versions[0],
|
|
618
|
+
);
|
|
619
|
+
if (!chosen)
|
|
620
|
+
throw new Error(
|
|
621
|
+
`No published Git version satisfies ${name} ${specification.version}`,
|
|
622
|
+
);
|
|
269
623
|
ref = chosen.commit;
|
|
270
624
|
tagVersion = chosen.tag.slice(prefix.length);
|
|
271
625
|
}
|
|
272
626
|
const repository = await gitRepository(specification.git);
|
|
273
627
|
const fetched = 'refs/lawspec/' + randomUUID();
|
|
274
628
|
let commit;
|
|
275
|
-
try
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
629
|
+
try
|
|
630
|
+
{
|
|
631
|
+
await git([
|
|
632
|
+
'--git-dir',
|
|
633
|
+
repository,
|
|
634
|
+
'fetch',
|
|
635
|
+
'--quiet',
|
|
636
|
+
'--no-tags',
|
|
637
|
+
'--no-write-fetch-head',
|
|
638
|
+
'--',
|
|
639
|
+
specification.git,
|
|
640
|
+
ref + ':' + fetched,
|
|
641
|
+
]);
|
|
642
|
+
commit = (
|
|
643
|
+
await git(['--git-dir', repository, 'rev-parse', fetched + '^{commit}'])
|
|
644
|
+
).trim();
|
|
645
|
+
}
|
|
646
|
+
finally
|
|
647
|
+
{
|
|
648
|
+
await git(['--git-dir', repository, 'update-ref', '-d', fetched]);
|
|
649
|
+
}
|
|
650
|
+
return downloaded({
|
|
651
|
+
kind: 'git',
|
|
652
|
+
url: specification.git,
|
|
653
|
+
commit,
|
|
654
|
+
...(tagVersion ? {tagVersion} : {}),
|
|
655
|
+
...(specification.subdir ? {subdir: specification.subdir} : {}),
|
|
656
|
+
});
|
|
280
657
|
}
|
|
281
658
|
|
|
282
|
-
async function resolve(name, specification, directory, owner, ancestry)
|
|
283
|
-
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
659
|
+
async function resolve(name, specification, directory, owner, ancestry)
|
|
660
|
+
{
|
|
661
|
+
const key = owner + '::' + name,
|
|
662
|
+
old = oldSelections[key];
|
|
663
|
+
const loaded = await materialize(
|
|
664
|
+
name,
|
|
665
|
+
specification,
|
|
666
|
+
directory,
|
|
667
|
+
old,
|
|
668
|
+
owner,
|
|
669
|
+
);
|
|
670
|
+
const described = await readManifest(
|
|
671
|
+
path.join(loaded.directory, manifestName),
|
|
672
|
+
);
|
|
673
|
+
if (!described.package || described.package.name !== name)
|
|
674
|
+
throw new Error(`Dependency ${name} has a different package identity`);
|
|
287
675
|
const version = described.package.version;
|
|
288
676
|
if (loaded.source.tagVersion && loaded.source.tagVersion !== version)
|
|
289
|
-
throw new Error(
|
|
290
|
-
|
|
677
|
+
throw new Error(
|
|
678
|
+
`Git tag version ${loaded.source.tagVersion} differs from ${name} manifest version ${version}`,
|
|
679
|
+
);
|
|
680
|
+
if (!(await packageVersions(rangeOf(specification), [version])).length)
|
|
681
|
+
throw new Error(
|
|
682
|
+
`requires ${name} ${rangeOf(specification)}, but version ${version} is supplied`,
|
|
683
|
+
);
|
|
291
684
|
const id = contentDigest(canonical({name, version, source: loaded.source}));
|
|
292
685
|
selections[key] = {request: specification, package: id};
|
|
293
|
-
if (ancestry.includes(id))
|
|
686
|
+
if (ancestry.includes(id))
|
|
687
|
+
throw new Error(
|
|
688
|
+
`Package dependency cycle: ${[...ancestry, id].join(' -> ')}`,
|
|
689
|
+
);
|
|
294
690
|
if (entries.has(id)) return id;
|
|
295
|
-
const digest = await packageDigest(loaded.directory),
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
691
|
+
const digest = await packageDigest(loaded.directory),
|
|
692
|
+
identity = {name, version, source: loaded.source, digest};
|
|
693
|
+
const sameVersion = [...identities.values()].find(
|
|
694
|
+
item => item.name === name && item.version === version,
|
|
695
|
+
);
|
|
696
|
+
if (sameVersion && sameVersion.digest !== digest)
|
|
697
|
+
throw new Error(`Ambiguous content for ${name} ${version}`);
|
|
698
|
+
const entry = {
|
|
699
|
+
id,
|
|
700
|
+
name,
|
|
701
|
+
version,
|
|
702
|
+
source: loaded.source,
|
|
703
|
+
...(loaded.source.kind === 'path' ? {} : {digest}),
|
|
704
|
+
dependencies: {},
|
|
705
|
+
};
|
|
299
706
|
entries.set(id, entry);
|
|
300
707
|
identities.set(id, identity);
|
|
301
708
|
locations.set(id, loaded.directory);
|
|
302
709
|
await localCandidates(loaded.directory, described);
|
|
303
|
-
for (const [dependency, child] of Object.entries(
|
|
304
|
-
|
|
305
|
-
|
|
710
|
+
for (const [dependency, child] of Object.entries(
|
|
711
|
+
described.dependencies ?? {},
|
|
712
|
+
).sort())
|
|
713
|
+
entry.dependencies[dependency] = await resolve(
|
|
714
|
+
dependency,
|
|
715
|
+
child,
|
|
716
|
+
loaded.directory,
|
|
717
|
+
id,
|
|
718
|
+
[...ancestry, id],
|
|
719
|
+
);
|
|
720
|
+
packages.set(id, {
|
|
721
|
+
name,
|
|
722
|
+
version,
|
|
723
|
+
dependencies: dependencyRanges(described),
|
|
724
|
+
sources: await collectSources(loaded.directory, described.sources, root),
|
|
725
|
+
});
|
|
306
726
|
return id;
|
|
307
727
|
}
|
|
308
728
|
const roots = {};
|
|
309
|
-
for (const [name, specification] of Object.entries(
|
|
729
|
+
for (const [name, specification] of Object.entries(
|
|
730
|
+
manifest.dependencies ?? {},
|
|
731
|
+
).sort())
|
|
310
732
|
roots[name] = await resolve(name, specification, root, '$', []);
|
|
311
|
-
const lock = {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
733
|
+
const lock = {
|
|
734
|
+
format: 'lawspec-lock',
|
|
735
|
+
version: 1,
|
|
736
|
+
roots,
|
|
737
|
+
selections,
|
|
738
|
+
packages: [...entries.values()].sort((a, b) => a.id.localeCompare(b.id)),
|
|
739
|
+
};
|
|
740
|
+
if (entries.size || previous)
|
|
741
|
+
{
|
|
742
|
+
if (locked && canonical(lock) !== canonical(previous))
|
|
743
|
+
throw new Error('Lockfile is out of date; run lawspec fetch');
|
|
744
|
+
if (
|
|
745
|
+
!locked &&
|
|
746
|
+
!readOnly &&
|
|
747
|
+
options.writeLock !== false &&
|
|
748
|
+
canonical(lock) !== canonical(previous)
|
|
749
|
+
)
|
|
750
|
+
await atomicWrite(path.join(root, lockName), writeManifest(lock));
|
|
315
751
|
}
|
|
316
752
|
const semantic = new Map();
|
|
317
|
-
const closure = id =>
|
|
318
|
-
|
|
319
|
-
|
|
753
|
+
const closure = id =>
|
|
754
|
+
{
|
|
755
|
+
if (!semantic.has(id))
|
|
756
|
+
semantic.set(
|
|
757
|
+
id,
|
|
758
|
+
resolvedPackageDigest(
|
|
759
|
+
identities.get(id).digest,
|
|
760
|
+
Object.fromEntries(
|
|
761
|
+
Object.entries(entries.get(id).dependencies).map(
|
|
762
|
+
([name, child]) => [name, closure(child)],
|
|
763
|
+
),
|
|
764
|
+
),
|
|
765
|
+
),
|
|
766
|
+
);
|
|
320
767
|
return semantic.get(id);
|
|
321
768
|
};
|
|
322
|
-
const resolvedIdentities = [...identities].map(([id,value]) => ({
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
769
|
+
const resolvedIdentities = [...identities].map(([id, value]) => ({
|
|
770
|
+
...value,
|
|
771
|
+
contentDigest: value.digest,
|
|
772
|
+
digest: closure(id),
|
|
773
|
+
}));
|
|
774
|
+
for (const identity of resolvedIdentities)
|
|
775
|
+
{
|
|
776
|
+
const alternatives = resolvedIdentities.filter(
|
|
777
|
+
other =>
|
|
778
|
+
other.name === identity.name && other.version === identity.version,
|
|
779
|
+
);
|
|
780
|
+
if (alternatives.some(other => other.digest !== identity.digest))
|
|
781
|
+
throw new Error(
|
|
782
|
+
`Ambiguous resolved contract closure for ${identity.name} ${identity.version}`,
|
|
783
|
+
);
|
|
326
784
|
}
|
|
327
|
-
const ordered = values =>
|
|
328
|
-
|
|
785
|
+
const ordered = values =>
|
|
786
|
+
[...values].sort(
|
|
787
|
+
(a, b) =>
|
|
788
|
+
a.name.localeCompare(b.name) || a.version.localeCompare(b.version),
|
|
789
|
+
);
|
|
790
|
+
return {
|
|
791
|
+
packages: ordered(packages.values()),
|
|
792
|
+
identities: ordered(resolvedIdentities),
|
|
793
|
+
lock,
|
|
794
|
+
};
|
|
329
795
|
}
|
|
330
796
|
|
|
331
|
-
export async function packComponent(file, output)
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
797
|
+
export async function packComponent(file, output)
|
|
798
|
+
{
|
|
799
|
+
if (path.basename(file) !== manifestName)
|
|
800
|
+
throw new Error(
|
|
801
|
+
'Published packages require the canonical lawspec.edn filename',
|
|
802
|
+
);
|
|
803
|
+
const manifest = await readManifest(file),
|
|
804
|
+
root = path.dirname(path.resolve(file));
|
|
805
|
+
if (!manifest.package)
|
|
806
|
+
throw new Error('lawspec package --output requires a package identity');
|
|
335
807
|
const selected = await packageFiles(root, manifest, {publish: true});
|
|
336
808
|
await mkdir(path.dirname(path.resolve(output)), {recursive: true});
|
|
337
|
-
await tar.c(
|
|
338
|
-
|
|
809
|
+
await tar.c(
|
|
810
|
+
{
|
|
811
|
+
cwd: root,
|
|
812
|
+
file: path.resolve(output),
|
|
813
|
+
gzip: true,
|
|
814
|
+
portable: true,
|
|
815
|
+
mtime: new Date(0),
|
|
816
|
+
noDirRecurse: true,
|
|
817
|
+
},
|
|
818
|
+
selected,
|
|
819
|
+
);
|
|
820
|
+
return {
|
|
821
|
+
file: path.resolve(output),
|
|
822
|
+
sha256: contentDigest(await readFile(output)),
|
|
823
|
+
package: manifest.package,
|
|
824
|
+
};
|
|
339
825
|
}
|