@valantic/spartacus-mock
Version:
This project offers you the possibility to mock the OCC Endpoints of your Composable Storefront (Spartacus). It uses the Mock Service Worker to mock the API calls.
28 lines • 1.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getWorkspace = getWorkspace;
exports.getAngularJsonFile = getAngularJsonFile;
const schematics_1 = require("@angular-devkit/schematics");
const jsonc_parser_1 = require("jsonc-parser");
const DEFAULT_POSSIBLE_PROJECT_FILES = ['/angular.json', '/.angular.json'];
function getWorkspace(host, files = DEFAULT_POSSIBLE_PROJECT_FILES) {
const workspaceConfig = getAngularJsonFile(host, files);
const path = files.filter((filePath) => host.exists(filePath))[0];
return {
path,
workspaceConfig,
};
}
function getAngularJsonFile(tree, possibleProjectFiles = DEFAULT_POSSIBLE_PROJECT_FILES) {
const path = possibleProjectFiles.filter((filePath) => tree.exists(filePath))[0];
if (!path) {
throw new schematics_1.SchematicsException(`Could not find Angular`);
}
const configBuffer = tree.read(path);
if (configBuffer === null) {
throw new schematics_1.SchematicsException(`Could not find (${path})`);
}
const angularJsonContent = configBuffer.toString();
return (0, jsonc_parser_1.parse)(angularJsonContent, undefined, { allowTrailingComma: true });
}
//# sourceMappingURL=workspace-utils.js.map