Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/create-cherry-pick-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ jobs:
run: git switch --detach "origin/$TARGET_BRANCH"
- run: npm ci
- uses: azure/login@a641126d1b8aa4d1fa005f4f92df94a3a4c4c906 # v3.1.0
if: ${{ !cancelled() }}
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
- name: Create GitHub App token
if: ${{ !cancelled() }}
id: app-token
uses: microsoft/create-github-app-token-via-key-vault@5ba0d436e9c3cac52feff4d1f2f66f9698ce4a2d # v1
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/new-release-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,13 @@ jobs:
git config core.hooksPath /dev/null
git commit -m "Bump version to $PACKAGE_VERSION"
- uses: azure/login@a641126d1b8aa4d1fa005f4f92df94a3a4c4c906 # v3.1.0
if: ${{ !cancelled() }}
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
- name: Create GitHub App token
if: ${{ !cancelled() }}
id: app-token
uses: microsoft/create-github-app-token-via-key-vault@5ba0d436e9c3cac52feff4d1f2f66f9698ce4a2d # v1
with:
Expand All @@ -121,6 +123,7 @@ jobs:
owner: microsoft
repositories: TypeScript
permission-contents: write
permission-issues: write
- name: Configure git for GitHub App token
env:
GITHUB_APP_TOKEN: ${{ steps.app-token.outputs.token }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/set-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,13 @@ jobs:
git config core.hooksPath /dev/null
git commit -m "Bump version to $PACKAGE_VERSION"
- uses: azure/login@a641126d1b8aa4d1fa005f4f92df94a3a4c4c906 # v3.1.0
if: ${{ !cancelled() }}
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
- name: Create GitHub App token
if: ${{ !cancelled() }}
id: app-token
uses: microsoft/create-github-app-token-via-key-vault@5ba0d436e9c3cac52feff4d1f2f66f9698ce4a2d # v1
with:
Expand All @@ -138,6 +140,7 @@ jobs:
owner: microsoft
repositories: TypeScript
permission-contents: write
permission-issues: write
- name: Configure git for GitHub App token
if: steps.configure.outputs.changed == 'true'
env:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/sync-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,13 @@ jobs:
exit 1
fi
- uses: azure/login@a641126d1b8aa4d1fa005f4f92df94a3a4c4c906 # v3.1.0
if: ${{ !cancelled() }}
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
- name: Create GitHub App token
if: ${{ !cancelled() }}
id: app-token
uses: microsoft/create-github-app-token-via-key-vault@5ba0d436e9c3cac52feff4d1f2f66f9698ce4a2d # v1
with:
Expand All @@ -129,6 +131,7 @@ jobs:
owner: microsoft
repositories: TypeScript
permission-contents: write
permission-issues: write
- name: Configure git for GitHub App token
env:
GITHUB_APP_TOKEN: ${{ steps.app-token.outputs.token }}
Expand Down
14 changes: 12 additions & 2 deletions tsc/internal/execute/tsctests/sys.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,12 +485,22 @@ var (

func (o *outputSanitizer) addOutputLine(s string) {
s = strings.ReplaceAll(s, fmt.Sprintf("'%s'", core.Version()), fmt.Sprintf("'%s'", harnessutil.FakeTSVersion))
s = strings.ReplaceAll(s, englishVersion, fakeEnglishVersion)
s = strings.ReplaceAll(s, czechVersion, fakeCzechVersion)
s = sanitizeVersion(s, englishVersion, fakeEnglishVersion)
s = sanitizeVersion(s, czechVersion, fakeCzechVersion)
s = fsbaselineutil.SanitizeInternalSymbolName(s)
o.outputLines = append(o.outputLines, s)
}

func sanitizeVersion(s string, version string, replacement string) string {
if before, after, ok := strings.Cut(s, version); ok && strings.HasPrefix(after, " ") {
// Preserve the padded field width when replacing the version in the help header.
suffix := strings.TrimLeft(after, " ")
width := len(version) + len(after) - len(suffix)
s = before + fmt.Sprintf("%-*s", width, replacement) + suffix
}
return strings.ReplaceAll(s, version, replacement)
}

func (o *outputSanitizer) sanitizeBuildStatusTimeStamp() string {
statusLine := o.lines[o.index]
hhSeparator := strings.IndexRune(statusLine, ':')
Expand Down
43 changes: 43 additions & 0 deletions tsc/internal/execute/tsctests/tsc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,54 @@ import (
"testing"

"github.com/microsoft/TypeScript/tsc/internal/core"
"github.com/microsoft/TypeScript/tsc/internal/diagnostics"
"github.com/microsoft/TypeScript/tsc/internal/locale"
"github.com/microsoft/TypeScript/tsc/internal/testutil/contentmappertest"
"github.com/microsoft/TypeScript/tsc/internal/testutil/harnessutil"
"github.com/microsoft/TypeScript/tsc/internal/testutil/stringtestutil"
"github.com/microsoft/TypeScript/tsc/internal/vfs/vfstest"
"gotest.tools/v3/assert"
)

func TestOutputSanitizerVersionPadding(t *testing.T) {
t.Parallel()
for name, language := range map[string]locale.Locale{"en": locale.Default, "cs": czech} {
t.Run(name, func(t *testing.T) {
t.Parallel()
version := diagnostics.Version_0.Localize(language, core.Version())
fakeVersion := diagnostics.Version_0.Localize(language, harnessutil.FakeTSVersion)
header := diagnostics.X_tsc_Colon_The_TypeScript_Compiler.Localize(language) + " - "
for _, test := range []struct {
name string
input string
want string
}{
{name: "version", input: version, want: fakeVersion},
{name: "version in prose", input: version + " is installed", want: fakeVersion + " is installed"},
{name: "repeated versions", input: version + ", " + version, want: fakeVersion + ", " + fakeVersion},
{name: "header without logo", input: header + version, want: header + fakeVersion},
{
name: "header with logo",
input: fmt.Sprintf("%-115s\x1b[44m \x1b[39;49m", header+version),
want: fmt.Sprintf("%-115s\x1b[44m \x1b[39;49m", header+fakeVersion),
},
{
name: "narrow header with logo",
input: fmt.Sprintf("%-75s\x1b[44m \x1b[39;49m", header+version),
want: fmt.Sprintf("%-75s\x1b[44m \x1b[39;49m", header+fakeVersion),
},
} {
t.Run(test.name, func(t *testing.T) {
t.Parallel()
sanitizer := &outputSanitizer{}
sanitizer.addOutputLine(test.input)
assert.Equal(t, strings.Join(sanitizer.outputLines, "\n"), test.want)
})
}
})
}
}

func TestTscCommandline(t *testing.T) {
t.Parallel()
colorTest := func(subScenario string, env map[string]string, outputIsTTY bool) *tscInput {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ tsgo
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
Version FakeTSVersion
tsc: The TypeScript Compiler - Version FakeTSVersion  
tsc: The TypeScript Compiler - Version FakeTSVersion  
 TS 
COMMON COMMANDS

Expand Down
Loading