Primeiro commit do projeto Angular
This commit is contained in:
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
import { <%= classifiedName %> } from './<%= dasherize(name) %><%= type ? '.' + dasherize(type) : '' %>';
|
||||
|
||||
describe('<%= classifiedName %>', () => {
|
||||
it('should create an instance', () => {
|
||||
const directive = new <%= classifiedName %>();
|
||||
expect(directive).toBeTruthy();
|
||||
});
|
||||
});
|
||||
Generated
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
import { Directive } from '@angular/core';
|
||||
|
||||
@Directive({
|
||||
selector: '[<%= selector %>]',<% if(!standalone) {%>
|
||||
standalone: false,<%}%>
|
||||
})
|
||||
export class <%= classifiedName %> {
|
||||
|
||||
constructor() { }
|
||||
|
||||
}
|
||||
+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 DirectiveOptions } from './schema';
|
||||
declare const directiveSchematic: RuleFactory<DirectiveOptions>;
|
||||
export default directiveSchematic;
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
"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 add_declaration_to_ng_module_1 = require("../utility/add-declaration-to-ng-module");
|
||||
const find_module_1 = require("../utility/find-module");
|
||||
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");
|
||||
function buildSelector(options, projectPrefix) {
|
||||
let selector = options.name;
|
||||
if (options.prefix) {
|
||||
selector = `${options.prefix}-${selector}`;
|
||||
}
|
||||
else if (options.prefix === undefined && projectPrefix) {
|
||||
selector = `${projectPrefix}-${selector}`;
|
||||
}
|
||||
return schematics_1.strings.camelize(selector);
|
||||
}
|
||||
const directiveSchematic = (0, project_1.createProjectSchematic)((options, { project, tree }) => {
|
||||
if (options.path === undefined) {
|
||||
options.path = (0, workspace_1.buildDefaultPath)(project);
|
||||
}
|
||||
options.module = (0, find_module_1.findModuleFromOptions)(tree, options);
|
||||
const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
|
||||
options.name = parsedPath.name;
|
||||
options.path = parsedPath.path;
|
||||
options.selector = options.selector || buildSelector(options, project.prefix || '');
|
||||
(0, validation_1.validateHtmlSelector)(options.selector);
|
||||
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, schematics_1.chain)([
|
||||
(0, add_declaration_to_ng_module_1.addDeclarationToNgModule)({
|
||||
type: 'directive',
|
||||
...options,
|
||||
}),
|
||||
(0, generate_from_files_1.generateFromFiles)({
|
||||
...options,
|
||||
classifiedName,
|
||||
}),
|
||||
]);
|
||||
});
|
||||
exports.default = directiveSchematic;
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAEH,2DAAyE;AACzE,0FAAmF;AACnF,wDAA+D;AAC/D,wEAAmE;AACnE,sDAAkD;AAClD,gDAA4D;AAC5D,sDAAgF;AAChF,oDAAwD;AAGxD,SAAS,aAAa,CAAC,OAAyB,EAAE,aAAqB;IACrE,IAAI,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAC5B,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;Q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CAAC;IACrF,IAAA,8BAAiB,EAAC,cAAc,CAAC,CAAC;IAElC,OAAO,IAAA,kBAAK,EAAC;QACX,IAAA,uDAAwB,EAAC;YACvB,IAAI,EAAE,WAAW;YAEjB,GAAG,OAAO;SACX,CAAC;QACF,IAAA,uCAAiB,EAAC;YAChB,GAAG,OAAO;YACV,cAAc;SACf,CAAC;KACH,CAAC,CAAC;AACL,CAAC,CACF,CAAC;AAEF,kBAAe,kBAAkB,CAAC"}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* Creates a new directive in your project. Directives are used to extend the behavior or
|
||||
* appearance of HTML elements and components. They allow you to manipulate the DOM, add
|
||||
* custom attributes, and respond to events. This schematic generates the necessary files
|
||||
* and boilerplate code for a new directive.
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* Automatically export the directive from the specified NgModule, making it accessible to
|
||||
* other modules in the application.
|
||||
*/
|
||||
export?: boolean;
|
||||
/**
|
||||
* Creates the new directive files at the top level of the current project. If set to false,
|
||||
* a new folder with the directive's name will be created to contain the files.
|
||||
*/
|
||||
flat?: boolean;
|
||||
/**
|
||||
* Specify the NgModule where the directive should be declared. If not provided, the CLI
|
||||
* will attempt to find the closest NgModule in the directive's path.
|
||||
*/
|
||||
module?: string;
|
||||
/**
|
||||
* The name for the new directive. This will be used to create the directive's class and
|
||||
* spec files (e.g., `my-directive.directive.ts` and `my-directive.directive.spec.ts`).
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The path where the directive files should be created, relative to the workspace root. If
|
||||
* not provided, the directive will be created in the current directory.
|
||||
*/
|
||||
path?: string;
|
||||
/**
|
||||
* A prefix to be added to the directive's selector. For example, if the prefix is `app` and
|
||||
* the directive name is `highlight`, the selector will be `appHighlight`.
|
||||
*/
|
||||
prefix?: string;
|
||||
/**
|
||||
* The name of the project where the directive should be added. If not specified, the CLI
|
||||
* will determine the project from the current directory.
|
||||
*/
|
||||
project: string;
|
||||
/**
|
||||
* The HTML selector to use for this directive. If not provided, a selector will be
|
||||
* generated based on the directive's name (e.g., `appHighlight`).
|
||||
*/
|
||||
selector?: string;
|
||||
/**
|
||||
* Do not automatically import the new directive into its closest NgModule.
|
||||
*/
|
||||
skipImport?: boolean;
|
||||
/**
|
||||
* Skip the generation of a unit test file `spec.ts` for the new directive.
|
||||
*/
|
||||
skipTests?: boolean;
|
||||
/**
|
||||
* Generate a standalone directive. Standalone directives are self-contained and don't need
|
||||
* to be declared in an NgModule. They can be used independently or imported directly into
|
||||
* other standalone components or directives.
|
||||
*/
|
||||
standalone?: boolean;
|
||||
/**
|
||||
* Append a custom type to the directive's filename. For example, if you set the type to
|
||||
* `directive`, the file will be named `example.directive.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"}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"$id": "SchematicsAngularDirective",
|
||||
"title": "Angular Directive Options Schema",
|
||||
"type": "object",
|
||||
"description": "Creates a new directive in your project. Directives are used to extend the behavior or appearance of HTML elements and components. They allow you to manipulate the DOM, add custom attributes, and respond to events. This schematic generates the necessary files and boilerplate code for a new directive.",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "The name for the new directive. This will be used to create the directive's class and spec files (e.g., `my-directive.directive.ts` and `my-directive.directive.spec.ts`).",
|
||||
"$default": {
|
||||
"$source": "argv",
|
||||
"index": 0
|
||||
},
|
||||
"x-prompt": "What name would you like to use for the directive?"
|
||||
},
|
||||
"path": {
|
||||
"type": "string",
|
||||
"format": "path",
|
||||
"$default": {
|
||||
"$source": "workingDirectory"
|
||||
},
|
||||
"description": "The path where the directive files should be created, relative to the workspace root. If not provided, the directive will be created in the current directory.",
|
||||
"visible": false
|
||||
},
|
||||
"project": {
|
||||
"type": "string",
|
||||
"description": "The name of the project where the directive should be added. If not specified, the CLI will determine the project from the current directory.",
|
||||
"$default": {
|
||||
"$source": "projectName"
|
||||
}
|
||||
},
|
||||
"prefix": {
|
||||
"type": "string",
|
||||
"description": "A prefix to be added to the directive's selector. For example, if the prefix is `app` and the directive name is `highlight`, the selector will be `appHighlight`.",
|
||||
"alias": "p",
|
||||
"oneOf": [
|
||||
{
|
||||
"maxLength": 0
|
||||
},
|
||||
{
|
||||
"minLength": 1,
|
||||
"format": "html-selector"
|
||||
}
|
||||
]
|
||||
},
|
||||
"skipTests": {
|
||||
"type": "boolean",
|
||||
"description": "Skip the generation of a unit test file `spec.ts` for the new directive.",
|
||||
"default": false
|
||||
},
|
||||
"skipImport": {
|
||||
"type": "boolean",
|
||||
"description": "Do not automatically import the new directive into its closest NgModule.",
|
||||
"default": false
|
||||
},
|
||||
"selector": {
|
||||
"type": "string",
|
||||
"format": "html-selector",
|
||||
"description": "The HTML selector to use for this directive. If not provided, a selector will be generated based on the directive's name (e.g., `appHighlight`)."
|
||||
},
|
||||
"standalone": {
|
||||
"description": "Generate a standalone directive. Standalone directives are self-contained and don't need to be declared in an NgModule. They can be used independently or imported directly into other standalone components or directives.",
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"x-user-analytics": "ep.ng_standalone"
|
||||
},
|
||||
"flat": {
|
||||
"type": "boolean",
|
||||
"description": "Creates the new directive files at the top level of the current project. If set to false, a new folder with the directive's name will be created to contain the files.",
|
||||
"default": true
|
||||
},
|
||||
"module": {
|
||||
"type": "string",
|
||||
"description": "Specify the NgModule where the directive should be declared. If not provided, the CLI will attempt to find the closest NgModule in the directive's path.",
|
||||
"alias": "m"
|
||||
},
|
||||
"export": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Automatically export the directive from the specified NgModule, making it accessible to other modules in the application."
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"description": "Append a custom type to the directive's filename. For example, if you set the type to `directive`, the file will be named `example.directive.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