{"id":16939,"library":"accent-cli","title":"Accent CLI","description":"The `accent-cli` package provides a robust command-line interface for seamless interaction with an Accent localization instance. It empowers developers to automate critical localization workflows, including synchronizing translation files, managing project configurations, and executing custom hooks directly from the terminal or within CI/CD pipelines. The current stable version is 0.17.0, and it follows a semantic versioning approach, with updates released to introduce new features, improve stability, and address bug fixes in alignment with the Accent platform's development. A key differentiator is its deep integration with the Accent platform, supporting various localization file formats such as JSON and `.strings`. It offers highly flexible configuration via a dedicated `accent.json` file, which supports powerful glob-pattern matching for file paths, and environment variables for sensitive data like API keys and URLs, providing secure and adaptable deployment options.","status":"active","version":"0.17.0","language":"javascript","source_language":"en","source_url":"https://github.com/mirego/accent","tags":["javascript","oclif","typescript"],"install":[{"cmd":"npm install accent-cli","lang":"bash","label":"npm"},{"cmd":"yarn add accent-cli","lang":"bash","label":"yarn"},{"cmd":"pnpm add accent-cli","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for matching source file paths with glob patterns as specified in the `accent.json` configuration, enabling flexible file selection.","package":"node-glob","optional":false}],"imports":[{"note":"accent-cli is built using the oclif framework for command-line interfaces. Its primary use is by executing the 'accent' binary in a shell environment, not as a JavaScript library. Attempting to import internal components directly is an anti-pattern and unsupported for stable API usage.","wrong":"import { AccentCommand } from 'accent-cli'","symbol":"AccentCommand","correct":"This package is primarily a CLI tool and not intended for direct programmatic import of its internal commands or modules. Interaction is via the 'accent' binary."},{"note":"The internal configuration schema or types used by accent-cli are not explicitly exported for programmatic consumption. Developers should define their project's localization settings in `accent.json` or via `ACCENT_` prefixed environment variables, as documented.","wrong":"import { AccentConfiguration } from 'accent-cli'","symbol":"AccentConfiguration","correct":"Configuration for accent-cli is managed externally through `accent.json` files or environment variables."},{"note":"There is no `run` function or similar public entry point exported for direct library usage. If you need to trigger `accent-cli` commands from a Node.js script, use `child_process.exec` or `child_process.spawn` to invoke the command-line binary.","wrong":"import { run } from 'accent-cli'","symbol":"run","correct":"To interact with accent-cli programmatically from Node.js, execute the 'accent' command using Node's `child_process` module."}],"quickstart":{"code":"import { exec } from 'child_process';\nimport * as path from 'path';\nimport * as fs from 'fs';\n\n// Define paths for dummy files\nconst configPath = path.join(process.cwd(), 'accent.json');\nconst dummyLocaleDir = path.join(process.cwd(), 'localization_test');\nconst dummyLocaleFilePath = path.join(dummyLocaleDir, 'en.json');\n\n// Create a dummy accent.json for demonstration\nconst dummyConfig = {\n  \"apiUrl\": process.env.ACCENT_API_URL ?? \"http://localhost:3000\",\n  \"apiKey\": process.env.ACCENT_API_KEY ?? \"sk_exampleapikey123\", // Replace with a real key or env var in production\n  \"project\": process.env.ACCENT_PROJECT ?? \"a1b2c3d4-e5f6-7890-1234-567890abcdef\",\n  \"files\": [\n    {\n      \"format\": \"json\",\n      \"source\": \"localization_test/en.json\",\n      \"target\": \"localization_test/%slug%/%document_path%.json\"\n    }\n  ]\n};\nfs.writeFileSync(configPath, JSON.stringify(dummyConfig, null, 2));\nconsole.log(`Created dummy accent.json at ${configPath}`);\n\n// Create a dummy localization file\nif (!fs.existsSync(dummyLocaleDir)) {\n  fs.mkdirSync(dummyLocaleDir);\n}\nfs.writeFileSync(dummyLocaleFilePath, JSON.stringify({ \"hello\": \"Hello from accent-cli!\" }, null, 2));\nconsole.log(`Created dummy localization/en.json at ${dummyLocaleFilePath}`);\n\nconsole.log('Running accent-cli programmatically with `accent sync`...');\n\nexec('accent sync', (error, stdout, stderr) => {\n  if (error) {\n    console.error(`Error executing accent sync: ${error.message}`);\n    console.error(`stderr: ${stderr}`);\n    return;\n  }\n  console.log(`stdout: ${stdout}`);\n  if (stderr) {\n    console.warn(`stderr (warnings/info): ${stderr}`);\n  }\n  console.log('accent-cli sync command executed successfully.');\n\n  // Clean up dummy files and directory\n  try {\n    fs.unlinkSync(configPath);\n    fs.unlinkSync(dummyLocaleFilePath);\n    fs.rmdirSync(dummyLocaleDir, { recursive: true });\n    console.log('Cleaned up dummy files and directory.');\n  } catch (cleanupError) {\n    console.error(`Error during cleanup: ${cleanupError}`);\n  }\n});\n","lang":"typescript","description":"This quickstart demonstrates how to execute `accent-cli` commands programmatically from a Node.js application using the `child_process.exec` function. It includes the creation of a temporary `accent.json` configuration file and a dummy localization file to simulate a project setup, runs the `accent sync` command, and then cleans up the generated temporary files and directories."},"warnings":[{"fix":"Always check your active environment variables if the configuration specified in `accent.json` appears to be ignored. Explicitly unset environment variables if you intend for `accent.json` values to take effect, or consistently manage configuration through a single source.","message":"Environment variables (e.g., `ACCENT_API_KEY`, `ACCENT_API_URL`, `ACCENT_PROJECT`) override corresponding values defined in the `accent.json` configuration file. This precedence can lead to unexpected behavior if not understood.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Before upgrading `accent-cli`, review the official documentation for any breaking changes related to command arguments or configuration. For automated scripts, consider pinning to a specific minor version (e.g., `^0.17.x`) and thoroughly testing upgrades in a staging environment.","message":"As an active CLI tool, the syntax, arguments, or flags for specific commands can undergo changes between minor or even patch versions. Relying on undocumented or experimental flags may lead to breakage upon upgrade.","severity":"breaking","affected_versions":">=0.x.0"},{"fix":"Thoroughly test your glob patterns, especially for complex file structures. Consult the `node-glob` library documentation for advanced pattern matching. Use `accent --help [command]` for command-specific options that might assist in debugging file paths or dry runs if available.","message":"Incorrectly formatted glob patterns in the `source` or `target` properties within `accent.json` can cause files to be missed during synchronization or incorrectly written to unintended locations. `accent-cli` uses the `node-glob` library, which has specific syntax rules.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Carefully review all commands defined within the `hooks` section of your `accent.json`. Ensure that any commands are from trusted sources, do not process untrusted user input, and are executed with the minimum necessary permissions. Consider running `accent-cli` in a sandboxed or containerized environment for critical workflows.","message":"The `hooks` feature allows executing arbitrary shell commands, which can introduce security vulnerabilities if the commands are not trusted or if they process untrusted input. Malicious commands could lead to data exposure or system compromise.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Ensure that the `ACCENT_API_KEY` environment variable is set to your valid Accent API key, or add an `\"apiKey\": \"YOUR_API_KEY\"` entry to your `accent.json` file.","cause":"The Accent API key required for authentication is not provided, either as an environment variable or in the configuration file.","error":"Error: Missing Accent API Key. Please set ACCENT_API_KEY environment variable or 'apiKey' in accent.json"},{"fix":"Verify the command name is spelled correctly. Use `accent --help` to list all available commands and their usage. If the command should exist, ensure you have the latest stable version of `accent-cli` or a version where the command is supported.","cause":"The command executed (e.g., `accent xyz`) is not a recognized or supported subcommand of `accent-cli` for the installed version.","error":"Error: Command 'xyz' not found."},{"fix":"Open your `accent.json` file and meticulously review its JSON syntax. Pay close attention to commas between properties, correctly balanced brackets and braces, and properly quoted string values. Utilize a JSON linter or an IDE with JSON validation to quickly identify and correct the syntax error.","cause":"The `accent.json` configuration file contains a syntax error (e.g., missing comma, unclosed quote, invalid character) that prevents it from being parsed as valid JSON.","error":"Error: Invalid accent.json: Unexpected token [token] in JSON at position [position]"}],"ecosystem":"npm","meta_description":null}