Files
vscode/build/lib/test/extensionTarget.test.ts
T
4e6997ae07 build: support platform-specific built-in extensions from GitHub releases (#324206)
* Support platform-specific built-in extensions from GitHub releases

Adds support for downloading platform-specific built-in extension VSIXs
from GitHub releases, keyed by marketplace target platform. Also downloads
the latest pre-release assets for insiders builds, ignoring the pinned
version and checksum.

- extensionTarget.ts: resolve build target + release asset name
- builtInExtensions.ts: platformSpecific checksum map + insiders detection
- extensions.ts/fetch.ts: fromGithub asset selection + prerelease support
- CI: platform-aware cache key and target env plumbing

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Insiders downloads the latest release instead of latest pre-release

Insiders builds should always be on the newest published release, so the
GitHub download now resolves the most recently published release (including
pre-releases) rather than filtering to pre-releases only.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Address code review feedback for platform-specific extensions

- Sort latest releases by published_at instead of created_at
- Log a warning when skipping checksum validation in latest mode
- Document that platform-specific extensions always download from GitHub
- Skip gracefully on unsupported platforms; keep a clear error for a
  known target missing from the platformSpecific map

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Address CCR feedback: restrict targets and harden helpers

- Restrict getExtensionTarget to the supported marketplace targets, returning
  undefined for unsupported OS/arch (e.g. win32-ia32, linux-riscv64) so callers
  skip gracefully instead of failing with a missing-asset error
- Remove the bogus ia32 -> x86 mapping (no win32-x86 target exists)
- Validate the target format in getPlatformSpecificAssetName and throw a clear
  error for malformed targets
- Guard the latest-release sort against NaN timestamps (missing published_at
  sorts to the end deterministically)
- Update tests accordingly

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Align asset naming with VS Code convention and support product.overrides.json

The platform-specific extension this feature targets (typescript-go's
TypeScriptTeam.native-preview) publishes VSIX assets named
<name>-<target>.vsix using the raw marketplace target platform, not the
node-vsce-sign osx/win/arm aliasing. Update getPlatformSpecificAssetName to
the standard <name>-<target>.vsix convention and validate against the
supported target set.

- fetch.ts: in latest mode, select the newest published release that actually
  contains the requested asset, so releases shipping only other artifacts
  (e.g. tarballs) without a matching VSIX are skipped
- builtInExtensions.ts: merge product.overrides.json (gitignored, local) so
  overridden built-in extensions are downloaded, mirroring bootstrap-meta
- Update tests for the new naming convention

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Detect extensions project by path segment, not substring

ESBuildTranspiler decided CJS vs ESM output via configFilePath.includes('extensions').
When the repo is checked out (e.g. as a git worktree) into a folder whose name
merely contains the substring 'extensions', the 'src' project was wrongly treated
as an extension and transpiled to CJS, breaking top-level await in src/cli.ts,
src/server-cli.ts and src/server-main.ts. Match an 'extensions' path segment instead.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Remove product.overrides.json support from built-in extensions download

Revert the download script to read product.json directly, per review feedback.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-14 10:26:58 +00:00

77 lines
3.4 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import assert from 'assert';
import { suite, test } from 'node:test';
import { getExtensionTarget, getPlatformSpecificAssetName } from '../extensionTarget.ts';
suite('extensionTarget', () => {
test('getExtensionTarget resolves marketplace target platforms', () => {
const notAlpine = () => false;
const alpine = () => true;
assert.deepStrictEqual({
darwinX64: getExtensionTarget('darwin', 'x64'),
darwinArm64: getExtensionTarget('darwin', 'arm64'),
win32X64: getExtensionTarget('win32', 'x64'),
win32Arm64: getExtensionTarget('win32', 'arm64'),
win32Ia32: getExtensionTarget('win32', 'ia32'),
linuxX64: getExtensionTarget('linux', 'x64', notAlpine),
linuxArm64: getExtensionTarget('linux', 'arm64', notAlpine),
linuxArmhf: getExtensionTarget('linux', 'armhf', notAlpine),
linuxArmProcess: getExtensionTarget('linux', 'arm', notAlpine),
linuxUnsupportedArch: getExtensionTarget('linux', 'riscv64', notAlpine),
alpineX64: getExtensionTarget('linux', 'x64', alpine),
alpineArm64: getExtensionTarget('linux', 'arm64', alpine),
unsupported: getExtensionTarget('sunos', 'x64'),
}, {
darwinX64: 'darwin-x64',
darwinArm64: 'darwin-arm64',
win32X64: 'win32-x64',
win32Arm64: 'win32-arm64',
win32Ia32: undefined,
linuxX64: 'linux-x64',
linuxArm64: 'linux-arm64',
linuxArmhf: 'linux-armhf',
linuxArmProcess: 'linux-armhf',
linuxUnsupportedArch: undefined,
alpineX64: 'alpine-x64',
alpineArm64: 'alpine-arm64',
unsupported: undefined,
});
});
test('getPlatformSpecificAssetName uses the <name>-<target>.vsix convention', () => {
assert.deepStrictEqual({
darwinX64: getPlatformSpecificAssetName('my-ext', 'darwin-x64'),
darwinArm64: getPlatformSpecificAssetName('my-ext', 'darwin-arm64'),
win32X64: getPlatformSpecificAssetName('my-ext', 'win32-x64'),
win32Arm64: getPlatformSpecificAssetName('my-ext', 'win32-arm64'),
linuxX64: getPlatformSpecificAssetName('my-ext', 'linux-x64'),
linuxArm64: getPlatformSpecificAssetName('my-ext', 'linux-arm64'),
linuxArmhf: getPlatformSpecificAssetName('my-ext', 'linux-armhf'),
alpineX64: getPlatformSpecificAssetName('my-ext', 'alpine-x64'),
alpineArm64: getPlatformSpecificAssetName('my-ext', 'alpine-arm64'),
}, {
darwinX64: 'my-ext-darwin-x64.vsix',
darwinArm64: 'my-ext-darwin-arm64.vsix',
win32X64: 'my-ext-win32-x64.vsix',
win32Arm64: 'my-ext-win32-arm64.vsix',
linuxX64: 'my-ext-linux-x64.vsix',
linuxArm64: 'my-ext-linux-arm64.vsix',
linuxArmhf: 'my-ext-linux-armhf.vsix',
alpineX64: 'my-ext-alpine-x64.vsix',
alpineArm64: 'my-ext-alpine-arm64.vsix',
});
});
test('getPlatformSpecificAssetName throws for unsupported targets', () => {
assert.throws(() => getPlatformSpecificAssetName('my-ext', 'linux'), /Invalid target platform/);
assert.throws(() => getPlatformSpecificAssetName('my-ext', 'win32-x86'), /Invalid target platform/);
assert.throws(() => getPlatformSpecificAssetName('my-ext', 'freebsd-x64'), /Invalid target platform/);
assert.throws(() => getPlatformSpecificAssetName('my-ext', ''), /Invalid target platform/);
});
});