@sap/bas-sdk
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -291,3 +291,12 @@ import { URL } from "url"; | ||
} | ||
/** | ||
* getDevspaceInfo returns information about the devspace- DevspaceInfo | ||
*/ | ||
export function getDevspaceInfo(): Promise<DevspaceInfo>; | ||
/** | ||
* didBASGeneratorsFinishInstallation checks if all the generators are installed | ||
*/ | ||
export function didBASGeneratorsFinishInstallation(): Promise<boolean>; | ||
} |
@@ -32,7 +32,8 @@ "use strict"; | ||
const getDevspaceInfo = __importStar(require("./apis/get-devspace")); | ||
const didBASGeneratorsFinishInstallation = __importStar(require("./apis/get-generators-installation-status")); | ||
exports.core = Object.assign(Object.assign(Object.assign(Object.assign({}, isAppStudio), headersHelper), runCommand), getEnvValue); | ||
exports.devspaceApi = Object.assign({}, devspaceApiFactory); | ||
exports.destinations = Object.assign(Object.assign({}, getDestinations), createDestination); | ||
exports.devspace = Object.assign({}, getDevspaceInfo); | ||
exports.devspace = Object.assign(Object.assign({}, getDevspaceInfo), didBASGeneratorsFinishInstallation); | ||
exports.hrtt = Object.assign({}, hanaHrttHelper); | ||
//# sourceMappingURL=index.js.map |
@@ -66,2 +66,6 @@ /** | ||
} | ||
export interface ExtensionsInstallationCompletion { | ||
InstalledModules?: any; | ||
InstallationCompleted: boolean; | ||
} | ||
/** | ||
@@ -74,1 +78,7 @@ * Create flat structure of exposed workspace information from given api call results. | ||
export declare function flattenDevspaceInfo(devspaceResults: DevspaceApiResults): DevspaceInfo; | ||
/** | ||
* Checks if generators installation JSON file is created and it can be parsed as plain object | ||
* @returns - an object of type ExtensionsInstallationCompletion with a field InstallationCompleted indicates generators installation result. | ||
* @throws - an error if the extensionsInstallationCompletion.json is not found under /extbin/extensionsInstallationCompletion | ||
*/ | ||
export declare function readExtensionsInstallationCompletionFile(): Promise<ExtensionsInstallationCompletion>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.flattenDevspaceInfo = void 0; | ||
exports.readExtensionsInstallationCompletionFile = exports.flattenDevspaceInfo = void 0; | ||
const fs_extra_1 = require("fs-extra"); | ||
const lodash_1 = require("lodash"); | ||
/** | ||
@@ -22,2 +24,21 @@ * Create flat structure of exposed workspace information from given api call results. | ||
exports.flattenDevspaceInfo = flattenDevspaceInfo; | ||
/** | ||
* Checks if generators installation JSON file is created and it can be parsed as plain object | ||
* @returns - an object of type ExtensionsInstallationCompletion with a field InstallationCompleted indicates generators installation result. | ||
* @throws - an error if the extensionsInstallationCompletion.json is not found under /extbin/extensionsInstallationCompletion | ||
*/ | ||
async function readExtensionsInstallationCompletionFile() { | ||
const filePath = "/extbin/extensionsInstallationCompletion/extensionsInstallationCompletion.json"; | ||
try { | ||
const fileContent = await fs_extra_1.readJson(filePath); | ||
if (lodash_1.isPlainObject(fileContent)) { | ||
return { InstallationCompleted: true }; | ||
} | ||
return { InstallationCompleted: false }; | ||
} | ||
catch (e) { | ||
throw new Error(`The ${filePath} file is missing.`); | ||
} | ||
} | ||
exports.readExtensionsInstallationCompletionFile = readExtensionsInstallationCompletionFile; | ||
//# sourceMappingURL=devspace-utils.js.map |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -8,5 +27,7 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
const axios_1 = __importDefault(require("axios")); | ||
const proxyquire_1 = __importDefault(require("proxyquire")); | ||
const axios_mock_adapter_1 = __importDefault(require("axios-mock-adapter")); | ||
const bas_sdk_sinon_helper_1 = require("@sap/bas-sdk-sinon-helper"); | ||
const get_devspace_1 = require("../../src/apis/get-devspace"); | ||
const generatorsInstallationStatus = __importStar(require("../../src/apis/get-generators-installation-status")); | ||
const getMockResponse = () => ({ | ||
@@ -152,3 +173,47 @@ devSpaceOriginLabel: "dev_space_origin_label", | ||
}); | ||
it("Should return devspace generators installation status completed", async () => { | ||
const devspaceUtilsProxy = proxyquire_1.default("../../src/utils/devspace-utils", { | ||
"fs-extra": { | ||
readJson: async (path) => { | ||
return { path }; | ||
}, | ||
"@noCallThru": true, | ||
}, | ||
"@noCallThru": true, | ||
}); | ||
const generatorsInstallationStatusProxy = proxyquire_1.default("../../src/apis/get-generators-installation-status", { | ||
"../utils/devspace-utils": devspaceUtilsProxy, | ||
"@noCallThru": true, | ||
}); | ||
chai_1.expect(await generatorsInstallationStatusProxy.didBASGeneratorsFinishInstallation()).to.be.true; | ||
}); | ||
it("Should return devspace generators installation status NOT completed", async () => { | ||
const devspaceUtilsProxy = proxyquire_1.default("../../src/utils/devspace-utils", { | ||
"fs-extra": { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- test | ||
readJson: async (path) => { | ||
return undefined; | ||
}, | ||
"@noCallThru": true, | ||
}, | ||
"@noCallThru": true, | ||
}); | ||
const generatorsInstallationStatusProxy = proxyquire_1.default("../../src/apis/get-generators-installation-status", { | ||
"../utils/devspace-utils": devspaceUtilsProxy, | ||
"@noCallThru": true, | ||
}); | ||
chai_1.expect(await generatorsInstallationStatusProxy.didBASGeneratorsFinishInstallation()).to.be.false; | ||
}); | ||
it("Should throw an error when devspace generators installation file is NOT found", async () => { | ||
const filePath = "/extbin/extensionsInstallationCompletion/extensionsInstallationCompletion.json"; | ||
try { | ||
await generatorsInstallationStatus.didBASGeneratorsFinishInstallation(); | ||
} | ||
catch (error) { | ||
if (error instanceof Error) { | ||
chai_1.expect(error.message).equals(`The ${filePath} file is missing.`); | ||
} | ||
} | ||
}); | ||
}); | ||
//# sourceMappingURL=get-devspace.spec.js.map |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const chai_1 = require("chai"); | ||
const sinon_1 = __importDefault(require("sinon")); | ||
const proxyquire_1 = __importDefault(require("proxyquire")); | ||
// import { SinonMock } from 'sinon'; | ||
const devspaceUtils = __importStar(require("../../src/utils/devspace-utils")); | ||
const devspace_utils_1 = require("../../src/utils/devspace-utils"); | ||
@@ -51,3 +77,47 @@ describe("Test for flattenDevspaceInfo()", () => { | ||
}); | ||
describe("readExtensionsInstallationCompletionFile()", () => { | ||
beforeEach(() => { | ||
sinon_1.default.createSandbox(); | ||
}); | ||
afterEach(() => { | ||
sinon_1.default.restore(); | ||
}); | ||
it("Return true when extensionsInstallationCompletion JSON file is found and read properly", async () => { | ||
const devspaceUtilsProxy = proxyquire_1.default("../../src/utils/devspace-utils", { | ||
"fs-extra": { | ||
readJson: async (path) => { | ||
return { path }; | ||
}, | ||
"@noCallThru": true, | ||
}, | ||
"@noCallThru": true, | ||
}); | ||
chai_1.expect(await devspaceUtilsProxy.readExtensionsInstallationCompletionFile()).deep.equals({ InstallationCompleted: true }); | ||
}); | ||
it("Return false when extensionsInstallationCompletion JSON file is empty", async () => { | ||
const devspaceUtilsProxy = proxyquire_1.default("../../src/utils/devspace-utils", { | ||
"fs-extra": { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- test | ||
readJson: async (path) => { | ||
return undefined; | ||
}, | ||
"@noCallThru": true, | ||
}, | ||
"@noCallThru": true, | ||
}); | ||
chai_1.expect(await devspaceUtilsProxy.readExtensionsInstallationCompletionFile()).deep.equals({ InstallationCompleted: false }); | ||
}); | ||
it("Throw when extensionsInstallationCompletion JSON file is NOT found", async () => { | ||
const filePath = "/extbin/extensionsInstallationCompletion/extensionsInstallationCompletion.json"; | ||
try { | ||
await devspaceUtils.readExtensionsInstallationCompletionFile(); | ||
} | ||
catch (error) { | ||
if (error instanceof Error) { | ||
chai_1.expect(error.message).equals(`The ${filePath} file is missing.`); | ||
} | ||
} | ||
}); | ||
}); | ||
}); | ||
//# sourceMappingURL=devsapce-utils.spec.js.map |
{ | ||
"name": "@sap/bas-sdk", | ||
"description": "SDK for SAP Business Application Studio", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"main": "dist/src/index.js", | ||
@@ -28,2 +28,3 @@ "license": "SAP", | ||
"cross-spawn": "^7.0.3", | ||
"fs-extra": "^11.1.0", | ||
"lodash": "4.17.21", | ||
@@ -34,10 +35,13 @@ "url-join": "^4.0.1", | ||
"devDependencies": { | ||
"@sap/bas-sdk-sinon-helper": "^3.1.0", | ||
"@sap/bas-sdk-sinon-helper": "^3.2.0", | ||
"@types/cross-spawn": "^6.0.2", | ||
"@types/fs-extra": "^11.0.1", | ||
"@types/lodash": "^4.14.182", | ||
"@types/proxyquire": "^1.3.28", | ||
"@types/url-join": "^4.0.0", | ||
"@types/uuid": "8.3.0", | ||
"@types/ws": "^8.5.2", | ||
"axios-mock-adapter": "^1.19.0" | ||
"axios-mock-adapter": "^1.19.0", | ||
"proxyquire": "^2.1.3" | ||
} | ||
} |
@@ -10,2 +10,3 @@ import * as isAppStudio from "./apis/is-app-studio"; | ||
import * as getDevspaceInfo from "./apis/get-devspace"; | ||
import * as didBASGeneratorsFinishInstallation from "./apis/get-generators-installation-status"; | ||
import * as publicApi from "../api"; | ||
@@ -28,3 +29,4 @@ | ||
...getDevspaceInfo, | ||
...didBASGeneratorsFinishInstallation, | ||
}; | ||
export const hrtt: typeof publicApi.hrtt = { ...hanaHrttHelper }; |
import { spawn } from "cross-spawn"; | ||
import { ChildProcessWithoutNullStreams } from "child_process"; | ||
import { isEmpty, isUndefined } from "lodash"; | ||
/** | ||
@@ -5,0 +6,0 @@ * Return true if the development platform is Buisness Application Studio otherwise return false |
@@ -0,1 +1,4 @@ | ||
import { readJson } from "fs-extra"; | ||
import { isPlainObject } from "lodash"; | ||
/** | ||
@@ -65,2 +68,8 @@ * Exposed devspace information | ||
export interface ExtensionsInstallationCompletion { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ignore for private func | ||
InstalledModules?: any; | ||
InstallationCompleted: boolean; | ||
} | ||
/** | ||
@@ -88,1 +97,20 @@ * Create flat structure of exposed workspace information from given api call results. | ||
} | ||
/** | ||
* Checks if generators installation JSON file is created and it can be parsed as plain object | ||
* @returns - an object of type ExtensionsInstallationCompletion with a field InstallationCompleted indicates generators installation result. | ||
* @throws - an error if the extensionsInstallationCompletion.json is not found under /extbin/extensionsInstallationCompletion | ||
*/ | ||
export async function readExtensionsInstallationCompletionFile(): Promise<ExtensionsInstallationCompletion> { | ||
const filePath = | ||
"/extbin/extensionsInstallationCompletion/extensionsInstallationCompletion.json"; | ||
try { | ||
const fileContent = await readJson(filePath); | ||
if (isPlainObject(fileContent)) { | ||
return { InstallationCompleted: true }; | ||
} | ||
return { InstallationCompleted: false }; | ||
} catch (e) { | ||
throw new Error(`The ${filePath} file is missing.`); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
377221
106
3894
6
10
5
+ Addedfs-extra@^11.1.0
+ Addedfs-extra@11.3.0(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedjsonfile@6.1.0(transitive)
+ Addeduniversalify@2.0.1(transitive)