@angular/cli 18.0.0-next.2 → 18.0.0-next.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -395,6 +395,9 @@
395
395
  "description": "The builder used for this package.",
396
396
  "not": {
397
397
  "enum": [
398
+ "@angular/build:application",
399
+ "@angular/build:dev-server",
400
+ "@angular/build:extract-i18n",
398
401
  "@angular-devkit/build-angular:application",
399
402
  "@angular-devkit/build-angular:app-shell",
400
403
  "@angular-devkit/build-angular:browser",
@@ -432,6 +435,28 @@
432
435
  "builder"
433
436
  ]
434
437
  },
438
+ {
439
+ "type": "object",
440
+ "additionalProperties": false,
441
+ "properties": {
442
+ "builder": {
443
+ "const": "@angular/build:application"
444
+ },
445
+ "defaultConfiguration": {
446
+ "type": "string",
447
+ "description": "A default named configuration to use when a target configuration is not provided."
448
+ },
449
+ "options": {
450
+ "$ref": "#/definitions/AngularBuildBuildersApplicationSchema"
451
+ },
452
+ "configurations": {
453
+ "type": "object",
454
+ "additionalProperties": {
455
+ "$ref": "#/definitions/AngularBuildBuildersApplicationSchema"
456
+ }
457
+ }
458
+ }
459
+ },
435
460
  {
436
461
  "type": "object",
437
462
  "additionalProperties": false,
@@ -444,12 +469,12 @@
444
469
  "description": "A default named configuration to use when a target configuration is not provided."
445
470
  },
446
471
  "options": {
447
- "$ref": "#/definitions/AngularDevkitBuildAngularBuildersApplicationSchema"
472
+ "$ref": "#/definitions/AngularBuildBuildersApplicationSchema"
448
473
  },
449
474
  "configurations": {
450
475
  "type": "object",
451
476
  "additionalProperties": {
452
- "$ref": "#/definitions/AngularDevkitBuildAngularBuildersApplicationSchema"
477
+ "$ref": "#/definitions/AngularBuildBuildersApplicationSchema"
453
478
  }
454
479
  }
455
480
  }
@@ -520,6 +545,28 @@
520
545
  }
521
546
  }
522
547
  },
548
+ {
549
+ "type": "object",
550
+ "additionalProperties": false,
551
+ "properties": {
552
+ "builder": {
553
+ "const": "@angular/build:dev-server"
554
+ },
555
+ "defaultConfiguration": {
556
+ "type": "string",
557
+ "description": "A default named configuration to use when a target configuration is not provided."
558
+ },
559
+ "options": {
560
+ "$ref": "#/definitions/AngularBuildBuildersDevServerSchema"
561
+ },
562
+ "configurations": {
563
+ "type": "object",
564
+ "additionalProperties": {
565
+ "$ref": "#/definitions/AngularBuildBuildersDevServerSchema"
566
+ }
567
+ }
568
+ }
569
+ },
523
570
  {
524
571
  "type": "object",
525
572
  "additionalProperties": false,
@@ -542,6 +589,28 @@
542
589
  }
543
590
  }
544
591
  },
592
+ {
593
+ "type": "object",
594
+ "additionalProperties": false,
595
+ "properties": {
596
+ "builder": {
597
+ "const": "@angular/build:extract-i18n"
598
+ },
599
+ "defaultConfiguration": {
600
+ "type": "string",
601
+ "description": "A default named configuration to use when a target configuration is not provided."
602
+ },
603
+ "options": {
604
+ "$ref": "#/definitions/AngularBuildBuildersExtractI18nSchema"
605
+ },
606
+ "configurations": {
607
+ "type": "object",
608
+ "additionalProperties": {
609
+ "$ref": "#/definitions/AngularBuildBuildersExtractI18nSchema"
610
+ }
611
+ }
612
+ }
613
+ },
545
614
  {
546
615
  "type": "object",
547
616
  "additionalProperties": false,
@@ -1710,7 +1779,7 @@
1710
1779
  }
1711
1780
  }
1712
1781
  },
