Skip to content

Commit

Permalink
feat(core): make nx.json optional
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed May 31, 2022
1 parent b35e383 commit e491c6f
Show file tree
Hide file tree
Showing 156 changed files with 711 additions and 1,479 deletions.
4 changes: 2 additions & 2 deletions dep-graph/client/project.json
Expand Up @@ -89,7 +89,7 @@
}
},
"serve": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"outputs": [],
"options": {
"commands": [
Expand All @@ -113,7 +113,7 @@
}
},
"serve-for-e2e": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"outputs": [],
"options": {
"commands": [
Expand Down
16 changes: 16 additions & 0 deletions docs/generated/cli/init.md
@@ -0,0 +1,16 @@
---
title: 'init - CLI command'
description: 'Adds nx.json file and installs nx if not installed already'
---

# init

Adds nx.json file and installs nx if not installed already

## Usage

```bash
nx init
```

[Install `nx` globally](/getting-started/nx-setup#install-nx) to invoke the command directly using `nx`, or use `npx nx`, `yarn nx`, or `pnpx nx`.
50 changes: 29 additions & 21 deletions docs/generated/devkit/index.md
Expand Up @@ -76,12 +76,12 @@ It only uses language primitives and immutable objects
- [NxAffectedConfig](../../devkit/index#nxaffectedconfig)
- [NxJsonConfiguration](../../devkit/index#nxjsonconfiguration)
- [ProjectConfiguration](../../devkit/index#projectconfiguration)
- [ProjectsConfigurations](../../devkit/index#projectsconfigurations)
- [TargetConfiguration](../../devkit/index#targetconfiguration)
- [TargetDependencyConfig](../../devkit/index#targetdependencyconfig)
- [Task](../../devkit/index#task)
- [TaskGraph](../../devkit/index#taskgraph)
- [Workspace](../../devkit/index#workspace)
- [WorkspaceJsonConfiguration](../../devkit/index#workspacejsonconfiguration)

### Generators Type aliases

Expand Down Expand Up @@ -112,6 +112,7 @@ It only uses language primitives and immutable objects
- [ImplicitDependencyEntry](../../devkit/index#implicitdependencyentry)
- [ProjectType](../../devkit/index#projecttype)
- [TaskGraphExecutor](../../devkit/index#taskgraphexecutor)
- [WorkspaceJsonConfiguration](../../devkit/index#workspacejsonconfiguration)

### Logger Variables

Expand Down Expand Up @@ -151,6 +152,7 @@ It only uses language primitives and immutable objects
- [offsetFromRoot](../../devkit/index#offsetfromroot)
- [parseJson](../../devkit/index#parsejson)
- [parseTargetString](../../devkit/index#parsetargetstring)
- [readAllWorkspaceConfiguration](../../devkit/index#readallworkspaceconfiguration)
- [readCachedProjectGraph](../../devkit/index#readcachedprojectgraph)
- [readJson](../../devkit/index#readjson)
- [readJsonFile](../../devkit/index#readjsonfile)
Expand Down Expand Up @@ -424,6 +426,12 @@ A plugin for Nx

---

### ProjectsConfigurations

**ProjectsConfigurations**: `Object`

---

### TargetConfiguration

**TargetConfiguration**: `Object`
Expand Down Expand Up @@ -452,17 +460,11 @@ A plugin for Nx

**Workspace**: `Object`

---

### WorkspaceJsonConfiguration

**WorkspaceJsonConfiguration**: `Object`

## Generators Type aliases

### WorkspaceConfiguration

Ƭ **WorkspaceConfiguration**: `Omit`<[`WorkspaceJsonConfiguration`](../../devkit/index#workspacejsonconfiguration), `"projects"`\> & `Partial`<[`NxJsonConfiguration`](../../devkit/index#nxjsonconfiguration)\>
Ƭ **WorkspaceConfiguration**: `Omit`<[`ProjectsConfigurations`](../../devkit/index#projectsconfigurations), `"projects"`\> & `Partial`<[`NxJsonConfiguration`](../../devkit/index#nxjsonconfiguration)\>

---

Expand Down Expand Up @@ -666,6 +668,12 @@ Implementation of a target of a project that handles multiple projects to be bat

`Promise`<`Record`<`string`, `Object`\>\>

---

### WorkspaceJsonConfiguration

Ƭ **WorkspaceJsonConfiguration**: [`ProjectsConfigurations`](../../devkit/index#projectsconfigurations)

## Logger Variables

### logger
Expand All @@ -689,7 +697,7 @@ Implementation of a target of a project that handles multiple projects to be bat

### appRootPath

**appRootPath**: `string`
**appRootPath**: `string` = `workspaceRoot`

---

Expand All @@ -707,7 +715,7 @@ Implementation of a target of a project that handles multiple projects to be bat

### workspaceRoot

**workspaceRoot**: `string` = `appRootPath`
**workspaceRoot**: `string`

## Functions

Expand Down Expand Up @@ -1357,6 +1365,16 @@ parseTargetString('proj:test:production'); // returns { project: "proj", target:

---

### readAllWorkspaceConfiguration

**readAllWorkspaceConfiguration**(): [`ProjectsConfigurations`](../../devkit/index#projectsconfigurations) & [`NxJsonConfiguration`](../../devkit/index#nxjsonconfiguration)

#### Returns

[`ProjectsConfigurations`](../../devkit/index#projectsconfigurations) & [`NxJsonConfiguration`](../../devkit/index#nxjsonconfiguration)

---

### readCachedProjectGraph

**readCachedProjectGraph**(): [`ProjectGraph`](../../devkit/index#projectgraph)
Expand Down Expand Up @@ -1426,17 +1444,7 @@ Object the JSON content of the file represents

### readNxJson

**readNxJson**(`path?`): [`NxJsonConfiguration`](../../devkit/index#nxjsonconfiguration)

Returns the contents of nx.json.

If nx.json extends another config file, it will be inlined here.

#### Parameters

| Name | Type |
| :----- | :------- |
| `path` | `string` |
**readNxJson**(): [`NxJsonConfiguration`](../../devkit/index#nxjsonconfiguration)

#### Returns

Expand Down
6 changes: 6 additions & 0 deletions docs/generated/packages/cli.json
Expand Up @@ -11,6 +11,12 @@
"file": "generated/cli/create-nx-workspace",
"content": "---\ntitle: 'create-nx-workspace - CLI command'\ndescription: 'Create a new Nx workspace'\n---\n\n# create-nx-workspace\n\nCreate a new Nx workspace\n\n## Usage\n\n```bash\ncreate-nx-workspace [name] [options]\n```\n\nInstall `create-nx-workspace` globally to invoke the command directly, or use `npx create-nx-workspace`, `yarn create nx-workspace`, or `pnpx create-nx-workspace`.\n\n## Options\n\n### allPrompts\n\nType: boolean\n\nDefault: false\n\nShow all prompts\n\n### appName\n\nType: string\n\nThe name of the application when a preset with pregenerated app is selected\n\n### ci\n\nType: string\n\nChoices: [github, circleci, azure]\n\nGenerate a CI workflow file\n\n### cli\n\nType: string\n\nChoices: [nx, angular]\n\nCLI to power the Nx workspace\n\n### defaultBase\n\nType: string\n\nDefault: main\n\nDefault base to use for new projects\n\n### help\n\nType: boolean\n\nShow help\n\n### interactive\n\nType: boolean\n\nEnable interactive mode with presets\n\n### name\n\nType: string\n\nWorkspace name (e.g. org name)\n\n### nxCloud\n\nType: boolean\n\nUse Nx Cloud\n\n### packageManager\n\nType: string\n\nChoices: [npm, pnpm, yarn]\n\nDefault: npm\n\nPackage manager to use\n\n### preset\n\nType: string\n\nCustomizes the initial content of your workspace. Default presets include: [\"apps\", \"empty\", \"core\", \"npm\", \"ts\", \"web-components\", \"angular\", \"angular-nest\", \"react\", \"react-express\", \"react-native\", \"next\", \"nest\", \"express\"]. To build your own see https://nx.dev/packages/nx-plugin#preset\n\n### style\n\nType: string\n\nStyle option to be used when a preset with pregenerated app is selected\n\n### version\n\nType: boolean\n\nShow version number\n"
},
{
"name": "init",
"id": "init",
"file": "generated/cli/init",
"content": "---\ntitle: 'init - CLI command'\ndescription: 'Adds nx.json file and installs nx if not installed already'\n---\n\n# init\n\nAdds nx.json file and installs nx if not installed already\n\n## Usage\n\n```bash\nnx init\n```\n\n[Install `nx` globally](/getting-started/nx-setup#install-nx) to invoke the command directly using `nx`, or use `npx nx`, `yarn nx`, or `pnpx nx`.\n"
},
{
"name": "generate",
"id": "generate",
Expand Down
2 changes: 1 addition & 1 deletion docs/generated/packages/devkit.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/map.json
Expand Up @@ -870,6 +870,7 @@
"id": "create-nx-workspace",
"file": "generated/cli/create-nx-workspace"
},
{ "name": "init", "id": "init", "file": "generated/cli/init" },
{
"name": "generate",
"id": "generate",
Expand Down
1 change: 0 additions & 1 deletion docs/shared/nx-core.md
Expand Up @@ -42,7 +42,6 @@ package.json
```json
{
"extends": "nx/presets/core.json",
"npmScope": "myorg",
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
Expand Down
2 changes: 1 addition & 1 deletion e2e/add-nx-to-monorepo/project.json
Expand Up @@ -4,7 +4,7 @@
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
{
Expand Down
15 changes: 15 additions & 0 deletions e2e/add-nx-to-monorepo/src/add-nx-to-monorepo.test.ts
Expand Up @@ -23,12 +23,20 @@ describe('add-nx-to-monorepo', () => {
'packages/package-a/package.json',
JSON.stringify({
name: 'package-a',
scripts: {
serve: 'some serve',
build: 'some build',
test: 'some test',
},
})
);
updateFile(
'packages/package-b/package.json',
JSON.stringify({
name: 'package-b',
scripts: {
lint: 'some lint',
},
})
);

Expand All @@ -40,6 +48,13 @@ describe('add-nx-to-monorepo', () => {
expect(output).toContain('🎉 Done!');
expect(readWorkspaceConfig().projects['package-a']).toBeTruthy();
expect(readWorkspaceConfig().projects['package-b']).toBeTruthy();
expect(readWorkspaceConfig().targetDependencies).toEqual({
build: [{ projects: 'dependencies', target: 'build' }],
});
expect(
readWorkspaceConfig().tasksRunnerOptions['default'].options
.cacheableOperations
).toEqual(['build', 'test', 'lint']);
}
});

Expand Down
2 changes: 1 addition & 1 deletion e2e/angular-core/project.json
Expand Up @@ -4,7 +4,7 @@
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
{
Expand Down
2 changes: 1 addition & 1 deletion e2e/angular-extensions/project.json
Expand Up @@ -4,7 +4,7 @@
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
{
Expand Down
2 changes: 1 addition & 1 deletion e2e/cli/project.json
Expand Up @@ -4,7 +4,7 @@
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
{
Expand Down
2 changes: 1 addition & 1 deletion e2e/cypress/project.json
Expand Up @@ -4,7 +4,7 @@
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
{
Expand Down
2 changes: 1 addition & 1 deletion e2e/detox/project.json
Expand Up @@ -4,7 +4,7 @@
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
{
Expand Down
2 changes: 1 addition & 1 deletion e2e/jest/project.json
Expand Up @@ -4,7 +4,7 @@
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
{
Expand Down
2 changes: 1 addition & 1 deletion e2e/js/project.json
Expand Up @@ -4,7 +4,7 @@
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
{
Expand Down
2 changes: 1 addition & 1 deletion e2e/linter/project.json
Expand Up @@ -4,7 +4,7 @@
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
{
Expand Down
2 changes: 1 addition & 1 deletion e2e/next/project.json
Expand Up @@ -4,7 +4,7 @@
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
{
Expand Down
2 changes: 1 addition & 1 deletion e2e/node/project.json
Expand Up @@ -4,7 +4,7 @@
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
{
Expand Down
10 changes: 10 additions & 0 deletions e2e/nx-init/jest.config.ts
@@ -0,0 +1,10 @@
export default {
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
displayName: 'e2e-nx-init',
preset: '../../jest.preset.js',
};
34 changes: 34 additions & 0 deletions e2e/nx-init/project.json
@@ -0,0 +1,34 @@
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "e2e/nx-init",
"projectType": "application",
"targets": {
"e2e": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "yarn e2e-start-local-registry"
},
{
"command": "yarn e2e-build-package-publish"
},
{
"command": "nx run-e2e-tests e2e-nx-init"
}
],
"parallel": false
}
},
"run-e2e-tests": {
"executor": "@nrwl/jest:jest",
"options": {
"jestConfig": "e2e/nx-init/jest.config.ts",
"passWithNoTests": true,
"runInBand": true
},
"outputs": ["coverage/e2e/nx-init"]
}
},
"implicitDependencies": ["nx"]
}

1 comment on commit e491c6f

@vercel
Copy link

@vercel vercel bot commented on e491c6f May 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-five.vercel.app
nx.dev
nx-dev-git-master-nrwl.vercel.app
nx-dev-nrwl.vercel.app

Please sign in to comment.