MCPcopy
hub / github.com/electron/forge / initializeTemplate

Method initializeTemplate

packages/template/base/src/BaseTemplate.ts:60–118  ·  view source on GitHub ↗
(
    directory: string,
    { copyCIFiles }: InitTemplateOptions,
  )

Source from the content-addressed store, hash-verified

58 }
59
60 public async initializeTemplate(
61 directory: string,
62 { copyCIFiles }: InitTemplateOptions,
63 ): Promise<ForgeListrTaskDefinition[]> {
64 return [
65 {
66 title: 'Copying starter files',
67 task: async () => {
68 const pm = await resolvePackageManager();
69 d('creating directory:', path.resolve(directory, 'src'));
70 await fs.mkdirs(path.resolve(directory, 'src'));
71 const rootFiles = ['_gitignore', 'forge.config.js'];
72
73 if (pm.executable === 'pnpm') {
74 rootFiles.push('_npmrc');
75 } else if (
76 // Support Yarn 2+ by default by initializing with nodeLinker: node-modules
77 pm.executable === 'yarn' &&
78 pm.version &&
79 semver.gte(pm.version, '2.0.0')
80 ) {
81 rootFiles.push('_yarnrc.yml');
82 }
83
84 if (copyCIFiles) {
85 d(
86 `Copying CI files is currently not supported - this will be updated in a later version of Forge`,
87 );
88 }
89
90 const srcFiles = [
91 'index.css',
92 'index.js',
93 'index.html',
94 'preload.js',
95 ];
96
97 for (const file of rootFiles) {
98 await this.copy(
99 path.resolve(tmplDir, file),
100 path.resolve(directory, file.replace(/^_/, '.')),
101 );
102 }
103 for (const file of srcFiles) {
104 await this.copy(
105 path.resolve(tmplDir, file),
106 path.resolve(directory, 'src', file),
107 );
108 }
109 },
110 },
111 {
112 title: 'Initializing package.json',
113 task: async () => {
114 await this.initializePackageJSON(directory);
115 },
116 },
117 ];

Callers 2

init.tsFile · 0.45
index.jsFile · 0.45

Calls 3

copyMethod · 0.95
initializePackageJSONMethod · 0.95
resolvePackageManagerFunction · 0.90

Tested by

no test coverage detected