How to use the @nrwl/workspace.offsetFromRoot function in @nrwl/workspace

To help you get started, we’ve selected a few @nrwl/workspace 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 nrwl / nx / packages / cypress / src / schematics / cypress-project / cypress-project.ts View on Github external
return (): Rule => {
    // host.delete(`${options.projectRoot}/tsconfig.e2e.json`);
    return mergeWith(
      apply(url('./files'), [
        template({
          tmpl: '',
          ...options,
          offsetFromRoot: offsetFromRoot(options.projectRoot)
        }),
        move(options.projectRoot)
      ])
    );
  };
}
github nrwl / nx / packages / angular / src / schematics / library / library.ts View on Github external
options.projectDirectory
        }').then(module => module.${options.moduleName})}`
      )
    ]);

    const tsConfig = findClosestTsConfigApp(host, options.parentModule);
    if (tsConfig) {
      const tsConfigAppSource = host.read(tsConfig)!.toString('utf-8');
      const tsConfigAppFile = ts.createSourceFile(
        tsConfig,
        tsConfigAppSource,
        ts.ScriptTarget.Latest,
        true
      );

      const offset = offsetFromRoot(path.dirname(tsConfig));
      insert(host, tsConfig, [
        ...addIncludeToTsConfig(
          tsConfig,
          tsConfigAppFile,
          `\n    , "${offset}${options.projectRoot}/src/index.ts"\n`
        )
      ]);
    } else {
      // we should warn the user about not finding the config
    }

    return host;
  };
}
github nrwl / nx / packages / next / src / schematics / application / application.ts View on Github external
function createApplicationFiles(options: NormalizedSchema): Rule {
  return mergeWith(
    apply(url(`./files`), [
      template({
        ...names(options.name),
        ...options,
        tmpl: '',
        offsetFromRoot: offsetFromRoot(options.appProjectRoot)
      }),
      options.styledModule
        ? filter(file => !file.endsWith(`.${options.style}`))
        : noop(),
      options.unitTestRunner === 'none'
        ? filter(file => file !== `/specs/index.spec.tsx`)
        : noop(),
      move(options.appProjectRoot)
    ])
  );
}
github nrwl / nx / packages / web / src / schematics / application / application.ts View on Github external
function createApplicationFiles(options: NormalizedSchema): Rule {
  return mergeWith(
    apply(url(`./files/app`), [
      template({
        ...options,
        ...names(options.name),
        tmpl: '',
        offsetFromRoot: offsetFromRoot(options.appProjectRoot)
      }),
      options.unitTestRunner === 'none'
        ? filter(file => file !== '/src/app/app.spec.ts')
        : noop(),
      move(options.appProjectRoot)
    ])
  );
}
github nrwl / nx / packages / schematics / migrations / update-6-0-0 / update-6-0-0.ts View on Github external
function createTsconfigSpecJson(host: Tree, project: any) {
  const files = ['src/test.ts'];

  const offset = offsetFromRoot(project.root);

  const compilerOptions = {
    outDir: `${offset}dist/out-tsc/${project.root}`,
    types: ['jasmine', 'node']
  };

  if (project.projectType === 'application') {
    files.push('src/polyfills.ts');
    compilerOptions['module'] = 'commonjs';
  }

  createOrUpdate(
    host,
    `${project.root}/tsconfig.spec.json`,
    serializeJson({
      extends: `${offset}tsconfig.json`,
github nrwl / nx / packages / react / src / schematics / library / library.ts View on Github external
function createFiles(options: NormalizedSchema): Rule {
  return mergeWith(
    apply(url(`./files/lib`), [
      template({
        ...options,
        ...names(options.name),
        tmpl: '',
        offsetFromRoot: offsetFromRoot(options.projectRoot)
      }),
      move(options.projectRoot),
      options.publishable
        ? noop()
        : filter(file => !file.endsWith('package.json'))
    ])
  );
}
github nrwl / nx / packages / angular / src / schematics / application / application.ts View on Github external
updateJsonInTree(`${options.e2eProjectRoot}/tsconfig.e2e.json`, json => {
        return {
          ...json,
          extends: `./tsconfig.json`,
          compilerOptions: {
            ...json.compilerOptions,
            outDir: `${offsetFromRoot(options.e2eProjectRoot)}dist/out-tsc`
          }
        };
      })
    ]);
github nrwl / nx / packages / workspace / src / schematics / library / library.ts View on Github external
function createFiles(options: NormalizedSchema): Rule {
  return mergeWith(
    apply(url(`./files/lib`), [
      template({
        ...options,
        ...names(options.name),
        tmpl: '',
        offsetFromRoot: offsetFromRoot(options.projectRoot)
      }),
      move(options.projectRoot)
    ])
  );
}
github nrwl / nx / packages / angular / src / schematics / karma-project / karma-project.ts View on Github external
return (host, context) => {
    const projectConfig = getProjectConfig(host, options.project);
    return mergeWith(
      apply(url('./files'), [
        template({
          tmpl: '',
          ...options,
          projectRoot: projectConfig.root,
          isLibrary: projectConfig.projectType === 'library',
          offsetFromRoot: offsetFromRoot(projectConfig.root)
        }),
        move(projectConfig.root)
      ])
    )(host, context);
  };
}
github nrwl / nx / packages / angular / src / schematics / application / application.ts View on Github external
function addSchematicFiles(
  appProjectRoot: string,
  options: NormalizedSchema
): Rule {
  return chain([
    host => host.delete(`${appProjectRoot}/src/favicon.ico`),
    mergeWith(
      apply(url('./files'), [
        template({
          ...options,
          offsetFromRoot: offsetFromRoot(options.appProjectRoot)
        }),
        move(options.appProjectRoot)
      ])
    )
  ]);
}