1713
- "AngularDevkitBuildAngularBuildersApplicationSchema": {
1782
+ "AngularBuildBuildersApplicationSchema": {
1714
1783
  "title": "Application schema for Build Facade.",
1715
1784
  "description": "Application builder target options",
1716
1785
  "type": "object",
@@ -1720,7 +1789,7 @@
1720
1789
  "description": "List of static application assets.",
1721
1790
  "default": [],
1722
1791
  "items": {
1723
- "$ref": "#/definitions/AngularDevkitBuildAngularBuildersApplicationSchema/definitions/assetPattern"
1792
+ "$ref": "#/definitions/AngularBuildBuildersApplicationSchema/definitions/assetPattern"
1724
1793
  }
1725
1794
  },
1726
1795
  "browser": {
@@ -1951,7 +2020,7 @@
1951
2020
  "description": "Replace compilation source files with other compilation source files in the build.",
1952
2021
  "type": "array",
1953
2022
  "items": {
1954
- "$ref": "#/definitions/AngularDevkitBuildAngularBuildersApplicationSchema/definitions/fileReplacement"
2023
+ "$ref": "#/definitions/AngularBuildBuildersApplicationSchema/definitions/fileReplacement"
1955
2024
  },
1956
2025
  "default": []
1957
2026
  },
@@ -2187,7 +2256,7 @@
2187
2256
  "description": "Budget thresholds to ensure parts of your application stay within boundaries which you set.",
2188
2257
  "type": "array",
2189
2258
  "items": {
2190
- "$ref": "#/definitions/AngularDevkitBuildAngularBuildersApplicationSchema/definitions/budget"
2259
+ "$ref": "#/definitions/AngularBuildBuildersApplicationSchema/definitions/budget"
2191
2260
  },
2192
2261
  "default": []
2193
2262
  },
@@ -3534,6 +3603,110 @@
3534
3603
  }
3535
3604
  }
3536
3605
  },
3606
+ "AngularBuildBuildersDevServerSchema": {
3607
+ "title": "Dev Server Target",
3608
+ "description": "Dev Server target options for Build Facade.",
3609
+ "type": "object",
3610
+ "properties": {
3611
+ "buildTarget": {
3612
+ "type": "string",
3613
+ "description": "A build builder target to serve in the format of `project:target[:configuration]`. You can also pass in more than one configuration name as a comma-separated list. Example: `project:target:production,staging`.",
3614
+ "pattern": "^[^:\\s]*:[^:\\s]*(:[^\\s]+)?$"
3615
+ },
3616
+ "port": {
3617
+ "type": "number",
3618
+ "description": "Port to listen on.",
3619
+ "default": 4200
3620
+ },
3621
+ "host": {
3622
+ "type": "string",
3623
+ "description": "Host to listen on.",
3624
+ "default": "localhost"
3625
+ },
3626
+ "proxyConfig": {
3627
+ "type": "string",
3628
+ "description": "Proxy configuration file. For more information, see https://angular.io/guide/build#proxying-to-a-backend-server."
3629
+ },
3630
+ "ssl": {
3631
+ "type": "boolean",
3632
+ "description": "Serve using HTTPS.",
3633
+ "default": false
3634
+ },
3635
+ "sslKey": {
3636
+ "type": "string",
3637
+ "description": "SSL key to use for serving HTTPS."
3638
+ },
3639
+ "sslCert": {
3640
+ "type": "string",
3641
+ "description": "SSL certificate to use for serving HTTPS."
3642
+ },
3643
+ "headers": {
3644
+ "type": "object",
3645
+ "description": "Custom HTTP headers to be added to all responses.",
3646
+ "propertyNames": {
3647
+ "pattern": "^[-_A-Za-z0-9]+$"
3648
+ },
3649
+ "additionalProperties": {
3650
+ "type": "string"
3651
+ }
3652
+ },
3653
+ "open": {
3654
+ "type": "boolean",
3655
+ "description": "Opens the url in default browser.",
3656
+ "default": false,
3657
+ "alias": "o"
3658
+ },
3659
+ "verbose": {
3660
+ "type": "boolean",
3661
+ "description": "Adds more details to output logging."
3662
+ },
3663
+ "liveReload": {
3664
+ "type": "boolean",
3665
+ "description": "Whether to reload the page on change, using live-reload.",
3666
+ "default": true
3667
+ },
3668
+ "servePath": {
3669
+ "type": "string",
3670
+ "description": "The pathname where the application will be served."
3671
+ },
3672
+ "hmr": {
3673
+ "type": "boolean",
3674
+ "description": "Enable hot module replacement.",
3675
+ "default": false
3676
+ },
3677
+ "watch": {
3678
+ "type": "boolean",
3679
+ "description": "Rebuild on change.",
3680
+ "default": true
3681
+ },
3682
+ "poll": {
3683
+ "type": "number",
3684
+ "description": "Enable and define the file watching poll time period in milliseconds."
3685
+ },
3686
+ "prebundle": {
3687
+ "description": "Enable and control the Vite-based development server's prebundling capabilities. To enable prebundling, the Angular CLI cache must also be enabled.",
3688
+ "oneOf": [
3689
+ {
3690
+ "type": "boolean"
3691
+ },
3692
+ {
3693
+ "type": "object",
3694
+ "properties": {
3695
+ "exclude": {
3696
+ "description": "List of package imports that should not be prebundled by the development server. The packages will be bundled into the application code itself.",
3697
+ "type": "array",
3698
+ "items": {
3699
+ "type": "string"
3700
+ }
3701
+ }
3702
+ },
3703
+ "additionalProperties": false
3704
+ }
3705
+ ]
3706
+ }
3707
+ },
3708
+ "additionalProperties": false
3709
+ },
3537
3710
  "AngularDevkitBuildAngularBuildersDevServerSchema": {
3538
3711
  "title": "Dev Server Target",
3539
3712
  "description": "Dev Server target options for Build Facade.",
@@ -3670,6 +3843,48 @@
3670
3843
  {}
3671
3844
  ]
