Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/ftd main package #2060

Closed
wants to merge 2 commits into from
Closed

Feat/ftd main package #2060

wants to merge 2 commits into from

Conversation

siddhantk232
Copy link
Contributor

@siddhantk232 siddhantk232 commented Jan 31, 2025

TODO

  • ftd.main-package variable
  • Add app param to ftd.app-path
  • Update docs of ftd.app-path
  • Document ftd.main-package

WARN: the `ftd.main-package` does not work yet. It's stored in the
`global` map in js output and it's not getting resolved when used in an
ftd file. This should be key on `ftd` object itself.

- `ftd.main-package`: A string variable that stores the name of the
  packaeg. This is useful to determine if a package is mounted in
  another package or if it's running standalone.
- Refactor: Create `HostBuiltins` type and use it instead of Array of
  fixed sized type everywhere. This makes it easy to add new builtins
This allows to use the following in ftd code:

```ftd
-- ftd.text: $ftd.main-package
```
///
/// Useful to determine if the package is run standalone or as a dependency:
#[inline]
pub fn main_package(pkg: &fastn_core::Package) -> (String, fastn_resolved::Definition) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also take fastn_core::Config as argument, for the same reason I discussed yesterday.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also maybe you can make impl Config { fn main_package() {} } so it shows up in code completion etc, which has better discovery than scattered utility methods.

@amitu
Copy link
Contributor

amitu commented Jan 31, 2025

In the task list add docs as well.

@siddhantk232 siddhantk232 force-pushed the feat/ftd_main_package branch from 8ecb8ce to 5806e7a Compare January 31, 2025 08:31
@siddhantk232
Copy link
Contributor Author

Closing in favor of #2061

@amitu amitu deleted the feat/ftd_main_package branch January 31, 2025 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants