Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(schematics): added Store workspace schematics
- Loading branch information
Showing
5 changed files
with
63 additions
and
22 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 was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
tools/schematics/store/_files/__path__/__name@dasherize__.store.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,5 @@ | ||
export class <%= classify(name) %>State { | ||
constructor() { | ||
|
||
} | ||
} |
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,13 +1,57 @@ | ||
import { chain, externalSchematic, Rule } from '@angular-devkit/schematics'; | ||
import { | ||
apply, | ||
branchAndMerge, | ||
chain, | ||
mergeWith, | ||
move, | ||
Rule, | ||
SchematicContext, | ||
SchematicsException, | ||
template, | ||
Tree, | ||
url, | ||
} from '@angular-devkit/schematics'; | ||
import { strings } from '@angular-devkit/core'; | ||
|
||
import { Schema as featureOptions } from './schema'; | ||
|
||
import { getWorkspace } from '@schematics/angular/utility/config'; | ||
import { parseName } from '@schematics/angular/utility/parse-name'; | ||
import { buildDefaultPath } from '@schematics/angular/utility/project'; | ||
import { findModuleFromOptions } from '@schematics/angular/utility/find-module'; | ||
import { validateName } from '@schematics/angular/utility//validation'; | ||
|
||
export default function store(options: featureOptions): Rule { | ||
return chain([ | ||
externalSchematic('@nrwl/schematics', 'class', | ||
options) | ||
// { | ||
// name: options.name, | ||
// project: options.project, | ||
// }), | ||
]); | ||
return (host: Tree, context: SchematicContext) => { | ||
const workspace = getWorkspace(host); | ||
if (!options.project) { | ||
throw new SchematicsException('Option (project) is required.'); | ||
} | ||
const project = workspace.projects[options.project]; | ||
|
||
if (options.path === undefined) { | ||
options.path = buildDefaultPath(project); | ||
} | ||
|
||
options.module = findModuleFromOptions(host, options); | ||
|
||
const parsedPath = parseName(options.path, options.name); | ||
options.name = parsedPath.name; | ||
options.path = parsedPath.path; | ||
|
||
validateName(options.name); | ||
console.log(options); | ||
|
||
const templateSource = apply(url('./_files'), [ | ||
template({ | ||
...strings, | ||
...options, | ||
}), | ||
// move(parsedPath.path), | ||
]); | ||
|
||
const rule = chain([branchAndMerge(chain([mergeWith(templateSource)]))]); | ||
|
||
return rule(host, context); | ||
}; | ||
} |
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,11 +1,8 @@ | ||
export interface Schema { | ||
name: string; | ||
/** | ||
* Target apps | ||
*/ | ||
projects?: string; | ||
/** | ||
* dry run | ||
*/ | ||
dryRun?: boolean; | ||
path?: string; | ||
project?: string; | ||
module?: string; | ||
} |