-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathcreate-start.ts
More file actions
33 lines (30 loc) · 1.11 KB
/
create-start.ts
File metadata and controls
33 lines (30 loc) · 1.11 KB
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 { downloadRepo } from "./utils/download-repo";
import { join } from "path";
import { writeFileSync } from "fs";
import { handleTSConversion } from "./utils/ts-conversion";
import { GIT_IGNORE, StartTemplate } from "./utils/constants";
export type CreateStartArgs = {
template: StartTemplate;
destination: string;
};
export const createStartTS = ({ template, destination }: CreateStartArgs) => {
return downloadRepo({
repo: { owner: "solidjs", name: "templates", subdir: `solid-start/${template}` },
dest: destination,
});
};
export const createStartJS = async ({ template, destination }: CreateStartArgs) => {
// Create typescript project in `<destination>/.project`
// then transpile this to javascript and clean up
const tempDir = join(destination, ".project");
await createStartTS({ template, destination: tempDir });
await handleTSConversion(tempDir, destination);
// Add .gitignore
writeFileSync(join(destination, ".gitignore"), GIT_IGNORE);
};
export const createStart = (args: CreateStartArgs, transpile?: boolean) => {
if (transpile) {
return createStartJS(args);
}
return createStartTS(args);
};