Updated the files.

This commit is contained in:
Batuhan Berk Başoğlu 2024-02-08 19:38:41 -05:00
parent 1553e6b971
commit 753967d4f5
23418 changed files with 3784666 additions and 0 deletions

View file

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { <%= classify(name) %>Guard } from './<%= dasherize(name) %>.guard';
describe('<%= classify(name) %>Guard', () => {
let guard: <%= classify(name) %>Guard;
beforeEach(() => {
TestBed.configureTestingModule({});
guard = TestBed.inject(<%= classify(name) %>Guard);
});
it('should be created', () => {
expect(guard).toBeTruthy();
});
});

View file

@ -0,0 +1,31 @@
import { Injectable } from '@angular/core';
import { <%= routerImports %> } from '@angular/router';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class <%= classify(name) %>Guard implements <%= implementations %> {
<% if (implements.includes('CanActivate')) { %>canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
return true;
}
<% } %><% if (implements.includes('CanActivateChild')) { %>canActivateChild(
childRoute: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
return true;
}
<% } %><% if (implements.includes('CanDeactivate')) { %>canDeactivate(
component: unknown,
currentRoute: ActivatedRouteSnapshot,
currentState: RouterStateSnapshot,
nextState?: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
return true;
}
<% } %><% if (implements.includes('CanMatch')) { %>canMatch(
route: Route,
segments: UrlSegment[]): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
return true;
}<% } %>
}

10
my-app/node_modules/@schematics/angular/guard/index.d.ts generated vendored Executable file
View file

@ -0,0 +1,10 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { Rule } from '@angular-devkit/schematics';
import { Schema as GuardOptions } from './schema';
export default function (options: GuardOptions): Rule;

47
my-app/node_modules/@schematics/angular/guard/index.js generated vendored Executable file
View file

@ -0,0 +1,47 @@
"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
const schematics_1 = require("@angular-devkit/schematics");
const generate_from_files_1 = require("../utility/generate-from-files");
const schema_1 = require("./schema");
function default_1(options) {
if (!options.implements) {
throw new schematics_1.SchematicsException('Option "implements" is required.');
}
if (options.implements.length > 1 && options.functional) {
throw new schematics_1.SchematicsException('Can only specify one value for implements when generating a functional guard.');
}
if (options.functional) {
const guardType = options.implements[0] + 'Fn';
return (0, generate_from_files_1.generateFromFiles)({ ...options, templateFilesDirectory: './type-files' }, { guardType });
}
else {
const implementations = options.implements
.map((implement) => (implement === 'CanDeactivate' ? 'CanDeactivate<unknown>' : implement))
.join(', ');
const commonRouterNameImports = ['ActivatedRouteSnapshot', 'RouterStateSnapshot'];
const routerNamedImports = [...options.implements, 'UrlTree'];
if (options.implements.includes(schema_1.Implement.CanMatch)) {
routerNamedImports.push('Route', 'UrlSegment');
if (options.implements.length > 1) {
routerNamedImports.push(...commonRouterNameImports);
}
}
else {
routerNamedImports.push(...commonRouterNameImports);
}
routerNamedImports.sort();
const routerImports = routerNamedImports.join(', ');
return (0, generate_from_files_1.generateFromFiles)({ ...options, templateFilesDirectory: './implements-files' }, {
implementations,
routerImports,
});
}
}
exports.default = default_1;

40
my-app/node_modules/@schematics/angular/guard/schema.d.ts generated vendored Executable file
View file

@ -0,0 +1,40 @@
/**
* Generates a new, generic route guard definition in the given project.
*/
export interface Schema {
/**
* When true (the default), creates the new files at the top level of the current project.
*/
flat?: boolean;
/**
* Specifies whether to generate a guard as a function.
*/
functional?: boolean;
/**
* Specifies which type of guard to create.
*/
implements?: Implement[];
/**
* The name of the new route guard.
*/
name: string;
/**
* The path at which to create the interface that defines the guard, relative to the current
* workspace.
*/
path?: string;
/**
* The name of the project.
*/
project: string;
/**
* Do not create "spec.ts" test files for the new guard.
*/
skipTests?: boolean;
}
export declare enum Implement {
CanActivate = "CanActivate",
CanActivateChild = "CanActivateChild",
CanDeactivate = "CanDeactivate",
CanMatch = "CanMatch"
}

12
my-app/node_modules/@schematics/angular/guard/schema.js generated vendored Executable file
View file

@ -0,0 +1,12 @@
"use strict";
// THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE
// CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...).
Object.defineProperty(exports, "__esModule", { value: true });
exports.Implement = void 0;
var Implement;
(function (Implement) {
Implement["CanActivate"] = "CanActivate";
Implement["CanActivateChild"] = "CanActivateChild";
Implement["CanDeactivate"] = "CanDeactivate";
Implement["CanMatch"] = "CanMatch";
})(Implement || (exports.Implement = Implement = {}));

64
my-app/node_modules/@schematics/angular/guard/schema.json generated vendored Executable file
View file

@ -0,0 +1,64 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "SchematicsAngularGuard",
"title": "Angular Guard Options Schema",
"type": "object",
"description": "Generates a new, generic route guard definition in the given project.",
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"description": "The name of the new route guard.",
"$default": {
"$source": "argv",
"index": 0
},
"x-prompt": "What name would you like to use for the guard?"
},
"skipTests": {
"type": "boolean",
"description": "Do not create \"spec.ts\" test files for the new guard.",
"default": false
},
"flat": {
"type": "boolean",
"description": "When true (the default), creates the new files at the top level of the current project.",
"default": true
},
"path": {
"type": "string",
"format": "path",
"$default": {
"$source": "workingDirectory"
},
"description": "The path at which to create the interface that defines the guard, relative to the current workspace.",
"visible": false
},
"project": {
"type": "string",
"description": "The name of the project.",
"$default": {
"$source": "projectName"
}
},
"functional": {
"type": "boolean",
"description": "Specifies whether to generate a guard as a function.",
"default": true
},
"implements": {
"alias": "guardType",
"type": "array",
"description": "Specifies which type of guard to create.",
"uniqueItems": true,
"minItems": 1,
"items": {
"enum": ["CanActivate", "CanActivateChild", "CanDeactivate", "CanMatch"],
"type": "string"
},
"default": ["CanActivate"],
"x-prompt": "Which type of guard would you like to create?"
}
},
"required": ["name", "project"]
}

View file

@ -0,0 +1,17 @@
import { TestBed } from '@angular/core/testing';
import { <%= guardType %> } from '@angular/router';
import { <%= camelize(name) %>Guard } from './<%= dasherize(name) %>.guard';
describe('<%= camelize(name) %>Guard', () => {
const executeGuard: <%= guardType %> = (...guardParameters) =>
TestBed.runInInjectionContext(() => <%= camelize(name) %>Guard(...guardParameters));
beforeEach(() => {
TestBed.configureTestingModule({});
});
it('should be created', () => {
expect(executeGuard).toBeTruthy();
});
});

View file

@ -0,0 +1,9 @@
import { <%= guardType %> } from '@angular/router';
export const <%= camelize(name) %>Guard: <%= guardType %><% if (guardType === 'CanDeactivateFn') { %><unknown><% } %> = <%
if (guardType === 'CanMatchFn') { %>(route, segments)<% }
%><% if (guardType === 'CanActivateFn') { %>(route, state)<% }
%><% if (guardType === 'CanActivateChildFn') { %>(childRoute, state)<% }
%><% if (guardType === 'CanDeactivateFn') { %>(component, currentRoute, currentState, nextState)<% } %> => {
return true;
};