MCPcopy Create free account
hub / github.com/GrapesJS/cli / createSourceFiles

Function createSourceFiles

src/init.ts:45–69  ·  view source on GitHub ↗
(opts: InitOptions = {})

Source from the content-addressed store, hash-verified

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