forked from bombshell-dev/clack
-
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
1 parent
67668ca
commit 728a773
Showing
20 changed files
with
2,775 additions
and
1,522 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
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
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 |
---|---|---|
|
@@ -11,6 +11,6 @@ module.exports = { | |
options: { | ||
useTabs: false, | ||
}, | ||
} | ||
}, | ||
], | ||
}; |
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,15 +1,15 @@ | ||
import { definePreset } from 'unbuild' | ||
import { definePreset } from 'unbuild'; | ||
|
||
// @see https://github.com/unjs/unbuild | ||
export default definePreset({ | ||
clean: true, | ||
declaration: true, | ||
rollup: { | ||
emitCJS: true, | ||
inlineDependencies: true, | ||
esbuild: { | ||
minify: true, | ||
sourceMap: true, | ||
} | ||
} | ||
}) | ||
clean: true, | ||
declaration: true, | ||
rollup: { | ||
emitCJS: true, | ||
inlineDependencies: true, | ||
esbuild: { | ||
minify: true, | ||
sourceMap: true, | ||
}, | ||
}, | ||
}); |
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,78 +1,74 @@ | ||
import * as p from "@clack/prompts"; | ||
import color from "picocolors"; | ||
import { setTimeout } from "node:timers/promises"; | ||
import * as p from '@clack/prompts'; | ||
import color from 'picocolors'; | ||
import { setTimeout } from 'node:timers/promises'; | ||
|
||
async function main() { | ||
console.clear(); | ||
console.clear(); | ||
|
||
await setTimeout(1000); | ||
await setTimeout(1000); | ||
|
||
p.intro(`${color.bgCyan(color.black(" create-app "))}`); | ||
p.intro(`${color.bgCyan(color.black(' create-app '))}`); | ||
|
||
const project = await p.group( | ||
{ | ||
path: () => | ||
p.text({ | ||
message: "Where should we create your project?", | ||
placeholder: "./sparkling-solid", | ||
validate: (value) => { | ||
if (!value) return "Please enter a path."; | ||
if (value[0] !== ".") return "Please enter an absolute path."; | ||
}, | ||
}), | ||
type: ({ results }) => | ||
p.select({ | ||
message: `Pick a project type within "${results.path}"`, | ||
initialValue: "ts", | ||
options: [ | ||
{ value: "ts", label: "TypeScript" }, | ||
{ value: "js", label: "JavaScript" }, | ||
{ value: "coffee", label: "CoffeeScript", hint: "oh no" }, | ||
], | ||
}), | ||
tools: () => | ||
p.multiselect({ | ||
message: "Select additional tools.", | ||
initialValue: ["prettier", "eslint"], | ||
options: [ | ||
{ value: "prettier", label: "Prettier", hint: "recommended" }, | ||
{ value: "eslint", label: "ESLint", hint: "recommended" }, | ||
{ value: "stylelint", label: "Stylelint" }, | ||
{ value: "gh-action", label: "GitHub Action" }, | ||
], | ||
}), | ||
install: () => | ||
p.confirm({ | ||
message: "Install dependencies?", | ||
initialValue: false, | ||
}), | ||
}, | ||
{ | ||
onCancel: () => { | ||
p.cancel("Operation cancelled."); | ||
process.exit(0); | ||
}, | ||
} | ||
); | ||
const project = await p.group( | ||
{ | ||
path: () => | ||
p.text({ | ||
message: 'Where should we create your project?', | ||
placeholder: './sparkling-solid', | ||
validate: (value) => { | ||
if (!value) return 'Please enter a path.'; | ||
if (value[0] !== '.') return 'Please enter an absolute path.'; | ||
}, | ||
}), | ||
type: ({ results }) => | ||
p.select({ | ||
message: `Pick a project type within "${results.path}"`, | ||
initialValue: 'ts', | ||
options: [ | ||
{ value: 'ts', label: 'TypeScript' }, | ||
{ value: 'js', label: 'JavaScript' }, | ||
{ value: 'coffee', label: 'CoffeeScript', hint: 'oh no' }, | ||
], | ||
}), | ||
tools: () => | ||
p.multiselect({ | ||
message: 'Select additional tools.', | ||
initialValue: ['prettier', 'eslint'], | ||
options: [ | ||
{ value: 'prettier', label: 'Prettier', hint: 'recommended' }, | ||
{ value: 'eslint', label: 'ESLint', hint: 'recommended' }, | ||
{ value: 'stylelint', label: 'Stylelint' }, | ||
{ value: 'gh-action', label: 'GitHub Action' }, | ||
], | ||
}), | ||
install: () => | ||
p.confirm({ | ||
message: 'Install dependencies?', | ||
initialValue: false, | ||
}), | ||
}, | ||
{ | ||
onCancel: () => { | ||
p.cancel('Operation cancelled.'); | ||
process.exit(0); | ||
}, | ||
} | ||
); | ||
|
||
if (project.install) { | ||
const s = p.spinner(); | ||
s.start("Installing via pnpm"); | ||
await setTimeout(5000); | ||
s.stop("Installed via pnpm"); | ||
} | ||
if (project.install) { | ||
const s = p.spinner(); | ||
s.start('Installing via pnpm'); | ||
await setTimeout(5000); | ||
s.stop('Installed via pnpm'); | ||
} | ||
|
||
let nextSteps = `cd ${project.path} \n${ | ||
project.install ? "" : "pnpm install\n" | ||
}pnpm dev`; | ||
let nextSteps = `cd ${project.path} \n${project.install ? '' : 'pnpm install\n'}pnpm dev`; | ||
|
||
p.note(nextSteps, "Next steps."); | ||
p.note(nextSteps, 'Next steps.'); | ||
|
||
await setTimeout(1000); | ||
await setTimeout(1000); | ||
|
||
p.outro( | ||
`Problems? ${color.underline(color.cyan("https://example.com/issues"))}` | ||
); | ||
p.outro(`Problems? ${color.underline(color.cyan('https://example.com/issues'))}`); | ||
} | ||
|
||
main().catch(console.error); |
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
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,9 +1,7 @@ | ||
import { defineBuildConfig } from 'unbuild' | ||
import { defineBuildConfig } from 'unbuild'; | ||
|
||
// @see https://github.com/unjs/unbuild | ||
export default defineBuildConfig({ | ||
preset: '../../build.preset', | ||
entries: [ | ||
'src/index' | ||
], | ||
}) | ||
preset: '../../build.preset', | ||
entries: ['src/index'], | ||
}); |
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,8 +1,8 @@ | ||
export type { State } from './prompts/prompt'; | ||
export { default as Prompt, isCancel } from './prompts/prompt'; | ||
export { default as TextPrompt } from './prompts/text'; | ||
export { default as PasswordPrompt } from './prompts/password'; | ||
export { default as SelectPrompt } from './prompts/select'; | ||
export { default as ConfirmPrompt } from './prompts/confirm'; | ||
export { default as MultiSelectPrompt } from './prompts/multi-select'; | ||
export { default as PasswordPrompt } from './prompts/password'; | ||
export { default as Prompt, isCancel } from './prompts/prompt'; | ||
export type { State } from './prompts/prompt'; | ||
export { default as SelectPrompt } from './prompts/select'; | ||
export { default as TextPrompt } from './prompts/text'; | ||
export { block } from './utils'; |
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,37 +1,37 @@ | ||
import Prompt, { PromptOptions } from './prompt'; | ||
import { cursor } from 'sisteransi'; | ||
import Prompt, { PromptOptions } from './prompt'; | ||
|
||
interface ConfirmOptions extends PromptOptions<ConfirmPrompt> { | ||
active: string; | ||
inactive: string; | ||
initialValue?: boolean; | ||
active: string; | ||
inactive: string; | ||
initialValue?: boolean; | ||
} | ||
export default class ConfirmPrompt extends Prompt { | ||
get cursor() { | ||
return this.value ? 0 : 1; | ||
} | ||
get cursor() { | ||
return this.value ? 0 : 1; | ||
} | ||
|
||
private get _value() { | ||
return this.cursor === 0; | ||
} | ||
|
||
constructor(opts: ConfirmOptions) { | ||
super(opts, false); | ||
this.value = opts.initialValue ? true : false; | ||
|
||
private get _value() { | ||
return this.cursor === 0; | ||
} | ||
this.on('value', () => { | ||
this.value = this._value; | ||
}); | ||
|
||
constructor(opts: ConfirmOptions) { | ||
super(opts, false); | ||
this.value = opts.initialValue ? true : false; | ||
|
||
this.on('value', () => { | ||
this.value = this._value; | ||
}) | ||
this.on('confirm', (confirm) => { | ||
this.output.write(cursor.move(0, -1)); | ||
this.value = confirm; | ||
this.state = 'submit'; | ||
this.close(); | ||
}); | ||
|
||
this.on('confirm', (confirm) => { | ||
this.output.write(cursor.move(0, -1)); | ||
this.value = confirm; | ||
this.state = 'submit'; | ||
this.close() | ||
}) | ||
|
||
this.on('cursor', () => { | ||
this.value = !this.value; | ||
}) | ||
} | ||
this.on('cursor', () => { | ||
this.value = !this.value; | ||
}); | ||
} | ||
} |
Oops, something went wrong.