(
cwd = Deno.cwd(),
input: (string | number)[],
flags: {
docker?: boolean | null;
force?: boolean | null;
tailwind?: boolean | null;
vscode?: boolean | null;
builder?: boolean | null;
help?: boolean | null;
h?: boolean | null;
skipInstall?: boolean | null;
} = {},
)
| 76 | } for build tooling?`; |
| 77 | |
| 78 | export async function initProject( |
| 79 | cwd = Deno.cwd(), |
| 80 | input: (string | number)[], |
| 81 | flags: { |
| 82 | docker?: boolean | null; |
| 83 | force?: boolean | null; |
| 84 | tailwind?: boolean | null; |
| 85 | vscode?: boolean | null; |
| 86 | builder?: boolean | null; |
| 87 | help?: boolean | null; |
| 88 | h?: boolean | null; |
| 89 | skipInstall?: boolean | null; |
| 90 | } = {}, |
| 91 | ): Promise<void> { |
| 92 | const freshVersion = await getLatestVersion("@fresh/core", FRESH_VERSION); |
| 93 | |
| 94 | if (flags.help || flags.h) { |
| 95 | console.log(HELP_TEXT); |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | console.log(); |
| 100 | console.log( |
| 101 | colors.bgRgb8( |
| 102 | colors.rgb8(" 🍋 Fresh: The next-gen web framework. ", 0), |
| 103 | 121, |
| 104 | ), |
| 105 | ); |
| 106 | console.log(` version ${colors.rgb8(freshVersion, 4)}`); |
| 107 | console.log(); |
| 108 | |
| 109 | let unresolvedDirectory; |
| 110 | if (input.length !== 1) { |
| 111 | const userInput = prompt( |
| 112 | "Project Name:", |
| 113 | "fresh-project", |
| 114 | ); |
| 115 | if (!userInput) { |
| 116 | error(HELP_TEXT); |
| 117 | } |
| 118 | |
| 119 | unresolvedDirectory = userInput; |
| 120 | } else { |
| 121 | unresolvedDirectory = String(input[0]); |
| 122 | } |
| 123 | |
| 124 | const projectDir = path.resolve(cwd, unresolvedDirectory); |
| 125 | |
| 126 | try { |
| 127 | const dir = [...Deno.readDirSync(projectDir)]; |
| 128 | const isEmpty = dir.length === 0 || |
| 129 | dir.length === 1 && dir[0].name === ".git"; |
| 130 | if ( |
| 131 | !isEmpty && |
| 132 | !(flags.force === null ? confirm(CONFIRM_EMPTY_MESSAGE) : flags.force) |
| 133 | ) { |
| 134 | error("Directory is not empty."); |
| 135 | } |
no test coverage detected