Primeiro commit do projeto Angular
This commit is contained in:
Generated
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { <%= classifiedName %> } from './<%= dasherize(name) %><%= type ? '.' + dasherize(type) : '' %>';
|
||||
|
||||
describe('<%= classifiedName %>', () => {
|
||||
let service: <%= classifiedName %>;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(<%= classifiedName %>);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class <%= classifiedName %> {
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @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 { RuleFactory } from '@angular-devkit/schematics';
|
||||
import { Schema as ServiceOptions } from './schema';
|
||||
declare const serviceSchematic: RuleFactory<ServiceOptions>;
|
||||
export default serviceSchematic;
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
"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 });
|
||||
const schematics_1 = require("@angular-devkit/schematics");
|
||||
const generate_from_files_1 = require("../utility/generate-from-files");
|
||||
const parse_name_1 = require("../utility/parse-name");
|
||||
const project_1 = require("../utility/project");
|
||||
const validation_1 = require("../utility/validation");
|
||||
const workspace_1 = require("../utility/workspace");
|
||||
const serviceSchematic = (0, project_1.createProjectSchematic)((options, { project, tree }) => {
|
||||
if (options.path === undefined) {
|
||||
options.path = (0, workspace_1.buildDefaultPath)(project);
|
||||
}
|
||||
const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
|
||||
options.name = parsedPath.name;
|
||||
options.path = parsedPath.path;
|
||||
const classifiedName = schematics_1.strings.classify(options.name) +
|
||||
(options.addTypeToClassName && options.type ? schematics_1.strings.classify(options.type) : '');
|
||||
(0, validation_1.validateClassName)(classifiedName);
|
||||
return (0, generate_from_files_1.generateFromFiles)({
|
||||
...options,
|
||||
classifiedName,
|
||||
});
|
||||
});
|
||||
exports.default = serviceSchematic;
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAEH,2DAAkE;AAClE,wEAAmE;AACnE,sDAAkD;AAClD,gDAA4D;AAC5D,sDAA0D;AAC1D,oDAAwD;AAGxD,MAAM,gBAAgB,GAAgC,IAAA,gCAAsB,EAC1E,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;IAC7B,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,CAAC,IAAI,GAAG,IAAA,4BAAgB,EAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,UAAU,GAAG,IAAA,sBAAS,EAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,OAAO,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;IAC/B,OAAO,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;IAE/B,MAAM,cAAc,GAClB,oBAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;QAC9B,CAAC,OAAO,CAAC,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,oBAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACrF,IAAA,8BAAiB,EAAC,cAAc,CAAC,CAAC;IAElC,OAAO,IAAA,uCAAiB,EAAC;QACvB,GAAG,OAAO;QACV,cAAc;KACf,CAAC,CAAC;AACL,CAAC,CACF,CAAC;AAEF,kBAAe,gBAAgB,CAAC"}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Creates a new service in your project. Services are used to encapsulate reusable logic,
|
||||
* such as data access, API calls, or utility functions. This schematic simplifies the
|
||||
* process of generating a new service with the necessary files and boilerplate code.
|
||||
*/
|
||||
export type Schema = {
|
||||
/**
|
||||
* When true, the 'type' option will be appended to the generated class name. When false,
|
||||
* only the file name will include the type.
|
||||
*/
|
||||
addTypeToClassName?: boolean;
|
||||
/**
|
||||
* Creates files at the top level of the project or the given path. If set to false, a new
|
||||
* folder with the service's name will be created to contain the files.
|
||||
*/
|
||||
flat?: boolean;
|
||||
/**
|
||||
* The name for the new service. This will be used to create the service's class and spec
|
||||
* files (e.g., `my-service.service.ts` and `my-service.service.spec.ts`).
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The path where the service files should be created, relative to the workspace root. If
|
||||
* not provided, the service will be created in the project's `src/app` directory.
|
||||
*/
|
||||
path?: string;
|
||||
/**
|
||||
* The name of the project where the service should be added. 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 service.
|
||||
*/
|
||||
skipTests?: boolean;
|
||||
/**
|
||||
* Append a custom type to the service's filename. For example, if you set the type to
|
||||
* `service`, the file will be named `my-service.service.ts`.
|
||||
*/
|
||||
type?: string;
|
||||
};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
"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 });
|
||||
//# sourceMappingURL=schema.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"schema.js","sourceRoot":"","sources":["schema.ts"],"names":[],"mappings":";AACA,mFAAmF;AACnF,oFAAoF"}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"$id": "SchematicsAngularService",
|
||||
"title": "Angular Service Options Schema",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"description": "Creates a new service in your project. Services are used to encapsulate reusable logic, such as data access, API calls, or utility functions. This schematic simplifies the process of generating a new service with the necessary files and boilerplate code.",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "The name for the new service. This will be used to create the service's class and spec files (e.g., `my-service.service.ts` and `my-service.service.spec.ts`).",
|
||||
"$default": {
|
||||
"$source": "argv",
|
||||
"index": 0
|
||||
},
|
||||
"x-prompt": "What name would you like to use for the service?"
|
||||
},
|
||||
"path": {
|
||||
"type": "string",
|
||||
"$default": {
|
||||
"$source": "workingDirectory"
|
||||
},
|
||||
"description": "The path where the service files should be created, relative to the workspace root. If not provided, the service will be created in the project's `src/app` directory.",
|
||||
"visible": false
|
||||
},
|
||||
"project": {
|
||||
"type": "string",
|
||||
"description": "The name of the project where the service should be added. If not specified, the CLI will determine the project from the current directory.",
|
||||
"$default": {
|
||||
"$source": "projectName"
|
||||
}
|
||||
},
|
||||
"flat": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Creates files at the top level of the project or the given path. If set to false, a new folder with the service's name will be created to contain the files."
|
||||
},
|
||||
"skipTests": {
|
||||
"type": "boolean",
|
||||
"description": "Skip the generation of a unit test file `spec.ts` for the service.",
|
||||
"default": false
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"description": "Append a custom type to the service's filename. For example, if you set the type to `service`, the file will be named `my-service.service.ts`."
|
||||
},
|
||||
"addTypeToClassName": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "When true, the 'type' option will be appended to the generated class name. When false, only the file name will include the type."
|
||||
}
|
||||
},
|
||||
"required": ["name", "project"]
|
||||
}
|
||||
Reference in New Issue
Block a user