Skip to content

Commit

Permalink
wip 💫
Browse files Browse the repository at this point in the history
  • Loading branch information
cossssmin committed Feb 14, 2024
1 parent 7307f2a commit 888f401
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 18 deletions.
5 changes: 5 additions & 0 deletions bin/create-maizzle.mjs
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)
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 26 additions & 18 deletions package.json
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"
}
}
93 changes: 93 additions & 0 deletions src/index.js
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'))}`
);

}

0 comments on commit 888f401

Please sign in to comment.