From c39135e0d2873dfcb21bf8742120ae6516ea2959 Mon Sep 17 00:00:00 2001 From: Isaac Mann Date: Fri, 11 Jun 2021 11:34:55 -0400 Subject: [PATCH] docs(core): autogenerate nx devkit api (#5827) Co-authored-by: Isaac Mann --- docs/angular/api-nx-devkit/index.md | 1331 +++++++++++++++++ docs/angular/api-nx-devkit/ngcli_adapter.md | 98 ++ docs/map.json | 54 + docs/node/api-nx-devkit/index.md | 1331 +++++++++++++++++ docs/node/api-nx-devkit/ngcli_adapter.md | 98 ++ docs/react/api-nx-devkit/index.md | 1331 +++++++++++++++++ docs/react/api-nx-devkit/ngcli_adapter.md | 98 ++ jest.config.js | 1 + .../src/lib/menu.utils.ts | 1 + nx.json | 3 + package.json | 2 + scripts/documentation/documentation.ts | 13 +- tsconfig.base.json | 3 +- typedoc-theme/.babelrc | 3 + typedoc-theme/.eslintrc.json | 21 + typedoc-theme/README.md | 7 + typedoc-theme/jest.config.js | 15 + typedoc-theme/package.json | 4 + typedoc-theme/src/index.ts | 4 + typedoc-theme/src/lib/theme.ts | 43 + typedoc-theme/tsconfig.json | 13 + typedoc-theme/tsconfig.lib.json | 13 + typedoc-theme/tsconfig.spec.json | 15 + workspace.json | 41 + yarn.lock | 73 +- 25 files changed, 4602 insertions(+), 14 deletions(-) create mode 100644 docs/angular/api-nx-devkit/index.md create mode 100644 docs/angular/api-nx-devkit/ngcli_adapter.md create mode 100644 docs/node/api-nx-devkit/index.md create mode 100644 docs/node/api-nx-devkit/ngcli_adapter.md create mode 100644 docs/react/api-nx-devkit/index.md create mode 100644 docs/react/api-nx-devkit/ngcli_adapter.md create mode 100644 typedoc-theme/.babelrc create mode 100644 typedoc-theme/.eslintrc.json create mode 100644 typedoc-theme/README.md create mode 100644 typedoc-theme/jest.config.js create mode 100644 typedoc-theme/package.json create mode 100644 typedoc-theme/src/index.ts create mode 100644 typedoc-theme/src/lib/theme.ts create mode 100644 typedoc-theme/tsconfig.json create mode 100644 typedoc-theme/tsconfig.lib.json create mode 100644 typedoc-theme/tsconfig.spec.json diff --git a/docs/angular/api-nx-devkit/index.md b/docs/angular/api-nx-devkit/index.md new file mode 100644 index 0000000000..ed769bc664 --- /dev/null +++ b/docs/angular/api-nx-devkit/index.md @@ -0,0 +1,1331 @@ +# Module: index + +## Table of contents + +### Enumerations + +- [ChangeType](../../angular/nx-devkit/index#changetype) +- [DependencyType](../../angular/nx-devkit/index#dependencytype) + +### Classes + +- [ProjectGraphBuilder](../../angular/nx-devkit/index#projectgraphbuilder) + +### Interfaces + +- [ExecutorContext](../../angular/nx-devkit/index#executorcontext) +- [FileChange](../../angular/nx-devkit/index#filechange) +- [FileData](../../angular/nx-devkit/index#filedata) +- [ImplicitJsonSubsetDependency](../../angular/nx-devkit/index#implicitjsonsubsetdependency) +- [JsonParseOptions](../../angular/nx-devkit/index#jsonparseoptions) +- [JsonSerializeOptions](../../angular/nx-devkit/index#jsonserializeoptions) +- [NxAffectedConfig](../../angular/nx-devkit/index#nxaffectedconfig) +- [NxJsonConfiguration](../../angular/nx-devkit/index#nxjsonconfiguration) +- [NxJsonProjectConfiguration](../../angular/nx-devkit/index#nxjsonprojectconfiguration) +- [NxPlugin](../../angular/nx-devkit/index#nxplugin) +- [ProjectConfiguration](../../angular/nx-devkit/index#projectconfiguration) +- [ProjectFileMap](../../angular/nx-devkit/index#projectfilemap) +- [ProjectGraph](../../angular/nx-devkit/index#projectgraph) +- [ProjectGraphDependency](../../angular/nx-devkit/index#projectgraphdependency) +- [ProjectGraphNode](../../angular/nx-devkit/index#projectgraphnode) +- [ProjectGraphProcessorContext](../../angular/nx-devkit/index#projectgraphprocessorcontext) +- [StringDeletion](../../angular/nx-devkit/index#stringdeletion) +- [StringInsertion](../../angular/nx-devkit/index#stringinsertion) +- [Target](../../angular/nx-devkit/index#target) +- [TargetConfiguration](../../angular/nx-devkit/index#targetconfiguration) +- [TargetDependencyConfig](../../angular/nx-devkit/index#targetdependencyconfig) +- [Tree](../../angular/nx-devkit/index#tree) +- [Workspace](../../angular/nx-devkit/index#workspace) +- [WorkspaceJsonConfiguration](../../angular/nx-devkit/index#workspacejsonconfiguration) + +### Type aliases + +- [Executor](../../angular/nx-devkit/index#executor) +- [Generator](../../angular/nx-devkit/index#generator) +- [GeneratorCallback](../../angular/nx-devkit/index#generatorcallback) +- [ImplicitDependencyEntry](../../angular/nx-devkit/index#implicitdependencyentry) +- [PackageManager](../../angular/nx-devkit/index#packagemanager) +- [ProjectType](../../angular/nx-devkit/index#projecttype) +- [StringChange](../../angular/nx-devkit/index#stringchange) +- [WorkspaceConfiguration](../../angular/nx-devkit/index#workspaceconfiguration) + +### Variables + +- [logger](../../angular/nx-devkit/index#logger) + +### Functions + +- [addDependenciesToPackageJson](../../angular/nx-devkit/index#adddependenciestopackagejson) +- [addProjectConfiguration](../../angular/nx-devkit/index#addprojectconfiguration) +- [applyChangesToString](../../angular/nx-devkit/index#applychangestostring) +- [convertNxExecutor](../../angular/nx-devkit/index#convertnxexecutor) +- [convertNxGenerator](../../angular/nx-devkit/index#convertnxgenerator) +- [formatFiles](../../angular/nx-devkit/index#formatfiles) +- [generateFiles](../../angular/nx-devkit/index#generatefiles) +- [getPackageManagerCommand](../../angular/nx-devkit/index#getpackagemanagercommand) +- [getProjects](../../angular/nx-devkit/index#getprojects) +- [getWorkspaceLayout](../../angular/nx-devkit/index#getworkspacelayout) +- [getWorkspacePath](../../angular/nx-devkit/index#getworkspacepath) +- [installPackagesTask](../../angular/nx-devkit/index#installpackagestask) +- [joinPathFragments](../../angular/nx-devkit/index#joinpathfragments) +- [moveFilesToNewDirectory](../../angular/nx-devkit/index#movefilestonewdirectory) +- [names](../../angular/nx-devkit/index#names) +- [normalizePath](../../angular/nx-devkit/index#normalizepath) +- [offsetFromRoot](../../angular/nx-devkit/index#offsetfromroot) +- [parseJson](../../angular/nx-devkit/index#parsejson) +- [parseTargetString](../../angular/nx-devkit/index#parsetargetstring) +- [readJson](../../angular/nx-devkit/index#readjson) +- [readJsonFile](../../angular/nx-devkit/index#readjsonfile) +- [readProjectConfiguration](../../angular/nx-devkit/index#readprojectconfiguration) +- [readTargetOptions](../../angular/nx-devkit/index#readtargetoptions) +- [readWorkspaceConfiguration](../../angular/nx-devkit/index#readworkspaceconfiguration) +- [removeDependenciesFromPackageJson](../../angular/nx-devkit/index#removedependenciesfrompackagejson) +- [removeProjectConfiguration](../../angular/nx-devkit/index#removeprojectconfiguration) +- [runExecutor](../../angular/nx-devkit/index#runexecutor) +- [serializeJson](../../angular/nx-devkit/index#serializejson) +- [stripIndents](../../angular/nx-devkit/index#stripindents) +- [stripJsonComments](../../angular/nx-devkit/index#stripjsoncomments) +- [targetToTargetString](../../angular/nx-devkit/index#targettotargetstring) +- [toJS](../../angular/nx-devkit/index#tojs) +- [updateJson](../../angular/nx-devkit/index#updatejson) +- [updateProjectConfiguration](../../angular/nx-devkit/index#updateprojectconfiguration) +- [updateTsConfigsToJs](../../angular/nx-devkit/index#updatetsconfigstojs) +- [updateWorkspaceConfiguration](../../angular/nx-devkit/index#updateworkspaceconfiguration) +- [visitNotIgnoredFiles](../../angular/nx-devkit/index#visitnotignoredfiles) +- [writeJson](../../angular/nx-devkit/index#writejson) +- [writeJsonFile](../../angular/nx-devkit/index#writejsonfile) + +## Enumerations + +### ChangeType + +• **ChangeType**: _object_ + +--- + +### DependencyType + +• **DependencyType**: _object_ + +Type of dependency between projects + +## Classes + +### ProjectGraphBuilder + +• **ProjectGraphBuilder**: _object_ + +Builder for adding nodes and dependencies to a [ProjectGraph](../../angular/nx-devkit/index#projectgraph) + +## Interfaces + +### ExecutorContext + +• **ExecutorContext**: _object_ + +Context that is passed into an executor + +--- + +### FileChange + +• **FileChange**: _object_ + +Description of a file change in the Nx virtual file system/ + +--- + +### FileData + +• **FileData**: _object_ + +Some metadata about a file + +--- + +### ImplicitJsonSubsetDependency + +• **ImplicitJsonSubsetDependency**: _object_ + +#### Type parameters + +| Name | Default | +| :--- | :------------------ | +| `T` | `"*"` \| _string_[] | + +--- + +### JsonParseOptions + +• **JsonParseOptions**: _object_ + +--- + +### JsonSerializeOptions + +• **JsonSerializeOptions**: _object_ + +--- + +### NxAffectedConfig + +• **NxAffectedConfig**: _object_ + +--- + +### NxJsonConfiguration + +• **NxJsonConfiguration**: _object_ + +Nx.json configuration + +#### Type parameters + +| Name | Default | +| :--- | :------------------ | +| `T` | `"*"` \| _string_[] | + +--- + +### NxJsonProjectConfiguration + +• **NxJsonProjectConfiguration**: _object_ + +--- + +### NxPlugin + +• **NxPlugin**: _object_ + +A plugin for Nx + +--- + +### ProjectConfiguration + +• **ProjectConfiguration**: _object_ + +Project configuration + +--- + +### ProjectFileMap + +• **ProjectFileMap**: _object_ + +A list of files separated by the project they belong to + +--- + +### ProjectGraph + +• **ProjectGraph**: _object_ + +A Graph of projects in the workspace and dependencies between them + +#### Type parameters + +| Name | Default | +| :--- | :------ | +| `T` | _any_ | + +--- + +### ProjectGraphDependency + +• **ProjectGraphDependency**: _object_ + +A dependency between two projects + +--- + +### ProjectGraphNode + +• **ProjectGraphNode**: _object_ + +A node describing a project in a workspace + +#### Type parameters + +| Name | Default | +| :--- | :------ | +| `T` | _any_ | + +--- + +### ProjectGraphProcessorContext + +• **ProjectGraphProcessorContext**: _object_ + +Additional information to be used to process a project graph + +--- + +### StringDeletion + +• **StringDeletion**: _object_ + +--- + +### StringInsertion + +• **StringInsertion**: _object_ + +--- + +### Target + +• **Target**: _object_ + +--- + +### TargetConfiguration + +• **TargetConfiguration**: _object_ + +Target's configuration + +--- + +### TargetDependencyConfig + +• **TargetDependencyConfig**: _object_ + +--- + +### Tree + +• **Tree**: _object_ + +Virtual file system tree. + +--- + +### Workspace + +• **Workspace**: _object_ + +--- + +### WorkspaceJsonConfiguration + +• **WorkspaceJsonConfiguration**: _object_ + +Workspace configuration + +## Type aliases + +### Executor + +Ƭ **Executor**: (`options`: T, `context`: [_ExecutorContext_](../../angular/nx-devkit/index#executorcontext)) => _Promise_<{ `success`: _boolean_ }\> \| _AsyncIterableIterator_<{ `success`: _boolean_ }\> + +Implementation of a target of a project + +#### Type parameters + +| Name | Default | +| :--- | :------ | +| `T` | _any_ | + +#### Type declaration + +▸ (`options`: T, `context`: [_ExecutorContext_](../../angular/nx-devkit/index#executorcontext)): _Promise_<{ `success`: _boolean_ }\> \| _AsyncIterableIterator_<{ `success`: _boolean_ }\> + +#### Parameters + +| Name | Type | +| :-------- | :----------------------------------------------------------------- | +| `options` | T | +| `context` | [_ExecutorContext_](../../angular/nx-devkit/index#executorcontext) | + +**Returns:** _Promise_<{ `success`: _boolean_ }\> \| _AsyncIterableIterator_<{ `success`: _boolean_ }\> + +--- + +### Generator + +Ƭ **Generator**: (`tree`: _any_, `schema`: T) => _void_ \| [_GeneratorCallback_](../../angular/nx-devkit/index#generatorcallback) \| _Promise_ + +A function that schedules updates to the filesystem to be done atomically + +#### Type parameters + +| Name | Default | +| :--- | :-------- | +| `T` | _unknown_ | + +#### Type declaration + +▸ (`tree`: _any_, `schema`: T): _void_ \| [_GeneratorCallback_](../../angular/nx-devkit/index#generatorcallback) \| _Promise_ + +#### Parameters + +| Name | Type | +| :------- | :---- | +| `tree` | _any_ | +| `schema` | T | + +**Returns:** _void_ \| [_GeneratorCallback_](../../angular/nx-devkit/index#generatorcallback) \| _Promise_ + +--- + +### GeneratorCallback + +Ƭ **GeneratorCallback**: () => _void_ \| _Promise_ + +A callback function that is executed after changes are made to the file system + +#### Type declaration + +▸ (): _void_ \| _Promise_ + +**Returns:** _void_ \| _Promise_ + +--- + +### ImplicitDependencyEntry + +Ƭ **ImplicitDependencyEntry**: _object_ + +#### Type parameters + +| Name | Default | +| :--- | :------------------ | +| `T` | `"*"` \| _string_[] | + +#### Type declaration + +--- + +### PackageManager + +Ƭ **PackageManager**: `"yarn"` \| `"pnpm"` \| `"npm"` + +--- + +### ProjectType + +Ƭ **ProjectType**: `"library"` \| `"application"` + +Type of project supported + +--- + +### StringChange + +Ƭ **StringChange**: [_StringInsertion_](../../angular/nx-devkit/index#stringinsertion) \| [_StringDeletion_](../../angular/nx-devkit/index#stringdeletion) + +A change to be made to a string + +--- + +### WorkspaceConfiguration + +Ƭ **WorkspaceConfiguration**: _Omit_<[_WorkspaceJsonConfiguration_](../../angular/nx-devkit/index#workspacejsonconfiguration), `"projects"`\> & _Omit_<[_NxJsonConfiguration_](../../angular/nx-devkit/index#nxjsonconfiguration), `"projects"`\> + +## Variables + +### logger + +• `Const` **logger**: _object_ + +#### Type declaration + +| Name | Type | +| :------ | :-------------------------- | +| `debug` | (...`s`: _any_[]) => _void_ | +| `error` | (`s`: _any_) => _void_ | +| `fatal` | (...`s`: _any_[]) => _void_ | +| `info` | (`s`: _any_) => _void_ | +| `log` | (...`s`: _any_[]) => _void_ | +| `warn` | (`s`: _any_) => _void_ | + +## Functions + +### addDependenciesToPackageJson + +▸ **addDependenciesToPackageJson**(`host`: [_Tree_](../../angular/nx-devkit/index#tree), `dependencies`: _Record_, `devDependencies`: _Record_, `packageJsonPath?`: _string_): [_GeneratorCallback_](../../angular/nx-devkit/index#generatorcallback) + +Add Dependencies and Dev Dependencies to package.json + +For example, `addDependenciesToPackageJson(host, { react: 'latest' }, { jest: 'latest' })` +will add `react` and `jest` to the dependencies and devDependencies sections of package.json respectively + +#### Parameters + +| Name | Type | Default value | Description | +| :---------------- | :------------------------------------------- | :------------- | :---------------------------------------------------------------------- | +| `host` | [_Tree_](../../angular/nx-devkit/index#tree) | - | Tree representing file system to modify | +| `dependencies` | _Record_ | - | Dependencies to be added to the dependencies section of package.json | +| `devDependencies` | _Record_ | - | Dependencies to be added to the devDependencies section of package.json | +| `packageJsonPath` | _string_ | 'package.json' | Path to package.json | + +**Returns:** [_GeneratorCallback_](../../angular/nx-devkit/index#generatorcallback) + +Callback to install dependencies only if necessary. undefined is returned if changes are not necessary. + +--- + +### addProjectConfiguration + +▸ **addProjectConfiguration**(`host`: [_Tree_](../../angular/nx-devkit/index#tree), `projectName`: _string_, `projectConfiguration`: [_ProjectConfiguration_](../../angular/nx-devkit/index#projectconfiguration) & [_NxJsonProjectConfiguration_](../../angular/nx-devkit/index#nxjsonprojectconfiguration)): _void_ + +Adds project configuration to the Nx workspace. + +The project configuration is stored in workspace.json and nx.json. The utility will update +both files. + +#### Parameters + +| Name | Type | Description | +| :--------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------- | +| `host` | [_Tree_](../../angular/nx-devkit/index#tree) | the file system tree | +| `projectName` | _string_ | unique name. Often directories are part of the name (e.g., mydir-mylib) | +| `projectConfiguration` | [_ProjectConfiguration_](../../angular/nx-devkit/index#projectconfiguration) & [_NxJsonProjectConfiguration_](../../angular/nx-devkit/index#nxjsonprojectconfiguration) | project configuration | + +**Returns:** _void_ + +--- + +### applyChangesToString + +▸ **applyChangesToString**(`text`: _string_, `changes`: [_StringChange_](../../angular/nx-devkit/index#stringchange)[]): _string_ + +Applies a list of changes to a string's original value. + +This is useful when working with ASTs. + +For Example, to rename a property in a method's options: + +``` +const code = `bootstrap({ + target: document.querySelector('#app') +})`; + +const indexOfPropertyName = 13; // Usually determined by analyzing an AST. +const updatedCode = applyChangesToString(code, [ + { + type: ChangeType.Insert, + index: indexOfPropertyName, + text: 'element' + }, + { + type: ChangeType.Delete, + start: indexOfPropertyName, + length: 6 + }, +]); + +bootstrap({ + element: document.querySelector('#app') +}); +``` + +#### Parameters + +| Name | Type | +| :-------- | :------------------------------------------------------------- | +| `text` | _string_ | +| `changes` | [_StringChange_](../../angular/nx-devkit/index#stringchange)[] | + +**Returns:** _string_ + +--- + +### convertNxExecutor + +▸ **convertNxExecutor**(`executor`: [_Executor_](../../angular/nx-devkit/index#executor)): _any_ + +Convert an Nx Executor into an Angular Devkit Builder + +Use this to expose a compatible Angular Builder + +#### Parameters + +| Name | Type | +| :--------- | :--------------------------------------------------- | +| `executor` | [_Executor_](../../angular/nx-devkit/index#executor) | + +**Returns:** _any_ + +--- + +### convertNxGenerator + +▸ **convertNxGenerator**(`generator`: [_Generator_](../../angular/nx-devkit/index#generator)): _function_ + +Convert an Nx Generator into an Angular Devkit Schematic + +#### Type parameters + +| Name | Default | +| :--- | :------ | +| `T` | _any_ | + +#### Parameters + +| Name | Type | +| :---------- | :--------------------------------------------------------- | +| `generator` | [_Generator_](../../angular/nx-devkit/index#generator) | + +**Returns:** (`options`: T) => (`tree`: _any_, `context`: _any_) => _Promise_ + +--- + +### formatFiles + +▸ **formatFiles**(`host`: [_Tree_](../../angular/nx-devkit/index#tree)): _Promise_ + +Formats all the created or updated files using Prettier + +#### Parameters + +| Name | Type | Description | +| :----- | :------------------------------------------- | :------------------- | +| `host` | [_Tree_](../../angular/nx-devkit/index#tree) | the file system tree | + +**Returns:** _Promise_ + +--- + +### generateFiles + +▸ **generateFiles**(`host`: [_Tree_](../../angular/nx-devkit/index#tree), `srcFolder`: _string_, `target`: _string_, `substitutions`: { [k: string]: _any_; }): _void_ + +Generates a folder of files based on provided templates. + +While doing so it performs two substitutions: + +- Substitutes segments of file names surrounded by \_\_ +- Uses ejs to substitute values in templates + +#### Parameters + +| Name | Type | Description | +| :-------------- | :------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `host` | [_Tree_](../../angular/nx-devkit/index#tree) | the file system tree | +| `srcFolder` | _string_ | the source folder of files (absolute path) | +| `target` | _string_ | the target folder (relative to the host root) | +| `substitutions` | _object_ | an object of key-value pairs Examples: `typescript generateFiles(host, path.join(__dirname , 'files'), './tools/scripts', {tmpl: '', name: 'myscript'}) ` This command will take all the files from the `files` directory next to the place where the command is invoked from. It will replace all `__tmpl__` with '' and all `__name__` with 'myscript' in the file names, and will replace all `<%= name %>` with `myscript` in the files themselves. `tmpl: ''` is a common pattern. With it you can name files like this: `index.ts__tmpl__`, so your editor doesn't get confused about incorrect TypeScript files. | + +**Returns:** _void_ + +--- + +### getPackageManagerCommand + +▸ **getPackageManagerCommand**(`packageManager?`: [_PackageManager_](../../angular/nx-devkit/index#packagemanager)): _object_ + +Returns commands for the package manager used in the workspace. +By default, the package manager is derived based on the lock file, +but it can also be passed in explicitly. + +Example: + +```javascript +execSync(`${getPackageManagerCommand().addDev} my-dev-package`); +``` + +#### Parameters + +| Name | Type | +| :--------------- | :--------------------------------------------------------------- | +| `packageManager` | [_PackageManager_](../../angular/nx-devkit/index#packagemanager) | + +**Returns:** _object_ + +| Name | Type | +| :-------- | :------------------------------------------------- | +| `add` | _string_ | +| `addDev` | _string_ | +| `exec` | _string_ | +| `install` | _string_ | +| `list` | _string_ | +| `rm` | _string_ | +| `run` | (`script`: _string_, `args`: _string_) => _string_ | + +--- + +### getProjects + +▸ **getProjects**(`host`: [_Tree_](../../angular/nx-devkit/index#tree)): _Map_ + +Get a map of all projects in a workspace. + +Use [readProjectConfiguration](../../angular/nx-devkit/index#readprojectconfiguration) if only one project is needed. + +#### Parameters + +| Name | Type | +| :----- | :------------------------------------------- | +| `host` | [_Tree_](../../angular/nx-devkit/index#tree) | + +**Returns:** _Map_ + +--- + +### getWorkspaceLayout + +▸ **getWorkspaceLayout**(`host`: [_Tree_](../../angular/nx-devkit/index#tree)): _object_ + +Returns workspace defaults. It includes defaults folders for apps and libs, +and the default scope. + +Example: + +`{ appsDir: 'apps', libsDir: 'libs', npmScope: 'myorg' }` + +#### Parameters + +| Name | Type | Description | +| :----- | :------------------------------------------- | :--------------- | +| `host` | [_Tree_](../../angular/nx-devkit/index#tree) | file system tree | + +**Returns:** _object_ + +| Name | Type | +| :--------- | :------- | +| `appsDir` | _string_ | +| `libsDir` | _string_ | +| `npmScope` | _string_ | + +--- + +### getWorkspacePath + +▸ **getWorkspacePath**(`host`: [_Tree_](../../angular/nx-devkit/index#tree)): _string_ + +#### Parameters + +| Name | Type | +| :----- | :------------------------------------------- | +| `host` | [_Tree_](../../angular/nx-devkit/index#tree) | + +**Returns:** _string_ + +--- + +### installPackagesTask + +▸ **installPackagesTask**(`host`: [_Tree_](../../angular/nx-devkit/index#tree), `alwaysRun?`: _boolean_, `cwd?`: _string_, `packageManager?`: [_PackageManager_](../../angular/nx-devkit/index#packagemanager)): _void_ + +Runs `npm install` or `yarn install`. It will skip running the install if +`package.json` hasn't changed at all or it hasn't changed since the last invocation. + +#### Parameters + +| Name | Type | Default value | Description | +| :--------------- | :--------------------------------------------------------------- | :------------ | :------------------------------------------------------------ | +| `host` | [_Tree_](../../angular/nx-devkit/index#tree) | - | the file system tree | +| `alwaysRun` | _boolean_ | false | always run the command even if `package.json` hasn't changed. | +| `cwd` | _string_ | '' | - | +| `packageManager` | [_PackageManager_](../../angular/nx-devkit/index#packagemanager) | - | - | + +**Returns:** _void_ + +--- + +### joinPathFragments + +▸ **joinPathFragments**(...`fragments`: _string_[]): _string_ + +Normalized path fragments and joins them + +#### Parameters + +| Name | Type | +| :------------- | :--------- | +| `...fragments` | _string_[] | + +**Returns:** _string_ + +--- + +### moveFilesToNewDirectory + +▸ **moveFilesToNewDirectory**(`host`: [_Tree_](../../angular/nx-devkit/index#tree), `oldDir`: _string_, `newDir`: _string_): _void_ + +#### Parameters + +| Name | Type | +| :------- | :------------------------------------------- | +| `host` | [_Tree_](../../angular/nx-devkit/index#tree) | +| `oldDir` | _string_ | +| `newDir` | _string_ | + +**Returns:** _void_ + +--- + +### names + +▸ **names**(`name`: _string_): _object_ + +Util function to generate different strings based off the provided name. + +Examples: + +```typescript +names('my-name'); // {name: 'my-name', className: 'MyName', propertyName: 'myName', constantName: 'MY_NAME', fileName: 'my-name'} +names('myName'); // {name: 'my-name', className: 'MyName', propertyName: 'myName', constantName: 'MY_NAME', fileName: 'my-name'} +``` + +#### Parameters + +| Name | Type | +| :----- | :------- | +| `name` | _string_ | + +**Returns:** _object_ + +| Name | Type | +| :------------- | :------- | +| `className` | _string_ | +| `constantName` | _string_ | +| `fileName` | _string_ | +| `name` | _string_ | +| `propertyName` | _string_ | + +--- + +### normalizePath + +▸ **normalizePath**(`osSpecificPath`: _string_): _string_ + +Coverts an os specific path to a unix style path + +#### Parameters + +| Name | Type | +| :--------------- | :------- | +| `osSpecificPath` | _string_ | + +**Returns:** _string_ + +--- + +### offsetFromRoot + +▸ **offsetFromRoot**(`fullPathToDir`: _string_): _string_ + +Calculates an offset from the root of the workspace, which is useful for +constructing relative URLs. + +Examples: + +```typescript +offsetFromRoot('apps/mydir/myapp/'); // returns "../../../" +``` + +#### Parameters + +| Name | Type | Description | +| :-------------- | :------- | :------------- | +| `fullPathToDir` | _string_ | directory path | + +**Returns:** _string_ + +--- + +### parseJson + +▸ **parseJson**(`input`: _string_, `options?`: [_JsonParseOptions_](../../angular/nx-devkit/index#jsonparseoptions)): T + +Parses the given JSON string and returns the object the JSON content represents. +By default javascript-style comments are allowed. + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------ | +| `T` | _object_ | _any_ | + +#### Parameters + +| Name | Type | Description | +| :--------- | :------------------------------------------------------------------- | :--------------------- | +| `input` | _string_ | JSON content as string | +| `options?` | [_JsonParseOptions_](../../angular/nx-devkit/index#jsonparseoptions) | JSON parse options | + +**Returns:** T + +Object the JSON content represents + +--- + +### parseTargetString + +▸ **parseTargetString**(`targetString`: _string_): [_Target_](../../angular/nx-devkit/index#target) + +Parses a target string into {project, target, configuration} + +#### Parameters + +| Name | Type | Description | +| :------------- | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `targetString` | _string_ | target reference Examples: `typescript parseTargetString("proj:test") // returns { project: "proj", target: "test" } parseTargetString("proj:test:production") // returns { project: "proj", target: "test", configuration: "production" } ` | + +**Returns:** [_Target_](../../angular/nx-devkit/index#target) + +--- + +### readJson + +▸ **readJson**(`host`: [_Tree_](../../angular/nx-devkit/index#tree), `path`: _string_, `options?`: [_JsonParseOptions_](../../angular/nx-devkit/index#jsonparseoptions)): T + +Reads a document for host, removes all comments and parses JSON. + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------ | +| `T` | _object_ | _any_ | + +#### Parameters + +| Name | Type | Description | +| :--------- | :------------------------------------------------------------------- | :-------------------------- | +| `host` | [_Tree_](../../angular/nx-devkit/index#tree) | file system tree | +| `path` | _string_ | file path | +| `options?` | [_JsonParseOptions_](../../angular/nx-devkit/index#jsonparseoptions) | Optional JSON Parse Options | + +**Returns:** T + +--- + +### readJsonFile + +▸ **readJsonFile**(`path`: _string_, `options?`: JsonReadOptions): T + +Reads a JSON file and returns the object the JSON content represents. + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------ | +| `T` | _object_ | _any_ | + +#### Parameters + +| Name | Type | Description | +| :--------- | :-------------- | :----------------- | +| `path` | _string_ | A path to a file. | +| `options?` | JsonReadOptions | JSON parse options | + +**Returns:** T + +Object the JSON content of the file represents + +--- + +### readProjectConfiguration + +▸ **readProjectConfiguration**(`host`: [_Tree_](../../angular/nx-devkit/index#tree), `projectName`: _string_): [_ProjectConfiguration_](../../angular/nx-devkit/index#projectconfiguration) & [_NxJsonProjectConfiguration_](../../angular/nx-devkit/index#nxjsonprojectconfiguration) + +Reads a project configuration. + +The project configuration is stored in workspace.json and nx.json. The utility will read +both files. + +#### Parameters + +| Name | Type | Description | +| :------------ | :------------------------------------------- | :---------------------------------------------------------------------- | +| `host` | [_Tree_](../../angular/nx-devkit/index#tree) | the file system tree | +| `projectName` | _string_ | unique name. Often directories are part of the name (e.g., mydir-mylib) | + +**Returns:** [_ProjectConfiguration_](../../angular/nx-devkit/index#projectconfiguration) & [_NxJsonProjectConfiguration_](../../angular/nx-devkit/index#nxjsonprojectconfiguration) + +--- + +### readTargetOptions + +▸ **readTargetOptions**(`__namedParameters`: [_Target_](../../angular/nx-devkit/index#target), `context`: [_ExecutorContext_](../../angular/nx-devkit/index#executorcontext)): T + +Reads and combines options for a given target. + +Works as if you invoked the target yourself without passing any command lint overrides. + +#### Type parameters + +| Name | Default | +| :--- | :------ | +| `T` | _any_ | + +#### Parameters + +| Name | Type | +| :------------------ | :----------------------------------------------------------------- | +| `__namedParameters` | [_Target_](../../angular/nx-devkit/index#target) | +| `context` | [_ExecutorContext_](../../angular/nx-devkit/index#executorcontext) | + +**Returns:** T + +--- + +### readWorkspaceConfiguration + +▸ **readWorkspaceConfiguration**(`host`: [_Tree_](../../angular/nx-devkit/index#tree)): [_WorkspaceConfiguration_](../../angular/nx-devkit/index#workspaceconfiguration) + +Read general workspace configuration such as the default project or cli settings + +This does _not_ provide projects configuration, use [readProjectConfiguration](../../angular/nx-devkit/index#readprojectconfiguration) instead. + +#### Parameters + +| Name | Type | +| :----- | :------------------------------------------- | +| `host` | [_Tree_](../../angular/nx-devkit/index#tree) | + +**Returns:** [_WorkspaceConfiguration_](../../angular/nx-devkit/index#workspaceconfiguration) + +--- + +### removeDependenciesFromPackageJson + +▸ **removeDependenciesFromPackageJson**(`host`: [_Tree_](../../angular/nx-devkit/index#tree), `dependencies`: _string_[], `devDependencies`: _string_[], `packageJsonPath?`: _string_): [_GeneratorCallback_](../../angular/nx-devkit/index#generatorcallback) + +Remove Dependencies and Dev Dependencies from package.json + +For example, `removeDependenciesFromPackageJson(host, ['react'], ['jest'])` +will remove `react` and `jest` from the dependencies and devDependencies sections of package.json respectively + +#### Parameters + +| Name | Type | Default value | Description | +| :---------------- | :------------------------------------------- | :------------- | :-------------------------------------------------------------------------- | +| `host` | [_Tree_](../../angular/nx-devkit/index#tree) | - | - | +| `dependencies` | _string_[] | - | Dependencies to be removed from the dependencies section of package.json | +| `devDependencies` | _string_[] | - | Dependencies to be removed from the devDependencies section of package.json | +| `packageJsonPath` | _string_ | 'package.json' | - | + +**Returns:** [_GeneratorCallback_](../../angular/nx-devkit/index#generatorcallback) + +Callback to uninstall dependencies only if necessary. undefined is returned if changes are not necessary. + +--- + +### removeProjectConfiguration + +▸ **removeProjectConfiguration**(`host`: [_Tree_](../../angular/nx-devkit/index#tree), `projectName`: _string_): _void_ + +Removes the configuration of an existing project. + +The project configuration is stored in workspace.json and nx.json. +The utility will update both files. + +#### Parameters + +| Name | Type | +| :------------ | :------------------------------------------- | +| `host` | [_Tree_](../../angular/nx-devkit/index#tree) | +| `projectName` | _string_ | + +**Returns:** _void_ + +--- + +### runExecutor + +▸ **runExecutor**(`targetDescription`: { `configuration?`: _string_ ; `project`: _string_ ; `target`: _string_ }, `options`: { [k: string]: _any_; }, `context`: [_ExecutorContext_](../../angular/nx-devkit/index#executorcontext)): _Promise_\> + +Loads and invokes executor. + +This is analogous to invoking executor from the terminal, with the exception +that the params aren't parsed from the string, but instead provided parsed already. + +Apart from that, it works the same way: + +- it will load the workspace configuration +- it will resolve the target +- it will load the executor and the schema +- it will load the options for the appropriate configuration +- it will run the validations and will set the default +- and, of course, it will invoke the executor + +Example: + +```typescript +for await (const s of await runExecutor( + { project: 'myproj', target: 'serve' }, + { watch: true }, + context +)) { + // s.success +} +``` + +Note that the return value is a promise of an iterator, so you need to await before iterating over it. + +#### Type parameters + +| Name | Type | +| :---------- | :-------- | +| `T` | _object_ | +| `T.success` | _boolean_ | + +#### Parameters + +| Name | Type | +| :--------------------------------- | :----------------------------------------------------------------- | +| `targetDescription` | _object_ | +| `targetDescription.configuration?` | _string_ | +| `targetDescription.project` | _string_ | +| `targetDescription.target` | _string_ | +| `options` | _object_ | +| `context` | [_ExecutorContext_](../../angular/nx-devkit/index#executorcontext) | + +**Returns:** _Promise_\> + +--- + +### serializeJson + +▸ **serializeJson**(`input`: T, `options?`: [_JsonSerializeOptions_](../../angular/nx-devkit/index#jsonserializeoptions)): _string_ + +Serializes the given data to a JSON string. +By default the JSON string is formatted with a 2 space intendation to be easy readable. + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------- | +| `T` | _object_ | _object_ | + +#### Parameters + +| Name | Type | Description | +| :--------- | :--------------------------------------------------------------------------- | :---------------------------------------- | +| `input` | T | Object which should be serialized to JSON | +| `options?` | [_JsonSerializeOptions_](../../angular/nx-devkit/index#jsonserializeoptions) | JSON serialize options | + +**Returns:** _string_ + +the formatted JSON representation of the object + +--- + +### stripIndents + +▸ **stripIndents**(`strings`: TemplateStringsArray, ...`values`: _any_[]): _string_ + +Removes indents, which is useful for printing warning and messages. + +Example: + +```typescript +stripIndents` + Options: + - option1 + - option2 +`; +``` + +#### Parameters + +| Name | Type | +| :---------- | :------------------- | +| `strings` | TemplateStringsArray | +| `...values` | _any_[] | + +**Returns:** _string_ + +--- + +### stripJsonComments + +▸ `Const` **stripJsonComments**(`text`: _string_, `replaceCh?`: _string_): _string_ + +Takes JSON with JavaScript-style comments and remove +them. Optionally replaces every none-newline character +of comments with a replaceCharacter + +#### Parameters + +| Name | Type | +| :----------- | :------- | +| `text` | _string_ | +| `replaceCh?` | _string_ | + +**Returns:** _string_ + +--- + +### targetToTargetString + +▸ **targetToTargetString**(`__namedParameters`: [_Target_](../../angular/nx-devkit/index#target)): _string_ + +Returns a string in the format "project:target[:configuration]" for the target + +#### Parameters + +| Name | Type | +| :------------------ | :----------------------------------------------- | +| `__namedParameters` | [_Target_](../../angular/nx-devkit/index#target) | + +**Returns:** _string_ + +--- + +### toJS + +▸ **toJS**(`tree`: [_Tree_](../../angular/nx-devkit/index#tree)): _void_ + +Rename and transpile any new typescript files created to javascript files + +#### Parameters + +| Name | Type | +| :----- | :------------------------------------------- | +| `tree` | [_Tree_](../../angular/nx-devkit/index#tree) | + +**Returns:** _void_ + +--- + +### updateJson + +▸ **updateJson**(`host`: [_Tree_](../../angular/nx-devkit/index#tree), `path`: _string_, `updater`: (`value`: T) => U, `options?`: [_JsonParseOptions_](../../angular/nx-devkit/index#jsonparseoptions) & [_JsonSerializeOptions_](../../angular/nx-devkit/index#jsonserializeoptions)): _void_ + +Updates a JSON value to the file system tree + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------ | +| `T` | _object_ | _any_ | +| `U` | _object_ | T | + +#### Parameters + +| Name | Type | Description | +| :--------- | :-------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------- | +| `host` | [_Tree_](../../angular/nx-devkit/index#tree) | File system tree | +| `path` | _string_ | Path of JSON file in the Tree | +| `updater` | (`value`: T) => U | Function that maps the current value of a JSON document to a new value to be written to the document | +| `options?` | [_JsonParseOptions_](../../angular/nx-devkit/index#jsonparseoptions) & [_JsonSerializeOptions_](../../angular/nx-devkit/index#jsonserializeoptions) | Optional JSON Parse and Serialize Options | + +**Returns:** _void_ + +--- + +### updateProjectConfiguration + +▸ **updateProjectConfiguration**(`host`: [_Tree_](../../angular/nx-devkit/index#tree), `projectName`: _string_, `projectConfiguration`: [_ProjectConfiguration_](../../angular/nx-devkit/index#projectconfiguration) & [_NxJsonProjectConfiguration_](../../angular/nx-devkit/index#nxjsonprojectconfiguration)): _void_ + +Updates the configuration of an existing project. + +The project configuration is stored in workspace.json and nx.json. The utility will update +both files. + +#### Parameters + +| Name | Type | Description | +| :--------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------- | +| `host` | [_Tree_](../../angular/nx-devkit/index#tree) | the file system tree | +| `projectName` | _string_ | unique name. Often directories are part of the name (e.g., mydir-mylib) | +| `projectConfiguration` | [_ProjectConfiguration_](../../angular/nx-devkit/index#projectconfiguration) & [_NxJsonProjectConfiguration_](../../angular/nx-devkit/index#nxjsonprojectconfiguration) | project configuration | + +**Returns:** _void_ + +--- + +### updateTsConfigsToJs + +▸ **updateTsConfigsToJs**(`host`: [_Tree_](../../angular/nx-devkit/index#tree), `options`: { `projectRoot`: _string_ }): _void_ + +#### Parameters + +| Name | Type | +| :-------------------- | :------------------------------------------- | +| `host` | [_Tree_](../../angular/nx-devkit/index#tree) | +| `options` | _object_ | +| `options.projectRoot` | _string_ | + +**Returns:** _void_ + +--- + +### updateWorkspaceConfiguration + +▸ **updateWorkspaceConfiguration**(`host`: [_Tree_](../../angular/nx-devkit/index#tree), `workspaceConfig`: [_WorkspaceConfiguration_](../../angular/nx-devkit/index#workspaceconfiguration)): _void_ + +Update general workspace configuration such as the default project or cli settings. + +This does _not_ update projects configuration, use [updateProjectConfiguration](../../angular/nx-devkit/index#updateprojectconfiguration) or [addProjectConfiguration](../../angular/nx-devkit/index#addprojectconfiguration) instead. + +#### Parameters + +| Name | Type | +| :---------------- | :------------------------------------------------------------------------------- | +| `host` | [_Tree_](../../angular/nx-devkit/index#tree) | +| `workspaceConfig` | [_WorkspaceConfiguration_](../../angular/nx-devkit/index#workspaceconfiguration) | + +**Returns:** _void_ + +--- + +### visitNotIgnoredFiles + +▸ **visitNotIgnoredFiles**(`tree`: [_Tree_](../../angular/nx-devkit/index#tree), `dirPath?`: _string_, `visitor`: (`path`: _string_) => _void_): _void_ + +Utility to act on all files in a tree that are not ignored by git. + +#### Parameters + +| Name | Type | +| :-------- | :------------------------------------------- | +| `tree` | [_Tree_](../../angular/nx-devkit/index#tree) | +| `dirPath` | _string_ | +| `visitor` | (`path`: _string_) => _void_ | + +**Returns:** _void_ + +--- + +### writeJson + +▸ **writeJson**(`host`: [_Tree_](../../angular/nx-devkit/index#tree), `path`: _string_, `value`: T, `options?`: [_JsonSerializeOptions_](../../angular/nx-devkit/index#jsonserializeoptions)): _void_ + +Writes a JSON value to the file system tree + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------- | +| `T` | _object_ | _object_ | + +#### Parameters + +| Name | Type | Description | +| :--------- | :--------------------------------------------------------------------------- | :------------------------------ | +| `host` | [_Tree_](../../angular/nx-devkit/index#tree) | File system tree | +| `path` | _string_ | Path of JSON file in the Tree | +| `value` | T | Serializable value to write | +| `options?` | [_JsonSerializeOptions_](../../angular/nx-devkit/index#jsonserializeoptions) | Optional JSON Serialize Options | + +**Returns:** _void_ + +--- + +### writeJsonFile + +▸ **writeJsonFile**(`path`: _string_, `data`: T, `options?`: JsonWriteOptions): _void_ + +Serializes the given data to JSON and writes it to a file. + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------- | +| `T` | _object_ | _object_ | + +#### Parameters + +| Name | Type | Description | +| :--------- | :--------------- | :-------------------------------------------------------------- | +| `path` | _string_ | A path to a file. | +| `data` | T | data which should be serialized to JSON and written to the file | +| `options?` | JsonWriteOptions | JSON serialize options | + +**Returns:** _void_ diff --git a/docs/angular/api-nx-devkit/ngcli_adapter.md b/docs/angular/api-nx-devkit/ngcli_adapter.md new file mode 100644 index 0000000000..32fa5223f7 --- /dev/null +++ b/docs/angular/api-nx-devkit/ngcli_adapter.md @@ -0,0 +1,98 @@ +# Module: ngcli-adapter + +## Table of contents + +### Classes + +- [NxScopedHost](../../angular/nx-devkit/ngcli_adapter#nxscopedhost) + +### Functions + +- [mockSchematicsForTesting](../../angular/nx-devkit/ngcli_adapter#mockschematicsfortesting) +- [overrideCollectionResolutionForTesting](../../angular/nx-devkit/ngcli_adapter#overridecollectionresolutionfortesting) +- [wrapAngularDevkitSchematic](../../angular/nx-devkit/ngcli_adapter#wrapangulardevkitschematic) + +## Classes + +### NxScopedHost + +• **NxScopedHost**: _object_ + +## Functions + +### mockSchematicsForTesting + +▸ **mockSchematicsForTesting**(`schematics`: { [name: string]: (`host`: [_Tree_](../../angular/nx-devkit/index#tree), `generatorOptions`: { [k: string]: _any_; }) => _Promise_; }): _void_ + +If you have an Nx Devkit generator invoking the wrapped Angular Devkit schematic, +and you don't want the Angular Devkit schematic to run, you can mock it up using this function. + +Unfortunately, there are some edge cases in the Nx-Angular devkit integration that +can be seen in the unit tests context. This function is useful for handling that as well. + +In this case, you can mock it up. + +Example: + +``` + mockSchematicsForTesting({ + 'mycollection:myschematic': (tree, params) => { + tree.write('README.md'); + } + }); + +``` + +#### Parameters + +| Name | Type | +| :----------- | :------- | +| `schematics` | _object_ | + +**Returns:** _void_ + +--- + +### overrideCollectionResolutionForTesting + +▸ **overrideCollectionResolutionForTesting**(`collections`: { [name: string]: _string_; }): _void_ + +By default, Angular Devkit schematic collections will be resolved using the Node resolution. +This doesn't work if you are testing schematics that refer to other schematics in the +same repo. + +This function can can be used to override the resolution behaviour. + +Example: + +``` + overrideCollectionResolutionForTesting({ + '@nrwl/workspace': path.join(__dirname, '../../../../workspace/collection.json'), + '@nrwl/angular': path.join(__dirname, '../../../../angular/collection.json'), + '@nrwl/linter': path.join(__dirname, '../../../../linter/collection.json') + }); + +``` + +#### Parameters + +| Name | Type | +| :------------ | :------- | +| `collections` | _object_ | + +**Returns:** _void_ + +--- + +### wrapAngularDevkitSchematic + +▸ **wrapAngularDevkitSchematic**(`collectionName`: _string_, `generatorName`: _string_): _function_ + +#### Parameters + +| Name | Type | +| :--------------- | :------- | +| `collectionName` | _string_ | +| `generatorName` | _string_ | + +**Returns:** (`host`: [_Tree_](../../angular/nx-devkit/index#tree), `generatorOptions`: { [k: string]: _any_; }) => _Promise_ diff --git a/docs/map.json b/docs/map.json index 4f0db48efe..93e548df0c 100644 --- a/docs/map.json +++ b/docs/map.json @@ -890,6 +890,24 @@ } ] }, + { + "name": "Nx Devkit", + "id": "nx-devkit", + "itemList": [ + { + "id": "index", + "name": "index", + "searchResultsName": "Nx Devkit", + "file": "angular/api-nx-devkit/index" + }, + { + "id": "ngcli_adapter", + "name": "ngcli_adapter", + "searchResultsName": "Ng CLI Adapter", + "file": "angular/api-nx-devkit/ngcli_adapter" + } + ] + }, { "name": "Executors / Builders", "id": "executors", @@ -1978,6 +1996,24 @@ } ] }, + { + "name": "Nx Devkit", + "id": "nx-devkit", + "itemList": [ + { + "id": "index", + "name": "index", + "searchResultsName": "Nx Devkit", + "file": "react/api-nx-devkit/index" + }, + { + "id": "ngcli_adapter", + "name": "ngcli_adapter", + "searchResultsName": "Ng CLI Adapter", + "file": "react/api-nx-devkit/ngcli_adapter" + } + ] + }, { "name": "Executors / Builders", "id": "executors", @@ -3012,6 +3048,24 @@ } ] }, + { + "name": "Nx Devkit", + "id": "nx-devkit", + "itemList": [ + { + "id": "index", + "name": "index", + "searchResultsName": "Nx Devkit", + "file": "node/api-nx-devkit/index" + }, + { + "id": "ngcli_adapter", + "name": "ngcli_adapter", + "searchResultsName": "Ng CLI Adapter", + "file": "node/api-nx-devkit/ngcli_adapter" + } + ] + }, { "name": "Executors / Builders", "id": "executors", diff --git a/docs/node/api-nx-devkit/index.md b/docs/node/api-nx-devkit/index.md new file mode 100644 index 0000000000..26d0f969fd --- /dev/null +++ b/docs/node/api-nx-devkit/index.md @@ -0,0 +1,1331 @@ +# Module: index + +## Table of contents + +### Enumerations + +- [ChangeType](../../node/nx-devkit/index#changetype) +- [DependencyType](../../node/nx-devkit/index#dependencytype) + +### Classes + +- [ProjectGraphBuilder](../../node/nx-devkit/index#projectgraphbuilder) + +### Interfaces + +- [ExecutorContext](../../node/nx-devkit/index#executorcontext) +- [FileChange](../../node/nx-devkit/index#filechange) +- [FileData](../../node/nx-devkit/index#filedata) +- [ImplicitJsonSubsetDependency](../../node/nx-devkit/index#implicitjsonsubsetdependency) +- [JsonParseOptions](../../node/nx-devkit/index#jsonparseoptions) +- [JsonSerializeOptions](../../node/nx-devkit/index#jsonserializeoptions) +- [NxAffectedConfig](../../node/nx-devkit/index#nxaffectedconfig) +- [NxJsonConfiguration](../../node/nx-devkit/index#nxjsonconfiguration) +- [NxJsonProjectConfiguration](../../node/nx-devkit/index#nxjsonprojectconfiguration) +- [NxPlugin](../../node/nx-devkit/index#nxplugin) +- [ProjectConfiguration](../../node/nx-devkit/index#projectconfiguration) +- [ProjectFileMap](../../node/nx-devkit/index#projectfilemap) +- [ProjectGraph](../../node/nx-devkit/index#projectgraph) +- [ProjectGraphDependency](../../node/nx-devkit/index#projectgraphdependency) +- [ProjectGraphNode](../../node/nx-devkit/index#projectgraphnode) +- [ProjectGraphProcessorContext](../../node/nx-devkit/index#projectgraphprocessorcontext) +- [StringDeletion](../../node/nx-devkit/index#stringdeletion) +- [StringInsertion](../../node/nx-devkit/index#stringinsertion) +- [Target](../../node/nx-devkit/index#target) +- [TargetConfiguration](../../node/nx-devkit/index#targetconfiguration) +- [TargetDependencyConfig](../../node/nx-devkit/index#targetdependencyconfig) +- [Tree](../../node/nx-devkit/index#tree) +- [Workspace](../../node/nx-devkit/index#workspace) +- [WorkspaceJsonConfiguration](../../node/nx-devkit/index#workspacejsonconfiguration) + +### Type aliases + +- [Executor](../../node/nx-devkit/index#executor) +- [Generator](../../node/nx-devkit/index#generator) +- [GeneratorCallback](../../node/nx-devkit/index#generatorcallback) +- [ImplicitDependencyEntry](../../node/nx-devkit/index#implicitdependencyentry) +- [PackageManager](../../node/nx-devkit/index#packagemanager) +- [ProjectType](../../node/nx-devkit/index#projecttype) +- [StringChange](../../node/nx-devkit/index#stringchange) +- [WorkspaceConfiguration](../../node/nx-devkit/index#workspaceconfiguration) + +### Variables + +- [logger](../../node/nx-devkit/index#logger) + +### Functions + +- [addDependenciesToPackageJson](../../node/nx-devkit/index#adddependenciestopackagejson) +- [addProjectConfiguration](../../node/nx-devkit/index#addprojectconfiguration) +- [applyChangesToString](../../node/nx-devkit/index#applychangestostring) +- [convertNxExecutor](../../node/nx-devkit/index#convertnxexecutor) +- [convertNxGenerator](../../node/nx-devkit/index#convertnxgenerator) +- [formatFiles](../../node/nx-devkit/index#formatfiles) +- [generateFiles](../../node/nx-devkit/index#generatefiles) +- [getPackageManagerCommand](../../node/nx-devkit/index#getpackagemanagercommand) +- [getProjects](../../node/nx-devkit/index#getprojects) +- [getWorkspaceLayout](../../node/nx-devkit/index#getworkspacelayout) +- [getWorkspacePath](../../node/nx-devkit/index#getworkspacepath) +- [installPackagesTask](../../node/nx-devkit/index#installpackagestask) +- [joinPathFragments](../../node/nx-devkit/index#joinpathfragments) +- [moveFilesToNewDirectory](../../node/nx-devkit/index#movefilestonewdirectory) +- [names](../../node/nx-devkit/index#names) +- [normalizePath](../../node/nx-devkit/index#normalizepath) +- [offsetFromRoot](../../node/nx-devkit/index#offsetfromroot) +- [parseJson](../../node/nx-devkit/index#parsejson) +- [parseTargetString](../../node/nx-devkit/index#parsetargetstring) +- [readJson](../../node/nx-devkit/index#readjson) +- [readJsonFile](../../node/nx-devkit/index#readjsonfile) +- [readProjectConfiguration](../../node/nx-devkit/index#readprojectconfiguration) +- [readTargetOptions](../../node/nx-devkit/index#readtargetoptions) +- [readWorkspaceConfiguration](../../node/nx-devkit/index#readworkspaceconfiguration) +- [removeDependenciesFromPackageJson](../../node/nx-devkit/index#removedependenciesfrompackagejson) +- [removeProjectConfiguration](../../node/nx-devkit/index#removeprojectconfiguration) +- [runExecutor](../../node/nx-devkit/index#runexecutor) +- [serializeJson](../../node/nx-devkit/index#serializejson) +- [stripIndents](../../node/nx-devkit/index#stripindents) +- [stripJsonComments](../../node/nx-devkit/index#stripjsoncomments) +- [targetToTargetString](../../node/nx-devkit/index#targettotargetstring) +- [toJS](../../node/nx-devkit/index#tojs) +- [updateJson](../../node/nx-devkit/index#updatejson) +- [updateProjectConfiguration](../../node/nx-devkit/index#updateprojectconfiguration) +- [updateTsConfigsToJs](../../node/nx-devkit/index#updatetsconfigstojs) +- [updateWorkspaceConfiguration](../../node/nx-devkit/index#updateworkspaceconfiguration) +- [visitNotIgnoredFiles](../../node/nx-devkit/index#visitnotignoredfiles) +- [writeJson](../../node/nx-devkit/index#writejson) +- [writeJsonFile](../../node/nx-devkit/index#writejsonfile) + +## Enumerations + +### ChangeType + +• **ChangeType**: _object_ + +--- + +### DependencyType + +• **DependencyType**: _object_ + +Type of dependency between projects + +## Classes + +### ProjectGraphBuilder + +• **ProjectGraphBuilder**: _object_ + +Builder for adding nodes and dependencies to a [ProjectGraph](../../node/nx-devkit/index#projectgraph) + +## Interfaces + +### ExecutorContext + +• **ExecutorContext**: _object_ + +Context that is passed into an executor + +--- + +### FileChange + +• **FileChange**: _object_ + +Description of a file change in the Nx virtual file system/ + +--- + +### FileData + +• **FileData**: _object_ + +Some metadata about a file + +--- + +### ImplicitJsonSubsetDependency + +• **ImplicitJsonSubsetDependency**: _object_ + +#### Type parameters + +| Name | Default | +| :--- | :------------------ | +| `T` | `"*"` \| _string_[] | + +--- + +### JsonParseOptions + +• **JsonParseOptions**: _object_ + +--- + +### JsonSerializeOptions + +• **JsonSerializeOptions**: _object_ + +--- + +### NxAffectedConfig + +• **NxAffectedConfig**: _object_ + +--- + +### NxJsonConfiguration + +• **NxJsonConfiguration**: _object_ + +Nx.json configuration + +#### Type parameters + +| Name | Default | +| :--- | :------------------ | +| `T` | `"*"` \| _string_[] | + +--- + +### NxJsonProjectConfiguration + +• **NxJsonProjectConfiguration**: _object_ + +--- + +### NxPlugin + +• **NxPlugin**: _object_ + +A plugin for Nx + +--- + +### ProjectConfiguration + +• **ProjectConfiguration**: _object_ + +Project configuration + +--- + +### ProjectFileMap + +• **ProjectFileMap**: _object_ + +A list of files separated by the project they belong to + +--- + +### ProjectGraph + +• **ProjectGraph**: _object_ + +A Graph of projects in the workspace and dependencies between them + +#### Type parameters + +| Name | Default | +| :--- | :------ | +| `T` | _any_ | + +--- + +### ProjectGraphDependency + +• **ProjectGraphDependency**: _object_ + +A dependency between two projects + +--- + +### ProjectGraphNode + +• **ProjectGraphNode**: _object_ + +A node describing a project in a workspace + +#### Type parameters + +| Name | Default | +| :--- | :------ | +| `T` | _any_ | + +--- + +### ProjectGraphProcessorContext + +• **ProjectGraphProcessorContext**: _object_ + +Additional information to be used to process a project graph + +--- + +### StringDeletion + +• **StringDeletion**: _object_ + +--- + +### StringInsertion + +• **StringInsertion**: _object_ + +--- + +### Target + +• **Target**: _object_ + +--- + +### TargetConfiguration + +• **TargetConfiguration**: _object_ + +Target's configuration + +--- + +### TargetDependencyConfig + +• **TargetDependencyConfig**: _object_ + +--- + +### Tree + +• **Tree**: _object_ + +Virtual file system tree. + +--- + +### Workspace + +• **Workspace**: _object_ + +--- + +### WorkspaceJsonConfiguration + +• **WorkspaceJsonConfiguration**: _object_ + +Workspace configuration + +## Type aliases + +### Executor + +Ƭ **Executor**: (`options`: T, `context`: [_ExecutorContext_](../../node/nx-devkit/index#executorcontext)) => _Promise_<{ `success`: _boolean_ }\> \| _AsyncIterableIterator_<{ `success`: _boolean_ }\> + +Implementation of a target of a project + +#### Type parameters + +| Name | Default | +| :--- | :------ | +| `T` | _any_ | + +#### Type declaration + +▸ (`options`: T, `context`: [_ExecutorContext_](../../node/nx-devkit/index#executorcontext)): _Promise_<{ `success`: _boolean_ }\> \| _AsyncIterableIterator_<{ `success`: _boolean_ }\> + +#### Parameters + +| Name | Type | +| :-------- | :-------------------------------------------------------------- | +| `options` | T | +| `context` | [_ExecutorContext_](../../node/nx-devkit/index#executorcontext) | + +**Returns:** _Promise_<{ `success`: _boolean_ }\> \| _AsyncIterableIterator_<{ `success`: _boolean_ }\> + +--- + +### Generator + +Ƭ **Generator**: (`tree`: _any_, `schema`: T) => _void_ \| [_GeneratorCallback_](../../node/nx-devkit/index#generatorcallback) \| _Promise_ + +A function that schedules updates to the filesystem to be done atomically + +#### Type parameters + +| Name | Default | +| :--- | :-------- | +| `T` | _unknown_ | + +#### Type declaration + +▸ (`tree`: _any_, `schema`: T): _void_ \| [_GeneratorCallback_](../../node/nx-devkit/index#generatorcallback) \| _Promise_ + +#### Parameters + +| Name | Type | +| :------- | :---- | +| `tree` | _any_ | +| `schema` | T | + +**Returns:** _void_ \| [_GeneratorCallback_](../../node/nx-devkit/index#generatorcallback) \| _Promise_ + +--- + +### GeneratorCallback + +Ƭ **GeneratorCallback**: () => _void_ \| _Promise_ + +A callback function that is executed after changes are made to the file system + +#### Type declaration + +▸ (): _void_ \| _Promise_ + +**Returns:** _void_ \| _Promise_ + +--- + +### ImplicitDependencyEntry + +Ƭ **ImplicitDependencyEntry**: _object_ + +#### Type parameters + +| Name | Default | +| :--- | :------------------ | +| `T` | `"*"` \| _string_[] | + +#### Type declaration + +--- + +### PackageManager + +Ƭ **PackageManager**: `"yarn"` \| `"pnpm"` \| `"npm"` + +--- + +### ProjectType + +Ƭ **ProjectType**: `"library"` \| `"application"` + +Type of project supported + +--- + +### StringChange + +Ƭ **StringChange**: [_StringInsertion_](../../node/nx-devkit/index#stringinsertion) \| [_StringDeletion_](../../node/nx-devkit/index#stringdeletion) + +A change to be made to a string + +--- + +### WorkspaceConfiguration + +Ƭ **WorkspaceConfiguration**: _Omit_<[_WorkspaceJsonConfiguration_](../../node/nx-devkit/index#workspacejsonconfiguration), `"projects"`\> & _Omit_<[_NxJsonConfiguration_](../../node/nx-devkit/index#nxjsonconfiguration), `"projects"`\> + +## Variables + +### logger + +• `Const` **logger**: _object_ + +#### Type declaration + +| Name | Type | +| :------ | :-------------------------- | +| `debug` | (...`s`: _any_[]) => _void_ | +| `error` | (`s`: _any_) => _void_ | +| `fatal` | (...`s`: _any_[]) => _void_ | +| `info` | (`s`: _any_) => _void_ | +| `log` | (...`s`: _any_[]) => _void_ | +| `warn` | (`s`: _any_) => _void_ | + +## Functions + +### addDependenciesToPackageJson + +▸ **addDependenciesToPackageJson**(`host`: [_Tree_](../../node/nx-devkit/index#tree), `dependencies`: _Record_, `devDependencies`: _Record_, `packageJsonPath?`: _string_): [_GeneratorCallback_](../../node/nx-devkit/index#generatorcallback) + +Add Dependencies and Dev Dependencies to package.json + +For example, `addDependenciesToPackageJson(host, { react: 'latest' }, { jest: 'latest' })` +will add `react` and `jest` to the dependencies and devDependencies sections of package.json respectively + +#### Parameters + +| Name | Type | Default value | Description | +| :---------------- | :---------------------------------------- | :------------- | :---------------------------------------------------------------------- | +| `host` | [_Tree_](../../node/nx-devkit/index#tree) | - | Tree representing file system to modify | +| `dependencies` | _Record_ | - | Dependencies to be added to the dependencies section of package.json | +| `devDependencies` | _Record_ | - | Dependencies to be added to the devDependencies section of package.json | +| `packageJsonPath` | _string_ | 'package.json' | Path to package.json | + +**Returns:** [_GeneratorCallback_](../../node/nx-devkit/index#generatorcallback) + +Callback to install dependencies only if necessary. undefined is returned if changes are not necessary. + +--- + +### addProjectConfiguration + +▸ **addProjectConfiguration**(`host`: [_Tree_](../../node/nx-devkit/index#tree), `projectName`: _string_, `projectConfiguration`: [_ProjectConfiguration_](../../node/nx-devkit/index#projectconfiguration) & [_NxJsonProjectConfiguration_](../../node/nx-devkit/index#nxjsonprojectconfiguration)): _void_ + +Adds project configuration to the Nx workspace. + +The project configuration is stored in workspace.json and nx.json. The utility will update +both files. + +#### Parameters + +| Name | Type | Description | +| :--------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------- | +| `host` | [_Tree_](../../node/nx-devkit/index#tree) | the file system tree | +| `projectName` | _string_ | unique name. Often directories are part of the name (e.g., mydir-mylib) | +| `projectConfiguration` | [_ProjectConfiguration_](../../node/nx-devkit/index#projectconfiguration) & [_NxJsonProjectConfiguration_](../../node/nx-devkit/index#nxjsonprojectconfiguration) | project configuration | + +**Returns:** _void_ + +--- + +### applyChangesToString + +▸ **applyChangesToString**(`text`: _string_, `changes`: [_StringChange_](../../node/nx-devkit/index#stringchange)[]): _string_ + +Applies a list of changes to a string's original value. + +This is useful when working with ASTs. + +For Example, to rename a property in a method's options: + +``` +const code = `bootstrap({ + target: document.querySelector('#app') +})`; + +const indexOfPropertyName = 13; // Usually determined by analyzing an AST. +const updatedCode = applyChangesToString(code, [ + { + type: ChangeType.Insert, + index: indexOfPropertyName, + text: 'element' + }, + { + type: ChangeType.Delete, + start: indexOfPropertyName, + length: 6 + }, +]); + +bootstrap({ + element: document.querySelector('#app') +}); +``` + +#### Parameters + +| Name | Type | +| :-------- | :---------------------------------------------------------- | +| `text` | _string_ | +| `changes` | [_StringChange_](../../node/nx-devkit/index#stringchange)[] | + +**Returns:** _string_ + +--- + +### convertNxExecutor + +▸ **convertNxExecutor**(`executor`: [_Executor_](../../node/nx-devkit/index#executor)): _any_ + +Convert an Nx Executor into an Angular Devkit Builder + +Use this to expose a compatible Angular Builder + +#### Parameters + +| Name | Type | +| :--------- | :------------------------------------------------ | +| `executor` | [_Executor_](../../node/nx-devkit/index#executor) | + +**Returns:** _any_ + +--- + +### convertNxGenerator + +▸ **convertNxGenerator**(`generator`: [_Generator_](../../node/nx-devkit/index#generator)): _function_ + +Convert an Nx Generator into an Angular Devkit Schematic + +#### Type parameters + +| Name | Default | +| :--- | :------ | +| `T` | _any_ | + +#### Parameters + +| Name | Type | +| :---------- | :------------------------------------------------------ | +| `generator` | [_Generator_](../../node/nx-devkit/index#generator) | + +**Returns:** (`options`: T) => (`tree`: _any_, `context`: _any_) => _Promise_ + +--- + +### formatFiles + +▸ **formatFiles**(`host`: [_Tree_](../../node/nx-devkit/index#tree)): _Promise_ + +Formats all the created or updated files using Prettier + +#### Parameters + +| Name | Type | Description | +| :----- | :---------------------------------------- | :------------------- | +| `host` | [_Tree_](../../node/nx-devkit/index#tree) | the file system tree | + +**Returns:** _Promise_ + +--- + +### generateFiles + +▸ **generateFiles**(`host`: [_Tree_](../../node/nx-devkit/index#tree), `srcFolder`: _string_, `target`: _string_, `substitutions`: { [k: string]: _any_; }): _void_ + +Generates a folder of files based on provided templates. + +While doing so it performs two substitutions: + +- Substitutes segments of file names surrounded by \_\_ +- Uses ejs to substitute values in templates + +#### Parameters + +| Name | Type | Description | +| :-------------- | :---------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `host` | [_Tree_](../../node/nx-devkit/index#tree) | the file system tree | +| `srcFolder` | _string_ | the source folder of files (absolute path) | +| `target` | _string_ | the target folder (relative to the host root) | +| `substitutions` | _object_ | an object of key-value pairs Examples: `typescript generateFiles(host, path.join(__dirname , 'files'), './tools/scripts', {tmpl: '', name: 'myscript'}) ` This command will take all the files from the `files` directory next to the place where the command is invoked from. It will replace all `__tmpl__` with '' and all `__name__` with 'myscript' in the file names, and will replace all `<%= name %>` with `myscript` in the files themselves. `tmpl: ''` is a common pattern. With it you can name files like this: `index.ts__tmpl__`, so your editor doesn't get confused about incorrect TypeScript files. | + +**Returns:** _void_ + +--- + +### getPackageManagerCommand + +▸ **getPackageManagerCommand**(`packageManager?`: [_PackageManager_](../../node/nx-devkit/index#packagemanager)): _object_ + +Returns commands for the package manager used in the workspace. +By default, the package manager is derived based on the lock file, +but it can also be passed in explicitly. + +Example: + +```javascript +execSync(`${getPackageManagerCommand().addDev} my-dev-package`); +``` + +#### Parameters + +| Name | Type | +| :--------------- | :------------------------------------------------------------ | +| `packageManager` | [_PackageManager_](../../node/nx-devkit/index#packagemanager) | + +**Returns:** _object_ + +| Name | Type | +| :-------- | :------------------------------------------------- | +| `add` | _string_ | +| `addDev` | _string_ | +| `exec` | _string_ | +| `install` | _string_ | +| `list` | _string_ | +| `rm` | _string_ | +| `run` | (`script`: _string_, `args`: _string_) => _string_ | + +--- + +### getProjects + +▸ **getProjects**(`host`: [_Tree_](../../node/nx-devkit/index#tree)): _Map_ + +Get a map of all projects in a workspace. + +Use [readProjectConfiguration](../../node/nx-devkit/index#readprojectconfiguration) if only one project is needed. + +#### Parameters + +| Name | Type | +| :----- | :---------------------------------------- | +| `host` | [_Tree_](../../node/nx-devkit/index#tree) | + +**Returns:** _Map_ + +--- + +### getWorkspaceLayout + +▸ **getWorkspaceLayout**(`host`: [_Tree_](../../node/nx-devkit/index#tree)): _object_ + +Returns workspace defaults. It includes defaults folders for apps and libs, +and the default scope. + +Example: + +`{ appsDir: 'apps', libsDir: 'libs', npmScope: 'myorg' }` + +#### Parameters + +| Name | Type | Description | +| :----- | :---------------------------------------- | :--------------- | +| `host` | [_Tree_](../../node/nx-devkit/index#tree) | file system tree | + +**Returns:** _object_ + +| Name | Type | +| :--------- | :------- | +| `appsDir` | _string_ | +| `libsDir` | _string_ | +| `npmScope` | _string_ | + +--- + +### getWorkspacePath + +▸ **getWorkspacePath**(`host`: [_Tree_](../../node/nx-devkit/index#tree)): _string_ + +#### Parameters + +| Name | Type | +| :----- | :---------------------------------------- | +| `host` | [_Tree_](../../node/nx-devkit/index#tree) | + +**Returns:** _string_ + +--- + +### installPackagesTask + +▸ **installPackagesTask**(`host`: [_Tree_](../../node/nx-devkit/index#tree), `alwaysRun?`: _boolean_, `cwd?`: _string_, `packageManager?`: [_PackageManager_](../../node/nx-devkit/index#packagemanager)): _void_ + +Runs `npm install` or `yarn install`. It will skip running the install if +`package.json` hasn't changed at all or it hasn't changed since the last invocation. + +#### Parameters + +| Name | Type | Default value | Description | +| :--------------- | :------------------------------------------------------------ | :------------ | :------------------------------------------------------------ | +| `host` | [_Tree_](../../node/nx-devkit/index#tree) | - | the file system tree | +| `alwaysRun` | _boolean_ | false | always run the command even if `package.json` hasn't changed. | +| `cwd` | _string_ | '' | - | +| `packageManager` | [_PackageManager_](../../node/nx-devkit/index#packagemanager) | - | - | + +**Returns:** _void_ + +--- + +### joinPathFragments + +▸ **joinPathFragments**(...`fragments`: _string_[]): _string_ + +Normalized path fragments and joins them + +#### Parameters + +| Name | Type | +| :------------- | :--------- | +| `...fragments` | _string_[] | + +**Returns:** _string_ + +--- + +### moveFilesToNewDirectory + +▸ **moveFilesToNewDirectory**(`host`: [_Tree_](../../node/nx-devkit/index#tree), `oldDir`: _string_, `newDir`: _string_): _void_ + +#### Parameters + +| Name | Type | +| :------- | :---------------------------------------- | +| `host` | [_Tree_](../../node/nx-devkit/index#tree) | +| `oldDir` | _string_ | +| `newDir` | _string_ | + +**Returns:** _void_ + +--- + +### names + +▸ **names**(`name`: _string_): _object_ + +Util function to generate different strings based off the provided name. + +Examples: + +```typescript +names('my-name'); // {name: 'my-name', className: 'MyName', propertyName: 'myName', constantName: 'MY_NAME', fileName: 'my-name'} +names('myName'); // {name: 'my-name', className: 'MyName', propertyName: 'myName', constantName: 'MY_NAME', fileName: 'my-name'} +``` + +#### Parameters + +| Name | Type | +| :----- | :------- | +| `name` | _string_ | + +**Returns:** _object_ + +| Name | Type | +| :------------- | :------- | +| `className` | _string_ | +| `constantName` | _string_ | +| `fileName` | _string_ | +| `name` | _string_ | +| `propertyName` | _string_ | + +--- + +### normalizePath + +▸ **normalizePath**(`osSpecificPath`: _string_): _string_ + +Coverts an os specific path to a unix style path + +#### Parameters + +| Name | Type | +| :--------------- | :------- | +| `osSpecificPath` | _string_ | + +**Returns:** _string_ + +--- + +### offsetFromRoot + +▸ **offsetFromRoot**(`fullPathToDir`: _string_): _string_ + +Calculates an offset from the root of the workspace, which is useful for +constructing relative URLs. + +Examples: + +```typescript +offsetFromRoot('apps/mydir/myapp/'); // returns "../../../" +``` + +#### Parameters + +| Name | Type | Description | +| :-------------- | :------- | :------------- | +| `fullPathToDir` | _string_ | directory path | + +**Returns:** _string_ + +--- + +### parseJson + +▸ **parseJson**(`input`: _string_, `options?`: [_JsonParseOptions_](../../node/nx-devkit/index#jsonparseoptions)): T + +Parses the given JSON string and returns the object the JSON content represents. +By default javascript-style comments are allowed. + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------ | +| `T` | _object_ | _any_ | + +#### Parameters + +| Name | Type | Description | +| :--------- | :---------------------------------------------------------------- | :--------------------- | +| `input` | _string_ | JSON content as string | +| `options?` | [_JsonParseOptions_](../../node/nx-devkit/index#jsonparseoptions) | JSON parse options | + +**Returns:** T + +Object the JSON content represents + +--- + +### parseTargetString + +▸ **parseTargetString**(`targetString`: _string_): [_Target_](../../node/nx-devkit/index#target) + +Parses a target string into {project, target, configuration} + +#### Parameters + +| Name | Type | Description | +| :------------- | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `targetString` | _string_ | target reference Examples: `typescript parseTargetString("proj:test") // returns { project: "proj", target: "test" } parseTargetString("proj:test:production") // returns { project: "proj", target: "test", configuration: "production" } ` | + +**Returns:** [_Target_](../../node/nx-devkit/index#target) + +--- + +### readJson + +▸ **readJson**(`host`: [_Tree_](../../node/nx-devkit/index#tree), `path`: _string_, `options?`: [_JsonParseOptions_](../../node/nx-devkit/index#jsonparseoptions)): T + +Reads a document for host, removes all comments and parses JSON. + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------ | +| `T` | _object_ | _any_ | + +#### Parameters + +| Name | Type | Description | +| :--------- | :---------------------------------------------------------------- | :-------------------------- | +| `host` | [_Tree_](../../node/nx-devkit/index#tree) | file system tree | +| `path` | _string_ | file path | +| `options?` | [_JsonParseOptions_](../../node/nx-devkit/index#jsonparseoptions) | Optional JSON Parse Options | + +**Returns:** T + +--- + +### readJsonFile + +▸ **readJsonFile**(`path`: _string_, `options?`: JsonReadOptions): T + +Reads a JSON file and returns the object the JSON content represents. + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------ | +| `T` | _object_ | _any_ | + +#### Parameters + +| Name | Type | Description | +| :--------- | :-------------- | :----------------- | +| `path` | _string_ | A path to a file. | +| `options?` | JsonReadOptions | JSON parse options | + +**Returns:** T + +Object the JSON content of the file represents + +--- + +### readProjectConfiguration + +▸ **readProjectConfiguration**(`host`: [_Tree_](../../node/nx-devkit/index#tree), `projectName`: _string_): [_ProjectConfiguration_](../../node/nx-devkit/index#projectconfiguration) & [_NxJsonProjectConfiguration_](../../node/nx-devkit/index#nxjsonprojectconfiguration) + +Reads a project configuration. + +The project configuration is stored in workspace.json and nx.json. The utility will read +both files. + +#### Parameters + +| Name | Type | Description | +| :------------ | :---------------------------------------- | :---------------------------------------------------------------------- | +| `host` | [_Tree_](../../node/nx-devkit/index#tree) | the file system tree | +| `projectName` | _string_ | unique name. Often directories are part of the name (e.g., mydir-mylib) | + +**Returns:** [_ProjectConfiguration_](../../node/nx-devkit/index#projectconfiguration) & [_NxJsonProjectConfiguration_](../../node/nx-devkit/index#nxjsonprojectconfiguration) + +--- + +### readTargetOptions + +▸ **readTargetOptions**(`__namedParameters`: [_Target_](../../node/nx-devkit/index#target), `context`: [_ExecutorContext_](../../node/nx-devkit/index#executorcontext)): T + +Reads and combines options for a given target. + +Works as if you invoked the target yourself without passing any command lint overrides. + +#### Type parameters + +| Name | Default | +| :--- | :------ | +| `T` | _any_ | + +#### Parameters + +| Name | Type | +| :------------------ | :-------------------------------------------------------------- | +| `__namedParameters` | [_Target_](../../node/nx-devkit/index#target) | +| `context` | [_ExecutorContext_](../../node/nx-devkit/index#executorcontext) | + +**Returns:** T + +--- + +### readWorkspaceConfiguration + +▸ **readWorkspaceConfiguration**(`host`: [_Tree_](../../node/nx-devkit/index#tree)): [_WorkspaceConfiguration_](../../node/nx-devkit/index#workspaceconfiguration) + +Read general workspace configuration such as the default project or cli settings + +This does _not_ provide projects configuration, use [readProjectConfiguration](../../node/nx-devkit/index#readprojectconfiguration) instead. + +#### Parameters + +| Name | Type | +| :----- | :---------------------------------------- | +| `host` | [_Tree_](../../node/nx-devkit/index#tree) | + +**Returns:** [_WorkspaceConfiguration_](../../node/nx-devkit/index#workspaceconfiguration) + +--- + +### removeDependenciesFromPackageJson + +▸ **removeDependenciesFromPackageJson**(`host`: [_Tree_](../../node/nx-devkit/index#tree), `dependencies`: _string_[], `devDependencies`: _string_[], `packageJsonPath?`: _string_): [_GeneratorCallback_](../../node/nx-devkit/index#generatorcallback) + +Remove Dependencies and Dev Dependencies from package.json + +For example, `removeDependenciesFromPackageJson(host, ['react'], ['jest'])` +will remove `react` and `jest` from the dependencies and devDependencies sections of package.json respectively + +#### Parameters + +| Name | Type | Default value | Description | +| :---------------- | :---------------------------------------- | :------------- | :-------------------------------------------------------------------------- | +| `host` | [_Tree_](../../node/nx-devkit/index#tree) | - | - | +| `dependencies` | _string_[] | - | Dependencies to be removed from the dependencies section of package.json | +| `devDependencies` | _string_[] | - | Dependencies to be removed from the devDependencies section of package.json | +| `packageJsonPath` | _string_ | 'package.json' | - | + +**Returns:** [_GeneratorCallback_](../../node/nx-devkit/index#generatorcallback) + +Callback to uninstall dependencies only if necessary. undefined is returned if changes are not necessary. + +--- + +### removeProjectConfiguration + +▸ **removeProjectConfiguration**(`host`: [_Tree_](../../node/nx-devkit/index#tree), `projectName`: _string_): _void_ + +Removes the configuration of an existing project. + +The project configuration is stored in workspace.json and nx.json. +The utility will update both files. + +#### Parameters + +| Name | Type | +| :------------ | :---------------------------------------- | +| `host` | [_Tree_](../../node/nx-devkit/index#tree) | +| `projectName` | _string_ | + +**Returns:** _void_ + +--- + +### runExecutor + +▸ **runExecutor**(`targetDescription`: { `configuration?`: _string_ ; `project`: _string_ ; `target`: _string_ }, `options`: { [k: string]: _any_; }, `context`: [_ExecutorContext_](../../node/nx-devkit/index#executorcontext)): _Promise_\> + +Loads and invokes executor. + +This is analogous to invoking executor from the terminal, with the exception +that the params aren't parsed from the string, but instead provided parsed already. + +Apart from that, it works the same way: + +- it will load the workspace configuration +- it will resolve the target +- it will load the executor and the schema +- it will load the options for the appropriate configuration +- it will run the validations and will set the default +- and, of course, it will invoke the executor + +Example: + +```typescript +for await (const s of await runExecutor( + { project: 'myproj', target: 'serve' }, + { watch: true }, + context +)) { + // s.success +} +``` + +Note that the return value is a promise of an iterator, so you need to await before iterating over it. + +#### Type parameters + +| Name | Type | +| :---------- | :-------- | +| `T` | _object_ | +| `T.success` | _boolean_ | + +#### Parameters + +| Name | Type | +| :--------------------------------- | :-------------------------------------------------------------- | +| `targetDescription` | _object_ | +| `targetDescription.configuration?` | _string_ | +| `targetDescription.project` | _string_ | +| `targetDescription.target` | _string_ | +| `options` | _object_ | +| `context` | [_ExecutorContext_](../../node/nx-devkit/index#executorcontext) | + +**Returns:** _Promise_\> + +--- + +### serializeJson + +▸ **serializeJson**(`input`: T, `options?`: [_JsonSerializeOptions_](../../node/nx-devkit/index#jsonserializeoptions)): _string_ + +Serializes the given data to a JSON string. +By default the JSON string is formatted with a 2 space intendation to be easy readable. + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------- | +| `T` | _object_ | _object_ | + +#### Parameters + +| Name | Type | Description | +| :--------- | :------------------------------------------------------------------------ | :---------------------------------------- | +| `input` | T | Object which should be serialized to JSON | +| `options?` | [_JsonSerializeOptions_](../../node/nx-devkit/index#jsonserializeoptions) | JSON serialize options | + +**Returns:** _string_ + +the formatted JSON representation of the object + +--- + +### stripIndents + +▸ **stripIndents**(`strings`: TemplateStringsArray, ...`values`: _any_[]): _string_ + +Removes indents, which is useful for printing warning and messages. + +Example: + +```typescript +stripIndents` + Options: + - option1 + - option2 +`; +``` + +#### Parameters + +| Name | Type | +| :---------- | :------------------- | +| `strings` | TemplateStringsArray | +| `...values` | _any_[] | + +**Returns:** _string_ + +--- + +### stripJsonComments + +▸ `Const` **stripJsonComments**(`text`: _string_, `replaceCh?`: _string_): _string_ + +Takes JSON with JavaScript-style comments and remove +them. Optionally replaces every none-newline character +of comments with a replaceCharacter + +#### Parameters + +| Name | Type | +| :----------- | :------- | +| `text` | _string_ | +| `replaceCh?` | _string_ | + +**Returns:** _string_ + +--- + +### targetToTargetString + +▸ **targetToTargetString**(`__namedParameters`: [_Target_](../../node/nx-devkit/index#target)): _string_ + +Returns a string in the format "project:target[:configuration]" for the target + +#### Parameters + +| Name | Type | +| :------------------ | :-------------------------------------------- | +| `__namedParameters` | [_Target_](../../node/nx-devkit/index#target) | + +**Returns:** _string_ + +--- + +### toJS + +▸ **toJS**(`tree`: [_Tree_](../../node/nx-devkit/index#tree)): _void_ + +Rename and transpile any new typescript files created to javascript files + +#### Parameters + +| Name | Type | +| :----- | :---------------------------------------- | +| `tree` | [_Tree_](../../node/nx-devkit/index#tree) | + +**Returns:** _void_ + +--- + +### updateJson + +▸ **updateJson**(`host`: [_Tree_](../../node/nx-devkit/index#tree), `path`: _string_, `updater`: (`value`: T) => U, `options?`: [_JsonParseOptions_](../../node/nx-devkit/index#jsonparseoptions) & [_JsonSerializeOptions_](../../node/nx-devkit/index#jsonserializeoptions)): _void_ + +Updates a JSON value to the file system tree + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------ | +| `T` | _object_ | _any_ | +| `U` | _object_ | T | + +#### Parameters + +| Name | Type | Description | +| :--------- | :-------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------- | +| `host` | [_Tree_](../../node/nx-devkit/index#tree) | File system tree | +| `path` | _string_ | Path of JSON file in the Tree | +| `updater` | (`value`: T) => U | Function that maps the current value of a JSON document to a new value to be written to the document | +| `options?` | [_JsonParseOptions_](../../node/nx-devkit/index#jsonparseoptions) & [_JsonSerializeOptions_](../../node/nx-devkit/index#jsonserializeoptions) | Optional JSON Parse and Serialize Options | + +**Returns:** _void_ + +--- + +### updateProjectConfiguration + +▸ **updateProjectConfiguration**(`host`: [_Tree_](../../node/nx-devkit/index#tree), `projectName`: _string_, `projectConfiguration`: [_ProjectConfiguration_](../../node/nx-devkit/index#projectconfiguration) & [_NxJsonProjectConfiguration_](../../node/nx-devkit/index#nxjsonprojectconfiguration)): _void_ + +Updates the configuration of an existing project. + +The project configuration is stored in workspace.json and nx.json. The utility will update +both files. + +#### Parameters + +| Name | Type | Description | +| :--------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------- | +| `host` | [_Tree_](../../node/nx-devkit/index#tree) | the file system tree | +| `projectName` | _string_ | unique name. Often directories are part of the name (e.g., mydir-mylib) | +| `projectConfiguration` | [_ProjectConfiguration_](../../node/nx-devkit/index#projectconfiguration) & [_NxJsonProjectConfiguration_](../../node/nx-devkit/index#nxjsonprojectconfiguration) | project configuration | + +**Returns:** _void_ + +--- + +### updateTsConfigsToJs + +▸ **updateTsConfigsToJs**(`host`: [_Tree_](../../node/nx-devkit/index#tree), `options`: { `projectRoot`: _string_ }): _void_ + +#### Parameters + +| Name | Type | +| :-------------------- | :---------------------------------------- | +| `host` | [_Tree_](../../node/nx-devkit/index#tree) | +| `options` | _object_ | +| `options.projectRoot` | _string_ | + +**Returns:** _void_ + +--- + +### updateWorkspaceConfiguration + +▸ **updateWorkspaceConfiguration**(`host`: [_Tree_](../../node/nx-devkit/index#tree), `workspaceConfig`: [_WorkspaceConfiguration_](../../node/nx-devkit/index#workspaceconfiguration)): _void_ + +Update general workspace configuration such as the default project or cli settings. + +This does _not_ update projects configuration, use [updateProjectConfiguration](../../node/nx-devkit/index#updateprojectconfiguration) or [addProjectConfiguration](../../node/nx-devkit/index#addprojectconfiguration) instead. + +#### Parameters + +| Name | Type | +| :---------------- | :---------------------------------------------------------------------------- | +| `host` | [_Tree_](../../node/nx-devkit/index#tree) | +| `workspaceConfig` | [_WorkspaceConfiguration_](../../node/nx-devkit/index#workspaceconfiguration) | + +**Returns:** _void_ + +--- + +### visitNotIgnoredFiles + +▸ **visitNotIgnoredFiles**(`tree`: [_Tree_](../../node/nx-devkit/index#tree), `dirPath?`: _string_, `visitor`: (`path`: _string_) => _void_): _void_ + +Utility to act on all files in a tree that are not ignored by git. + +#### Parameters + +| Name | Type | +| :-------- | :---------------------------------------- | +| `tree` | [_Tree_](../../node/nx-devkit/index#tree) | +| `dirPath` | _string_ | +| `visitor` | (`path`: _string_) => _void_ | + +**Returns:** _void_ + +--- + +### writeJson + +▸ **writeJson**(`host`: [_Tree_](../../node/nx-devkit/index#tree), `path`: _string_, `value`: T, `options?`: [_JsonSerializeOptions_](../../node/nx-devkit/index#jsonserializeoptions)): _void_ + +Writes a JSON value to the file system tree + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------- | +| `T` | _object_ | _object_ | + +#### Parameters + +| Name | Type | Description | +| :--------- | :------------------------------------------------------------------------ | :------------------------------ | +| `host` | [_Tree_](../../node/nx-devkit/index#tree) | File system tree | +| `path` | _string_ | Path of JSON file in the Tree | +| `value` | T | Serializable value to write | +| `options?` | [_JsonSerializeOptions_](../../node/nx-devkit/index#jsonserializeoptions) | Optional JSON Serialize Options | + +**Returns:** _void_ + +--- + +### writeJsonFile + +▸ **writeJsonFile**(`path`: _string_, `data`: T, `options?`: JsonWriteOptions): _void_ + +Serializes the given data to JSON and writes it to a file. + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------- | +| `T` | _object_ | _object_ | + +#### Parameters + +| Name | Type | Description | +| :--------- | :--------------- | :-------------------------------------------------------------- | +| `path` | _string_ | A path to a file. | +| `data` | T | data which should be serialized to JSON and written to the file | +| `options?` | JsonWriteOptions | JSON serialize options | + +**Returns:** _void_ diff --git a/docs/node/api-nx-devkit/ngcli_adapter.md b/docs/node/api-nx-devkit/ngcli_adapter.md new file mode 100644 index 0000000000..15fed02eb6 --- /dev/null +++ b/docs/node/api-nx-devkit/ngcli_adapter.md @@ -0,0 +1,98 @@ +# Module: ngcli-adapter + +## Table of contents + +### Classes + +- [NxScopedHost](../../node/nx-devkit/ngcli_adapter#nxscopedhost) + +### Functions + +- [mockSchematicsForTesting](../../node/nx-devkit/ngcli_adapter#mockschematicsfortesting) +- [overrideCollectionResolutionForTesting](../../node/nx-devkit/ngcli_adapter#overridecollectionresolutionfortesting) +- [wrapAngularDevkitSchematic](../../node/nx-devkit/ngcli_adapter#wrapangulardevkitschematic) + +## Classes + +### NxScopedHost + +• **NxScopedHost**: _object_ + +## Functions + +### mockSchematicsForTesting + +▸ **mockSchematicsForTesting**(`schematics`: { [name: string]: (`host`: [_Tree_](../../node/nx-devkit/index#tree), `generatorOptions`: { [k: string]: _any_; }) => _Promise_; }): _void_ + +If you have an Nx Devkit generator invoking the wrapped Angular Devkit schematic, +and you don't want the Angular Devkit schematic to run, you can mock it up using this function. + +Unfortunately, there are some edge cases in the Nx-Angular devkit integration that +can be seen in the unit tests context. This function is useful for handling that as well. + +In this case, you can mock it up. + +Example: + +``` + mockSchematicsForTesting({ + 'mycollection:myschematic': (tree, params) => { + tree.write('README.md'); + } + }); + +``` + +#### Parameters + +| Name | Type | +| :----------- | :------- | +| `schematics` | _object_ | + +**Returns:** _void_ + +--- + +### overrideCollectionResolutionForTesting + +▸ **overrideCollectionResolutionForTesting**(`collections`: { [name: string]: _string_; }): _void_ + +By default, Angular Devkit schematic collections will be resolved using the Node resolution. +This doesn't work if you are testing schematics that refer to other schematics in the +same repo. + +This function can can be used to override the resolution behaviour. + +Example: + +``` + overrideCollectionResolutionForTesting({ + '@nrwl/workspace': path.join(__dirname, '../../../../workspace/collection.json'), + '@nrwl/angular': path.join(__dirname, '../../../../angular/collection.json'), + '@nrwl/linter': path.join(__dirname, '../../../../linter/collection.json') + }); + +``` + +#### Parameters + +| Name | Type | +| :------------ | :------- | +| `collections` | _object_ | + +**Returns:** _void_ + +--- + +### wrapAngularDevkitSchematic + +▸ **wrapAngularDevkitSchematic**(`collectionName`: _string_, `generatorName`: _string_): _function_ + +#### Parameters + +| Name | Type | +| :--------------- | :------- | +| `collectionName` | _string_ | +| `generatorName` | _string_ | + +**Returns:** (`host`: [_Tree_](../../node/nx-devkit/index#tree), `generatorOptions`: { [k: string]: _any_; }) => _Promise_ diff --git a/docs/react/api-nx-devkit/index.md b/docs/react/api-nx-devkit/index.md new file mode 100644 index 0000000000..dfd89d0b7b --- /dev/null +++ b/docs/react/api-nx-devkit/index.md @@ -0,0 +1,1331 @@ +# Module: index + +## Table of contents + +### Enumerations + +- [ChangeType](../../react/nx-devkit/index#changetype) +- [DependencyType](../../react/nx-devkit/index#dependencytype) + +### Classes + +- [ProjectGraphBuilder](../../react/nx-devkit/index#projectgraphbuilder) + +### Interfaces + +- [ExecutorContext](../../react/nx-devkit/index#executorcontext) +- [FileChange](../../react/nx-devkit/index#filechange) +- [FileData](../../react/nx-devkit/index#filedata) +- [ImplicitJsonSubsetDependency](../../react/nx-devkit/index#implicitjsonsubsetdependency) +- [JsonParseOptions](../../react/nx-devkit/index#jsonparseoptions) +- [JsonSerializeOptions](../../react/nx-devkit/index#jsonserializeoptions) +- [NxAffectedConfig](../../react/nx-devkit/index#nxaffectedconfig) +- [NxJsonConfiguration](../../react/nx-devkit/index#nxjsonconfiguration) +- [NxJsonProjectConfiguration](../../react/nx-devkit/index#nxjsonprojectconfiguration) +- [NxPlugin](../../react/nx-devkit/index#nxplugin) +- [ProjectConfiguration](../../react/nx-devkit/index#projectconfiguration) +- [ProjectFileMap](../../react/nx-devkit/index#projectfilemap) +- [ProjectGraph](../../react/nx-devkit/index#projectgraph) +- [ProjectGraphDependency](../../react/nx-devkit/index#projectgraphdependency) +- [ProjectGraphNode](../../react/nx-devkit/index#projectgraphnode) +- [ProjectGraphProcessorContext](../../react/nx-devkit/index#projectgraphprocessorcontext) +- [StringDeletion](../../react/nx-devkit/index#stringdeletion) +- [StringInsertion](../../react/nx-devkit/index#stringinsertion) +- [Target](../../react/nx-devkit/index#target) +- [TargetConfiguration](../../react/nx-devkit/index#targetconfiguration) +- [TargetDependencyConfig](../../react/nx-devkit/index#targetdependencyconfig) +- [Tree](../../react/nx-devkit/index#tree) +- [Workspace](../../react/nx-devkit/index#workspace) +- [WorkspaceJsonConfiguration](../../react/nx-devkit/index#workspacejsonconfiguration) + +### Type aliases + +- [Executor](../../react/nx-devkit/index#executor) +- [Generator](../../react/nx-devkit/index#generator) +- [GeneratorCallback](../../react/nx-devkit/index#generatorcallback) +- [ImplicitDependencyEntry](../../react/nx-devkit/index#implicitdependencyentry) +- [PackageManager](../../react/nx-devkit/index#packagemanager) +- [ProjectType](../../react/nx-devkit/index#projecttype) +- [StringChange](../../react/nx-devkit/index#stringchange) +- [WorkspaceConfiguration](../../react/nx-devkit/index#workspaceconfiguration) + +### Variables + +- [logger](../../react/nx-devkit/index#logger) + +### Functions + +- [addDependenciesToPackageJson](../../react/nx-devkit/index#adddependenciestopackagejson) +- [addProjectConfiguration](../../react/nx-devkit/index#addprojectconfiguration) +- [applyChangesToString](../../react/nx-devkit/index#applychangestostring) +- [convertNxExecutor](../../react/nx-devkit/index#convertnxexecutor) +- [convertNxGenerator](../../react/nx-devkit/index#convertnxgenerator) +- [formatFiles](../../react/nx-devkit/index#formatfiles) +- [generateFiles](../../react/nx-devkit/index#generatefiles) +- [getPackageManagerCommand](../../react/nx-devkit/index#getpackagemanagercommand) +- [getProjects](../../react/nx-devkit/index#getprojects) +- [getWorkspaceLayout](../../react/nx-devkit/index#getworkspacelayout) +- [getWorkspacePath](../../react/nx-devkit/index#getworkspacepath) +- [installPackagesTask](../../react/nx-devkit/index#installpackagestask) +- [joinPathFragments](../../react/nx-devkit/index#joinpathfragments) +- [moveFilesToNewDirectory](../../react/nx-devkit/index#movefilestonewdirectory) +- [names](../../react/nx-devkit/index#names) +- [normalizePath](../../react/nx-devkit/index#normalizepath) +- [offsetFromRoot](../../react/nx-devkit/index#offsetfromroot) +- [parseJson](../../react/nx-devkit/index#parsejson) +- [parseTargetString](../../react/nx-devkit/index#parsetargetstring) +- [readJson](../../react/nx-devkit/index#readjson) +- [readJsonFile](../../react/nx-devkit/index#readjsonfile) +- [readProjectConfiguration](../../react/nx-devkit/index#readprojectconfiguration) +- [readTargetOptions](../../react/nx-devkit/index#readtargetoptions) +- [readWorkspaceConfiguration](../../react/nx-devkit/index#readworkspaceconfiguration) +- [removeDependenciesFromPackageJson](../../react/nx-devkit/index#removedependenciesfrompackagejson) +- [removeProjectConfiguration](../../react/nx-devkit/index#removeprojectconfiguration) +- [runExecutor](../../react/nx-devkit/index#runexecutor) +- [serializeJson](../../react/nx-devkit/index#serializejson) +- [stripIndents](../../react/nx-devkit/index#stripindents) +- [stripJsonComments](../../react/nx-devkit/index#stripjsoncomments) +- [targetToTargetString](../../react/nx-devkit/index#targettotargetstring) +- [toJS](../../react/nx-devkit/index#tojs) +- [updateJson](../../react/nx-devkit/index#updatejson) +- [updateProjectConfiguration](../../react/nx-devkit/index#updateprojectconfiguration) +- [updateTsConfigsToJs](../../react/nx-devkit/index#updatetsconfigstojs) +- [updateWorkspaceConfiguration](../../react/nx-devkit/index#updateworkspaceconfiguration) +- [visitNotIgnoredFiles](../../react/nx-devkit/index#visitnotignoredfiles) +- [writeJson](../../react/nx-devkit/index#writejson) +- [writeJsonFile](../../react/nx-devkit/index#writejsonfile) + +## Enumerations + +### ChangeType + +• **ChangeType**: _object_ + +--- + +### DependencyType + +• **DependencyType**: _object_ + +Type of dependency between projects + +## Classes + +### ProjectGraphBuilder + +• **ProjectGraphBuilder**: _object_ + +Builder for adding nodes and dependencies to a [ProjectGraph](../../react/nx-devkit/index#projectgraph) + +## Interfaces + +### ExecutorContext + +• **ExecutorContext**: _object_ + +Context that is passed into an executor + +--- + +### FileChange + +• **FileChange**: _object_ + +Description of a file change in the Nx virtual file system/ + +--- + +### FileData + +• **FileData**: _object_ + +Some metadata about a file + +--- + +### ImplicitJsonSubsetDependency + +• **ImplicitJsonSubsetDependency**: _object_ + +#### Type parameters + +| Name | Default | +| :--- | :------------------ | +| `T` | `"*"` \| _string_[] | + +--- + +### JsonParseOptions + +• **JsonParseOptions**: _object_ + +--- + +### JsonSerializeOptions + +• **JsonSerializeOptions**: _object_ + +--- + +### NxAffectedConfig + +• **NxAffectedConfig**: _object_ + +--- + +### NxJsonConfiguration + +• **NxJsonConfiguration**: _object_ + +Nx.json configuration + +#### Type parameters + +| Name | Default | +| :--- | :------------------ | +| `T` | `"*"` \| _string_[] | + +--- + +### NxJsonProjectConfiguration + +• **NxJsonProjectConfiguration**: _object_ + +--- + +### NxPlugin + +• **NxPlugin**: _object_ + +A plugin for Nx + +--- + +### ProjectConfiguration + +• **ProjectConfiguration**: _object_ + +Project configuration + +--- + +### ProjectFileMap + +• **ProjectFileMap**: _object_ + +A list of files separated by the project they belong to + +--- + +### ProjectGraph + +• **ProjectGraph**: _object_ + +A Graph of projects in the workspace and dependencies between them + +#### Type parameters + +| Name | Default | +| :--- | :------ | +| `T` | _any_ | + +--- + +### ProjectGraphDependency + +• **ProjectGraphDependency**: _object_ + +A dependency between two projects + +--- + +### ProjectGraphNode + +• **ProjectGraphNode**: _object_ + +A node describing a project in a workspace + +#### Type parameters + +| Name | Default | +| :--- | :------ | +| `T` | _any_ | + +--- + +### ProjectGraphProcessorContext + +• **ProjectGraphProcessorContext**: _object_ + +Additional information to be used to process a project graph + +--- + +### StringDeletion + +• **StringDeletion**: _object_ + +--- + +### StringInsertion + +• **StringInsertion**: _object_ + +--- + +### Target + +• **Target**: _object_ + +--- + +### TargetConfiguration + +• **TargetConfiguration**: _object_ + +Target's configuration + +--- + +### TargetDependencyConfig + +• **TargetDependencyConfig**: _object_ + +--- + +### Tree + +• **Tree**: _object_ + +Virtual file system tree. + +--- + +### Workspace + +• **Workspace**: _object_ + +--- + +### WorkspaceJsonConfiguration + +• **WorkspaceJsonConfiguration**: _object_ + +Workspace configuration + +## Type aliases + +### Executor + +Ƭ **Executor**: (`options`: T, `context`: [_ExecutorContext_](../../react/nx-devkit/index#executorcontext)) => _Promise_<{ `success`: _boolean_ }\> \| _AsyncIterableIterator_<{ `success`: _boolean_ }\> + +Implementation of a target of a project + +#### Type parameters + +| Name | Default | +| :--- | :------ | +| `T` | _any_ | + +#### Type declaration + +▸ (`options`: T, `context`: [_ExecutorContext_](../../react/nx-devkit/index#executorcontext)): _Promise_<{ `success`: _boolean_ }\> \| _AsyncIterableIterator_<{ `success`: _boolean_ }\> + +#### Parameters + +| Name | Type | +| :-------- | :--------------------------------------------------------------- | +| `options` | T | +| `context` | [_ExecutorContext_](../../react/nx-devkit/index#executorcontext) | + +**Returns:** _Promise_<{ `success`: _boolean_ }\> \| _AsyncIterableIterator_<{ `success`: _boolean_ }\> + +--- + +### Generator + +Ƭ **Generator**: (`tree`: _any_, `schema`: T) => _void_ \| [_GeneratorCallback_](../../react/nx-devkit/index#generatorcallback) \| _Promise_ + +A function that schedules updates to the filesystem to be done atomically + +#### Type parameters + +| Name | Default | +| :--- | :-------- | +| `T` | _unknown_ | + +#### Type declaration + +▸ (`tree`: _any_, `schema`: T): _void_ \| [_GeneratorCallback_](../../react/nx-devkit/index#generatorcallback) \| _Promise_ + +#### Parameters + +| Name | Type | +| :------- | :---- | +| `tree` | _any_ | +| `schema` | T | + +**Returns:** _void_ \| [_GeneratorCallback_](../../react/nx-devkit/index#generatorcallback) \| _Promise_ + +--- + +### GeneratorCallback + +Ƭ **GeneratorCallback**: () => _void_ \| _Promise_ + +A callback function that is executed after changes are made to the file system + +#### Type declaration + +▸ (): _void_ \| _Promise_ + +**Returns:** _void_ \| _Promise_ + +--- + +### ImplicitDependencyEntry + +Ƭ **ImplicitDependencyEntry**: _object_ + +#### Type parameters + +| Name | Default | +| :--- | :------------------ | +| `T` | `"*"` \| _string_[] | + +#### Type declaration + +--- + +### PackageManager + +Ƭ **PackageManager**: `"yarn"` \| `"pnpm"` \| `"npm"` + +--- + +### ProjectType + +Ƭ **ProjectType**: `"library"` \| `"application"` + +Type of project supported + +--- + +### StringChange + +Ƭ **StringChange**: [_StringInsertion_](../../react/nx-devkit/index#stringinsertion) \| [_StringDeletion_](../../react/nx-devkit/index#stringdeletion) + +A change to be made to a string + +--- + +### WorkspaceConfiguration + +Ƭ **WorkspaceConfiguration**: _Omit_<[_WorkspaceJsonConfiguration_](../../react/nx-devkit/index#workspacejsonconfiguration), `"projects"`\> & _Omit_<[_NxJsonConfiguration_](../../react/nx-devkit/index#nxjsonconfiguration), `"projects"`\> + +## Variables + +### logger + +• `Const` **logger**: _object_ + +#### Type declaration + +| Name | Type | +| :------ | :-------------------------- | +| `debug` | (...`s`: _any_[]) => _void_ | +| `error` | (`s`: _any_) => _void_ | +| `fatal` | (...`s`: _any_[]) => _void_ | +| `info` | (`s`: _any_) => _void_ | +| `log` | (...`s`: _any_[]) => _void_ | +| `warn` | (`s`: _any_) => _void_ | + +## Functions + +### addDependenciesToPackageJson + +▸ **addDependenciesToPackageJson**(`host`: [_Tree_](../../react/nx-devkit/index#tree), `dependencies`: _Record_, `devDependencies`: _Record_, `packageJsonPath?`: _string_): [_GeneratorCallback_](../../react/nx-devkit/index#generatorcallback) + +Add Dependencies and Dev Dependencies to package.json + +For example, `addDependenciesToPackageJson(host, { react: 'latest' }, { jest: 'latest' })` +will add `react` and `jest` to the dependencies and devDependencies sections of package.json respectively + +#### Parameters + +| Name | Type | Default value | Description | +| :---------------- | :----------------------------------------- | :------------- | :---------------------------------------------------------------------- | +| `host` | [_Tree_](../../react/nx-devkit/index#tree) | - | Tree representing file system to modify | +| `dependencies` | _Record_ | - | Dependencies to be added to the dependencies section of package.json | +| `devDependencies` | _Record_ | - | Dependencies to be added to the devDependencies section of package.json | +| `packageJsonPath` | _string_ | 'package.json' | Path to package.json | + +**Returns:** [_GeneratorCallback_](../../react/nx-devkit/index#generatorcallback) + +Callback to install dependencies only if necessary. undefined is returned if changes are not necessary. + +--- + +### addProjectConfiguration + +▸ **addProjectConfiguration**(`host`: [_Tree_](../../react/nx-devkit/index#tree), `projectName`: _string_, `projectConfiguration`: [_ProjectConfiguration_](../../react/nx-devkit/index#projectconfiguration) & [_NxJsonProjectConfiguration_](../../react/nx-devkit/index#nxjsonprojectconfiguration)): _void_ + +Adds project configuration to the Nx workspace. + +The project configuration is stored in workspace.json and nx.json. The utility will update +both files. + +#### Parameters + +| Name | Type | Description | +| :--------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :---------------------------------------------------------------------- | +| `host` | [_Tree_](../../react/nx-devkit/index#tree) | the file system tree | +| `projectName` | _string_ | unique name. Often directories are part of the name (e.g., mydir-mylib) | +| `projectConfiguration` | [_ProjectConfiguration_](../../react/nx-devkit/index#projectconfiguration) & [_NxJsonProjectConfiguration_](../../react/nx-devkit/index#nxjsonprojectconfiguration) | project configuration | + +**Returns:** _void_ + +--- + +### applyChangesToString + +▸ **applyChangesToString**(`text`: _string_, `changes`: [_StringChange_](../../react/nx-devkit/index#stringchange)[]): _string_ + +Applies a list of changes to a string's original value. + +This is useful when working with ASTs. + +For Example, to rename a property in a method's options: + +``` +const code = `bootstrap({ + target: document.querySelector('#app') +})`; + +const indexOfPropertyName = 13; // Usually determined by analyzing an AST. +const updatedCode = applyChangesToString(code, [ + { + type: ChangeType.Insert, + index: indexOfPropertyName, + text: 'element' + }, + { + type: ChangeType.Delete, + start: indexOfPropertyName, + length: 6 + }, +]); + +bootstrap({ + element: document.querySelector('#app') +}); +``` + +#### Parameters + +| Name | Type | +| :-------- | :----------------------------------------------------------- | +| `text` | _string_ | +| `changes` | [_StringChange_](../../react/nx-devkit/index#stringchange)[] | + +**Returns:** _string_ + +--- + +### convertNxExecutor + +▸ **convertNxExecutor**(`executor`: [_Executor_](../../react/nx-devkit/index#executor)): _any_ + +Convert an Nx Executor into an Angular Devkit Builder + +Use this to expose a compatible Angular Builder + +#### Parameters + +| Name | Type | +| :--------- | :------------------------------------------------- | +| `executor` | [_Executor_](../../react/nx-devkit/index#executor) | + +**Returns:** _any_ + +--- + +### convertNxGenerator + +▸ **convertNxGenerator**(`generator`: [_Generator_](../../react/nx-devkit/index#generator)): _function_ + +Convert an Nx Generator into an Angular Devkit Schematic + +#### Type parameters + +| Name | Default | +| :--- | :------ | +| `T` | _any_ | + +#### Parameters + +| Name | Type | +| :---------- | :------------------------------------------------------- | +| `generator` | [_Generator_](../../react/nx-devkit/index#generator) | + +**Returns:** (`options`: T) => (`tree`: _any_, `context`: _any_) => _Promise_ + +--- + +### formatFiles + +▸ **formatFiles**(`host`: [_Tree_](../../react/nx-devkit/index#tree)): _Promise_ + +Formats all the created or updated files using Prettier + +#### Parameters + +| Name | Type | Description | +| :----- | :----------------------------------------- | :------------------- | +| `host` | [_Tree_](../../react/nx-devkit/index#tree) | the file system tree | + +**Returns:** _Promise_ + +--- + +### generateFiles + +▸ **generateFiles**(`host`: [_Tree_](../../react/nx-devkit/index#tree), `srcFolder`: _string_, `target`: _string_, `substitutions`: { [k: string]: _any_; }): _void_ + +Generates a folder of files based on provided templates. + +While doing so it performs two substitutions: + +- Substitutes segments of file names surrounded by \_\_ +- Uses ejs to substitute values in templates + +#### Parameters + +| Name | Type | Description | +| :-------------- | :----------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `host` | [_Tree_](../../react/nx-devkit/index#tree) | the file system tree | +| `srcFolder` | _string_ | the source folder of files (absolute path) | +| `target` | _string_ | the target folder (relative to the host root) | +| `substitutions` | _object_ | an object of key-value pairs Examples: `typescript generateFiles(host, path.join(__dirname , 'files'), './tools/scripts', {tmpl: '', name: 'myscript'}) ` This command will take all the files from the `files` directory next to the place where the command is invoked from. It will replace all `__tmpl__` with '' and all `__name__` with 'myscript' in the file names, and will replace all `<%= name %>` with `myscript` in the files themselves. `tmpl: ''` is a common pattern. With it you can name files like this: `index.ts__tmpl__`, so your editor doesn't get confused about incorrect TypeScript files. | + +**Returns:** _void_ + +--- + +### getPackageManagerCommand + +▸ **getPackageManagerCommand**(`packageManager?`: [_PackageManager_](../../react/nx-devkit/index#packagemanager)): _object_ + +Returns commands for the package manager used in the workspace. +By default, the package manager is derived based on the lock file, +but it can also be passed in explicitly. + +Example: + +```javascript +execSync(`${getPackageManagerCommand().addDev} my-dev-package`); +``` + +#### Parameters + +| Name | Type | +| :--------------- | :------------------------------------------------------------- | +| `packageManager` | [_PackageManager_](../../react/nx-devkit/index#packagemanager) | + +**Returns:** _object_ + +| Name | Type | +| :-------- | :------------------------------------------------- | +| `add` | _string_ | +| `addDev` | _string_ | +| `exec` | _string_ | +| `install` | _string_ | +| `list` | _string_ | +| `rm` | _string_ | +| `run` | (`script`: _string_, `args`: _string_) => _string_ | + +--- + +### getProjects + +▸ **getProjects**(`host`: [_Tree_](../../react/nx-devkit/index#tree)): _Map_ + +Get a map of all projects in a workspace. + +Use [readProjectConfiguration](../../react/nx-devkit/index#readprojectconfiguration) if only one project is needed. + +#### Parameters + +| Name | Type | +| :----- | :----------------------------------------- | +| `host` | [_Tree_](../../react/nx-devkit/index#tree) | + +**Returns:** _Map_ + +--- + +### getWorkspaceLayout + +▸ **getWorkspaceLayout**(`host`: [_Tree_](../../react/nx-devkit/index#tree)): _object_ + +Returns workspace defaults. It includes defaults folders for apps and libs, +and the default scope. + +Example: + +`{ appsDir: 'apps', libsDir: 'libs', npmScope: 'myorg' }` + +#### Parameters + +| Name | Type | Description | +| :----- | :----------------------------------------- | :--------------- | +| `host` | [_Tree_](../../react/nx-devkit/index#tree) | file system tree | + +**Returns:** _object_ + +| Name | Type | +| :--------- | :------- | +| `appsDir` | _string_ | +| `libsDir` | _string_ | +| `npmScope` | _string_ | + +--- + +### getWorkspacePath + +▸ **getWorkspacePath**(`host`: [_Tree_](../../react/nx-devkit/index#tree)): _string_ + +#### Parameters + +| Name | Type | +| :----- | :----------------------------------------- | +| `host` | [_Tree_](../../react/nx-devkit/index#tree) | + +**Returns:** _string_ + +--- + +### installPackagesTask + +▸ **installPackagesTask**(`host`: [_Tree_](../../react/nx-devkit/index#tree), `alwaysRun?`: _boolean_, `cwd?`: _string_, `packageManager?`: [_PackageManager_](../../react/nx-devkit/index#packagemanager)): _void_ + +Runs `npm install` or `yarn install`. It will skip running the install if +`package.json` hasn't changed at all or it hasn't changed since the last invocation. + +#### Parameters + +| Name | Type | Default value | Description | +| :--------------- | :------------------------------------------------------------- | :------------ | :------------------------------------------------------------ | +| `host` | [_Tree_](../../react/nx-devkit/index#tree) | - | the file system tree | +| `alwaysRun` | _boolean_ | false | always run the command even if `package.json` hasn't changed. | +| `cwd` | _string_ | '' | - | +| `packageManager` | [_PackageManager_](../../react/nx-devkit/index#packagemanager) | - | - | + +**Returns:** _void_ + +--- + +### joinPathFragments + +▸ **joinPathFragments**(...`fragments`: _string_[]): _string_ + +Normalized path fragments and joins them + +#### Parameters + +| Name | Type | +| :------------- | :--------- | +| `...fragments` | _string_[] | + +**Returns:** _string_ + +--- + +### moveFilesToNewDirectory + +▸ **moveFilesToNewDirectory**(`host`: [_Tree_](../../react/nx-devkit/index#tree), `oldDir`: _string_, `newDir`: _string_): _void_ + +#### Parameters + +| Name | Type | +| :------- | :----------------------------------------- | +| `host` | [_Tree_](../../react/nx-devkit/index#tree) | +| `oldDir` | _string_ | +| `newDir` | _string_ | + +**Returns:** _void_ + +--- + +### names + +▸ **names**(`name`: _string_): _object_ + +Util function to generate different strings based off the provided name. + +Examples: + +```typescript +names('my-name'); // {name: 'my-name', className: 'MyName', propertyName: 'myName', constantName: 'MY_NAME', fileName: 'my-name'} +names('myName'); // {name: 'my-name', className: 'MyName', propertyName: 'myName', constantName: 'MY_NAME', fileName: 'my-name'} +``` + +#### Parameters + +| Name | Type | +| :----- | :------- | +| `name` | _string_ | + +**Returns:** _object_ + +| Name | Type | +| :------------- | :------- | +| `className` | _string_ | +| `constantName` | _string_ | +| `fileName` | _string_ | +| `name` | _string_ | +| `propertyName` | _string_ | + +--- + +### normalizePath + +▸ **normalizePath**(`osSpecificPath`: _string_): _string_ + +Coverts an os specific path to a unix style path + +#### Parameters + +| Name | Type | +| :--------------- | :------- | +| `osSpecificPath` | _string_ | + +**Returns:** _string_ + +--- + +### offsetFromRoot + +▸ **offsetFromRoot**(`fullPathToDir`: _string_): _string_ + +Calculates an offset from the root of the workspace, which is useful for +constructing relative URLs. + +Examples: + +```typescript +offsetFromRoot('apps/mydir/myapp/'); // returns "../../../" +``` + +#### Parameters + +| Name | Type | Description | +| :-------------- | :------- | :------------- | +| `fullPathToDir` | _string_ | directory path | + +**Returns:** _string_ + +--- + +### parseJson + +▸ **parseJson**(`input`: _string_, `options?`: [_JsonParseOptions_](../../react/nx-devkit/index#jsonparseoptions)): T + +Parses the given JSON string and returns the object the JSON content represents. +By default javascript-style comments are allowed. + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------ | +| `T` | _object_ | _any_ | + +#### Parameters + +| Name | Type | Description | +| :--------- | :----------------------------------------------------------------- | :--------------------- | +| `input` | _string_ | JSON content as string | +| `options?` | [_JsonParseOptions_](../../react/nx-devkit/index#jsonparseoptions) | JSON parse options | + +**Returns:** T + +Object the JSON content represents + +--- + +### parseTargetString + +▸ **parseTargetString**(`targetString`: _string_): [_Target_](../../react/nx-devkit/index#target) + +Parses a target string into {project, target, configuration} + +#### Parameters + +| Name | Type | Description | +| :------------- | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `targetString` | _string_ | target reference Examples: `typescript parseTargetString("proj:test") // returns { project: "proj", target: "test" } parseTargetString("proj:test:production") // returns { project: "proj", target: "test", configuration: "production" } ` | + +**Returns:** [_Target_](../../react/nx-devkit/index#target) + +--- + +### readJson + +▸ **readJson**(`host`: [_Tree_](../../react/nx-devkit/index#tree), `path`: _string_, `options?`: [_JsonParseOptions_](../../react/nx-devkit/index#jsonparseoptions)): T + +Reads a document for host, removes all comments and parses JSON. + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------ | +| `T` | _object_ | _any_ | + +#### Parameters + +| Name | Type | Description | +| :--------- | :----------------------------------------------------------------- | :-------------------------- | +| `host` | [_Tree_](../../react/nx-devkit/index#tree) | file system tree | +| `path` | _string_ | file path | +| `options?` | [_JsonParseOptions_](../../react/nx-devkit/index#jsonparseoptions) | Optional JSON Parse Options | + +**Returns:** T + +--- + +### readJsonFile + +▸ **readJsonFile**(`path`: _string_, `options?`: JsonReadOptions): T + +Reads a JSON file and returns the object the JSON content represents. + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------ | +| `T` | _object_ | _any_ | + +#### Parameters + +| Name | Type | Description | +| :--------- | :-------------- | :----------------- | +| `path` | _string_ | A path to a file. | +| `options?` | JsonReadOptions | JSON parse options | + +**Returns:** T + +Object the JSON content of the file represents + +--- + +### readProjectConfiguration + +▸ **readProjectConfiguration**(`host`: [_Tree_](../../react/nx-devkit/index#tree), `projectName`: _string_): [_ProjectConfiguration_](../../react/nx-devkit/index#projectconfiguration) & [_NxJsonProjectConfiguration_](../../react/nx-devkit/index#nxjsonprojectconfiguration) + +Reads a project configuration. + +The project configuration is stored in workspace.json and nx.json. The utility will read +both files. + +#### Parameters + +| Name | Type | Description | +| :------------ | :----------------------------------------- | :---------------------------------------------------------------------- | +| `host` | [_Tree_](../../react/nx-devkit/index#tree) | the file system tree | +| `projectName` | _string_ | unique name. Often directories are part of the name (e.g., mydir-mylib) | + +**Returns:** [_ProjectConfiguration_](../../react/nx-devkit/index#projectconfiguration) & [_NxJsonProjectConfiguration_](../../react/nx-devkit/index#nxjsonprojectconfiguration) + +--- + +### readTargetOptions + +▸ **readTargetOptions**(`__namedParameters`: [_Target_](../../react/nx-devkit/index#target), `context`: [_ExecutorContext_](../../react/nx-devkit/index#executorcontext)): T + +Reads and combines options for a given target. + +Works as if you invoked the target yourself without passing any command lint overrides. + +#### Type parameters + +| Name | Default | +| :--- | :------ | +| `T` | _any_ | + +#### Parameters + +| Name | Type | +| :------------------ | :--------------------------------------------------------------- | +| `__namedParameters` | [_Target_](../../react/nx-devkit/index#target) | +| `context` | [_ExecutorContext_](../../react/nx-devkit/index#executorcontext) | + +**Returns:** T + +--- + +### readWorkspaceConfiguration + +▸ **readWorkspaceConfiguration**(`host`: [_Tree_](../../react/nx-devkit/index#tree)): [_WorkspaceConfiguration_](../../react/nx-devkit/index#workspaceconfiguration) + +Read general workspace configuration such as the default project or cli settings + +This does _not_ provide projects configuration, use [readProjectConfiguration](../../react/nx-devkit/index#readprojectconfiguration) instead. + +#### Parameters + +| Name | Type | +| :----- | :----------------------------------------- | +| `host` | [_Tree_](../../react/nx-devkit/index#tree) | + +**Returns:** [_WorkspaceConfiguration_](../../react/nx-devkit/index#workspaceconfiguration) + +--- + +### removeDependenciesFromPackageJson + +▸ **removeDependenciesFromPackageJson**(`host`: [_Tree_](../../react/nx-devkit/index#tree), `dependencies`: _string_[], `devDependencies`: _string_[], `packageJsonPath?`: _string_): [_GeneratorCallback_](../../react/nx-devkit/index#generatorcallback) + +Remove Dependencies and Dev Dependencies from package.json + +For example, `removeDependenciesFromPackageJson(host, ['react'], ['jest'])` +will remove `react` and `jest` from the dependencies and devDependencies sections of package.json respectively + +#### Parameters + +| Name | Type | Default value | Description | +| :---------------- | :----------------------------------------- | :------------- | :-------------------------------------------------------------------------- | +| `host` | [_Tree_](../../react/nx-devkit/index#tree) | - | - | +| `dependencies` | _string_[] | - | Dependencies to be removed from the dependencies section of package.json | +| `devDependencies` | _string_[] | - | Dependencies to be removed from the devDependencies section of package.json | +| `packageJsonPath` | _string_ | 'package.json' | - | + +**Returns:** [_GeneratorCallback_](../../react/nx-devkit/index#generatorcallback) + +Callback to uninstall dependencies only if necessary. undefined is returned if changes are not necessary. + +--- + +### removeProjectConfiguration + +▸ **removeProjectConfiguration**(`host`: [_Tree_](../../react/nx-devkit/index#tree), `projectName`: _string_): _void_ + +Removes the configuration of an existing project. + +The project configuration is stored in workspace.json and nx.json. +The utility will update both files. + +#### Parameters + +| Name | Type | +| :------------ | :----------------------------------------- | +| `host` | [_Tree_](../../react/nx-devkit/index#tree) | +| `projectName` | _string_ | + +**Returns:** _void_ + +--- + +### runExecutor + +▸ **runExecutor**(`targetDescription`: { `configuration?`: _string_ ; `project`: _string_ ; `target`: _string_ }, `options`: { [k: string]: _any_; }, `context`: [_ExecutorContext_](../../react/nx-devkit/index#executorcontext)): _Promise_\> + +Loads and invokes executor. + +This is analogous to invoking executor from the terminal, with the exception +that the params aren't parsed from the string, but instead provided parsed already. + +Apart from that, it works the same way: + +- it will load the workspace configuration +- it will resolve the target +- it will load the executor and the schema +- it will load the options for the appropriate configuration +- it will run the validations and will set the default +- and, of course, it will invoke the executor + +Example: + +```typescript +for await (const s of await runExecutor( + { project: 'myproj', target: 'serve' }, + { watch: true }, + context +)) { + // s.success +} +``` + +Note that the return value is a promise of an iterator, so you need to await before iterating over it. + +#### Type parameters + +| Name | Type | +| :---------- | :-------- | +| `T` | _object_ | +| `T.success` | _boolean_ | + +#### Parameters + +| Name | Type | +| :--------------------------------- | :--------------------------------------------------------------- | +| `targetDescription` | _object_ | +| `targetDescription.configuration?` | _string_ | +| `targetDescription.project` | _string_ | +| `targetDescription.target` | _string_ | +| `options` | _object_ | +| `context` | [_ExecutorContext_](../../react/nx-devkit/index#executorcontext) | + +**Returns:** _Promise_\> + +--- + +### serializeJson + +▸ **serializeJson**(`input`: T, `options?`: [_JsonSerializeOptions_](../../react/nx-devkit/index#jsonserializeoptions)): _string_ + +Serializes the given data to a JSON string. +By default the JSON string is formatted with a 2 space intendation to be easy readable. + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------- | +| `T` | _object_ | _object_ | + +#### Parameters + +| Name | Type | Description | +| :--------- | :------------------------------------------------------------------------- | :---------------------------------------- | +| `input` | T | Object which should be serialized to JSON | +| `options?` | [_JsonSerializeOptions_](../../react/nx-devkit/index#jsonserializeoptions) | JSON serialize options | + +**Returns:** _string_ + +the formatted JSON representation of the object + +--- + +### stripIndents + +▸ **stripIndents**(`strings`: TemplateStringsArray, ...`values`: _any_[]): _string_ + +Removes indents, which is useful for printing warning and messages. + +Example: + +```typescript +stripIndents` + Options: + - option1 + - option2 +`; +``` + +#### Parameters + +| Name | Type | +| :---------- | :------------------- | +| `strings` | TemplateStringsArray | +| `...values` | _any_[] | + +**Returns:** _string_ + +--- + +### stripJsonComments + +▸ `Const` **stripJsonComments**(`text`: _string_, `replaceCh?`: _string_): _string_ + +Takes JSON with JavaScript-style comments and remove +them. Optionally replaces every none-newline character +of comments with a replaceCharacter + +#### Parameters + +| Name | Type | +| :----------- | :------- | +| `text` | _string_ | +| `replaceCh?` | _string_ | + +**Returns:** _string_ + +--- + +### targetToTargetString + +▸ **targetToTargetString**(`__namedParameters`: [_Target_](../../react/nx-devkit/index#target)): _string_ + +Returns a string in the format "project:target[:configuration]" for the target + +#### Parameters + +| Name | Type | +| :------------------ | :--------------------------------------------- | +| `__namedParameters` | [_Target_](../../react/nx-devkit/index#target) | + +**Returns:** _string_ + +--- + +### toJS + +▸ **toJS**(`tree`: [_Tree_](../../react/nx-devkit/index#tree)): _void_ + +Rename and transpile any new typescript files created to javascript files + +#### Parameters + +| Name | Type | +| :----- | :----------------------------------------- | +| `tree` | [_Tree_](../../react/nx-devkit/index#tree) | + +**Returns:** _void_ + +--- + +### updateJson + +▸ **updateJson**(`host`: [_Tree_](../../react/nx-devkit/index#tree), `path`: _string_, `updater`: (`value`: T) => U, `options?`: [_JsonParseOptions_](../../react/nx-devkit/index#jsonparseoptions) & [_JsonSerializeOptions_](../../react/nx-devkit/index#jsonserializeoptions)): _void_ + +Updates a JSON value to the file system tree + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------ | +| `T` | _object_ | _any_ | +| `U` | _object_ | T | + +#### Parameters + +| Name | Type | Description | +| :--------- | :---------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------- | +| `host` | [_Tree_](../../react/nx-devkit/index#tree) | File system tree | +| `path` | _string_ | Path of JSON file in the Tree | +| `updater` | (`value`: T) => U | Function that maps the current value of a JSON document to a new value to be written to the document | +| `options?` | [_JsonParseOptions_](../../react/nx-devkit/index#jsonparseoptions) & [_JsonSerializeOptions_](../../react/nx-devkit/index#jsonserializeoptions) | Optional JSON Parse and Serialize Options | + +**Returns:** _void_ + +--- + +### updateProjectConfiguration + +▸ **updateProjectConfiguration**(`host`: [_Tree_](../../react/nx-devkit/index#tree), `projectName`: _string_, `projectConfiguration`: [_ProjectConfiguration_](../../react/nx-devkit/index#projectconfiguration) & [_NxJsonProjectConfiguration_](../../react/nx-devkit/index#nxjsonprojectconfiguration)): _void_ + +Updates the configuration of an existing project. + +The project configuration is stored in workspace.json and nx.json. The utility will update +both files. + +#### Parameters + +| Name | Type | Description | +| :--------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :---------------------------------------------------------------------- | +| `host` | [_Tree_](../../react/nx-devkit/index#tree) | the file system tree | +| `projectName` | _string_ | unique name. Often directories are part of the name (e.g., mydir-mylib) | +| `projectConfiguration` | [_ProjectConfiguration_](../../react/nx-devkit/index#projectconfiguration) & [_NxJsonProjectConfiguration_](../../react/nx-devkit/index#nxjsonprojectconfiguration) | project configuration | + +**Returns:** _void_ + +--- + +### updateTsConfigsToJs + +▸ **updateTsConfigsToJs**(`host`: [_Tree_](../../react/nx-devkit/index#tree), `options`: { `projectRoot`: _string_ }): _void_ + +#### Parameters + +| Name | Type | +| :-------------------- | :----------------------------------------- | +| `host` | [_Tree_](../../react/nx-devkit/index#tree) | +| `options` | _object_ | +| `options.projectRoot` | _string_ | + +**Returns:** _void_ + +--- + +### updateWorkspaceConfiguration + +▸ **updateWorkspaceConfiguration**(`host`: [_Tree_](../../react/nx-devkit/index#tree), `workspaceConfig`: [_WorkspaceConfiguration_](../../react/nx-devkit/index#workspaceconfiguration)): _void_ + +Update general workspace configuration such as the default project or cli settings. + +This does _not_ update projects configuration, use [updateProjectConfiguration](../../react/nx-devkit/index#updateprojectconfiguration) or [addProjectConfiguration](../../react/nx-devkit/index#addprojectconfiguration) instead. + +#### Parameters + +| Name | Type | +| :---------------- | :----------------------------------------------------------------------------- | +| `host` | [_Tree_](../../react/nx-devkit/index#tree) | +| `workspaceConfig` | [_WorkspaceConfiguration_](../../react/nx-devkit/index#workspaceconfiguration) | + +**Returns:** _void_ + +--- + +### visitNotIgnoredFiles + +▸ **visitNotIgnoredFiles**(`tree`: [_Tree_](../../react/nx-devkit/index#tree), `dirPath?`: _string_, `visitor`: (`path`: _string_) => _void_): _void_ + +Utility to act on all files in a tree that are not ignored by git. + +#### Parameters + +| Name | Type | +| :-------- | :----------------------------------------- | +| `tree` | [_Tree_](../../react/nx-devkit/index#tree) | +| `dirPath` | _string_ | +| `visitor` | (`path`: _string_) => _void_ | + +**Returns:** _void_ + +--- + +### writeJson + +▸ **writeJson**(`host`: [_Tree_](../../react/nx-devkit/index#tree), `path`: _string_, `value`: T, `options?`: [_JsonSerializeOptions_](../../react/nx-devkit/index#jsonserializeoptions)): _void_ + +Writes a JSON value to the file system tree + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------- | +| `T` | _object_ | _object_ | + +#### Parameters + +| Name | Type | Description | +| :--------- | :------------------------------------------------------------------------- | :------------------------------ | +| `host` | [_Tree_](../../react/nx-devkit/index#tree) | File system tree | +| `path` | _string_ | Path of JSON file in the Tree | +| `value` | T | Serializable value to write | +| `options?` | [_JsonSerializeOptions_](../../react/nx-devkit/index#jsonserializeoptions) | Optional JSON Serialize Options | + +**Returns:** _void_ + +--- + +### writeJsonFile + +▸ **writeJsonFile**(`path`: _string_, `data`: T, `options?`: JsonWriteOptions): _void_ + +Serializes the given data to JSON and writes it to a file. + +#### Type parameters + +| Name | Type | Default | +| :--- | :------- | :------- | +| `T` | _object_ | _object_ | + +#### Parameters + +| Name | Type | Description | +| :--------- | :--------------- | :-------------------------------------------------------------- | +| `path` | _string_ | A path to a file. | +| `data` | T | data which should be serialized to JSON and written to the file | +| `options?` | JsonWriteOptions | JSON serialize options | + +**Returns:** _void_ diff --git a/docs/react/api-nx-devkit/ngcli_adapter.md b/docs/react/api-nx-devkit/ngcli_adapter.md new file mode 100644 index 0000000000..10b73cc185 --- /dev/null +++ b/docs/react/api-nx-devkit/ngcli_adapter.md @@ -0,0 +1,98 @@ +# Module: ngcli-adapter + +## Table of contents + +### Classes + +- [NxScopedHost](../../react/nx-devkit/ngcli_adapter#nxscopedhost) + +### Functions + +- [mockSchematicsForTesting](../../react/nx-devkit/ngcli_adapter#mockschematicsfortesting) +- [overrideCollectionResolutionForTesting](../../react/nx-devkit/ngcli_adapter#overridecollectionresolutionfortesting) +- [wrapAngularDevkitSchematic](../../react/nx-devkit/ngcli_adapter#wrapangulardevkitschematic) + +## Classes + +### NxScopedHost + +• **NxScopedHost**: _object_ + +## Functions + +### mockSchematicsForTesting + +▸ **mockSchematicsForTesting**(`schematics`: { [name: string]: (`host`: [_Tree_](../../react/nx-devkit/index#tree), `generatorOptions`: { [k: string]: _any_; }) => _Promise_; }): _void_ + +If you have an Nx Devkit generator invoking the wrapped Angular Devkit schematic, +and you don't want the Angular Devkit schematic to run, you can mock it up using this function. + +Unfortunately, there are some edge cases in the Nx-Angular devkit integration that +can be seen in the unit tests context. This function is useful for handling that as well. + +In this case, you can mock it up. + +Example: + +``` + mockSchematicsForTesting({ + 'mycollection:myschematic': (tree, params) => { + tree.write('README.md'); + } + }); + +``` + +#### Parameters + +| Name | Type | +| :----------- | :------- | +| `schematics` | _object_ | + +**Returns:** _void_ + +--- + +### overrideCollectionResolutionForTesting + +▸ **overrideCollectionResolutionForTesting**(`collections`: { [name: string]: _string_; }): _void_ + +By default, Angular Devkit schematic collections will be resolved using the Node resolution. +This doesn't work if you are testing schematics that refer to other schematics in the +same repo. + +This function can can be used to override the resolution behaviour. + +Example: + +``` + overrideCollectionResolutionForTesting({ + '@nrwl/workspace': path.join(__dirname, '../../../../workspace/collection.json'), + '@nrwl/angular': path.join(__dirname, '../../../../angular/collection.json'), + '@nrwl/linter': path.join(__dirname, '../../../../linter/collection.json') + }); + +``` + +#### Parameters + +| Name | Type | +| :------------ | :------- | +| `collections` | _object_ | + +**Returns:** _void_ + +--- + +### wrapAngularDevkitSchematic + +▸ **wrapAngularDevkitSchematic**(`collectionName`: _string_, `generatorName`: _string_): _function_ + +#### Parameters + +| Name | Type | +| :--------------- | :------- | +| `collectionName` | _string_ | +| `generatorName` | _string_ | + +**Returns:** (`host`: [_Tree_](../../react/nx-devkit/index#tree), `generatorOptions`: { [k: string]: _any_; }) => _Promise_ diff --git a/jest.config.js b/jest.config.js index 89598538cc..d75c071a15 100644 --- a/jest.config.js +++ b/jest.config.js @@ -27,5 +27,6 @@ module.exports = { '/nx-dev/data-access-menu', '/nx-dev/feature-search', '/nx-dev/feature-analytics', + '/typedoc-theme', ], }; diff --git a/nx-dev/data-access-documents/src/lib/menu.utils.ts b/nx-dev/data-access-documents/src/lib/menu.utils.ts index ddf0a15ed2..dbef117bd8 100644 --- a/nx-dev/data-access-documents/src/lib/menu.utils.ts +++ b/nx-dev/data-access-documents/src/lib/menu.utils.ts @@ -92,6 +92,7 @@ export function getApiSection(items: MenuItem[]): MenuSection { m.id === 'next' || m.id === 'gatsby' || m.id === 'nx-plugin' || + m.id === 'nx-devkit' || m.id === 'cli' ), }; diff --git a/nx.json b/nx.json index 03b415dc8f..8136d4c8e0 100644 --- a/nx.json +++ b/nx.json @@ -150,6 +150,9 @@ }, "nx-dev-feature-analytics": { "tags": ["scope:nx-dev", "type:feature"] + }, + "typedoc-theme": { + "tags": [] } } } diff --git a/package.json b/package.json index 953ad868b1..55a9ded7ec 100644 --- a/package.json +++ b/package.json @@ -227,6 +227,8 @@ "tslib": "^2.0.0", "tslint": "6.1.3", "tslint-to-eslint-config": "^2.4.0", + "typedoc": "^0.20.36", + "typedoc-plugin-markdown": "^3.8.2", "typescript": "4.2.4", "url-loader": "^3.0.0", "verdaccio": "^5.0.4", diff --git a/scripts/documentation/documentation.ts b/scripts/documentation/documentation.ts index aceca0e2fb..9a7dcd312b 100644 --- a/scripts/documentation/documentation.ts +++ b/scripts/documentation/documentation.ts @@ -1,5 +1,6 @@ import * as chalk from 'chalk'; -import { execSync } from 'child_process'; +import { execSync, exec } from 'child_process'; +import { Frameworks } from './frameworks'; import { generateCLIDocumentation } from './generate-cli-data'; import { generateExecutorsDocumentation } from './generate-executors-data'; @@ -8,6 +9,16 @@ import { generateGeneratorsDocumentation } from './generate-generators-data'; async function generate() { console.log(`${chalk.blue('i')} Generating Documentation`); + execSync('nx build typedoc-theme'); + Frameworks.forEach((framework) => { + execSync( + `rm -rf docs/${framework}/api-nx-devkit && npx typedoc packages/devkit/index.ts packages/devkit/ngcli-adapter.ts --tsconfig packages/devkit/tsconfig.lib.json --out ./docs/${framework}/api-nx-devkit --hideBreadcrumbs true --disableSources --publicPath ../../${framework}/nx-devkit/ --theme dist/typedoc-theme/src/lib` + ); + execSync( + `rm -rf docs/${framework}/api-nx-devkit/modules.md docs/${framework}/api-nx-devkit/README.md` + ); + execSync(`nx format`); + }); await generateGeneratorsDocumentation(); await generateExecutorsDocumentation(); await generateCLIDocumentation(); diff --git a/tsconfig.base.json b/tsconfig.base.json index ade489a8bf..2f30137c42 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -55,7 +55,8 @@ "@nrwl/nx-dev/feature-search": ["./nx-dev/feature-search/src/index.ts"], "@nrwl/nx-dev/feature-analytics": [ "./nx-dev/feature-analytics/src/index.ts" - ] + ], + "@nrwl/typedoc-theme": ["/typedoc-theme/src/index.ts"] } } } diff --git a/typedoc-theme/.babelrc b/typedoc-theme/.babelrc new file mode 100644 index 0000000000..cf7ddd99c6 --- /dev/null +++ b/typedoc-theme/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": [["@nrwl/web/babel", { "useBuiltIns": "usage" }]] +} diff --git a/typedoc-theme/.eslintrc.json b/typedoc-theme/.eslintrc.json new file mode 100644 index 0000000000..75d3588cb0 --- /dev/null +++ b/typedoc-theme/.eslintrc.json @@ -0,0 +1,21 @@ +{ + "extends": ["../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "parserOptions": { + "project": ["./typedoc-theme/tsconfig.*?.json"] + }, + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/typedoc-theme/README.md b/typedoc-theme/README.md new file mode 100644 index 0000000000..07b76f41ab --- /dev/null +++ b/typedoc-theme/README.md @@ -0,0 +1,7 @@ +# typedoc-theme + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test typedoc-theme` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/typedoc-theme/jest.config.js b/typedoc-theme/jest.config.js new file mode 100644 index 0000000000..958a3277b0 --- /dev/null +++ b/typedoc-theme/jest.config.js @@ -0,0 +1,15 @@ +module.exports = { + displayName: 'typedoc-theme', + preset: '../jest.preset.js', + globals: { + 'ts-jest': { + tsconfig: '/tsconfig.spec.json', + }, + }, + transform: { + '^.+\\.[tj]sx?$': 'ts-jest', + }, + resolver: '../scripts/patched-jest-resolver.js', + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], + coverageDirectory: '../coverage/typedoc-theme', +}; diff --git a/typedoc-theme/package.json b/typedoc-theme/package.json new file mode 100644 index 0000000000..9240fecc51 --- /dev/null +++ b/typedoc-theme/package.json @@ -0,0 +1,4 @@ +{ + "name": "@nrwl/typedoc-theme", + "version": "0.0.1" +} diff --git a/typedoc-theme/src/index.ts b/typedoc-theme/src/index.ts new file mode 100644 index 0000000000..0aba4424b2 --- /dev/null +++ b/typedoc-theme/src/index.ts @@ -0,0 +1,4 @@ +import NrwlMarkdownTheme from './lib/theme'; + +export * from './lib/theme'; +export default NrwlMarkdownTheme; diff --git a/typedoc-theme/src/lib/theme.ts b/typedoc-theme/src/lib/theme.ts new file mode 100644 index 0000000000..210f605f59 --- /dev/null +++ b/typedoc-theme/src/lib/theme.ts @@ -0,0 +1,43 @@ +import MarkdownTheme from 'typedoc-plugin-markdown/dist/theme'; +import { ReflectionKind } from 'typedoc/dist/lib/models'; + +/** + * The MarkdownTheme is based on TypeDoc's DefaultTheme @see https://github.com/TypeStrong/typedoc/blob/master/src/lib/output/themes/DefaultTheme.ts. + * - html specific components are removed from the renderer + * - markdown specefic components have been added + */ + +export default class NrwlMarkdownTheme extends MarkdownTheme { + constructor(renderer, basePath) { + super(renderer, basePath); + + const relativeURL = MarkdownTheme.HANDLEBARS.helpers.relativeURL; + NrwlMarkdownTheme.HANDLEBARS.helpers.relativeURL = function (url: string) { + return relativeURL(url.replace('.md', '')); + }; + } + + get mappings() { + return [ + { + kind: [ReflectionKind.Module], + isLeaf: true, + directory: '.', + template: 'reflection.hbs', + }, + ]; + } + + /** + * Returns the full url of a given mapping and reflection + * @param mapping + * @param reflection + */ + toUrl(mapping, reflection) { + return ( + (mapping.directory === '.' ? '' : mapping.directory + '/') + + this.getUrl(reflection) + + '.md' + ); + } +} diff --git a/typedoc-theme/tsconfig.json b/typedoc-theme/tsconfig.json new file mode 100644 index 0000000000..e236e0f405 --- /dev/null +++ b/typedoc-theme/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../tsconfig.base.json", + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/typedoc-theme/tsconfig.lib.json b/typedoc-theme/tsconfig.lib.json new file mode 100644 index 0000000000..f079f568fc --- /dev/null +++ b/typedoc-theme/tsconfig.lib.json @@ -0,0 +1,13 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "target": "es2018", + "lib": ["es2018", "dom"], + "module": "commonjs", + "outDir": "../dist/out-tsc", + "declaration": true, + "types": [] + }, + "include": ["**/*.ts"], + "exclude": ["**/*.spec.ts"] +} diff --git a/typedoc-theme/tsconfig.spec.json b/typedoc-theme/tsconfig.spec.json new file mode 100644 index 0000000000..36027728fe --- /dev/null +++ b/typedoc-theme/tsconfig.spec.json @@ -0,0 +1,15 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": [ + "**/*.spec.ts", + "**/*.spec.tsx", + "**/*.spec.js", + "**/*.spec.jsx", + "**/*.d.ts" + ] +} diff --git a/workspace.json b/workspace.json index 24b47ffd9c..06eec5617a 100644 --- a/workspace.json +++ b/workspace.json @@ -2413,6 +2413,47 @@ } } } + }, + "typedoc-theme": { + "root": "typedoc-theme", + "sourceRoot": "typedoc-theme/src", + "projectType": "library", + "targets": { + "build-base": { + "executor": "@nrwl/workspace:tsc", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/typedoc-theme", + "main": "typedoc-theme/src/index.ts", + "tsConfig": "typedoc-theme/tsconfig.lib.json", + "assets": ["typedoc-theme/*.md"] + } + }, + "build": { + "executor": "@nrwl/workspace:tsc", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/typedoc-theme", + "main": "typedoc-theme/src/index.ts", + "tsConfig": "typedoc-theme/tsconfig.lib.json", + "assets": ["typedoc-theme/*.md"] + } + }, + "lint": { + "executor": "@nrwl/linter:eslint", + "options": { + "lintFilePatterns": ["typedoc-theme/**/*.ts"] + } + }, + "test": { + "executor": "@nrwl/jest:jest", + "outputs": ["coverage/typedoc-theme"], + "options": { + "jestConfig": "typedoc-theme/jest.config.js", + "passWithNoTests": true + } + } + } } } } diff --git a/yarn.lock b/yarn.lock index 66483ff6cf..1ac721f3ae 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13019,7 +13019,7 @@ handle-thing@^2.0.0: resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-2.0.1.tgz#857f79ce359580c340d43081cc648970d0bb234e" integrity sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg== -handlebars@4.7.7, handlebars@^4.7.6: +handlebars@4.7.7, handlebars@^4.7.6, handlebars@^4.7.7: version "4.7.7" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.7.tgz#9ce33416aad02dbd6c8fafa8240d5d98004945a1" integrity sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA== @@ -16241,7 +16241,7 @@ lunr-mutable-indexes@2.3.2: dependencies: lunr ">= 2.3.0 < 2.4.0" -"lunr@>= 2.3.0 < 2.4.0": +"lunr@>= 2.3.0 < 2.4.0", lunr@^2.3.9: version "2.3.9" resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.9.tgz#18b123142832337dd6e964df1a5a7707b25d35e1" integrity sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow== @@ -16387,10 +16387,10 @@ markdown-to-jsx@^7.1.0: resolved "https://registry.yarnpkg.com/markdown-to-jsx/-/markdown-to-jsx-7.1.2.tgz#19d3da4cd8864045cdd13a0d179147fbd6a088d4" integrity sha512-O8DMCl32V34RrD+ZHxcAPc2+kYytuDIoQYjY36RVdsLK7uHjgNVvFec4yv0X6LgB4YEZgSvK5QtFi5YVqEpoMA== -marked@2.0.1, marked@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/marked/-/marked-2.0.1.tgz#5e7ed7009bfa5c95182e4eb696f85e948cefcee3" - integrity sha512-5+/fKgMv2hARmMW7DOpykr2iLhl0NgjyELk5yn92iE7z8Se1IS9n3UsFm86hFXIkvMBmVxki8+ckcpjBeyo/hw== +marked@^2.0.3: + version "2.0.6" + resolved "https://registry.yarnpkg.com/marked/-/marked-2.0.6.tgz#c3ab1403b9b70f26acd92590fc272eb1718e778c" + integrity sha512-S2mYj0FzTQa0dLddssqwRVW4EOJOVJ355Xm2Vcbm+LU7GQRGWvwbO5K87OaPSOux2AwTSgtPPaXmc8sDPrhn2A== matcher@^4.0.0: version "4.0.0" @@ -16905,7 +16905,7 @@ minimalistic-crypto-utils@^1.0.1: resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo= -"minimatch@2 || 3", minimatch@3.0.4, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4: +"minimatch@2 || 3", minimatch@3.0.4, minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== @@ -17897,10 +17897,17 @@ onetime@^5.1.0: dependencies: mimic-fn "^2.1.0" -open@8.0.2: - version "8.0.2" - resolved "https://registry.yarnpkg.com/open/-/open-8.0.2.tgz#8c3e95cce93ba2fc8d99968ee8bfefecdb50b84f" - integrity sha512-NV5QmWJrTaNBLHABJyrb+nd5dXI5zfea/suWawBhkHzAbVhLLiJdrqMgxMypGK9Eznp2Ltoh7SAVkQ3XAucX7Q== +onigasm@^2.2.5: + version "2.2.5" + resolved "https://registry.yarnpkg.com/onigasm/-/onigasm-2.2.5.tgz#cc4d2a79a0fa0b64caec1f4c7ea367585a676892" + integrity sha512-F+th54mPc0l1lp1ZcFMyL/jTs2Tlq4SqIHKIXGZOR/VkHkF9A7Fr5rRr5+ZG/lWeRsyrClLYRq7s/yFQ/XhWCA== + dependencies: + lru-cache "^5.1.1" + +open@8.0.7: + version "8.0.7" + resolved "https://registry.yarnpkg.com/open/-/open-8.0.7.tgz#5597eeff14b440f6ff78fb7ced9ede9f69b2122d" + integrity sha512-qoyG0kpdaWVoL5MiwTRQWujSdivwBOgfLadVEdpsZNHOK1+kBvmVtLYdgWr8G4cgBpG9zaxezn6jz6PPdQW5xg== dependencies: define-lazy-prop "^2.0.0" is-docker "^2.1.1" @@ -19912,7 +19919,7 @@ process@0.11.10, process@^0.11.10: resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI= -progress@^2.0.0: +progress@^2.0.0, progress@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== @@ -22047,6 +22054,14 @@ shellwords@^0.1.1: resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b" integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww== +shiki@^0.9.3: + version "0.9.3" + resolved "https://registry.yarnpkg.com/shiki/-/shiki-0.9.3.tgz#7bf7bcf3ed50ca525ec89cc09254abce4264d5ca" + integrity sha512-NEjg1mVbAUrzRv2eIcUt3TG7X9svX7l3n3F5/3OdFq+/BxUdmBOeKGiH4icZJBLHy354Shnj6sfBTemea2e7XA== + dependencies: + onigasm "^2.2.5" + vscode-textmate "^5.2.0" + side-channel@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf" @@ -23940,6 +23955,35 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= +typedoc-default-themes@^0.12.10: + version "0.12.10" + resolved "https://registry.yarnpkg.com/typedoc-default-themes/-/typedoc-default-themes-0.12.10.tgz#614c4222fe642657f37693ea62cad4dafeddf843" + integrity sha512-fIS001cAYHkyQPidWXmHuhs8usjP5XVJjWB8oZGqkTowZaz3v7g3KDZeeqE82FBrmkAnIBOY3jgy7lnPnqATbA== + +typedoc-plugin-markdown@^3.8.2: + version "3.8.2" + resolved "https://registry.yarnpkg.com/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.8.2.tgz#47bb85d93e1f61e6a543d5acc9505e2b2f1b3d0b" + integrity sha512-Ci2dy1mILbDFqO09/C1i/BQiGxbIURLhNwBFHWPqhYvLuDK557ofwEhJmkgTXc6NQ6f1XrXtIWfBQtmmAmQNew== + dependencies: + handlebars "^4.7.7" + +typedoc@^0.20.36: + version "0.20.36" + resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.20.36.tgz#ee5523c32f566ad8283fc732aa8ea322d1a45f6a" + integrity sha512-qFU+DWMV/hifQ9ZAlTjdFO9wbUIHuUBpNXzv68ZyURAP9pInjZiO4+jCPeAzHVcaBCHER9WL/+YzzTt6ZlN/Nw== + dependencies: + colors "^1.4.0" + fs-extra "^9.1.0" + handlebars "^4.7.7" + lodash "^4.17.21" + lunr "^2.3.9" + marked "^2.0.3" + minimatch "^3.0.0" + progress "^2.0.3" + shelljs "^0.8.4" + shiki "^0.9.3" + typedoc-default-themes "^0.12.10" + typescript@4.2.4: version "4.2.4" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.4.tgz#8610b59747de028fda898a8aef0e103f156d0961" @@ -24537,6 +24581,11 @@ void-elements@^2.0.0: resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" integrity sha1-wGavtYK7HLQSjWDqkjkulNXp2+w= +vscode-textmate@^5.2.0: + version "5.4.0" + resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-5.4.0.tgz#4b25ffc1f14ac3a90faf9a388c67a01d24257cd7" + integrity sha512-c0Q4zYZkcLizeYJ3hNyaVUM2AA8KDhNCA3JvXY8CeZSJuBdAy3bAvSbv46RClC4P3dSO9BdwhnKEx2zOo6vP/w== + w3c-hr-time@^1.0.1, w3c-hr-time@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz#0a89cdf5cc15822df9c360543676963e0cc308cd"