-
Notifications
You must be signed in to change notification settings - Fork 26
feat: TypeScript support in charts #502
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "cmp" | ||
| "context" | ||
| "fmt" | ||
|
|
||
| "github.com/spf13/cobra" | ||
|
|
||
| "github.com/werf/common-go/pkg/cli" | ||
| "github.com/werf/nelm/pkg/action" | ||
| "github.com/werf/nelm/pkg/common" | ||
| "github.com/werf/nelm/pkg/log" | ||
| ) | ||
|
|
||
| type chartInitConfig struct { | ||
| action.ChartInitOptions | ||
|
|
||
| LogColorMode string | ||
| LogLevel string | ||
| } | ||
|
|
||
| func newChartInitCommand(ctx context.Context, afterAllCommandsBuiltFuncs map[*cobra.Command]func(cmd *cobra.Command) error) *cobra.Command { | ||
| cfg := &chartInitConfig{} | ||
|
|
||
| cmd := cli.NewSubCommand( | ||
| ctx, | ||
| "init [PATH]", | ||
| "Initialize a new chart.", | ||
| "Initialize a new chart in the specified directory. If PATH is not specified, uses the current directory.", | ||
| 10, // priority for ordering in help | ||
| chartCmdGroup, | ||
| cli.SubCommandOptions{ | ||
| Args: cobra.MaximumNArgs(1), | ||
| ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { | ||
| return nil, cobra.ShellCompDirectiveFilterDirs | ||
| }, | ||
| }, | ||
| func(cmd *cobra.Command, args []string) error { | ||
| ctx = log.SetupLogging(ctx, cmp.Or(log.Level(cfg.LogLevel), log.InfoLevel), log.SetupLoggingOptions{ | ||
| ColorMode: cfg.LogColorMode, | ||
| }) | ||
|
|
||
| if len(args) > 0 { | ||
| cfg.ChartDirPath = args[0] | ||
| } | ||
|
|
||
| if err := action.ChartInit(ctx, cfg.ChartInitOptions); err != nil { | ||
| return fmt.Errorf("chart init: %w", err) | ||
| } | ||
|
|
||
| return nil | ||
| }, | ||
| ) | ||
|
|
||
| afterAllCommandsBuiltFuncs[cmd] = func(cmd *cobra.Command) error { | ||
ilya-lesikov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if err := cli.AddFlag(cmd, &cfg.TS, "ts", false, "Initialize TypeScript chart", cli.AddFlagOptions{ | ||
| Group: mainFlagGroup, | ||
| }); err != nil { | ||
| return fmt.Errorf("add flag: %w", err) | ||
| } | ||
|
|
||
| if err := cli.AddFlag(cmd, &cfg.TempDirPath, "temp-dir", "", "The directory for temporary files. By default, create a new directory in the default system directory for temporary files", cli.AddFlagOptions{ | ||
| GetEnvVarRegexesFunc: cli.GetFlagGlobalEnvVarRegexes, | ||
| Group: miscFlagGroup, | ||
| Type: cli.FlagTypeDir, | ||
| }); err != nil { | ||
| return fmt.Errorf("add flag: %w", err) | ||
| } | ||
|
|
||
| if err := cli.AddFlag(cmd, &cfg.LogColorMode, "color-mode", common.DefaultLogColorMode, "Color mode for logs. "+allowedLogColorModesHelp(), cli.AddFlagOptions{ | ||
| GetEnvVarRegexesFunc: cli.GetFlagGlobalAndLocalEnvVarRegexes, | ||
| Group: miscFlagGroup, | ||
| }); err != nil { | ||
| return fmt.Errorf("add flag: %w", err) | ||
| } | ||
|
|
||
| if err := cli.AddFlag(cmd, &cfg.LogLevel, "log-level", string(log.InfoLevel), "Set log level. "+allowedLogLevelsHelp(), cli.AddFlagOptions{ | ||
| GetEnvVarRegexesFunc: cli.GetFlagGlobalAndLocalEnvVarRegexes, | ||
| Group: miscFlagGroup, | ||
| }); err != nil { | ||
| return fmt.Errorf("add flag: %w", err) | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| return cmd | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package tschart | ||
|
|
||
| import ( | ||
| "github.com/dop251/goja" | ||
| "github.com/dop251/goja_nodejs/console" | ||
| "github.com/dop251/goja_nodejs/require" | ||
| ) | ||
|
|
||
| func SetupConsoleGlobal(runtime *goja.Runtime) { | ||
| registry := require.NewRegistry() | ||
| registry.Enable(runtime) | ||
|
|
||
| console.Enable(runtime) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.