Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

akita-schematics

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

akita-schematics - npm Package Compare versions

Comparing version 1.0.0-rc.4 to 1.0.0

src/component/files/__name@dasherize__.component.__styleext__

2

package.json
{
"name": "akita-schematics",
"version": "1.0.0-rc.4",
"version": "1.0.0",
"description": "Akita Schematics for Angular",

@@ -5,0 +5,0 @@ "scripts": {

@@ -93,1 +93,5 @@ # Akita Schematics

`ng g af products/products --spec`
## Generate Module
Add the `--withModule` to generate module and akita component. (only for entity store)

@@ -46,4 +46,14 @@ {

"schema": "./service/schema.json"
},
"withModule": {
"description": "A module",
"factory": "./module/index",
"schema": "./module/schema.json"
},
"withComponent": {
"description": "A component",
"factory": "./component/index",
"schema": "./component/schema.json"
}
}
}

@@ -6,4 +6,5 @@ "use strict";

const plain = options.plain;
const withModule = options.withModule;
let files = [
schematics_1.schematic(plain ? 'store' : 'entity-store', {
schematics_1.schematic(plain ? "store" : "entity-store", {
flat: options.flat,

@@ -17,3 +18,3 @@ name: options.name,

}),
schematics_1.schematic(plain ? 'query' : 'entity-query', {
schematics_1.schematic(plain ? "query" : "entity-query", {
flat: options.flat,

@@ -27,3 +28,3 @@ name: options.name,

}),
schematics_1.schematic('service', {
schematics_1.schematic("service", {
flat: options.flat,

@@ -35,2 +36,3 @@ module: options.module,

spec: options.spec,
plain,
dirName: options.dirName,

@@ -42,3 +44,3 @@ feature: true

files = files.concat([
schematics_1.schematic('model', {
schematics_1.schematic("model", {
flat: options.flat,

@@ -55,2 +57,27 @@ module: options.module,

}
if (withModule) {
files = files.concat([
schematics_1.schematic("withModule", {
flat: options.flat,
module: options.module,
name: options.name,
path: options.path,
project: options.project,
spec: options.spec,
dirName: options.dirName,
feature: true
}),
schematics_1.schematic("withComponent", {
flat: options.flat,
module: options.module,
name: options.name,
path: options.path,
project: options.project,
spec: options.spec,
dirName: options.dirName,
styleext: options.styleext,
feature: true
})
]);
}
return (host, context) => {

@@ -57,0 +84,0 @@ return schematics_1.chain(files)(host, context);

@@ -7,9 +7,10 @@ import {

schematic
} from '@angular-devkit/schematics';
} from "@angular-devkit/schematics";
export default function(options: any): Rule {
const plain = options.plain;
const withModule = options.withModule;
let files = [
schematic(plain ? 'store' : 'entity-store', {
schematic(plain ? "store" : "entity-store", {
flat: options.flat,

@@ -23,3 +24,3 @@ name: options.name,

}),
schematic(plain ? 'query' : 'entity-query', {
schematic(plain ? "query" : "entity-query", {
flat: options.flat,

@@ -33,3 +34,3 @@ name: options.name,

}),
schematic('service', {
schematic("service", {
flat: options.flat,

@@ -41,2 +42,3 @@ module: options.module,

spec: options.spec,
plain,
dirName: options.dirName,

@@ -49,3 +51,3 @@ feature: true

files = files.concat([
schematic('model', {
schematic("model", {
flat: options.flat,

@@ -62,2 +64,29 @@ module: options.module,

}
if (withModule) {
files = files.concat([
schematic("withModule", {
flat: options.flat,
module: options.module,
name: options.name,
path: options.path,
project: options.project,
spec: options.spec,
dirName: options.dirName,
feature: true
}),
schematic("withComponent", {
flat: options.flat,
module: options.module,
name: options.name,
path: options.path,
project: options.project,
spec: options.spec,
dirName: options.dirName,
styleext: options.styleext,
feature: true
})
]);
}
return (host: Tree, context: SchematicContext) => {

@@ -64,0 +93,0 @@ return chain(files)(host, context);

@@ -32,2 +32,7 @@ {

},
"module": {
"type": "boolean",
"default": false,
"description": "Specifies if module and component are generated."
},
"dirName": {

@@ -37,2 +42,14 @@ "type": "string",

"description": "Specifies the name of the generated folder"
},
"styleext": {
"description": "The file extension to be used for style files.",
"type": "string",
"default": "scss"
},
"project": {
"type": "string",
"description": "The name of the project.",
"$default": {
"$source": "projectName"
}
}

@@ -39,0 +56,0 @@ },

@@ -1,4 +0,6 @@

import { Injectable } from '@angular/core';
import { <%= classify(name) %>Store } from './<%= dasherize(name) %>.store';
import { Injectable } from '@angular/core';<% if (!plain) { %>
import { ID } from '@datorama/akita';<% } %>
import { HttpClient } from '@angular/common/http';
import { <%= classify(name) %>Store } from './<%= dasherize(name) %>.store';<% if (!plain) { %>
import { <%= singular(classify(name)) %> } from './<%= singular(dasherize(name)) %>.model';<% } %>

@@ -11,15 +13,18 @@ @Injectable({ providedIn: 'root' })

}
<% if (!plain) { %>
get() {
// this.http.get(url).subscribe((entities) => {
// this.{<%= camelize(name) %>Store.set(entities);
// });
this.http.get('https://akita.com').subscribe((entities) => this.<%= camelize(name) %>Store.set(entities));
}
add() {
// this.http.post().subscribe((entity) => {
// this.{<%= camelize(name) %>Store.add(entity);
// });
add(<%= singular(camelize(name)) %>: <%= singular(classify(name)) %>) {
this.<%= camelize(name) %>Store.add(<%= singular(camelize(name)) %>);
}
update(id, <%= singular(camelize(name)) %>: Partial<<%= singular(classify(name)) %>>) {
this.<%= camelize(name) %>Store.update(id, <%= singular(camelize(name)) %>);
}
remove(id: ID) {
this.<%= camelize(name) %>Store.remove(id);
}<% } %>
}

@@ -37,2 +37,8 @@ {

},
"plain": {
"type": "boolean",
"default": false,
"alias": "p",
"description": "Specifies if a plain store is generated."
},
"feature": {

@@ -39,0 +45,0 @@ "type": "boolean",

@@ -10,8 +10,8 @@ "use strict";

const project = workspace.projects[options.project];
if (project.root.substr(-1) === '/') {
if (project.root.substr(-1) === "/") {
project.root = project.root.substr(0, project.root.length - 1);
}
if (options.path === undefined) {
const projectDirName = project.projectType === 'application' ? 'app' : 'lib';
return `${project.root ? `/${project.root}` : ''}/src/${projectDirName}`;
const projectDirName = project.projectType === "application" ? "app" : "lib";
return `${project.root ? `/${project.root}` : ""}/src/${projectDirName}`;
}

@@ -21,2 +21,13 @@ return options.path;

exports.getProjectPath = getProjectPath;
function getProject(workspaceOrHost, projectName) {
const workspace = isWorkspaceSchema(workspaceOrHost)
? workspaceOrHost
: workspace_1.getWorkspace(workspaceOrHost);
return workspace.projects[projectName];
}
exports.getProject = getProject;
function isWorkspaceSchema(workspace) {
return !!(workspace && workspace.projects);
}
exports.isWorkspaceSchema = isWorkspaceSchema;
//# sourceMappingURL=project.js.map

@@ -1,3 +0,3 @@

import { getWorkspace } from './workspace';
import { Tree } from '@angular-devkit/schematics';
import { getWorkspace } from "./workspace";
import { Tree } from "@angular-devkit/schematics";

@@ -16,3 +16,3 @@ export function getProjectPath(

if (project.root.substr(-1) === '/') {
if (project.root.substr(-1) === "/") {
project.root = project.root.substr(0, project.root.length - 1);

@@ -23,5 +23,5 @@ }

const projectDirName =
project.projectType === 'application' ? 'app' : 'lib';
project.projectType === "application" ? "app" : "lib";
return `${project.root ? `/${project.root}` : ''}/src/${projectDirName}`;
return `${project.root ? `/${project.root}` : ""}/src/${projectDirName}`;
}

@@ -31,1 +31,13 @@

}
export function getProject(workspaceOrHost: any, projectName: string) {
const workspace = isWorkspaceSchema(workspaceOrHost)
? workspaceOrHost
: getWorkspace(workspaceOrHost);
return workspace.projects[projectName];
}
export function isWorkspaceSchema(workspace: any) {
return !!(workspace && (workspace as any).projects);
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc