MCPcopy Create free account
hub / github.com/IgorWarzocha/howcode / createProject

Function createProject

desktop/project-create.ts:37–65  ·  view source on GitHub ↗
(options: {
  preferredProjectLocation: string | null
  projectName: string
  initializeGit: boolean
})

Source from the content-addressed store, hash-verified

35}
36
37export async function createProject(options: {
38 preferredProjectLocation: string | null
39 projectName: string
40 initializeGit: boolean
41}) {
42 const preferredProjectLocation = options.preferredProjectLocation?.trim() ?? ''
43 if (preferredProjectLocation.length === 0) {
44 throw new Error('Set a default project location in Settings first.')
45 }
46
47 const folderName = sanitizeProjectFolderName(options.projectName)
48 if (folderName.length === 0) {
49 throw new Error('Enter a project name.')
50 }
51
52 const parentDirectory = path.resolve(preferredProjectLocation)
53 const projectPath = path.join(parentDirectory, folderName)
54
55 await mkdir(parentDirectory, { recursive: true })
56 await mkdir(projectPath, { recursive: true })
57
58 if (options.initializeGit) {
59 await initializeProjectGit(projectPath)
60 }
61
62 const result = await startNewThread({ projectId: projectPath })
63 moveProjectToTop(projectPath)
64 return result
65}
66
67async function resolvePathIfPresent(projectPath: string) {
68 try {

Callers 1

createProjectFromPayloadFunction · 0.90

Calls 4

initializeProjectGitFunction · 0.90
startNewThreadFunction · 0.90
moveProjectToTopFunction · 0.90

Tested by

no test coverage detected