Skip to content

Commit 2ac1c0f

Browse files
Merge branch 'master' of https://github.com/rokucommunity/brighterscript into ast-to-string
2 parents 17b5e8d + 8d6a4db commit 2ac1c0f

File tree

209 files changed

+43919
-16998
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

209 files changed

+43919
-16998
lines changed

.eslintrc.js

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,21 @@ module.exports = {
1313
plugins: [
1414
'@typescript-eslint',
1515
'no-only-tests',
16-
'jsdoc'
16+
'jsdoc',
17+
'import'
1718
],
1819
extends: [
1920
'eslint:all',
2021
'plugin:@typescript-eslint/all',
21-
'plugin:jsdoc/recommended'
22+
'plugin:jsdoc/recommended',
23+
'plugin:import/typescript'
2224
],
25+
settings: {
26+
'import/resolver': {
27+
typescript: true,
28+
node: true
29+
}
30+
},
2331
rules: {
2432
'@typescript-eslint/array-type': 'off',
2533
'@typescript-eslint/consistent-type-assertions': 'off',
@@ -42,6 +50,7 @@ module.exports = {
4250
'@typescript-eslint/no-implicit-any-catch': 'off',
4351
'@typescript-eslint/no-invalid-this': 'off',
4452
'@typescript-eslint/no-magic-numbers': 'off',
53+
'@typescript-eslint/no-non-null-assertion': 'off',
4554
'@typescript-eslint/no-parameter-properties': 'off',
4655
//had to add this rule to prevent eslint from crashing
4756
'@typescript-eslint/no-restricted-imports': ['off', {}],
@@ -55,12 +64,12 @@ module.exports = {
5564
'@typescript-eslint/no-shadow': 'off',
5665
'@typescript-eslint/no-this-alias': 'off',
5766
//possibly disable this once we have converted all throw statements to actual errors
58-
'@typescript-eslint/no-throw-literal': 'off',
5967
'@typescript-eslint/no-invalid-void': 'off',
6068
'@typescript-eslint/no-invalid-void-type': 'off',
6169
'@typescript-eslint/no-type-alias': 'off',
6270
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off',
6371
'@typescript-eslint/no-unnecessary-condition': 'off',
72+
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
6473
'@typescript-eslint/no-unsafe-assignment': 'off',
6574
'@typescript-eslint/no-unsafe-call': 'off',
6675
'@typescript-eslint/no-unsafe-member-access': 'off',
@@ -116,6 +125,9 @@ module.exports = {
116125
'getter-return': 'off',
117126
'guard-for-in': 'off',
118127
'id-length': 'off',
128+
'import/no-extraneous-dependencies': ['error', {
129+
'devDependencies': ['**/*.spec.ts']
130+
}],
119131
'indent': 'off',
120132
'init-declarations': 'off',
121133
'line-comment-position': 'off',
@@ -208,6 +220,8 @@ module.exports = {
208220
'@typescript-eslint/no-unused-vars-experimental': 'off',
209221
'@typescript-eslint/dot-notation': 'off',
210222
'@typescript-eslint/no-unsafe-argument': 'off',
223+
'import/no-extraneous-dependencies': 'off',
224+
'func-names': 'off',
211225
'new-cap': 'off',
212226
'no-shadow': 'off',
213227
'no-void': 'off'
@@ -227,12 +241,23 @@ module.exports = {
227241
'eol-last': 'off',
228242
'@typescript-eslint/semi': 'off'
229243
}
230-
}, {
244+
},
245+
{
231246
files: ['scripts/**/*.ts'],
232247
rules: {
233248
'@typescript-eslint/no-var-requires': 'off',
234249
'@typescript-eslint/no-require-imports': 'off',
235250
'camelcase': 'off'
236251
}
252+
},
253+
{
254+
files: ['benchmarks/**/*.ts'],
255+
rules: {
256+
'@typescript-eslint/dot-notation': 'off',
257+
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
258+
'@typescript-eslint/no-non-null-assertion': 'off',
259+
'no-var': 'off',
260+
'camelcase': 'off'
261+
}
237262
}]
238263
};

.github/copilot-instructions.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# BrighterScript - Copilot Instructions
2+
3+
Compiler (written in TypeScript) to transform BrighterScript (a superset of Roku's BrightScript) into valid BrightScript code.
4+
5+
## Architecture
6+
- **Core**: Lexer → Parser → AST → Compiler
7+
- **Patterns**: Visitor pattern for AST traversal, plugin-based extensibility
8+
- **Key Classes**: `Program`, `Scope`, `Parser`, `Lexer`, `BrsFile`, `XmlFile`
9+
- **Language Server**: Implements LSP for IDE features like autocompletion, diagnostics, and code navigation
10+
11+
## Code Style
12+
- TypeScript strict mode, PascalCase for classes, camelCase for variables
13+
- `.spec.ts` for tests adjacent to source files
14+
- Use `Diagnostic` class for errors/warnings with source locations
15+
16+
## Key Directories
17+
- `src/parser/` - Parser and AST nodes
18+
- `src/lexer/` - Tokenization
19+
- `src/files/` - File handlers
20+
- `src/lsp/` - Language server
21+
- `src/astUtils/` - AST manipulation utilities
22+
23+
## Common Patterns
24+
- Use `AstEditor` for safe AST modifications in plugins
25+
- Visitor pattern for AST traversal (`astUtils/visitors`)
26+
- Plugin system via `PluginInterface`
27+
- Error recovery in parser for IDE experience
28+
29+
## Build Commands
30+
- `npm run build` - Build project
31+
- `npm run test:nocover` - Run tests without coverage but correct source maps
32+
- `npm run lint` - Run ESLint
33+
34+
## Notes
35+
- Transpiled code must be valid BrightScript syntax that runs on Roku devices
36+
- BrighterScript is superset of BrightScript
37+
- Performance-critical: optimize AST traversal and caching

.github/workflows/build.yml

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ on:
33
push:
44
branches:
55
- master
6-
tags:
7-
- v*
86
pull_request:
97

108
jobs:
@@ -20,53 +18,12 @@ jobs:
2018
- uses: actions/checkout@master
2119
- uses: actions/setup-node@master
2220
with:
23-
node-version: "14.18.1"
21+
node-version: "16.20.2"
22+
architecture: 'x64' # fix for macos-latest
2423
- run: npm ci
2524
- run: npm run build
2625
- run: npm run lint
2726
- run: npm run test
2827
- run: npm run publish-coverage
29-
- run: npm run test-related-projects
30-
npm-release:
31-
#only run this task if a tag starting with 'v' was used to trigger this (i.e. a tagged release)
32-
if: startsWith(github.ref, 'refs/tags/v')
33-
needs: ci
34-
runs-on: ubuntu-latest
35-
env:
36-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
37-
steps:
38-
- uses: actions/checkout@master
39-
- uses: actions/setup-node@master
40-
with:
41-
node-version: "14.18.1"
42-
- run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ./.npmrc
43-
- run: npm ci
44-
- run: npm run build
45-
#create npm package
46-
- run: npm pack
47-
- run: npm run test-related-projects
48-
49-
#create GitHub release
50-
- name: Create GitHub Release
51-
id: create_release
52-
uses: actions/create-release@latest
53-
env:
54-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55-
with:
56-
tag_name: ${{ github.ref }}
57-
release_name: ${{ github.ref }}
58-
draft: false
59-
prerelease: false #contains(github.ref, '-beta.') == true
60-
61-
#upload package to GitHub release
62-
- name: Upload GitHub Release Assets
63-
uses: alexellis/upload-assets@0.2.3
64-
env:
65-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66-
with:
67-
asset_paths: '["./*.tgz"]'
68-
69-
#If there's a dash followed by an alpha character, this is a prerelease and should be tagged "next". Otherwise tag as "latest"
70-
- run: if [[ "${{ github.ref }}" =~ -[a-zA-Z] ]]; then echo "DIST_TAG=next" >> $GITHUB_ENV; else echo "DIST_TAG=latest" >> $GITHUB_ENV; fi
71-
#upload to npm
72-
- run: npm publish --tag ${{env.DIST_TAG}}
28+
# this is stalling out for some reason, so disable it for now
29+
#- run: npm run test-related-projects
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: "Copilot Setup Steps"
2+
3+
# Automatically run the setup steps when they are changed to allow for easy validation, and
4+
# allow manual testing through the repository's "Actions" tab
5+
on:
6+
workflow_dispatch:
7+
push:
8+
branches:
9+
- master
10+
paths:
11+
- .github/workflows/copilot-setup-steps.yml
12+
pull_request:
13+
paths:
14+
- .github/workflows/copilot-setup-steps.yml
15+
16+
jobs:
17+
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
18+
copilot-setup-steps:
19+
runs-on: ubuntu-latest
20+
21+
# Set the permissions to the lowest permissions possible needed for your steps.
22+
# Copilot will be given its own token for its operations.
23+
permissions:
24+
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
25+
contents: read
26+
27+
# You can define any steps you want, and they will run before the agent starts.
28+
# If you do not check out your code, Copilot will do this for you.
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v4
32+
33+
- name: Set up Node.js
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: "16.20.2"
37+
cache: "npm"
38+
39+
- name: Install JavaScript dependencies
40+
run: npm install
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: create-package
2+
on:
3+
pull_request:
4+
types: [labeled, unlabeled, synchronize]
5+
jobs:
6+
create-package:
7+
runs-on: ubuntu-latest
8+
if: contains(github.event.pull_request.labels.*.name, 'create-package')
9+
env:
10+
GH_TOKEN: ${{ github.token }}
11+
steps:
12+
- uses: actions/checkout@master
13+
- uses: actions/setup-node@master
14+
with:
15+
node-version: "16.20.2"
16+
# Get a bot token so the bot's name shows up on all our actions
17+
- name: Get Token From roku-ci-token Application
18+
uses: tibdex/github-app-token@v1
19+
id: generate-token
20+
with:
21+
app_id: ${{ secrets.BOT_APP_ID }}
22+
private_key: ${{ secrets.BOT_PRIVATE_KEY }}
23+
- run: echo "TOKEN=${{ steps.generate-token.outputs.token }}" >> $GITHUB_ENV
24+
- name: Compute variables
25+
run: |
26+
CURRENT_VERSION=$(grep -o '\"version\": *\"[^\"]*\"' package.json | awk -F'\"' '{print $4}')
27+
SANITIZED_BRANCH_NAME=$(echo "$GITHUB_HEAD_REF" | sed 's/[^0-9a-zA-Z-]/-/g')
28+
BUILD_VERSION="$CURRENT_VERSION-$SANITIZED_BRANCH_NAME.$(date +%Y%m%d%H%M%S)"
29+
NPM_PACKAGE_NAME=$(grep -o '\"name\": *\"[^\"]*\"' package.json | awk -F'\"' '{print $4}' | sed -e 's/@//g' -e 's#/#-#g')
30+
ARTIFACT_NAME=$(echo "$NPM_PACKAGE_NAME-$BUILD_VERSION.tgz" | tr '/' '-')
31+
ARTIFACT_URL="${{ github.server_url }}/${{ github.repository }}/releases/download/v0.0.0-packages/${ARTIFACT_NAME}"
32+
33+
echo "BUILD_VERSION=$BUILD_VERSION" >> $GITHUB_ENV
34+
echo "ARTIFACT_URL=$ARTIFACT_URL" >> $GITHUB_ENV
35+
36+
- run: npm ci
37+
- run: npm version "$BUILD_VERSION" --no-git-tag-version
38+
- run: npm pack
39+
40+
# create the release if not exist
41+
- run: gh release create v0.0.0-packages --title "v0.0.0-packages" --latest=false --prerelease --notes "catchall release for temp packages" -R ${{ github.repository }}
42+
continue-on-error: true
43+
44+
# upload this artifact to the "packages" github release
45+
- run: gh release upload v0.0.0-packages *.tgz -R ${{ github.repository }}
46+
47+
- name: Fetch build artifact
48+
uses: actions/github-script@v7
49+
with:
50+
github-token: ${{ env.TOKEN }}
51+
script: |
52+
return github.rest.issues.createComment({
53+
issue_number: context.issue.number,
54+
owner: context.repo.owner,
55+
repo: context.repo.repo,
56+
body: "Hey there! I just built a new temporary npm package based on ${{ github.event.pull_request.head.sha }}. You can download it [here](${{ env.ARTIFACT_URL }}) or install it by running the following command: \n```bash\nnpm install ${{ env.ARTIFACT_URL }}\n```"
57+
});
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Initialize Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
branch:
7+
type: string
8+
description: "Create release from this branch:"
9+
default: "master"
10+
required: true
11+
releaseType:
12+
type: choice
13+
description: "Release type:"
14+
required: true
15+
default: "patch"
16+
options:
17+
- major
18+
- minor
19+
- patch
20+
- prerelease
21+
customVersion:
22+
type: string
23+
description: "Version override: (ignore release type)"
24+
default: ""
25+
required: false
26+
installDependencies:
27+
type: boolean
28+
description: "Install latest RokuCommunity dependencies"
29+
required: true
30+
default: true
31+
32+
jobs:
33+
run:
34+
uses: rokucommunity/workflows/.github/workflows/initialize-release.yml@master
35+
with:
36+
branch: ${{ github.event.inputs.branch }}
37+
releaseType: ${{ github.event.inputs.releaseType }}
38+
customVersion: ${{ github.event.inputs.customVersion }}
39+
installDependencies: ${{ github.event.inputs.installDependencies }}
40+
secrets: inherit
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Make Release Artifacts
2+
3+
on:
4+
pull_request:
5+
types:
6+
- reopened
7+
- opened
8+
- synchronize
9+
workflow_dispatch:
10+
inputs:
11+
tag:
12+
type: string
13+
description: 'The release tag that should be referenced (i.e. `v1.2.3`)'
14+
required: true
15+
force:
16+
type: boolean
17+
description: 'Force the release artifacts to be created and uploaded'
18+
required: false
19+
default: false
20+
21+
jobs:
22+
run:
23+
if: github.event_name == 'workflow_dispatch' || startsWith( github.head_ref, 'release/')
24+
uses: rokucommunity/workflows/.github/workflows/make-release-artifacts.yml@master
25+
with:
26+
branch: ${{ github.event.inputs.tag || github.event.pull_request.head.ref }}
27+
node-version: "16.20.2"
28+
artifact-paths: "./*.tgz" # "*.vsix"
29+
force: ${{ github.event.inputs.force == 'true' }}
30+
secrets: inherit
31+
32+
success-or-skip:
33+
if: always()
34+
needs: [run]
35+
runs-on: ubuntu-latest
36+
steps:
37+
- run: if [ "${{ needs.run.result }}" = "failure" ]; then exit 1; fi
38+

0 commit comments

Comments
 (0)