Commit Graph

492 Commits

Author SHA1 Message Date
Simon Rüegg
7699f297d8 Allow formatting multiple files/directories
This makes it easier to work with tools which return a list of file to
format, e.g. to only handle files which have changed in a PR.
2025-09-19 13:16:16 +02:00
Islon Scherer
618c6243c5 Fix bug in format apply (#1211) 2025-09-19 11:28:40 +02:00
Islon Scherer
222741dccd Fix broken test (#1208) 2025-09-17 13:53:15 -07:00
Islon Scherer
fdc501a35c Implement canonical formatter (#1107)
CLI commands also added: `pkl format check` and `pkl format apply`.
2025-09-17 11:12:04 +02:00
Vladimir Matveev
6a06ab7caa Fixed fallback certificates not working in certain classloader setups (#1198)
In the original implementation the `org/pkl/commons/cli/PklCARoots.pem` resource is resolved relatively to the classloader associated with the class returned by `javaClass`. However, since this is an extension method for `HttpClient.Builder`, it means calling `javaClass` on the builder instance, which is actually defined in the system classpath.

Because of this, if the Pkl class is loaded by a different classloader compared to the one which contains JDK classes, which is totally possible in certain scenarios (e.g. with Gradle), then this resource resolution will fail.

The solution is to resolve `javaClass` against `this@CliCommand`, to use the classloader which loaded the jar with the `CliCommand` class to find the CA resource.
2025-09-04 15:49:43 -07:00
Daniel Chao
a66ac0eb35 Refine documentation for class Any (#1194) 2025-09-02 08:19:39 -07:00
Jen Basch
bef0375285 Improve interrupt handling in pkl repl (#1188) 2025-08-29 13:39:49 -07:00
Jen Basch
44cc154501 Prepare 0.29.1 release (#1192)
Co-authored-by: Daniel Chao <dan.chao@apple.com>
2025-08-27 14:33:25 -07:00
Artem Yarmoliuk
af7057b75f Fix shell completion for paths (#1161) 2025-08-26 10:46:54 -07:00
Jen Basch
a8806416b9 Correctly handle EOF after unmatched backtick (#1187) 2025-08-25 14:31:26 -07:00
Jen Basch
b32039a4f1 Add me as a maintainer (#1185) 2025-08-25 13:17:53 -07:00
Daniel Chao
a779316cc2 Update dependencies (#1184)
Bump test dependencies, and also commonmark
2025-08-21 21:32:56 -07:00
Daniel Chao
d9db939bdc Fix missing resources in native pkldoc, and disable test mode (#1175)
This fixes two issues:

1. Test mode is enabled in pkldoc without the ability to turn it off
2. Native pkldoc is missing required resources

This also adds tests for both `jpkldoc` and `pkldoc`.
2025-08-21 06:44:13 -07:00
Jen Basch
ae5f02b285 Allow trailing commas in comma-separated syntax elements (#1137) 2025-08-21 06:43:38 -07:00
Daniel Chao
3f2f0c3a2b Add docs for installing via winget (#1171) 2025-08-11 17:22:30 -07:00
Daniel Chao
7d50aaeec9 Fix escaping in yaml strings (#1165)
The backslash needs to be escaped when rendering double-quoted YAML strings.

In addition, this escapes the following characters:

* next line (0x85)
* nbsp (0xa0)
2025-08-06 07:57:52 -07:00
Daniel Chao
78ba6bf758 Fix download links (#1162)
* Snapshot repo has changed
* Fix a bug where pkl-codegen-java download link points to Sonatype instead of GitHub

Not in the PR: we also need to fix the snapshot download location;
but haven't figured out yet what the correct link is.
2025-07-31 08:43:24 -07:00
Daniel Chao
20e7e251ec Fix encoding for mapping with local members (#1152)
Fixes an issue where local members are included in
the mapping entry count.

Also: avoid re-computing Mapping.length
2025-07-28 10:13:45 -07:00
Islon Scherer
a3cc2f0ea6 Start next dev iteration 2025-07-24 20:06:01 +02:00
Islon Scherer
e12c655f5c Prepare 0.29.0 release 2025-07-24 20:06:01 +02:00
Daniel Chao
efee9f3801 Disable publishing jpkl (#1147)
This is causing a breakage in our release pipeline right now.
2025-07-24 10:04:46 -07:00
Daniel Chao
8e88133248 Disable publishing native executables to Maven Central (#1146)
Attempts to publish these artifacts is resulting in errors like
"No Archiver found for the stream signature"

Also, add to release notes
2025-07-24 09:21:02 -07:00
Daniel Chao
b38b15ba71 Remove duplicate block ids (#1145)
We can't repeat these block ids multiple times in the same page.
2025-07-24 17:19:29 +02:00
Daniel Chao
1c4fbe7c1c Fix: use http.rewrites to configure the evaluator in message passing API (#1141)
This is a bugfix, where the `rewrites` option is currently ignored.

Also: return any illegal argument errors from creating the evaluator as
an error in the CreateEvaluatorResponse
2025-07-24 07:30:31 -07:00
Daniel Chao
ae046a804b Add release notes for 0.29 (#1140)
Co-authored-by: Jen Basch <421772+HT154@users.noreply.github.com>
2025-07-24 07:30:04 -07:00
Daniel Chao
53f6951d81 Add bytesType to pkl:reflect (#1144)
Just like other data types on the base module, the mirror for `Bytes`
should be available directly on `pkl:reflect`.
2025-07-24 06:21:10 -07:00
Daniel Chao
7c8c4438d5 Defer noProxy to settings.pkl or PklProject if not set explicitly (#1143)
Fixes an issue where `http.noProxy` settings are ignored.
2025-07-23 10:57:31 -07:00
Daniel Chao
bdf6aa6b60 Un-deprecate Resource.base64, compute bytes/base64 in terms of each other (#1138)
This makes changes to avoid a needless breaking change.
It preserves code like `new Resource { base64 = someValue }.sha256`,
and also code that renders `Resource` into static formats.

Co-authored-by: Islon Scherer <islonscherer@gmail.com>
2025-07-23 06:25:49 -07:00
Daniel Chao
03d8e01801 Bump GraalVM JDK version to 21.0.8 (#1139) 2025-07-23 05:22:17 -07:00
Jen Basch
85e4f133a4 Add getOrDefault method to Listing and Mapping (#1053)
This PR adds methods to Listing and Mapping that can be used to retrieve members. If the member for the index/key isn't present, it applies default to the index/key. In both cases, this is essentially sugar for getOrNull(<index/key>) ?? default.apply(<index/key>).

Co-authored-by: Daniel Chao <daniel.h.chao@gmail.com>
2025-07-22 15:45:49 -07:00
Daniel Chao
306a3b0fc2 Polish http rewrites (#1133)
* Polish rewrite docs
* Add documentation comments, add missing evaluator options
* Add ability to set HTTP builder in ConfigEvaluatorBuilder
* Add ability to set rewrites in executor API
2025-07-22 15:42:07 -07:00
Daniel Chao
fe064960b4 Bump Gradle to 8.14.3 (#1129) 2025-07-18 11:03:38 -07:00
Daniel Chao
6cd73227a1 Update dependencies (#1128) 2025-07-18 09:29:44 -07:00
Islon Scherer
ba82c5c6d6 Only allow shebangs in the beginning of a module (#1126) 2025-07-18 11:18:45 +02:00
Daniel Chao
decb4ea66e Improve message passing api docs (#1127)
1. Change `Binary` to `Bytes` (new type representing binary data)
2. Add documentation for `http.rewrites` option
2025-07-17 07:57:48 -07:00
Daniel Chao
99020bb79d Add support for HTTP rewrites (#1062)
This adds a new configuration option for the HTTP client to replace URI prefixes when making outbound calls.

Follows the design of https://github.com/apple/pkl-evolution/pull/17
2025-07-16 15:53:31 -07:00
Daniel Chao
fea031a138 Switch publishing to sonatype central (#1121)
OSSRH is now EOL, so we need to publish to this new repository.
2025-07-11 05:48:31 -07:00
Daniel Chao
48ad4386c8 Add Kotlin support for "addGeneratedAnnotation" flag (#1115)
This adds logic so that the Kotlin code generator also supports the
"addGeneratedAnnotation" flag.

Also:
* Add Antora documentation
* Adjust names (generated-annotation -> add-generated-annotation)
* Adjust doc comments
2025-07-08 14:05:15 -07:00
Islon Scherer
3a35be6311 Remove ANTLR from the repo (#1114) 2025-07-08 09:43:35 +02:00
André Rouél
0973774a5d Add @Generated annotation to generated Java types (#1075)
JaCoCo automatically excludes methods and classes annotated with @Generated from the coverage reports. This is very important to us as generated code should not normally be included in the coverage report. We want to measure the coverage of the code that we actually wrote and maintain, not the code that was automatically generated by tools.

By introducing a property generatedAnnotation (default value false) one could enable writing @Generated on Java types to be generated.

Co-authored-by: Nullpointer <mike.schulze@tealium.com>
2025-07-07 15:31:49 -07:00
Jen Basch
dbf57280ba Fix crash due to parse error in module header (#1112) 2025-07-01 10:05:16 +02:00
Artem Yarmoliuk
f1388ffb2f Don't show 100% when number of failures is rounded up (#1110)
Co-Authored-By: Mike Drob <mdrob@apple.com>
2025-06-27 15:29:26 +02:00
Daniel Chao
d6fd7e0942 Fix native build (#1099)
* Add truffle boundaries
* Fix snippet output tests
* Make java LanguageSnippetTests eval output.bytes, just like the CLI does
2025-06-17 08:42:49 -07:00
Daniel Chao
e9320557b7 Introduces Bytes class (#1019)
This introduces a new `Bytes` standard library class, for working with
binary data.

* Add Bytes class to the standard library
* Change CLI to eval `output.bytes`
* Change code generators to map Bytes to respective underlying type
* Add subscript and concat operator support
* Add binary encoding for Bytes
* Add PCF and Plist rendering for Bytes

Co-authored-by: Kushal Pisavadia <kushi.p@gmail.com>
2025-06-11 16:23:55 -07:00
Artem Yarmoliuk
3bd8a88506 Aggregate junit report into one file (#1056)
Some systems require junit report to be in a single file. For example `bazel` https://bazel.build/reference/test-encyclopedia needs single file to be available in `XML_OUTPUT_FILE` path.

To avoid implementing junit aggregation in pkl wrappers in different places this PR instead adds a `--junit-aggregate-reports` flag to return all junit reports as a single file.

Additional flag `--junit-aggregate-suite-name` is added to allow overriding global test suite name from default `pkl-tests`
2025-06-06 17:33:13 -07:00
Daniel Chao
0b0f3b131d Add ResourceReaders#fromServiceProviders to preconfigured evaluator (#1094)
The preconfigured evaluator currently adds module key factories from
service providers, but not resource readers.

This means that users of pkl-spring, for example, cannot add custom
resource readers.
This is also inconsistent (in the preconfigured evaluator, `import` can
 use custom schemes, but not `read`).
2025-06-06 17:26:38 -07:00
Daniel Chao
568c6ccbc2 Update dependencies, and clean up multi-JDK testing (#1088)
* Update dependencies
  1. Remove */gradle.lockfile files
  2. Run `gradle updateDependencyLocks` and commit
* Update multi-JDK testing to use simple Test task, add junit-platform-launcher to dependencies
  - Don't use JvmTestSuite (we don't use another test runner, we use the same classpath)
* Add junit-platform-launcher to libs (prevent an issue where junit-engine and junit-launcher can fall out of sync)
2025-06-04 08:30:02 -07:00
Daniel Chao
dd9800c70a Update Gradle to 8.14.1 (#1091) 2025-06-04 08:28:52 -07:00
Daniel Chao
2bc9c2f424 Treat opaque file URIs as errors (#1087)
Opaque file URIs are URIs whose scheme-specific part does not start with `/`.
For example, `file:foo/bar.txt` is an opaque URI.

Currently, this has the unintentional behavior of: look for file `foo/bar.txt` from the process working directory.
These are effectively dynamics imports; from a single import, we can't statically analyze what it resolves as.

According to RFC-8089, File URIs must have paths that start with `/`. So, these are actually _not valid URIs_.
See the grammar defined in https://datatracker.ietf.org/doc/html/rfc8089#section-2

This changes Pkl's behavior so that these URIs are treated as errors.
2025-06-03 14:57:22 -07:00
Daniel Chao
4eeb61dc74 Fix multi-jdk testing setup (#1086)
This changes the Gradle build to always create multi-jdk tasks,
and instead use the `enabled` property to determine whether the task
is actually ran or not.

The has the following benefits:
* IntelliJ and other tools understand the task execution graph (e.g. testJdk20 shows up as a task)
* JDK-specific Gradle configurations always exist, so `updateDependencyLocks` is consistent.
2025-06-03 08:56:02 -07:00