Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re authored and github-actions[bot] committed Feb 17, 2023
1 parent 67668ca commit 728a773
Show file tree
Hide file tree
Showing 20 changed files with 2,775 additions and 1,522 deletions.
13 changes: 7 additions & 6 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
name: Bug report
about: Create a report to help us improve
title: "[Bug] "
title: '[Bug] '
labels: bug
assignees: ''

---

**Environment**
- OS: [e.g. macOS, Windows]
- Node Version: [e.g. v18.14.0]
- Package: [e.g. `@clack/prompts`, `@clack/core`]
- Package Version: [e.g. v0.2.0]

- OS: [e.g. macOS, Windows]
- Node Version: [e.g. v18.14.0]
- Package: [e.g. `@clack/prompts`, `@clack/core`]
- Package Version: [e.g. v0.2.0]

**Describe the bug**
A clear and concise description of what the bug is.
Expand All @@ -20,6 +20,7 @@ A clear and concise description of what the bug is.
Include a link to a minimal reproduction using [`node.new`](https://node.new/)

Steps to reproduce the behavior:

- Include reproduction steps

**Expected behavior**
Expand Down
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[Request]"
title: '[Request]'
labels: enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ module.exports = {
options: {
useTabs: false,
},
}
},
],
};
24 changes: 12 additions & 12 deletions build.preset.ts
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,
},
},
});
126 changes: 61 additions & 65 deletions examples/basic/index.ts
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);
2 changes: 1 addition & 1 deletion packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Currently, `TextPrompt`, `SelectPrompt`, and `ConfirmPrompt` are exposed as well
Each `Prompt` accepts a `render` function.

```js
import { TextPrompt, isCancel } from "@clack/core";
import { TextPrompt, isCancel } from '@clack/core';

const p = new TextPrompt({
render() {
Expand Down
10 changes: 4 additions & 6 deletions packages/core/build.config.ts
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'],
});
10 changes: 5 additions & 5 deletions packages/core/src/index.ts
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';
56 changes: 28 additions & 28 deletions packages/core/src/prompts/confirm.ts
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;
});
}
}
Loading

0 comments on commit 728a773

Please sign in to comment.