@rxap/plugin-utilities
Version:
Provides utility functions for Nx plugins, such as retrieving project dependencies, determining output paths, and interacting with package.json files. It simplifies common tasks within Nx executors and generators. This package helps streamline plugin deve
34 lines • 1.69 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetProjectConfiguration = GetProjectConfiguration;
exports.GetProjectRoot = GetProjectRoot;
exports.GetProjectSourceRoot = GetProjectSourceRoot;
exports.IsWorkspaceProject = IsWorkspaceProject;
const path_1 = require("path");
function GetProjectConfiguration(context, projectName = context.projectName) {
const { projectsConfigurations } = context;
if (!projectsConfigurations) {
throw new Error('The projectsConfigurations is undefined. Ensure the projectsConfigurations is passed into the executor context.');
}
if (!projectName) {
throw new Error('The projectName is undefined. Ensure the projectName is passed into the executor context.');
}
const projectConfiguration = projectsConfigurations.projects[projectName];
if (!projectConfiguration) {
throw new Error(`The project configuration for project '${projectName}' not found!`);
}
return projectConfiguration;
}
function GetProjectRoot(context, projectName = context.projectName) {
const projectConfiguration = GetProjectConfiguration(context, projectName);
return projectConfiguration.root;
}
function GetProjectSourceRoot(context, projectName = context.projectName) {
var _a;
const projectConfiguration = GetProjectConfiguration(context, projectName);
return (_a = projectConfiguration.sourceRoot) !== null && _a !== void 0 ? _a : (0, path_1.join)(projectConfiguration.root, 'src');
}
function IsWorkspaceProject(context, projectName = context.projectName) {
return ['', '/'].includes(GetProjectRoot(context, projectName));
}
//# sourceMappingURL=project.js.map