Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
...options,
'dot': '.',
relativePathToWorkspaceRoot,
}),
move(sourceRoot),
])),
mergeWith(
apply(url('./files/root'), [
template({
utils: strings,
...options,
'dot': '.',
relativePathToWorkspaceRoot,
rootInSrc,
}),
move(appDir),
])),
mergeWith(
apply(url('./files/lint'), [
template({
utils: strings,
...options,
tsLintRoot,
relativePathToWorkspaceRoot,
prefix,
}),
// TODO: Moving should work but is bugged right now.
// The __tsLintRoot__ is being used meanwhile.
// Otherwise the tslint.json file could be inside of the root folder and
// this block and the lint folder could be removed.
])),
schematic('module', {
return (host, context) => {
options.path = utils_1.getProjectPath(host, options);
// Build state based on options
const extensionState = getExtensionState(options);
const parsedPath = utils_1.parseName(options);
options.name = parsedPath.name;
options.path = parsedPath.path;
const templateSource = schematics_1.apply(schematics_1.url('./files'), [
options.spec ? schematics_1.noop() : schematics_1.filter(path => !path.endsWith('.spec.ts')),
schematics_1.template(Object.assign({}, utils_1.stringUtils, options, { extensionState })),
schematics_1.move(parsedPath.path)
]);
return schematics_1.chain([schematics_1.branchAndMerge(schematics_1.chain([schematics_1.mergeWith(templateSource)]))])(host, context);
};
}
function default_1(options) {
const schematicsVersion = require('@angular-devkit/schematics/package.json').version;
const coreVersion = require('@angular-devkit/core/package.json').version;
return schematics_1.mergeWith(schematics_1.apply(schematics_1.url('./files'), [
schematics_1.partitionApplyMerge((p) => !/\/src\/.*?\/files\//.test(p), schematics_1.template(Object.assign({}, options, { coreVersion,
schematicsVersion, dot: '.', dasherize: core_1.dasherize }))),
schematics_1.move(options.name),
]));
}
exports.default = default_1;
function createFiles(options: NormalizedSchema): Rule {
return mergeWith(
apply(url(`./files/lib`), [
template({
...options,
...names(options.name),
tmpl: '',
offsetFromRoot: offsetFromRoot(options.projectRoot)
}),
move(options.projectRoot)
])
);
}
}
const project = workspace.projects[options.project];
if (options.path === undefined) {
options.path = project_1.buildDefaultPath(project);
}
if (options.module) {
options.module = find_module_1.findModuleFromOptions(host, options);
}
const parsedPath = parse_name_1.parseName(options.path, options.name);
options.name = parsedPath.name;
options.path = parsedPath.path;
const templateSource = schematics_1.apply(schematics_1.url('./files'), [
options.spec ? schematics_1.noop() : schematics_1.filter(path => !path.endsWith('.spec.ts')),
options.routing ? schematics_1.noop() : schematics_1.filter(path => !path.endsWith('-routing.module.ts')),
schematics_1.template(Object.assign({}, core_1.strings, { 'if-flat': (s) => options.flat ? '' : s }, options)),
schematics_1.move(parsedPath.path),
]);
return schematics_1.chain([
schematics_1.branchAndMerge(schematics_1.chain([
addDeclarationToNgModule(options),
schematics_1.mergeWith(templateSource),
])),
]);
};
}
function generate(options: ControllerOptions) {
return apply(url(join('./files' as Path, options.language)), [
options.spec === 'true'
? noop()
: filter(path => !path.endsWith('.spec.ts')),
template({
...strings,
...options,
}),
move(options.path),
]);
}
function addServerlessAWS(options: IServerlessSchema): Rule {
const fileName = options.serverless && options.serverless.aws && options.serverless.aws.filename ? options.serverless.aws.filename : 'serverless.yml';
const source = apply(url('./files/aws'), [
move(options.directory)
]);
return chain([
mergeWith(source),
(tree: Tree) => {
tree.rename(`${options.directory}/serverless-aws.yml`, `${options.directory}/${fileName}`);
tree.overwrite(`${options.directory}/${fileName}`, getFileContent(tree, `${options.directory}/${fileName}`).replace('__appName__', options.clientProject.toLowerCase()));
addDependencyToPackageJson(tree, options, {
type: NodeDependencyType.Default,
name: 'aws-serverless-express',
version: '^3.2.0'
});
addDependencyToPackageJson(tree, options, {
type: NodeDependencyType.Dev,
name: 'serverless-apigw-binary',
version: '^0.4.4'
export function crud(options: ICrudOptions): Rule {
const name = strings.dasherize(basename(options.name as Path));
const fullName = join(dirname(options.name as Path), pluralize.plural(name));
const projectPath = options.path || '.';
const path = normalize(join(projectPath as Path, 'src/app', options.name, '..'));
return chain([
schematic('entity', options),
mergeWith(
apply(url('./files'), [
template({
...strings,
name,
fullName,
}),
formatTsFiles(),
move(path),
]),
),
updatePackageJson(projectPath),
updateModule(name, path),
]);
}