3672
3845
  },
3846
+ "AngularBuildBuildersExtractI18nSchema": {
3847
+ "title": "Extract i18n Target",
3848
+ "description": "Extract i18n target options for Build Facade.",
3849
+ "type": "object",
3850
+ "properties": {
3851
+ "buildTarget": {
3852
+ "type": "string",
3853
+ "description": "A builder target to extract i18n messages in the format of `project:target[:configuration]`. You can also pass in more than one configuration name as a comma-separated list. Example: `project:target:production,staging`.",
3854
+ "pattern": "^[^:\\s]*:[^:\\s]*(:[^\\s]+)?$"
3855
+ },
3856
+ "format": {
3857
+ "type": "string",
3858
+ "description": "Output format for the generated file.",
3859
+ "default": "xlf",
3860
+ "enum": [
3861
+ "xmb",
3862
+ "xlf",
3863
+ "xlif",
3864
+ "xliff",
3865
+ "xlf2",
3866
+ "xliff2",
3867
+ "json",
3868
+ "arb",
3869
+ "legacy-migrate"
3870
+ ]
3871
+ },
3872
+ "progress": {
3873
+ "type": "boolean",
3874
+ "description": "Log progress to the console.",
3875
+ "default": true
3876
+ },
3877
+ "outputPath": {
3878
+ "type": "string",
3879
+ "description": "Path where output will be placed."
3880
+ },
3881
+ "outFile": {
3882
+ "type": "string",
3883
+ "description": "Name of the file to output."
3884
+ }
3885
+ },
3886
+ "additionalProperties": false
3887
+ },
3673
3888
  "AngularDevkitBuildAngularBuildersExtractI18nSchema": {
3674
3889
  "title": "Extract i18n Target",
3675
3890
  "description": "Extract i18n target options for Build Facade.",
@@ -4864,6 +5079,10 @@
4864
5079
  "type": "boolean",
4865
5080
  "description": "Run build when files change.",
4866
5081
  "default": false
5082
+ },
5083
+ "poll": {
5084
+ "type": "number",
5085
+ "description": "Enable and define the file watching poll time period in milliseconds."
4867
5086
  }
4868
5087
  },
4869
5088
  "additionalProperties": false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/cli",
3
- "version": "18.0.0-next.2",
3
+ "version": "18.0.0-next.4",
4
4
  "description": "CLI tool for Angular",
5
5
  "main": "lib/cli/index.js",
