-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add ng update support to ngrx packages (#1053)
Also adds a `schematics-core` and `migrations` build to each package
- Loading branch information
1 parent
92c13fd
commit 4f91e9e
Showing
122 changed files
with
12,391 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as tasks from './tasks'; | ||
import { createBuilder } from './util'; | ||
import { packages } from './config'; | ||
|
||
const copySchematics = createBuilder([ | ||
['Copy Schematics Core Files', tasks.copySchematicsCore], | ||
]); | ||
|
||
copySchematics({ | ||
scope: '@ngrx', | ||
packages, | ||
}).catch(err => { | ||
console.error(err); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Tree } from '@angular-devkit/schematics'; | ||
import { | ||
SchematicTestRunner, | ||
UnitTestTree, | ||
} from '@angular-devkit/schematics/testing'; | ||
import * as path from 'path'; | ||
import { | ||
createPackageJson, | ||
packagePath, | ||
} from '../../../schematics-core/testing/create-package'; | ||
import { | ||
upgradeVersion, | ||
versionPrefixes, | ||
} from '../../../schematics-core/testing/update'; | ||
|
||
const collectionPath = path.join(__dirname, '../migration.json'); | ||
|
||
describe('Effects Migration 6_0_0', () => { | ||
let appTree; | ||
const pkgName = 'effects'; | ||
|
||
versionPrefixes.forEach(prefix => { | ||
it(`should install version ${prefix}6.0.0`, () => { | ||
appTree = new UnitTestTree(Tree.empty()); | ||
const runner = new SchematicTestRunner('schematics', collectionPath); | ||
const tree = createPackageJson(prefix, pkgName, appTree); | ||
|
||
const newTree = runner.runSchematic( | ||
`ngrx-${pkgName}-migration-01`, | ||
{}, | ||
tree | ||
); | ||
const pkg = JSON.parse(newTree.readContent(packagePath)); | ||
expect(pkg.dependencies[`@ngrx/${pkgName}`]).toBe( | ||
`${prefix}${upgradeVersion}` | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Rule } from '@angular-devkit/schematics'; | ||
import { updatePackage } from '@ngrx/effects/schematics-core'; | ||
|
||
export default function(): Rule { | ||
return updatePackage('effects'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load("//tools:defaults.bzl", "ts_library") | ||
load("//tools:defaults.bzl", "npm_package") | ||
|
||
ts_library( | ||
name = "migrations", | ||
srcs = glob( | ||
[ | ||
"**/*.ts", | ||
], | ||
exclude = [ | ||
"**/testing/*.ts", | ||
"**/*.spec.ts", | ||
], | ||
), | ||
module_name = "@ngrx/effects/migrations", | ||
deps = [ | ||
"//modules/effects/schematics-core", | ||
], | ||
) | ||
|
||
npm_package( | ||
name = "npm_package", | ||
srcs = [ | ||
":migration.json", | ||
], | ||
deps = [ | ||
":migrations", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": | ||
"../../../node_modules/@angular-devkit/schematics/collection-schema.json", | ||
"schematics": { | ||
"ngrx-effects-migration-01": { | ||
"description": "The road to v6", | ||
"version": "5.2", | ||
"factory": "./6_0_0/index" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load("//tools:defaults.bzl", "ts_library") | ||
load("//tools:defaults.bzl", "npm_package") | ||
|
||
ts_library( | ||
name = "schematics-core", | ||
srcs = glob( | ||
[ | ||
"**/*.ts", | ||
], | ||
exclude = [ | ||
"**/testing/**/*.ts", | ||
"**/*spec.ts", | ||
], | ||
), | ||
module_name = "@ngrx/effects/schematics-core", | ||
) | ||
|
||
npm_package( | ||
name = "npm_package", | ||
srcs = [], | ||
deps = [ | ||
":schematics-core", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { | ||
dasherize, | ||
decamelize, | ||
camelize, | ||
classify, | ||
underscore, | ||
group, | ||
capitalize, | ||
featurePath, | ||
} from './utility/strings'; | ||
|
||
export { | ||
findNodes, | ||
getSourceNodes, | ||
getDecoratorMetadata, | ||
getContentOfKeyLiteral, | ||
insertAfterLastOccurrence, | ||
addBootstrapToModule, | ||
addDeclarationToModule, | ||
addExportToModule, | ||
addImportToModule, | ||
addProviderToModule, | ||
} from './utility/ast-utils'; | ||
|
||
export { | ||
Host, | ||
Change, | ||
NoopChange, | ||
InsertChange, | ||
RemoveChange, | ||
ReplaceChange, | ||
} from './utility/change'; | ||
|
||
export { | ||
AppConfig, | ||
CliConfig, | ||
getAppFromConfig, | ||
getConfig, | ||
getWorkspace, | ||
getWorkspacePath, | ||
} from './utility/config'; | ||
|
||
export { | ||
findModule, | ||
findModuleFromOptions, | ||
buildRelativePath, | ||
ModuleOptions, | ||
} from './utility/find-module'; | ||
|
||
export { | ||
addReducerToState, | ||
addReducerToStateInferface, | ||
addReducerImportToNgModule, | ||
addReducerToActionReducerMap, | ||
omit, | ||
} from './utility/ngrx-utils'; | ||
|
||
export { getProjectPath } from './utility/project'; | ||
export { insertImport } from './utility/route-utils'; | ||
|
||
export const stringUtils = { | ||
dasherize, | ||
decamelize, | ||
camelize, | ||
classify, | ||
underscore, | ||
group, | ||
capitalize, | ||
featurePath, | ||
}; | ||
|
||
export { updatePackage } from './utility/update'; |
Oops, something went wrong.