Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getModuleSpecifier(gestureConfigPath, sourceFile.fileName), false,
this._getGestureConfigIdentifiersOfFile(sourceFile));
const hammerConfigTokenExpr = this._importManager.addImportToSourceFile(
sourceFile, HAMMER_CONFIG_TOKEN_NAME, HAMMER_CONFIG_TOKEN_MODULE);
const newProviderNode = ts.createObjectLiteral([
ts.createPropertyAssignment('provide', hammerConfigTokenExpr),
ts.createPropertyAssignment('useClass', gestureConfigExpr)
]);
// If the providers field exists and already contains references to the hammer gesture
// config token and the gesture config, we naively assume that the gesture config is
// already set up. We only want to add the gesture config provider if it is not set up.
if (!providerIdentifiers ||
!(this._hammerConfigTokenReferences.some(r => providerIdentifiers.includes(r.node)) &&
this._gestureConfigReferences.some(r => providerIdentifiers.includes(r.node)))) {
addSymbolToNgModuleMetadata(
sourceFile, relativePath, 'providers', this._printNode(newProviderNode, sourceFile), null)
.forEach(change => {
if (change instanceof InsertChange) {
recorder.insertRight(change.pos, change.toAdd);
}
});
}
}
function addToMetadata(
host: Tree,
modulePath: string,
importText: string,
metadataType: 'imports' | 'declarations' | 'entryComponents' | 'exports',
moduleSource?: ts.SourceFile
): InsertChange[] {
moduleSource = moduleSource || getTsSourceFile(host, modulePath);
return addSymbolToNgModuleMetadata(
moduleSource,
modulePath,
metadataType,
importText
) as InsertChange[];
}
return (host: Tree) => {
const workspace = getWorkspace(host);
const project = getProjectFromWorkspace(workspace, options.project);
const appModulePath = getAppModulePath(host, getProjectMainFile(project));
const moduleSource = getSourceFile(host, appModulePath);
if (!moduleSource) {
throw new SchematicsException(`Module not found: ${appModulePath}`);
}
const changes = addSymbolToNgModuleMetadata(moduleSource, appModulePath, 'schemas', 'CUSTOM_ELEMENTS_SCHEMA', '@angular/core');
const declarationRecorder = host.beginUpdate(appModulePath);
for (const change of changes) {
if (change instanceof InsertChange) {
declarationRecorder.insertLeft(change.pos, change.toAdd);
}
}
host.commitUpdate(declarationRecorder);
return host;
}
}
(tree: Tree) => {
const moduleSource = getSourceFile(tree, modulePath);
const recorder = tree.beginUpdate(modulePath);
const metadataChange = addSymbolToNgModuleMetadata(
moduleSource, modulePath,
'schemas', 'NO_ERRORS_SCHEMA',
'@angular/core');
metadataChange.forEach((change: InsertChange) =>
recorder.insertRight(change.pos, change.toAdd),
);
tree.commitUpdate(recorder);
return tree;
};
const addNSCommonModule = (tree: Tree, modulePath: string) => {
const moduleSource = getSourceFile(tree, modulePath);
const recorder = tree.beginUpdate(modulePath);
const metadataChange = addSymbolToNgModuleMetadata(
moduleSource, modulePath,
'imports', 'NativeScriptCommonModule',
'nativescript-angular/common');
metadataChange.forEach((change: InsertChange) =>
recorder.insertRight(change.pos, change.toAdd)
);
tree.commitUpdate(recorder);
return tree;
};