Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
inlineTemplate: true,
spec: false,
styleext: options.style,
};
const sourceDir = options.sourceDir || 'src';
return schematics_1.chain([
schematics_1.mergeWith(schematics_1.apply(schematics_1.url('./files'), [
// =====@delon/cli=====
options.delonI18n ? schematics_1.noop() : schematics_1.filter(path => path.indexOf('i18n.') === -1),
options.delonForm ? schematics_1.noop() : schematics_1.filter(path => path.indexOf('json-schema') === -1),
options.delonElectron ? schematics_1.noop() : schematics_1.filter(path => path.indexOf('electron') === -1 && path.indexOf('gulpfile.js') === -1),
// =====@delon/cli=====
options.minimal ? schematics_1.filter(minimalPathFilter) : schematics_1.noop(),
options.skipGit ? schematics_1.filter(path => !path.endsWith('/__dot__gitignore')) : schematics_1.noop(),
options.serviceWorker ? schematics_1.noop() : schematics_1.filter(path => !path.endsWith('/ngsw-config.json')),
schematics_1.template(Object.assign({ utils: stringUtils }, options, { 'dot': '.', sourcedir: sourceDir })),
schematics_1.move(options.directory),
])),
schematics_1.schematic('module', {
name: 'app',
commonModule: false,
flat: true,
routing: options.routing,
routingScope: 'Root',
path: options.path,
sourceDir: options.directory + '/' + sourceDir,
spec: false,
}),
schematics_1.schematic('component', Object.assign({ name: 'app', selector: appRootSelector, sourceDir: options.directory + '/' + sourceDir, flat: true, path: options.path }, componentOptions)),
addBootstrapToNgModule(options.directory, sourceDir),
schematics_1.mergeWith(schematics_1.apply(schematics_1.url('./other-files'), [
// =====@delon/cli=====
if (!options.project) {
throw new schematics_1.SchematicsException('Option "project" is required.');
}
const project = workspace.projects[options.project];
if (!project) {
throw new schematics_1.SchematicsException(`Invalid project name (${options.project})`);
}
if (project.projectType !== 'application') {
throw new schematics_1.SchematicsException(`Service worker requires a project type of "application".`);
}
let { resourcesOutputPath = '' } = getProjectConfiguration(workspace, options);
if (resourcesOutputPath) {
resourcesOutputPath = '/' + resourcesOutputPath.split('/').filter(x => !!x).join('/');
}
const templateSource = schematics_1.apply(schematics_1.url('./files'), [
schematics_1.template(Object.assign({}, options, { resourcesOutputPath })),
schematics_1.move(project.root),
]);
context.addTask(new tasks_1.NodePackageInstallTask());
return schematics_1.chain([
schematics_1.mergeWith(templateSource),
updateConfigFile(options),
addDependencies(),
updateAppModule(options),
]);
};
}
apply(root: DirEntry): Rule {
const directory = this.name ? root.dir(fragment(this.filename)) : root;
return chain([
mergeWith(
apply(url('./files/collection'), [
template({
...strings,
...this
}),
move(directory.path)
])
),
...this.collections.map(c => c.apply(directory)),
...this.icons.map(i => i.apply(directory))
]);
}
}
name: 'app',
commonModule: false,
flat: true,
routing: options.routing,
routingScope: 'Root',
sourceDir: options.directory + '/' + sourceDir,
spec: false,
}),
schematics_1.schematic('component', Object.assign({ name: 'app', selector: appRootSelector, sourceDir: options.directory + '/' + sourceDir, flat: true }, componentOptions)),
addBootstrapToNgModule(options.directory, sourceDir),
schematics_1.mergeWith(schematics_1.apply(schematics_1.url('./other-files'), [
componentOptions.inlineTemplate ? schematics_1.filter(path => !path.endsWith('.html')) : schematics_1.noop(),
!componentOptions.spec ? schematics_1.filter(path => !path.endsWith('.spec.ts')) : schematics_1.noop(),
!options.material ? schematics_1.filter(materialPathFilter) : schematics_1.noop(),
!options.ssr ? schematics_1.filter(ssrPathOtherFilter) : schematics_1.noop(),
schematics_1.template(Object.assign({ utils: stringUtils }, options, { selector: appRootSelector }, componentOptions)),
schematics_1.move(options.directory + '/' + sourceDir + '/app'),
]), schematics_1.MergeStrategy.Overwrite),
])(host, context);
};
}
return (host, context) => {
setupOptions(options, host, context);
const templateSource = schematics_1.apply(schematics_1.url('./files'), [
schematics_1.template(Object.assign({}, schematics_core_1.stringUtils, options, { 'i18nLocale': options['i18n-locale'], 'i18nFormat': options['i18n-format'] })),
schematics_1.move(options.path ? options.path : ''),
]);
const configurationAdditions = options.parsedLanguages
.filter(lang => lang !== options['i18n-locale'])
.map(lang => addLanguageConfigurationToProject(options, lang));
return schematics_1.chain([
schematics_1.branchAndMerge(schematics_1.chain([addExtractScriptToPackageJson(options), ...configurationAdditions, schematics_1.mergeWith(templateSource)])),
addXliffmergeDependencyToPackageJson(),
])(host, context);
};
}
return (host, context) => {
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 (!project) {
throw new schematics_1.SchematicsException(`Invalid project name (${options.project})`);
}
if (project.projectType !== 'application') {
throw new schematics_1.SchematicsException(`Service worker requires a project type of "application".`);
}
const templateSource = schematics_1.apply(schematics_1.url('./files'), [
schematics_1.template(Object.assign({}, options)),
schematics_1.move(project.root),
]);
context.addTask(new tasks_1.NodePackageInstallTask());
return schematics_1.chain([
schematics_1.mergeWith(templateSource),
updateConfigFile(options),
addDependencies(),
updateAppModule(options),
]);
};
}
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;
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)
])
)
);
};
export function main(options: IControllerOptions): Rule {
const name = strings.dasherize(basename(options.name as Path));
const fullName = strings.dasherize(join(dirname(options.name as Path), pluralize.plural(name)));
const projectPath = options.path || '.';
const path: Path = strings.dasherize(normalize(join(projectPath as Path, 'src/app', options.name, '..'))) as Path;
return chain([
mergeWith(
apply(url('./files'), [
options.spec ? noop() : filter(p => !p.endsWith('.spec.ts')),
template({
...strings,
name,
fullName,
}),
move(path),
formatTsFiles(),
]),
),
(tree: Tree): Tree => {
addBarrels(tree, join(path, 'controllers'), name + '.controller');
return tree;
},
updateModule(name, path),
]);
}
return (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);
}
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'), [
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),
])),
options.lintFix ? lint_fix_1.applyLintFix(options.path) : schematics_1.noop(),
]);
};
}