feat(cli): switch desktop sync to folocli

This commit is contained in:
DIYgod
2026-03-17 11:18:48 +08:00
parent bd0d081a7d
commit 9a8280ded4
20 changed files with 398 additions and 401 deletions
+19 -3
View File
@@ -1,9 +1,22 @@
{
"name": "@follow/cli",
"name": "folocli",
"type": "module",
"version": "0.1.0",
"private": true,
"description": "Folo CLI for AI agents and power users",
"description": "Folo CLI for terminal workflows and automation",
"author": "Folo Team",
"license": "AGPL-3.0-only",
"homepage": "https://github.com/RSSNext/Folo",
"repository": {
"type": "git",
"url": "git+https://github.com/RSSNext/Folo.git"
},
"keywords": [
"folo",
"rss",
"reader",
"cli",
"automation"
],
"bin": {
"folo": "./dist/index.js"
},
@@ -11,6 +24,9 @@
"dist",
"skill.md"
],
"engines": {
"node": ">=18"
},
"scripts": {
"build": "tsup --config tsup.config.ts && chmod +x dist/index.js",
"dev": "tsx src/index.ts",
+7 -4
View File
@@ -16,8 +16,8 @@ Use this skill when a user asks to:
1. Folo CLI is installed and executable as `folo`.
2. Authentication is configured:
- `folo auth login` (recommended, opens browser and auto-logins)
- or `folo auth login --token <session-token>`
- `folo login` (recommended, opens browser and auto-logins)
- or `folo login --token <session-token>`
- or set `FOLO_TOKEN=<token>`
## Output Contract
@@ -114,6 +114,9 @@ Loop until `hasNext` is `false`:
## Command Reference
- `folo login [--timeout <seconds>] [--token <token>]`
- `folo logout`
- `folo whoami`
- `folo auth login [--timeout <seconds>] [--token <token>]`
- `folo auth logout`
- `folo auth whoami`
@@ -164,8 +167,8 @@ Loop until `hasNext` is `false`:
## Error Recovery
- `UNAUTHORIZED`
- Re-login: `folo auth login`
- or `folo auth login --token <token>`
- Re-login: `folo login`
- or `folo login --token <token>`
- Or set `FOLO_TOKEN`
- `HTTP_4xx` / `HTTP_5xx`
- Retry with `--verbose` for request details
+1 -1
View File
@@ -210,7 +210,7 @@ export const loginWithBrowser = async (
reject(
new CLIError(
"TIMEOUT",
"Timed out waiting for browser login. Please run `folo auth login` again.",
"Timed out waiting for browser login. Please run `folo login` again.",
),
)
})
+2 -2
View File
@@ -10,7 +10,7 @@ import { describe, expect, it } from "vitest"
const execFileAsync = promisify(execFile)
const cliPath = resolve(process.cwd(), "dist/index.js")
const testToken = process.env.FOLO_TEST_TOKEN
const isolatedHome = mkdtempSync(resolve(tmpdir(), "folo-cli-test-"))
const isolatedHome = mkdtempSync(resolve(tmpdir(), "folocli-test-"))
type CLIExecution = {
code: number
@@ -64,7 +64,7 @@ describe("cli e2e", () => {
})
it.runIf(Boolean(testToken))("can fetch session with test token", async () => {
const result = await runCLI(["--token", testToken!, "auth", "whoami"])
const result = await runCLI(["--token", testToken!, "whoami"])
expect(result.code).toBe(0)
const payload = JSON.parse(result.stdout) as {
+1 -1
View File
@@ -82,7 +82,7 @@ export const createCommandContext = async (
if (requireAuth && !token) {
throw new CLIError(
"UNAUTHORIZED",
"Missing token. Run `folo auth login` (browser sign-in) or set FOLO_TOKEN.",
"Missing token. Run `folo login` (browser sign-in) or set FOLO_TOKEN.",
)
}
+99 -81
View File
@@ -12,92 +12,110 @@ interface AuthLoginOptions {
timeout?: number
}
export const registerAuthCommand = (program: Command) => {
const authCommand = program.command("auth").description("Authentication commands")
const runLoginAction = async function (this: Command, options: AuthLoginOptions) {
await runCommand(
this,
async ({ client, options: globalOptions }) => {
let token = options.token ?? getGlobalOptions(this).token
if (!token) {
const timeoutMs = (options.timeout ?? 180) * 1000
const browserLogin = await loginWithBrowser({
apiUrl: globalOptions.apiUrl,
timeoutMs,
onStatus: (message) => {
console.error(`[auth] ${message}`)
},
})
token = browserLogin.token
}
authCommand
.command("login")
.description("Sign in via browser (or save a provided token) and verify authentication")
client.setAuthToken(token)
const session = await client.api.auth.getSession()
if (!session.user || !session.session) {
throw new CLIError("UNAUTHORIZED", "Token is invalid or expired.")
}
await updateConfig({
token,
apiUrl: globalOptions.apiUrl,
})
return {
message: "Login successful.",
configPath: getConfigPath(),
user: session.user,
}
},
{ requireAuth: false },
)
}
const runLogoutAction = async function (this: Command) {
await runCommand(
this,
async () => {
await clearToken()
return {
message: "Logged out.",
configPath: getConfigPath(),
}
},
{ requireAuth: false },
)
}
const runWhoamiAction = async function (this: Command) {
await runCommand(this, async ({ client }) => {
const session = await client.api.auth.getSession()
if (!session.user || !session.session) {
throw new CLIError("UNAUTHORIZED", "Token is invalid or expired.")
}
return {
user: session.user,
session: session.session,
role: session.role,
roleEndAt: session.roleEndAt ?? null,
feedSubscriptionLimit: session.feedSubscriptionLimit,
rsshubSubscriptionLimit: session.rsshubSubscriptionLimit,
}
})
}
const registerLoginCommand = (program: Command, name: string, description: string) => {
program
.command(name)
.description(description)
.option("--token <token>", "Session token from Folo")
.option(
"--timeout <seconds>",
"Browser login timeout in seconds (default: 180)",
parsePositiveInt,
)
.action(async function (this: Command, options: AuthLoginOptions) {
await runCommand(
this,
async ({ client, options: globalOptions }) => {
let token = options.token ?? getGlobalOptions(this).token
if (!token) {
const timeoutMs = (options.timeout ?? 180) * 1000
const browserLogin = await loginWithBrowser({
apiUrl: globalOptions.apiUrl,
timeoutMs,
onStatus: (message) => {
console.error(`[auth] ${message}`)
},
})
token = browserLogin.token
}
client.setAuthToken(token)
const session = await client.api.auth.getSession()
if (!session.user || !session.session) {
throw new CLIError("UNAUTHORIZED", "Token is invalid or expired.")
}
await updateConfig({
token,
apiUrl: globalOptions.apiUrl,
})
return {
message: "Login successful.",
configPath: getConfigPath(),
user: session.user,
}
},
{ requireAuth: false },
)
})
authCommand
.command("logout")
.description("Clear stored token")
.action(async function (this: Command) {
await runCommand(
this,
async () => {
await clearToken()
return {
message: "Logged out.",
configPath: getConfigPath(),
}
},
{ requireAuth: false },
)
})
authCommand
.command("whoami")
.description("Show current session user")
.action(async function (this: Command) {
await runCommand(this, async ({ client }) => {
const session = await client.api.auth.getSession()
if (!session.user || !session.session) {
throw new CLIError("UNAUTHORIZED", "Token is invalid or expired.")
}
return {
user: session.user,
session: session.session,
role: session.role,
roleEndAt: session.roleEndAt ?? null,
feedSubscriptionLimit: session.feedSubscriptionLimit,
rsshubSubscriptionLimit: session.rsshubSubscriptionLimit,
}
})
})
.action(runLoginAction)
}
const registerLogoutCommand = (program: Command, name: string, description: string) => {
program.command(name).description(description).action(runLogoutAction)
}
const registerWhoamiCommand = (program: Command, name: string, description: string) => {
program.command(name).description(description).action(runWhoamiAction)
}
export const registerAuthCommand = (program: Command) => {
const authCommand = program.command("auth").description("Authentication commands")
registerLoginCommand(
authCommand,
"login",
"Sign in via browser (or save a provided token) and verify authentication",
)
registerLogoutCommand(authCommand, "logout", "Clear stored token")
registerWhoamiCommand(authCommand, "whoami", "Show current session user")
registerLoginCommand(program, "login", "Sign in and store a CLI session")
registerLogoutCommand(program, "logout", "Clear the stored CLI session")
registerWhoamiCommand(program, "whoami", "Show the current CLI session user")
}
+1 -4
View File
@@ -102,10 +102,7 @@ const config: ForgeConfig = {
buildVersion: process.env.BUILD_VERSION || undefined,
appBundleId: "is.follow",
icon: isStaging ? "resources/icon-staging" : "resources/icon",
extraResource: [
"./resources/app-update.yml",
...(fs.existsSync("./resources/cli") ? ["./resources/cli"] : []),
],
extraResource: ["./resources/app-update.yml"],
protocols: [
{
name: "Folo",
@@ -109,7 +109,7 @@ export class AuthService extends IpcService {
async sessionChanged(_context: IpcContext): Promise<void> {
await updateNotificationsToken()
// Sync session token to CLI config
// Sync the current desktop session to the npm CLI login.
const token = await getSessionTokenFromCookies()
await syncSessionToCliConfig(token).catch((err) => {
logger.error("Failed to sync session to CLI config:", err)
@@ -120,7 +120,7 @@ export class AuthService extends IpcService {
async signOut(_context: IpcContext): Promise<void> {
await deleteNotificationsToken()
// Clear CLI config token on sign out
// Clear the synced CLI login on sign out.
await syncSessionToCliConfig().catch((err) => {
logger.error("Failed to clear CLI config token:", err)
})
+47 -188
View File
@@ -1,51 +1,25 @@
import { execSync } from "node:child_process"
import { existsSync, lstatSync, readlinkSync } from "node:fs"
import { unlink, writeFile } from "node:fs/promises"
import { tmpdir } from "node:os"
import { app } from "electron"
import type { IpcContext } from "electron-ipc-decorator"
import { IpcMethod, IpcService } from "electron-ipc-decorator"
import path from "pathe"
import { logger } from "../../logger"
const CLI_BINARY_NAME = "folo"
const getDefaultInstallDir = (): string => {
switch (process.platform) {
case "win32": {
return path.join(process.env.LOCALAPPDATA || "", "Folo", "bin")
}
default: {
return "/usr/local/bin"
}
}
}
const getCliSourcePath = (): string => {
if (app.isPackaged) {
return path.join(process.resourcesPath, "cli", "index.js")
}
// In dev, read from the cli workspace directly
return path.resolve(app.getAppPath(), "../../cli/dist/index.js")
}
const getCliInstallPath = (): string => {
return path.join(getDefaultInstallDir(), CLI_BINARY_NAME)
}
/** Check whether the CLI is present at the given path (also checks .cmd on Windows). */
const cliExistsAt = (installPath: string): boolean => {
if (existsSync(installPath)) return true
if (process.platform === "win32" && existsSync(`${installPath}.cmd`)) return true
return false
}
import {
CLI_NPM_PACKAGE_NAME,
getCliConfigPath,
getCliInstallCommand,
getCliLoginCommand,
getSessionTokenFromCookies,
isCliRunnerAvailable,
readCliConfig,
syncSessionToCliConfig,
} from "../../lib/cli-session-sync"
export interface CliInstallStatus {
installed: boolean
installPath: string | null
cliSourceAvailable: boolean
connected: boolean
configPath: string
hasDesktopSession: boolean
installCommand: string
loginCommand: string
npxAvailable: boolean
packageName: string
}
export class CliService extends IpcService {
@@ -53,169 +27,54 @@ export class CliService extends IpcService {
@IpcMethod()
async getInstallStatus(_context: IpcContext): Promise<CliInstallStatus> {
const installPath = getCliInstallPath()
const cliSourcePath = getCliSourcePath()
const cliSourceAvailable = existsSync(cliSourcePath)
const [config, npxAvailable, desktopToken] = await Promise.all([
readCliConfig(),
isCliRunnerAvailable(),
getSessionTokenFromCookies(),
])
try {
if (!cliExistsAt(installPath)) {
return { installed: false, installPath: null, cliSourceAvailable }
}
if (existsSync(installPath)) {
const stats = lstatSync(installPath)
if (stats.isSymbolicLink()) {
const target = readlinkSync(installPath)
const isOurs = target.includes("Folo") || target.includes("cli/index.js")
return { installed: isOurs, installPath, cliSourceAvailable }
}
}
// Exists as a regular file (wrapper script or .cmd on Windows)
return { installed: true, installPath, cliSourceAvailable }
} catch {
return { installed: false, installPath: null, cliSourceAvailable }
return {
connected: Boolean(config.token),
configPath: getCliConfigPath(),
hasDesktopSession: Boolean(desktopToken),
installCommand: getCliInstallCommand(),
loginCommand: getCliLoginCommand(),
npxAvailable,
packageName: CLI_NPM_PACKAGE_NAME,
}
}
@IpcMethod()
async installCli(_context: IpcContext): Promise<{ success: boolean; error?: string }> {
const cliSource = getCliSourcePath()
if (!existsSync(cliSource)) {
return { success: false, error: "CLI bundle not found in app resources" }
}
const installPath = getCliInstallPath()
const wrapperContent = `#!/bin/sh\nexec /usr/bin/env node "${cliSource}" "$@"\n`
if (process.platform === "win32") {
return this.installCliWindows(cliSource, installPath)
}
try {
// Try without elevated permissions first
await writeFile(installPath, wrapperContent, { mode: 0o755 })
logger.info(`CLI installed at ${installPath}`)
if (!(await isCliRunnerAvailable())) {
return { success: false, error: "npx is not available. Install Node.js and npm first." }
}
const token = await getSessionTokenFromCookies()
if (!token) {
return { success: false, error: "Sign in to Folo Desktop first." }
}
await syncSessionToCliConfig(token)
return { success: true }
} catch {
// Write to a temp file first, then use admin privileges to copy it.
// This avoids shell-expansion issues with $@ in the wrapper content.
const tmpFile = path.join(tmpdir(), `folo-cli-wrapper-${Date.now()}`)
try {
await writeFile(tmpFile, wrapperContent, { mode: 0o755 })
if (process.platform === "darwin") {
execSync(
`osascript -e 'do shell script "cp \\"${tmpFile}\\" \\"${installPath}\\" && chmod +x \\"${installPath}\\"" with administrator privileges'`,
)
} else {
// Linux: use pkexec
execSync(`pkexec sh -c 'cp "${tmpFile}" "${installPath}" && chmod +x "${installPath}"'`)
}
logger.info(`CLI installed at ${installPath} (with elevated privileges)`)
return { success: true }
} catch (err) {
logger.error("Failed to install CLI with elevated privileges:", err)
return {
success: false,
error: err instanceof Error ? err.message : "Failed to install CLI",
}
} finally {
await unlink(tmpFile).catch(() => {})
} catch (error) {
return {
success: false,
error: error instanceof Error ? error.message : "Failed to sync CLI login",
}
}
}
@IpcMethod()
async uninstallCli(_context: IpcContext): Promise<{ success: boolean; error?: string }> {
const installPath = getCliInstallPath()
if (!cliExistsAt(installPath)) {
return { success: true }
}
if (process.platform === "win32") {
return this.uninstallCliWindows(installPath)
}
try {
await unlink(installPath)
logger.info(`CLI uninstalled from ${installPath}`)
await syncSessionToCliConfig()
return { success: true }
} catch {
// Needs elevated permissions
if (process.platform === "darwin") {
try {
execSync(
`osascript -e 'do shell script "rm -f \\"${installPath}\\"" with administrator privileges'`,
)
logger.info(`CLI uninstalled from ${installPath} (with admin privileges)`)
return { success: true }
} catch (err) {
logger.error("Failed to uninstall CLI with admin privileges:", err)
return {
success: false,
error: err instanceof Error ? err.message : "Failed to uninstall CLI",
}
}
}
try {
execSync(`pkexec rm -f "${installPath}"`)
logger.info(`CLI uninstalled from ${installPath} (with pkexec)`)
return { success: true }
} catch (err) {
logger.error("Failed to uninstall CLI:", err)
return {
success: false,
error: err instanceof Error ? err.message : "Failed to uninstall CLI",
}
}
}
}
private async installCliWindows(
cliSource: string,
installPath: string,
): Promise<{ success: boolean; error?: string }> {
const installDir = path.dirname(installPath)
const cmdContent = `@echo off\r\nnode "${cliSource}" %*\r\n`
try {
const { mkdirSync, writeFileSync } = await import("node:fs")
mkdirSync(installDir, { recursive: true })
writeFileSync(`${installPath}.cmd`, cmdContent)
logger.info(`CLI installed at ${installPath}.cmd`)
return { success: true }
} catch (err) {
logger.error("Failed to install CLI on Windows:", err)
} catch (error) {
return {
success: false,
error: err instanceof Error ? err.message : "Failed to install CLI",
}
}
}
private async uninstallCliWindows(
installPath: string,
): Promise<{ success: boolean; error?: string }> {
try {
const { unlinkSync } = await import("node:fs")
const cmdPath = `${installPath}.cmd`
if (existsSync(cmdPath)) {
unlinkSync(cmdPath)
}
if (existsSync(installPath)) {
unlinkSync(installPath)
}
logger.info(`CLI uninstalled from ${installPath}`)
return { success: true }
} catch (err) {
logger.error("Failed to uninstall CLI on Windows:", err)
return {
success: false,
error: err instanceof Error ? err.message : "Failed to uninstall CLI",
error: error instanceof Error ? error.message : "Failed to clear CLI login",
}
}
}
@@ -1,5 +1,7 @@
import { execFile } from "node:child_process"
import { mkdir, readFile, writeFile } from "node:fs/promises"
import { homedir } from "node:os"
import { promisify } from "node:util"
import { env } from "@follow/shared/env.desktop"
import { join } from "pathe"
@@ -9,15 +11,18 @@ import { WindowManager } from "~/manager/window"
import { logger } from "../logger"
const execFileAsync = promisify(execFile)
export const CLI_NPM_PACKAGE_NAME = "folocli"
const CLI_CONFIG_DIR = join(homedir(), ".folo")
const CLI_CONFIG_PATH = join(CLI_CONFIG_DIR, "config.json")
const getNpxCommand = () => (process.platform === "win32" ? "npx.cmd" : "npx")
interface CliConfig {
export interface CliConfig {
token?: string
apiUrl?: string
}
const readCliConfig = async (): Promise<CliConfig> => {
export const readCliConfig = async (): Promise<CliConfig> => {
try {
const raw = await readFile(CLI_CONFIG_PATH, "utf8")
return JSON.parse(raw) as CliConfig
@@ -31,6 +36,44 @@ const writeCliConfig = async (config: CliConfig): Promise<void> => {
await writeFile(CLI_CONFIG_PATH, `${JSON.stringify(config, null, 2)}\n`, "utf8")
}
export const getCliConfigPath = () => CLI_CONFIG_PATH
export const getCliInstallCommand = () => `npm install -g ${CLI_NPM_PACKAGE_NAME}`
export const getCliLoginCommand = () =>
`npx --yes ${CLI_NPM_PACKAGE_NAME} login --token <session-token>`
const runCliCommand = async (args: string[]) => {
await execFileAsync(getNpxCommand(), ["--yes", CLI_NPM_PACKAGE_NAME, ...args], {
windowsHide: true,
timeout: 120_000,
maxBuffer: 1024 * 1024,
})
}
export const isCliRunnerAvailable = async (): Promise<boolean> => {
try {
await execFileAsync(getNpxCommand(), ["--version"], {
windowsHide: true,
timeout: 10_000,
maxBuffer: 128 * 1024,
})
return true
} catch {
return false
}
}
const clearCliConfigToken = async () => {
const config = await readCliConfig()
if (!config.token) {
return
}
delete config.token
await writeCliConfig(config)
}
export const getSessionTokenFromCookies = async (): Promise<string | undefined> => {
const window = WindowManager.getMainWindow()
if (!window) return undefined
@@ -47,15 +90,34 @@ export const getSessionTokenFromCookies = async (): Promise<string | undefined>
}
export const syncSessionToCliConfig = async (token?: string): Promise<void> => {
const config = await readCliConfig()
if (token) {
config.token = token
config.apiUrl = env.VITE_API_URL
} else {
delete config.token
const config = await readCliConfig()
if (config.token === token && config.apiUrl === env.VITE_API_URL) {
return
}
if (!(await isCliRunnerAvailable())) {
throw new Error("npx is not available")
}
await runCliCommand(["login", "--token", token, "--api-url", env.VITE_API_URL])
logger.info("CLI login synced via npx")
return
}
await writeCliConfig(config)
logger.info(`CLI config synced (token ${token ? "set" : "cleared"})`)
if (await isCliRunnerAvailable()) {
try {
await runCliCommand(["logout"])
logger.info("CLI login cleared via npx")
return
} catch (error) {
logger.error(
"Failed to clear CLI login via npx, falling back to local config cleanup:",
error,
)
}
}
await clearCliConfigToken()
logger.info("CLI login cleared from local config")
}
+1 -1
View File
@@ -49,7 +49,7 @@ class AppManagerStatic {
registerUpdater()
registerAppTray()
// Sync session to CLI config after window and cookies are ready
// Sync the desktop session to the npm CLI after cookies are ready.
setTimeout(async () => {
try {
const token = await getSessionTokenFromCookies()
@@ -10,9 +10,13 @@ import { SettingSectionTitle } from "../section"
export const SettingCli = () => {
interface CliInstallStatus {
installed: boolean
installPath: string | null
cliSourceAvailable: boolean
connected: boolean
configPath: string
hasDesktopSession: boolean
installCommand: string
loginCommand: string
npxAvailable: boolean
packageName: string
}
const { t } = useTranslation("settings")
const [status, setStatus] = useState<CliInstallStatus | null>(null)
@@ -72,9 +76,9 @@ export const SettingCli = () => {
{status && (
<div className="space-y-3">
<div className="flex items-center gap-2">
<div className="flex flex-wrap items-center gap-2">
<span className="text-sm font-medium">Status:</span>
{status.installed ? (
{status.connected ? (
<span className="inline-flex items-center gap-1 rounded-full bg-green/10 px-2 py-0.5 text-xs text-green">
<i className="i-mingcute-check-line" />
{t("cli.installed")}
@@ -84,31 +88,68 @@ export const SettingCli = () => {
{t("cli.not_installed")}
</span>
)}
<span
className={
status.npxAvailable
? "inline-flex items-center gap-1 rounded-full bg-blue/10 px-2 py-0.5 text-xs text-blue"
: "inline-flex items-center gap-1 rounded-full bg-orange/10 px-2 py-0.5 text-xs text-orange"
}
>
{status.npxAvailable ? t("cli.runtime_ready") : t("cli.runtime_missing")}
</span>
</div>
{status.installed && status.installPath && (
<div className="grid gap-3">
<div className="rounded-xl border border-fill-secondary bg-fill-quaternary/60 p-3">
<div className="mb-1 text-xs font-medium uppercase tracking-wide text-text-secondary">
{t("cli.package")}
</div>
<code className="text-sm font-medium">{status.packageName}</code>
</div>
<div className="rounded-xl border border-fill-secondary bg-fill-quaternary/60 p-3">
<div className="mb-1 text-xs font-medium uppercase tracking-wide text-text-secondary">
{t("cli.global_install")}
</div>
<code className="block break-all text-sm">{status.installCommand}</code>
</div>
<div className="rounded-xl border border-fill-secondary bg-fill-quaternary/60 p-3">
<div className="mb-1 text-xs font-medium uppercase tracking-wide text-text-secondary">
{t("cli.desktop_sync")}
</div>
<code className="block break-all text-sm">{status.loginCommand}</code>
</div>
</div>
<div className="flex items-center gap-2">
<div className="flex items-center gap-2">
<span className="text-sm font-medium">{t("cli.path")}:</span>
<code className="rounded bg-fill-quaternary px-2 py-0.5 text-xs">
{status.installPath}
{status.configPath}
</code>
</div>
)}
</div>
{!status.cliSourceAvailable && (
{!status.npxAvailable && (
<p className="text-sm text-orange-500">{t("cli.not_available")}</p>
)}
{!status.hasDesktopSession && (
<p className="text-sm text-text-secondary">{t("cli.require_login")}</p>
)}
<div className="flex gap-2">
{!status.installed ? (
<Button
onClick={handleInstall}
disabled={loading || !status.cliSourceAvailable}
isLoading={loading}
>
{t("cli.install")}
</Button>
) : (
<Button
onClick={handleInstall}
disabled={loading || !status.npxAvailable || !status.hasDesktopSession}
isLoading={loading}
>
{t("cli.install")}
</Button>
{status.connected && (
<Button
variant="outline"
onClick={handleUninstall}
@@ -6,13 +6,12 @@ import { defineSettingPageData } from "~/modules/settings/utils"
const iconName = "i-mgc-terminal-cute-re"
const priority = (1000 << 1) + 25
const CLI_SETTINGS_DISABLED_FOR_THIS_RELEASE = true
export const loader = defineSettingPageData({
icon: iconName,
name: "titles.cli",
priority,
hideIf: () => CLI_SETTINGS_DISABLED_FOR_THIS_RELEASE || !IN_ELECTRON,
hideIf: () => !IN_ELECTRON,
})
export function Component() {
+1 -2
View File
@@ -18,7 +18,7 @@
"build:electron-forge:macos": "electron-forge make --arch=x64 --platform=darwin && electron-forge make --arch=arm64 --platform=darwin && tsx scripts/merge-yml.ts",
"build:electron-forge:mas": "electron-forge make --arch=universal --platform=mas",
"build:electron-forge:ms": "tsx scripts/generate-appx-manifest.ts && electron-forge make --platform=win32 --ms=true",
"build:electron-vite": "pnpm run prepare:cli && electron-vite build",
"build:electron-vite": "electron-vite build",
"build:render": "vite build -c vite.config.electron-render.ts",
"build:web": "rm -rf out/web && cross-env WEB_BUILD=1 vite build",
"bump": "vv --minor",
@@ -36,7 +36,6 @@
"e2e:web": "playwright test -c e2e/playwright.config.ts --project=web",
"e2e:web:prod": "cross-env FOLO_E2E_PROFILE=prod playwright test -c e2e/playwright.config.ts --project=web",
"hotfix": "vv -c bump.hotfix.config.js --patch",
"prepare:cli": "tsx scripts/prepare-cli.ts",
"publish": "electron-vite build && electron-forge publish",
"start": "electron-vite preview",
"update:main-hash": "tsx plugins/vite/generate-main-hash.ts"
-27
View File
@@ -1,27 +0,0 @@
import { execSync } from "node:child_process"
import { cpSync, existsSync, mkdirSync } from "node:fs"
import { resolve } from "pathe"
const rootDir = resolve(import.meta.dirname, "../../..")
const cliDistDir = resolve(rootDir, "apps/cli/dist")
const targetDir = resolve(rootDir, "apps/desktop/resources/cli")
// Build CLI
console.info("Building CLI...")
execSync("pnpm --filter @follow/cli build", {
cwd: rootDir,
stdio: "inherit",
})
// Ensure CLI was built
const cliEntry = resolve(cliDistDir, "index.js")
if (!existsSync(cliEntry)) {
throw new Error(`CLI build output not found at ${cliEntry}`)
}
// Copy to desktop resources
mkdirSync(targetDir, { recursive: true })
cpSync(cliEntry, resolve(targetDir, "index.js"))
console.info("CLI prepared at", targetDir)
+17 -11
View File
@@ -220,18 +220,24 @@
"appearance.use_pointer_cursor.description": "When the mouse hovers over any interactive element, the cursor appears as a hand.",
"appearance.use_pointer_cursor.label": "Use Hand Cursor",
"appearance.words.customize": "Customize",
"cli.description": "Install the Folo CLI to manage your subscriptions and entries from the terminal. The CLI shares your desktop app login session automatically.",
"cli.install": "Install CLI",
"cli.install_failed": "Failed to install CLI",
"cli.install_success": "CLI installed successfully",
"cli.installed": "Installed",
"cli.not_available": "CLI bundle is not available in this build",
"cli.not_installed": "Not installed",
"cli.path": "Install path",
"cli.description": "Install the npm package to use Folo from any terminal. The global command is folo, and Desktop can sync your current login with one click.",
"cli.desktop_sync": "Desktop sync command",
"cli.global_install": "Global install",
"cli.install": "Sync Desktop Login",
"cli.install_failed": "Failed to sync desktop login to CLI",
"cli.install_success": "Desktop login synced to CLI",
"cli.installed": "Connected",
"cli.not_available": "npx is not available. Install Node.js and npm first.",
"cli.not_installed": "Not connected",
"cli.package": "Package",
"cli.path": "Config path",
"cli.require_login": "Sign in to Folo Desktop first to sync your CLI login.",
"cli.runtime_missing": "Node.js/npm required",
"cli.runtime_ready": "Node.js/npm ready",
"cli.title": "Folo CLI",
"cli.uninstall": "Uninstall CLI",
"cli.uninstall_failed": "Failed to uninstall CLI",
"cli.uninstall_success": "CLI uninstalled successfully",
"cli.uninstall": "Clear CLI Login",
"cli.uninstall_failed": "Failed to clear CLI login",
"cli.uninstall_success": "CLI login cleared",
"common.give_star": "<HeartIcon />Love our product? <Link>Give us a star on GitHub!</Link>",
"control.paid_badge.basic_or_higher": "This feature requires a Basic plan or higher to use",
"control.paid_badge.free_limited": "This feature is limited for free plan",
+17 -11
View File
@@ -220,18 +220,24 @@
"appearance.use_pointer_cursor.description": "Lorsque la souris survole un élément interactif, le curseur apparaît comme une main.",
"appearance.use_pointer_cursor.label": "Utiliser le curseur main",
"appearance.words.customize": "Personnaliser",
"cli.description": "Installez Folo CLI pour gérer vos abonnements et entrées depuis le terminal. Le CLI partage automatiquement la session de connexion de l'application de bureau.",
"cli.install": "Installer CLI",
"cli.install_failed": "Échec de l'installation du CLI",
"cli.install_success": "CLI installé avec succès",
"cli.installed": "Installé",
"cli.not_available": "Le CLI n'est pas disponible dans cette version",
"cli.not_installed": "Non installé",
"cli.path": "Chemin d'installation",
"cli.description": "Installez le package npm pour utiliser Folo depuis n'importe quel terminal. La commande globale est folo, et l'app Desktop peut synchroniser votre connexion actuelle en un clic.",
"cli.desktop_sync": "Commande de synchronisation Desktop",
"cli.global_install": "Installation globale",
"cli.install": "Synchroniser la connexion Desktop",
"cli.install_failed": "Échec de la synchronisation de la connexion Desktop vers le CLI",
"cli.install_success": "Connexion Desktop synchronisée vers le CLI",
"cli.installed": "Connecté",
"cli.not_available": "npx n'est pas disponible. Installez d'abord Node.js et npm.",
"cli.not_installed": "Non connecté",
"cli.package": "Package",
"cli.path": "Chemin du fichier de configuration",
"cli.require_login": "Connectez-vous d'abord à Folo Desktop pour synchroniser la connexion CLI.",
"cli.runtime_missing": "Node.js/npm requis",
"cli.runtime_ready": "Node.js/npm prêt",
"cli.title": "Folo CLI",
"cli.uninstall": "Désinstaller CLI",
"cli.uninstall_failed": "Échec de la désinstallation du CLI",
"cli.uninstall_success": "CLI désinstallé avec succès",
"cli.uninstall": "Effacer la connexion CLI",
"cli.uninstall_failed": "Échec de l'effacement de la connexion CLI",
"cli.uninstall_success": "Connexion CLI effacée",
"common.give_star": "<HeartIcon />Vous aimez notre produit ? <Link>Donnez-nous une étoile sur GitHub !</Link>",
"control.paid_badge.basic_or_higher": "Cette fonctionnalité nécessite un plan Basique ou supérieur",
"control.paid_badge.free_limited": "Cette fonctionnalité est limitée pour le plan gratuit",
+17 -11
View File
@@ -220,18 +220,24 @@
"appearance.use_pointer_cursor.description": "マウスがインタラクティブな要素の上にあるとき、カーソルは手の形になります。",
"appearance.use_pointer_cursor.label": "手の形のカーソルを使用する",
"appearance.words.customize": "カスタマイズ",
"cli.description": "Folo CLI をインストールして、ターミナルからサブスクリプションやエントリーを管理できます。CLI はデスクトップアプリのログイン状態を自動的に共有します。",
"cli.install": "CLI をインストール",
"cli.install_failed": "CLI のインストールに失敗しました",
"cli.install_success": "CLI のインストールに成功しました",
"cli.installed": "インストール済み",
"cli.not_available": "このビルドには CLI が含まれていません",
"cli.not_installed": "未インストール",
"cli.path": "インストールパス",
"cli.description": "npm パッケージをインストールすると、どのターミナルからでも Folo を使えます。グローバルコマンドは folo で、デスクトップアプリから現在のログイン状態をワンクリックで同期できます。",
"cli.desktop_sync": "Desktop sync command",
"cli.global_install": "Global install",
"cli.install": "デスクトップのログインを同期",
"cli.install_failed": "デスクトップのログインを CLI に同期できませんでした",
"cli.install_success": "デスクトップのログインを CLI に同期しました",
"cli.installed": "接続済み",
"cli.not_available": "npx が見つかりません。先に Node.js と npm をインストールしてください。",
"cli.not_installed": "未接続",
"cli.package": "Package",
"cli.path": "設定ファイルのパス",
"cli.require_login": "先に Folo Desktop にログインしてから CLI ログインを同期してください。",
"cli.runtime_missing": "Node.js/npm が必要です",
"cli.runtime_ready": "Node.js/npm 利用可",
"cli.title": "Folo CLI",
"cli.uninstall": "CLI をアンインストール",
"cli.uninstall_failed": "CLI のアンインストールに失敗しました",
"cli.uninstall_success": "CLI のアンインストールに成功しました",
"cli.uninstall": "CLI ログインをクリア",
"cli.uninstall_failed": "CLI ログインをクリアできませんでした",
"cli.uninstall_success": "CLI ログインをクリアしました",
"common.give_star": "<HeartIcon />私たちの製品が好きですか?<Link>GitHub で Star を付けましょう!</Link>",
"control.paid_badge.basic_or_higher": "この機能を利用するには Basic プラン以上が必要です",
"control.paid_badge.free_limited": "この機能は無料プランでは制限されています",
+17 -11
View File
@@ -220,18 +220,24 @@
"appearance.use_pointer_cursor.description": "当鼠标悬停在任何可交互元素上时,光标会显示为手型光标。",
"appearance.use_pointer_cursor.label": "使用手型光标",
"appearance.words.customize": "自定义",
"cli.description": "安装 Folo CLI 以便从终端管理你的订阅和条目。CLI 会自动共享桌面应用的登录状态。",
"cli.install": "安装 CLI",
"cli.install_failed": "CLI 安装失败",
"cli.install_success": "CLI 安装成功",
"cli.installed": "已安装",
"cli.not_available": "当前版本不包含 CLI",
"cli.not_installed": "未安装",
"cli.path": "安装路径",
"cli.description": "通过 npm 安装 Folo CLI 后,你就可以在任意终端里使用它。全局命令为 folo,桌面端可以一键同步当前登录状态。",
"cli.desktop_sync": "桌面端同步命令",
"cli.global_install": "全局安装",
"cli.install": "同步桌面端登录",
"cli.install_failed": "同步桌面端登录到 CLI 失败",
"cli.install_success": "已将桌面端登录同步到 CLI",
"cli.installed": "已连接",
"cli.not_available": "未检测到 npx,请先安装 Node.js 和 npm。",
"cli.not_installed": "未连接",
"cli.package": "包名",
"cli.path": "配置路径",
"cli.require_login": "请先登录 Folo Desktop,再同步 CLI 登录。",
"cli.runtime_missing": "需要 Node.js/npm",
"cli.runtime_ready": "Node.js/npm 已就绪",
"cli.title": "Folo CLI",
"cli.uninstall": "卸载 CLI",
"cli.uninstall_failed": "CLI 卸载失败",
"cli.uninstall_success": "CLI 卸载成功",
"cli.uninstall": "清除 CLI 登录",
"cli.uninstall_failed": "清除 CLI 登录失败",
"cli.uninstall_success": "已清除 CLI 登录",
"common.give_star": "<HeartIcon />喜欢我们的产品吗? <Link>在 GitHub 上给我们「Star」吧!</Link>",
"control.paid_badge.basic_or_higher": "此功能需要 Basic 计划或更高级别才能使用",
"control.paid_badge.free_limited": "此功能在免费计划中有限制",
+17 -11
View File
@@ -220,18 +220,24 @@
"appearance.use_pointer_cursor.description": "當滑鼠懸停在任何互動元素上時,遊標會顯示為手型遊標。",
"appearance.use_pointer_cursor.label": "使用手指遊標",
"appearance.words.customize": "自訂",
"cli.description": "安裝 Folo CLI 以便從終端機管理你的訂閱和條目。CLI 會自動共享桌面應用的登入狀態。",
"cli.install": "安裝 CLI",
"cli.install_failed": "CLI 安裝失敗",
"cli.install_success": "CLI 安裝成功",
"cli.installed": "已安裝",
"cli.not_available": "目前版本不包含 CLI",
"cli.not_installed": "未安裝",
"cli.path": "安裝路徑",
"cli.description": "透過 npm 安裝 Folo CLI 後,你就可以在任何終端機裡使用它。全域命令為 folo,桌面端可以一鍵同步目前的登入狀態。",
"cli.desktop_sync": "桌面端同步命令",
"cli.global_install": "全域安裝",
"cli.install": "同步桌面端登入",
"cli.install_failed": "同步桌面端登入到 CLI 失敗",
"cli.install_success": "已將桌面端登入同步到 CLI",
"cli.installed": "已連線",
"cli.not_available": "找不到 npx,請先安裝 Node.js 與 npm。",
"cli.not_installed": "未連線",
"cli.package": "套件名稱",
"cli.path": "設定檔路徑",
"cli.require_login": "請先登入 Folo Desktop,再同步 CLI 登入。",
"cli.runtime_missing": "需要 Node.js/npm",
"cli.runtime_ready": "Node.js/npm 已就緒",
"cli.title": "Folo CLI",
"cli.uninstall": "解除安裝 CLI",
"cli.uninstall_failed": "CLI 解除安裝失敗",
"cli.uninstall_success": "CLI 解除安裝成功",
"cli.uninstall": "清除 CLI 登入",
"cli.uninstall_failed": "清除 CLI 登入失敗",
"cli.uninstall_success": "已清除 CLI 登入",
"common.give_star": "<HeartIcon />喜歡我們的產品嗎? <Link>在 GitHub 上給我們 Star 吧!</Link>",
"control.paid_badge.basic_or_higher": "此功能需要 Basic 方案或更高級別才能使用",
"control.paid_badge.free_limited": "此功能在免費方案中受限",