@o3r/schematics
Version:
Schematics module of the Otter framework
50 lines • 2.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TYPES_DEFAULT_FOLDER = exports.OTTER_ITEM_TYPES = void 0;
exports.getDestinationPath = getDestinationPath;
const collection_1 = require("./collection");
const error_1 = require("./error");
const loaders_1 = require("./loaders");
/** List of Otter items types */
exports.OTTER_ITEM_TYPES = [
'@o3r/core:component',
'@o3r/core:page',
'@o3r/core:service',
'@o3r/core:store',
'@o3r/core:schematics-update',
'@o3r/testing:playwright-scenario',
'@o3r/testing:playwright-sanity'
];
/** List of the default destination paths for each generated entity */
exports.TYPES_DEFAULT_FOLDER = {
'@o3r/core:component': { app: 'src/components', lib: 'src/components' },
'@o3r/core:page': { app: 'src/app' },
'@o3r/core:service': { app: 'src/services', lib: 'src/services' },
'@o3r/core:store': { app: 'src/store', lib: 'src/store' },
'@o3r/core:schematics-update': { app: 'src/schematics', lib: 'src/schematics' },
'@o3r/testing:playwright-scenario': { app: 'e2e-playwright/scenarios' },
'@o3r/testing:playwright-sanity': { app: 'e2e-playwright/sanity' }
};
/**
* Get destination path for a generated item
* @param typeOfItem
* @param directory
* @param tree
* @param project
*/
function getDestinationPath(typeOfItem, directory, tree, project) {
if (directory) {
return directory;
}
const getSchematicsProperty = (generatorName, propTree, propProject) => {
const workspace = (0, loaders_1.getWorkspaceConfig)(propTree);
const [collection, schematicName] = generatorName.split(':');
return ((workspace && (0, collection_1.getDefaultOptionsForSchematic)(workspace, collection, schematicName, { projectName: propProject || undefined })) || null); // TODO: Check why `getDefaultOptionsForSchematic` expect a type matching `WorkspaceLayout`
};
const config = getSchematicsProperty(typeOfItem, tree, project);
if (config && config.path) {
return config.path;
}
throw new error_1.O3rCliError('No destination directory configured.');
}
//# sourceMappingURL=generation.js.map