@ngstato/schematics
v0.4.0
Published
Angular CLI schematics for ngStato — generate stores, features, and entities
Maintainers
Readme
@ngstato/schematics
ng generate @ngstato/schematics:store users — done.
Scaffold stores, features, and tests in seconds.
Install
npm install -D @ngstato/schematicsGenerate a store
ng generate @ngstato/schematics:store users
# or shorthand
ng g @ngstato/schematics:s usersCreates:
src/app/stores/users/
├── users.store.ts # Store with CRUD actions, selectors, hooks, DevTools
└── users.store.spec.ts # Test file with createMockStoreOptions
| Option | Default | Description |
|--------|---------|-------------|
| --name | (required) | Store name (e.g. users, products) |
| --crud | true | Generate CRUD actions (load, create, update, delete) |
| --entity | false | Use createEntityAdapter for normalized collections |
| --devtools | true | Connect to DevTools with connectDevTools |
| --spec | true | Generate test file |
| --flat | false | Create file directly in path (no subdirectory) |
| --path | src/app/stores | Target directory |
Examples
# Basic CRUD store
ng g @ngstato/schematics:s products
# Entity-based store with adapter
ng g @ngstato/schematics:s orders --entity
# Flat file, no tests
ng g @ngstato/schematics:s settings --flat --no-spec
# Custom path
ng g @ngstato/schematics:s auth --path src/app/core/authGenerate a feature
ng generate @ngstato/schematics:feature loading
# or shorthand
ng g @ngstato/schematics:f paginationCreates a reusable store feature:
// loading.feature.ts
export function withLoading(): FeatureConfig {
return {
state: { loading: false, error: null },
actions: { /* ... */ },
computed: { /* ... */ }
}
}
// Usage in any store
const store = createStore({
items: [],
...mergeFeatures(withLoading(), withPagination()),
actions: { ... }
})License
MIT
