MCPcopy Create free account
hub / github.com/Snapchat/Valdi / initializeConfigFiles

Function initializeConfigFiles

npm_modules/cli/src/commands/bootstrap.ts:161–211  ·  view source on GitHub ↗
(
  projectName: string,
  template: ApplicationTemplate,
  valdiReleaseTag: string,
  valdiWidgetsReleaseTag: string,
)

Source from the content-addressed store, hash-verified

159
160// Create files from templates
161function initializeConfigFiles(
162 projectName: string,
163 template: ApplicationTemplate,
164 valdiReleaseTag: string,
165 valdiWidgetsReleaseTag: string,
166) {
167
168 const TEMPLATE_FILES = [
169 TemplateFile.init(TEMPLATE_BASE_PATHS.USER_CONFIG).withOutputPath(resolveFilePath(VALDI_CONFIG_PATHS[0] ?? '')),
170 TemplateFile.init(TEMPLATE_BASE_PATHS.BAZEL_VERSION),
171 TemplateFile.init(TEMPLATE_BASE_PATHS.MODULE_BAZEL).withReplacements({
172 WORKSPACE_NAME: projectName,
173 VALDI_RELEASE_TAG: valdiReleaseTag,
174 VALDI_WIDGETS_RELEASE_TAG: valdiWidgetsReleaseTag,
175 }),
176 TemplateFile.init(TEMPLATE_BASE_PATHS.BAZEL_RC).withReplacements({
177 VALDI_RELEASE_TAG: valdiReleaseTag,
178 }),
179 TemplateFile.init(TEMPLATE_BASE_PATHS.README),
180 TemplateFile.init(TEMPLATE_BASE_PATHS.GIT_IGNORE),
181 TemplateFile.init(TEMPLATE_BASE_PATHS.WATCHMAN_CONFIG),
182 TemplateFile.init(TEMPLATE_BASE_PATHS.EDITOR_CONFIG),
183 TemplateFile.init(TEMPLATE_BASE_PATHS.AGENTS).withReplacements({ MODULE_NAME: projectName }),
184 ];
185
186 TEMPLATE_FILES.forEach(templateFile => {
187 console.log(
188 wrapInColor(`Creating ${templateFile.baseName} in ${templateFile.outputPath}...`, ANSI_COLORS.YELLOW_COLOR),
189 );
190 templateFile.expandTemplate();
191 });
192
193 // Copy shared bootstrap directories
194 const replacements: Replacements = {
195 MODULE_NAME: projectName,
196 MODULE_NAME_PASCAL_CASED: toPascalCase(projectName),
197 };
198 const githubSourcePath = path.join(BOOTSTRAP_DIR_PATH, '.github');
199 if (fileExists(githubSourcePath)) {
200 console.log(wrapInColor('Creating GitHub templates...', ANSI_COLORS.YELLOW_COLOR));
201 const githubDestPath = path.join(process.cwd(), '.github');
202 copyBootstrapFiles(githubSourcePath, githubDestPath, replacements);
203 }
204
205 // Setup hello world application
206 console.log(wrapInColor(`Initializing ${template.name} application...`, ANSI_COLORS.YELLOW_COLOR));
207 const sourcePath = path.join(BOOTSTRAP_DIR_PATH, 'apps', template.path);
208 const destPath = process.cwd();
209
210 copyBootstrapFiles(sourcePath, destPath, replacements);
211}
212
213const VALDI_SUB_MODULES: readonly { name: string; subPath: string }[] = [
214 { name: 'android_macros', subPath: 'bzl/macros' },

Callers 1

valdiBootstrapFunction · 0.85

Calls 13

resolveFilePathFunction · 0.90
wrapInColorFunction · 0.90
toPascalCaseFunction · 0.90
fileExistsFunction · 0.90
copyBootstrapFilesFunction · 0.90
withOutputPathMethod · 0.80
withReplacementsMethod · 0.80
expandTemplateMethod · 0.80
cwdMethod · 0.80
forEachMethod · 0.65
logMethod · 0.65
initMethod · 0.45

Tested by

no test coverage detected