Skip to content

Commit 7328beb

Browse files
authored
chore: Fork @clack/prompts. (#587)
1 parent d9409f0 commit 7328beb

39 files changed

Lines changed: 2569 additions & 27 deletions

.github/workflows/ci.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,19 +190,20 @@ jobs:
190190
with:
191191
target: ${{ matrix.os == 'ubuntu-latest' && 'x86_64-unknown-linux-gnu' || matrix.os == 'windows-latest' && 'x86_64-pc-windows-msvc' || 'aarch64-apple-darwin' }}
192192

193-
- name: Check TypeScript types
194-
if: ${{ matrix.os == 'ubuntu-latest' }}
195-
run: pnpm tsgo
196-
197193
- name: Build CLI
198194
run: |
195+
pnpm build
199196
pnpm bootstrap-cli:ci
200197
if [[ "$RUNNER_OS" == "Windows" ]]; then
201198
echo "$USERPROFILE\.vite-plus\bin" >> $GITHUB_PATH
202199
else
203200
echo "$HOME/.vite-plus/bin" >> $GITHUB_PATH
204201
fi
205202
203+
- name: Check TypeScript types
204+
if: ${{ matrix.os == 'ubuntu-latest' }}
205+
run: pnpm tsgo
206+
206207
- name: Verify CLI installation
207208
run: |
208209
which vp

packages/global/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
"picocolors": "catalog:"
3030
},
3131
"devDependencies": {
32-
"@clack/prompts": "catalog:",
3332
"@napi-rs/cli": "catalog:",
3433
"@nkzw/safe-word-list": "catalog:",
3534
"@oxc-node/core": "catalog:",
3635
"@types/cross-spawn": "catalog:",
3736
"@types/semver": "catalog:",
3837
"@types/validate-npm-package-name": "catalog:",
38+
"@voidzero-dev/vite-plus-prompts": "workspace:*",
3939
"@voidzero-dev/vite-plus-tools": "workspace:",
4040
"detect-indent": "catalog:",
4141
"detect-newline": "catalog:",

packages/global/src/create/bin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'node:path';
22
import { styleText } from 'node:util';
33

4-
import * as prompts from '@clack/prompts';
4+
import * as prompts from '@voidzero-dev/vite-plus-prompts';
55
import mri from 'mri';
66

77
import {
@@ -325,7 +325,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
325325
message: 'Where should the new package be added to the monorepo:',
326326
placeholder: 'e.g., packages/',
327327
validate: (value) => {
328-
return formatTargetDir(value).error;
328+
return value ? formatTargetDir(value).error : 'Target directory is required';
329329
},
330330
});
331331

packages/global/src/create/prompts.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'node:fs';
22
import path from 'node:path';
33

4-
import * as prompts from '@clack/prompts';
4+
import * as prompts from '@voidzero-dev/vite-plus-prompts';
55
import validateNpmPackageName from 'validate-npm-package-name';
66

77
import { accent } from '../utils/terminal.js';
@@ -20,15 +20,15 @@ export async function promptPackageNameAndTargetDir(
2020
placeholder: defaultPackageName,
2121
defaultValue: defaultPackageName,
2222
validate: (value) => {
23-
if (value.length === 0) {
23+
if (value != null && value.length === 0) {
2424
return;
2525
}
2626

27-
const result = validateNpmPackageName(value);
28-
if (result.validForNewPackages) {
27+
const result = value ? validateNpmPackageName(value) : null;
28+
if (result?.validForNewPackages) {
2929
return;
3030
}
31-
return result.errors?.[0] ?? result.warnings?.[0] ?? 'Invalid package name';
31+
return result?.errors?.[0] ?? result?.warnings?.[0] ?? 'Invalid package name';
3232
},
3333
});
3434
if (prompts.isCancel(selected)) {

packages/global/src/create/templates/generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'node:fs';
22
import path from 'node:path';
33

4-
import * as prompts from '@clack/prompts';
4+
import * as prompts from '@voidzero-dev/vite-plus-prompts';
55

66
import type { WorkspaceInfo } from '../../types/index.js';
77
import { editJsonFile } from '../../utils/json.js';

packages/global/src/create/templates/monorepo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import assert from 'node:assert';
22
import fs from 'node:fs';
33
import path from 'node:path';
44

5-
import * as prompts from '@clack/prompts';
5+
import * as prompts from '@voidzero-dev/vite-plus-prompts';
66
import spawn from 'cross-spawn';
77

88
import { rewriteMonorepoProject } from '../../migration/migrator.js';

packages/global/src/create/templates/remote.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as prompts from '@clack/prompts';
1+
import * as prompts from '@voidzero-dev/vite-plus-prompts';
22
import colors from 'picocolors';
33

44
import type { WorkspaceInfo } from '../../types/index.js';

packages/global/src/local/bin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { join } from 'node:path';
22
import { pathToFileURL } from 'node:url';
33

4-
import * as prompts from '@clack/prompts';
4+
import * as prompts from '@voidzero-dev/vite-plus-prompts';
55

66
import { detectWorkspace as detectWorkspaceBinding } from '../../binding/index.js';
77
import { runCommand } from '../utils/command.js';

packages/global/src/migration/bin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'node:path';
22
import { styleText } from 'node:util';
33

4-
import * as prompts from '@clack/prompts';
4+
import * as prompts from '@voidzero-dev/vite-plus-prompts';
55
import mri from 'mri';
66
import colors from 'picocolors';
77
import semver from 'semver';

packages/global/src/migration/migrator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'node:fs';
22
import path from 'node:path';
33

4-
import * as prompts from '@clack/prompts';
4+
import * as prompts from '@voidzero-dev/vite-plus-prompts';
55
import semver from 'semver';
66
import { Scalar, YAMLMap, YAMLSeq } from 'yaml';
77

0 commit comments

Comments
 (0)