Skip to content

Commit

Permalink
feat: Add ng update support to ngrx packages
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonroberts committed May 11, 2018
1 parent fb662c1 commit dc31a1d
Show file tree
Hide file tree
Showing 158 changed files with 717 additions and 2,646 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,6 @@ tmp

example-dist/

*.tgz
*.tgz
modules/*/schematics-core/testing
!modules/schematics-core/testing
2 changes: 1 addition & 1 deletion build/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface Config {
scope: string;
}

const modulesDir = './modules/';
export const modulesDir = './modules/';
export const packages: PackageDescription[] = fs
.readdirSync(modulesDir)
.filter(path => {
Expand Down
15 changes: 15 additions & 0 deletions build/copy-schematics-core.ts
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);
});
31 changes: 30 additions & 1 deletion build/tasks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
import { Config } from './config';
import { Config, modulesDir } from './config';
import * as util from './util';
import * as fs from 'fs';
import { ncp } from 'ncp';

/**
*
* Copies the schematics-core package into any package that provides
* schematics or migrations
*/
export async function copySchematicsCore(config: Config) {
(ncp as any).limit = 1;
for (let pkg of util.getTopLevelPackages(config)) {
const packageJson = fs
.readFileSync(`${modulesDir}${pkg}/package.json`)
.toString('utf-8');
const pkgConfig = JSON.parse(packageJson);

if (pkgConfig.schematics || pkgConfig['ng-update'].migrations) {
ncp(
`${modulesDir}/schematics-core`,
`${modulesDir}/${pkg}/schematics-core`,
function(err: any) {
if (err) {
return console.error(err);
}
}
);
}
}
}

/**
* Deploy build artifacts to repos
Expand Down
4 changes: 4 additions & 0 deletions modules/effects/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ ng_package(
":effects",
"//modules/effects/testing",
],
packages = [
"//modules/effects/migrations:npm_package",
"//modules/effects/schematics-core:npm_package",
],
)
2 changes: 1 addition & 1 deletion modules/effects/migrations/6_0_0/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Rule } from '@angular-devkit/schematics';
import { updatePackage } from '../../src/schematics-core';
import { updatePackage } from '@ngrx/effects/schematics-core';

export default function(): Rule {
return updatePackage('effects');
Expand Down
31 changes: 31 additions & 0 deletions modules/effects/migrations/BUILD
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"
]
)
26 changes: 26 additions & 0 deletions modules/effects/schematics-core/BUILD
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",
],
)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ const STRING_UNDERSCORE_REGEXP_2 = /-|\s+/g;
decamelize('css-class-name'); // 'css-class-name'
decamelize('my favorite items'); // 'my favorite items'
```
@method decamelize
@param {String} str The string to decamelize.
@return {String} the decamelized string.
*/
export function decamelize(str: string): string {
return str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase();
Expand All @@ -38,10 +34,6 @@ export function decamelize(str: string): string {
dasherize('css-class-name'); // 'css-class-name'
dasherize('my favorite items'); // 'my-favorite-items'
```
@method dasherize
@param {String} str The string to dasherize.
@return {String} the dasherized string.
*/
export function dasherize(str?: string): string {
return decamelize(str || '').replace(STRING_DASHERIZE_REGEXP, '-');
Expand All @@ -57,10 +49,6 @@ export function dasherize(str?: string): string {
camelize('my favorite items'); // 'myFavoriteItems'
camelize('My Favorite Items'); // 'myFavoriteItems'
```
@method camelize
@param {String} str The string to camelize.
@return {String} the camelized string.
*/
export function camelize(str: string): string {
return str
Expand All @@ -82,10 +70,6 @@ export function camelize(str: string): string {
'css-class-name'.classify(); // 'CssClassName'
'my favorite items'.classify(); // 'MyFavoriteItems'
```
@method classify
@param {String} str the string to classify
@return {String} the classified string
*/
export function classify(str: string): string {
return str
Expand All @@ -104,10 +88,6 @@ export function classify(str: string): string {
'css-class-name'.underscore(); // 'css_class_name'
'my favorite items'.underscore(); // 'my_favorite_items'
```
@method underscore
@param {String} str The string to underscore.
@return {String} the underscored string.
*/
export function underscore(str: string): string {
return str
Expand All @@ -125,10 +105,6 @@ export function underscore(str: string): string {
'css-class-name'.capitalize() // 'Css-class-name'
'my favorite items'.capitalize() // 'My favorite items'
```
@method capitalize
@param {String} str The string to capitalize.
@return {String} The capitalized string.
*/
export function capitalize(str: string): string {
return str.charAt(0).toUpperCase() + str.substr(1);
Expand Down
60 changes: 0 additions & 60 deletions modules/effects/src/schematics-core/testing/create-app-module.ts

This file was deleted.

26 changes: 0 additions & 26 deletions modules/effects/src/schematics-core/testing/create-package.ts

This file was deleted.

34 changes: 0 additions & 34 deletions modules/effects/src/schematics-core/testing/create-reducers.ts

This file was deleted.

55 changes: 0 additions & 55 deletions modules/effects/src/schematics-core/testing/create-workspace.ts

This file was deleted.

Loading

0 comments on commit dc31a1d

Please sign in to comment.