Skip to content

Commit

Permalink
feat: add slangroom grammar package (#196)
Browse files Browse the repository at this point in the history
* initial package structure

* change example to slangroom

* fix: scenario statement

* update makefile

* add first simple tests

* fix: add License

* fix: given have statement

* fix: send can be optional

* fix: ethereum actions

* fix: Helpers send

* update keywords list

* update Given name statement

* fix: add the possibility of having more than one scenario

* update test list

* add some others test from didroom

* add grammar test to github actions

* fix(grammar): add missing syntax.grammar.d.ts file

* chore(grammar): remove package-lock since using pnpm

* chore: add grammar to workspace

* chore(grammar): remove capital letter from package name

* chore: add test:grammar command to test grammar

* ci: update grammar test

* refactor(grammar): remove unused Makefile

* chore: add missing license headers

* chore: add grammar package acknowledgement in the readme

* chore: Give to Cesar what is to Cesar

* feat(grammar): publish npm package on main merge

* pnpm-lock ❗

---------

Co-authored-by: FilippoTrotter <[email protected]>
Co-authored-by: puria <[email protected]>
  • Loading branch information
3 people authored Aug 28, 2024
1 parent c23c584 commit 3142f3b
Show file tree
Hide file tree
Showing 21 changed files with 2,883 additions and 38 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ jobs:
while ! nc -z 0.0.0.0 8090; do echo "pocketbase not ready" && sleep 1; done
- name: 🧪 Run the tests
run: pnpm coverage
- name: 🧪 Test grammar package
run: pnpm test:grammar
- name: 📨 Setup playwright
run: |
npx playwright install
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/grammar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SPDX-FileCopyrightText: 2024 Dyne.org foundation
#
# SPDX-License-Identifier: AGPL-3.0-or-later

name: 🪶 Grammar publish

on:
push:
branches:
- main
paths: [ "grammar" ]

permissions:
contents: write
issues: write
id-token: write
pull-requests: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

jobs:

publish:
runs-on: ubuntu-latest
needs: build_and_test
if: github.ref == 'refs/heads/main'
steps:
- name: 🛠️ Prepare pnpm workspace
uses: dyne/pnpm@main
- name: 📦 Releases
working-directory: ./grammar
run: npx semantic-release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,15 @@ node_modules

# grammar lezer
!/grammar/Makefile
!/grammar/slangroom.grammar
!/grammar/src/syntax.grammar
!/grammar/src/syntax.grammar.d.ts
!/grammar/src/index.ts
!/grammar/test/*
!/grammar/.npmignore
!/grammar/package.json
!/grammar/rollup.config.js
!/grammar/tsconfig.json
!/grammar/.releaserc



4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ To write new plugins and other technical documentation head your browser to

<img alt="software by Dyne.org" src="https://files.dyne.org/software_by_dyne.png" width="150" />

Copyleft 🄯 2023—2024 by [Dyne.org](https://www.dyne.org) foundation, Amsterdam
Copyleft 🄯 2023—2024 by [Dyne.org](https://www.dyne.org) foundation, Amsterdam.

The grammar package has been created starting from [CodeMirror 6 language package template](https://github.com/codemirror/lang-example).

**[🔝 back to top](#toc)**

Expand Down
9 changes: 9 additions & 0 deletions grammar/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPDX-FileCopyrightText: 2024 Dyne.org foundation
#
# SPDX-License-Identifier: AGPL-3.0-or-later

/src
/test
/node_modules
rollup.config.js
tsconfig.json
43 changes: 43 additions & 0 deletions grammar/.releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2017-2018 Dyne.org foundation
# SPDX-FileCopyrightText: 2017-2021 Dyne.org foundation
#
# SPDX-License-Identifier: AGPL-3.0-or-later
{
"extends": ["semantic-release-commit-filter"]
"repositoryUrl": "[email protected]:dyne/slangroom.git",
"dryRun": false,
"plugins": [
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/commit-analyzer",
{
"preset": "angular",
"releaseRules": [
{ "type": "build", "scope": "deps", "release": "patch" },
{ "type": "build", "scope": "deps-dev", "release": "patch" }
]
}
],
[
"@semantic-release/npm",
{
"npmPublish": true
}
],
[
"@semantic-release/git",
{
"assets": [
"grammar/CHANGELOG.md",
"grammar/pnpm-lock.yaml",
"grammar/package.json"
],
"message": "chore(grammar release): 🚀 ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
],
"branches": [
"main"
]
}
2 changes: 0 additions & 2 deletions grammar/Makefile

This file was deleted.

47 changes: 47 additions & 0 deletions grammar/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "codemirror-lang-slangroom",
"version": "0.1.0",
"description": "Slangroom language support for CodeMirror",
"scripts": {
"test": "mocha test/test.js",
"prepare": "rollup -c"
},
"author": {
"name": "Filippo Trotter"
},
"contributors": [
{ "name": "Matteo Cristino" }
],
"publishConfig": {
"access": "public"
},
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.js",
"exports": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"types": "dist/index.d.ts",
"sideEffects": false,
"dependencies": {
"@codemirror/language": "^6.0.0",
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0"
},
"devDependencies": {
"@lezer/generator": "^1.0.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^13.0.0",
"@semantic-release/git": "^10.0.1",
"@semantic-release/npm": "^12.0.1",
"@semantic-release/release-notes-generator": "^14.0.1",
"mocha": "^9.0.1",
"rollup": "^2.60.2",
"rollup-plugin-dts": "^4.0.1",
"rollup-plugin-ts": "^3.0.2",
"semantic-release-commit-filter": "^1.0.2",
"typescript": "^4.3.4"
},
"license": "AGPL-3.0-or-later"
}
3 changes: 3 additions & 0 deletions grammar/package.json.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2024 Dyne.org foundation

SPDX-License-Identifier: AGPL-3.0-or-later
16 changes: 16 additions & 0 deletions grammar/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-FileCopyrightText: 2024 Dyne.org foundation
//
// SPDX-License-Identifier: AGPL-3.0-or-later

import typescript from "rollup-plugin-ts"
import {lezer} from "@lezer/generator/rollup"

export default {
input: "src/index.ts",
external: id => id != "tslib" && !/^(\.?\/|\w:)/.test(id),
output: [
{file: "dist/index.cjs", format: "cjs"},
{dir: "./dist", format: "es"}
],
plugins: [lezer(), typescript()]
}
34 changes: 34 additions & 0 deletions grammar/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-FileCopyrightText: 2024 Dyne.org foundation
//
// SPDX-License-Identifier: AGPL-3.0-or-later

import {parser} from "./syntax.grammar"
import {LRLanguage, LanguageSupport, indentNodeProp, foldNodeProp, foldInside, delimitedIndent} from "@codemirror/language"
import {styleTags, tags as t} from "@lezer/highlight"

export const SlangroomLanguage = LRLanguage.define({
parser: parser.configure({
props: [
indentNodeProp.add({
Application: delimitedIndent({closing: ")", align: false})
}),
foldNodeProp.add({
Application: foldInside
}),
styleTags({
Identifier: t.variableName,
Boolean: t.bool,
String: t.string,
LineComment: t.lineComment,
"( )": t.paren
})
]
}),
languageData: {
commentTokens: {line: ";"}
}
})

export function Slangroom() {
return new LanguageSupport(SlangroomLanguage)
}
Loading

0 comments on commit 3142f3b

Please sign in to comment.