6
6
  "bin": {
@@ -25,20 +25,19 @@
25
25
  },
26
26
  "homepage": "https://github.com/angular/angular-cli",
27
27
  "dependencies": {
28
- "@angular-devkit/architect": "0.1800.0-next.2",
29
- "@angular-devkit/core": "18.0.0-next.2",
30
- "@angular-devkit/schematics": "18.0.0-next.2",
31
- "@schematics/angular": "18.0.0-next.2",
28
+ "@angular-devkit/architect": "0.1800.0-next.4",
29
+ "@angular-devkit/core": "18.0.0-next.4",
30
+ "@angular-devkit/schematics": "18.0.0-next.4",
31
+ "@schematics/angular": "18.0.0-next.4",
32
32
  "@yarnpkg/lockfile": "1.1.0",
33
33
  "ansi-colors": "4.1.3",
34
34
  "ini": "4.1.2",
35
- "inquirer": "9.2.17",
35
+ "inquirer": "9.2.19",
36
36
  "jsonc-parser": "3.2.1",
37
- "npm-package-arg": "11.0.1",
37
+ "npm-package-arg": "11.0.2",
38
38
  "npm-pick-manifest": "9.0.0",
39
- "open": "8.4.2",
40
39
  "ora": "5.4.1",
41
- "pacote": "17.0.6",
40
+ "pacote": "18.0.2",
42
41
  "resolve": "1.22.8",
43
42
  "semver": "7.6.0",
44
43
  "symbol-observable": "4.0.0",
@@ -47,17 +46,17 @@
47
46
  "ng-update": {
48
47
  "migrations": "@schematics/angular/migrations/migration-collection.json",
49
48
  "packageGroup": {
50
- "@angular/cli": "18.0.0-next.2",
51
- "@angular/ssr": "18.0.0-next.2",
52
- "@angular-devkit/architect": "0.1800.0-next.2",
53
- "@angular-devkit/build-angular": "18.0.0-next.2",
54
- "@angular-devkit/build-webpack": "0.1800.0-next.2",
55
- "@angular-devkit/core": "18.0.0-next.2",
56
- "@angular-devkit/schematics": "18.0.0-next.2"
49
+ "@angular/cli": "18.0.0-next.4",
50
+ "@angular/ssr": "18.0.0-next.4",
51
+ "@angular-devkit/architect": "0.1800.0-next.4",
52
+ "@angular-devkit/build-angular": "18.0.0-next.4",
53
+ "@angular-devkit/build-webpack": "0.1800.0-next.4",
54
+ "@angular-devkit/core": "18.0.0-next.4",
55
+ "@angular-devkit/schematics": "18.0.0-next.4"
57
56
  }
58
57
  },
59
58
  "engines": {
60
- "node": "^18.19.1 || >=20.11.1",
59
+ "node": "^18.19.1 || ^20.11.1 || >=22.0.0",
61
60
  "npm": "^6.11.0 || ^7.5.6 || >=8.0.0",
62
61
  "yarn": ">= 1.13.0"
63
62
  }
@@ -36,7 +36,7 @@ class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBa
36
36
  describe: `One or more named builder configurations as a comma-separated ` +
37
37
  `list as specified in the "configurations" section in angular.json.\n` +
38
38
  `The builder uses the named configurations to run the given target.\n` +
39
- `For more information, see https://angular.io/guide/workspace-config#alternate-build-configurations.`,
39
+ `For more information, see https://angular.dev/reference/configs/workspace-config#alternate-build-configurations.`,
40
40
  alias: 'c',
41
41
  type: 'string',
42
42
  // Show only in when using --help and auto completion because otherwise comma seperated configuration values will be invalid.
@@ -98,7 +98,7 @@ async function runCommand(args, logger) {
98
98
  'deprecated: %s': color_1.colors.yellow('deprecated:') + ' %s',
99
99
  'Did you mean %s?': 'Unknown command. Did you mean %s?',
100
100
  })
101
- .epilogue('For more information, see https://angular.io/cli/.\n')
101
+ .epilogue('For more information, see https://angular.dev/cli/.\n')
102
102
  .demandCommand(1, command_1.demandCommandFailureMessage)
103
103
  .recommendCommands()
