@ngx-pwa/local-storage
Version:
Efficient local storage module for Angular: simple API based on native localStorage API, but internally stored via the asynchronous IndexedDB API for performance, and wrapped in RxJS observables to be homogeneous with other Angular modules.
46 lines • 2.43 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.packageName = void 0;
exports.getDependencyMajorVersion = getDependencyMajorVersion;
exports.getAllMainPaths = getAllMainPaths;
const schematics_1 = require("@angular-devkit/schematics");
const dependencies_1 = require("@schematics/angular/utility/dependencies");
const workspace_1 = require("@schematics/angular/utility/workspace");
exports.packageName = "@ngx-pwa/local-storage";
function getDependencyMajorVersion(name, host) {
const dependency = (0, dependencies_1.getPackageJsonDependency)(host, name);
/* Throw if Angular is not installed */
if (dependency === null) {
return undefined;
}
/* Remove semver signs if present and keep only the first number (major) */
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return Number.parseInt(dependency.version.replace("~", "").replace("^", "").split(".")[0], 10);
}
async function getAllMainPaths(host) {
const mainPaths = [];
const workspace = await (0, workspace_1.getWorkspace)(host);
/* Loop on all projects configured in angular.json */
workspace.projects.forEach((project) => {
var _a;
/* The schematic only work with applications (not librairies) */
if (project.extensions["projectType"] === "application") {
/* Get `main` option in angular.json project config */
const buildTarget = project.targets.get("build");
const e2eTarget = project.targets.get("e2e");
if (buildTarget) {
if (((_a = buildTarget.options) === null || _a === void 0 ? void 0 : _a["main"]) === undefined) {
throw new schematics_1.SchematicsException(`angular.json config is broken, can't find 'architect.build.options.main' in one or more projects`);
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
mainPaths.push(buildTarget.options["main"]);
}
else if (!e2eTarget) {
/* In old CLI projects, e2e where distinct applications project, we don't need to throw for them */
throw new schematics_1.SchematicsException(`angular.json config is broken, can't find 'architect.build.options.main' in one or more projects`);
}
}
});
return mainPaths;
}
//# sourceMappingURL=config.js.map