Skip to content

Commit

Permalink
3.1.4 release
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosOrozco88 committed Jun 12, 2024
1 parent f136e3b commit cb60b9d
Show file tree
Hide file tree
Showing 8 changed files with 723 additions and 684 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 3.1.4 (12/06/2024)

- **New feature**: when deploying an application to the Gateway, in the `update existing transport` option, the system will attempt to read the transport orders and list them below. If there are no orders or the service is not activated, it will ask for the transport number as it does currently.
- Updated sandbox.js files
- Dependencies upgrade

## 3.1.3 (29/05/2024)

- Fixed a bug with download SAPUI5 runtime.
Expand Down
1,166 changes: 557 additions & 609 deletions package-lock.json

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ui5-tools",
"displayName": "UI5 Tools",
"description": "Local development tools for UI5",
"version": "3.1.3",
"version": "3.1.4",
"publisher": "carlosorozcojimenez",
"author": "Carlos Orozco Jiménez <carlos.orozco.jimenez@gmail.com>",
"contributors": [
Expand Down Expand Up @@ -583,33 +583,33 @@
"@types/ejs": "3.1.5",
"@types/express": "4.17.21",
"@types/less": "3.0.6",
"@types/node": "18.15.0",
"@types/node": "20.14.2",
"@types/node-fetch": "2.6.11",
"@types/on-headers": "1.0.3",
"@types/pretty-data": "0.40.3",
"@types/vscode": "1.84.1",
"@types/ws": "8.5.10",
"@typescript-eslint/eslint-plugin": "7.8.0",
"@typescript-eslint/parser": "7.8.0",
"@typescript-eslint/eslint-plugin": "7.13.0",
"@typescript-eslint/parser": "7.13.0",
"babel-loader": "9.1.3",
"clean-webpack-plugin": "4.0.0",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.1.3",
"node-loader": "2.0.0",
"prettier": "3.2.5",
"prettier": "3.3.2",
"ts-node": "10.9.2",
"ts-loader": "9.5.1",
"typescript": "5.4.5",
"webassembly-loader": "1.1.0",
"webpack": "5.91.0",
"webpack": "5.92.0",
"webpack-cli": "5.1.4"
},
"dependencies": {
"@babel/core": "7.24.5",
"@babel/preset-typescript": "7.24.1",
"adm-zip": "0.5.12",
"babel-preset-transform-ui5": "7.3.0",
"@babel/core": "7.24.7",
"@babel/preset-typescript": "7.24.7",
"adm-zip": "0.5.14",
"babel-preset-transform-ui5": "7.4.1",
"bufferutil": "4.0.8",
"chokidar": "3.6.0",
"connect-livereload": "0.6.1",
Expand All @@ -619,24 +619,24 @@
"ejs": "3.1.10",
"express": "4.19.2",
"express-timeout-handler": "2.2.2",
"fast-xml-parser": "4.3.6",
"fast-xml-parser": "4.4.0",
"http-proxy-middleware": "2.0.6",
"http-terminator": "3.2.0",
"less": "4.2.0",
"less-openui5": "0.11.6",
"livereload": "0.9.3",
"marked": "12.0.2",
"minimatch": "9.0.4",
"node-fetch": "2.6.13",
"node-fetch": "2.7.0",
"node-html-parser": "6.1.13",
"on-headers": "1.0.2",
"open": "8.4.2",
"openui5-preload": "4.0.0",
"portfinder": "1.0.32",
"pretty-data": "0.40.0",
"terser": "5.31.0",
"terser": "5.31.1",
"ui5-nwabap-deployer-core": "1.0.23",
"utf-8-validate": "6.0.3",
"utf-8-validate": "6.0.4",
"ws": "8.17.0"
}
}
6 changes: 2 additions & 4 deletions src/Configurator/Ui5Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,17 +444,15 @@ export default {

async downloadRuntime(version: VersionsItem) {
const sMessage = Log.configurator(`Installing SAPUI5 ${version.version} runtime`);
const headers = await this.acceptLicence();
await window.withProgress(
{
title: sMessage,
cancellable: false,
location: ProgressLocation.Window,
location: ProgressLocation.Notification,
},
async (progress) => {
progress.report({ increment: 10, message: 'Accept or reject EULA...' });
try {
const headers = await this.acceptLicence();

progress.report({ increment: 10, message: 'Downloading...' });
const zipBuffer = await Fetch.buffer(version.url, {
headers,
Expand Down
78 changes: 69 additions & 9 deletions src/Deployer/Deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,20 +391,80 @@ export default {
async updateTransport(ui5Project: Ui5Project, oDeployOptions: DeployOptions, transportno?: string) {
if (!transportno) {
try {
transportno = await new Promise((resolve) => {
const inputBox = window.createInputBox();
inputBox.title = 'ui5-tools > Deployer > Update transport > Enter transport number';
inputBox.placeholder = 'Enter the transport number';
inputBox.ignoreFocusOut = true;
inputBox.onDidAccept(() => {
resolve(inputBox.value);
inputBox.hide();
const uri = oDeployOptions.conn.server;
const client = oDeployOptions.conn.client;

const orders: any[] = await new Promise((resolve) => {
window.withProgress(
{
location: ProgressLocation.Notification,
title: `ui5-tools > Importing Transports List...`,
cancellable: false,
},
async () => {
Log.deployer(`Getting Transports list from ${uri}...`);
const transportDataXML = await Fetch.getXMLFile(
`${uri}/sap/bc/adt/cts/transportrequests?targets=false&user=*&sap-client=${client}`,
oDeployOptions.auth
);
resolve(transportDataXML?.['tm:root']?.['tm:workbench']?.['tm:modifiable']?.['tm:request'] ?? []);
}
);
});
if (!orders.length) {
Log.deployer(`There are no transports.`, Level.ERROR);
throw new Error('No transports found');
}

const selTransportOption: QuickPickItem = await new Promise(async (resolve, reject) => {
const selTransportOptionQp = await window.createQuickPick();
selTransportOptionQp.title = 'ui5-tools > Deployer > Select existing transport';
selTransportOptionQp.items = orders.map((order: any) => {
return {
label: `${order['@_tm:desc']} - ${order['@_tm:owner']}`,
description: order['@_tm:number'],
};
});
inputBox.show();
selTransportOptionQp.placeholder = `Select a transport for ${ui5Project.folderName} project`;
selTransportOptionQp.canSelectMany = false;
if (Config.deployer('autoPrefixBSP')) {
selTransportOptionQp.value = `${oDeployOptions.ui5.bspcontainer}: `;
}
selTransportOptionQp.ignoreFocusOut = true;
selTransportOptionQp.onDidAccept(async () => {
if (selTransportOptionQp.selectedItems.length) {
resolve(selTransportOptionQp.selectedItems[0]);
} else {
reject('No UI5 project selected');
}
selTransportOptionQp.hide();
});
selTransportOptionQp.show();
});

transportno = selTransportOption.description;
} catch (oError) {
transportno = undefined;
}

if (!transportno) {
Log.deployer(`Asking to enter transportno`, Level.ERROR);
try {
transportno = await new Promise((resolve) => {
const inputBox = window.createInputBox();
inputBox.title = 'ui5-tools > Deployer > Update transport > Enter transport number';
inputBox.placeholder = 'Enter the transport number';
inputBox.ignoreFocusOut = true;
inputBox.onDidAccept(() => {
resolve(inputBox.value);
inputBox.hide();
});
inputBox.show();
});
} catch (oError) {
transportno = undefined;
}
}
}

if (!transportno) {
Expand Down
49 changes: 7 additions & 42 deletions src/Importer/Importer.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { window, ProgressLocation, QuickPickItem, workspace, Uri } from 'vscode';
import Config from '../Utils/ConfigVscode';
import Log from '../Utils/LogVscode';
import { Headers } from 'node-fetch';
import Fetch from '../Utils/Fetch';
import https from 'https';
import Utils from '../Utils/ExtensionVscode';
import { BSPData, ImportOptions, Level, Ui5ToolsConfiguration } from '../Types/Types';
import { XMLParser } from 'fast-xml-parser';
import { URL } from 'url';
import path from 'path';
import ImporterProvider from '../Configurator/ImporterProvider';
import Finder from '../Project/Finder';
import Fetch from '../Utils/Fetch';

export default {
async askBSPToImport(): Promise<void> {
Expand Down Expand Up @@ -63,14 +60,14 @@ export default {
return new Promise((resolve) => {
window.withProgress(
{
location: ProgressLocation.Window,
location: ProgressLocation.Notification,
title: `ui5-tools > Importing BSP List...`,
cancellable: false,
},
async () => {
const bspDataXML = await this.getXMLFile(
const bspDataXML = await Fetch.getXMLFile(
`${uri}/sap/bc/adt/filestore/ui5-bsp/objects?sap-client=${client}`,
oImportOptions
oImportOptions.auth
);

const bspData = bspDataXML['atom:feed']['atom:entry'].map((oEntry: Record<string, any>) => {
Expand Down Expand Up @@ -151,7 +148,7 @@ export default {

async importProject(oBSP: BSPData, oImportOptions: ImportOptions): Promise<void> {
Log.importer(`Importing BSP ${oBSP.title}...`);
const bspInfo = await this.getXMLFile(oBSP.url, oImportOptions);
const bspInfo = await Fetch.getXMLFile(oBSP.url, oImportOptions.auth);

await this.processEntry(bspInfo['atom:feed']['atom:entry'], oBSP, oImportOptions);

Expand Down Expand Up @@ -202,32 +199,6 @@ export default {
}
},

async getXMLFile(url: string, oImportOptions: ImportOptions) {
const data = await this.getFile(url, oImportOptions);
const res = this.parseXML(data);
return res;
},

async getFile(url: string, oImportOptions: ImportOptions) {
const headers = new Headers();
headers.set(
'Authorization',
'Basic ' + Buffer.from(oImportOptions.auth.user + ':' + oImportOptions.auth.pwd).toString('base64')
);

const httpsAgent = new https.Agent({
rejectUnauthorized: false,
});
const unaut = Fetch.setUnautorized(oImportOptions.conn?.useStrictSSL, !!Config.deployer('rejectUnauthorized'));
const data = await Fetch.file(url, {
timeout: 0,
headers: headers,
agent: httpsAgent,
});
unaut.restore();
return data;
},

async processEntry(aData: any, oBSP: BSPData, oImportOptions: ImportOptions) {
if (Array.isArray(aData)) {
for (let i = 0; i < aData.length; i++) {
Expand All @@ -253,12 +224,12 @@ export default {
Log.importer(`Creating folder ${uriFsPath}...`);
await workspace.fs.createDirectory(uriFsPath);

const data = await this.getXMLFile(sPath, oImportOptions);
const data = await Fetch.getXMLFile(sPath, oImportOptions.auth);

await this.processEntry(data['atom:feed']['atom:entry'], oBSP, oImportOptions);
} else {
Log.importer(`Creating file ${uriFsPath}...`);
const filedata = await this.getFile(sPath, oImportOptions);
const filedata = await Fetch.getFile(sPath, oImportOptions.auth);
workspace.fs.writeFile(uriFsPath, Buffer.from(filedata));
}
},
Expand Down Expand Up @@ -303,10 +274,4 @@ export default {
oImportOptions.auth.pwd = sPwd;
}
},

parseXML(XMLdata: string) {
const parser = new XMLParser({ ignoreAttributes: false });
const jsonData = parser.parse(XMLdata);
return jsonData;
},
};
50 changes: 46 additions & 4 deletions src/Utils/Fetch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import fetch, { RequestInit } from 'node-fetch';
import https from 'https';
import { XMLParser } from 'fast-xml-parser';
import { Headers } from 'node-fetch';
const originalReject = https.globalAgent.options.rejectUnauthorized;

const Fetch = {
Expand All @@ -22,10 +24,16 @@ const Fetch = {
},

async file(url: string, options: RequestInit = {}) {
const response = await Fetch.fetch(url, {
timeout: 5000,
...options,
});
let response;
try {
response = await Fetch.fetch(url, {
timeout: 5000,
...options,
});
} catch (error) {
console.log(error);
throw error;
}
return response.text();
},

Expand All @@ -43,5 +51,39 @@ const Fetch = {
},
};
},

async getXMLFile(url: string, oImportOptions: { user?: string; pwd?: string }) {
const data = await this.getFile(url, oImportOptions);
const res = Fetch.parseXML(data);
return res;
},

async getFile(url: string, oImportOptions: { user?: string; pwd?: string }) {
const headers = new Headers();
headers.set(
'Authorization',
'Basic ' + Buffer.from((oImportOptions.user ?? '') + ':' + (oImportOptions.pwd ?? '')).toString('base64')
);

const httpsAgent = new https.Agent({
rejectUnauthorized: false,
});

const { default: Config } = await import('../Utils/ConfigVscode');
const unaut = Fetch.setUnautorized(false, !!Config.deployer('rejectUnauthorized'));
const data = await Fetch.file(url, {
timeout: 0,
headers: headers,
agent: httpsAgent,
});
unaut.restore();
return data;
},

parseXML(XMLdata: string) {
const parser = new XMLParser({ ignoreAttributes: false });
const jsonData = parser.parse(XMLdata);
return jsonData;
},
};
export default Fetch;
Loading

0 comments on commit cb60b9d

Please sign in to comment.