104
104
  .middleware(normalize_options_middleware_1.normalizeOptionsMiddleware)
@@ -1,5 +1,5 @@
1
1
  The command can be used to build a project of type "application" or "library".
2
- When used to build a library, a different builder is invoked, and only the `ts-config`, `configuration`, and `watch` options are applied.
2
+ When used to build a library, a different builder is invoked, and only the `ts-config`, `configuration`, `poll` and `watch` options are applied.
3
3
  All other options apply only to building applications.
4
4
 
5
5
  The application builder uses the [esbuild](https://esbuild.github.io/) build tool, with default configuration options specified in the workspace configuration file (`angular.json`) or with a named alternative configuration.
@@ -15,4 +15,4 @@ either by direct editing or with the `ng config` command.
15
15
  These include `assets`, `styles`, and `scripts` objects that provide runtime-global resources to include in the project.
16
16
  Resources in CSS, such as images and fonts, are automatically written and fingerprinted at the root of the output folder.
17
17
 
18
- For further details, see [Workspace Configuration](guide/workspace-config).
18
+ For further details, see [Workspace Configuration](reference/configs/workspace-config).
@@ -2,7 +2,7 @@ Angular CLI saves a number of cachable operations on disk by default.
2
2
 
3
3
  When you re-run the same build, the build system restores the state of the previous build and re-uses previously performed operations, which decreases the time taken to build and test your applications and libraries.
4
4
 
5
- To amend the default cache settings, add the `cli.cache` object to your [Workspace Configuration](guide/workspace-config).
5
+ To amend the default cache settings, add the `cli.cache` object to your [Workspace Configuration](reference/configs/workspace-config).
6
6
  The object goes under `cli.cache` at the top level of the file, outside the `projects` sections.
7
7
 
8
8
  ```jsonc
@@ -12,13 +12,13 @@ The object goes under `cli.cache` at the top level of the file, outside the `pro
12
12
  "cli": {
13
13
  "cache": {
14
14
  // ...
15
- }
15
+ },
16
16
  },
17
- "projects": {}
17
+ "projects": {},
18
18
  }
19
19
  ```
20
20
 
21
- For more information, see [cache options](guide/workspace-config#cache-options).
21
+ For more information, see [cache options](reference/configs/workspace-config#cache-options).
22
22
 
23
23
  ### Cache environments
24
24
 
@@ -34,7 +34,7 @@ To change the environment setting to `all`, run the following command:
34
34
  ng config cli.cache.environment all
35
35
  ```
36
36
 
