This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { createGlobPatternsForDependencies } = require('@nx/angular/tailwind'); | |
const { join } = require('path'); | |
const { Project } = require('ts-morph'); | |
const { workspaceRoot } = require('nx/src/utils/workspace-root'); | |
/** | |
* Get all the library imports from the given paths | |
* @param {string} scope | |
* @param {string[]} paths |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addPackageJsonDependency(tree, { | |
name: '@package/name', | |
version: '~2.0.0', | |
type: NodeDependencyType.Dev | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
removeImports(imports) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
editImports(imports, ({moduleSpecifier}) => ({ | |
moduleSpecifier: moduleSpecifier.replace('@org', '@new-org') | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const imports = getImports('src/**/*.ts', { | |
moduleSpecifier: '@org/*', | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
createImports('/src/some.ts', [ | |
{ | |
namedImports: ['CoreModule'], | |
moduleSpecifier: '@org/core', | |
isTypeOnly: true, | |
} | |
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setActiveProject(createProject(new NgMorphTree('/'))); | |
const enums = getEnums('/**/*.ts'); | |
editEnums(enums, ({name}) => ({name: name.toUpperCase()})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const rule: Rule = (tree: Tree, context: SchematicContext): void => { | |
setActiveProject(createProject(tree)); | |
const appModule = getMainModule('src/main.ts'); | |
addImportToNgModule(appModule, 'SomeModule'); | |
addImports(appModule.getFilePath(), {moduleSpecifier: '@some/package', namedExports: ['SomeModule']}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function addSymbolToNgModuleMetadata( | |
source: ts.SourceFile, | |
ngModulePath: string, | |
metadataField: string, | |
symbolName: string, | |
importPath: string | null = null, | |
): Change[] { | |
const nodes = getDecoratorMetadata(source, 'NgModule', '@angular/core'); | |
let node: any = nodes[0]; // tslint:disable-line:no-any |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Rule = (tree: Tree, context: SchematicContext) => Tree | Observable<Tree> | Rule | Promise<void | Rule> | void; |
NewerOlder