Primeiro commit do projeto Angular
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @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 { Argv } from 'yargs';
|
||||
import { CommandModule, CommandModuleImplementation } from '../../command-builder/command-module';
|
||||
export default class CompletionCommandModule extends CommandModule implements CommandModuleImplementation {
|
||||
command: string;
|
||||
describe: string;
|
||||
longDescriptionPath: string;
|
||||
builder(localYargs: Argv): Argv;
|
||||
run(): Promise<number>;
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
"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 node_path_1 = require("node:path");
|
||||
const command_module_1 = require("../../command-builder/command-module");
|
||||
const command_1 = require("../../command-builder/utilities/command");
|
||||
const color_1 = require("../../utilities/color");
|
||||
const completion_1 = require("../../utilities/completion");
|
||||
const error_1 = require("../../utilities/error");
|
||||
class CompletionCommandModule extends command_module_1.CommandModule {
|
||||
command = 'completion';
|
||||
describe = 'Set up Angular CLI autocompletion for your terminal.';
|
||||
longDescriptionPath = (0, node_path_1.join)(__dirname, 'long-description.md');
|
||||
builder(localYargs) {
|
||||
(0, command_1.addCommandModuleToYargs)(CompletionScriptCommandModule, this.context);
|
||||
return localYargs;
|
||||
}
|
||||
async run() {
|
||||
let rcFile;
|
||||
try {
|
||||
rcFile = await (0, completion_1.initializeAutocomplete)();
|
||||
}
|
||||
catch (err) {
|
||||
(0, error_1.assertIsError)(err);
|
||||
this.context.logger.error(err.message);
|
||||
return 1;
|
||||
}
|
||||
this.context.logger.info(`
|
||||
Appended \`source <(ng completion script)\` to \`${rcFile}\`. Restart your terminal or run the following to autocomplete \`ng\` commands:
|
||||
|
||||
${color_1.colors.yellow('source <(ng completion script)')}
|
||||
`.trim());
|
||||
if ((await (0, completion_1.hasGlobalCliInstall)()) === false) {
|
||||
this.context.logger.warn('Setup completed successfully, but there does not seem to be a global install of the' +
|
||||
' Angular CLI. For autocompletion to work, the CLI will need to be on your `$PATH`, which' +
|
||||
' is typically done with the `-g` flag in `npm install -g @angular/cli`.' +
|
||||
'\n\n' +
|
||||
'For more information, see https://angular.dev/cli/completion#global-install');
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
exports.default = CompletionCommandModule;
|
||||
class CompletionScriptCommandModule extends command_module_1.CommandModule {
|
||||
command = 'script';
|
||||
describe = 'Generate a bash and zsh real-time type-ahead autocompletion script.';
|
||||
longDescriptionPath = undefined;
|
||||
builder(localYargs) {
|
||||
return localYargs;
|
||||
}
|
||||
run() {
|
||||
this.context.yargsInstance.showCompletionScript();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=cli.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"cli.js","sourceRoot":"","sources":["cli.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAEH,yCAAiC;AAEjC,yEAAkG;AAClG,qEAAkF;AAClF,iDAA+C;AAC/C,2DAAyF;AACzF,iDAAsD;AAEtD,MAAqB,uBACnB,SAAQ,8BAAa;IAGrB,OAAO,GAAG,YAAY,CAAC;IACvB,QAAQ,GAAG,sDAAsD,CAAC;IAClE,mBAAmB,GAAG,IAAA,gBAAI,EAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;IAE7D,OAAO,CAAC,UAAgB;QACtB,IAAA,iCAAuB,EAAC,6BAA6B,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAErE,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,GAAG;QACP,IAAI,MAAc,CAAC;QACnB,IAAI,CAAC;YACH,MAAM,GAAG,MAAM,IAAA,mCAAsB,GAAE,CAAC;QAC1C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAA,qBAAa,EAAC,GAAG,CAAC,CAAC;YACnB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAEvC,OAAO,CAAC,CAAC;QACX,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CACtB;mDAC6C,MAAM;;MAEnD,cAAM,CAAC,MAAM,CAAC,gCAAgC,CAAC;OAC9C,CAAC,IAAI,EAAE,CACT,CAAC;QAEF,IAAI,CAAC,MAAM,IAAA,gCAAmB,GAAE,CAAC,KAAK,KAAK,EAAE,CAAC;YAC5C,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CACtB,qFAAqF;gBACnF,0FAA0F;gBAC1F,yEAAyE;gBACzE,MAAM;gBACN,6EAA6E,CAChF,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AA7CD,0CA6CC;AAED,MAAM,6BAA8B,SAAQ,8BAAa;IACvD,OAAO,GAAG,QAAQ,CAAC;IACnB,QAAQ,GAAG,qEAAqE,CAAC;IACjF,mBAAmB,GAAG,SAAS,CAAC;IAEhC,OAAO,CAAC,UAAgB;QACtB,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,GAAG;QACD,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,oBAAoB,EAAE,CAAC;IACpD,CAAC;CACF"}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
Setting up autocompletion configures your terminal, so pressing the `<TAB>` key while in the middle
|
||||
of typing will display various commands and options available to you. This makes it very easy to
|
||||
discover and use CLI commands without lots of memorization.
|
||||
|
||||

|
||||
|
||||
## Automated setup
|
||||
|
||||
The CLI should prompt and ask to set up autocompletion for you the first time you use it (v14+).
|
||||
Simply answer "Yes" and the CLI will take care of the rest.
|
||||
|
||||
```
|
||||
$ ng serve
|
||||
? Would you like to enable autocompletion? This will set up your terminal so pressing TAB while typing Angular CLI commands will show possible options and autocomplete arguments. (Enabling autocompletion will modify configuration files in your home directory.) Yes
|
||||
Appended `source <(ng completion script)` to `/home/my-username/.bashrc`. Restart your terminal or run:
|
||||
|
||||
source <(ng completion script)
|
||||
|
||||
to autocomplete `ng` commands.
|
||||
|
||||
# Serve output...
|
||||
```
|
||||
|
||||
If you already refused the prompt, it won't ask again. But you can run `ng completion` to
|
||||
do the same thing automatically.
|
||||
|
||||
This modifies your terminal environment to load Angular CLI autocompletion, but can't update your
|
||||
current terminal session. Either restart it or run `source <(ng completion script)` directly to
|
||||
enable autocompletion in your current session.
|
||||
|
||||
Test it out by typing `ng ser<TAB>` and it should autocomplete to `ng serve`. Ambiguous arguments
|
||||
will show all possible options and their documentation, such as `ng generate <TAB>`.
|
||||
|
||||
## Manual setup
|
||||
|
||||
Some users may have highly customized terminal setups, possibly with configuration files checked
|
||||
into source control with an opinionated structure. `ng completion` only ever appends Angular's setup
|
||||
to an existing configuration file for your current shell, or creates one if none exists. If you want
|
||||
more control over exactly where this configuration lives, you can manually set it up by having your
|
||||
shell run at startup:
|
||||
|
||||
```bash
|
||||
source <(ng completion script)
|
||||
```
|
||||
|
||||
This is equivalent to what `ng completion` will automatically set up, and gives power users more
|
||||
flexibility in their environments when desired.
|
||||
|
||||
## Platform support
|
||||
|
||||
Angular CLI supports autocompletion for the Bash and Zsh shells on MacOS and Linux operating
|
||||
systems. On Windows, Git Bash and [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/)
|
||||
using Bash or Zsh are supported.
|
||||
|
||||
## Global install
|
||||
|
||||
Autocompletion works by configuring your terminal to invoke the Angular CLI on startup to load the
|
||||
setup script. This means the terminal must be able to find and execute the Angular CLI, typically
|
||||
through a global install that places the binary on the user's `$PATH`. If you get
|
||||
`command not found: ng`, make sure the CLI is installed globally which you can do with the `-g`
|
||||
flag:
|
||||
|
||||
```bash
|
||||
npm install -g @angular/cli
|
||||
```
|
||||
Reference in New Issue
Block a user