@rxap/schematics-ts-morph
Version:
This package provides utilities for manipulating TypeScript code using ts-morph, particularly for Angular and NestJS projects. It offers functions to add, coerce, and modify code elements like classes, methods, decorators, and imports. The package also in
30 lines • 1.56 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AddNestModuleToAppModule = AddNestModuleToAppModule;
const schematics_utilities_1 = require("@rxap/schematics-utilities");
const path_1 = require("path");
const ts_morph_transform_1 = require("../ts-morph-transform");
const add_nest_module_import_1 = require("./add-nest-module-import");
const DEFAULT_APP_MODULE_PATH = '/app/app.module.ts';
function AddNestModuleToAppModule(options) {
const { project, feature, shared, name, directory, backend } = options;
let { appModulePath } = options;
appModulePath !== null && appModulePath !== void 0 ? appModulePath : (appModulePath = DEFAULT_APP_MODULE_PATH);
return (0, ts_morph_transform_1.TsMorphNestProjectTransformRule)({
project,
feature,
shared,
backend,
}, (project, [sourceFile]) => {
const cleanAppModulePath = (0, path_1.dirname)(appModulePath.replace(/^\//, ''));
const modulePath = (0, path_1.join)(directory !== null && directory !== void 0 ? directory : '', name + '.module');
const relativePath = (0, path_1.relative)(cleanAppModulePath, modulePath);
(0, add_nest_module_import_1.AddNestModuleImport)(sourceFile, (0, schematics_utilities_1.classify)(name) + 'Module', [
{
namedImports: [(0, schematics_utilities_1.classify)(name) + 'Module'],
moduleSpecifier: relativePath,
},
]);
}, [appModulePath]);
}
//# sourceMappingURL=add-nest-module-to-app-module.js.map