Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const componentNames = options.components.split(',');
for (let component of componentNames) {
// using short name ("menu" for a component named "MenuComponent")
// convert to fully best practice name
const isShortName =
component.toLowerCase().indexOf('component') === -1;
let selector = `${workspacePrefix ? `${workspacePrefix}-` : ''}`;
if (isShortName) {
selector += component.toLowerCase();
} else {
const parts = component.toLowerCase().split('component');
selector += parts[0];
}
componentSymbols.push({
selector,
symbol: `${stringUtils.classify(component)}${
isShortName ? 'Component' : ''
}`
});
htmlElementList.push(`<${selector}>`);
}
componentSymbolList = componentSymbols.map(c => c.symbol).join(', ');
htmlElements = htmlElementList.join('\n');
customElementList = createCustomElementList(componentSymbols);
}
return tree;
},
// add custom element module
function builderElementsContent(name: string) {
return `import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { ${stringUtils.classify(name)}Module } from '../${name}.module';
platformBrowserDynamic()
.bootstrapModule(${stringUtils.classify(name)}Module)
.catch(err => console.log(err));
`;
}
function builderElementsContent(name: string) {
return `import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { ${stringUtils.classify(name)}Module } from '../${name}.module';
platformBrowserDynamic()
.bootstrapModule(${stringUtils.classify(name)}Module)
.catch(err => console.log(err));
`;
}
function electronModule() {
return `import { NgModule } from '@angular/core';
import { ${stringUtils.classify(
getPrefix()
)}ElectronCoreModule } from '@${getNpmScope()}/${XplatHelpers.getXplatFoldername(
'electron',
'angular'
)}';
import { AppModule } from './app.module';
import { AppComponent } from './app.component';
@NgModule({
imports: [AppModule, ${stringUtils.classify(getPrefix())}ElectronCoreModule],
bootstrap: [AppComponent]
})
export class AppElectronModule {}`;
}
xplat: {
prefix: 'tt'
}
})
);
const tree = await runSchematic('app', options, appTree);
const appModule = getFileContent(
tree,
'/apps/nativescript-foo/src/core/core.module.ts'
);
expect(appModule).toMatch(
isInModuleMetadata(
'CoreModule',
'imports',
`${stringUtils.classify(options.prefix)}CoreModule`,
true
)
);
expect(appModule).toMatch(
`import { ${stringUtils.classify(options.prefix)}CoreModule } from \'@${
options.npmScope
}/nativescript-angular\'`
);
});