MCPcopy
hub / github.com/triggerdotdev/trigger.dev / readConfig

Function readConfig

packages/cli-v3/src/utilities/configFiles.ts:136–222  ·  view source on GitHub ↗
(
  dir: string,
  options?: ReadConfigOptions
)

Source from the content-addressed store, hash-verified

134 };
135
136export async function readConfig(
137 dir: string,
138 options?: ReadConfigOptions
139): Promise<ReadConfigResult> {
140 const absoluteDir = path.resolve(process.cwd(), dir);
141
142 const configPath = await getConfigPath(dir, options?.configFile);
143
144 if (!configPath) {
145 if (options?.projectRef) {
146 const rawConfig = await normalizeConfig({ project: options.projectRef });
147 const config = Config.parse(rawConfig);
148
149 return {
150 status: "in-memory",
151 config: await resolveConfig(absoluteDir, config),
152 };
153 } else {
154 throw new Error(`Config file not found in ${absoluteDir} or any parent directory.`);
155 }
156 }
157
158 const tempDir = await createTempDir();
159
160 const builtConfigFilePath = join(tempDir, "config.js");
161 const builtConfigFileHref = pathToFileURL(builtConfigFilePath).href;
162
163 logger.debug("Building config file", {
164 configPath,
165 builtConfigFileHref,
166 builtConfigFilePath,
167 });
168
169 // We need to build the path to the config file, and then import it?
170 await build({
171 entryPoints: [configPath],
172 bundle: true,
173 metafile: true,
174 minify: false,
175 write: true,
176 format: "cjs",
177 platform: "node",
178 target: ["es2018", "node18"],
179 outfile: builtConfigFilePath,
180 logLevel: "silent",
181 plugins: [
182 esbuildDecorators({
183 cwd: absoluteDir,
184 tsx: false,
185 force: false,
186 }),
187 {
188 name: "native-node-modules",
189 setup(build) {
190 const opts = build.initialOptions;
191 opts.loader = opts.loader || {};
192 opts.loader[".node"] = "copy";
193 },

Callers 3

startDevFunction · 0.90
_deployCommandFunction · 0.85
_initCommandFunction · 0.85

Calls 7

getConfigPathFunction · 0.85
normalizeConfigFunction · 0.85
resolveConfigFunction · 0.85
createTempDirFunction · 0.85
resolveMethod · 0.80
parseMethod · 0.80
debugMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…