MCPcopy Create free account
hub / github.com/chakra-ui/panda / Builder

Class Builder

packages/node/src/builder.ts:20–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20export class Builder {
21 /**
22 * The current panda context
23 */
24 context: PandaContext | undefined
25
26 private hasEmitted = false
27 private filesMeta: FileChanges | undefined
28 private explicitDepsMeta: FileChanges | undefined
29 private affecteds: DiffConfigResult | undefined
30 private configDependencies: Set<string> = new Set()
31
32 setConfigDependencies(options: SetupContextOptions) {
33 const tsOptions = this.context?.conf.tsOptions ?? { baseUrl: undefined, pathMappings: [] }
34 const compilerOptions = this.context?.conf.tsconfig?.compilerOptions ?? {}
35
36 const { deps: foundDeps } = getConfigDependencies(options.configPath, tsOptions, compilerOptions)
37 const cwd = options?.cwd ?? this.context?.config.cwd ?? process.cwd()
38
39 const configDeps = new Set([
40 ...foundDeps,
41 ...(this.context?.conf.dependencies ?? []).map((file) => resolve(cwd, file)),
42 ])
43
44 configDeps.forEach((file) => {
45 this.configDependencies.add(file)
46 })
47
48 logger.debug('builder', 'Config dependencies')
49 logger.debug('builder', configDeps)
50 }
51
52 setup = async (options: { configPath?: string; cwd?: string } = {}) => {
53 logger.debug('builder', '🚧 Setup')
54
55 const configPath = options.configPath ?? findConfig({ cwd: options.cwd })
56 this.setConfigDependencies({ configPath, cwd: options.cwd })
57
58 if (!this.context) {
59 return this.setupContext({ configPath, cwd: options.cwd })
60 }
61
62 const ctx = this.getContextOrThrow()
63
64 this.affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
65 this.context = new PandaContext(conf)
66 })
67
68 logger.debug('builder', this.affecteds)
69
70 // explicit config dependencies change
71 this.explicitDepsMeta = this.checkFilesChanged(this.context.explicitDeps)
72
73 if (this.explicitDepsMeta.hasFilesChanged) {
74 this.explicitDepsMeta.changes.forEach((meta, file) => {
75 fileModifiedMap.set(file, meta.mtime)
76 })
77

Callers

nothing calls this directly

Calls 15

setConfigDependenciesMethod · 0.95
checkFilesChangedMethod · 0.95
findConfigFunction · 0.90
uniqFunction · 0.90
parseDependencyFunction · 0.90
forEachMethod · 0.80
hasMethod · 0.80
getMethod · 0.80
appendMethod · 0.80
getFilesMethod · 0.65

Tested by

no test coverage detected