Skip to content

Commit

Permalink
feat(core): move barrel files to js
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Apr 14, 2023
1 parent acb3dd3 commit 3677795
Show file tree
Hide file tree
Showing 45 changed files with 101 additions and 192 deletions.
49 changes: 0 additions & 49 deletions docs/generated/devkit/nrwl_devkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ It only uses language primitives and immutable objects
- [applySharedFunction](../../devkit/documents/nrwl_devkit#applysharedfunction)
- [convertNxExecutor](../../devkit/documents/nrwl_devkit#convertnxexecutor)
- [convertNxGenerator](../../devkit/documents/nrwl_devkit#convertnxgenerator)
- [createLockFile](../../devkit/documents/nrwl_devkit#createlockfile)
- [createPackageJson](../../devkit/documents/nrwl_devkit#createpackagejson)
- [createProjectGraphAsync](../../devkit/documents/nrwl_devkit#createprojectgraphasync)
- [defaultTasksRunner](../../devkit/documents/nrwl_devkit#defaulttasksrunner)
- [detectPackageManager](../../devkit/documents/nrwl_devkit#detectpackagemanager)
Expand Down Expand Up @@ -1054,53 +1052,6 @@ Convert an Nx Generator into an Angular Devkit Schematic.

---

### createLockFile

**createLockFile**(`packageJson`, `packageManager?`): `string`

**`Deprecated`**

Import this from @nrwl/js instead

#### Parameters

| Name | Type |
| :--------------- | :-------------------------------------------------------------------- |
| `packageJson` | `PackageJson` |
| `packageManager` | [`PackageManager`](../../devkit/documents/nrwl_devkit#packagemanager) |

#### Returns

`string`

---

### createPackageJson

**createPackageJson**(`projectName`, `graph`, `options?`): `PackageJson`

**`Deprecated`**

Import this from @nrwl/js instead

#### Parameters

| Name | Type |
| :---------------------------- | :---------------------------------------------------------------- |
| `projectName` | `string` |
| `graph` | [`ProjectGraph`](../../devkit/documents/nrwl_devkit#projectgraph) |
| `options` | `Object` |
| `options.helperDependencies?` | `string`[] |
| `options.isProduction?` | `boolean` |
| `options.root?` | `string` |
| `options.target?` | `string` |

#### Returns

`PackageJson`

---

### createProjectGraphAsync

**createProjectGraphAsync**(`opts?`): `Promise`<[`ProjectGraph`](../../devkit/documents/nrwl_devkit#projectgraph)\>
Expand Down
49 changes: 0 additions & 49 deletions docs/generated/packages/devkit/documents/nrwl_devkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ It only uses language primitives and immutable objects
- [applySharedFunction](../../devkit/documents/nrwl_devkit#applysharedfunction)
- [convertNxExecutor](../../devkit/documents/nrwl_devkit#convertnxexecutor)
- [convertNxGenerator](../../devkit/documents/nrwl_devkit#convertnxgenerator)
- [createLockFile](../../devkit/documents/nrwl_devkit#createlockfile)
- [createPackageJson](../../devkit/documents/nrwl_devkit#createpackagejson)
- [createProjectGraphAsync](../../devkit/documents/nrwl_devkit#createprojectgraphasync)
- [defaultTasksRunner](../../devkit/documents/nrwl_devkit#defaulttasksrunner)
- [detectPackageManager](../../devkit/documents/nrwl_devkit#detectpackagemanager)
Expand Down Expand Up @@ -1054,53 +1052,6 @@ Convert an Nx Generator into an Angular Devkit Schematic.

---

### createLockFile

**createLockFile**(`packageJson`, `packageManager?`): `string`

**`Deprecated`**

Import this from @nrwl/js instead

#### Parameters

| Name | Type |
| :--------------- | :-------------------------------------------------------------------- |
| `packageJson` | `PackageJson` |
| `packageManager` | [`PackageManager`](../../devkit/documents/nrwl_devkit#packagemanager) |

#### Returns

`string`

---

### createPackageJson

**createPackageJson**(`projectName`, `graph`, `options?`): `PackageJson`

**`Deprecated`**

Import this from @nrwl/js instead

#### Parameters

| Name | Type |
| :---------------------------- | :---------------------------------------------------------------- |
| `projectName` | `string` |
| `graph` | [`ProjectGraph`](../../devkit/documents/nrwl_devkit#projectgraph) |
| `options` | `Object` |
| `options.helperDependencies?` | `string`[] |
| `options.isProduction?` | `boolean` |
| `options.root?` | `string` |
| `options.target?` | `string` |

#### Returns

`PackageJson`

---

### createProjectGraphAsync

**createProjectGraphAsync**(`opts?`): `Promise`<[`ProjectGraph`](../../devkit/documents/nrwl_devkit#projectgraph)\>
Expand Down
2 changes: 1 addition & 1 deletion docs/generated/packages/jest/documents/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ In order to use Jest's global setup/teardown functions that reference nx librari
Nx provides a helper function that you can import within your setup/teardown file.
```typescript {% fileName="global-setup.ts" %}
import { registerTsProject } from 'nx/src/plugins/js/utils/register';
import { registerTsProject } from '@nrwl/js';
const cleanupRegisteredPaths = registerTsProject('.', 'tsconfig.base.json');
import { yourFancyFunction } from '@some-org/my-util-library';
Expand Down
2 changes: 1 addition & 1 deletion docs/shared/packages/jest/jest-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ In order to use Jest's global setup/teardown functions that reference nx librari
Nx provides a helper function that you can import within your setup/teardown file.
```typescript {% fileName="global-setup.ts" %}
import { registerTsProject } from 'nx/src/plugins/js/utils/register';
import { registerTsProject } from '@nrwl/js';
const cleanupRegisteredPaths = registerTsProject('.', 'tsconfig.base.json');
import { yourFancyFunction } from '@some-org/my-util-library';
Expand Down
4 changes: 2 additions & 2 deletions e2e/jest/src/jest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('Jest', () => {
updateFile(
`libs/${mylib}/setup.ts`,
stripIndents`
const { registerTsProject } = require('nx/src/plugins/js/utils/register');
const { registerTsProject } = require('@nrwl/js');
const cleanup = registerTsProject('.', 'tsconfig.base.json');
import {setup} from '@global-fun/globals';
Expand All @@ -61,7 +61,7 @@ describe('Jest', () => {
updateFile(
`libs/${mylib}/teardown.ts`,
stripIndents`
import { registerTsProject } from 'nx/src/plugins/js/utils/register';
import { registerTsProject } from '@nrwl/js';
const cleanup = registerTsProject('.', 'tsconfig.base.json');
import {teardown} from '@global-fun/globals';
Expand Down
3 changes: 1 addition & 2 deletions e2e/node/src/node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
packageManagerLockFile,
promisifiedTreeKill,
readFile,
readJson,
runCLI,
runCLIAsync,
runCommand,
Expand All @@ -26,7 +25,7 @@ import {
} from '@nrwl/e2e/utils';
import { exec, execSync } from 'child_process';
import * as http from 'http';
import { getLockFileName } from 'nx/src/plugins/js';
import { getLockFileName } from '@nrwl/js';
import { satisfies } from 'semver';

function getData(port, path = '/api'): Promise<any> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type { Schema } from './schema';
import { createTmpTsConfigForBuildableLibs } from '../utilities/buildable-libs';
import { from } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { getRootTsConfigPath } from 'nx/src/plugins/js';
import { getRootTsConfigPath } from '@nrwl/js';

type BuildTargetOptions = {
tsConfig: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Tree } from '@nrwl/devkit';
import { ensureTypescript } from '@nrwl/js/src/utils/typescript/ensure-typescript';
import { findNodes } from 'nx/src/plugins/js';
import { findNodes } from '@nrwl/js';
import type { PropertyAssignment } from 'typescript';

import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
stripIndents,
visitNotIgnoredFiles,
} from '@nrwl/devkit';
import { findNodes } from 'nx/src/plugins/js';
import { findNodes } from '@nrwl/js';
import { extname } from 'path';
import type {
ClassDeclaration,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Tree } from '@nrwl/devkit';
import { findNodes } from 'nx/src/plugins/js';
import { findNodes } from '@nrwl/js';
import { getSourceNodes } from '@nrwl/js';
import type { PropertyDeclaration } from 'typescript';
import { getTsSourceFile } from '../../../utils/nx-devkit/ast-utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/utils/nx-devkit/ast-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type * as ts from 'typescript';
import { findNodes } from 'nx/src/plugins/js';
import { findNodes } from '@nrwl/js';
import {
getImport,
getSourceNodes,
Expand Down
2 changes: 1 addition & 1 deletion packages/devkit/src/utils/module-federation/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
collectWorkspaceLibrarySecondaryEntryPoints,
} from './secondary-entry-points';
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
import { getRootTsConfigPath } from 'nx/src/plugins/js';
import { getRootTsConfigPath } from 'nx/src/plugins/js/utils/typescript';
import type { ProjectGraph } from 'nx/src/config/project-graph';
import { requireNx } from '../../../nx';

Expand Down
2 changes: 1 addition & 1 deletion packages/devkit/src/utils/module-federation/typescript.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { existsSync } from 'fs';
import { ParsedCommandLine } from 'typescript';
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
import { getRootTsConfigPath } from 'nx/src/plugins/js';
import { getRootTsConfigPath } from 'nx/src/plugins/js/utils/typescript';
import { dirname } from 'path';

let tsConfig: ParsedCommandLine;
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-nx/src/resolve-workspace-rules.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TSESLint } from '@typescript-eslint/utils';
import { existsSync } from 'fs';
import { registerTsProject } from 'nx/src/plugins/js/utils/register';
import { registerTsProject } from '@nrwl/js';
import { WORKSPACE_PLUGIN_DIR, WORKSPACE_RULE_NAMESPACE } from './constants';

type ESLintRules = Record<string, TSESLint.RuleModule<string, unknown[]>>;
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-nx/src/rules/nx-plugin-checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@nrwl/devkit';
import { findProject, getSourceFilePath } from '../utils/runtime-lint-utils';
import { existsSync } from 'fs';
import { registerTsProject } from 'nx/src/plugins/js/utils/register';
import { registerTsProject } from '@nrwl/js';
import * as path from 'path';

import { createESLintRule } from '../utils/create-eslint-rule';
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-nx/src/utils/ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
ProjectGraphProjectNode,
readJsonFile,
} from '@nrwl/devkit';
import { findNodes } from 'nx/src/plugins/js';
import { findNodes } from '@nrwl/js';
import { existsSync, readFileSync } from 'fs';
import { dirname } from 'path';
import ts = require('typescript');
Expand Down
5 changes: 1 addition & 4 deletions packages/eslint-plugin-nx/src/utils/runtime-lint-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ import {
findProjectForPath,
ProjectRootMappings,
} from 'nx/src/project-graph/utils/find-project-for-path';
import {
getRootTsConfigFileName,
resolveModuleByImport,
} from 'nx/src/plugins/js';
import { getRootTsConfigFileName, resolveModuleByImport } from '@nrwl/js';

export type Deps = { [projectName: string]: ProjectGraphDependency[] };
type SingleSourceTagConstraint = {
Expand Down
2 changes: 1 addition & 1 deletion packages/expo/src/generators/component/lib/add-import.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { findNodes } from 'nx/src/plugins/js';
import { findNodes } from '@nrwl/js';
import * as ts from 'typescript';
import { ChangeType, StringChange } from '@nrwl/devkit';

Expand Down
18 changes: 16 additions & 2 deletions packages/js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,19 @@ export * from './utils/assets';
export * from './utils/package-json/update-package-json';
export { libraryGenerator } from './generators/library/library';
export { initGenerator } from './generators/init/init';
export { createLockFile } from 'nx/src/plugins/js';
export { createPackageJson } from 'nx/src/plugins/js';

export {
createLockFile,
getLockFileName,
} from 'nx/src/plugins/js/lock-file/lock-file';
export { createPackageJson } from 'nx/src/plugins/js/package-json/create-package-json';
export {
findNodes,
getRootTsConfigPath,
// readTsConfig,
resolveModuleByImport,
} from 'nx/src/plugins/js/utils/typescript';
export {
registerTsProject,
registerTsConfigPaths,
} from 'nx/src/plugins/js/utils/register';
3 changes: 1 addition & 2 deletions packages/js/src/utils/package-json/update-package-json.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createLockFile, getLockFileName } from 'nx/src/plugins/js';
import { createPackageJson } from 'nx/src/plugins/js';
import { createLockFile, getLockFileName, createPackageJson } from '../../';
import {
ExecutorContext,
getOutputsForTargetAndConfiguration,
Expand Down
2 changes: 1 addition & 1 deletion packages/js/src/utils/typescript/ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Tree } from '@nrwl/devkit';
import type * as ts from 'typescript';
// TODO(colum): replace when https://github.com/nrwl/nx/pull/15497 is merged
import { getSourceNodes } from '@nrwl/workspace/src/utilities/typescript';
import { findNodes } from 'nx/src/plugins/js';
import { findNodes } from '../..';
import { ensureTypescript } from './ensure-typescript';

let tsModule: typeof import('typescript');
Expand Down
8 changes: 6 additions & 2 deletions packages/js/src/utils/typescript/ts-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ export function getRelativePathToRootTsConfig(
return offsetFromRoot(targetPath) + getRootTsConfigPathInTree(tree);
}

export function getRootTsConfigFileName(tree: Tree): string | null {
export function getRootTsConfigFileName(tree?: Tree): string | null {
for (const tsConfigName of ['tsconfig.base.json', 'tsconfig.json']) {
if (tree.exists(tsConfigName)) {
const pathExists = tree
? tree.exists(tsConfigName)
: existsSync(join(workspaceRoot, tsConfigName));

if (pathExists) {
return tsConfigName;
}
}
Expand Down
4 changes: 1 addition & 3 deletions packages/next/src/executors/build/build.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
workspaceRoot,
writeJsonFile,
} from '@nrwl/devkit';
import { createLockFile, createPackageJson } from '@nrwl/js';
import { createLockFile, createPackageJson, getLockFileName } from '@nrwl/js';
import build from 'next/dist/build';
import { join, resolve } from 'path';
import { copySync, existsSync, mkdir, writeFileSync } from 'fs-extra';
Expand All @@ -18,8 +18,6 @@ import { createNextConfigFile } from './lib/create-next-config-file';
import { checkPublicDirectory } from './lib/check-project';
import { NextBuildBuilderOptions } from '../../utils/types';

import { getLockFileName } from 'nx/src/plugins/js';

export default async function buildExecutor(
options: NextBuildBuilderOptions,
context: ExecutorContext
Expand Down
5 changes: 4 additions & 1 deletion packages/nx/src/command-line/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import * as yargs from 'yargs';

import * as prettier from 'prettier';
import { sortObjectByKeys } from '../utils/object-sort';
import { getRootTsConfigFileName, getRootTsConfigPath } from '../plugins/js';
import {
getRootTsConfigFileName,
getRootTsConfigPath,
} from '../plugins/js/utils/typescript';
import { createProjectGraphAsync } from '../project-graph/project-graph';
import { filterAffected } from '../project-graph/affected/affected-project-graph';
import { readNxJson } from '../config/configuration';
Expand Down
15 changes: 0 additions & 15 deletions packages/nx/src/devkit-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,18 +225,3 @@ export { Hash, Hasher } from './hasher/hasher';
* @category Utils
*/
export { cacheDir } from './utils/cache-directory';

import { createLockFile as _createLockFile } from './plugins/js';
import { createPackageJson as _createPackageJson } from './plugins/js';

/**
* @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;
Loading

0 comments on commit 3677795

Please sign in to comment.