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
52 changes: 26 additions & 26 deletions tasks/offlinePackagingTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ import { getRuntimeDependenciesPackages } from '../src/tools/RuntimeDependencyPa
import { getAbsolutePathPackagesToInstall } from '../src/packageManager/getAbsolutePathPackagesToInstall';
import { isValidDownload } from '../src/packageManager/isValidDownload';

export const offlinePackages = [
{ platformInfo: new PlatformInformation('win32', 'x86_64'), id: "win32-x64" },
{ platformInfo: new PlatformInformation('win32', 'x86'), id: "win32-ia32" },
{ platformInfo: new PlatformInformation('win32', 'arm64'), id: "win32-arm64" },
{ platformInfo: new PlatformInformation('linux', 'x86_64'), id: "linux-x64" },
{ platformInfo: new PlatformInformation('darwin', 'x86_64'), id: "darwin-x64" },
{ platformInfo: new PlatformInformation('darwin', 'arm64'), id: "darwin-arm64" },
];

export function getPackageName(packageJSON: any, vscodePlatformId: string) {
const name = packageJSON.name;
const version = packageJSON.version;
return `${name}.${version}-${vscodePlatformId}.vsix`;
}

gulp.task('vsix:offline:package', async () => {

if (process.platform === 'win32') {
Expand Down Expand Up @@ -53,44 +68,30 @@ async function doPackageOffline() {
}

const packageJSON = getPackageJSON();
const name = packageJSON.name;
const version = packageJSON.version;
const packageName = name + '.' + version;

const packages = [
{ platformInfo: new PlatformInformation('win32', 'x86_64'), id: "win32-x64" },
{ platformInfo: new PlatformInformation('win32', 'x86'), id: "win32-ia32" },
{ platformInfo: new PlatformInformation('win32', 'arm64'), id: "win32-arm64" },
{ platformInfo: new PlatformInformation('linux', 'x86_64'), id: "linux-x64" },
{ platformInfo: new PlatformInformation('darwin', 'x86_64'), id: "darwin-x64" },
{ platformInfo: new PlatformInformation('darwin', 'arm64'), id: "darwin-arm64" },
];

for (let p of packages) {
try
{
await doOfflinePackage(p.platformInfo, p.id, packageName, packageJSON, packedVsixOutputRoot);

for (let p of offlinePackages) {
try {
await doOfflinePackage(p.platformInfo, p.id, packageJSON, packedVsixOutputRoot);
}
catch (err)
{
// NOTE: Extra `\n---` at the end is because gulp will print this message following by the
catch (err) {
// NOTE: Extra `\n---` at the end is because gulp will print this message following by the
// stack trace of this line. So that seperates the two stack traces.
throw Error(`Failed to create package ${p.id}. ${err.stack ?? err ?? '<unknown error>'}\n---`);
}
}
}

async function cleanAsync(deleteVsix: boolean) {
await del([ 'install.*', '.omnisharp*', '.debugger', '.razor']);
await del(['install.*', '.omnisharp*', '.debugger', '.razor']);

if (deleteVsix) {
await del('*.vsix');
}
}

async function doOfflinePackage(platformInfo: PlatformInformation, vscodePlatformId: string, packageName: string, packageJSON: any, outputFolder: string) {
async function doOfflinePackage(platformInfo: PlatformInformation, vscodePlatformId: string, packageJSON: any, outputFolder: string) {
await cleanAsync(false);
const packageFileName = `${packageName}-${vscodePlatformId}.vsix`;
const packageFileName = getPackageName(packageJSON, vscodePlatformId);
await install(platformInfo, packageJSON);
await createPackageAsync(packageFileName, outputFolder, vscodePlatformId);
}
Expand All @@ -104,14 +105,13 @@ async function install(platformInfo: PlatformInformation, packageJSON: any) {
let runTimeDependencies = getRuntimeDependenciesPackages(packageJSON);
let packagesToInstall = await getAbsolutePathPackagesToInstall(runTimeDependencies, platformInfo, codeExtensionPath);
let provider = () => new NetworkSettings(undefined, undefined);
if (!(await downloadAndInstallPackages(packagesToInstall, provider, eventStream, isValidDownload)))
{
if (!(await downloadAndInstallPackages(packagesToInstall, provider, eventStream, isValidDownload))) {
throw Error("Failed to download package.");
}

// The VSIX Format doesn't allow files that differ only by case. The Linux OmniSharp package had a lowercase version of these files ('.targets') targets from mono,
// and an upper case ('.Targets') from Microsoft.Build.Runtime. Remove the lowercase versions.
await del([ '.omnisharp/*/omnisharp/.msbuild/Current/Bin/Workflow.targets', '.omnisharp/*/omnisharp/.msbuild/Current/Bin/Workflow.VisualBasic.targets' ]);
await del(['.omnisharp/*/omnisharp/.msbuild/Current/Bin/Workflow.targets', '.omnisharp/*/omnisharp/.msbuild/Current/Bin/Workflow.VisualBasic.targets']);
}

/// Packaging (VSIX) Tasks
Expand Down
27 changes: 16 additions & 11 deletions test/releaseTests/offlinePackage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ import * as chai from 'chai';
import * as glob from 'glob-promise';
import * as path from 'path';
import { invokeNode } from './testAssets/testAssets';
import { PlatformInformation } from '../../src/platform';
import { TmpAsset, CreateTmpDir } from '../../src/CreateTmpAsset';
import { getPackageName, offlinePackages } from '../../tasks/offlinePackagingTasks';
import { getPackageJSON } from '../../tasks/packageJson';
import { expect } from 'chai';

suite("Offline packaging of VSIX", function () {
let vsixFiles: string[];
this.timeout(1000000);
let tmpDir: TmpAsset;

const packageJson = getPackageJSON();

suiteSetup(async () => {
chai.should();
tmpDir = await CreateTmpDir(true);
Expand All @@ -28,18 +32,19 @@ suite("Offline packaging of VSIX", function () {
vsixFiles = glob.sync(path.join(tmpDir.name, '*.vsix'));
});

test("Exactly 3 vsix files should be produced", () => {
vsixFiles.length.should.be.equal(3, "the build should produce exactly 3 vsix files");
test(`Exactly ${offlinePackages.length} vsix files should be produced`, () => {
vsixFiles.length.should.be.equal(offlinePackages.length, `the build should produce exactly ${offlinePackages.length} vsix files`);
});

[
new PlatformInformation('win32', 'x86_64'),
new PlatformInformation('darwin', 'x86_64'),
new PlatformInformation('linux', 'x86_64')
].forEach(element => {
test(`Given Platform: ${element.platform} and Architecture: ${element.architecture}, the vsix file is created`, () => {
vsixFiles.findIndex(elem => elem.indexOf(element.platform) != -1).should.not.be.equal(-1);
vsixFiles.findIndex(elem => elem.indexOf(element.architecture) != -1).should.not.be.equal(-1);
offlinePackages.forEach(packageInfo => {
const platformInfo = packageInfo.platformInfo;
const packageId = packageInfo.id;

test(`Given Platform: ${platformInfo.platform} and Architecture: ${platformInfo.architecture}, the vsix file is created`, () => {
const expectedVsixName = getPackageName(packageJson, packageId);
const vsixFile = vsixFiles.find(file => file.endsWith(expectedVsixName))
expect(vsixFile, `offline packaging did not build package ${expectedVsixName}`)
.to.not.be.null;
});
});

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"module": "commonjs",
"outDir": "out",
"lib": [
"es6"
"ES2017"
],
"sourceMap": true,
"moduleResolution": "node",
Expand Down