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
5 changes: 5 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const platform = require('./out/src/platform');
const util = require('./out/src/common');
const child_process = require('child_process');
const optionsSchemaGenerator = require('./out/src/tools/GenerateOptionsSchema');
const packageDependencyUpdater = require('./out/src/tools/UpdatePackageDependencies');

const Logger = logger.Logger;
const PackageManager = packages.PackageManager;
Expand All @@ -44,6 +45,10 @@ gulp.task('generateOptionsSchema', () => {
optionsSchemaGenerator.GenerateOptionsSchema();
});

gulp.task('updatePackageDependencies', () => {
packageDependencyUpdater.updatePackageDependencies();
});

// Install Tasks
function install(platformInfo, packageJSON) {
const packageManager = new PackageManager(platformInfo, packageJSON);
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"runtimeDependencies": [
{
"description": "Mono Runtime (Linux / x86)",
"url": "https://omnisharpdownload.azureedge.net/ext/mono.linux-x86-5.2.0-omnisharp1.zip",
"url": "https://download.visualstudio.microsoft.com/download/pr/10942097/51c64a0c8945d53601bbf75af88d88f3/mono.linux-x86-5.2.0-omnisharp1.zip",
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/mono.linux-x86-5.2.0-omnisharp1.zip",
"installPath": "./bin",
"platforms": [
Expand All @@ -85,7 +85,7 @@
},
{
"description": "Mono Runtime (Linux / x64)",
"url": "https://omnisharpdownload.azureedge.net/ext/mono.linux-x86_64-5.2.0-omnisharp1.zip",
"url": "https://download.visualstudio.microsoft.com/download/pr/10942097/51c64a0c8945d53601bbf75af88d88f3/mono.linux-x86_64-5.2.0-omnisharp1.zip",
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/mono.linux-x86_64-5.2.0-omnisharp1.zip",
"installPath": "./bin",
"platforms": [
Expand All @@ -102,7 +102,7 @@
},
{
"description": "Mono Runtime (macOS)",
"url": "https://omnisharpdownload.azureedge.net/ext/mono.osx-5.2.0-omnisharp1.zip",
"url": "https://download.visualstudio.microsoft.com/download/pr/10942097/51c64a0c8945d53601bbf75af88d88f3/mono.osx-5.2.0-omnisharp1.zip",
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/mono.osx-5.2.0-omnisharp1.zip",
"installPath": "./bin",
"platforms": [
Expand All @@ -116,7 +116,7 @@
},
{
"description": "Mono Framework Assemblies",
"url": "https://omnisharpdownload.azureedge.net/ext/framework-5.2.0-omnisharp1.zip",
"url": "https://download.visualstudio.microsoft.com/download/pr/10942097/51c64a0c8945d53601bbf75af88d88f3/framework-5.2.0-omnisharp1.zip",
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/framework-5.2.0-omnisharp1.zip",
"installPath": "./bin/framework",
"platforms": [
Expand All @@ -127,7 +127,7 @@
},
{
"description": "OmniSharp (.NET 4.6 / x86)",
"url": "https://omnisharpdownload.azureedge.net/ext/omnisharp-win-x86-1.22.0.zip",
"url": "https://download.visualstudio.microsoft.com/download/pr/10942097/51c64a0c8945d53601bbf75af88d88f3/omnisharp-win-x86-1.22.0.zip",
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-win-x86-1.22.0.zip",
"installPath": "./bin/omnisharp",
"platforms": [
Expand All @@ -140,7 +140,7 @@
},
{
"description": "OmniSharp (.NET 4.6 / x64)",
"url": "https://omnisharpdownload.azureedge.net/ext/omnisharp-win-x64-1.22.0.zip",
"url": "https://download.visualstudio.microsoft.com/download/pr/10942097/51c64a0c8945d53601bbf75af88d88f3/omnisharp-win-x64-1.22.0.zip",
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-win-x64-1.22.0.zip",
"installPath": "./bin/omnisharp",
"platforms": [
Expand All @@ -153,7 +153,7 @@
},
{
"description": "OmniSharp (Mono 4.6)",
"url": "https://omnisharpdownload.azureedge.net/ext/omnisharp-mono-1.22.0.zip",
"url": "https://download.visualstudio.microsoft.com/download/pr/10942097/51c64a0c8945d53601bbf75af88d88f3/omnisharp-mono-1.22.0.zip",
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-mono-1.22.0.zip",
"installPath": "./bin/omnisharp",
"platforms": [
Expand Down
7 changes: 6 additions & 1 deletion src/tools/GenerateOptionsSchema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as fs from 'fs';
import * as os from 'os';

function AppendFieldsToObject(reference: any, obj: any) {

Expand Down Expand Up @@ -94,5 +95,9 @@ export function GenerateOptionsSchema() {
packageJSON.contributes.debuggers[1].configurationAttributes.launch = schemaJSON.definitions.LaunchOptions;
packageJSON.contributes.debuggers[1].configurationAttributes.attach = schemaJSON.definitions.AttachOptions;

fs.writeFileSync('package.json', JSON.stringify(packageJSON, null, 2));
let content = JSON.stringify(packageJSON, null, 2);
if (os.platform() === 'win32') {
content = content.replace(/\n/gm, "\r\n");
}
fs.writeFileSync('package.json', content);
}
87 changes: 87 additions & 0 deletions src/tools/UpdatePackageDependencies.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import * as fs from 'fs';
import * as os from 'os';
import { Package } from '../packages';

interface PackageJSONFile
{
runtimeDependencies : Package[];
}

export function updatePackageDependencies() {

const urlsIndex = process.argv.indexOf("--urls");
const newPrimaryUrls = urlsIndex >= 0 ? process.argv[urlsIndex+1] : undefined;

const fallbackUrlsIndex = process.argv.indexOf("--fallbackUrls");
const newFallbackUrls = fallbackUrlsIndex >= 0 ? process.argv[fallbackUrlsIndex+1] : undefined;

if (newPrimaryUrls === undefined || newPrimaryUrls === "-?" || newPrimaryUrls === "-h") {
console.log("This command will update the URLs for package dependencies in package.json");
console.log();
console.log("Syntax: updatePackageDependencies --urls \"<url1>,<url2>,...\" [--fallbackUrls \"<fallback-url-1>,<fallback-url-2>...\"]");
console.log();
return;
}

if (newPrimaryUrls.length === 0) {
throw new Error("Invalid first argument to updatePackageDependencies. URL string argument expected.");
}

let packageJSON: PackageJSONFile = JSON.parse(fs.readFileSync('package.json').toString());

// map from lowercase filename to Package
const mapFileNameToDependency = {};

// First build the map
packageJSON.runtimeDependencies.forEach(dependency => {
let fileName = getLowercaseFileNameFromUrl(dependency.url);
let existingDependency = mapFileNameToDependency[fileName];
if (existingDependency !== undefined) {
throw new Error(`Multiple dependencies found with filename '${fileName}': '${existingDependency.url}' and '${dependency.url}'.`);
}
mapFileNameToDependency[fileName] = dependency;
});

let findDependencyToUpdate = (url : string): Package => {
let fileName = getLowercaseFileNameFromUrl(url);
let dependency = mapFileNameToDependency[fileName];
if (dependency === undefined) {
throw new Error(`Unable to update item for url '${url}'. No 'runtimeDependency' found with filename '${fileName}'.`);
}

console.log(`Updating ${url}`);
return dependency;
};

newPrimaryUrls.split(',').forEach(urlToUpdate =>{
let depedency = findDependencyToUpdate(urlToUpdate);
depedency.url = urlToUpdate;
});

if (newFallbackUrls !== undefined) {
newFallbackUrls.split(',').forEach(urlToUpdate =>{
let depedency = findDependencyToUpdate(urlToUpdate);
depedency.fallbackUrl = urlToUpdate;
});
}

let content = JSON.stringify(packageJSON, null, 2);
if (os.platform() === 'win32') {
content = content.replace(/\n/gm, "\r\n");
}
fs.writeFileSync('package.json', content);
}

function getLowercaseFileNameFromUrl(url : string) : string {

if (!url.startsWith("https://")) {
throw new Error(`Unexpected URL '${url}'. URL expected to start with 'https://'.`);
}

if (!url.endsWith(".zip")) {
throw new Error(`Unexpected URL '${url}'. URL expected to end with '.zip'.`);
}

let index = url.lastIndexOf("/");
return url.substr(index + 1).toLowerCase();
}