@nrwl/workspace

  • Version 15.2.4
  • Published
  • 605 kB
  • 25 dependencies
  • MIT license

Install

npm i @nrwl/workspace
yarn add @nrwl/workspace
pnpm add @nrwl/workspace

Overview

The Workspace plugin contains executors and generators that are useful for any Nx workspace. It should be present in every Nx workspace and other plugins build on it.

Index

Variables

variable stringUtils

const stringUtils: typeof strings;

    Functions

    function addDepsToPackageJson

    addDepsToPackageJson: (deps: any, devDeps: any, addInstall?: boolean) => Rule;
    • Updates the package.json given the passed deps and/or devDeps. Only updates if the packages are not yet present

      Parameter deps

      the package.json dependencies to add

      Parameter devDeps

      the package.json devDependencies to add

      Parameter addInstall

      default true; set to false to avoid installs

    function addGlobal

    addGlobal: (
    source: ts.SourceFile,
    modulePath: string,
    statement: string
    ) => Change[];

      function addIncludeToTsConfig

      addIncludeToTsConfig: (
      tsConfigPath: string,
      source: ts.SourceFile,
      include: string
      ) => Change[];

        function addInstallTask

        addInstallTask: (options?: { skipInstall: boolean }) => Rule;

          function addLintFiles

          addLintFiles: (
          projectRoot: string,
          linter: Linter,
          options?: AddLintFileOptions
          ) => Rule;

            function addMethod

            addMethod: (
            source: ts.SourceFile,
            modulePath: string,
            opts: { className: string; methodHeader: string; body: string }
            ) => Change[];

              function addPackageWithInit

              addPackageWithInit: (
              packageName: string,
              testRunners?: {
              unitTestRunner: 'jest' | 'none';
              e2eTestRunner?: 'cypress' | 'none';
              }
              ) => Rule;
              • Calls init _if_ the package does not already exist

              function addParameterToConstructor

              addParameterToConstructor: (
              source: ts.SourceFile,
              modulePath: string,
              opts: { className: string; param: string }
              ) => Change[];

                function addUpdateTask

                addUpdateTask: (pkg: string, to: string, dependencies?: TaskId[]) => Rule;

                  function checkAndCleanWithSemver

                  checkAndCleanWithSemver: (pkgName: string, version: string) => string;

                    function convertToNxProjectGenerator

                    convertToNxProjectGenerator: (host: Tree, schema: Schema) => Promise<void>;

                      function convertToNxProjectSchematic

                      convertToNxProjectSchematic: (
                      generatorOptions: Schema
                      ) => (tree: any, context: any) => Promise<any>;

                        function copyFile

                        copyFile: (file: string, target: string) => void;

                          function createOrUpdate

                          createOrUpdate: (host: Tree, path: string, content: string) => void;

                            function deleteFile

                            deleteFile: (from: string) => Rule;
                            • Remove a file from the Virtual Schematic Tree

                            function editTarget

                            editTarget: (targetString: string, callback: any) => string;

                              function findNodes

                              findNodes: (
                              node: ts.Node,
                              kind: ts.SyntaxKind | ts.SyntaxKind[],
                              max?: number
                              ) => ts.Node[];

                                function formatFiles

                                formatFiles: (options?: { skipFormat: boolean }, directory?: string) => Rule;

                                  function generateProjectLint

                                  generateProjectLint: (
                                  projectRoot: string,
                                  tsConfigPath: string,
                                  linter: Linter,
                                  eslintFilePatterns: string[]
                                  ) => { builder: string; options: { lintFilePatterns: string[] } };

                                    function getNpmScope

                                    getNpmScope: (host: Tree) => string;

                                      function getProjectConfig

                                      getProjectConfig: (host: Tree, name: string) => any;

                                        function getWorkspace

                                        getWorkspace: (
                                        tree: Tree,
                                        path?: string
                                        ) => Promise<workspaces.WorkspaceDefinition>;

                                          function getWorkspacePath

                                          getWorkspacePath: (host: Tree) => string;

                                            function insert

                                            insert: (host: Tree, modulePath: string, changes: Change[]) => void;

                                              function libraryGenerator

                                              libraryGenerator: (tree: Tree, schema: Schema) => Promise<GeneratorCallback>;

                                                function moveGenerator

                                                moveGenerator: (tree: Tree, rawSchema: Schema) => Promise<void>;

                                                  function parseTarget

                                                  parseTarget: (targetString: string) => {
                                                  project: string;
                                                  target: string;
                                                  config: string;
                                                  };

                                                    function projectRootDir

                                                    projectRootDir: (projectType: ProjectType) => 'libs' | 'apps';

                                                      function readJsonInTree

                                                      readJsonInTree: <T extends object = any>(host: Tree, path: string) => T;
                                                      • This method is specifically for reading JSON files in a Tree

                                                        Parameter host

                                                        The host tree

                                                        Parameter path

                                                        The path to the JSON file

                                                        Returns

                                                        The JSON data in the file.

                                                      function readNxJsonInTree

                                                      readNxJsonInTree: (host: Tree) => NxJsonConfiguration<string[] | '*'>;

                                                        function readTsConfig

                                                        readTsConfig: (tsConfigPath: string) => ts.ParsedCommandLine;

                                                          function readWorkspace

                                                          readWorkspace: (host: Tree) => any;

                                                            function removeGenerator

                                                            removeGenerator: (tree: Tree, schema: Schema) => Promise<void>;

                                                              function renameDirSyncInTree

                                                              renameDirSyncInTree: (
                                                              tree: Tree,
                                                              from: string,
                                                              to: string,
                                                              cb: (err: string) => void
                                                              ) => void;

                                                                function renameNpmPackages

                                                                renameNpmPackages: (
                                                                packageRenameMapping: PackageRenameMapping
                                                                ) => (tree: Tree, context: SchematicContext) => Rule;
                                                                • Updates all the imports in the workspace, and adjust the package.json appropriately.

                                                                  Parameter packageNameMapping

                                                                  The packageNameMapping provided to the schematic

                                                                function renamePackageImports

                                                                renamePackageImports: (packageNameMapping: PackageNameMapping) => Rule;
                                                                • Updates all the imports found in the workspace

                                                                  Parameter packageNameMapping

                                                                  The packageNameMapping provided to the schematic

                                                                function renameSync

                                                                renameSync: (from: string, to: string, cb: (err: Error | null) => void) => void;

                                                                  function renameSyncInTree

                                                                  renameSyncInTree: (
                                                                  tree: Tree,
                                                                  from: string,
                                                                  to: string,
                                                                  cb: (err: string) => void
                                                                  ) => void;

                                                                    function replaceAppNameWithPath

                                                                    replaceAppNameWithPath: (node: any, appName: string, root: string) => any;

                                                                      function replaceNodeValue

                                                                      replaceNodeValue: (
                                                                      host: Tree,
                                                                      modulePath: string,
                                                                      node: ts.Node,
                                                                      content: string
                                                                      ) => void;

                                                                        function resolveUserExistingPrettierConfig

                                                                        resolveUserExistingPrettierConfig: () => Promise<ExistingPrettierConfig | null>;

                                                                          function runCommandsGenerator

                                                                          runCommandsGenerator: (host: Tree, schema: Schema) => Promise<void>;

                                                                            function serializeTarget

                                                                            serializeTarget: ({
                                                                            project,
                                                                            target,
                                                                            config,
                                                                            }: {
                                                                            project: any;
                                                                            target: any;
                                                                            config: any;
                                                                            }) => string;

                                                                              function updateBuilderConfig

                                                                              updateBuilderConfig: (
                                                                              updater: (
                                                                              currentValue: Record<
                                                                              string,
                                                                              string | number | boolean | JsonArray | JsonObject
                                                                              >,
                                                                              target?: TargetDefinition,
                                                                              project?: ProjectDefinition
                                                                              ) => Record<string, string | number | boolean | JsonArray | JsonObject>,
                                                                              ...builderNames: string[]
                                                                              ) => Rule;
                                                                              • Updates builder options for options and configurations for given builder names

                                                                              function updateJsonFile

                                                                              updateJsonFile: (path: string, callback: (a: any) => any) => void;
                                                                              • This method is specifically for updating a JSON file using the filesystem

                                                                                Parameter path

                                                                                Path of the JSON file on the filesystem

                                                                                Parameter callback

                                                                                Manipulation of the JSON data

                                                                                Remarks

                                                                                If you are looking to update a JSON file in a tree, look for ./ast-utils#updateJsonInTree

                                                                              function updateJsonInTree

                                                                              updateJsonInTree: <T extends object = any, O extends object = T>(
                                                                              path: string,
                                                                              callback: (json: T, context: SchematicContext) => O
                                                                              ) => Rule;
                                                                              • This method is specifically for updating JSON in a Tree

                                                                                Parameter path

                                                                                Path of JSON file in the Tree

                                                                                Parameter callback

                                                                                Manipulation of the JSON data

                                                                                Returns

                                                                                A rule which updates a JSON file file in a Tree

                                                                              function updateKarmaConf

                                                                              updateKarmaConf: (options: { projectName: string }) => Rule;
                                                                              • This returns a Rule which changes the default Angular CLI Generated karma.conf.js

                                                                                Parameter options

                                                                                Object containing projectROot

                                                                              function updateNxJsonInTree

                                                                              updateNxJsonInTree: (
                                                                              callback: (
                                                                              json: NxJsonConfiguration,
                                                                              context: SchematicContext
                                                                              ) => NxJsonConfiguration
                                                                              ) => Rule;

                                                                                function updatePackageJsonDependencies

                                                                                updatePackageJsonDependencies: (
                                                                                deps: any,
                                                                                devDeps: any,
                                                                                addInstall?: boolean
                                                                                ) => Rule;

                                                                                  function updatePackagesInPackageJson

                                                                                  updatePackagesInPackageJson: (
                                                                                  migrationFilePath: string,
                                                                                  versionName: string,
                                                                                  options?: { skipInstall: boolean }
                                                                                  ) => any;

                                                                                    function updateWorkspace

                                                                                    updateWorkspace: {
                                                                                    (
                                                                                    updater: (
                                                                                    workspace: workspaces.WorkspaceDefinition
                                                                                    ) => void | PromiseLike<void>
                                                                                    ): Rule;
                                                                                    (workspace: workspaces.WorkspaceDefinition): Rule;
                                                                                    };

                                                                                      function updateWorkspaceInTree

                                                                                      updateWorkspaceInTree: <T extends object = any, O extends object = T>(
                                                                                      callback: (json: T, context: SchematicContext, host: Tree) => O
                                                                                      ) => Rule;

                                                                                        function visitNotIgnoredFiles

                                                                                        visitNotIgnoredFiles: (
                                                                                        visitor: (file: Path, host: Tree, context: SchematicContext) => void | Rule,
                                                                                        dir?: Path
                                                                                        ) => Rule;

                                                                                          Classes

                                                                                          class InsertChange

                                                                                          class InsertChange implements Change {}

                                                                                            constructor

                                                                                            constructor(path: string, pos: number, toAdd: string);

                                                                                              property description

                                                                                              description: string;

                                                                                                property order

                                                                                                order: number;

                                                                                                  property path

                                                                                                  path: string;

                                                                                                    property pos

                                                                                                    pos: number;

                                                                                                      property toAdd

                                                                                                      toAdd: string;

                                                                                                        property type

                                                                                                        type: string;

                                                                                                          method apply

                                                                                                          apply: (host: any) => any;

                                                                                                            class RemoveChange

                                                                                                            class RemoveChange implements Change {}

                                                                                                              constructor

                                                                                                              constructor(path: string, pos: number, toRemove: string);

                                                                                                                property description

                                                                                                                description: string;

                                                                                                                  property order

                                                                                                                  order: number;

                                                                                                                    property path

                                                                                                                    path: string;

                                                                                                                      property pos

                                                                                                                      pos: number;

                                                                                                                        property toRemove

                                                                                                                        toRemove: string;

                                                                                                                          property type

                                                                                                                          type: string;

                                                                                                                            method apply

                                                                                                                            apply: (host: any) => Promise<void>;

                                                                                                                              class ReplaceChange

                                                                                                                              class ReplaceChange implements Change {}

                                                                                                                                constructor

                                                                                                                                constructor(path: string, pos: number, oldText: string, newText: string);

                                                                                                                                  property description

                                                                                                                                  description: string;

                                                                                                                                    property newText

                                                                                                                                    newText: string;

                                                                                                                                      property oldText

                                                                                                                                      oldText: string;

                                                                                                                                        property order

                                                                                                                                        order: number;

                                                                                                                                          property path

                                                                                                                                          path: string;

                                                                                                                                            property pos

                                                                                                                                            pos: number;

                                                                                                                                              property type

                                                                                                                                              type: string;

                                                                                                                                                method apply

                                                                                                                                                apply: (host: any) => Promise<void>;

                                                                                                                                                  Interfaces

                                                                                                                                                  interface ExistingPrettierConfig

                                                                                                                                                  interface ExistingPrettierConfig {}

                                                                                                                                                    property config

                                                                                                                                                    config: Options;

                                                                                                                                                      property sourceFilepath

                                                                                                                                                      sourceFilepath: string;

                                                                                                                                                        Enums

                                                                                                                                                        enum Linter

                                                                                                                                                        const enum Linter {
                                                                                                                                                        EsLint = 'eslint',
                                                                                                                                                        None = 'none',
                                                                                                                                                        }

                                                                                                                                                          member EsLint

                                                                                                                                                          EsLint = 'eslint'

                                                                                                                                                            member None

                                                                                                                                                            None = 'none'

                                                                                                                                                              enum ProjectType

                                                                                                                                                              enum ProjectType {
                                                                                                                                                              Application = 'application',
                                                                                                                                                              Library = 'library',
                                                                                                                                                              }

                                                                                                                                                                member Application

                                                                                                                                                                Application = 'application'

                                                                                                                                                                  member Library

                                                                                                                                                                  Library = 'library'

                                                                                                                                                                    Package Files (26)

                                                                                                                                                                    Dependencies (25)

                                                                                                                                                                    Dev Dependencies (0)

                                                                                                                                                                    No dev dependencies.

                                                                                                                                                                    Peer Dependencies (1)

                                                                                                                                                                    Badge

                                                                                                                                                                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@nrwl/workspace.

                                                                                                                                                                    • Markdown
                                                                                                                                                                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@nrwl/workspace)
                                                                                                                                                                    • HTML
                                                                                                                                                                      <a href="https://www.jsdocs.io/package/@nrwl/workspace"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>