Skip to content

Commit 7abcee2

Browse files
committed
Merge branch 'release/2.1.0'
* release/2.1.0: Use dll instead of exe for Cake Bakery (#681) packageName needs to be lowerCase for v3-flatcontainer (maint) added some logging Bump @types/node from 16.11.12 to 18.8.3 Bump typescript from 4.5.3 to 4.8.4 Bump minimist from 1.2.5 to 1.2.6 Bump glob and @types/glob Bump https-proxy-agent from 5.0.0 to 5.0.1 Bump node-fetch and @types/node-fetch Bump ini from 2.0.0 to 3.0.1 Bump mocha and @types/mocha Bump depcheck from 1.4.2 to 1.4.3
2 parents cbad3e3 + 64443b7 commit 7abcee2

File tree

10 files changed

+441
-290
lines changed

10 files changed

+441
-290
lines changed

package-lock.json

Lines changed: 357 additions & 246 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -626,26 +626,26 @@
626626
"dependencies": {
627627
"adm-zip": "^0.5.9",
628628
"byline": "^5.0.0",
629-
"https-proxy-agent": "^5.0.0",
630-
"ini": "^2.0.0",
631-
"node-fetch": "^2.6.6",
629+
"https-proxy-agent": "^5.0.1",
630+
"ini": "^3.0.1",
631+
"node-fetch": "^2.6.7",
632632
"request": "^2.88.2",
633633
"xml2js": "^0.4.23"
634634
},
635635
"devDependencies": {
636636
"@types/byline": "^4.2.33",
637-
"@types/glob": "^7.2.0",
637+
"@types/glob": "^8.0.0",
638638
"@types/ini": "^1.3.31",
639-
"@types/mocha": "^9.0.0",
640-
"@types/node": "^16.11.12",
641-
"@types/node-fetch": "^2.5.12",
639+
"@types/mocha": "^10.0.0",
640+
"@types/node": "^18.8.3",
641+
"@types/node-fetch": "^2.6.2",
642642
"@types/vscode": "^1.24.0",
643643
"@types/xml2js": "^0.4.9",
644-
"depcheck": "^1.4.2",
645-
"glob": "^7.2.0",
646-
"mocha": "^9.1.3",
644+
"depcheck": "^1.4.3",
645+
"glob": "^8.0.3",
646+
"mocha": "^10.0.0",
647647
"typemoq": "^2.1.0",
648-
"typescript": "^4.5.3",
648+
"typescript": "^4.8.4",
649649
"vscode-test": "^1.6.1"
650650
},
651651
"extensionDependencies": [

src/addPackage/actions/fetchCakePackages.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as qs from 'querystring';
22
import fetch from 'node-fetch';
3+
import { logger } from '../../shared'
34
import { Response } from 'node-fetch';
45
import { getFetchOptions } from '../../shared/utils';
56
import { window, workspace } from 'vscode';
@@ -32,8 +33,16 @@ export default async function fetchCakePackages(
3233
take: take
3334
});
3435

35-
return await fetch(
36-
`${searchUrl}?${queryParams}`,
37-
getFetchOptions(workspace.getConfiguration('http'))
38-
);
36+
try {
37+
const fullUrl = `${searchUrl}?${queryParams}`;
38+
logger.logInfo(`Fetching available packages for query '${value}' using URL: ${fullUrl}`);
39+
return await fetch(
40+
fullUrl,
41+
getFetchOptions(workspace.getConfiguration('http'))
42+
);
43+
} catch (e: any) {
44+
logger.logError("Error fetching available packages from NuGet for query: "+value);
45+
logger.logToOutput(e);
46+
throw e;
47+
}
3948
}
Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { window, workspace } from 'vscode';
22
import fetch from 'node-fetch';
3+
import { logger } from '../../shared'
34
import { getFetchOptions } from '../../shared/utils';
45
import { CANCEL } from '../../constants';
56
import { NUGET_LOADING_VERSIONS } from '../../shared/messages';
@@ -14,16 +15,24 @@ export default async function fetchPackageVersions(
1415
return Promise.reject(CANCEL);
1516
}
1617

17-
window.setStatusBarMessage(NUGET_LOADING_VERSIONS);
18-
if(!versionsUrl) {
19-
versionsUrl = await getNugetServiceUrl(NuGetServiceType.FlatContainer3);
20-
}
18+
try {
19+
window.setStatusBarMessage(NUGET_LOADING_VERSIONS);
20+
if(!versionsUrl) {
21+
versionsUrl = await getNugetServiceUrl(NuGetServiceType.FlatContainer3);
22+
}
2123

22-
const response = await fetch(
23-
versionsUrl.replace(/\/?$/,`/${selectedPackageName}/index.json`),
24-
getFetchOptions(workspace.getConfiguration('http'))
25-
);
26-
27-
window.setStatusBarMessage('');
28-
return { response, selectedPackageName };
24+
versionsUrl = versionsUrl.replace(/\/?$/,`/${selectedPackageName.toLowerCase()}/index.json`)
25+
logger.logInfo(`Fetching package versions for package '${selectedPackageName}' using URL: ${versionsUrl}`);
26+
const response = await fetch(
27+
versionsUrl,
28+
getFetchOptions(workspace.getConfiguration('http'))
29+
);
30+
31+
window.setStatusBarMessage('');
32+
return { response, selectedPackageName };
33+
} catch (e: any) {
34+
logger.logError("Error fetching package versions from NuGet for package: "+selectedPackageName);
35+
logger.logToOutput(e);
36+
throw e;
37+
}
2938
}

