Skip to content

Commit

Permalink
fix(nx): add migrate packages
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed Sep 26, 2019
1 parent 1edb44a commit 5bb12dc
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 33 deletions.
17 changes: 9 additions & 8 deletions docs/angular/api-workspace/npmscripts/migrate.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# migrate
# migrate
Creates a migrations file or runs migrations from the migrations file.

Creates a migrations file or runs migrations from the migrations file.
- Migrate packages and create migrations.json (e.g., nx migrate @nrwl/workspace@latest)
- Run migrations (e.g., nx migrate --run-migrations=migrations.json)

## Usage
## Usage
```bash
nx migrate
```

```bash
nx migrate
```

Install `@nrwl/cli` globally to invoke the command directly using `nx`, or use `npm run nx` or `yarn nx`.
Install `@nrwl/cli` globally to invoke the command directly using `nx`, or use `npm run nx` or `yarn nx`.

## Options

Expand Down
17 changes: 9 additions & 8 deletions docs/react/api-workspace/npmscripts/migrate.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# migrate
# migrate
Creates a migrations file or runs migrations from the migrations file.

Creates a migrations file or runs migrations from the migrations file.
- Migrate packages and create migrations.json (e.g., nx migrate @nrwl/workspace@latest)
- Run migrations (e.g., nx migrate --run-migrations=migrations.json)

## Usage
## Usage
```bash
nx migrate
```

```bash
nx migrate
```

Install `@nrwl/cli` globally to invoke the command directly using `nx`, or use `npm run nx` or `yarn nx`.
Install `@nrwl/cli` globally to invoke the command directly using `nx`, or use `npm run nx` or `yarn nx`.

## Options

Expand Down
17 changes: 9 additions & 8 deletions docs/web/api-workspace/npmscripts/migrate.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# migrate
# migrate
Creates a migrations file or runs migrations from the migrations file.

Creates a migrations file or runs migrations from the migrations file.
- Migrate packages and create migrations.json (e.g., nx migrate @nrwl/workspace@latest)
- Run migrations (e.g., nx migrate --run-migrations=migrations.json)

## Usage
## Usage
```bash
nx migrate
```

```bash
nx migrate
```

Install `@nrwl/cli` globally to invoke the command directly using `nx`, or use `npm run nx` or `yarn nx`.
Install `@nrwl/cli` globally to invoke the command directly using `nx`, or use `npm run nx` or `yarn nx`.

## Options

