MCPcopy Create free account
hub / github.com/toeverything/AFFiNE / generateWorkspaceFiles

Method generateWorkspaceFiles

tools/cli/src/init.ts:23–60  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21 }
22
23 async generateWorkspaceFiles() {
24 this.workspace = new Workspace(yarnList());
25 const filesToGenerate: [
26 Path,
27 (prev: string) => string,
28 BuiltInParserName?,
29 ][] = [
30 [this.workspace.join('tsconfig.json'), this.genProjectTsConfig, 'json'],
31 [
32 this.workspace
33 .getPackage('@affine-tools/utils')
34 .join('src/workspace.gen.ts'),
35 this.genWorkspaceInfo,
36 'typescript',
37 ],
38 [this.workspace.join('.oxlintrc.json'), this.genOxlintConfig, 'json'],
39 ...this.workspace.packages
40 .filter(p => p.isTsProject)
41 .map(
42 p =>
43 [
44 p.join('tsconfig.json'),
45 this.genPackageTsConfig.bind(this, p),
46 'json',
47 ] as any
48 ),
49 ];
50
51 for (const [path, content, formatter] of filesToGenerate) {
52 this.logger.info(`Generating: ${path}`);
53 const previous = readFileSync(path.value, 'utf-8');
54 let file = content(previous);
55 if (formatter) {
56 file = await this.format(file, formatter);
57 }
58 writeFileSync(path.value, file);
59 }
60 }
61
62 format(content: string, parser: BuiltInParserName) {
63 const config = JSON.parse(

Callers 1

executeMethod · 0.95

Calls 8

formatMethod · 0.95
getPackageMethod · 0.80
mapMethod · 0.80
contentFunction · 0.50
joinMethod · 0.45
filterMethod · 0.45
bindMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected