How to use the @schematics/angular/utility/find-module.buildRelativePath function in @schematics/angular

To help you get started, we’ve selected a few @schematics/angular examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github intershop / intershop-pwa / schematics / src / utils / registration.js View on Github external
return host => {
        const source = filesystem_1.readIntoSourceFile(host, options.module);
        const relativePath = options.moduleImportPath
            ? find_module_1.buildRelativePath(options.module, options.moduleImportPath)
            : undefined;
        const declarationChanges = ast_utils_1.addProviderToModule(source, options.module, options.artifactName, relativePath);
        const declarationRecorder = host.beginUpdate(options.module);
        for (const change of declarationChanges) {
            if (change instanceof change_1.InsertChange) {
                declarationRecorder.insertLeft(change.pos, change.toAdd);
            }
        }
        host.commitUpdate(declarationRecorder);
        return host;
    };
}
github angular-extensions / schematics / src / model / index.js View on Github external
return (host) => {
        if (!options.module) {
            return host;
        }
        const modulePath = `${options.path}/${options.module}`;
        const moduleSource = readIntoSourceFile(host, modulePath);
        const servicePath = `${options.path}/` +
            (options.flat ? '' : core_1.strings.dasherize(options.name) + '/') +
            core_1.strings.dasherize(options.name) +
            '.service';
        const relativePath = find_module_1.buildRelativePath(modulePath, servicePath);
        const classifiedName = core_1.strings.classify(`${options.name}Service`);
        const providersChanges = ast_utils_1.addProviderToModule(moduleSource, modulePath, classifiedName, relativePath);
        const providersRecorder = host.beginUpdate(modulePath);
        for (const change of providersChanges) {
            if (change instanceof change_1.InsertChange) {
                providersRecorder.insertLeft(change.pos, change.toAdd);
            }
        }
        host.commitUpdate(providersRecorder);
        return host;
    };
}
github intershop / intershop-pwa / schematics / src / utils / registration.js View on Github external
return host => {
        const relativePath = find_module_1.buildRelativePath(options.module, options.moduleImportPath);
        const source = filesystem_1.readIntoSourceFile(host, options.module);
        const exportRecorder = host.beginUpdate(options.module);
        const exportChanges = ast_utils_1.addExportToModule(source, options.module, core_1.strings.classify(options.artifactName), relativePath);
        for (const change of exportChanges) {
            if (change instanceof change_1.InsertChange) {
                exportRecorder.insertLeft(change.pos, change.toAdd);
            }
        }
        host.commitUpdate(exportRecorder);
    };
}
github nitayneeman / schematics-utilities / src / angular / find-module.ts View on Github external
export function buildRelativePath(from: string, to: string): string {
  return originalBuildRelativePath(from, to);
}
github ng-matero / ng-matero / schematics / utils / build-component.ts View on Github external
function buildRelativeComponentPath(options: ComponentOptions, modulePath: string): string {
  const componentPath =
    `/${options.path}/` +
    (options.flat ? '' : strings.dasherize(options.name) + '/') +
    strings.dasherize(options.name) +
    '.component';

  return buildRelativePath(modulePath, componentPath);
}
github mselerin / yang-schematics / src / directive / index.ts View on Github external
return (host: Tree) => {
    if (options.skipImport || !options.module)
      return host;

    const file = options.module;
    const sourceFile = CodeUtils.readSourceFile(host, file);

    const directivePath = `/${options.path}/`
      + (options.flat ? '' : strings.dasherize(options.name) + '/')
      + strings.dasherize(options.name)
      + '.directive';

    const relativePath = buildRelativePath(options.module, directivePath);

    CodeUtils.addImport(sourceFile, `${strings.classify(options.name)}Directive`, relativePath);
    CodeUtils.insertInVariableArray(sourceFile, "DECLARATIONS", `${strings.classify(options.name)}Directive`);

    CodeUtils.writeSourceFile(host, file, sourceFile);
    return host;
  };
}
github mselerin / yang-schematics / src / module / index.ts View on Github external
return (host: Tree) => {
    if (!options.module)
      return host;

    const file = options.module;
    const sourceFile = CodeUtils.readSourceFile(host, file);

    const modulePath = `/${options.path}/`
      + (options.flat ? '' : strings.dasherize(options.name) + '/')
      + strings.dasherize(options.name)
      + '.module';

    const relativePath = buildRelativePath(options.module, modulePath);

    CodeUtils.addImport(sourceFile, `${strings.classify(options.name)}Module`, relativePath);
    CodeUtils.insertInVariableArray(sourceFile, "MODULES", `${strings.classify(options.name)}Module`);

    CodeUtils.writeSourceFile(host, file, sourceFile);
    return host;
  };
}
github ng-matero / ng-matero / schematics / ng-generate / module / index.ts View on Github external
function buildRelativeModulePath(options: ModuleOptions, modulePath: string): string {
  const importModulePath = normalize(
    `/${options.path}/` +
      (options.flat ? '' : strings.dasherize(options.name) + '/') +
      strings.dasherize(options.name) +
      '.module'
  );
  return buildRelativePath(modulePath, importModulePath);
}