diff --git a/BUILD.bazel b/BUILD.bazel index a901735e70..8f785f3c8c 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,4 +1,5 @@ -package(default_visibility = ["//visibility:public"]) +package(default_visibility=["//visibility:public"]) +load("@build_bazel_rules_nodejs//:defs.bzl", "node_modules_filegroup") # Needed so that tsconfig.json can be referenced from BUILD rules. exports_files([ @@ -6,25 +7,17 @@ exports_files([ "LICENSE", ]) -filegroup( - name = "node_modules", +node_modules_filegroup( + name="node_modules", # NB: rxjs is not in this list, because we build it from sources using the # label @rxjs//:rxjs - srcs = glob(["/".join([ - "node_modules", - pkg, - "**", - ext, - ]) for pkg in [ + packages=[ "@angular", + "@angular-devkit", "jasmine", "jasmine-marbles", "typescript", "@types", "tsickle", - ] for ext in [ - "*.js", - "*.json", - "*.d.ts", - ]]), + ], ) diff --git a/modules/schematics/BUILD b/modules/schematics/BUILD new file mode 100644 index 0000000000..62e40a0e2d --- /dev/null +++ b/modules/schematics/BUILD @@ -0,0 +1,29 @@ +package(default_visibility = ["//visibility:public"]) + +load("//tools:defaults.bzl", "ts_library", "npm_package") + +ts_library( + name = "schematics", + srcs = glob(["src/*/*.ts"]), + module_name = "@ngrx/schematics", +) + +filegroup( + name = "schematics_templates", + srcs = glob([ + "src/*/files/**/*.ts", + "src/*/schema.json", + ]), +) + +npm_package( + name = "npm_package", + srcs = [":schematics_templates"] + glob([ + "collection.json", + "package.json", + "README.md", + ]), + deps = [ + ":schematics", + ], +) diff --git a/modules/schematics/package.json b/modules/schematics/package.json index 77312bb982..451691d12a 100644 --- a/modules/schematics/package.json +++ b/modules/schematics/package.json @@ -1,6 +1,6 @@ { "name": "@ngrx/schematics", - "version": "5.2.0", + "version": "0.0.0-PLACEHOLDER", "description": "NgRx Schematics for Angular", "repository": { "type": "git", diff --git a/modules/schematics/src/action/index.spec.ts b/modules/schematics/spec/action.spec.ts similarity index 94% rename from modules/schematics/src/action/index.spec.ts rename to modules/schematics/spec/action.spec.ts index d5db68c07b..845b4c44e0 100644 --- a/modules/schematics/src/action/index.spec.ts +++ b/modules/schematics/spec/action.spec.ts @@ -1,11 +1,11 @@ import { SchematicTestRunner } from '@angular-devkit/schematics/testing'; import * as path from 'path'; -import { Schema as ActionOptions } from './schema'; +import { ActionOptions } from '../src/action'; describe('Action Schematic', () => { const schematicRunner = new SchematicTestRunner( '@ngrx/schematics', - path.join(__dirname, '../../collection.json') + path.join(__dirname, '../collection.json') ); const defaultOptions: ActionOptions = { name: 'foo', diff --git a/modules/schematics/src/utility/ast-utils_spec.ts b/modules/schematics/spec/ast-utils.spec.ts similarity index 93% rename from modules/schematics/src/utility/ast-utils_spec.ts rename to modules/schematics/spec/ast-utils.spec.ts index ec4a56c902..994a226943 100644 --- a/modules/schematics/src/utility/ast-utils_spec.ts +++ b/modules/schematics/spec/ast-utils.spec.ts @@ -8,9 +8,9 @@ import { tags } from '@angular-devkit/core'; import { VirtualTree } from '@angular-devkit/schematics'; import * as ts from 'typescript'; -import { Change, InsertChange } from '../utility/change'; -import { getFileContent } from '../utility/test'; -import { addExportToModule } from './ast-utils'; +import { getFileContent } from './utils'; +import { Change, InsertChange } from '../src/utility/change'; +import { addExportToModule } from '../src/utility/ast-utils'; function getTsSource(path: string, content: string): ts.SourceFile { return ts.createSourceFile(path, content, ts.ScriptTarget.Latest, true); diff --git a/modules/schematics/src/cli.spec.ts b/modules/schematics/spec/cli.spec.ts similarity index 92% rename from modules/schematics/src/cli.spec.ts rename to modules/schematics/spec/cli.spec.ts index 84a3c7e2c0..c0345537cf 100644 --- a/modules/schematics/src/cli.spec.ts +++ b/modules/schematics/spec/cli.spec.ts @@ -1,7 +1,7 @@ import { Tree, VirtualTree } from '@angular-devkit/schematics'; import { SchematicTestRunner } from '@angular-devkit/schematics/testing'; import * as path from 'path'; -import { createAppModule, getFileContent } from './utility/test'; +import { createAppModule, getFileContent } from './utils'; describe('CLI Schematic', () => { const schematicRunner = new SchematicTestRunner( diff --git a/modules/schematics/src/container/index.spec.ts b/modules/schematics/spec/container.spec.ts similarity index 94% rename from modules/schematics/src/container/index.spec.ts rename to modules/schematics/spec/container.spec.ts index 65deaae7fe..0b9f8450b9 100644 --- a/modules/schematics/src/container/index.spec.ts +++ b/modules/schematics/spec/container.spec.ts @@ -1,13 +1,13 @@ import { Tree, VirtualTree } from '@angular-devkit/schematics'; import { SchematicTestRunner } from '@angular-devkit/schematics/testing'; import * as path from 'path'; -import { createAppModule, getFileContent } from '../utility/test'; -import { Schema as ContainerOptions } from './schema'; +import { createAppModule, getFileContent } from './utils'; +import { ContainerOptions } from '../src/container'; describe('Container Schematic', () => { const schematicRunner = new SchematicTestRunner( '@ngrx/schematics', - path.join(__dirname, '../../collection.json') + path.join(__dirname, '../collection.json') ); const defaultOptions: ContainerOptions = { name: 'foo', diff --git a/modules/schematics/src/effect/index.spec.ts b/modules/schematics/spec/effect.spec.ts similarity index 98% rename from modules/schematics/src/effect/index.spec.ts rename to modules/schematics/spec/effect.spec.ts index ae0d7832c2..d5146aa5be 100644 --- a/modules/schematics/src/effect/index.spec.ts +++ b/modules/schematics/spec/effect.spec.ts @@ -5,13 +5,13 @@ import { createAppModule, getFileContent, createAppModuleWithEffects, -} from '../utility/test'; -import { Schema as EffectOptions } from './schema'; +} from './utils'; +import { EffectOptions } from '../src/effect'; describe('Effect Schematic', () => { const schematicRunner = new SchematicTestRunner( '@ngrx/schematics', - path.join(__dirname, '../../collection.json') + path.join(__dirname, '../collection.json') ); const defaultOptions: EffectOptions = { name: 'foo', diff --git a/modules/schematics/src/entity/index.spec.ts b/modules/schematics/spec/entity.spec.ts similarity index 95% rename from modules/schematics/src/entity/index.spec.ts rename to modules/schematics/spec/entity.spec.ts index a91d6a8e2b..ba7450d8be 100644 --- a/modules/schematics/src/entity/index.spec.ts +++ b/modules/schematics/spec/entity.spec.ts @@ -1,13 +1,13 @@ import { SchematicTestRunner } from '@angular-devkit/schematics/testing'; import * as path from 'path'; -import { getFileContent, createAppModule } from '../utility/test'; -import { Schema as EntityOptions } from './schema'; +import { getFileContent, createAppModule } from './utils'; +import { EntityOptions } from '../src/entity'; import { Tree, VirtualTree } from '@angular-devkit/schematics'; describe('Entity Schematic', () => { const schematicRunner = new SchematicTestRunner( '@ngrx/schematics', - path.join(__dirname, '../../collection.json') + path.join(__dirname, '../collection.json') ); const defaultOptions: EntityOptions = { name: 'foo', diff --git a/modules/schematics/src/feature/index.spec.ts b/modules/schematics/spec/feature.spec.ts similarity index 94% rename from modules/schematics/src/feature/index.spec.ts rename to modules/schematics/spec/feature.spec.ts index 029740c725..b8cb6a1144 100644 --- a/modules/schematics/src/feature/index.spec.ts +++ b/modules/schematics/spec/feature.spec.ts @@ -1,11 +1,11 @@ import { SchematicTestRunner } from '@angular-devkit/schematics/testing'; import * as path from 'path'; -import { Schema as FeatureOptions } from './schema'; +import { FeatureOptions } from '../src/feature'; describe('Feature Schematic', () => { const schematicRunner = new SchematicTestRunner( '@ngrx/schematics', - path.join(__dirname, '../../collection.json') + path.join(__dirname, '../collection.json') ); const defaultOptions: FeatureOptions = { name: 'foo', diff --git a/modules/schematics/src/utility/find-module_spec.ts b/modules/schematics/spec/find-module.spec.ts similarity index 97% rename from modules/schematics/src/utility/find-module_spec.ts rename to modules/schematics/spec/find-module.spec.ts index ecdfe1a3f2..cc783515b2 100644 --- a/modules/schematics/src/utility/find-module_spec.ts +++ b/modules/schematics/spec/find-module.spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ import { EmptyTree, Tree } from '@angular-devkit/schematics'; -import { findModule } from './find-module'; +import { findModule } from '../src/utility/find-module'; describe('find-module', () => { describe('findModule', () => { diff --git a/modules/schematics/src/reducer/index.spec.ts b/modules/schematics/spec/reducer.spec.ts similarity index 94% rename from modules/schematics/src/reducer/index.spec.ts rename to modules/schematics/spec/reducer.spec.ts index 0f6d1a044b..aa4e379a0e 100644 --- a/modules/schematics/src/reducer/index.spec.ts +++ b/modules/schematics/spec/reducer.spec.ts @@ -1,14 +1,13 @@ import { Tree, VirtualTree } from '@angular-devkit/schematics'; import { SchematicTestRunner } from '@angular-devkit/schematics/testing'; import * as path from 'path'; -import { createAppModule, getFileContent } from '../utility/test'; -import { Schema as ReducerOptions } from './schema'; -import { createReducers } from '../utility/test/create-reducers'; +import { createAppModule, getFileContent, createReducers } from './utils'; +import { ReducerOptions } from '../src/reducer'; describe('Reducer Schematic', () => { const schematicRunner = new SchematicTestRunner( '@ngrx/schematics', - path.join(__dirname, '../../collection.json') + path.join(__dirname, '../collection.json') ); const defaultOptions: ReducerOptions = { name: 'foo', diff --git a/modules/schematics/src/store/index.spec.ts b/modules/schematics/spec/store.spec.ts similarity index 96% rename from modules/schematics/src/store/index.spec.ts rename to modules/schematics/spec/store.spec.ts index 4c23651bd1..b22ef59dd1 100644 --- a/modules/schematics/src/store/index.spec.ts +++ b/modules/schematics/spec/store.spec.ts @@ -1,13 +1,13 @@ import { Tree, VirtualTree } from '@angular-devkit/schematics'; import { SchematicTestRunner } from '@angular-devkit/schematics/testing'; import * as path from 'path'; -import { createAppModule, getFileContent } from '../utility/test'; -import { Schema as StoreOptions } from './schema'; +import { createAppModule, getFileContent } from './utils'; +import { StoreOptions } from '../src/store'; describe('Store Schematic', () => { const schematicRunner = new SchematicTestRunner( '@ngrx/schematics', - path.join(__dirname, '../../collection.json') + path.join(__dirname, '../collection.json') ); const defaultOptions: StoreOptions = { name: 'foo', diff --git a/modules/schematics/src/utility/test/create-app-module.ts b/modules/schematics/spec/utils/create-app-module.ts similarity index 100% rename from modules/schematics/src/utility/test/create-app-module.ts rename to modules/schematics/spec/utils/create-app-module.ts diff --git a/modules/schematics/src/utility/test/create-reducers.ts b/modules/schematics/spec/utils/create-reducers.ts similarity index 100% rename from modules/schematics/src/utility/test/create-reducers.ts rename to modules/schematics/spec/utils/create-reducers.ts diff --git a/modules/schematics/src/utility/test/get-file-content.ts b/modules/schematics/spec/utils/get-file-content.ts similarity index 100% rename from modules/schematics/src/utility/test/get-file-content.ts rename to modules/schematics/spec/utils/get-file-content.ts diff --git a/modules/schematics/src/utility/test/index.ts b/modules/schematics/spec/utils/index.ts similarity index 67% rename from modules/schematics/src/utility/test/index.ts rename to modules/schematics/spec/utils/index.ts index 9b653dcab2..1e9dcece74 100644 --- a/modules/schematics/src/utility/test/index.ts +++ b/modules/schematics/spec/utils/index.ts @@ -1,2 +1,3 @@ export * from './create-app-module'; +export * from './create-reducers'; export * from './get-file-content'; diff --git a/modules/schematics/src/action/index.ts b/modules/schematics/src/action/index.ts index b49ed9f3fe..33ce383d36 100644 --- a/modules/schematics/src/action/index.ts +++ b/modules/schematics/src/action/index.ts @@ -12,8 +12,21 @@ import { template, url, } from '@angular-devkit/schematics'; -import * as stringUtils from '../strings'; -import { Schema as ActionOptions } from './schema'; +import * as stringUtils from '../utility/strings'; + +export const ActionOptions = require('./schema.json'); +export type ActionOptions = { + name: string; + appRoot?: string; + path?: string; + sourceDir?: string; + /** + * Specifies if a spec file is generated. + */ + spec?: boolean; + flat?: boolean; + group?: boolean; +}; export default function(options: ActionOptions): Rule { options.path = options.path ? normalize(options.path) : options.path; diff --git a/modules/schematics/src/action/schema.d.ts b/modules/schematics/src/action/schema.d.ts deleted file mode 100644 index 5146b2005d..0000000000 --- a/modules/schematics/src/action/schema.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -export interface Schema { - name: string; - appRoot?: string; - path?: string; - sourceDir?: string; - /** - * Specifies if a spec file is generated. - */ - spec?: boolean; - flat?: boolean; - group?: boolean; -} diff --git a/modules/schematics/src/container/index.ts b/modules/schematics/src/container/index.ts index 4eb3dcaeb7..5e27e55e14 100644 --- a/modules/schematics/src/container/index.ts +++ b/modules/schematics/src/container/index.ts @@ -14,13 +14,70 @@ import { mergeWith, } from '@angular-devkit/schematics'; import * as ts from 'typescript'; -import * as stringUtils from '../strings'; -import { Schema as ContainerOptions } from './schema'; +import * as stringUtils from '../utility/strings'; import { buildRelativePath } from '../utility/find-module'; import { NoopChange, InsertChange, ReplaceChange } from '../utility/change'; import { insertImport } from '../utility/route-utils'; import { omit } from '../utility/ngrx-utils'; +export const ContainerOptions = require('./schema.json'); +export type ContainerOptions = { + path?: string; + appRoot?: string; + sourceDir?: string; + name: string; + /** + * Specifies if the style will be in the ts file. + */ + inlineStyle?: boolean; + /** + * Specifies if the template will be in the ts file. + */ + inlineTemplate?: boolean; + /** + * Specifies the view encapsulation strategy. + */ + viewEncapsulation?: 'Emulated' | 'Native' | 'None'; + /** + * Specifies the change detection strategy. + */ + changeDetection?: 'Default' | 'OnPush'; + routing?: boolean; + /** + * The prefix to apply to generated selectors. + */ + prefix?: string; + /** + * The file extension to be used for style files. + */ + styleext?: string; + spec?: boolean; + /** + * Flag to indicate if a dir is created. + */ + flat?: boolean; + htmlTemplate?: string; + skipImport?: boolean; + selector?: string; + /** + * Allows specification of the declaring module. + */ + module?: string; + /** + * Specifies if declaring module exports the component. + */ + export?: boolean; + /** + * Specifies the path to the state exports + */ + state?: string; + + /** + * Specifies the interface for the state + */ + stateInterface?: string; +}; + function addStateToComponent(options: ContainerOptions) { return (host: Tree) => { if (!options.state && !options.stateInterface) { diff --git a/modules/schematics/src/container/schema.d.ts b/modules/schematics/src/container/schema.d.ts deleted file mode 100644 index 72d814456c..0000000000 --- a/modules/schematics/src/container/schema.d.ts +++ /dev/null @@ -1,56 +0,0 @@ -export interface Schema { - path?: string; - appRoot?: string; - sourceDir?: string; - name: string; - /** - * Specifies if the style will be in the ts file. - */ - inlineStyle?: boolean; - /** - * Specifies if the template will be in the ts file. - */ - inlineTemplate?: boolean; - /** - * Specifies the view encapsulation strategy. - */ - viewEncapsulation?: 'Emulated' | 'Native' | 'None'; - /** - * Specifies the change detection strategy. - */ - changeDetection?: 'Default' | 'OnPush'; - routing?: boolean; - /** - * The prefix to apply to generated selectors. - */ - prefix?: string; - /** - * The file extension to be used for style files. - */ - styleext?: string; - spec?: boolean; - /** - * Flag to indicate if a dir is created. - */ - flat?: boolean; - htmlTemplate?: string; - skipImport?: boolean; - selector?: string; - /** - * Allows specification of the declaring module. - */ - module?: string; - /** - * Specifies if declaring module exports the component. - */ - export?: boolean; - /** - * Specifies the path to the state exports - */ - state?: string; - - /** - * Specifies the interface for the state - */ - stateInterface?: string; -} diff --git a/modules/schematics/src/effect/index.ts b/modules/schematics/src/effect/index.ts index 72fad93b60..dcf6498d19 100644 --- a/modules/schematics/src/effect/index.ts +++ b/modules/schematics/src/effect/index.ts @@ -15,16 +15,38 @@ import { url, } from '@angular-devkit/schematics'; import * as ts from 'typescript'; -import * as stringUtils from '../strings'; +import * as stringUtils from '../utility/strings'; import { addImportToModule } from '../utility/ast-utils'; import { InsertChange } from '../utility/change'; import { buildRelativePath, findModuleFromOptions, } from '../utility/find-module'; -import { Schema as EffectOptions } from './schema'; import { insertImport } from '../utility/route-utils'; +export const EffectOptions = require('./schema.json'); +export type EffectOptions = { + name: string; + path?: string; + appRoot?: string; + sourceDir?: string; + /** + * Flag to indicate if a dir is created. + */ + flat?: boolean; + /** + * Specifies if a spec file is generated. + */ + spec?: boolean; + /** + * Allows specification of the declaring module. + */ + module?: string; + root?: boolean; + feature?: boolean; + group?: boolean; +}; + function addImportToNgModule(options: EffectOptions): Rule { return (host: Tree) => { const modulePath = options.module; diff --git a/modules/schematics/src/effect/schema.d.ts b/modules/schematics/src/effect/schema.d.ts deleted file mode 100644 index 6355e9cd8d..0000000000 --- a/modules/schematics/src/effect/schema.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -export interface Schema { - name: string; - path?: string; - appRoot?: string; - sourceDir?: string; - /** - * Flag to indicate if a dir is created. - */ - flat?: boolean; - /** - * Specifies if a spec file is generated. - */ - spec?: boolean; - /** - * Allows specification of the declaring module. - */ - module?: string; - root?: boolean; - feature?: boolean; - group?: boolean; -} diff --git a/modules/schematics/src/entity/index.ts b/modules/schematics/src/entity/index.ts index 47c61f9f26..ecec6a2d03 100644 --- a/modules/schematics/src/entity/index.ts +++ b/modules/schematics/src/entity/index.ts @@ -14,14 +14,29 @@ import { Tree, SchematicContext, } from '@angular-devkit/schematics'; -import * as stringUtils from '../strings'; -import { Schema as EntityOptions } from './schema'; +import * as stringUtils from '../utility/strings'; import { addReducerToState, addReducerImportToNgModule, } from '../utility/ngrx-utils'; import { findModuleFromOptions } from '../utility/find-module'; +export const EntityOptions = require('./schema.json'); +export type EntityOptions = { + name: string; + appRoot?: string; + path?: string; + sourceDir?: string; + /** + * Specifies if a spec file is generated. + */ + spec?: boolean; + module?: string; + reducers?: string; + flat?: boolean; + group?: boolean; +}; + export default function(options: EntityOptions): Rule { options.path = options.path ? normalize(options.path) : options.path; const sourceDir = options.sourceDir; diff --git a/modules/schematics/src/entity/schema.d.ts b/modules/schematics/src/entity/schema.d.ts deleted file mode 100644 index c11b5ee0e2..0000000000 --- a/modules/schematics/src/entity/schema.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -export interface Schema { - name: string; - appRoot?: string; - path?: string; - sourceDir?: string; - /** - * Specifies if a spec file is generated. - */ - spec?: boolean; - module?: string; - reducers?: string; - flat?: boolean; - group?: boolean; -} diff --git a/modules/schematics/src/feature/index.ts b/modules/schematics/src/feature/index.ts index 120a8f8b6d..2cc30a968b 100644 --- a/modules/schematics/src/feature/index.ts +++ b/modules/schematics/src/feature/index.ts @@ -5,7 +5,18 @@ import { chain, schematic, } from '@angular-devkit/schematics'; -import { Schema as FeatureOptions } from './schema'; + +export const FeatureOptions = require('./schema.json'); +export type FeatureOptions = { + path?: string; + sourceDir?: string; + name: string; + module?: string; + flat?: boolean; + spec?: boolean; + reducers?: string; + group?: boolean; +}; export default function(options: FeatureOptions): Rule { return (host: Tree, context: SchematicContext) => { diff --git a/modules/schematics/src/feature/schema.d.ts b/modules/schematics/src/feature/schema.d.ts deleted file mode 100644 index 06501e9c73..0000000000 --- a/modules/schematics/src/feature/schema.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -export interface Schema { - path?: string; - sourceDir?: string; - name: string; - module?: string; - flat?: boolean; - spec?: boolean; - reducers?: string; - group?: boolean; -} diff --git a/modules/schematics/src/reducer/index.ts b/modules/schematics/src/reducer/index.ts index 048f05f091..697da18f02 100644 --- a/modules/schematics/src/reducer/index.ts +++ b/modules/schematics/src/reducer/index.ts @@ -15,9 +15,8 @@ import { url, } from '@angular-devkit/schematics'; import * as ts from 'typescript'; -import * as stringUtils from '../strings'; +import * as stringUtils from '../utility/strings'; import { findModuleFromOptions } from '../utility/find-module'; -import { Schema as ReducerOptions } from './schema'; import { addReducerToStateInferface, addReducerToActionReducerMap, @@ -25,6 +24,26 @@ import { addReducerImportToNgModule, } from '../utility/ngrx-utils'; +export const ReducerOptions = require('./schema.json'); +export type ReducerOptions = { + name: string; + appRoot?: string; + path?: string; + sourceDir?: string; + /** + * Specifies if a spec file is generated. + */ + spec?: boolean; + /** + * Flag to indicate if a dir is created. + */ + flat?: boolean; + module?: string; + feature?: boolean; + reducers?: string; + group?: boolean; +}; + export default function(options: ReducerOptions): Rule { options.path = options.path ? normalize(options.path) : options.path; const sourceDir = options.sourceDir; diff --git a/modules/schematics/src/reducer/schema.d.ts b/modules/schematics/src/reducer/schema.d.ts deleted file mode 100644 index b099aaa783..0000000000 --- a/modules/schematics/src/reducer/schema.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -export interface Schema { - name: string; - appRoot?: string; - path?: string; - sourceDir?: string; - /** - * Specifies if a spec file is generated. - */ - spec?: boolean; - /** - * Flag to indicate if a dir is created. - */ - flat?: boolean; - module?: string; - feature?: boolean; - reducers?: string; - group?: boolean; -} diff --git a/modules/schematics/src/store/index.ts b/modules/schematics/src/store/index.ts index 42abeb6d4f..1dd9915c7f 100644 --- a/modules/schematics/src/store/index.ts +++ b/modules/schematics/src/store/index.ts @@ -14,16 +14,41 @@ import { url, } from '@angular-devkit/schematics'; import * as ts from 'typescript'; -import * as stringUtils from '../strings'; +import * as stringUtils from '../utility/strings'; import { addImportToModule } from '../utility/ast-utils'; import { InsertChange, Change } from '../utility/change'; import { buildRelativePath, findModuleFromOptions, } from '../utility/find-module'; -import { Schema as StoreOptions } from './schema'; import { insertImport } from '../utility/route-utils'; +export const StoreOptions = require('./schema.json'); +export type StoreOptions = { + name: string; + path?: string; + appRoot?: string; + sourceDir?: string; + /** + * Flag to indicate if a dir is created. + */ + flat?: boolean; + /** + * Specifies if a spec file is generated. + */ + spec?: boolean; + /** + * Allows specification of the declaring module. + */ + module?: string; + statePath?: string; + root?: boolean; + /** + * Specifies the interface for the state + */ + stateInterface?: string; +}; + function addImportToNgModule(options: StoreOptions): Rule { return (host: Tree) => { const modulePath = options.module; diff --git a/modules/schematics/src/store/schema.d.ts b/modules/schematics/src/store/schema.d.ts deleted file mode 100644 index a90c4473fd..0000000000 --- a/modules/schematics/src/store/schema.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -export interface Schema { - name: string; - path?: string; - appRoot?: string; - sourceDir?: string; - /** - * Flag to indicate if a dir is created. - */ - flat?: boolean; - /** - * Specifies if a spec file is generated. - */ - spec?: boolean; - /** - * Allows specification of the declaring module. - */ - module?: string; - statePath?: string; - root?: boolean; - /** - * Specifies the interface for the state - */ - stateInterface?: string; -} diff --git a/modules/schematics/src/utility/find-module.ts b/modules/schematics/src/utility/find-module.ts index 254e7caa1a..c93928780e 100644 --- a/modules/schematics/src/utility/find-module.ts +++ b/modules/schematics/src/utility/find-module.ts @@ -7,7 +7,7 @@ */ import { Path, join, normalize, relative } from '@angular-devkit/core'; import { DirEntry, Tree } from '@angular-devkit/schematics'; -import { dasherize } from '../strings'; +import { dasherize } from './strings'; export interface ModuleOptions { module?: string; diff --git a/modules/schematics/src/utility/ngrx-utils.ts b/modules/schematics/src/utility/ngrx-utils.ts index d1a49243b6..6fec6d551e 100644 --- a/modules/schematics/src/utility/ngrx-utils.ts +++ b/modules/schematics/src/utility/ngrx-utils.ts @@ -1,11 +1,11 @@ import * as ts from 'typescript'; -import * as stringUtils from '../strings'; +import * as stringUtils from './strings'; import { InsertChange, Change, NoopChange } from './change'; import { Tree, SchematicsException, Rule } from '@angular-devkit/schematics'; import { normalize } from '@angular-devkit/core'; import { buildRelativePath } from './find-module'; import { insertImport } from './route-utils'; -import { Schema as ReducerOptions } from '../reducer/schema'; +import { ReducerOptions } from '../reducer'; import { addImportToModule } from './ast-utils'; export function addReducerToState(options: ReducerOptions): Rule { diff --git a/modules/schematics/src/strings.ts b/modules/schematics/src/utility/strings.ts similarity index 100% rename from modules/schematics/src/strings.ts rename to modules/schematics/src/utility/strings.ts diff --git a/tools/defaults.bzl b/tools/defaults.bzl index fba24da4e7..2877fcb8a8 100644 --- a/tools/defaults.bzl +++ b/tools/defaults.bzl @@ -2,7 +2,7 @@ load("@build_bazel_rules_typescript//:defs.bzl", _ts_library="ts_library") load("@angular//:index.bzl", _ng_module="ng_module", _ng_package="ng_package") load("@build_bazel_rules_nodejs//:defs.bzl", - _jasmine_node_test="jasmine_node_test") + _jasmine_node_test="jasmine_node_test", _npm_package="npm_package") DEFAULT_TSCONFIG = "//:tsconfig.json" NG_VERSION = "^6.0.0 || ^6.0.0-rc.0" @@ -72,3 +72,10 @@ def ng_package(name, readme_md=None, license_banner=None, globals={}, **kwargs): globals=dict(globals, **NGRX_GLOBALS), replacements=PKG_GROUP_REPLACEMENTS, **kwargs) + + +def npm_package(name, **kwargs): + _npm_package( + name=name, + replacements=PKG_GROUP_REPLACEMENTS, + **kwargs)