MCPcopy Create free account
hub / github.com/ember-cli/ember-cli / generateOutputFiles

Function generateOutputFiles

dev/output-repo-helpers.js:36–80  ·  view source on GitHub ↗

* We can re-use generated projects

({ name, variant, isTypeScript, version, command })

Source from the content-addressed store, hash-verified

34 * We can re-use generated projects
35 */
36async function generateOutputFiles({ name, variant, isTypeScript, version, command }) {
37 console.log(Object.keys(cliOutputCache));
38 let cacheKey = `${command}-${variant}`;
39
40 if (cliOutputCache[cacheKey]) {
41 return cliOutputCache[cacheKey];
42 }
43
44 let updatedOutputTmpDir = tmp.dirSync();
45 console.log(`Running npx ember-cli@${version} ${command} ${name}`);
46
47 await execa(
48 'npx',
49 [`ember-cli@${version}`, command, name, `--skip-npm`, `--skip-git`, ...(isTypeScript ? ['--typescript'] : [])],
50 {
51 cwd: updatedOutputTmpDir.name,
52 env: {
53 /**
54 * using --typescript triggers npm's peer resolution features,
55 * and since we don't know if the npm package has been released yet,
56 * (and therefor) generate the project using the local ember-cli,
57 * the ember-cli version may not exist yet.
58 *
59 * We need to tell npm to ignore peers and just "let things be".
60 * Especially since we don't actually care about npm running,
61 * and just want the typescript files to generate.
62 *
63 * See this related issue: https://github.com/ember-cli/ember-cli/issues/10045
64 */
65 // eslint-disable-next-line camelcase
66 npm_config_legacy_peer_deps: 'true',
67 },
68 }
69 );
70
71 // node_modules is .gitignored, but since we already need to remove package-lock.json due to #10045,
72 // we may as well remove node_modules as while we're at it, just in case.
73 await execa('rm', ['-rf', 'node_modules', 'package-lock.json'], { cwd: updatedOutputTmpDir.name });
74
75 let generatedOutputPath = path.join(updatedOutputTmpDir.name, name);
76
77 cliOutputCache[cacheKey] = generatedOutputPath;
78
79 return generatedOutputPath;
80}
81
82module.exports = { cloneBranch, clearRepo, generateOutputFiles };

Callers 2

updateOnlineEditorReposFunction · 0.85
updateRepoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…