src/addPackage/actions/handleVersionsResponse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default function handleVersionsResponse({
1111
}): Promise<any> | Promise<never> {
1212
if (!response.ok) {
1313
return handleError<Promise<never>>(
14-
null,
14+
response,
1515
NUGET_BAD_VERSIONING,
1616
Promise.reject.bind(Promise)
1717
);

src/bakery/cakeBakery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class CakeBakery {
1818
public getTargetPath(): string {
1919
return path.join(
2020
this.extensionPath,
21-
'Cake.Bakery/tools/Cake.Bakery.exe'
21+
'Cake.Bakery/tools/Cake.Bakery.dll'
2222
);
2323
}
2424

src/cakeMain.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ async function _registerCakeBakery(context: vscode.ExtensionContext) {
128128
// Read in file
129129
//import omnisharpCakeConfig from getOmnisharpCakeConfigFile();
130130
var omnisharpCakeConfig = JSON.parse(fs.readFileSync(getOmnisharpCakeConfigFile(), 'utf-8'))
131-
console.log(omnisharpCakeConfig.cake.bakeryPath);
131+
logger.logInfo(`existing bakery-path: ${omnisharpCakeConfig.cake.bakeryPath}`);
132132
omnisharpCakeConfig.cake.bakeryPath = targetPath;
133+
logger.logInfo(`new bakery-path: ${omnisharpCakeConfig.cake.bakeryPath}`);
133134
fs.writeFileSync(getOmnisharpCakeConfigFile(), JSON.stringify(omnisharpCakeConfig));
134135

135136
// lets force a restart of the Omnisharp server to use new config

src/shared/log.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
import { window, OutputChannel } from 'vscode';
1+
import { window, OutputChannel, extensions } from 'vscode';
22
import { OUTPUT_CHANNEL_NAME } from '../constants';
33

4+
interface IPackageJson {
5+
// see https://code.visualstudio.com/api/references/extension-manifest
6+
name: string;
7+
version: string;
8+
}
9+
410
let channel: OutputChannel;
511

612
export function logToOutput(...items: string[]): void {
@@ -32,6 +38,8 @@ export function logInfo(info: string, notify: boolean = false) {
3238
function getChannel(name: string): OutputChannel {
3339
if (!channel) {
3440
channel = window.createOutputChannel(name);
41+
const thisExtension = (extensions.getExtension("cake-build.cake-vscode")?.packageJSON ?? {}) as IPackageJson;
42+
channel.appendLine(`This is ${thisExtension.name}, version ${thisExtension.version}`);
3543
}
3644

3745
return channel;

src/shared/nugetServiceUrl.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import fetch from 'node-fetch';
2+
import * as logger from './log';
23
import { workspace } from 'vscode';
34
import { NUGET_SERVICE_INDEX_URL } from '../constants';
45
import { getFetchOptions } from './utils';
@@ -9,18 +10,23 @@ export enum NuGetServiceType {
910
SearchQueryService = 'SearchQueryService'
1011
}
1112
export async function getNugetServiceUrl(type: NuGetServiceType) : Promise<string> {
12-
// TODO: the url's won't change every 5 min. - should we cache the call to the services?
13-
const response = await fetch(NUGET_SERVICE_INDEX_URL, getFetchOptions(workspace.getConfiguration('http')));
14-
const json: any = await response.json();
15-
const resources = (json.resources as any[] || []).filter((x:any) => x['@type'] === type);
16-
let resource = resources.find((x: any) => (x.comment as string).toLowerCase().indexOf('primary') >= 0);
17-
if(!resource && resources.length > 0) {
18-
resource = resources[0];
19-
}
13+
try {
14+
// TODO: the url's won't change every 5 min. - should we cache the call to the services?
15+
const response = await fetch(NUGET_SERVICE_INDEX_URL, getFetchOptions(workspace.getConfiguration('http')));
16+
const json: any = await response.json();
17+
const resources = (json.resources as any[] || []).filter((x:any) => x['@type'] === type);
18+
let resource = resources.find((x: any) => (x.comment as string).toLowerCase().indexOf('primary') >= 0);
19+
if(!resource && resources.length > 0) {
20+
resource = resources[0];
21+
}
2022

21-
if(!resource){
22-
throw new Error("Service endpoint not Found: "+type);
23+
if(!resource){
24+
throw new Error("Service endpoint not Found: "+type);
25+
}
26+
return resource['@id'] as string;
27+
} catch (e: any) {
28+
logger.logError("Error reading NuGet Service Url for type: "+type);
29+
logger.logToOutput(e);
30+
throw e;
2331
}
24-
25-
return resource['@id'] as string;
2632
}

src/shared/utils/handleError.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { logger } from '../../shared'
12
/**
2-
* Writes an error to the console but rejects with the given message
3+
* Writes an error to the logger but rejects with the given message
34
*
45
* @param {Error} err
56
* @param {string} displayMessage
@@ -10,7 +11,13 @@ export function handleError<T>(
1011
displayMessage: string,
1112
rejector: (reason?: any) => T
1213
): T {
13-
console.error(err || displayMessage);
14+
logger.logError(displayMessage);
15+
if(err){
16+
if(typeof(err) == "object") {
17+
err = JSON.stringify(err);
18+
}
19+
logger.logToOutput(err);
20+
}
1421
return rejector(displayMessage);
1522
}
1623

0 commit comments

Comments
 (0)