nestjs

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IMPORT         = 1
	REQUIRE        = 2
	EXPORT         = 3
	JEST_MOCK      = 4
	DYNAMIC_IMPORT = 5
)
View Source
const DefaultPackageJsonPath = "package.json"

Variables

View Source
var (
	Black   = Color("\033[1;30m%s\033[0m")
	Red     = Color("\033[1;31m%s\033[0m")
	Green   = Color("\033[1;32m%s\033[0m")
	Yellow  = Color("\033[1;33m%s\033[0m")
	Purple  = Color("\033[1;34m%s\033[0m")
	Magenta = Color("\033[1;35m%s\033[0m")
	Teal    = Color("\033[1;36m%s\033[0m")
	White   = Color("\033[1;37m%s\033[0m")
)
View Source
var (
	Info = Teal
	Warn = Yellow
	Err  = Red
)
View Source
var BUILTINS = map[string]bool{
	"assert":         true,
	"async_hooks":    true,
	"buffer":         true,
	"child_process":  true,
	"cluster":        true,
	"console":        true,
	"constants":      true,
	"crypto":         true,
	"dgram":          true,
	"dns":            true,
	"domain":         true,
	"events":         true,
	"fs":             true,
	"http":           true,
	"http2":          true,
	"https":          true,
	"inspector":      true,
	"module":         true,
	"net":            true,
	"os":             true,
	"path":           true,
	"perf_hooks":     true,
	"process":        true,
	"punycode":       true,
	"querystring":    true,
	"readline":       true,
	"repl":           true,
	"stream":         true,
	"string_decoder": true,
	"timers":         true,
	"tls":            true,
	"trace_events":   true,
	"tty":            true,
	"url":            true,
	"util":           true,
	"v8":             true,
	"vm":             true,
	"wasi":           true,
	"worker_threads": true,
	"zlib":           true,
}

BUILTINS list taken from https://github.com/sindresorhus/builtin-modules/blob/master/builtin-modules.json

Functions

func Color

func Color(colorString string) func(string, ...interface{}) string

func NewLanguage

func NewLanguage() language.Language

func ParseTS

func ParseTS(data []byte) ([]string, int, error)

func PkgName

func PkgName(dirpath string) string

Types

type CompilerOptions

type CompilerOptions struct {
	DeleteOutDir bool   `json:"deleteOutDir"`
	Webpack      bool   `json:"webpack"`
	TsConfigPath string `json:"tsConfigPath"`
}

type JestConfig

type JestConfig struct {
	ModuleFileExtensions []string               `json:"moduleFileExtensions"`
	RootDir              string                 `json:"rootDir"`
	TestRegex            string                 `json:"testRegex"`
	Transform            map[string]interface{} `json:"transform"`
	Preset               string                 `json:"preset"`
	CollectCoverageFrom  []string               `json:"collectCoverageFrom"`
	CoverageDirectory    string                 `json:"coverageDirectory"`
	TestEnvironment      string                 `json:"testEnvironment"`
	Roots                []string               `json:"roots"`
	ModuleNameMapper     struct {
		AppAuth string `json:"^@app/auth(|/.*)$"`
		AppUser string `json:"^@app/user(|/.*)$"`
	} `json:"moduleNameMapper"`
	Verbose     bool `json:"verbose"`
	TestTimeout int  `json:"testTimeout"`
}

type NestCliConfig

type NestCliConfig struct {
	Schema          string              `json:"$schema"`
	Collection      string              `json:"collection"`
	SourceRoot      string              `json:"sourceRoot"`
	CompilerOptions *CompilerOptions    `json:"compilerOptions"`
	Monorepo        bool                `json:"monorepo"`
	Root            string              `json:"root"`
	Projects        map[string]*Project `json:"projects"`
}

type NestJS

type NestJS struct {
}

func (*NestJS) CheckFlags

func (lang *NestJS) CheckFlags(fs *flag.FlagSet, c *config.Config) error

