Skip to content

Instantly share code, notes, and snippets.

View anjy-07's full-sized avatar

Anjali Verma anjy-07

View GitHub Profile
json.scripts = {
...json.scripts,
'build:prod': 'ng build --prod',
'test:ci': 'ng test --no-watch --code-coverage'
};
json.husky = {
'hooks': {
'pre-commit': 'pretty-quick --staged --pattern \"apps/**/**/*.{ts,scss,html}\"'
}
function updatePackageJson(name: string): Rule {
return (tree: Tree): Tree => {
const path = `/${name}/package.json`;
const file = tree.read(path);
const json = JSON.parse(file!.toString());
}
}
const rule = chain([
generateRepo(name),
merged
]);
return rule(tree, _context) as Rule;
const templateSource = apply(url('./files'), [
template({..._options, ...strings}),
]);
import { Rule, SchematicContext, Tree, externalSchematic } from '@angular-devkit/schematics';
export function angularSchematic(_options: any): Rule {
const name = _options.name
return (_: Tree, _context: SchematicContext) => {
return externalSchematic('@schematics/angular', 'ng-new', {
name,
version: '11.0.1',
{
"$schema": "http://json-schema.org/schema",
"id": "angularSchematic",
"title": "ng new options schema",
"type": "object",
"description": "Initialise a new project",
"properties": {
"name": {
"type": "string",
"description": "The name of the project",
<button *appHasPermissions="[admin, guest]" class="btn btn-primary">Click</button>
import { Directive, Input, TemplateRef, ViewContainerRef, Renderer2 } from '@angular/core';
import { PermissionOptions } from './model/permissionOptions.interface';
import { PermissionService } from './permission.service';
@Directive({
selector: '[appHasPermissions]'
})
export class HasPermissionsDirective {
import { Injectable } from '@angular/core';
import { Subject, Observable } from 'rxjs';
import { PermissionOptions } from './model/permissionOptions.interface';
@Injectable({
providedIn: 'root'
})
export class PermissionService {
userPermissions : string[] = [
<button *ngIf="userPermissionService.userPrmissions.includes('admin')"> </button>