@nstudio/angular
Version:
Angular Plugin for xplat
140 lines (139 loc) • 4.12 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.runSchematic = runSchematic;
exports.callRule = callRule;
exports.getAppConfig = getAppConfig;
exports.getLibConfig = getLibConfig;
const path_1 = require("path");
const testing_1 = require("@angular-devkit/schematics/testing");
// import { createApp, createLib } from '@nx/angular/testing';
// import { names, toFileName } from '@nx/workspace';
const testRunner = new testing_1.SchematicTestRunner('@nstudio/angular', (0, path_1.join)(__dirname, '../../collection.json'));
function runSchematic(schematicName, options, tree) {
return testRunner.runSchematic(schematicName, options, tree);
}
// export function runSchematicSync(
// schematicName: string,
// options: any,
// tree: Tree
// ) {
// return testRunner.runSchematicAs(schematicName, options, tree);
// }
function callRule(rule, tree) {
return testRunner.callRule(rule, tree).toPromise();
}
var appConfig; // configure built in createApp()
var libConfig;
function getAppConfig() {
return appConfig;
}
function getLibConfig() {
return libConfig;
}
// export function createApp(
// tree: Tree,
// appName: string,
// routing: boolean = true
// ): Tree {
// appName = toFileName(appName);
// // save for getAppDir() lookup by external *.spec.ts tests
// appConfig = {
// appName,
// appModule: `/apps/${appName}/src/app/app.module.ts`
// };
// tree.create(
// appConfig.appModule,
// `
// import { NgModule } from '@angular/core';
// import { BrowserModule } from '@angular/platform-browser';
// ${routing ? "import { RouterModule } from '@angular/router'" : ''};
// import { AppComponent } from './app.component';
// @NgModule({
// imports: [BrowserModule, ${routing ? 'RouterModule.forRoot([])' : ''}],
// declarations: [AppComponent],
// bootstrap: [AppComponent]
// })
// export class AppModule {}
// `
// );
// tree.create(
// `/apps/${appName}/src/main.ts`,
// `
// import { enableProdMode } from '@angular/core';
// import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
// import { AppModule } from './app/app.module';
// import { environment } from './environments/environment';
// if (environment.production) {
// enableProdMode();
// }
// platformBrowserDynamic()
// .bootstrapModule(AppModule)
// .catch(err => console.log(err));
// `
// );
// tree.create(
// `/apps/${appName}/tsconfig.app.json`,
// JSON.stringify({
// include: ['**/*.ts']
// })
// );
// tree.create(
// `/apps/${appName}-e2e/tsconfig.e2e.json`,
// JSON.stringify({
// include: ['../**/*.ts']
// })
// );
// tree.overwrite(
// '/angular.json',
// JSON.stringify({
// newProjectRoot: '',
// version: 1,
// projects: {
// [appName]: {
// root: `apps/${appName}`,
// sourceRoot: `apps/${appName}/src`,
// architect: {
// build: {
// options: {
// main: `apps/${appName}/src/main.ts`
// }
// },
// serve: {
// options: {}
// }
// }
// }
// }
// })
// );
// return tree;
// }
// export function createLib(tree: Tree, libName: string): Tree {
// const { name, className, fileName, propertyName } = names(libName);
// libConfig = {
// name,
// module: `/libs/${propertyName}/src/lib/${fileName}.module.ts`,
// barrel: `/libs/${propertyName}/src/index.ts`
// };
// tree.create(
// libConfig.module,
// `
// import { NgModule } from '@angular/core';
// import { CommonModule } from '@angular/common';
// @NgModule({
// imports: [
// CommonModule
// ],
// providers: []
// })
// export class ${className}Module { }
// `
// );
// tree.create(
// libConfig.barrel,
// `
// export * from './lib/${fileName}.module';
// `
// );
// return tree;
// }
;