mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-05 07:34:25 +00:00
Compare commits
4
Commits
v0.6.6
..
eea844320d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eea844320d | ||
|
|
d255e76806 | ||
|
|
2be1093b91 | ||
|
|
83e902862c |
@@ -8,10 +8,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
|
||||
### Added
|
||||
|
||||
- **i18n**: Add Korean as a display language, selectable on the sign-up page and in team settings.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **cli**: Fix release publication failing to find staged standalone downloads.
|
||||
|
||||
### Changed
|
||||
|
||||
- **cli**: Show copyable commands and shell configuration instructions when the standalone CLI installation directory is missing from PATH.
|
||||
|
||||
## [0.6.6] - 2026-11-13
|
||||
|
||||
### Added
|
||||
|
||||
+3
-1
@@ -32,12 +32,14 @@ powershell -NoProfile -ExecutionPolicy Bypass -Command "irm https://github.com/s
|
||||
|
||||
Native builds use Bun 1.4.4's runtime; x64 CPUs need SSE4.2. See [Bun's system requirements](https://bun.com/docs/installation). Alpine/musl is not included in these native downloads. Native downloads are available for releases containing the installer assets; use npm for earlier releases.
|
||||
|
||||
On macOS/Linux the default directory is `~/.local/bin`. Add it to your shell's PATH if needed:
|
||||
On macOS/Linux the default directory is `~/.local/bin`. If it is missing from your current PATH, the installer prints a command to run in your current Bash/Zsh terminal:
|
||||
|
||||
```sh
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
```
|
||||
|
||||
To keep the CLI available in future terminals, add the same export line to `~/.bashrc` (Bash) or `~/.zshrc` (Zsh). For Bash login shells, use your existing login profile, such as `~/.bash_profile` or `~/.profile`. Open a new terminal after saving. If you already added it, you do not need to add it again. For a custom installation directory, use the exact command printed by the installer.
|
||||
|
||||
On Windows the installer uses `%LOCALAPPDATA%\Shumai\bin` and updates the user PATH. Open a new terminal afterward. Administrator access is not required.
|
||||
|
||||
Re-run the installer to upgrade. To pin a version, roll back, or choose an installation directory, download the installer and pass its options (replace `X.Y.Z` with a release containing native binaries):
|
||||
|
||||
@@ -20,43 +20,46 @@ describe('Auth Signup Locale Hook', () => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
it('should save locale metadata for the user upon signup', async () => {
|
||||
const email = `signup-locale-${Date.now()}@example.com`
|
||||
it.each(['zh', 'ko'])(
|
||||
'should save %s locale metadata for the user upon signup',
|
||||
async (locale) => {
|
||||
const email = `signup-locale-${locale}-${Date.now()}@example.com`
|
||||
|
||||
// We must use any here because 'locale' is a custom property we extract in
|
||||
// our auth hooks, but better-auth's signUpEmail typescript interface does
|
||||
// not recognize it.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const res = await (auth.api.signUpEmail as any)({
|
||||
headers: new Headers(),
|
||||
body: {
|
||||
email,
|
||||
password: 'testpassword',
|
||||
name: 'Locale Tester',
|
||||
locale: 'zh',
|
||||
},
|
||||
})
|
||||
// We must use any here because 'locale' is a custom property we extract in
|
||||
// our auth hooks, but better-auth's signUpEmail typescript interface does
|
||||
// not recognize it.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const res = await (auth.api.signUpEmail as any)({
|
||||
headers: new Headers(),
|
||||
body: {
|
||||
email,
|
||||
password: 'testpassword',
|
||||
name: 'Locale Tester',
|
||||
locale,
|
||||
},
|
||||
})
|
||||
|
||||
if (res.error) {
|
||||
console.error('SIGNUP ERROR:', res.error)
|
||||
}
|
||||
if (res.error) {
|
||||
console.error('SIGNUP ERROR:', res.error)
|
||||
}
|
||||
|
||||
expect(res).toBeDefined()
|
||||
expect(res.user).toBeDefined()
|
||||
expect(res.user.email).toBe(email)
|
||||
expect(res).toBeDefined()
|
||||
expect(res.user).toBeDefined()
|
||||
expect(res.user.email).toBe(email)
|
||||
|
||||
// Check that the userMetadata record was created with key 'locale' and value 'zh'
|
||||
const teamMembers = await prisma.teamMember.findMany({
|
||||
where: { userId: res.user.id },
|
||||
})
|
||||
expect(teamMembers.length).toBeGreaterThan(0)
|
||||
// Check that the userMetadata record was created with key 'locale' and the requested value
|
||||
const teamMembers = await prisma.teamMember.findMany({
|
||||
where: { userId: res.user.id },
|
||||
})
|
||||
expect(teamMembers.length).toBeGreaterThan(0)
|
||||
|
||||
for (const member of teamMembers) {
|
||||
const meta = await userMetadataService.getMetadata(res.user.id, member.teamId, 'locale')
|
||||
expect(meta).toBeDefined()
|
||||
expect(meta?.value).toBe('zh')
|
||||
}
|
||||
})
|
||||
for (const member of teamMembers) {
|
||||
const meta = await userMetadataService.getMetadata(res.user.id, member.teamId, 'locale')
|
||||
expect(meta).toBeDefined()
|
||||
expect(meta?.value).toBe(locale)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
it('should not save locale metadata if locale is invalid or missing', async () => {
|
||||
const email = `signup-no-locale-${Date.now()}@example.com`
|
||||
|
||||
@@ -201,7 +201,7 @@ export const auth = betterAuth({
|
||||
}
|
||||
|
||||
const locale = body?.locale
|
||||
if (locale === 'en' || locale === 'zh') {
|
||||
if (locale === 'en' || locale === 'zh' || locale === 'ko') {
|
||||
const joinedTeams = await prisma.teamMember.findMany({
|
||||
where: { userId: user.id },
|
||||
select: { teamId: true },
|
||||
|
||||
@@ -241,6 +241,7 @@
|
||||
"select_language": "Select Language",
|
||||
"english": "English",
|
||||
"chinese": "简体中文 (Chinese)",
|
||||
"korean": "한국어 (Korean)",
|
||||
"language_updated": "Language updated successfully",
|
||||
"failed_update_language": "Failed to update language",
|
||||
"avatar_updated": "Avatar updated successfully",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -241,6 +241,7 @@
|
||||
"select_language": "选择语言",
|
||||
"english": "English",
|
||||
"chinese": "简体中文 (Chinese)",
|
||||
"korean": "한국어 (Korean)",
|
||||
"language_updated": "语言更新成功",
|
||||
"failed_update_language": "语言更新失败",
|
||||
"avatar_updated": "头像更新成功",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/project-settings",
|
||||
"baseLocale": "en",
|
||||
"locales": ["en", "zh"],
|
||||
"locales": ["en", "zh", "ko"],
|
||||
"modules": [
|
||||
"https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@4/dist/index.js",
|
||||
"https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@2/dist/index.js"
|
||||
|
||||
@@ -199,7 +199,10 @@ export const Route = createRootRouteWithContext<MyRouterContext>()({
|
||||
try {
|
||||
await fetchMetadata(teamId)
|
||||
const savedLocale = getMetadata<string>('locale')
|
||||
if ((savedLocale === 'en' || savedLocale === 'zh') && savedLocale !== getLocale()) {
|
||||
if (
|
||||
(savedLocale === 'en' || savedLocale === 'zh' || savedLocale === 'ko') &&
|
||||
savedLocale !== getLocale()
|
||||
) {
|
||||
setLocale(savedLocale, { reload: false })
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
@@ -31,12 +31,12 @@ function SignupPage() {
|
||||
const inviteCode = (search as { inviteCode?: string }).inviteCode
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [locale, setLocaleState] = useState<'en' | 'zh'>(() => {
|
||||
const [locale, setLocaleState] = useState<'en' | 'zh' | 'ko'>(() => {
|
||||
const activeLocale = getLocale()
|
||||
return activeLocale === 'zh' ? 'zh' : 'en'
|
||||
return activeLocale === 'zh' || activeLocale === 'ko' ? activeLocale : 'en'
|
||||
})
|
||||
|
||||
const handleLocaleChange = (newLocale: 'en' | 'zh') => {
|
||||
const handleLocaleChange = (newLocale: 'en' | 'zh' | 'ko') => {
|
||||
setLocaleState(newLocale)
|
||||
setLocale(newLocale)
|
||||
}
|
||||
@@ -249,7 +249,7 @@ function SignupPage() {
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
<div className="mt-12 pt-10 border-t border-zinc-200/30 dark:border-zinc-800/30 text-center text-sm flex flex justify-between gap-4">
|
||||
<div className="mt-6 pt-4 border-t border-zinc-200/30 dark:border-zinc-800/30 text-center text-sm flex flex-col gap-16">
|
||||
<div>
|
||||
<span className="text-zinc-500 dark:text-zinc-400">{m.already_have_account()} </span>
|
||||
<a
|
||||
@@ -260,7 +260,7 @@ function SignupPage() {
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2 text-xs text-zinc-400 dark:text-zinc-500">
|
||||
<div className="flex items-center self-end gap-2 text-[11px] text-zinc-400 dark:text-zinc-500">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleLocaleChange('en')}
|
||||
@@ -280,6 +280,16 @@ function SignupPage() {
|
||||
>
|
||||
中文
|
||||
</button>
|
||||
<span className="text-zinc-300 dark:text-zinc-850">/</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleLocaleChange('ko')}
|
||||
className={`cursor-pointer hover:text-zinc-800 dark:hover:text-zinc-200 transition-colors ${
|
||||
locale === 'ko' ? 'font-bold text-rose-500 dark:text-rose-400' : ''
|
||||
}`}
|
||||
>
|
||||
한국어
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</AuthLayout>
|
||||
|
||||
@@ -254,7 +254,7 @@ export function TeamSettingsPage() {
|
||||
const currentLocale = getMetadata<string>('locale') || getLocale()
|
||||
|
||||
const handleLanguageChange = async (newLocale: string) => {
|
||||
if (newLocale === 'en' || newLocale === 'zh') {
|
||||
if (newLocale === 'en' || newLocale === 'zh' || newLocale === 'ko') {
|
||||
try {
|
||||
await setMetadata(teamId, 'locale', newLocale)
|
||||
setLocale(newLocale)
|
||||
@@ -957,6 +957,7 @@ export function TeamSettingsPage() {
|
||||
<SelectContent>
|
||||
<SelectItem value="en">{m.english()}</SelectItem>
|
||||
<SelectItem value="zh">{m.chinese()}</SelectItem>
|
||||
<SelectItem value="ko">{m.korean()}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
+8
-1
@@ -84,7 +84,14 @@ main() {
|
||||
printf 'Installed shumai-cli %s to %s\n' "$version" "$destination"
|
||||
case ":${PATH:-}:" in
|
||||
*":$install_dir:"*) ;;
|
||||
*) printf 'Add this directory to PATH in your shell configuration: %s\n' "$install_dir" ;;
|
||||
*)
|
||||
escaped_install_dir=$(printf '%s' "$install_dir" | sed "s/'/'\\\\''/g")
|
||||
printf '\nTo use shumai-cli in this terminal (Bash/Zsh), run:\n'
|
||||
printf " export PATH='%s':\"\$PATH\"\n" "$escaped_install_dir"
|
||||
printf '\nFor future terminals, add that line to ~/.bashrc (Bash) or ~/.zshrc (Zsh).\n'
|
||||
printf 'For Bash login shells, use your existing login profile\n(e.g. ~/.bash_profile or ~/.profile).\n'
|
||||
printf 'Open a new terminal after saving. If already configured, skip this step.\n'
|
||||
;;
|
||||
esac
|
||||
resolved=$(command -v shumai-cli || true)
|
||||
if [ -n "$resolved" ] && [ "$resolved" != "$destination" ]; then
|
||||
|
||||
@@ -16,13 +16,26 @@ describe('CLI release publication', () => {
|
||||
let manifest: string
|
||||
let assets: { name: string; digest: string }[]
|
||||
let draft: boolean | undefined
|
||||
let releasePages: unknown[][] | undefined
|
||||
let source = 'release-commit'
|
||||
const calls: string[][] = []
|
||||
const releaseEntry = (tag: string, isDraft: boolean) => ({
|
||||
// GitHub's REST API uses snake_case field names.
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
tag_name: tag,
|
||||
draft: isDraft,
|
||||
assets,
|
||||
})
|
||||
const run = vi.fn((command: string, args: string[]): string => {
|
||||
calls.push([command, ...args])
|
||||
if (command === 'git') return args[1] === 'HEAD' ? source : 'release-commit'
|
||||
if (args[0] === 'api') {
|
||||
if (draft === undefined) throw new Error('gh: Not Found (HTTP 404)')
|
||||
if (args.includes('--paginate'))
|
||||
return JSON.stringify(
|
||||
releasePages ?? [draft === undefined ? [] : [releaseEntry(`v${version}`, draft)]],
|
||||
)
|
||||
// GitHub's tag endpoint only returns published releases, even with write access.
|
||||
if (draft !== false) throw new Error('gh: Not Found (HTTP 404)')
|
||||
return JSON.stringify({ draft, assets })
|
||||
}
|
||||
if (args[1] === 'create') draft = true
|
||||
@@ -51,6 +64,7 @@ describe('CLI release publication', () => {
|
||||
)
|
||||
await writeFile(join(directory, 'notes.md'), 'Test release notes')
|
||||
draft = undefined
|
||||
releasePages = undefined
|
||||
source = 'release-commit'
|
||||
calls.length = 0
|
||||
run.mockClear()
|
||||
@@ -88,6 +102,45 @@ describe('CLI release publication', () => {
|
||||
.filter((call) => call[0] === 'gh')
|
||||
.every((call) => call[1] === 'api' || call[2] === 'download'),
|
||||
).toBe(true)
|
||||
expect(calls.some((call) => call.includes('--paginate'))).toBe(false)
|
||||
})
|
||||
|
||||
it('finds an existing draft on a later release-list page when the tag endpoint returns 404', async () => {
|
||||
draft = true
|
||||
releasePages = [[releaseEntry('v0.0.1', true)], [releaseEntry(`v${version}`, true)]]
|
||||
await publishCliRelease('publish', context(), run)
|
||||
expect(draft).toBe(false)
|
||||
expect(calls.some((call) => call.includes('--paginate') && call.includes('--slurp'))).toBe(true)
|
||||
expect(calls.some((call) => call[2] === 'create' || call[2] === 'upload')).toBe(false)
|
||||
})
|
||||
|
||||
it('does not create a release when the draft-list request fails', async () => {
|
||||
run
|
||||
.mockImplementationOnce(() => 'release-commit')
|
||||
.mockImplementationOnce(() => 'release-commit')
|
||||
.mockImplementationOnce(() => {
|
||||
throw new Error('gh: Not Found (HTTP 404)')
|
||||
})
|
||||
.mockImplementationOnce(() => {
|
||||
throw new Error('gh: Forbidden (HTTP 403)')
|
||||
})
|
||||
await expect(publishCliRelease('stage', context(), run)).rejects.toThrow('HTTP 403')
|
||||
expect(
|
||||
run.mock.calls.filter(([command, args]) => command === 'gh' && args[0] !== 'api'),
|
||||
).toHaveLength(0)
|
||||
})
|
||||
|
||||
it('rejects malformed or ambiguous release lists before changing GitHub', async () => {
|
||||
releasePages = [[{ name: 'missing tag' }]]
|
||||
await expect(publishCliRelease('stage', context(), run)).rejects.toThrow(
|
||||
'Invalid GitHub release list entry',
|
||||
)
|
||||
const release = releaseEntry(`v${version}`, true)
|
||||
releasePages = [[release], [release]]
|
||||
await expect(publishCliRelease('stage', context(), run)).rejects.toThrow(
|
||||
'Multiple GitHub releases',
|
||||
)
|
||||
expect(calls.every((call) => call[0] === 'git' || call[1] === 'api')).toBe(true)
|
||||
})
|
||||
|
||||
it('rejects a source/tag mismatch before making any GitHub changes', async () => {
|
||||
|
||||
@@ -65,6 +65,37 @@ function parseRelease(value: unknown): Release {
|
||||
}
|
||||
}
|
||||
|
||||
function findRelease(repository: string, tag: string, run: Runner): Release | undefined {
|
||||
try {
|
||||
return parseRelease(JSON.parse(run('gh', ['api', `repos/${repository}/releases/tags/${tag}`])))
|
||||
} catch (error) {
|
||||
if (!(error instanceof Error) || !error.message.includes('HTTP 404')) throw error
|
||||
}
|
||||
|
||||
// The tag endpoint only returns published releases. Authenticated release lists include drafts.
|
||||
const pages: unknown = JSON.parse(
|
||||
run('gh', ['api', '--paginate', '--slurp', `repos/${repository}/releases?per_page=100`]),
|
||||
)
|
||||
assert.ok(Array.isArray(pages), 'Invalid GitHub release list')
|
||||
let release: Release | undefined
|
||||
for (const page of pages) {
|
||||
assert.ok(Array.isArray(page), 'Invalid GitHub release list page')
|
||||
for (const entry of page as unknown[]) {
|
||||
assert.ok(
|
||||
entry &&
|
||||
typeof entry === 'object' &&
|
||||
'tag_name' in entry &&
|
||||
typeof entry.tag_name === 'string',
|
||||
'Invalid GitHub release list entry',
|
||||
)
|
||||
if (entry.tag_name !== tag) continue
|
||||
assert.ok(!release, 'Multiple GitHub releases found for the release tag')
|
||||
release = parseRelease(entry)
|
||||
}
|
||||
}
|
||||
return release
|
||||
}
|
||||
|
||||
export async function publishCliRelease(
|
||||
mode: 'stage' | 'publish',
|
||||
context: { tag: string; repository: string; outdir: string; notes: string },
|
||||
@@ -85,13 +116,7 @@ export async function publishCliRelease(
|
||||
`Local checksum mismatch: ${name}`,
|
||||
)
|
||||
|
||||
const endpoint = `repos/${context.repository}/releases/tags/${context.tag}`
|
||||
let release: Release | undefined
|
||||
try {
|
||||
release = parseRelease(JSON.parse(run('gh', ['api', endpoint])))
|
||||
} catch (error) {
|
||||
if (!(error instanceof Error) || !error.message.includes('HTTP 404')) throw error
|
||||
}
|
||||
let release = findRelease(context.repository, context.tag, run)
|
||||
if (!release) {
|
||||
assert.equal(mode, 'stage', 'Release must be staged before publishing')
|
||||
run('gh', [
|
||||
|
||||
Reference in New Issue
Block a user