Expand Down
6 changes: 4 additions & 2 deletions packages/tao/src/commands/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ async function fetch(
let migrationsFile = json['nx-migrations'] || json['ng-update'];

// migrationsFile is an object
if (migrationsFile.migration) {
migrationsFile = migrationsFile.migration;
if (migrationsFile && migrationsFile.migrations) {
migrationsFile = migrationsFile.migrations;
}

// packageVersion can be a tag, resolvedVersion works with semver
Expand Down Expand Up @@ -357,6 +357,8 @@ async function generateMigrationsJsonAndUpdatePackageJson(
to: { [p: string]: string };
}
) {
logger.info(`Fetching meta data about packages.`);
logger.info(`It may take a few minutes.`);
const migrator = new Migrator({
versions: versions(root),
fetch,
Expand Down
4 changes: 4 additions & 0 deletions packages/tao/src/compat/compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ Module.prototype.require = function() {
try {
require('@angular-devkit/build-angular/src/utils/version').Version.assertCompatibleAngularVersion = () => {};
} catch (e) {}

try {
require('@angular-devkit/build-angular/src/utils/version').assertCompatibleAngularVersion = () => {};
} catch (e) {}
108 changes: 108 additions & 0 deletions packages/workspace/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,113 @@
"description": "Fix the exclude paths in tsconfig.lib.json files for Jest projects",
"factory": "./src/migrations/update-8-5-0/fix-tsconfig-lib-json"
}
},
"packageJsonUpdates": {
"852": {
"version": "8.5.2",
"packages": {
"@nrwl/angular": {
"version": "8.5.2",
"alwaysAddToPackageJson": false
},
"@nrwl/cypress": {
"version": "8.5.2",
"alwaysAddToPackageJson": false
},
"@nrwl/eslint-plugin-nx": {
"version": "8.5.2",
"alwaysAddToPackageJson": false
},
"@nrwl/express": {
"version": "8.5.2",
"alwaysAddToPackageJson": false
},
"@nrwl/jest": {
"version": "8.5.2",
"alwaysAddToPackageJson": false
},
"@nrwl/linter": {
"version": "8.5.2",
"alwaysAddToPackageJson": false
},
"@nrwl/nest": {
"version": "8.5.2",
"alwaysAddToPackageJson": false
},
"@nrwl/next": {
"version": "8.5.2",
"alwaysAddToPackageJson": false
},
"@nrwl/node": {
"version": "8.5.2",
"alwaysAddToPackageJson": false
},
"@nrwl/react": {
"version": "8.5.2",
"alwaysAddToPackageJson": false
},
"@nrwl/tao": {
"version": "8.5.2",
"alwaysAddToPackageJson": false
},
"@nrwl/web": {
"version": "8.5.2",
"alwaysAddToPackageJson": false
}
}
},
"853": {
"version": "8.5.3",
"packages": {
"@nrwl/angular": {
"version": "8.5.3",
"alwaysAddToPackageJson": false
},
"@nrwl/cypress": {
"version": "8.5.3",
"alwaysAddToPackageJson": false
},
"@nrwl/eslint-plugin-nx": {
"version": "8.5.3",
"alwaysAddToPackageJson": false
},
"@nrwl/express": {
"version": "8.5.3",
"alwaysAddToPackageJson": false
},
"@nrwl/jest": {
"version": "8.5.3",
"alwaysAddToPackageJson": false
},
"@nrwl/linter": {
"version": "8.5.3",
"alwaysAddToPackageJson": false
},
"@nrwl/nest": {
"version": "8.5.3",
"alwaysAddToPackageJson": false
},
"@nrwl/next": {
"version": "8.5.3",
"alwaysAddToPackageJson": false
},
"@nrwl/node": {
"version": "8.5.3",
"alwaysAddToPackageJson": false
},
"@nrwl/react": {
"version": "8.5.3",
"alwaysAddToPackageJson": false
},
"@nrwl/tao": {
"version": "8.5.3",
"alwaysAddToPackageJson": false
},
"@nrwl/web": {
"version": "8.5.3",
"alwaysAddToPackageJson": false
}
}
}
}
}
19 changes: 12 additions & 7 deletions packages/workspace/src/command-line/nx-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { workspaceSchematic } from './workspace-schematic';
import { generateGraph, OutputType } from './dep-graph';
import { nxVersion } from '../utils/versions';
import { execSync } from 'child_process';
import { platform } from 'os';

const noop = (yargs: yargs.Argv): yargs.Argv => yargs;

Expand Down Expand Up @@ -182,15 +183,19 @@ export const commandsObject = yargs
)
.command(
'migrate',
'Creates a migrations file or runs migrations from the migrations file.',
`Creates a migrations file or runs migrations from the migrations file.
- Migrate packages and create migrations.json (e.g., nx migrate @nrwl/workspace@latest)
- Run migrations (e.g., nx migrate --run-migrations=migrations.json)
`,
yargs => yargs,
() => {
execSync(
`./node_modules/.bin/tao migrate ${process.argv.slice(3).join(' ')}`,
{
stdio: ['inherit', 'inherit', 'inherit']
}
);
const executable =
platform() === 'win32'
? `.\\node_modules\\.bin\\tao`
: `./node_modules/.bin/tao`;
execSync(`${executable} migrate ${process.argv.slice(3).join(' ')}`, {
stdio: ['inherit', 'inherit', 'inherit']
});
}
)
.help('help')
Expand Down

0 comments on commit 5bb12dc

Please sign in to comment.