Primeiro commit do projeto Angular
This commit is contained in:
Generated
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { <%= classify(name) %>Resolver } from './<%= dasherize(name) %><%= typeSeparator %>resolver';
|
||||
|
||||
describe('<%= classify(name) %>Resolver', () => {
|
||||
let resolver: <%= classify(name) %>Resolver;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
resolver = TestBed.inject(<%= classify(name) %>Resolver);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(resolver).toBeTruthy();
|
||||
});
|
||||
});
|
||||
Generated
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
Router, Resolve,
|
||||
RouterStateSnapshot,
|
||||
ActivatedRouteSnapshot
|
||||
} from '@angular/router';
|
||||
import { Observable, of } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class <%= classify(name) %>Resolver implements Resolve<boolean> {
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
|
||||
return of(true);
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { <%= camelize(name) %>Resolver } from './<%= dasherize(name) %><%= typeSeparator %>resolver';
|
||||
|
||||
describe('<%= camelize(name) %>Resolver', () => {
|
||||
const executeResolver: ResolveFn<boolean> = (...resolverParameters) =>
|
||||
TestBed.runInInjectionContext(() => <%= camelize(name) %>Resolver(...resolverParameters));
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(executeResolver).toBeTruthy();
|
||||
});
|
||||
});
|
||||
Generated
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
export const <%= camelize(name) %>Resolver: ResolveFn<boolean> = (route, state) => {
|
||||
return true;
|
||||
};
|
||||
+10
@@ -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.dev/license
|
||||
*/
|
||||
import type { Rule } from '@angular-devkit/schematics';
|
||||
import type { Schema as ResolverOptions } from './schema';
|
||||
export default function (options: ResolverOptions): Rule;
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
"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.dev/license
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const generate_from_files_1 = require("../utility/generate-from-files");
|
||||
function default_1(options) {
|
||||
const templateFilesDirectory = options.functional ? './functional-files' : './class-files';
|
||||
return (0, generate_from_files_1.generateFromFiles)({ ...options, templateFilesDirectory });
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAMH,4BAIC;AAPD,wEAAmE;AAGnE,mBAAyB,OAAwB;IAC/C,MAAM,sBAAsB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,eAAe,CAAC;IAE3F,OAAO,IAAA,uCAAiB,EAAC,EAAE,GAAG,OAAO,EAAE,sBAAsB,EAAE,CAAC,CAAC;AACnE,CAAC"}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Creates a new resolver in your project. Resolvers are used to pre-fetch data before a
|
||||
* route is activated, ensuring that the necessary data is available before the component is
|
||||
* displayed. This can improve the user experience by preventing delays and loading states.
|
||||
* This schematic generates a new resolver with the specified name and options.
|
||||
*/
|
||||
export type Schema = {
|
||||
/**
|
||||
* Creates the new resolver files at the top level of the current project. If set to false,
|
||||
* a new folder with the resolver's name will be created to contain the files.
|
||||
*/
|
||||
flat?: boolean;
|
||||
/**
|
||||
* Creates the resolver as a function `ResolveFn` instead of a class. Functional resolvers
|
||||
* can be simpler for basic scenarios.
|
||||
*/
|
||||
functional?: boolean;
|
||||
/**
|
||||
* The name for the new resolver. This will be used to create the resolver's class and spec
|
||||
* files (e.g., `my-resolver.resolver.ts` and `my-resolver.resolver.spec.ts`).
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The path where the resolver files should be created, relative to the current workspace.
|
||||
* If not provided, the resolver will be created in the current directory.
|
||||
*/
|
||||
path?: string;
|
||||
/**
|
||||
* The name of the project where the resolver should be created. If not specified, the CLI
|
||||
* will determine the project from the current directory.
|
||||
*/
|
||||
project: string;
|
||||
/**
|
||||
* Skip the generation of a unit test file `spec.ts` for the new resolver.
|
||||
*/
|
||||
skipTests?: boolean;
|
||||
/**
|
||||
* The separator character to use before the type within the generated file's name. For
|
||||
* example, if you set the option to `.`, the file will be named `example.resolver.ts`.
|
||||
*/
|
||||
typeSeparator?: TypeSeparator;
|
||||
};
|
||||
/**
|
||||
* The separator character to use before the type within the generated file's name. For
|
||||
* example, if you set the option to `.`, the file will be named `example.resolver.ts`.
|
||||
*/
|
||||
export declare enum TypeSeparator {
|
||||
Empty = "-",
|
||||
TypeSeparator = "."
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
"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.TypeSeparator = void 0;
|
||||
/**
|
||||
* The separator character to use before the type within the generated file's name. For
|
||||
* example, if you set the option to `.`, the file will be named `example.resolver.ts`.
|
||||
*/
|
||||
var TypeSeparator;
|
||||
(function (TypeSeparator) {
|
||||
TypeSeparator["Empty"] = "-";
|
||||
TypeSeparator["TypeSeparator"] = ".";
|
||||
})(TypeSeparator || (exports.TypeSeparator = TypeSeparator = {}));
|
||||
//# sourceMappingURL=schema.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"schema.js","sourceRoot":"","sources":["schema.ts"],"names":[],"mappings":";AACA,mFAAmF;AACnF,oFAAoF;;;AA6CpF;;;GAGG;AACH,IAAY,aAGX;AAHD,WAAY,aAAa;IACrB,4BAAW,CAAA;IACX,oCAAmB,CAAA;AACvB,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB"}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"$id": "SchematicsAngularResolver",
|
||||
"title": "Angular Resolver Options Schema",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"description": "Creates a new resolver in your project. Resolvers are used to pre-fetch data before a route is activated, ensuring that the necessary data is available before the component is displayed. This can improve the user experience by preventing delays and loading states. This schematic generates a new resolver with the specified name and options.",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "The name for the new resolver. This will be used to create the resolver's class and spec files (e.g., `my-resolver.resolver.ts` and `my-resolver.resolver.spec.ts`).",
|
||||
"$default": {
|
||||
"$source": "argv",
|
||||
"index": 0
|
||||
},
|
||||
"x-prompt": "What name would you like to use for the resolver?"
|
||||
},
|
||||
"skipTests": {
|
||||
"type": "boolean",
|
||||
"description": "Skip the generation of a unit test file `spec.ts` for the new resolver.",
|
||||
"default": false
|
||||
},
|
||||
"flat": {
|
||||
"type": "boolean",
|
||||
"description": "Creates the new resolver files at the top level of the current project. If set to false, a new folder with the resolver's name will be created to contain the files.",
|
||||
"default": true
|
||||
},
|
||||
"functional": {
|
||||
"type": "boolean",
|
||||
"description": "Creates the resolver as a function `ResolveFn` instead of a class. Functional resolvers can be simpler for basic scenarios.",
|
||||
"default": true
|
||||
},
|
||||
"path": {
|
||||
"type": "string",
|
||||
"format": "path",
|
||||
"$default": {
|
||||
"$source": "workingDirectory"
|
||||
},
|
||||
"description": "The path where the resolver files should be created, relative to the current workspace. If not provided, the resolver will be created in the current directory.",
|
||||
"visible": false
|
||||
},
|
||||
"project": {
|
||||
"type": "string",
|
||||
"description": "The name of the project where the resolver should be created. If not specified, the CLI will determine the project from the current directory.",
|
||||
"$default": {
|
||||
"$source": "projectName"
|
||||
}
|
||||
},
|
||||
"typeSeparator": {
|
||||
"type": "string",
|
||||
"default": "-",
|
||||
"enum": ["-", "."],
|
||||
"description": "The separator character to use before the type within the generated file's name. For example, if you set the option to `.`, the file will be named `example.resolver.ts`."
|
||||
}
|
||||
},
|
||||
"required": ["name", "project"]
|
||||
}
|
||||
Reference in New Issue
Block a user