37
- For more information, see `environment` in [cache options](guide/workspace-config#cache-options).
37
+ For more information, see `environment` in [cache options](reference/configs/workspace-config#cache-options).
38
38
 
39
39
  <div class="alert is-helpful">
40
40
 
@@ -6,7 +6,7 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import { CommandModuleConstructor } from '../command-builder/utilities/command';
9
- export type CommandNames = 'add' | 'analytics' | 'build' | 'cache' | 'completion' | 'config' | 'deploy' | 'doc' | 'e2e' | 'extract-i18n' | 'generate' | 'lint' | 'make-this-awesome' | 'new' | 'run' | 'serve' | 'test' | 'update' | 'version';
9
+ export type CommandNames = 'add' | 'analytics' | 'build' | 'cache' | 'completion' | 'config' | 'deploy' | 'e2e' | 'extract-i18n' | 'generate' | 'lint' | 'make-this-awesome' | 'new' | 'run' | 'serve' | 'test' | 'update' | 'version';
10
10
  export interface CommandConfig {
11
11
  aliases?: string[];
12
12
  factory: () => Promise<{
@@ -54,10 +54,6 @@ exports.RootCommands = {
54
54
  'deploy': {
55
55
  factory: () => Promise.resolve().then(() => __importStar(require('./deploy/cli'))),
56
56
  },
57
- 'doc': {
58
- factory: () => Promise.resolve().then(() => __importStar(require('./doc/cli'))),
59
- aliases: ['d'],
60
- },
61
57
  'e2e': {
62
58
  factory: () => Promise.resolve().then(() => __importStar(require('./e2e/cli'))),
63
59
  aliases: ['e'],
@@ -44,7 +44,7 @@ Appended \`source <(ng completion script)\` to \`${rcFile}\`. Restart your termi
44
44
  ' Angular CLI. For autocompletion to work, the CLI will need to be on your `$PATH`, which' +
45
45
  ' is typically done with the `-g` flag in `npm install -g @angular/cli`.' +
46
46
  '\n\n' +
47
- 'For more information, see https://angular.io/cli/completion#global-install');
47
+ 'For more information, see https://angular.dev/cli/completion#global-install');
48
48
  }
49
49
  return 0;
50
50
  }
@@ -4,7 +4,7 @@ discover and use CLI commands without lots of memorization.
4
4
 
5
5
  ![A demo of Angular CLI autocompletion in a terminal. The user types several partial `ng` commands,
6
6
  using autocompletion to finish several arguments and list contextual options.
7
- ](generated/images/guide/cli/completion.gif)
7
+ ](assets/images/guide/cli/completion.gif)
8
8
 
9
9
  ## Automated setup
10
10
 
@@ -8,6 +8,6 @@ The configurable property names match command option names,
8
8
  except that in the configuration file, all names must use camelCase,
9
9
  while on the command line options can be given dash-case.
10
10
 
11
- For further details, see [Workspace Configuration](guide/workspace-config).
11
+ For further details, see [Workspace Configuration](reference/configs/workspace-config).
12
12
 
13
13
  For configuration of CLI usage analytics, see [ng analytics](cli/analytics).
@@ -3,7 +3,7 @@ When a project name is not supplied, executes the `deploy` builder for the defau
3
3
 
4
4
  To use the `ng deploy` command, use `ng add` to add a package that implements deployment capabilities to your favorite platform.
5
5
  Adding the package automatically updates your workspace configuration, adding a deployment
6
- [CLI builder](guide/cli-builder).
6
+ [CLI builder](tools/cli/cli-builder).
7
7
  For example:
8
8
 
9
9
  ```json
@@ -1,7 +1,7 @@
1
1
  The command takes an optional project name, as specified in the `projects` section of the `angular.json` workspace configuration file.
2
2
  When a project name is not supplied, executes the `lint` builder for all projects.
3
3
 
4
- To use the `ng lint` command, use `ng add` to add a package that implements linting capabilities. Adding the package automatically updates your workspace configuration, adding a lint [CLI builder](guide/cli-builder).
4
+ To use the `ng lint` command, use `ng add` to add a package that implements linting capabilities. Adding the package automatically updates your workspace configuration, adding a lint [CLI builder](tools/cli/cli-builder).
5
5
  For example:
6
6
 
7
7
  ```json
@@ -18,7 +18,7 @@ const command_config_1 = require("../command-config");
18
18
  /**
19
19
  * Major versions of Node.js that are officially supported by Angular.
20
20
  */
21
- const SUPPORTED_NODE_MAJORS = [18, 20];
21
+ const SUPPORTED_NODE_MAJORS = [18, 20, 22];
22
22
  const PACKAGE_PATTERNS = [
23
23
  /^@angular\/.*/,
24
24
  /^@angular-devkit\/.*/,
@@ -89,7 +89,7 @@ Appended \`source <(ng completion script)\` to \`${rcFile}\`. Restart your termi
89
89
  ' Angular CLI. For autocompletion to work, the CLI will need to be on your `$PATH`, which' +
90
90
  ' is typically done with the `-g` flag in `npm install -g @angular/cli`.' +
91
91
  '\n\n' +
92
- 'For more information, see https://angular.io/cli/completion#global-install');
92
+ 'For more information, see https://angular.dev/cli/completion#global-install');
93
93
  }
94
94
  // Save configuration to remember that the user was prompted.
95
95
  await setCompletionConfig({ ...completionConfig, prompted: true });
@@ -25,5 +25,5 @@ class Version {
25
25
  }
26
26
  }
27
27
  // TODO(bazel): Convert this to use build-time version stamping after flipping the build script to use bazel
28
- // export const VERSION = new Version('18.0.0-next.2');
28
+ // export const VERSION = new Version('18.0.0-next.4');
29
29
  exports.VERSION = new Version(JSON.parse((0, fs_1.readFileSync)((0, path_1.resolve)(__dirname, '../../package.json'), 'utf-8')).version);
@@ -1,23 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright Google LLC All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import { Argv } from 'yargs';
9
- import { CommandModule, CommandModuleImplementation, Options } from '../../command-builder/command-module';
10
- interface DocCommandArgs {
11
- keyword: string;
12
- search?: boolean;
13
- version?: string;
14
- }
15
- export default class DocCommandModule extends CommandModule<DocCommandArgs> implements CommandModuleImplementation<DocCommandArgs> {
16
- command: string;
17
- aliases: string[] | undefined;
18
- describe: string;
19
- longDescriptionPath?: string;
20
- builder(localYargs: Argv): Argv<DocCommandArgs>;
21
- run(options: Options<DocCommandArgs>): Promise<number | void>;
22
- }
23
- export {};
@@ -1,98 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright Google LLC All Rights Reserved.
5
- *
6
- * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
8
- */
9
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- var desc = Object.getOwnPropertyDescriptor(m, k);
12
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
- desc = { enumerable: true, get: function() { return m[k]; } };
14
- }
15
- Object.defineProperty(o, k2, desc);
16
- }) : (function(o, m, k, k2) {
17
- if (k2 === undefined) k2 = k;
18
- o[k2] = m[k];
19
- }));
20
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
- Object.defineProperty(o, "default", { enumerable: true, value: v });
22
- }) : function(o, v) {
23
- o["default"] = v;
24
- });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
32
- var __importDefault = (this && this.__importDefault) || function (mod) {
33
- return (mod && mod.__esModule) ? mod : { "default": mod };
34
- };
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- const open_1 = __importDefault(require("open"));
37
- const command_module_1 = require("../../command-builder/command-module");
38
- const command_config_1 = require("../command-config");
39
- class DocCommandModule extends command_module_1.CommandModule {
40
- command = 'doc <keyword>';
41
- aliases = command_config_1.RootCommands['doc'].aliases;
42
- describe = 'Opens the official Angular documentation (angular.io) in a browser, and searches for a given keyword.';
43
- longDescriptionPath;
44
- builder(localYargs) {
45
- return localYargs
46
- .positional('keyword', {
47
- description: 'The keyword to search for, as provided in the search bar in angular.io.',
48
- type: 'string',
49
- demandOption: true,
50
- })
51
- .option('search', {
52
- description: `Search all of angular.io. Otherwise, searches only API reference documentation.`,
53
- alias: ['s'],
54
- type: 'boolean',
55
- default: false,
56
- })
57
- .option('version', {
58
- description: 'The version of Angular to use for the documentation. ' +
59
- 'If not provided, the command uses your current Angular core version.',
60
- type: 'string',
61
- })
62
- .strict();
63
- }
64
- async run(options) {
65
- let domain = 'angular.io';
66
- if (options.version) {
67
- // version can either be a string containing "next"
68
- if (options.version === 'next') {
69
- domain = 'next.angular.io';
70
- }
71
- else if (options.version === 'rc') {
72
- domain = 'rc.angular.io';
73
- // or a number where version must be a valid Angular version (i.e. not 0, 1 or 3)
74
- }
75
- else if (!isNaN(+options.version) && ![0, 1, 3].includes(+options.version)) {
76
- domain = `v${options.version}.angular.io`;
77
- }
78
- else {
79
- this.context.logger.error('Version should either be a number (2, 4, 5, 6...), "rc" or "next"');
80
- return 1;
81
- }
82
- }
83
- else {
84
- // we try to get the current Angular version of the project
85
- // and use it if we can find it
86
- try {
87
- /* eslint-disable-next-line import/no-extraneous-dependencies */
88
- const currentNgVersion = (await Promise.resolve().then(() => __importStar(require('@angular/core')))).VERSION.major;
89
- domain = `v${currentNgVersion}.angular.io`;
90
- }
91
- catch { }
92
- }
93
- await (0, open_1.default)(options.search
94
- ? `https://${domain}/docs?search=${options.keyword}`
95
- : `https://${domain}/api?query=${options.keyword}`);
96
- }
97
- }
98
- exports.default = DocCommandModule;