CheckFlags validates the configuration after command line flags are parsed. This is called once with the root configuration when Gazelle starts. CheckFlags may set default values in flags or make implied changes.

func (*NestJS) Configure

func (*NestJS) Configure(c *config.Config, rel string, f *rule.File)

Configure modifies the configuration using directives and other information extracted from a build file. Configure is called in each directory.

c is the configuration for the current directory. It starts out as a copy of the configuration for the parent directory.

rel is the slash-separated relative path from the repository root to the current directory. It is "" for the root directory itself.

f is the build file for the current directory or nil if there is no existing build file.

func (*NestJS) Embeds

func (*NestJS) Embeds(r *rule.Rule, from label.Label) []label.Label

Embeds returns a list of labels of rules that the given rule embeds. If a rule is embedded by another importable rule of the same language, only the embedding rule will be indexed. The embedding rule will inherit the imports of the embedded rule.

func (*NestJS) Fix

func (*NestJS) Fix(c *config.Config, f *rule.File)

Fix repairs deprecated usage of language-specific rules in f. This is called before the file is indexed. Unless c.ShouldFix is true, fixes that delete or rename rules should not be performed.Í

func (*NestJS) GenerateRules

func (lang *NestJS) GenerateRules(args language.GenerateArgs) language.GenerateResult

GenerateRules extracts build metadata from source files in a directory. GenerateRules is called in each directory where an update is requested in depth-first post-order.

args contains the arguments for GenerateRules. This is passed as a struct to avoid breaking implementations in the future when new fields are added.

A GenerateResult struct is returned. Optional fields may be added to this type in the future.

func (*NestJS) Imports

func (lang *NestJS) Imports(c *config.Config, r *rule.Rule, f *rule.File) []resolve.ImportSpec

Imports returns a list of ImportSpecs that can be used to import the rule r. This is used to populate RuleIndex.

If nil is returned, the rule will not be indexed. If any non-nil slice is returned, including an empty slice, the rule will be indexed.

func (*NestJS) Kinds

func (*NestJS) Kinds() map[string]rule.KindInfo

Kinds returns a map of maps rule names (kinds) and information on how to match and merge attributes that may be found in rules of those kinds. All kinds of rules generated for this language may be found here.

func (*NestJS) KnownDirectives

func (*NestJS) KnownDirectives() []string

KnownDirectives returns a list of directive keys that this Configurer can interpret. Gazelle prints errors for directives that are not recognized by any Configurer.

func (*NestJS) Loads

func (lang *NestJS) Loads() []rule.LoadInfo

Loads returns .bzl files and symbols they define. Every rule generated by GenerateRules, now or in the past, should be loadable from one of these files.

func (*NestJS) Name

func (*NestJS) Name() string

Name returns the name of the language. This should be a prefix of the kinds of rules generated by the language, e.g., "go" for the Go extension since it generates "go_library" rules.

func (*NestJS) RegisterFlags

func (lang *NestJS) RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config)

RegisterFlags registers command-line flags used by the extension. This method is called once with the root configuration when Gazelle starts. RegisterFlags may set an initial values in Config.Exts. When flags are set, they should modify these values.

func (*NestJS) Resolve

func (lang *NestJS) Resolve(c *config.Config, ix *resolve.RuleIndex, rc *repo.RemoteCache, r *rule.Rule, _imports interface{}, from label.Label)

Resolve translates imported libraries for a given rule into Bazel dependencies. Information about imported libraries is returned for each rule generated by language.GenerateRules in language.GenerateResult.Imports. Resolve generates a "deps" attribute (or the appropriate language-specific equivalent) for each import according to language-specific rules and heuristics. https://www.typescriptlang.org/docs/handbook/module-resolution.html#classic

type NestTranspiler

type NestTranspiler string

type NestjsConfig

