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

Convert cue import into typescript #24

Closed
ying-jeanne opened this issue Aug 27, 2021 · 2 comments · Fixed by #33
Closed

Convert cue import into typescript #24

ying-jeanne opened this issue Aug 27, 2021 · 2 comments · Fixed by #33

Comments

@ying-jeanne
Copy link
Collaborator

an example of cue import https://github.com/grafana/grafana/blob/main/public/app/plugins/panel/timeseries/models.cue

@ying-jeanne ying-jeanne added this to To do in Grafana Backend (DO NOT USE!) via automation Aug 30, 2021
@ying-jeanne ying-jeanne added this to the 8.2.0 milestone Aug 30, 2021
@ying-jeanne ying-jeanne self-assigned this Aug 30, 2021
@ying-jeanne
Copy link
Collaborator Author

an example would be something in cue:

import (
    ui "github.com/grafana/grafana/packages/grafana-schema/src/schema"
)

to

import * as ui from "@grafana/ui"

@sdboyer
Copy link
Contributor

sdboyer commented Aug 31, 2021

What we want here is, i think, an entirely separate generator from our existing func Generate(), on the expectation that we're going to want to handle import generation separately from generating the body. This is a necessary outgrowth of our existing type signatures - if we want Generate() to continue taking a cue.Value (and we do), then swimming back upstream from the cue.Value to finding import statements becomes difficult, so we should handle them separately.

This would be a reasonable signature:

type ImportMapper func(*ast.ImportSpec) (string, error) // Already in cuetsy, but needs type sig change
func GenerateImports(imports []*ast.ImportSpec, mapper ImportMapper) ([]byte, error) {}

We could, at some later point, add an e.g. func GenerateFile(), which itself would internally call GenerateImports() and Generate(), but for now we can leave it up to the user to put these bits together themselves.

@ying-jeanne ying-jeanne moved this from To do to In progress in Grafana Backend (DO NOT USE!) Sep 7, 2021
@ying-jeanne ying-jeanne removed this from the 8.2.0 milestone Sep 14, 2021
@marefr marefr moved this from In progress to To do in Grafana Backend (DO NOT USE!) Sep 14, 2021
Grafana Backend (DO NOT USE!) automation moved this from To do to Done Sep 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants