@tsed/cli 7.0.0-beta.11 → 7.0.0-beta.12

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.
@@ -13,9 +13,7 @@ export class AddCmd {
13
13
  message: "Which cli plugin ?",
14
14
  default: initialOptions.name,
15
15
  when: !initialOptions.name,
16
- source: (state, keyword) => {
17
- return this.cliPlugins.searchPlugins(keyword);
18
- }
16
+ source: () => this.cliPlugins.searchPlugins()
19
17
  }
20
18
  ];
21
19
  }
@@ -3,14 +3,8 @@ import { CliProjectService } from "../../services/CliProjectService.js";
3
3
  import { CliTemplatesService } from "../../services/CliTemplatesService.js";
4
4
  import { addContextMethods } from "../../services/mappers/addContextMethods.js";
5
5
  import { mapDefaultTemplateOptions } from "../../services/mappers/mapDefaultTemplateOptions.js";
6
- const searchFactory = (list) => {
7
- const items = list.map((item) => ({ name: item.label, value: item.id }));
8
- return (_, keyword) => {
9
- if (keyword) {
10
- return items.filter((item) => item.name.toLowerCase().includes(keyword.toLowerCase()));
11
- }
12
- return items;
13
- };
6
+ const mapChoices = (list) => {
7
+ return list.map((item) => ({ label: item.label, value: item.id }));
14
8
  };
15
9
  export class GenerateCmd {
16
10
  constructor() {
@@ -30,7 +24,7 @@ export class GenerateCmd {
30
24
  message: "Which template you want to use?",
31
25
  default: data.type,
32
26
  when: () => templates.length > 1,
33
- source: searchFactory(this.templates.find(data.type))
27
+ choices: mapChoices(this.templates.find(data.type))
34
28
  },
35
29
  {
36
30
  type: "input",
@@ -1,3 +1,5 @@
1
+ import { CliHttpClient } from "@tsed/cli-core";
2
+ import { inject } from "@tsed/di";
1
3
  import { ArchitectureConvention, PlatformType, ProjectConvention } from "../../../interfaces/index.js";
2
4
  import { hasFeature, hasValue, hasValuePremium } from "../utils/hasFeature.js";
3
5
  import { isPlatform } from "../utils/isPlatform.js";
@@ -449,6 +451,24 @@ export const FeaturesPrompt = (availableRuntimes, availablePackageManagers) => [
449
451
  ],
450
452
  when: hasValue("featuresDB", FeatureType.TYPEORM)
451
453
  },
454
+ {
455
+ type: "autocomplete",
456
+ name: "passportPackage",
457
+ message: "Which passport package ?",
458
+ when: hasFeature(FeatureType.PASSPORTJS),
459
+ async source(_, input) {
460
+ const result = await inject(CliHttpClient).get(`https://www.passportjs.org/packages/-/all.json`, {});
461
+ return Object.values(result)
462
+ .filter((o) => {
463
+ return o.name?.startsWith("passport-");
464
+ })
465
+ .filter((item) => item.name.toLowerCase().includes(input.toLowerCase()))
466
+ .map((item) => ({
467
+ name: `${item.name} - ${item.description}`,
468
+ value: item.name
469
+ }));
470
+ }
471
+ },
452
472
  {
453
473
  type: "password",
454
474
  name: "GH_TOKEN",
@@ -3,15 +3,6 @@ import { snakeCase } from "change-case";
3
3
  import { PKG } from "../../constants/index.js";
4
4
  import { render } from "../../fn/render.js";
5
5
  import { CliTemplatesService } from "../../services/CliTemplatesService.js";
6
- const searchFactory = (list) => {
7
- const items = list.map((item) => ({ name: item.label, value: item.id }));
8
- return (_, keyword) => {
9
- if (keyword) {
10
- return items.filter((item) => item.name.toLowerCase().includes(keyword.toLowerCase()));
11
- }
12
- return items;
13
- };
14
- };
15
6
  export class CreateTemplateCommand {
16
7
  constructor() {
17
8
  this.projectPackageJson = inject(ProjectPackageJson);
@@ -38,7 +29,7 @@ export class CreateTemplateCommand {
38
29
  when: (ctx) => {
39
30
  return ctx.from === "existing";
40
31
  },
41
- source: searchFactory(this.templates.find())
32
+ source: () => this.templates.find().map((item) => ({ name: item.label, value: item.id }))
42
33
  },
43
34
  {
44
35
  type: "confirm",
@@ -20,7 +20,12 @@ export default defineTemplate({
20
20
  when(state) {
21
21
  return !!(["controller"].includes(state.type || context.type) || context.directory);
22
22
  },
23
- choices: context.getDirectories("controllers")
23
+ choices: context.getDirectories("controllers").map((value) => {
24
+ return {
25
+ label: value,
26
+ value
27
+ };
28
+ })
24
29
  },
25
30
  {
26
31
  type: "input",