Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const project = getProject(host, id);
if (options.path === undefined) {
options.path = buildDefaultPath(project);
}
options.module = findModuleFromOptions(host, options);
const parsedPath = parseName(options.path, options.name);
options.name = parsedPath.name;
options.path = parsedPath.path;
validateName(options.name);
console.log(options);
const templateSource = apply(url('./_files'), [
template({
...strings,
...options,
}),
// move(parsedPath.path),
]);
const rule = chain([branchAndMerge(chain([mergeWith(templateSource)]))]);
return rule(host, context);
};
}
if (!options.project) {
throw new schematics_1.SchematicsException('Option (project) is required.');
}
const project = project_1.getProject(host, options.project);
if (options.path === undefined) {
options.path = project_1.buildDefaultPath(project);
}
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;
options.selector = options.selector || buildSelector(options, project.prefix);
validation_1.validateHtmlSelector(options.selector);
// todo remove these when we remove the deprecations
options.skipTests = options.skipTests || !options.spec;
const templateSource = schematics_1.apply(schematics_1.url('./files'), [
options.skipTests ? schematics_1.filter(path => !path.endsWith('.spec.ts')) : schematics_1.noop(),
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),
])),
options.lintFix ? lint_fix_1.applyLintFix(options.path) : schematics_1.noop(),
]);
};
}
return host => {
return mergeWith(
apply(url('./files/root-build-file'), [
template({
tmpl: '',
rootFiles: host
.getDir('/')
.subfiles.filter(f => !ignoredFromRootBuildFile.includes(f))
}),
() => {
if (host.exists('BUILD.bazel')) {
host.delete('BUILD.bazel');
}
}
]),
MergeStrategy.Overwrite
);
};
}
function default_1(options) {
options.prefix = options.prefix ? options.prefix : '';
options.type = !!options.type ? `.${options.type}` : '';
options.path = options.path ? core_1.normalize(options.path) : options.path;
const sourceDir = options.sourceDir;
if (!sourceDir) {
throw new schematics_1.SchematicsException(`sourceDir option is required.`);
}
const templateSource = schematics_1.apply(schematics_1.url('./files'), [
schematics_1.template(Object.assign({}, stringUtils, options)),
schematics_1.move(sourceDir),
]);
return schematics_1.chain([
schematics_1.branchAndMerge(schematics_1.chain([
schematics_1.mergeWith(templateSource),
])),
]);
}
exports.default = default_1;
return (context: SchematicContext) =>
apply(url(join('./files' as Path, options.language)), [
options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),
template({
...strings,
...options,
}),
move(options.path),
])(context);
}
export function addFiles(
options: Schema,
target: string = '',
projectName: string = '',
extra: string = ''
) {
let moveTo: string;
if (target) {
moveTo = getMoveTo(options, target, projectName);
} else {
target = 'lib';
moveTo = `libs/features/${options.name.toLowerCase()}`;
}
return branchAndMerge(
mergeWith(
apply(url(`./${extra}_files`), [
template(getTemplateOptions(options)),
move(moveTo)
])
)
);
};
function addAppFiles(
options: Schema,
appPath: string,
extra: string = ''
): Rule {
extra = extra ? `${extra}_` : '';
const appname = getAppName(options, 'nativescript');
const directory = options.directory ? `${options.directory}/` : '';
return branchAndMerge(
mergeWith(
apply(url(`./_${extra}files`), [
template({
...(options as any),
...getDefaultTemplateOptions(),
appname,
pathOffset: directory ? '../../../' : '../../',
xplatFolderName: XplatHelpers.getXplatFoldername(
'nativescript',
'angular'
)
}),
move(`apps/${directory}${appPath}`)
])
)
);
}
function addGlobalKarmaConf() {
const templateSource = url('./files');
return mergeWith(templateSource);
}
return (host) => {
const workspace = config_1.getWorkspace(host);
if (!options.project) {
throw new schematics_1.SchematicsException('Option (project) is required.');
}
const project = workspace.projects[options.project];
if (options.path === undefined) {
options.path = project_1.buildDefaultPath(project);
}
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')),
schematics_1.template(Object.assign({}, core_1.strings, options)),
schematics_1.move(parsedPath.path),
]);
return schematics_1.chain([
schematics_1.branchAndMerge(schematics_1.chain([
schematics_1.mergeWith(templateSource),
])),
]);
};
}