-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
136 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env node | ||
|
||
import { main } from '../src/index.js' | ||
|
||
main().catch(console.error) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
{ | ||
"name": "create-maizzle", | ||
"version": "0.0.1", | ||
"description": "Quickly start a new Maizzle project.", | ||
"license": "MIT", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/maizzle/framework.git" | ||
}, | ||
"bugs": "https://github.com/maizzle/framework/issues", | ||
"homepage": "https://maizzle.com", | ||
"author": "Cosmin Popovici (https://github.com/cossssmin)", | ||
"dependencies": { | ||
"@clack/prompts": "^0.7.0", | ||
"picocolors": "^1.0.0" | ||
} | ||
"name": "create-maizzle", | ||
"version": "0.0.1", | ||
"description": "Quickly start a new Maizzle project.", | ||
"license": "MIT", | ||
"type": "module", | ||
"bin": { | ||
"create-maizzle": "bin/create-maizzle.mjs" | ||
}, | ||
"files": [ | ||
"bin" | ||
], | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/maizzle/framework.git" | ||
}, | ||
"bugs": "https://github.com/maizzle/framework/issues", | ||
"homepage": "https://maizzle.com", | ||
"author": "Cosmin Popovici (https://github.com/cossssmin)", | ||
"dependencies": { | ||
"@clack/prompts": "^0.7.0", | ||
"degit": "^2.8.4", | ||
"picocolors": "^1.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import degit from 'degit'; | ||
import color from 'picocolors'; | ||
import * as p from '@clack/prompts'; | ||
import { setTimeout } from 'node:timers/promises'; | ||
|
||
export async function main() { | ||
console.clear(); | ||
|
||
p.intro(`${color.bgCyan(color.black(' create-maizzle '))}`); | ||
|
||
const project = await p.group( | ||
{ | ||
path: () => | ||
p.text({ | ||
message: 'Where should we create your project?', | ||
placeholder: './maizzle', | ||
validate: value => { | ||
if (!value) return 'Please enter a path.'; | ||
if (value[0] !== '.') return 'Please enter a relative path.'; | ||
}, | ||
}), | ||
starter: async () => { | ||
const starter = await p.select({ | ||
message: 'Select a Starter', | ||
initialValue: 'default', | ||
options: [ | ||
{ value: 'default', label: 'Default' }, | ||
{ value: 'custom', label: 'Custom' }, | ||
], | ||
}); | ||
|
||
if (starter === 'custom') { | ||
const starters = await p.select({ | ||
message: 'Select a custom Starter', | ||
initialValue: 'default', | ||
options: [ | ||
{ value: 'api', label: 'API' }, | ||
{ value: 'amp', label: 'AMP4Email' }, | ||
{ value: 'mc', label: 'Mailchimp' }, | ||
{ value: 'md', label: 'Markdown' }, | ||
{ value: 'wp', label: 'WordPress API' }, | ||
{ value: 'git', label: 'Git', hint: 'provide a git url' }, | ||
], | ||
}); | ||
|
||
if (starters === 'git') { | ||
const url = await p.text({ | ||
message: 'Enter a Git repository url', | ||
validate: value => { | ||
if (!value) return 'Please enter a Git repository url.'; | ||
if (!value.endsWith('.git')) return 'Please include the .git extension.'; | ||
}, | ||
}); | ||
return console.log(url); | ||
} | ||
|
||
return starters; | ||
} | ||
}, | ||
install: () => | ||
p.confirm({ | ||
message: 'Install dependencies?', | ||
initialValue: true, | ||
}), | ||
}, | ||
{ | ||
onCancel: () => { | ||
p.cancel('💀'); | ||
process.exit(0); | ||
}, | ||
} | ||
); | ||
|
||
if (project.install) { | ||
const s = p.spinner(); | ||
s.start('Installing dependencies'); | ||
|
||
await setTimeout(2500); | ||
s.stop('Installed dependencies'); | ||
} | ||
|
||
let nextSteps = `cd ${project.path} \n${project.install ? '' : 'npm install\n'}npm run dev`; | ||
|
||
p.note(nextSteps, 'Next steps.'); | ||
|
||
p.outro(`Join the community: ${color.underline(color.cyan('https://maizzle.com/discord'))} | ||
Documentation: ${color.underline(color.cyan('https://maizzle.com/docs'))} | ||
Problems? ${color.underline(color.cyan('https://maizzle.com/issues'))}` | ||
); | ||
|
||
} |