@tsed/cli 6.2.0-beta.3 → 6.2.0

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { register } from "node:module";
3
3
  import { join } from "node:path";
4
- import { pathToFileURL } from "node:url";
4
+ import { fileURLToPath, pathToFileURL } from "node:url";
5
5
  const EXT = process.env.CLI_MODE === "ts" ? "ts" : "js";
6
6
  register(pathToFileURL(join(import.meta.dirname, `../loaders/alias.hook.${EXT}`)), {
7
7
  parentURL: import.meta.dirname,
@@ -12,7 +12,6 @@ import { RoutePipe } from "../../pipes/RoutePipe.js";
12
12
  import { ProvidersInfoService } from "../../services/ProvidersInfoService.js";
13
13
  import { SrcRendererService } from "../../services/Renderer.js";
14
14
  import { fillImports } from "../../utils/fillImports.js";
15
- import { getFrameworksPrompt } from "../init/prompts/getFeaturesPrompt.js";
16
15
  import { PROVIDER_TYPES } from "./ProviderTypes.js";
17
16
  const DECORATOR_TYPES = [
18
17
  { name: "Class decorator", value: "class" },
@@ -64,13 +63,24 @@ let GenerateCmd = GenerateCmd_1 = class GenerateCmd {
64
63
  when: !initialOptions.name
65
64
  },
66
65
  {
67
- ...getFrameworksPrompt(),
68
66
  message: "Which platform?",
69
67
  type: "list",
70
68
  name: "platform",
71
69
  when(state) {
72
70
  return ["server"].includes(state.type || initialOptions.type);
73
- }
71
+ },
72
+ choices: [
73
+ {
74
+ name: "Express.js",
75
+ checked: true,
76
+ value: "express"
77
+ },
78
+ {
79
+ name: "Koa.js",
80
+ checked: false,
81
+ value: "koa"
82
+ }
83
+ ]
74
84
  },
75
85
  {
76
86
  type: "input",
@@ -144,25 +154,13 @@ let GenerateCmd = GenerateCmd_1 = class GenerateCmd {
144
154
  const { symbolPath } = ctx;
145
155
  if (this.providersList.isMyProvider(ctx.type, GenerateCmd_1)) {
146
156
  const type = [ctx.type, ctx.templateType].filter(Boolean).join(".");
147
- let template = `generate/${type}.hbs`;
148
- if (ctx.type === "server") {
149
- template = `generate/server/${ctx.platform}/server.hbs`;
150
- }
157
+ const template = `generate/${type}.hbs`;
151
158
  return [
152
159
  {
153
160
  title: `Generate ${ctx.type} file to '${symbolPath}.ts'`,
154
- task: () => {
155
- if (ctx.type === "server") {
156
- return this.srcRenderService.render(template, ctx, {
157
- baseDir: "generate",
158
- basename: `${symbolPath}.ts`,
159
- replaces: [`server/${ctx.platform}`]
160
- });
161
- }
162
- return this.srcRenderService.render(template, ctx, {
163
- output: `${symbolPath}.ts`
164
- });
165
- }
161
+ task: () => this.srcRenderService.render(template, ctx, {
162
+ output: `${symbolPath}.ts`
163
+ })
166
164
  },
167
165
  {
168
166
  title: `Update bin/index`,
@@ -360,7 +360,7 @@ InitCmd = __decorate([
360
360
  "-p, --platform <platform>": {
361
361
  type: String,
362
362
  defaultValue: PlatformType.EXPRESS,
363
- description: "Set the default platform for Ts.ED (express, koa or fastify)"
363
+ description: "Set the default platform for Ts.ED (express or koa)"
364
364
  },
365
365
  "--features <features...>": {
366
366
  type: Array,
@@ -44,16 +44,12 @@ export var FeatureType;
44
44
  export const FeaturesMap = {
45
45
  [PlatformType.EXPRESS]: {
46
46
  name: "Express.js",
47
- checked: (options) => options.platform === PlatformType.EXPRESS || !options.platform
47
+ checked: (options) => options.platform !== PlatformType.KOA
48
48
  },
49
49
  [PlatformType.KOA]: {
50
50
  name: "Koa.js",
51
51
  checked: (options) => options.platform === PlatformType.KOA
52
52
  },
53
- [PlatformType.FASTIFY]: {
54
- name: "Fastify.js (beta)",
55
- checked: (options) => options.platform === PlatformType.FASTIFY
56
- },
57
53
  [FeatureType.GRAPHQL]: {
58
54
  name: "TypeGraphQL",
59
55
  dependencies: {
@@ -283,14 +279,13 @@ export const FeaturesMap = {
283
279
  checked: false
284
280
  }
285
281
  };
286
- export const FrameworksPrompt = {
287
- message: "Choose the target Framework:",
288
- type: "list",
289
- name: "platform",
290
- choices: [PlatformType.EXPRESS, PlatformType.KOA, PlatformType.FASTIFY]
291
- };
292
282
  export const FeaturesPrompt = (availableRuntimes, availablePackageManagers) => [
293
- FrameworksPrompt,
283
+ {
284
+ message: "Choose the target Framework:",
285
+ type: "list",
286
+ name: "platform",
287
+ choices: [PlatformType.EXPRESS, PlatformType.KOA]
288
+ },
294
289
  {
295
290
  message: "Choose the architecture for your project:",
296
291
  type: "list",
@@ -1,5 +1,5 @@
1
1
  import { cleanObject, isFunction } from "@tsed/core";
2
- import { FeaturesMap, FeaturesPrompt, FrameworksPrompt } from "../config/FeaturesPrompt.js";
2
+ import { FeaturesMap, FeaturesPrompt } from "../config/FeaturesPrompt.js";
3
3
  function mapChoices(item, options) {
4
4
  return item.choices.map((choice) => {
5
5
  const { checked } = FeaturesMap[choice];
@@ -11,22 +11,10 @@ function mapChoices(item, options) {
11
11
  });
12
12
  }
13
13
  export function getFeaturesPrompt(runtimes, availablePackageManagers, options) {
14
- return FeaturesPrompt(runtimes, availablePackageManagers).map((item, index) => {
14
+ return FeaturesPrompt(runtimes, availablePackageManagers).map((item) => {
15
15
  return cleanObject({
16
16
  ...item,
17
17
  choices: item.choices?.length ? mapChoices(item, options) : undefined
18
18
  });
19
19
  });
20
20
  }
21
- export function getFrameworksPrompt() {
22
- return {
23
- ...FrameworksPrompt,
24
- choices: FrameworksPrompt.choices.map((choice, index) => {
25
- return cleanObject({
26
- ...FeaturesMap[choice],
27
- checked: index === 0,
28
- value: choice
29
- });
30
- })
31
- };
32
- }
@@ -5,7 +5,7 @@ const { path, packageJson } = readPackageUpSync({
5
5
  });
6
6
  export const PKG = packageJson;
7
7
  export const MINIMAL_TSED_VERSION = "8";
8
- export const DEFAULT_TSED_TAGS = "beta";
8
+ export const DEFAULT_TSED_TAGS = "latest";
9
9
  export const IGNORE_VERSIONS = ["6.0.0"];
10
10
  export const IGNORE_TAGS = false; // /alpha|beta/
11
11
  export const TEMPLATE_DIR = join(dirname(path), "templates");
@@ -2,5 +2,4 @@ export var PlatformType;
2
2
  (function (PlatformType) {
3
3
  PlatformType["EXPRESS"] = "express";
4
4
  PlatformType["KOA"] = "koa";
5
- PlatformType["FASTIFY"] = "fastify";
6
5
  })(PlatformType || (PlatformType = {}));
@@ -1,8 +1,7 @@
1
1
  import { __decorate } from "tslib";
2
- import { injectMany } from "@tsed/cli-core";
2
+ import { Inject, injectMany } from "@tsed/cli-core";
3
3
  import { Module } from "@tsed/di";
4
4
  import { InitExpressPlatform } from "./supports/InitExpressPlatform.js";
5
- import { InitFastifyPlatform } from "./supports/InitFastifyPlatform.js";
6
5
  import { InitKoaPlatform } from "./supports/InitKoaPlatform.js";
7
6
  let InitPlatformsModule = class InitPlatformsModule {
8
7
  constructor() {
@@ -14,7 +13,7 @@ let InitPlatformsModule = class InitPlatformsModule {
14
13
  };
15
14
  InitPlatformsModule = __decorate([
16
15
  Module({
17
- imports: [InitExpressPlatform, InitKoaPlatform, InitFastifyPlatform]
16
+ imports: [InitExpressPlatform, InitKoaPlatform]
18
17
  })
19
18
  ], InitPlatformsModule);
20
19
  export { InitPlatformsModule };
@@ -16,7 +16,6 @@ export function fillImports(ctx) {
16
16
  { from: "@tsed/platform-log-request", comment: " // remove this import if you don't want log request" },
17
17
  ctx.express && { from: "@tsed/platform-express", comment: " // /!\\ keep this import" },
18
18
  ctx.koa && { from: "@tsed/platform-koa", comment: " // /!\\ keep this import" },
19
- ctx.fastify && { from: "@tsed/platform-fastify", comment: " // /!\\ keep this import" },
20
19
  { from: "@tsed/ajv" },
21
20
  ctx.swagger && { from: "@tsed/swagger" },
22
21
  ctx.scalar && { from: "@tsed/scalar" },