type NestjsConfig struct {
	Enabled          bool
	RootTsConfigFile string
	PackageFile      string
	NpmDependencies  struct {
		Dependencies    map[string]string `json:"dependencies"`
		DevDependencies map[string]string `json:"devDependencies"`
	}
	LookupTypes            bool
	ImportAliases          []struct{ From, To string }
	ImportAliasPattern     *regexp.Regexp
	Visibility             Visibility
	CollectBarrels         bool
	CollectWebAssets       bool
	CollectAllAssets       bool
	CollectedAssets        map[string]bool
	CollectAll             bool
	CollectAllRoot         string
	CollectAllSources      map[string]bool
	Fix                    bool
	WebAssetSuffixes       map[string]bool
	Quiet                  bool
	Verbose                bool
	DefaultNpmLabel        string
	JestConfigRelativePath string
	JestTestsPerShard      int
	JestSize               string

	// Nestjs
	RootPkg             string
	Root                string
	CollectWithTsConfig bool
	PackageByDir        map[string]*Project
	SourcePerProject    map[string]map[string]bool
	Monorepo            bool
	NestCliPath         string
	PackageJSONPath     string
	IsNestjs            bool
	CompilerOptions     *CompilerOptions
	Transpiler          NestTranspiler
	RootTsConfig        *TsConfig
	PnpmLockFilePath    string

	IsIgnoreE2E bool
	// contains filtered or unexported fields
}

func NewNestjsConfig

func NewNestjsConfig() *NestjsConfig

func (*NestjsConfig) NewChild

func (parent *NestjsConfig) NewChild() *NestjsConfig

type NestjsConfigs

type NestjsConfigs map[string]*NestjsConfig

func (*NestjsConfigs) ParentForPackage

func (c *NestjsConfigs) ParentForPackage(pkg string) *NestjsConfig

ParentForPackage returns the parent Config for the given Bazel package.

type Project

type Project struct {
	Name         string
	Rel          string
	TsConfig     *TsConfig
	TsConfigRel  string
	TsConfigPath string

	// Default generated by nest cli
	Type            string `json:"type"`
	Root            string `json:"root"`
	EntryFile       string `json:"entryFile"`
	SourceRoot      string `json:"sourceRoot"`
	CompilerOptions struct {
		TsConfigPath string `json:"tsConfigPath"`
	} `json:"compilerOptions"`
}

func (*Project) ParseTsConfig

func (p *Project) ParseTsConfig(cwd string) *TsConfig

type TsConfig

type TsConfig struct {
	Extends         string                  `json:"extends"`
	CompilerOptions TsConfigCompilerOptions `json:"compilerOptions"`
	Include         []string                `json:"include"`
	Exclude         []string                `json:"exclude"`
}

type TsConfigCompilerOptions

type TsConfigCompilerOptions struct {
	Module                           string              `json:"module"`
	Declaration                      bool                `json:"declaration"`
	RemoveComments                   bool                `json:"removeComments"`
	EmitDecoratorMetadata            bool                `json:"emitDecoratorMetadata"`
	ExperimentalDecorators           bool                `json:"experimentalDecorators"`
	AllowSyntheticDefaultImports     bool                `json:"allowSyntheticDefaultImports"`
	Target                           string              `json:"target"`
	SourceMap                        bool                `json:"sourceMap"`
	OutDir                           string              `json:"outDir"`
	BaseURL                          string              `json:"baseUrl"`
	Incremental                      bool                `json:"incremental"`
	SkipLibCheck                     bool                `json:"skipLibCheck"`
	StrictNullChecks                 bool                `json:"strictNullChecks"`
	NoImplicitAny                    bool                `json:"noImplicitAny"`
	StrictBindCallApply              bool                `json:"strictBindCallApply"`
	ForceConsistentCasingInFileNames bool                `json:"forceConsistentCasingInFileNames"`
	NoFallthroughCasesInSwitch       bool                `json:"noFallthroughCasesInSwitch"`
	Paths                            map[string][]string `json:"paths"`
}

type Visibility

type Visibility struct {
	Labels []string
}

func (*Visibility) Set

func (v *Visibility) Set(value string) error

func (*Visibility) String

func (v *Visibility) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL