Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(tree: Tree, context: SchematicContext) => {
const nrwlWebOptions = {
...options,
skipInstall: true
};
let executionOptions: Partial;
if (options.useXplat) {
// when generating xplat architecture, ensure:
// 1. sass is used
nrwlWebOptions.style = 'scss';
// executionOptions = {
// interactive: false
// };
}
return externalSchematic(
'@nrwl/angular',
'app',
nrwlWebOptions,
executionOptions
)(tree, context);
},
(tree: Tree, context: SchematicContext) =>
return (tree: Tree, context: SchematicContext) => {
const rules: Rule[] = [];
const collectionPath = join(__dirname, '../../../collection.json');
// run external migration schematics
rules.push(externalSchematic(collectionPath, 'update-5.0.0', {}));
return chain(rules)(tree, context);
};
}
export async function createTestUILib(libName: string): Promise {
let appTree = Tree.empty();
appTree = createEmptyWorkspace(appTree);
appTree = await callRule(
externalSchematic('@nrwl/angular', 'library', {
name: libName
}),
appTree
);
appTree = await callRule(
externalSchematic('@schematics/angular', 'component', {
name: 'test-button',
project: libName
}),
appTree
);
appTree.overwrite(
`libs/${libName}/src/lib/test-button/test-button.component.ts`,
`
import { Component, OnInit, Input } from '@angular/core';
export type ButtonStyle = 'default' | 'primary' | 'accent';
@Component({
selector: 'proj-test-button',
templateUrl: './test-button.component.html',
styleUrls: ['./test-button.component.css']
export const addRendererProject = (options: NgGenerateOptions) => {
console.log('⚙️ addRendererProject');
const rendererName = options.singleProject ? options.project : options.project + options.rendererPrefix;
return externalSchematic('@schematics/angular', 'application', { name: rendererName });
}
setDefaultCollection('@nrwl/angular'),
connectAngularAndNest(options)
]);
} else if (options.preset === 'react-express') {
return chain([
externalSchematic(
'@nrwl/react',
'application',
{
name: options.name,
style: options.style,
linter
},
{ interactive: false }
),
externalSchematic(
'@nrwl/express',
'application',
{
name: 'api',
frontendProject: options.name,
linter
},
{ interactive: false }
),
schematic(
'library',
{ name: 'api-interfaces', linter },
{ interactive: false }
),
setDefaultCollection('@nrwl/react'),
connectReactAndExpress(options)
url(options.testDepth === 'unit' ? './files' : './integration-files'),
[
options.spec
? noop()
: filter(path => !path.endsWith('.spec.ts.template')),
applyTemplates({
'if-flat': (s: string) => (options.flat ? '' : s),
...stringUtils,
...(options as object),
} as any),
move(parsedPath.path),
]
);
return chain([
externalSchematic('@schematics/angular', 'component', {
...opts,
spec: false,
}),
addStateToComponent(options),
mergeWith(templateSource),
])(host, context);
};
}
function spectatorDirectiveSchematic(options) {
return schematics_1.chain([
schematics_1.externalSchematic('@schematics/angular', 'directive', Object.assign({}, options, { skipTests: true, spec: false })),
(tree, _context) => {
_ensurePath(tree, options);
const movePath = core_1.normalize(options.path || '');
const specTemplateRule = schematics_1.apply(schematics_1.url(`./files/directive`), [
schematics_1.template(Object.assign({}, core_1.strings, options)),
schematics_1.move(movePath)
]);
return schematics_1.mergeWith(specTemplateRule, schematics_1.MergeStrategy.Default);
}
]);
}
exports.spectatorDirectiveSchematic = spectatorDirectiveSchematic;
export async function createTestUILib(libName: string): Promise {
let appTree = Tree.empty();
appTree = createEmptyWorkspace(appTree);
appTree = await callRule(
externalSchematic('@nrwl/angular', 'library', {
name: libName
}),
appTree
);
appTree = await callRule(
externalSchematic('@schematics/angular', 'component', {
name: 'test-button',
project: libName
}),
appTree
);
appTree.overwrite(
`libs/${libName}/src/lib/test-button/test-button.component.ts`,
`
import { Component, OnInit, Input } from '@angular/core';
export type ButtonStyle = 'default' | 'primary' | 'accent';
@Component({
selector: 'proj-test-button',
templateUrl: './test-button.component.html',
styleUrls: ['./test-button.component.css']
(tree: Tree, context: SchematicContext) =>
externalSchematic('@nstudio/xplat', 'init', options)
]);
export function main(options: GuardOptions) {
const newOptions = { ...options };
newOptions.name = options.name.startsWith('app/') ? options.name : 'app/' + options.name;
if (newOptions.path) {
newOptions.path = join(options.path as Path, 'src');
}
newOptions.language = 'ts';
const path = newOptions.path || './src';
const dir = dirname(newOptions.name as Path);
const base = strings.dasherize(basename(newOptions.name as Path));
return chain([
externalSchematic('@nestjs/schematics', 'guard', newOptions),
move(
strings.dasherize(join(path as Path, dir, base + '.guard.ts')),
strings.dasherize(join(path as Path, dir, 'guards', base + '.guard.ts')),
),
move(
strings.dasherize(join(path as Path, dir, base + '.guard.spec.ts')),
strings.dasherize(join(path as Path, dir, 'guards', base + '.guard.spec.ts')),
),
]);
}