MCPcopy Index your code
hub / github.com/QwikDev/qwik / loadConfig

Function loadConfig

scripts/util.ts:83–142  ·  view source on GitHub ↗
(args: string[] = [])

Source from the content-addressed store, hash-verified

81 * reading from and writing to.
82 */
83export function loadConfig(args: string[] = []) {
84 const __dirname = fileURLToPath(new URL('.', import.meta.url));
85 const rootDir = join(__dirname, '..');
86 const packagesDir = join(rootDir, 'packages');
87 const srcQwikDir = join(packagesDir, 'qwik', 'src');
88 const distQwikPkgDir = join(packagesDir, 'qwik', 'dist');
89 const tmpDir = join(rootDir, 'dist-dev');
90 const knownOptions = [...stringOptions, ...booleanOptions] as const;
91 const kebabOptions = knownOptions.map(kebab);
92 // Add _ to known options
93 kebabOptions.push('_');
94 const alias = Object.fromEntries(knownOptions.map((k, i) => [kebabOptions[i], k]));
95 // rename qwik to build
96 (alias as any).build = 'qwik';
97 kebabOptions.push('build');
98 const config = mri<BuildConfig>(args, {
99 boolean: [...booleanOptions],
100 string: [...stringOptions],
101 alias,
102 default: {
103 rootDir,
104 packagesDir,
105 srcQwikDir,
106 tmpDir,
107 srcQwikCityDir: join(packagesDir, 'qwik-city', 'src'),
108 srcQwikLabsDir: join(packagesDir, 'qwik-labs'),
109 srcNapiDir: join(srcQwikDir, 'napi'),
110 scriptsDir: join(rootDir, 'scripts'),
111 startersDir: join(rootDir, 'starters'),
112 distQwikPkgDir,
113 distQwikCityPkgDir: join(packagesDir, 'qwik-city', 'lib'),
114 distBindingsDir: join(packagesDir, 'qwik', 'bindings'),
115 tscDir: join(tmpDir, 'tsc-out'),
116 dtsDir: join(tmpDir, 'dts-out'),
117 esmNode: parseInt(process.version.slice(1).split('.')[0], 10) >= 14,
118 } as BuildConfig,
119 });
120 const parseError =
121 config._.length > 0
122 ? `!!! Extra non-args: ${config._.join(' ')}\n\n`
123 : process.argv.length === 2
124 ? `No args provided. `
125 : Object.keys(config).some((k) => !kebabOptions.includes(kebab(k)))
126 ? `!!! Unknown args: ${Object.keys(config)
127 .filter((k) => !kebabOptions.includes(kebab(k)))
128 .join(' ')}\n\n`
129 : undefined;
130 if (parseError) {
131 console.error(
132 `\n${parseError}Known args:\n${booleanOptions
133 .map((k) => ` --${kebab(k)}\n`)
134 .join('')}${stringOptions
135 .map((k) => ` --${kebab(k)} <string>\n`)
136 .join('')}\n=== Use pnpm build.local for initial build. ===\n\n`
137 );
138 process.exit(1);
139 }
140

Callers 1

index.tsFile · 0.90

Calls 3

joinFunction · 0.85
kebabFunction · 0.85
joinMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…