forked from solidjs-community/solid-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-start.ts
More file actions
36 lines (33 loc) · 1.14 KB
/
create-start.ts
File metadata and controls
36 lines (33 loc) · 1.14 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
34
35
36
import { downloadRepo, GithubFetcher } from "@begit/core";
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,
},
GithubFetcher,
);
};
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);
};