Skip to content

Commit a48a2a9

Browse files
nayeemrmnnathanwhitdsherret
authored andcommitted
Deno changes rebased from 383c1a6
Co-authored-by: nathanwhit <nathanwhit@users.noreply.github.com> Co-authored-by: dsherret <dsherret@users.noreply.github.com>
1 parent 6e1e2c2 commit a48a2a9

Some content is hidden

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

54 files changed

+2394
-776
lines changed

.github/workflows/ci.yml

Lines changed: 349 additions & 349 deletions
Large diffs are not rendered by default.

.github/workflows/create-cache.yml

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
1-
name: Create CI cache
2-
3-
on:
4-
workflow_dispatch:
5-
push:
6-
branches:
7-
- main
8-
schedule:
9-
# Run every day at 10:00 UTC / 03:00 PST
10-
- cron: '0 10 * * *'
11-
12-
permissions:
13-
contents: read
14-
15-
# Ensure scripts are run with pipefail. See:
16-
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
17-
defaults:
18-
run:
19-
shell: bash
20-
21-
jobs:
22-
cache:
23-
if: github.repository == 'microsoft/typescript-go'
24-
25-
strategy:
26-
fail-fast: false
27-
matrix:
28-
os:
29-
- ubuntu-latest
30-
- windows-latest
31-
- macos-latest
32-
33-
runs-on: ${{ matrix.os }}
34-
35-
steps:
36-
- uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
37-
with:
38-
large-packages: false
39-
docker-images: false
40-
swap-storage: false
41-
dotnet: false
42-
43-
- run: git config --system core.longpaths true
44-
if: ${{ matrix.os == 'windows-latest' }}
45-
46-
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
47-
with:
48-
submodules: true
49-
- uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
50-
- uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
51-
52-
- uses: ./.github/actions/setup-go
53-
with:
54-
create: 'true'
1+
# name: Create CI cache
2+
3+
# on:
4+
# workflow_dispatch:
5+
# push:
6+
# branches:
7+
# - main
8+
# schedule:
9+
# # Run every day at 10:00 UTC / 03:00 PST
10+
# - cron: '0 10 * * *'
11+
12+
# permissions:
13+
# contents: read
14+
15+
# # Ensure scripts are run with pipefail. See:
16+
# # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
17+
# defaults:
18+
# run:
19+
# shell: bash
20+
21+
# jobs:
22+
# cache:
23+
# if: github.repository == 'microsoft/typescript-go'
24+
25+
# strategy:
26+
# fail-fast: false
27+
# matrix:
28+
# os:
29+
# - ubuntu-latest
30+
# - windows-latest
31+
# - macos-latest
32+
33+
# runs-on: ${{ matrix.os }}
34+
35+
# steps:
36+
# - uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
37+
# with:
38+
# large-packages: false
39+
# docker-images: false
40+
# swap-storage: false
41+
# dotnet: false
42+
43+
# - run: git config --system core.longpaths true
44+
# if: ${{ matrix.os == 'windows-latest' }}
45+
46+
# - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
47+
# with:
48+
# submodules: true
49+
# - uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
50+
# - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
51+
52+
# - uses: ./.github/actions/setup-go
53+
# with:
54+
# create: 'true'

