-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathinitial_project_file_generator.ts
34 lines (31 loc) · 1.1 KB
/
initial_project_file_generator.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
34
import _path from 'path';
import _fsp from 'fs/promises';
import { type PackageManagerController } from '@aws-amplify/plugin-types';
/**
* InitialProjectFileGenerator is responsible for copying getting started template to a new project directory
*/
export class InitialProjectFileGenerator {
/**
* Responsible for copying getting started template to a new project directory
* fs is injected for testing
*/
constructor(
private readonly projectRoot: string,
private readonly packageManagerController: PackageManagerController,
private readonly fsp = _fsp,
private readonly path = _path
) {}
/**
* Copies the template directory to an amplify folder within the projectRoot
*/
generateInitialProjectFiles = async (): Promise<void> => {
const targetDir = this.path.resolve(this.projectRoot, 'amplify');
await this.fsp.mkdir(targetDir, { recursive: true });
await this.fsp.cp(
new URL('../templates/basic-auth-data/amplify', import.meta.url),
targetDir,
{ recursive: true }
);
await this.packageManagerController.initializeTsConfig(targetDir);
};
}