-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement ng add for store and effects packages #1067
Merged
+1,126
−11
Merged
Changes from 6 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
83e4753
feat(Store): implement ng add
vitaliy-bobrov 1acce75
Merge branch 'master' of github.com:ngrx/platform into HEAD
vitaliy-bobrov 50538c0
Implemented suggested changes.
vitaliy-bobrov 0c9f0fe
Restore BUILD files
vitaliy-bobrov 25d3a3d
Restore BUILD file
vitaliy-bobrov cbd08ed
Restore BUILD files
vitaliy-bobrov 3f0a143
Implemented additional requested changes.
vitaliy-bobrov 1970999
Update source path to reflect changes
vitaliy-bobrov 51f5a64
Update source path to reflect changes
vitaliy-bobrov f9c40c2
Fix store schematics dependency
vitaliy-bobrov 44c4d89
feat(Effects): implement ng add
vitaliy-bobrov 1f91998
Merge branch 'upstream' into ng-add
vitaliy-bobrov 803d000
Effects ng-add implementation.
vitaliy-bobrov 0ad27f8
Fix effects schematics-core path
vitaliy-bobrov 2d51f22
Restore move code
brandonroberts 26a065f
Revert move code change
brandonroberts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/dist | ||
/modules/schematics/src/*/files/* | ||
/modules/**/schematics/**/files/* | ||
/tmp | ||
package-lock.json | ||
package.json | ||
|
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 @@ | ||
export const platformVersion = '^6.0.0'; |
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,27 @@ | ||
import { Tree } from '@angular-devkit/schematics'; | ||
|
||
/** | ||
* Adds a package to the package.json | ||
*/ | ||
export function addPackageToPackageJson( | ||
host: Tree, | ||
type: string, | ||
pkg: string, | ||
version: string | ||
): Tree { | ||
if (host.exists('package.json')) { | ||
const sourceText = host.read('package.json')!.toString('utf-8'); | ||
const json = JSON.parse(sourceText); | ||
if (!json[type]) { | ||
json[type] = {}; | ||
} | ||
|
||
if (!json[type][pkg]) { | ||
json[type][pkg] = version; | ||
} | ||
|
||
host.overwrite('package.json', JSON.stringify(json, null, 2)); | ||
} | ||
|
||
return host; | ||
} |
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 @@ | ||
export const platformVersion = '^6.0.0'; |
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,27 @@ | ||
import { Tree } from '@angular-devkit/schematics'; | ||
|
||
/** | ||
* Adds a package to the package.json | ||
*/ | ||
export function addPackageToPackageJson( | ||
host: Tree, | ||
type: string, | ||
pkg: string, | ||
version: string | ||
): Tree { | ||
if (host.exists('package.json')) { | ||
const sourceText = host.read('package.json')!.toString('utf-8'); | ||
const json = JSON.parse(sourceText); | ||
if (!json[type]) { | ||
json[type] = {}; | ||
} | ||
|
||
if (!json[type][pkg]) { | ||
json[type][pkg] = version; | ||
} | ||
|
||
host.overwrite('package.json', JSON.stringify(json, null, 2)); | ||
} | ||
|
||
return host; | ||
} |
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 @@ | ||
export const platformVersion = '^6.0.0'; |
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,27 @@ | ||
import { Tree } from '@angular-devkit/schematics'; | ||
|
||
/** | ||
* Adds a package to the package.json | ||
*/ | ||
export function addPackageToPackageJson( | ||
host: Tree, | ||
type: string, | ||
pkg: string, | ||
version: string | ||
): Tree { | ||
if (host.exists('package.json')) { | ||
const sourceText = host.read('package.json')!.toString('utf-8'); | ||
const json = JSON.parse(sourceText); | ||
if (!json[type]) { | ||
json[type] = {}; | ||
} | ||
|
||
if (!json[type][pkg]) { | ||
json[type][pkg] = version; | ||
} | ||
|
||
host.overwrite('package.json', JSON.stringify(json, null, 2)); | ||
} | ||
|
||
return host; | ||
} |
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 @@ | ||
export const platformVersion = '^6.0.0'; |
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,27 @@ | ||
import { Tree } from '@angular-devkit/schematics'; | ||
|
||
/** | ||
* Adds a package to the package.json | ||
*/ | ||
export function addPackageToPackageJson( | ||
host: Tree, | ||
type: string, | ||
pkg: string, | ||
version: string | ||
): Tree { | ||
if (host.exists('package.json')) { | ||
const sourceText = host.read('package.json')!.toString('utf-8'); | ||
const json = JSON.parse(sourceText); | ||
if (!json[type]) { | ||
json[type] = {}; | ||
} | ||
|
||
if (!json[type][pkg]) { | ||
json[type][pkg] = version; | ||
} | ||
|
||
host.overwrite('package.json', JSON.stringify(json, null, 2)); | ||
} | ||
|
||
return host; | ||
} |
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 @@ | ||
export const platformVersion = '^6.0.0'; |
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,27 @@ | ||
import { Tree } from '@angular-devkit/schematics'; | ||
|
||
/** | ||
* Adds a package to the package.json | ||
*/ | ||
export function addPackageToPackageJson( | ||
host: Tree, | ||
type: string, | ||
pkg: string, | ||
version: string | ||
): Tree { | ||
if (host.exists('package.json')) { | ||
const sourceText = host.read('package.json')!.toString('utf-8'); | ||
const json = JSON.parse(sourceText); | ||
if (!json[type]) { | ||
json[type] = {}; | ||
} | ||
|
||
if (!json[type][pkg]) { | ||
json[type][pkg] = version; | ||
} | ||
|
||
host.overwrite('package.json', JSON.stringify(json, null, 2)); | ||
} | ||
|
||
return host; | ||
} |
File renamed without changes.
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 @@ | ||
export const platformVersion = '^6.0.0'; |
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,27 @@ | ||
import { Tree } from '@angular-devkit/schematics'; | ||
|
||
/** | ||
* Adds a package to the package.json | ||
*/ | ||
export function addPackageToPackageJson( | ||
host: Tree, | ||
type: string, | ||
pkg: string, | ||
version: string | ||
): Tree { | ||
if (host.exists('package.json')) { | ||
const sourceText = host.read('package.json')!.toString('utf-8'); | ||
const json = JSON.parse(sourceText); | ||
if (!json[type]) { | ||
json[type] = {}; | ||
} | ||
|
||
if (!json[type][pkg]) { | ||
json[type][pkg] = version; | ||
} | ||
|
||
host.overwrite('package.json', JSON.stringify(json, null, 2)); | ||
} | ||
|
||
return host; | ||
} |
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 @@ | ||
export const platformVersion = '^6.0.0'; |
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,27 @@ | ||
import { Tree } from '@angular-devkit/schematics'; | ||
|
||
/** | ||
* Adds a package to the package.json | ||
*/ | ||
export function addPackageToPackageJson( | ||
host: Tree, | ||
type: string, | ||
pkg: string, | ||
version: string | ||
): Tree { | ||
if (host.exists('package.json')) { | ||
const sourceText = host.read('package.json')!.toString('utf-8'); | ||
const json = JSON.parse(sourceText); | ||
if (!json[type]) { | ||
json[type] = {}; | ||
} | ||
|
||
if (!json[type][pkg]) { | ||
json[type][pkg] = version; | ||
} | ||
|
||
host.overwrite('package.json', JSON.stringify(json, null, 2)); | ||
} | ||
|
||
return host; | ||
} |
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,33 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be added to the |
||
|
||
load("//tools:defaults.bzl", "ts_library", "npm_package") | ||
|
||
ts_library( | ||
name = "schematics", | ||
srcs = glob( | ||
[ | ||
"**/*.ts", | ||
], | ||
exclude = [ | ||
"**/*.spec.ts", | ||
"**/files/**/*", | ||
], | ||
), | ||
module_name = "@ngrx/store/schematics", | ||
deps = [ | ||
"//modules/schematics/schematics-core", | ||
], | ||
) | ||
|
||
npm_package( | ||
name = "npm_package", | ||
srcs = [ | ||
":collection.json", | ||
] + glob([ | ||
"**/files/**/*", | ||
"**/schema.json", | ||
]), | ||
deps = [ | ||
":schematics", | ||
], | ||
) |
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,10 @@ | ||
{ | ||
"schematics": { | ||
"ng-add": { | ||
"aliases": ["init"], | ||
"factory": "./ng-add", | ||
"schema": "./ng-add/schema.json", | ||
"description": "Adds initial setup for state managment" | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
modules/store/schematics/ng-add/files/__path__/__statePath__/index.ts
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,19 @@ | ||
import { | ||
ActionReducer, | ||
ActionReducerMap, | ||
createFeatureSelector, | ||
createSelector, | ||
MetaReducer | ||
} from '@ngrx/store'; | ||
import { environment } from '<%= environmentsPath %>'; | ||
|
||
export interface <%= classify(stateInterface) %> { | ||
|
||
} | ||
|
||
export const reducers: ActionReducerMap<<%= classify(stateInterface) %>> = { | ||
|
||
}; | ||
|
||
|
||
export const metaReducers: MetaReducer<<%= classify(stateInterface) %>>[] = !environment.production ? [] : []; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this replacement to
/tools/default.bzl