@exercism/codemirror-lang-groovy 1.0.0 → 1.0.1

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 (3) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +73 -56
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.0.1
2
+
3
+ The README is restructured. This release is the first published from GitHub Actions, with npm provenance.
4
+
1
5
  ## 1.0.0
2
6
 
3
7
  This is Exercism's first release of the package, published as
package/README.md CHANGED
@@ -1,22 +1,57 @@
1
- # @exercism/codemirror-lang-groovy
2
-
3
- This is Exercism's fork of
4
- [codemirror-lang-groovy](https://github.com/codeconsole/codemirror-lang-groovy),
5
- written by Scott Murphy Heiberg. Exercism uses it for Groovy in the editor on
6
- [exercism.org](https://exercism.org). Our changes are on the `exercism` branch,
7
- and the rest of this README is upstream's, apart from the sections on
8
- completion, installing and releasing, and the package name.
9
-
10
- The fork adds:
11
-
12
- - completion for the names declared in the file (classes, methods, fields,
13
- parameters, locals, loop and closure variables, script variables and
14
- imports), offered only where each name is in scope.
15
- - snippets for methods, classes, enums, traits, `if`, loops, `switch`, `try`
16
- and closures.
17
- - completion for keywords, common classes and Groovy JDK methods. After a `.`
18
- it offers only methods. Inside strings and comments it offers nothing.
19
- - parsing of `(a, b) = [b, a]`, `f()(x)`, `list[0](x)`, `?.@` and `*.@`.
1
+ # codemirror-lang-groovy
2
+
3
+ ## Exercism's fork
4
+
5
+ This is Exercism's fork of [codemirror-lang-groovy](https://github.com/codeconsole/codemirror-lang-groovy), by Scott Murphy Heiberg.
6
+ Exercism uses it in the Groovy editor on [exercism.org](https://exercism.org).
7
+ It is published on npm as `@exercism/codemirror-lang-groovy`.
8
+ Our changes are on the `exercism` branch, and the `main` branch follows upstream.
9
+ Below this section, the README is upstream's.
10
+
11
+ The fork parses `(a, b) = [b, a]`, `f()(x)`, `list[0](x)`, `?.@` and `*.@`, and adds completion.
12
+ `groovy()` registers two completion sources, and the package exports both, along with `snippets`:
13
+
14
+ - `groovyCompletion` offers keywords, snippets, common classes and global
15
+ functions such as `println`. After a `.`, `?.` or `*.` it offers only the
16
+ methods called on a value, such as `collect` and `inject`. After `@` it
17
+ offers common annotations such as `CompileStatic`.
18
+ - `localCompletionSource` offers the names declared in the file. A parameter
19
+ is offered inside its method or closure, a local below the place that
20
+ declares it, a class member anywhere in its class, and a top level
21
+ declaration anywhere in the file. A closure with no parameters offers `it`.
22
+
23
+ Neither source offers anything inside a comment or where you declare a new name.
24
+ Inside a string, `localCompletionSource` completes `$name` and code in
25
+ `${...}`.
26
+
27
+ The completion adds a dependency on `@codemirror/autocomplete`.
28
+ If you load CodeMirror through an import map, map `@exercism/codemirror-lang-groovy` to `dist/index.js`.
29
+
30
+ ### Install
31
+
32
+ ```sh
33
+ npm install @exercism/codemirror-lang-groovy
34
+ ```
35
+
36
+ ### Building and testing
37
+
38
+ Run `npm install`, which also builds `dist/`, then `npm test`.
39
+ Upstream's Development section below lists the other scripts.
40
+ `.github/workflows/test.yml` runs the tests on Node 24 for every push to `exercism` and every pull request.
41
+
42
+ ### Releasing
43
+
44
+ 1. Update `version` in `package.json` and add a `CHANGELOG.md` entry, then commit.
45
+ 2. Tag the commit with that version and push the tag: `git tag v1.0.0 && git push origin v1.0.0`.
46
+
47
+ Pushing the tag starts `.github/workflows/publish.yml`.
48
+ The workflow checks that the tag matches `package.json`, builds the package and runs the tests.
49
+ It then publishes the package to npm as `@exercism/codemirror-lang-groovy`, using the `exercism` organisation's `NPM_TOKEN` secret.
50
+
51
+ ### Contributing
52
+
53
+ Contributions to this fork follow the Exercism [Code of Conduct](https://exercism.org/docs/using/legal/code-of-conduct).
54
+ Please read about how to [contribute to Exercism](https://exercism.org/docs/building).
20
55
 
21
56
  ---
22
57
 
@@ -32,12 +67,6 @@ real parser. The editor gets a syntax tree, which brings:
32
67
  - a tree that other extensions (autocompletion, linting, structural
33
68
  navigation) can build on.
34
69
 
35
- ## Install
36
-
37
- ```sh
38
- npm install @exercism/codemirror-lang-groovy
39
- ```
40
-
41
70
  ## Usage
42
71
 
43
72
  ```js
@@ -56,13 +85,10 @@ The package exports:
56
85
  - `groovy()`: the `LanguageSupport` to add to an editor;
57
86
  - `groovyLanguage`: the `LRLanguage`, for use with other language tooling;
58
87
  - `parser`: the Lezer parser on its own, which works without CodeMirror.
59
- - `groovyCompletion`, `localCompletionSource` and `snippets`: the
60
- completion that `groovy()` adds (see below).
61
88
 
62
- It depends only on `@codemirror/language`, `@codemirror/autocomplete`,
63
- `@lezer/lr`, `@lezer/highlight` and `@lezer/common`. When loading CodeMirror
64
- through an import map, map `@exercism/codemirror-lang-groovy` to
65
- `dist/index.js` alongside those modules.
89
+ It depends only on `@codemirror/language`, `@lezer/lr`, `@lezer/highlight` and
90
+ `@lezer/common`. When loading CodeMirror through an import map, map
91
+ `codemirror-lang-groovy` to `dist/index.js` alongside those modules.
66
92
 
67
93
  Java and Grails applications can take it from Maven Central as a WebJar,
68
94
  `org.webjars.npm:codemirror-lang-groovy`, which serves the bundle at
@@ -72,23 +98,6 @@ Java and Grails applications can take it from Maven Central as a WebJar,
72
98
  runtimeOnly "org.webjars.npm:codemirror-lang-groovy:0.1.1"
73
99
  ```
74
100
 
75
- ## Completion
76
-
77
- `groovy()` registers two completion sources, and both are exported.
78
-
79
- - `groovyCompletion` offers keywords, snippets, common classes and global
80
- functions such as `println`. After a `.`, `?.` or `*.` it offers only the
81
- methods called on a value, such as `collect` and `inject`. After `@` it
82
- offers common annotations such as `CompileStatic`.
83
- - `localCompletionSource` offers the names declared in the file. A parameter
84
- is offered inside its method or closure, a local below the place that
85
- declares it, a class member anywhere in its class, and a top level
86
- declaration anywhere in the file. A closure with no parameters offers `it`.
87
-
88
- Neither source offers anything inside a comment or a name being declared.
89
- Inside a string, `localCompletionSource` completes `$name` and code in
90
- `${...}`.
91
-
92
101
  ## What it parses
93
102
 
94
103
  The grammar starts from `@lezer/java` and adds the parts of Groovy that Java
@@ -156,8 +165,8 @@ node scripts/parse.js 'println "hi"'
156
165
  serve the repository root (for example `python3 -m http.server`) and open
157
166
  `/demo/`.
158
167
 
159
- `.github/workflows/test.yml` runs the tests on Node 24 for every push to
160
- `exercism` and every pull request.
168
+ `.github/workflows/test.yml` runs the tests on Node 22 and 24 for every push
169
+ to `main` and every pull request.
161
170
 
162
171
  Test cases live in `test/*.txt` in Lezer's test format.
163
172
  `node scripts/fill-tests.js test/<file>.txt` fills in the expected trees from
@@ -168,12 +177,20 @@ the current parser; review every changed tree before committing it.
168
177
  1. Update `version` in `package.json` and add a `CHANGELOG.md` entry, then
169
178
  commit.
170
179
  2. Tag the commit with that version and push the tag:
171
- `git tag v1.0.0 && git push origin v1.0.0`.
172
-
173
- Pushing the tag starts `.github/workflows/publish.yml`. The workflow checks that the tag
174
- matches `package.json`, builds the package and runs the tests. It then publishes the package
175
- to npm as `@exercism/codemirror-lang-groovy`, using the `exercism` organisation's `NPM_TOKEN`
176
- secret.
180
+ `git tag v0.2.0 && git push origin v0.2.0`.
181
+ 3. Approve the staged version on npmjs.com, or with
182
+ `npm stage approve <stage-id>`. npm asks for your second factor.
183
+
184
+ `.github/workflows/release.yml` checks that the tag matches `package.json`,
185
+ runs the tests and stages the version on npm. Nothing is installable until
186
+ you approve it. Once you do, the workflow has webjars.org deploy the WebJar
187
+ to Maven Central, where it can take an hour to appear. The workflow waits up
188
+ to five hours for the approval; after that, re-run its `webjar` job.
189
+
190
+ Publishing uses npm's trusted publishing, so no npm token is stored in the
191
+ repository. The package's trusted publisher on npmjs.com is GitHub Actions,
192
+ user `codeconsole`, repository `codemirror-lang-groovy`, workflow
193
+ `release.yml`, allowed to stage releases only.
177
194
 
178
195
  ## License
179
196
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exercism/codemirror-lang-groovy",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Groovy language support for CodeMirror 6, built on a Lezer grammar",
5
5
  "keywords": [
6
6
  "codemirror",