MCPcopy Index your code
hub / github.com/GrapesJS/grapesjs / createSourceFiles

Function createSourceFiles

packages/cli/src/init.ts:46–72  ·  view source on GitHub ↗
(opts: InitOptions = {})

Source from the content-addressed store, hash-verified

44};
45
46const createSourceFiles = async (opts: InitOptions = {}) => {
47 const rdmSrc = getTemplateFileContent('README.md');
48 const rdmDst = resolveRoot('README.md');
49 const indxSrc = getTemplateFileContent('src/index.js');
50 const indxDst = resolveRoot('src/index.js');
51 const indexCnt = getTemplateFileContent('_index.html');
52 const indexDst = resolveRoot('_index.html');
53 const license = spdxLicenseList[opts.license];
54 const licenseTxt =
55 license &&
56 (license.licenseText || '')
57 .replace('<year>', `${new Date().getFullYear()}-current`)
58 .replace('<copyright holders>', opts.name);
59 ensureDir(indxDst);
60 // write src/_index.html
61 fs.writeFileSync(indxDst, template(indxSrc)(opts).trim());
62 // write _index.html
63 fs.writeFileSync(indexDst, template(indexCnt)(opts));
64 // Write README.md
65 fs.writeFileSync(rdmDst, template(rdmSrc)(opts));
66 // write LICENSE
67 licenseTxt && fs.writeFileSync(resolveRoot('LICENSE'), licenseTxt);
68 // Copy files
69 fs.copyFileSync(resolveLocal('.gitignore-t'), resolveRoot('.gitignore'));
70 fs.copyFileSync(resolveLocal('.npmignore-t'), resolveRoot('.npmignore'));
71 fs.copyFileSync(resolveLocal('tsconfig.json'), resolveRoot('tsconfig.json'));
72};
73
74const createFileComponents = (opts: InitOptions = {}) => {
75 const filepath = 'src/components.js';

Callers 1

initPluginFunction · 0.85

Calls 4

ensureDirFunction · 0.90
getTemplateFileContentFunction · 0.85
resolveRootFunction · 0.85
resolveLocalFunction · 0.85

Tested by

no test coverage detected