Skip to content
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

build: Add BUILD files for Schematics #954

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
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([
"tsconfig.json",
"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",
]]),
],
)
29 changes: 29 additions & 0 deletions modules/schematics/BUILD
Original file line number Diff line number Diff line change
@@ -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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this published to npm separately from other modules?
just FYI if you need it - there is a packages attribute on ng_package and npm_package that allows you to nest them if needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is published separately.

srcs = [":schematics_templates"] + glob([
"collection.json",
"package.json",
"README.md",
]),
deps = [
":schematics",
],
)
2 changes: 1 addition & 1 deletion modules/schematics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ngrx/schematics",
"version": "5.2.0",
"version": "0.0.0-PLACEHOLDER",
"description": "NgRx Schematics for Angular",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './create-app-module';
export * from './create-reducers';
export * from './get-file-content';
17 changes: 15 additions & 2 deletions modules/schematics/src/action/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 0 additions & 12 deletions modules/schematics/src/action/schema.d.ts

This file was deleted.

61 changes: 59 additions & 2 deletions modules/schematics/src/container/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
56 changes: 0 additions & 56 deletions modules/schematics/src/container/schema.d.ts

This file was deleted.

Loading