@nstudio/schematics
Version:
Cross-platform (xplat) tools for Nx workspaces.
133 lines (130 loc) • 4.44 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
function createEmptyWorkspace(tree) {
tree.create('/angular.json', JSON.stringify({
$schema: "./node_modules/@angular/cli/lib/config/schema.json",
projects: {},
newProjectRoot: '',
cli: {
defaultCollection: "@nrwl/schematics"
}
}));
tree.create('/nx.json', JSON.stringify({
npmScope: "testing",
projects: {}
}));
tree.create('/.gitignore', '');
tree.create('/package.json', JSON.stringify({
name: 'testing',
dependencies: {},
devDependencies: {},
xplat: {
prefix: 'tt'
}
}));
tree.create('/tsconfig.json', JSON.stringify({ compilerOptions: { paths: {} } }));
tree.create('/tslint.json', JSON.stringify({
rules: {
'nx-enforce-module-boundaries': [
true,
{
npmScope: '<%= npmScope %>',
lazyLoad: [],
allow: []
}
]
}
}));
return tree;
}
exports.createEmptyWorkspace = createEmptyWorkspace;
function createXplatWithAppsForElectron(tree) {
tree = createXplatWithApps(tree);
tree.overwrite('angular.json', JSON.stringify({
$schema: "./node_modules/@angular/cli/lib/config/schema.json",
projects: {
'web-viewer': {
architect: {
build: {
options: {
assets: []
}
},
serve: {
options: {},
configurations: {
production: {}
}
}
}
}
}
}));
tree.overwrite('/nx.json', JSON.stringify({
npmScope: "testing",
projects: {
'web-viewer': {
tags: []
}
}
}));
tree.create('/tools/tsconfig.tools.json', JSON.stringify({
"extends": "../tsconfig.json"
}));
return tree;
}
exports.createXplatWithAppsForElectron = createXplatWithAppsForElectron;
function createXplatWithApps(tree) {
tree = createEmptyWorkspace(tree);
createStandardWebFiles(tree);
return tree;
}
exports.createXplatWithApps = createXplatWithApps;
function createStandardWebFiles(tree) {
tree.create('/apps/web-viewer/src/index.html', '');
tree.create('/apps/web-viewer/src/app/features/core/core.module.ts', '');
tree.create('/apps/web-viewer/src/app/app.module.ts', '');
tree.create('/apps/web-viewer/src/app/app.routing.ts', `import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
// app
import { SharedModule } from './features/shared/shared.module';
const routes: Routes = [
{
path: '',
redirectTo: '/home',
pathMatch: 'full'
},
{
path: 'home',
loadChildren: './features/home/home.module#HomeModule'
}
];
@NgModule({
imports: [
SharedModule,
RouterModule.forRoot(routes)
]
})
export class AppRoutingModule {}`);
}
exports.createStandardWebFiles = createStandardWebFiles;
exports.isInModuleMetadata = (moduleName, property, value, inArray) => exports.isInDecoratorMetadata(moduleName, property, value, 'NgModule', inArray);
exports.isInComponentMetadata = (componentName, property, value, inArray) => exports.isInDecoratorMetadata(componentName, property, value, 'Component', inArray);
exports.isInDecoratorMetadata = (moduleName, property, value, decoratorName, inArray) => new RegExp(`@${decoratorName}\\(\\{([^}]*)` +
objectContaining(property, value, inArray) +
'[^}]*\\}\\)' +
'\\s*' +
`(export )?class ${moduleName}`);
const objectContaining = (property, value, inArray) => inArray ?
keyValueInArray(property, value) :
keyValueString(property, value);
const keyValueInArray = (property, value) => `${property}: \\[` +
nonLastValueInArrayMatcher +
`${value},?` +
nonLastValueInArrayMatcher +
lastValueInArrayMatcher +
`\\s*]`;
const nonLastValueInArrayMatcher = `(\\s*|(\\s*(\\w+,)*)\\s*)*`;
const lastValueInArrayMatcher = `(\\s*|(\\s*(\\w+)*)\\s*)?`;
const keyValueString = (property, value) => `${property}: ${value}`;
//# sourceMappingURL=testing.js.map
;