/
create-application-files.ts
33 lines (32 loc) · 940 Bytes
/
create-application-files.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import {
detectPackageManager,
generateFiles,
offsetFromRoot,
PackageManager,
toJS,
Tree,
} from '@nx/devkit';
import { join } from 'path';
import { NormalizedSchema } from './normalize-options';
export function createApplicationFiles(host: Tree, options: NormalizedSchema) {
const packageManagerLockFile: Record<PackageManager, string> = {
npm: 'package-lock.json',
yarn: 'yarn.lock',
pnpm: 'pnpm-lock.yaml',
bun: 'bun.lockb',
};
const packageManager = detectPackageManager(host.root);
const packageLockFile = packageManagerLockFile[packageManager];
generateFiles(host, join(__dirname, '../files'), options.appProjectRoot, {
...options,
offsetFromRoot: offsetFromRoot(options.appProjectRoot),
packageManager,
packageLockFile,
});
if (options.unitTestRunner === 'none') {
host.delete(join(options.appProjectRoot, `App.spec.tsx`));
}
if (options.js) {
toJS(host);
}
}