.github/workflows/release.yml

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
defaults:
12+
run:
13+
shell: bash
14+
15+
jobs:
16+
build:
17+
name: Build ${{ matrix.archive_suffix }}
18+
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- goos: linux
24+
goarch: amd64
25+
archive_suffix: linux-x64
26+
binary_name: tsgo
27+
- goos: linux
28+
goarch: arm64
29+
archive_suffix: linux-arm64
30+
binary_name: tsgo
31+
- goos: darwin
32+
goarch: amd64
33+
archive_suffix: macos-x64
34+
binary_name: tsgo
35+
- goos: darwin
36+
goarch: arm64
37+
archive_suffix: macos-arm64
38+
binary_name: tsgo
39+
- goos: windows
40+
goarch: amd64
41+
archive_suffix: windows-x64
42+
binary_name: tsgo.exe
43+
44+
steps:
45+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
46+
47+
- uses: ./.github/actions/setup-go
48+
49+
- name: Determine version
50+
id: version
51+
run: |
52+
VERSION="${GITHUB_REF_NAME#v}"
53+
echo "version=$VERSION" >> $GITHUB_OUTPUT
54+
echo "VERSION=$VERSION" >> $GITHUB_ENV
55+
56+
- name: Build release archive
57+
id: package
58+
env:
59+
GOOS: ${{ matrix.goos }}
60+
GOARCH: ${{ matrix.goarch }}
61+
CGO_ENABLED: 0
62+
run: |
63+
set -euo pipefail
64+
65+
VERSION="${VERSION:?}"
66+
TARGET="typescript-go-${VERSION}-${{ matrix.archive_suffix }}"
67+
OUT_DIR="dist/${TARGET}"
68+
BIN_NAME="${{ matrix.binary_name }}"
69+
70+
mkdir -p "$OUT_DIR"
71+
72+
go build \
73+
-trimpath \
74+
-tags "noembed,release" \
75+
-ldflags "-s -w -X github.com/microsoft/typescript-go/internal/core.version=${VERSION}" \
76+
-o "$OUT_DIR/$BIN_NAME" \
77+
./cmd/tsgo
78+
79+
cp LICENSE "$OUT_DIR/"
80+
cp NOTICE.txt "$OUT_DIR/"
81+
82+
ARCHIVE_NAME="${TARGET}.zip"
83+
mkdir -p artifacts
84+
zip -9 -j "artifacts/${ARCHIVE_NAME}" "$OUT_DIR"/*
85+
86+
echo "archive-path=artifacts/${ARCHIVE_NAME}" >> "$GITHUB_OUTPUT"
87+
88+
- name: Upload release artifact
89+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
90+
with:
91+
name: tsgo-${{ matrix.archive_suffix }}-${{ steps.version.outputs.version }}
92+
path: ${{ steps.package.outputs.archive-path }}
93+
94+
publish:
95+
needs: build
96+
runs-on: ubuntu-latest
97+
steps:
98+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
99+
100+
- name: Download build artifacts
101+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
102+
with:
103+
path: release
104+
merge-multiple: true
105+
106+
- name: Create source archive
107+
run: |
108+
set -euo pipefail
109+
110+
RAW_TAG="${GITHUB_REF_NAME}"
111+
VERSION="${RAW_TAG#v}"
112+
ARCHIVE_FOLDER="typescript-go-${VERSION}"
113+
ARCHIVE_NAME="${ARCHIVE_FOLDER}-source.zip"
114+
TMP_DIR="$(mktemp -d)"
115+
SOURCE_DIR="${TMP_DIR}/${ARCHIVE_FOLDER}"
116+
117+
mkdir -p "${SOURCE_DIR}"
118+
119+
rsync -a \
120+
--exclude='.git/' \
121+
--exclude='release/' \
122+
--exclude='node_modules/' \
123+
--exclude='testdata/' \
124+
./ "${SOURCE_DIR}/"
125+
126+
mkdir -p release
127+
(cd "${TMP_DIR}" && zip -9 -r "${GITHUB_WORKSPACE}/release/${ARCHIVE_NAME}" "${ARCHIVE_FOLDER}")
128+
129+
- name: Create or update GitHub release
130+
env:
131+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
132+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133+
run: |
134+
set -euo pipefail
135+
136+
RAW_TAG="${GITHUB_REF_NAME}"
137+
VERSION="${RAW_TAG#v}"
138+
TITLE="TypeScript Go ${VERSION}"
139+
NOTES="Release ${VERSION}"
140+
REPO="${GITHUB_REPOSITORY}"
141+
142+
shopt -s nullglob
143+
ASSETS=(release/*.zip)
144+
if [ ${#ASSETS[@]} -eq 0 ]; then
145+
echo "No release assets found" >&2
146+
exit 1
147+
fi
148+
149+
if gh release view "$RAW_TAG" --repo "$REPO" >/dev/null 2>&1; then
150+
gh release edit "$RAW_TAG" --repo "$REPO" --title "$TITLE" --notes "$NOTES"
151+
gh release upload "$RAW_TAG" "${ASSETS[@]}" --repo "$REPO" --clobber
152+
else
153+
gh release create "$RAW_TAG" "${ASSETS[@]}" --repo "$REPO" --title "$TITLE" --notes "$NOTES" --latest --verify-tag
154+
fi

DENO_REBASE_LOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Deno Rebase Log
2+
3+
### 2025.12.16 / @nayeemrmn
4+
5+
- `git checkout <main-working-branch>`
6+
- This time it's `main`, but in the future it may be the most recent
7+
`rebase/YYYY-MM-DD` branch.
8+
- We're at commit 383c1a6b97d917bb8454d87827387f886ea0b655.
9+
- `git pull <denoland-remote> <main-working-branch>`
10+
- `git checkout -b main_squashed`
11+
- The existing changes in the fork will be squashed into one commit on this
12+
branch.
13+
- `git reset --soft <upstream-commit-last-rebased-on>`
14+
- This time it's d1be94b3c21175dac7b631f952a737a2995d59da.
15+
- ```
16+
git commit -m "Deno changes rebased from 383c1a6b97d917bb8454d87827387f886ea0b655
17+
18+
Co-authored-by: nathanwhit <nathanwhit@users.noreply.github.com>
19+
Co-authored-by: dsherret <dsherret@users.noreply.github.com>"
20+
```
21+
- The tag mentioned is the current commit from `<main-working-branch>`.
22+
- These are the authors of the changes being squashed.
23+
- `git diff <main-working-branch>`
24+
- Verify that this is empty and no changes were lost.
25+
- `git checkout -b rebase/YYYY-MM-DD`
26+
- Today's date: `rebase/2025-12-16`.
27+
- `git fetch <microsoft-remote>`
28+
- `git rebase <microsoft-remote>/main`
29+
- Resolve conflicts.
30+
- While resolving conflicts, write this log file.
31+
- `git add .`
32+
- `git rebase --continue`
33+
- `git push -u <denoland-remote> rebase/YYYY-MM-DD`
34+
- `git branch -D main_squashed`

cmd/tsgo/api.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ func runAPI(args []string) int {
2121

2222
defaultLibraryPath := bundled.LibPath()
2323

24+
logEnabled := os.Getenv("TSGO_LOG_ENABLED") == "1"
25+
2426
s := api.NewServer(&api.ServerOptions{
2527
In: os.Stdin,
2628
Out: os.Stdout,
2729
Err: os.Stderr,
2830
Cwd: *cwd,
2931
DefaultLibraryPath: defaultLibraryPath,
32+
LogEnabled: logEnabled,
3033
})
3134

3235
if err := s.Run(); err != nil && !errors.Is(err, io.EOF) {

internal/api/api.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ func (api *API) HandleRequest(ctx context.Context, method string, payload []byte
105105
return encodeJSON(core.TryMap(params.Symbols, func(symbol Handle[ast.Symbol]) (any, error) {
106106
return api.GetTypeOfSymbol(ctx, params.Project, symbol)
107107
}))
108+
case MethodGetDiagnostics:
109+
params := params.(*GetDiagnosticsParams)
110+
return encodeJSON((api.GetDiagnostics(ctx, params.Project, params.FileNames)))
108111
default:
109112
return nil, fmt.Errorf("unhandled API method %q", method)
110113
}
@@ -263,6 +266,26 @@ func (api *API) GetSourceFile(projectId Handle[project.Project], fileName string
263266
return sourceFile, nil
264267
}
265268

269+
func (api *API) GetDiagnostics(ctx context.Context, projectId Handle[project.Project], fileNames []string) ([]*ls.Diagnostic, error) {
270+
projectPath, ok := api.projects[projectId]
271+
if !ok {
272+
return nil, errors.New("project ID not found")
273+
}
274+
snapshot, release := api.session.Snapshot()
275+
defer release()
276+
project := snapshot.ProjectCollection.GetProjectByPath(projectPath)
277+
if project == nil {
278+
return nil, errors.New("project not found")
279+
}
280+
281+
languageService := ls.NewLanguageService(project.GetProgram(), snapshot)
282+
diagnostics := languageService.GetDiagnostics(ctx, fileNames)
283+
284+
api.symbolsMu.Lock()
285+
defer api.symbolsMu.Unlock()
286+
return diagnostics, nil
287+
}
288+
266289
func (api *API) releaseHandle(handle string) error {
267290
switch handle[0] {
268291
case handlePrefixProject:
@@ -317,5 +340,9 @@ func encodeJSON(v any, err error) ([]byte, error) {
317340
if err != nil {
318341
return nil, err
319342
}
320-
return json.Marshal(v)
343+
b, err := json.Marshal(v)
344+
if err != nil {
345+
return nil, err
346+
}
347+
return b, nil
321348
}

internal/api/log.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package api
2+
3+
import "github.com/microsoft/typescript-go/internal/project/logging"
4+
5+
type NoLogger struct{}
6+
7+
// SetVerbose implements logging.Logger.
8+
func (n NoLogger) SetVerbose(verbose bool) {
9+
panic("unimplemented")
10+
}
11+
12+
var _ logging.Logger = (*NoLogger)(nil)
13+
14+
func (n NoLogger) Error(msg ...any) {}
15+
func (n NoLogger) Errorf(format string, args ...any) {}
16+
func (n NoLogger) Warn(msg ...any) {}
17+
func (n NoLogger) Warnf(format string, args ...any) {}
18+
func (n NoLogger) Info(msg ...any) {}
19+
func (n NoLogger) Infof(format string, args ...any) {}
20+
func (n NoLogger) Log(msg ...any) {}
21+
func (n NoLogger) Logf(format string, args ...any) {}
22+
func (n NoLogger) Write(msg string) {}
23+
func (n NoLogger) Verbose() logging.Logger {
24+
return n
25+
}
26+
27+
func (n NoLogger) IsVerbose() bool {
28+
return false
29+
}

0 commit comments

Comments
 (0)