@spartacus/schematics
Version:
Spartacus schematics
27 lines • 1.58 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.removedPublicApiDeprecation = void 0;
const constants_1 = require("../../../shared/constants");
const file_utils_1 = require("../../../shared/utils/file-utils");
const workspace_utils_1 = require("../../../shared/utils/workspace-utils");
function removedPublicApiDeprecation(tree, context, removedNodes) {
var _a;
context.logger.info('Checking removed public api...');
const project = workspace_utils_1.getSourceRoot(tree, {});
const sourceFiles = file_utils_1.getAllTsSourceFiles(tree, project);
for (const originalSource of sourceFiles) {
const sourcePath = originalSource.fileName;
for (const removedNode of removedNodes) {
// 'source' has to be reloaded after each committed change
const source = file_utils_1.getTsSourceFile(tree, sourcePath);
const changes = file_utils_1.insertCommentAboveImportIdentifier(sourcePath, source, removedNode.node, removedNode.importPath, buildComment((_a = removedNode.comment) !== null && _a !== void 0 ? _a : `'${removedNode.node}' is no longer part of the public API. Please look into migration guide for more information`));
file_utils_1.commitChanges(tree, sourcePath, changes, file_utils_1.InsertDirection.RIGHT);
}
}
return tree;
}
exports.removedPublicApiDeprecation = removedPublicApiDeprecation;
function buildComment(content) {
return `// ${constants_1.TODO_SPARTACUS} ${content}\n`;
}
//# sourceMappingURL=removed-public-api-deprecation.js.map