Skip to content

Commit

Permalink
feat(core): introduce nx import
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Jul 9, 2024
1 parent 4c76b95 commit ebf8ad0
Show file tree
Hide file tree
Showing 15 changed files with 817 additions and 47 deletions.
54 changes: 54 additions & 0 deletions docs/generated/cli/import.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: 'import - CLI command'
description: 'Import another project into the workspace'
---

# import

Import another project into the workspace

## Usage

```shell
nx import [sourceRemoteUrl] [destination]
```

Install `nx` globally to invoke the command directly using `nx`, or use `npx nx`, `yarn nx`, or `pnpm nx`.

## Options

### destination

Type: `string`

The destination in the current workspace

### help

Type: `boolean`

Show help

### ref

Type: `string`

The branch to import

### sourceRemoteUrl

Type: `string`

The remote URL of the source to import

### verbose

Type: `boolean`

Prints additional information about the commands (e.g., stack traces)

### version

Type: `boolean`

Show version number
8 changes: 8 additions & 0 deletions docs/generated/manifests/menus.json
Original file line number Diff line number Diff line change
Expand Up @@ -8544,6 +8544,14 @@
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "import",
"path": "/nx-api/nx/documents/import",
"id": "import",
"isExternal": false,
"children": [],
"disableCollapsible": false
}
],
"isExternal": false,
Expand Down
11 changes: 11 additions & 0 deletions docs/generated/manifests/nx-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -1949,6 +1949,17 @@
"path": "/nx-api/nx/documents/add",
"tags": [],
"originalFilePath": "generated/cli/add"
},
"/nx-api/nx/documents/import": {
"id": "import",
"name": "import",
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
"file": "generated/packages/nx/documents/import",
"itemList": [],
"isExternal": false,
"path": "/nx-api/nx/documents/import",
"tags": [],
"originalFilePath": "generated/cli/import"
}
},
"root": "/packages/nx",
Expand Down
11 changes: 11 additions & 0 deletions docs/generated/packages-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -1928,6 +1928,17 @@
"path": "nx/documents/add",
"tags": [],
"originalFilePath": "generated/cli/add"
},
{
"id": "import",
"name": "import",
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
"file": "generated/packages/nx/documents/import",
"itemList": [],
"isExternal": false,
"path": "nx/documents/import",
"tags": [],
"originalFilePath": "generated/cli/import"
}
],
"executors": [
Expand Down
54 changes: 54 additions & 0 deletions docs/generated/packages/nx/documents/import.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: 'import - CLI command'
description: 'Import another project into the workspace'
---

# import

Import another project into the workspace

## Usage

```shell
nx import [sourceRemoteUrl] [destination]
```

Install `nx` globally to invoke the command directly using `nx`, or use `npx nx`, `yarn nx`, or `pnpm nx`.

## Options

### destination

Type: `string`

The destination in the current workspace

### help

Type: `boolean`

Show help

### ref

Type: `string`

The branch to import

### sourceRemoteUrl

Type: `string`

The remote URL of the source to import

### verbose

Type: `boolean`

Prints additional information about the commands (e.g., stack traces)

### version

Type: `boolean`

Show version number
5 changes: 5 additions & 0 deletions docs/map.json
Original file line number Diff line number Diff line change
Expand Up @@ -2075,6 +2075,11 @@
"name": "add",
"id": "add",
"file": "generated/cli/add"
},
{
"name": "import",
"id": "import",
"file": "generated/cli/import"
}
]
},
Expand Down
1 change: 1 addition & 0 deletions docs/shared/reference/sitemap.md
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@
- [view-logs](/nx-api/nx/documents/view-logs)
- [release](/nx-api/nx/documents/release)
- [add](/nx-api/nx/documents/add)
- [import](/nx-api/nx/documents/import)
- [executors](/nx-api/nx/executors)
- [noop](/nx-api/nx/executors/noop)
- [run-commands](/nx-api/nx/executors/run-commands)
Expand Down
39 changes: 39 additions & 0 deletions packages/nx/src/command-line/import/command-object.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Arguments, CommandModule, MiddlewareFunction } from 'yargs';
import { linkToNxDevAndExamples } from '../yargs-utils/documentation';
import { withVerbose } from '../yargs-utils/shared-options';
import { handleErrors } from '../../utils/params';
import type { ImportOptions } from './import';

export const yargsImportCommand: CommandModule = {
command: 'import [sourceRemoteUrl] [destination]',
describe: 'Import another project into the workspace',
builder: (yargs) =>
linkToNxDevAndExamples(
withVerbose(
yargs
.positional('sourceRemoteUrl', {
type: 'string',
description: 'The remote URL of the source to import',
})
.positional('destination', {
type: 'string',
description: 'The destination in the current workspace',
})
.option('ref', {
type: 'string',
description: 'The branch to import',
})
.requiresArg('ref')
),
'import'
),
handler: async (args) => {
const exitCode = await handleErrors(
(args.verbose as boolean) ?? process.env.NX_VERBOSE_LOGGING === 'true',
async () => {
return (await import('./import')).importHandler(args as any);
}
);
process.exit(exitCode);
},
};
Loading

0 comments on commit ebf8ad0

Please sign in to comment.