question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] External DeepKit CLI for Managing Applications

See original GitHub issue

DeepKit makes CLI commands part of the application so that we can easily add our own commands. This is definitely a great design, but when there is not only a DeepKit application per repository (such as Angular + DeepKit repo or DeepKit monorepo), an external CLI can make things much easier.

The DeepKit CLI should super lightweight. Its reponsibility is just managing applications.

Launching Applications

Like Angular CLI, it has a configuration file deepkit.json generated by the DeepKit CLI when creating new applications.

{
  "applications": {
    "app1": {
      "root": "projects/app1",
      "tsConfig": "projects/app1/tsconfig.app.json"
    },
    "app2": {
      "root": "projects/app2",
      "tsConfig": "projects/app2/tsconfig.app.json"
    },
  },
  "applicationDefault": "app1",
}

Now we can launch our applications using the CLI:

deepkit run server:start // app1 by default
deepkit run server:start -p app2 // shortcut of --project

These are equivalent to:

npx ts-node -P projects/app1/tsconfig.app.json projects/app1/app.ts server:start
npx ts-node -P projects/app2/tsconfig.app.json projects/app2/app.ts server:start

Note that shebang is not possible with the case of multiple applications, as there are usually multiple tsconfigs, especially when the repo contains both frontend and backend projects.

Building Applications

With DeepKit CLI, we have the project roots and tsconfigs specified in the deepkit.json, so we can simply build applications like this:

deepkit build
deepkit build -p app2

These are equivalent to:

tsc -p projects/app1/tsconfig.app.json
tsc -p projects/app2/tsconfig.app.json

Unlike Angular and ts-node having their own CLI entry, currently deepkit relies on ts-node and tsc, which makes us unable to know which tsconfig we are using, so @deepkit/type-compiler can only look for tsconfig by using const tsconfigPath = join(currentDir, 'tsconfig.json').

This makes it impossible for us to customize the path of tsconfig, and also prevents us from using the extends feature of tsconfig. But now the paths of tsconfig are all specified in deepkit.json, we can resolve the correct tsconfig of each project.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
marcjcommented, Apr 8, 2022

I’d really prefer to not introduce yet another build system when its not totally necessary. The issue with @deepkit/type-compiler’s tsconfig.json resolution algorithm can be solved, but is even in its current stage able to support extends feature and multiple projects in the same repo. You just have to put a tsconfig.json inside each sub project folder and don’t rely solely on custom filenames llike tsconfig.app.json. You can though, but you have to put tsconfig.json right next to it, or in an appropriate sub folder. The current flexibility makes it actually easier to have multiple projects in the same repo as you have not to think about or adjust a deepkit specific configuration file in order to set up it. It works naturally with the build tools you already use.

Deepkit’s app framework (@deepkit/app and @deepkit/framework) was explicitly designed to never require a global deepkit CLI tool or any untyped configuration files, to not hide complexity or hide the entry point of your application. There is nothing worse than having to deal with a huge json configuration file like we have in Angular with angular.json and other frameworks. It’s unergonomic, unintuitive, and decreases flexibility. If Deepkit can be used with any build tools out of the box like nx, webpack, etc, then this is a win for me. Requiring to learn yet another build tool and configuration schema in JSON is a huge loss regarding developer experience and flexibility for me.

Unfortunately, I don’t see in this proposal any improvement, but only drawbacks.

0reactions
marcjcommented, Aug 7, 2022

It requires every developer to manually make main.ts executable after cloning the repository

Git stores file permissions like the execution bit

Read more comments on GitHub >

github_iconTop Results From Across the Web

deepkit/deepkit-framework: A new full-featured and ... - GitHub
A new full-featured and high-performance TypeScript framework for enterprise applications. - GitHub - deepkit/deepkit-framework: A new full-featured and ...
Read more >
Framework - Deepkit
Deepkit framework is highly modular and allows you to split your application into several handy modules. Each module has its own dependency injection...
Read more >
CLI :: Deepkit
A CLI application in Deepkit has full access to the DI container and can thus access all providers and configuration options. The arguments...
Read more >
CLI / Framework - High-Performance TypeScript Framework
A new full-featured web framework for sophisticated TypeScript web applications.
Read more >
Deployment / Framework - Documentation | Deepkit - Deepkit
A new full-featured web framework for sophisticated TypeScript web applications.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found