fix(devkit): make devkit backwards compatible back to nx 14.1 (#14854)
This commit is contained in:
parent
0f8faa249b
commit
1d773c0d35
@ -91,7 +91,7 @@ overrideCollectionResolutionForTesting({
|
|||||||
|
|
||||||
### wrapAngularDevkitSchematic
|
### wrapAngularDevkitSchematic
|
||||||
|
|
||||||
▸ **wrapAngularDevkitSchematic**(`collectionName`, `generatorName`): (`host`: [`Tree`](../../devkit/documents/index#tree), `generatorOptions`: { [k: string]: `any`; }) => `Promise`<`any`\>
|
▸ **wrapAngularDevkitSchematic**(`collectionName`, `generatorName`): (`host`: [`Tree`](../../devkit/documents/nrwl_devkit#tree), `generatorOptions`: { [k: string]: `any`; }) => `Promise`<`any`\>
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
@ -108,10 +108,10 @@ overrideCollectionResolutionForTesting({
|
|||||||
|
|
||||||
##### Parameters
|
##### Parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
| :----------------- | :------------------------------------------ |
|
| :----------------- | :------------------------------------------------ |
|
||||||
| `host` | [`Tree`](../../devkit/documents/index#tree) |
|
| `host` | [`Tree`](../../devkit/documents/nrwl_devkit#tree) |
|
||||||
| `generatorOptions` | `Object` |
|
| `generatorOptions` | `Object` |
|
||||||
|
|
||||||
##### Returns
|
##### Returns
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -623,7 +623,7 @@
|
|||||||
"isExternal": false,
|
"isExternal": false,
|
||||||
"path": "/packages/devkit/documents/index",
|
"path": "/packages/devkit/documents/index",
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"originalFilePath": "generated/devkit/index"
|
"originalFilePath": "generated/devkit/nrwl_devkit"
|
||||||
},
|
},
|
||||||
"/packages/devkit/documents/ngcli_adapter": {
|
"/packages/devkit/documents/ngcli_adapter": {
|
||||||
"id": "ngcli_adapter",
|
"id": "ngcli_adapter",
|
||||||
|
|||||||
@ -613,7 +613,7 @@
|
|||||||
"isExternal": false,
|
"isExternal": false,
|
||||||
"path": "devkit/documents/index",
|
"path": "devkit/documents/index",
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"originalFilePath": "generated/devkit/index"
|
"originalFilePath": "generated/devkit/nrwl_devkit"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "ngcli_adapter",
|
"id": "ngcli_adapter",
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -91,7 +91,7 @@ overrideCollectionResolutionForTesting({
|
|||||||
|
|
||||||
### wrapAngularDevkitSchematic
|
### wrapAngularDevkitSchematic
|
||||||
|
|
||||||
▸ **wrapAngularDevkitSchematic**(`collectionName`, `generatorName`): (`host`: [`Tree`](../../devkit/documents/index#tree), `generatorOptions`: { [k: string]: `any`; }) => `Promise`<`any`\>
|
▸ **wrapAngularDevkitSchematic**(`collectionName`, `generatorName`): (`host`: [`Tree`](../../devkit/documents/nrwl_devkit#tree), `generatorOptions`: { [k: string]: `any`; }) => `Promise`<`any`\>
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
@ -108,10 +108,10 @@ overrideCollectionResolutionForTesting({
|
|||||||
|
|
||||||
##### Parameters
|
##### Parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
| :----------------- | :------------------------------------------ |
|
| :----------------- | :------------------------------------------------ |
|
||||||
| `host` | [`Tree`](../../devkit/documents/index#tree) |
|
| `host` | [`Tree`](../../devkit/documents/nrwl_devkit#tree) |
|
||||||
| `generatorOptions` | `Object` |
|
| `generatorOptions` | `Object` |
|
||||||
|
|
||||||
##### Returns
|
##### Returns
|
||||||
|
|
||||||
|
|||||||
@ -1550,7 +1550,7 @@
|
|||||||
{
|
{
|
||||||
"id": "index",
|
"id": "index",
|
||||||
"name": "Overview",
|
"name": "Overview",
|
||||||
"file": "generated/devkit/index"
|
"file": "generated/devkit/nrwl_devkit"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "ngcli_adapter",
|
"id": "ngcli_adapter",
|
||||||
|
|||||||
@ -49,7 +49,7 @@ describe('nx-dev: Additional API references section', () => {
|
|||||||
path: '/storybook/storybook-composition-setup',
|
path: '/storybook/storybook-composition-setup',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Module: index',
|
title: 'Module: @nrwl/devkit',
|
||||||
path: '/devkit/index',
|
path: '/devkit/index',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,12 +1,27 @@
|
|||||||
{
|
{
|
||||||
"extends": "../../.eslintrc",
|
"extends": "../../.eslintrc",
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-restricted-imports": [
|
"@typescript-eslint/no-restricted-imports": [
|
||||||
"error",
|
"error",
|
||||||
"@nrwl/workspace",
|
{
|
||||||
"@angular-devkit/core",
|
"paths": [
|
||||||
"@angular-devkit/architect",
|
"@nrwl/workspace",
|
||||||
"@angular-devkit/schematics"
|
"@angular-devkit/core",
|
||||||
|
"@angular-devkit/architect",
|
||||||
|
"@angular-devkit/schematics"
|
||||||
|
],
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"group": ["nx/**/*"],
|
||||||
|
"message": "Use getNx() from packages/devkit/nx.ts OR use a type import instead.",
|
||||||
|
"allowTypeImports": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group": ["@nrwl/devkit/**/*"],
|
||||||
|
"message": "Use a relative import"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"ignorePatterns": ["!**/*"],
|
"ignorePatterns": ["!**/*"],
|
||||||
@ -15,6 +30,12 @@
|
|||||||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
||||||
"rules": {}
|
"rules": {}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"files": ["*.spec.ts"],
|
||||||
|
"rules": {
|
||||||
|
"@typescript-eslint/no-restricted-imports": "off"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"files": ["*.ts", "*.tsx"],
|
"files": ["*.ts", "*.tsx"],
|
||||||
"rules": {
|
"rules": {
|
||||||
|
|||||||
19
packages/devkit/index.d.ts
vendored
Normal file
19
packages/devkit/index.d.ts
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/**
|
||||||
|
* The Nx Devkit is the underlying technology used to customize Nx to support
|
||||||
|
* different technologies and custom use-cases. It contains many utility
|
||||||
|
* functions for reading and writing files, updating configuration,
|
||||||
|
* working with Abstract Syntax Trees(ASTs), and more.
|
||||||
|
*
|
||||||
|
* As with most things in Nx, the core of Nx Devkit is very simple.
|
||||||
|
* It only uses language primitives and immutable objects
|
||||||
|
* (the tree being the only exception).
|
||||||
|
*
|
||||||
|
* @module @nrwl/devkit
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO(v17): remove this file, we can use the normally generated index.d.ts from index.ts
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/no-restricted-imports */
|
||||||
|
export * from 'nx/src/devkit-exports';
|
||||||
|
|
||||||
|
export * from './public-api';
|
||||||
27
packages/devkit/index.js
Normal file
27
packages/devkit/index.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* The Nx Devkit is the underlying technology used to customize Nx to support
|
||||||
|
* different technologies and custom use-cases. It contains many utility
|
||||||
|
* functions for reading and writing files, updating configuration,
|
||||||
|
* working with Abstract Syntax Trees(ASTs), and more.
|
||||||
|
*
|
||||||
|
* As with most things in Nx, the core of Nx Devkit is very simple.
|
||||||
|
* It only uses language primitives and immutable objects
|
||||||
|
* (the tree being the only exception).
|
||||||
|
*
|
||||||
|
* @module @nrwl/devkit
|
||||||
|
*/
|
||||||
|
|
||||||
|
try {
|
||||||
|
// TODO(v17): We will not need to maintain this file anymore, change this to a regular export statement
|
||||||
|
// This file was introduced in the nx package in v15.7 but devkit is compatible down to v14.1 which doesn't have this file.
|
||||||
|
module.exports = require('nx/src/devkit-exports');
|
||||||
|
} catch {
|
||||||
|
// These are the nx-reexports from before v16
|
||||||
|
// TODO(v17): This can be removed once the above is done.
|
||||||
|
module.exports = require('./nx-reexports-pre16');
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
...module.exports,
|
||||||
|
...require('./public-api'),
|
||||||
|
};
|
||||||
@ -1,6 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @category Ng CLI Adapter
|
* @category Ng CLI Adapter
|
||||||
*/
|
*/
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
||||||
export {
|
export {
|
||||||
wrapAngularDevkitSchematic,
|
wrapAngularDevkitSchematic,
|
||||||
overrideCollectionResolutionForTesting,
|
overrideCollectionResolutionForTesting,
|
||||||
|
|||||||
@ -1,23 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* The Nx Devkit is the underlying technology used to customize Nx to support
|
* STOP! Do not change this file!
|
||||||
* different technologies and custom use-cases. It contains many utility
|
|
||||||
* functions for reading and writing files, updating configuration,
|
|
||||||
* working with Abstract Syntax Trees(ASTs), and more.
|
|
||||||
*
|
*
|
||||||
* As with most things in Nx, the core of Nx Devkit is very simple.
|
* If you need to export something from nx, it should go into nx/src/devkit-exports
|
||||||
* It only uses language primitives and immutable objects
|
|
||||||
* (the tree being the only exception).
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
// TODO(v17): Remove this file
|
||||||
* Note to developers: This is the Public API of @nrwl/devkit.
|
|
||||||
* @nrwl/devkit should be compatible with versions of Nx 1 major version prior.
|
/* eslint-disable @typescript-eslint/no-restricted-imports */
|
||||||
* This is so that plugins can use the latest @nrwl/devkit while their users may use versions +/- 1 of Nx.
|
|
||||||
*
|
|
||||||
* 1. Try hard to not add to this API to reduce the surface area we need to maintain.
|
|
||||||
* 2. Do not add newly created paths from the nx package to this file as they will not be available in older versions of Nx.
|
|
||||||
* a. We might need to duplicate code instead of importing from nx until all supported versions of nx contain the file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @category Tree
|
* @category Tree
|
||||||
@ -138,21 +127,18 @@ export {
|
|||||||
getProjects,
|
getProjects,
|
||||||
} from 'nx/src/generators/utils/project-configuration';
|
} from 'nx/src/generators/utils/project-configuration';
|
||||||
|
|
||||||
/**
|
|
||||||
* @category Generators
|
|
||||||
*/
|
|
||||||
export { readNxJson, updateNxJson } from 'nx/src/generators/utils/nx-json';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @category Generators
|
* @category Generators
|
||||||
*/
|
*/
|
||||||
export {
|
export {
|
||||||
|
readNxJson,
|
||||||
|
updateNxJson,
|
||||||
readWorkspaceConfiguration,
|
readWorkspaceConfiguration,
|
||||||
updateWorkspaceConfiguration,
|
updateWorkspaceConfiguration,
|
||||||
isStandaloneProject,
|
isStandaloneProject,
|
||||||
WorkspaceConfiguration,
|
WorkspaceConfiguration,
|
||||||
getWorkspacePath,
|
getWorkspacePath,
|
||||||
} from 'nx/src/generators/utils/deprecated';
|
} from 'nx/src/generators/utils/project-configuration';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @category Generators
|
* @category Generators
|
||||||
@ -366,8 +352,4 @@ export { Hash, Hasher } from 'nx/src/hasher/hasher';
|
|||||||
*/
|
*/
|
||||||
export { cacheDir } from 'nx/src/utils/cache-directory';
|
export { cacheDir } from 'nx/src/utils/cache-directory';
|
||||||
|
|
||||||
/**
|
// STOP! Do not export any new things from the nx package
|
||||||
* @category Package Manager
|
|
||||||
*/
|
|
||||||
export { createLockFile } from 'nx/src/lock-file/lock-file';
|
|
||||||
export { createPackageJson } from 'nx/src/utils/create-package-json';
|
|
||||||
7
packages/devkit/nx.ts
Normal file
7
packages/devkit/nx.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export function requireNx(): typeof import('nx/src/devkit-exports') {
|
||||||
|
try {
|
||||||
|
return require('nx/src/devkit-exports');
|
||||||
|
} catch {
|
||||||
|
return require('./nx-reexports-pre16');
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -35,7 +35,7 @@
|
|||||||
"semver": "7.3.4"
|
"semver": "7.3.4"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"nx": ">= 14 <= 16"
|
"nx": ">= 14.1 <= 16"
|
||||||
},
|
},
|
||||||
"nx-migrations": {
|
"nx-migrations": {
|
||||||
"migrations": "./migrations.json"
|
"migrations": "./migrations.json"
|
||||||
|
|||||||
129
packages/devkit/public-api.ts
Normal file
129
packages/devkit/public-api.ts
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
/**
|
||||||
|
* Note to developers: STOP! This is the Public API of @nrwl/devkit.
|
||||||
|
* @nrwl/devkit should be compatible with versions of Nx 1 major version prior.
|
||||||
|
* This is so that plugins can use the latest @nrwl/devkit while their users may use versions +/- 1 of Nx.
|
||||||
|
*
|
||||||
|
* 1. Try hard to not add to this API to reduce the surface area we need to maintain.
|
||||||
|
* 2. Do not add newly created paths from the nx package to this file as they will not be available in older versions of Nx.
|
||||||
|
* a. We might need to duplicate code instead of importing from nx until all supported versions of nx contain the file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Generators
|
||||||
|
*/
|
||||||
|
export { formatFiles } from './src/generators/format-files';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Generators
|
||||||
|
*/
|
||||||
|
export { generateFiles } from './src/generators/generate-files';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Generators
|
||||||
|
*/
|
||||||
|
export { toJS } from './src/generators/to-js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Generators
|
||||||
|
*/
|
||||||
|
export { updateTsConfigsToJs } from './src/generators/update-ts-configs-to-js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Generators
|
||||||
|
*/
|
||||||
|
export { visitNotIgnoredFiles } from './src/generators/visit-not-ignored-files';
|
||||||
|
|
||||||
|
export {
|
||||||
|
parseTargetString,
|
||||||
|
targetToTargetString,
|
||||||
|
} from './src/executors/parse-target-string';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Executors
|
||||||
|
*/
|
||||||
|
export { readTargetOptions } from './src/executors/read-target-options';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export {
|
||||||
|
addDependenciesToPackageJson,
|
||||||
|
ensurePackage,
|
||||||
|
removeDependenciesFromPackageJson,
|
||||||
|
} from './src/utils/package-json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export { installPackagesTask } from './src/tasks/install-packages-task';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export { names } from './src/utils/names';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export {
|
||||||
|
getWorkspaceLayout,
|
||||||
|
extractLayoutDirectory,
|
||||||
|
} from './src/utils/get-workspace-layout';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export type {
|
||||||
|
StringChange,
|
||||||
|
StringDeletion,
|
||||||
|
StringInsertion,
|
||||||
|
} from './src/utils/string-change';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export { applyChangesToString, ChangeType } from './src/utils/string-change';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export { offsetFromRoot } from './src/utils/offset-from-root';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export { convertNxGenerator } from './src/utils/invoke-nx-generator';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export { convertNxExecutor } from './src/utils/convert-nx-executor';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export { moveFilesToNewDirectory } from './src/utils/move-dir';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export {
|
||||||
|
SharedLibraryConfig,
|
||||||
|
SharedWorkspaceLibraryConfig,
|
||||||
|
AdditionalSharedConfig,
|
||||||
|
applySharedFunction,
|
||||||
|
applyAdditionalShared,
|
||||||
|
mapRemotes,
|
||||||
|
mapRemotesForSSR,
|
||||||
|
getNpmPackageSharedConfig,
|
||||||
|
shareWorkspaceLibraries,
|
||||||
|
sharePackages,
|
||||||
|
getDependentPackagesForProject,
|
||||||
|
ModuleFederationConfig,
|
||||||
|
ModuleFederationLibrary,
|
||||||
|
readRootPackageJson,
|
||||||
|
WorkspaceLibrary,
|
||||||
|
SharedFunction,
|
||||||
|
WorkspaceLibrarySecondaryEntryPoint,
|
||||||
|
Remotes,
|
||||||
|
} from './src/utils/module-federation';
|
||||||
@ -1,7 +1,10 @@
|
|||||||
import type { Target } from 'nx/src/command-line/run';
|
import type { Target } from 'nx/src/command-line/run';
|
||||||
import { ProjectGraph } from 'nx/src/config/project-graph';
|
import type { ProjectGraph } from 'nx/src/config/project-graph';
|
||||||
import { readCachedProjectGraph } from 'nx/src/project-graph/project-graph';
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
||||||
import { splitTarget } from 'nx/src/utils/split-target';
|
import { splitTarget } from 'nx/src/utils/split-target';
|
||||||
|
import { requireNx } from '../../nx';
|
||||||
|
|
||||||
|
const { readCachedProjectGraph } = requireNx();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated(v17) A project graph should be passed to parseTargetString for best accuracy.
|
* @deprecated(v17) A project graph should be passed to parseTargetString for best accuracy.
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
import type { Target } from 'nx/src/command-line/run';
|
import type { Target } from 'nx/src/command-line/run';
|
||||||
import type { ExecutorContext } from 'nx/src/config/misc-interfaces';
|
import type { ExecutorContext } from 'nx/src/config/misc-interfaces';
|
||||||
import { Workspaces } from 'nx/src/config/workspaces';
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
||||||
import { combineOptionsForExecutor } from 'nx/src/utils/params';
|
import { combineOptionsForExecutor } from 'nx/src/utils/params';
|
||||||
|
import { requireNx } from '../../nx';
|
||||||
|
|
||||||
|
const { Workspaces } = requireNx();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads and combines options for a given target.
|
* Reads and combines options for a given target.
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
import type { Tree } from 'nx/src/generators/tree';
|
import type { Tree } from 'nx/src/generators/tree';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import type * as Prettier from 'prettier';
|
import type * as Prettier from 'prettier';
|
||||||
import { readJson, updateJson, writeJson } from 'nx/src/generators/utils/json';
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
||||||
import { sortObjectByKeys } from 'nx/src/utils/object-sort';
|
import { sortObjectByKeys } from 'nx/src/utils/object-sort';
|
||||||
|
import { requireNx } from '../../nx';
|
||||||
|
|
||||||
|
const { updateJson } = requireNx();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats all the created or updated files using Prettier
|
* Formats all the created or updated files using Prettier
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
import { readFileSync, readdirSync, statSync } from 'fs';
|
import { readFileSync, readdirSync, statSync } from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import type { Tree } from 'nx/src/generators/tree';
|
import type { Tree } from 'nx/src/generators/tree';
|
||||||
import { logger } from 'nx/src/utils/logger';
|
import { requireNx } from '../../nx';
|
||||||
|
|
||||||
|
const { logger } = requireNx();
|
||||||
|
|
||||||
const binaryExts = new Set([
|
const binaryExts = new Set([
|
||||||
// // Image types originally from https://github.com/sindresorhus/image-type/blob/5541b6a/index.js
|
// // Image types originally from https://github.com/sindresorhus/image-type/blob/5541b6a/index.js
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
import type { Tree } from 'nx/src/generators/tree';
|
import type { Tree } from 'nx/src/generators/tree';
|
||||||
import { updateJson } from 'nx/src/generators/utils/json';
|
import { requireNx } from '../../nx';
|
||||||
|
|
||||||
|
const { updateJson } = requireNx();
|
||||||
|
|
||||||
export function updateTsConfigsToJs(
|
export function updateTsConfigsToJs(
|
||||||
tree: Tree,
|
tree: Tree,
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { Tree } from 'nx/src/generators/tree';
|
import type { Tree } from 'nx/src/generators/tree';
|
||||||
import { getProjects } from 'nx/src/generators/utils/project-configuration';
|
|
||||||
import {
|
import {
|
||||||
StringChange,
|
StringChange,
|
||||||
ChangeType,
|
ChangeType,
|
||||||
@ -10,6 +9,10 @@ import { tsquery } from '@phenomnomnominal/tsquery';
|
|||||||
|
|
||||||
import { visitNotIgnoredFiles } from '../../generators/visit-not-ignored-files';
|
import { visitNotIgnoredFiles } from '../../generators/visit-not-ignored-files';
|
||||||
import { formatFiles } from '../../generators/format-files';
|
import { formatFiles } from '../../generators/format-files';
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
||||||
|
import { requireNx } from '../../../nx';
|
||||||
|
|
||||||
|
const { getProjects } = requireNx();
|
||||||
|
|
||||||
export default async function update(tree: Tree): Promise<void> {
|
export default async function update(tree: Tree): Promise<void> {
|
||||||
for (const [project, { root }] of getProjects(tree)) {
|
for (const [project, { root }] of getProjects(tree)) {
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
import type { Tree } from 'nx/src/generators/tree';
|
|
||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import {
|
import { requireNx } from '../../nx';
|
||||||
detectPackageManager,
|
|
||||||
getPackageManagerCommand,
|
import type { Tree } from 'nx/src/generators/tree';
|
||||||
} from 'nx/src/utils/package-manager';
|
|
||||||
import type { PackageManager } from 'nx/src/utils/package-manager';
|
import type { PackageManager } from 'nx/src/utils/package-manager';
|
||||||
import { joinPathFragments } from 'nx/src/utils/path';
|
const { detectPackageManager, getPackageManagerCommand, joinPathFragments } =
|
||||||
|
requireNx();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs `npm install` or `yarn install`. It will skip running the install if
|
* Runs `npm install` or `yarn install`. It will skip running the install if
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
import type { Observable } from 'rxjs';
|
import type { Observable } from 'rxjs';
|
||||||
import { Workspaces } from 'nx/src/config/workspaces';
|
import type { Executor, ExecutorContext } from 'nx/src/config/misc-interfaces';
|
||||||
import { Executor, ExecutorContext } from 'nx/src/config/misc-interfaces';
|
import type { ProjectGraph } from 'nx/src/config/project-graph';
|
||||||
import {
|
import { requireNx } from '../../nx';
|
||||||
createProjectGraphAsync,
|
|
||||||
readCachedProjectGraph,
|
const { createProjectGraphAsync, readCachedProjectGraph, Workspaces } =
|
||||||
} from 'nx/src/project-graph/project-graph';
|
requireNx();
|
||||||
import { ProjectGraph } from 'nx/src/config/project-graph';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert an Nx Executor into an Angular Devkit Builder
|
* Convert an Nx Executor into an Angular Devkit Builder
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
import { readNxJson } from 'nx/src/generators/utils/nx-json';
|
|
||||||
import type { Tree } from 'nx/src/generators/tree';
|
import type { Tree } from 'nx/src/generators/tree';
|
||||||
|
import { requireNx } from '../../nx';
|
||||||
|
|
||||||
|
const { readNxJson } = requireNx();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns workspace defaults. It includes defaults folders for apps and libs,
|
* Returns workspace defaults. It includes defaults folders for apps and libs,
|
||||||
|
|||||||
@ -1,12 +1,19 @@
|
|||||||
import { logger, stripIndent } from 'nx/src/utils/logger';
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
||||||
|
import { stripIndent } from 'nx/src/utils/logger';
|
||||||
import type {
|
import type {
|
||||||
FileChange,
|
FileChange,
|
||||||
Tree,
|
Tree,
|
||||||
TreeWriteOptions,
|
TreeWriteOptions,
|
||||||
} from 'nx/src/generators/tree';
|
} from 'nx/src/generators/tree';
|
||||||
import { Generator, GeneratorCallback } from 'nx/src/config/misc-interfaces';
|
import type {
|
||||||
|
Generator,
|
||||||
|
GeneratorCallback,
|
||||||
|
} from 'nx/src/config/misc-interfaces';
|
||||||
import { join, relative } from 'path';
|
import { join, relative } from 'path';
|
||||||
import type { Mode } from 'fs';
|
import type { Mode } from 'fs';
|
||||||
|
import { requireNx } from '../../nx';
|
||||||
|
|
||||||
|
const { logger } = requireNx();
|
||||||
|
|
||||||
class RunCallbackTask {
|
class RunCallbackTask {
|
||||||
constructor(private callback: GeneratorCallback) {}
|
constructor(private callback: GeneratorCallback) {}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { joinPathFragments } from 'nx/src/utils/path';
|
|
||||||
import { readJsonFile } from 'nx/src/utils/fileutils';
|
|
||||||
import { workspaceRoot } from 'nx/src/utils/workspace-root';
|
|
||||||
import { existsSync } from 'fs';
|
import { existsSync } from 'fs';
|
||||||
|
import { requireNx } from '../../../nx';
|
||||||
|
|
||||||
|
const { workspaceRoot, readJsonFile, joinPathFragments } = requireNx();
|
||||||
|
|
||||||
export function readRootPackageJson(): {
|
export function readRootPackageJson(): {
|
||||||
dependencies?: { [key: string]: string };
|
dependencies?: { [key: string]: string };
|
||||||
|
|||||||
@ -2,10 +2,12 @@ import type { WorkspaceLibrary } from './models';
|
|||||||
import { WorkspaceLibrarySecondaryEntryPoint } from './models';
|
import { WorkspaceLibrarySecondaryEntryPoint } from './models';
|
||||||
import { dirname, join, relative } from 'path';
|
import { dirname, join, relative } from 'path';
|
||||||
import { existsSync, lstatSync, readdirSync } from 'fs';
|
import { existsSync, lstatSync, readdirSync } from 'fs';
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
||||||
import { PackageJson, readModulePackageJson } from 'nx/src/utils/package-json';
|
import { PackageJson, readModulePackageJson } from 'nx/src/utils/package-json';
|
||||||
import { workspaceRoot } from 'nx/src/utils/workspace-root';
|
import { requireNx } from '../../../nx';
|
||||||
import { joinPathFragments } from 'nx/src/utils/path';
|
|
||||||
import { readJsonFile } from 'nx/src/utils/fileutils';
|
const { readJsonFile, joinPathFragments, workspaceRoot } = requireNx();
|
||||||
|
|
||||||
export function collectWorkspaceLibrarySecondaryEntryPoints(
|
export function collectWorkspaceLibrarySecondaryEntryPoints(
|
||||||
library: WorkspaceLibrary,
|
library: WorkspaceLibrary,
|
||||||
|
|||||||
@ -2,7 +2,13 @@ jest.mock('fs');
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as tsUtils from './typescript';
|
import * as tsUtils from './typescript';
|
||||||
|
|
||||||
import * as nxFileutils from 'nx/src/utils/fileutils';
|
jest.mock('nx/src/devkit-exports', () => {
|
||||||
|
return {
|
||||||
|
...jest.requireActual('nx/src/devkit-exports'),
|
||||||
|
readJsonFile: jest.fn(),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
import * as nxFileutils from 'nx/src/devkit-exports';
|
||||||
import { sharePackages, shareWorkspaceLibraries } from './share';
|
import { sharePackages, shareWorkspaceLibraries } from './share';
|
||||||
|
|
||||||
describe('MF Share Utils', () => {
|
describe('MF Share Utils', () => {
|
||||||
@ -336,13 +342,16 @@ describe('MF Share Utils', () => {
|
|||||||
(fs.existsSync as jest.Mock).mockImplementation(
|
(fs.existsSync as jest.Mock).mockImplementation(
|
||||||
(file) => !file.endsWith('non-existent-top-level-package/package.json')
|
(file) => !file.endsWith('non-existent-top-level-package/package.json')
|
||||||
);
|
);
|
||||||
jest.spyOn(nxFileutils, 'readJsonFile').mockImplementation((file) => ({
|
jest.spyOn(nxFileutils, 'readJsonFile').mockImplementation((file) => {
|
||||||
name: file
|
console.log('HELLO?');
|
||||||
.replace(/\\/g, '/')
|
return {
|
||||||
.replace(/^.*node_modules[/]/, '')
|
name: file
|
||||||
.replace('/package.json', ''),
|
.replace(/\\/g, '/')
|
||||||
dependencies: { '@angular/core': '~13.2.0' },
|
.replace(/^.*node_modules[/]/, '')
|
||||||
}));
|
.replace('/package.json', ''),
|
||||||
|
dependencies: { '@angular/core': '~13.2.0' },
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
// ACT & ASSERT
|
// ACT & ASSERT
|
||||||
expect(() =>
|
expect(() =>
|
||||||
|
|||||||
@ -11,10 +11,12 @@ import {
|
|||||||
collectPackageSecondaryEntryPoints,
|
collectPackageSecondaryEntryPoints,
|
||||||
collectWorkspaceLibrarySecondaryEntryPoints,
|
collectWorkspaceLibrarySecondaryEntryPoints,
|
||||||
} from './secondary-entry-points';
|
} from './secondary-entry-points';
|
||||||
import { workspaceRoot } from 'nx/src/utils/workspace-root';
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
||||||
import { logger } from 'nx/src/utils/logger';
|
|
||||||
import { getRootTsConfigPath } from 'nx/src/utils/typescript';
|
import { getRootTsConfigPath } from 'nx/src/utils/typescript';
|
||||||
import { ProjectGraph } from 'nx/src/config/project-graph';
|
import type { ProjectGraph } from 'nx/src/config/project-graph';
|
||||||
|
import { requireNx } from '../../../nx';
|
||||||
|
|
||||||
|
const { workspaceRoot, logger } = requireNx();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build an object of functions to be used with the ModuleFederationPlugin to
|
* Build an object of functions to be used with the ModuleFederationPlugin to
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { existsSync } from 'fs';
|
import { existsSync } from 'fs';
|
||||||
import { ParsedCommandLine } from 'typescript';
|
import { ParsedCommandLine } from 'typescript';
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
||||||
import { getRootTsConfigPath } from 'nx/src/utils/typescript';
|
import { getRootTsConfigPath } from 'nx/src/utils/typescript';
|
||||||
import { dirname } from 'path';
|
import { dirname } from 'path';
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import { Tree } from 'nx/src/generators/tree';
|
import type { Tree } from 'nx/src/generators/tree';
|
||||||
import { relative } from 'path';
|
import { relative } from 'path';
|
||||||
import { visitNotIgnoredFiles } from '../generators/visit-not-ignored-files';
|
import { visitNotIgnoredFiles } from '../generators/visit-not-ignored-files';
|
||||||
import { normalizePath } from 'nx/src/utils/path';
|
import { requireNx } from '../../nx';
|
||||||
|
|
||||||
|
const { normalizePath } = requireNx();
|
||||||
/**
|
/**
|
||||||
* Analogous to cp -r oldDir newDir
|
* Analogous to cp -r oldDir newDir
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,12 +1,15 @@
|
|||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process';
|
||||||
import { readJson, updateJson } from 'nx/src/generators/utils/json';
|
|
||||||
import type { Tree } from 'nx/src/generators/tree';
|
import type { Tree } from 'nx/src/generators/tree';
|
||||||
import { GeneratorCallback } from 'nx/src/config/misc-interfaces';
|
|
||||||
|
import type { GeneratorCallback } from 'nx/src/config/misc-interfaces';
|
||||||
import { clean, coerce, gt, satisfies } from 'semver';
|
import { clean, coerce, gt, satisfies } from 'semver';
|
||||||
import { getPackageManagerCommand } from 'nx/src/utils/package-manager';
|
|
||||||
import { workspaceRoot } from 'nx/src/utils/workspace-root';
|
|
||||||
|
|
||||||
import { installPackagesTask } from '../tasks/install-packages-task';
|
import { installPackagesTask } from '../tasks/install-packages-task';
|
||||||
|
import { requireNx } from '../../nx';
|
||||||
|
|
||||||
|
const { readJson, updateJson, getPackageManagerCommand, workspaceRoot } =
|
||||||
|
requireNx();
|
||||||
|
|
||||||
const UNIDENTIFIED_VERSION = 'UNIDENTIFIED_VERSION';
|
const UNIDENTIFIED_VERSION = 'UNIDENTIFIED_VERSION';
|
||||||
const NON_SEMVER_TAGS = {
|
const NON_SEMVER_TAGS = {
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-restricted-imports */
|
||||||
export {
|
export {
|
||||||
createTreeWithEmptyWorkspace,
|
createTreeWithEmptyWorkspace,
|
||||||
createTreeWithEmptyV1Workspace,
|
createTreeWithEmptyV1Workspace,
|
||||||
2
packages/devkit/testing.d.ts
vendored
Normal file
2
packages/devkit/testing.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
||||||
|
export * from 'nx/src/devkit-testing-exports';
|
||||||
9
packages/devkit/testing.js
Normal file
9
packages/devkit/testing.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
try {
|
||||||
|
// TODO(v17): We will not need to maintain this file anymore, change this to a regular export statement
|
||||||
|
// This file was introduced in the nx package in v15.7 but devkit is compatible down to v14.1 which doesn't have this file.
|
||||||
|
module.exports = require('nx/src/devkit-testing-exports');
|
||||||
|
} catch {
|
||||||
|
// These are the nx-reexports from before v16
|
||||||
|
// TODO(v17): This can be removed once the above is done.
|
||||||
|
module.exports = require('./testing-pre16');
|
||||||
|
}
|
||||||
@ -13,5 +13,6 @@
|
|||||||
"**/*_test.ts",
|
"**/*_test.ts",
|
||||||
"jest.config.ts"
|
"jest.config.ts"
|
||||||
],
|
],
|
||||||
|
"files": ["./index.d.ts"],
|
||||||
"include": ["**/*.ts"]
|
"include": ["**/*.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,3 +5,6 @@ export * from './utils/package-json';
|
|||||||
export * from './utils/assets';
|
export * from './utils/assets';
|
||||||
export * from './utils/package-json/update-package-json';
|
export * from './utils/package-json/update-package-json';
|
||||||
export { libraryGenerator } from './generators/library/library';
|
export { libraryGenerator } from './generators/library/library';
|
||||||
|
|
||||||
|
export { createLockFile } from 'nx/src/lock-file/lock-file';
|
||||||
|
export { createPackageJson } from 'nx/src/utils/create-package-json';
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
|
import { createLockFile } from 'nx/src/lock-file/lock-file';
|
||||||
|
import { createPackageJson } from 'nx/src/utils/create-package-json';
|
||||||
import {
|
import {
|
||||||
createLockFile,
|
|
||||||
createPackageJson,
|
|
||||||
ExecutorContext,
|
ExecutorContext,
|
||||||
getOutputsForTargetAndConfiguration,
|
getOutputsForTargetAndConfiguration,
|
||||||
joinPathFragments,
|
joinPathFragments,
|
||||||
|
|||||||
@ -38,6 +38,7 @@
|
|||||||
"@nrwl/cypress": "file:../cypress",
|
"@nrwl/cypress": "file:../cypress",
|
||||||
"@nrwl/devkit": "file:../devkit",
|
"@nrwl/devkit": "file:../devkit",
|
||||||
"@nrwl/jest": "file:../jest",
|
"@nrwl/jest": "file:../jest",
|
||||||
|
"@nrwl/js": "file:../js",
|
||||||
"@nrwl/linter": "file:../linter",
|
"@nrwl/linter": "file:../linter",
|
||||||
"@nrwl/react": "file:../react",
|
"@nrwl/react": "file:../react",
|
||||||
"@nrwl/webpack": "file:../webpack",
|
"@nrwl/webpack": "file:../webpack",
|
||||||
|
|||||||
@ -4,10 +4,9 @@ import {
|
|||||||
readJsonFile,
|
readJsonFile,
|
||||||
workspaceLayout,
|
workspaceLayout,
|
||||||
workspaceRoot,
|
workspaceRoot,
|
||||||
createPackageJson,
|
|
||||||
createLockFile,
|
|
||||||
writeJsonFile,
|
writeJsonFile,
|
||||||
} from '@nrwl/devkit';
|
} from '@nrwl/devkit';
|
||||||
|
import { createLockFile, createPackageJson } from '@nrwl/js';
|
||||||
import build from 'next/dist/build';
|
import build from 'next/dist/build';
|
||||||
import { join, resolve } from 'path';
|
import { join, resolve } from 'path';
|
||||||
import { copySync, existsSync, mkdir, writeFileSync } from 'fs-extra';
|
import { copySync, existsSync, mkdir, writeFileSync } from 'fs-extra';
|
||||||
|
|||||||
243
packages/nx/src/devkit-exports.ts
Normal file
243
packages/nx/src/devkit-exports.ts
Normal file
@ -0,0 +1,243 @@
|
|||||||
|
/**
|
||||||
|
* Note to developers: STOP! These exports end up as the public API of @nrwl/devkit.
|
||||||
|
* Try hard to not add to this API to reduce the surface area we need to maintain.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Tree
|
||||||
|
*/
|
||||||
|
export type { Tree, FileChange } from './generators/tree';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Workspace
|
||||||
|
*/
|
||||||
|
export type {
|
||||||
|
WorkspaceJsonConfiguration,
|
||||||
|
ProjectsConfigurations,
|
||||||
|
TargetDependencyConfig,
|
||||||
|
TargetConfiguration,
|
||||||
|
ProjectConfiguration,
|
||||||
|
ProjectType,
|
||||||
|
Workspace,
|
||||||
|
} from './config/workspace-json-project-json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Workspace
|
||||||
|
*/
|
||||||
|
export type {
|
||||||
|
Generator,
|
||||||
|
GeneratorCallback,
|
||||||
|
Executor,
|
||||||
|
ExecutorContext,
|
||||||
|
TaskGraphExecutor,
|
||||||
|
GeneratorsJson,
|
||||||
|
ExecutorsJson,
|
||||||
|
MigrationsJson,
|
||||||
|
CustomHasher,
|
||||||
|
HasherContext,
|
||||||
|
} from './config/misc-interfaces';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Workspace
|
||||||
|
*/
|
||||||
|
export { Workspaces } from './config/workspaces';
|
||||||
|
|
||||||
|
// TODO (v16): Change this to export from './config/configuration'
|
||||||
|
export {
|
||||||
|
readAllWorkspaceConfiguration,
|
||||||
|
workspaceLayout,
|
||||||
|
} from './project-graph/file-utils';
|
||||||
|
|
||||||
|
export type { NxPlugin, ProjectTargetConfigurator } from './utils/nx-plugin';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Workspace
|
||||||
|
*/
|
||||||
|
export type { Task, TaskGraph } from './config/task-graph';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Workspace
|
||||||
|
*/
|
||||||
|
export type {
|
||||||
|
ImplicitDependencyEntry,
|
||||||
|
ImplicitJsonSubsetDependency,
|
||||||
|
NxJsonConfiguration,
|
||||||
|
NxAffectedConfig,
|
||||||
|
} from './config/nx-json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Logger
|
||||||
|
*/
|
||||||
|
export { logger } from './utils/logger';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export { output } from './utils/output';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Package Manager
|
||||||
|
*/
|
||||||
|
export type { PackageManager } from './utils/package-manager';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Package Manager
|
||||||
|
*/
|
||||||
|
export {
|
||||||
|
getPackageManagerCommand,
|
||||||
|
detectPackageManager,
|
||||||
|
getPackageManagerVersion,
|
||||||
|
} from './utils/package-manager';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Commands
|
||||||
|
*/
|
||||||
|
export type { Target } from './command-line/run';
|
||||||
|
/**
|
||||||
|
* @category Commands
|
||||||
|
*/
|
||||||
|
export { runExecutor } from './command-line/run';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Generators
|
||||||
|
*/
|
||||||
|
export {
|
||||||
|
addProjectConfiguration,
|
||||||
|
readProjectConfiguration,
|
||||||
|
removeProjectConfiguration,
|
||||||
|
updateProjectConfiguration,
|
||||||
|
getProjects,
|
||||||
|
} from './generators/utils/project-configuration';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Generators
|
||||||
|
*/
|
||||||
|
export {
|
||||||
|
readWorkspaceConfiguration,
|
||||||
|
updateWorkspaceConfiguration,
|
||||||
|
isStandaloneProject,
|
||||||
|
WorkspaceConfiguration,
|
||||||
|
getWorkspacePath,
|
||||||
|
} from './generators/utils/deprecated';
|
||||||
|
|
||||||
|
export {
|
||||||
|
readNxJson,
|
||||||
|
updateNxJson,
|
||||||
|
} from './generators/utils/project-configuration';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Project Graph
|
||||||
|
*/
|
||||||
|
export type {
|
||||||
|
ProjectFileMap,
|
||||||
|
FileData,
|
||||||
|
ProjectGraph,
|
||||||
|
ProjectGraphV4,
|
||||||
|
ProjectGraphDependency,
|
||||||
|
ProjectGraphNode,
|
||||||
|
ProjectGraphProjectNode,
|
||||||
|
ProjectGraphExternalNode,
|
||||||
|
ProjectGraphProcessorContext,
|
||||||
|
} from './config/project-graph';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Project Graph
|
||||||
|
*/
|
||||||
|
export { DependencyType } from './config/project-graph';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Project Graph
|
||||||
|
*/
|
||||||
|
export { ProjectGraphBuilder } from './project-graph/project-graph-builder';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export { readJson, writeJson, updateJson } from './generators/utils/json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export { parseJson, serializeJson, stripJsonComments } from './utils/json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export type { JsonParseOptions, JsonSerializeOptions } from './utils/json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export { readJsonFile, writeJsonFile } from './utils/fileutils';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export { stripIndents } from './utils/strip-indents';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export {
|
||||||
|
joinPathFragments,
|
||||||
|
normalizePath,
|
||||||
|
getImportPath,
|
||||||
|
detectWorkspaceScope,
|
||||||
|
} from './utils/path';
|
||||||
|
|
||||||
|
// TODO(v16): Change this to export from './utils/workspace-root'
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export { workspaceRoot, appRootPath } from './utils/app-root';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export { reverse } from './project-graph/operators';
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export {
|
||||||
|
createProjectGraphAsync,
|
||||||
|
readCachedProjectGraph,
|
||||||
|
} from './project-graph/project-graph';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export { getOutputsForTargetAndConfiguration } from './tasks-runner/utils';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export {
|
||||||
|
defaultTasksRunner,
|
||||||
|
DefaultTasksRunnerOptions,
|
||||||
|
RemoteCache,
|
||||||
|
} from './tasks-runner/default-tasks-runner';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export { Hash, Hasher } from './hasher/hasher';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Utils
|
||||||
|
*/
|
||||||
|
export { cacheDir } from './utils/cache-directory';
|
||||||
|
|
||||||
|
import { createLockFile as _createLockFile } from './lock-file/lock-file';
|
||||||
|
import { createPackageJson as _createPackageJson } from './utils/create-package-json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Package Manager
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @deprecated Import this from @nrwl/js instead
|
||||||
|
*/
|
||||||
|
export const createLockFile = _createLockFile;
|
||||||
|
/**
|
||||||
|
* @deprecated Import this from @nrwl/js instead
|
||||||
|
*/
|
||||||
|
export const createPackageJson = _createPackageJson;
|
||||||
5
packages/nx/src/devkit-testing-exports.ts
Normal file
5
packages/nx/src/devkit-testing-exports.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export {
|
||||||
|
createTreeWithEmptyWorkspace,
|
||||||
|
createTreeWithEmptyV1Workspace,
|
||||||
|
} from './generators/testing-utils/create-tree-with-empty-workspace';
|
||||||
|
export { createTree } from './generators/testing-utils/create-tree';
|
||||||
@ -4,12 +4,14 @@ import { ProjectsConfigurations } from '../../config/workspace-json-project-json
|
|||||||
import type { Tree } from '../tree';
|
import type { Tree } from '../tree';
|
||||||
import { readNxJson, updateNxJson } from './nx-json';
|
import { readNxJson, updateNxJson } from './nx-json';
|
||||||
|
|
||||||
|
// TODO(v16): Remove this
|
||||||
/**
|
/**
|
||||||
* @deprecated using NxJsonConfiguration
|
* @deprecated using NxJsonConfiguration
|
||||||
*/
|
*/
|
||||||
export type WorkspaceConfiguration = Omit<ProjectsConfigurations, 'projects'> &
|
export type WorkspaceConfiguration = Omit<ProjectsConfigurations, 'projects'> &
|
||||||
Partial<NxJsonConfiguration>;
|
Partial<NxJsonConfiguration>;
|
||||||
|
|
||||||
|
// TODO(v16): Remove this
|
||||||
/**
|
/**
|
||||||
* Update general workspace configuration such as the default project or cli settings.
|
* Update general workspace configuration such as the default project or cli settings.
|
||||||
*
|
*
|
||||||
@ -59,6 +61,7 @@ export function updateWorkspaceConfiguration(
|
|||||||
updateNxJson(tree, nxJson);
|
updateNxJson(tree, nxJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(v16): Remove this
|
||||||
/**
|
/**
|
||||||
* Returns if a project has a standalone configuration (project.json).
|
* Returns if a project has a standalone configuration (project.json).
|
||||||
*
|
*
|
||||||
@ -71,6 +74,7 @@ export function isStandaloneProject(tree: Tree, project: string): boolean {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(v16): Remove this
|
||||||
/**
|
/**
|
||||||
* Read general workspace configuration such as the default project or cli settings
|
* Read general workspace configuration such as the default project or cli settings
|
||||||
*
|
*
|
||||||
@ -81,6 +85,7 @@ export function readWorkspaceConfiguration(tree: Tree): WorkspaceConfiguration {
|
|||||||
return readNxJson(tree) as any;
|
return readNxJson(tree) as any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(v16): Remove this
|
||||||
/**
|
/**
|
||||||
* @deprecated all projects are configured using project.json
|
* @deprecated all projects are configured using project.json
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -4,19 +4,30 @@ import type { NxJsonConfiguration } from '../../config/nx-json';
|
|||||||
import type { Tree } from '../tree';
|
import type { Tree } from '../tree';
|
||||||
|
|
||||||
import { readJson, updateJson } from './json';
|
import { readJson, updateJson } from './json';
|
||||||
|
import { readNxJson as readNxJsonFromDisk } from '../../project-graph/file-utils';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated You must pass a {@link Tree}
|
||||||
|
*/
|
||||||
|
export function readNxJson(): NxJsonConfiguration | null;
|
||||||
|
export function readNxJson(tree: Tree): NxJsonConfiguration | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads nx.json
|
* Reads nx.json
|
||||||
*/
|
*/
|
||||||
export function readNxJson(tree: Tree): NxJsonConfiguration | null {
|
export function readNxJson(tree?: Tree): NxJsonConfiguration | null {
|
||||||
if (!tree.exists('nx.json')) {
|
if (tree) {
|
||||||
return null;
|
if (!tree.exists('nx.json')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
let nxJson = readJson<NxJsonConfiguration>(tree, 'nx.json');
|
||||||
|
if (nxJson.extends) {
|
||||||
|
nxJson = { ...readNxJsonExtends(tree, nxJson.extends), ...nxJson };
|
||||||
|
}
|
||||||
|
return nxJson;
|
||||||
|
} else {
|
||||||
|
return readNxJsonFromDisk();
|
||||||
}
|
}
|
||||||
let nxJson = readJson<NxJsonConfiguration>(tree, 'nx.json');
|
|
||||||
if (nxJson.extends) {
|
|
||||||
nxJson = { ...readNxJsonExtends(tree, nxJson.extends), ...nxJson };
|
|
||||||
}
|
|
||||||
return nxJson;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import { type Compiler, sources, type WebpackPluginInstance } from 'webpack';
|
import { type Compiler, sources, type WebpackPluginInstance } from 'webpack';
|
||||||
|
import { createLockFile, createPackageJson } from '@nrwl/js';
|
||||||
import {
|
import {
|
||||||
createLockFile,
|
|
||||||
createPackageJson,
|
|
||||||
ExecutorContext,
|
ExecutorContext,
|
||||||
type ProjectGraph,
|
type ProjectGraph,
|
||||||
serializeJson,
|
serializeJson,
|
||||||
|
|||||||
@ -12,7 +12,7 @@ export function generateDevkitDocumentation() {
|
|||||||
execSync('nx build typedoc-theme', execSyncOptions);
|
execSync('nx build typedoc-theme', execSyncOptions);
|
||||||
|
|
||||||
execSync(
|
execSync(
|
||||||
`rm -rf docs/generated/devkit && npx typedoc packages/devkit/index.ts packages/devkit/ngcli-adapter.ts --tsconfig packages/devkit/tsconfig.lib.json --out ./docs/generated/devkit --hideBreadcrumbs true --disableSources --publicPath ../../devkit/ --theme dist/typedoc-theme/src/lib --readme none`,
|
`rm -rf docs/generated/devkit && npx typedoc packages/devkit/index.d.ts packages/devkit/ngcli-adapter.ts --tsconfig packages/devkit/tsconfig.lib.json --out ./docs/generated/devkit --hideBreadcrumbs true --disableSources --publicPath ../../devkit/ --theme dist/typedoc-theme/src/lib --readme none`,
|
||||||
execSyncOptions
|
execSyncOptions
|
||||||
);
|
);
|
||||||
execSync(
|
execSync(
|
||||||
|
|||||||
@ -3,6 +3,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|||||||
const path_1 = require('path');
|
const path_1 = require('path');
|
||||||
const ts = require('typescript');
|
const ts = require('typescript');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const { relative, join } = require('path');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom resolver which will respect package exports (until Jest supports it natively
|
* Custom resolver which will respect package exports (until Jest supports it natively
|
||||||
@ -67,7 +68,9 @@ module.exports = function (path, options) {
|
|||||||
if (path.startsWith('nx/')) throw new Error('custom resolution');
|
if (path.startsWith('nx/')) throw new Error('custom resolution');
|
||||||
|
|
||||||
if (path.indexOf('@nrwl/workspace') > -1) {
|
if (path.indexOf('@nrwl/workspace') > -1) {
|
||||||
throw 'Reference to local Nx package found. Use local version instead.';
|
throw new Error(
|
||||||
|
'Reference to local Nx package found. Use local version instead.'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Global modules which must be resolved by defaultResolver
|
// Global modules which must be resolved by defaultResolver
|
||||||
@ -80,6 +83,14 @@ module.exports = function (path, options) {
|
|||||||
// Fallback to using typescript
|
// Fallback to using typescript
|
||||||
compilerSetup = compilerSetup || getCompilerSetup(options.rootDir);
|
compilerSetup = compilerSetup || getCompilerSetup(options.rootDir);
|
||||||
const { compilerOptions, host } = compilerSetup;
|
const { compilerOptions, host } = compilerSetup;
|
||||||
|
|
||||||
|
// TODO(v17): Remove this workaround
|
||||||
|
// We have some weird d.ts + .js business going on for these 2 imports so this is a workaround
|
||||||
|
if (path === '@nrwl/devkit') {
|
||||||
|
return join(__dirname, '../', './packages/devkit/index.js');
|
||||||
|
} else if (path === '@nrwl/devkit/testing') {
|
||||||
|
return join(__dirname, '../', './packages/devkit/testing.js');
|
||||||
|
}
|
||||||
return ts.resolveModuleName(path, options.basedir, compilerOptions, host)
|
return ts.resolveModuleName(path, options.basedir, compilerOptions, host)
|
||||||
.resolvedModule.resolvedFileName;
|
.resolvedModule.resolvedFileName;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user