Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cli in the repo to truly become a MONOREPO 🎉
- Loading branch information
Showing
62 changed files
with
5,933 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "oclif" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
*-debug.log | ||
*-error.log | ||
.oclif.manifest.json | ||
/lib | ||
/node_modules | ||
/tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Copyright (c) 2018, Mirego All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
Neither the name of the Mirego nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
Accent CLI | ||
====== | ||
|
||
[![Version](https://img.shields.io/npm/v/accent-cli.svg)](https://npmjs.org/package/accent-cli) | ||
[![Build Status](https://img.shields.io/travis/v/accent-cli.svg?branch=master)](https://travis-ci.com/mirego/accent-cli) | ||
|
||
<!-- toc --> | ||
* [Usage](#usage) | ||
* [Configuration](#configuration) | ||
* [Commands](#commands) | ||
* [License](#license) | ||
* [About Mirego](#about-mirego) | ||
<!-- tocstop --> | ||
|
||
# Usage | ||
<!-- usage --> | ||
```sh-session | ||
$ npm install -g accent-cli | ||
$ accent COMMAND | ||
running command... | ||
$ accent (-v|--version|version) | ||
accent-cli/0.6.0 darwin-x64 node-v9.5.0 | ||
$ accent --help [COMMAND] | ||
USAGE | ||
$ accent COMMAND | ||
... | ||
``` | ||
<!-- usagestop --> | ||
|
||
# Configuration | ||
|
||
accent-cli reads from a `accent.json` file. The file should contain valid JSON representing the configuration of your project. | ||
|
||
## Example | ||
|
||
``` | ||
{ | ||
"apiUrl": "http://your.accent.instance", | ||
"apiKey": "2nziVSaa8yUJxLkwoZA", | ||
"files": [ | ||
{ | ||
"language": "fr", | ||
"format": "json", | ||
"source": "localization/fr/*.json", | ||
"target": "localization/%slug%/%original_file_name%.json", | ||
"hooks": { | ||
"afterSync": "touch sync-done.txt" | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
|
||
## Document configuration | ||
|
||
Each operation section `sync` and `addTranslations` can contain the following object: | ||
|
||
- `language`: The identifier of the document’s language | ||
- `format`: The format of the document | ||
- `source`: The path of the document. This can contain glob pattern (See [the node glob library] used as a dependancy (https://github.com/isaacs/node-glob)) | ||
- `target`: Path of the target languages | ||
- `hooks`: List of hooks to be run | ||
|
||
## Hooks | ||
|
||
Here is a list of available hooks. Those are self-explanatory | ||
|
||
- `beforeSync` | ||
- `afterSync` | ||
- `beforeExport` | ||
- `afterExport` | ||
|
||
# Commands | ||
<!-- commands --> | ||
* [`accent export`](#accent-export) | ||
* [`accent help [COMMAND]`](#accent-help-command) | ||
* [`accent jipt PSEUDOLANGUAGENAME`](#accent-jipt-pseudolanguagename) | ||
* [`accent stats`](#accent-stats) | ||
* [`accent sync`](#accent-sync) | ||
|
||
## `accent export` | ||
|
||
Export files from Accent and write them to your local filesystem | ||
|
||
``` | ||
USAGE | ||
$ accent export | ||
OPTIONS | ||
--order-by=index|key-asc [default: index] Will be used in the export call as the order of the keys | ||
EXAMPLE | ||
$ accent export | ||
``` | ||
|
||
## `accent help [COMMAND]` | ||
|
||
display help for accent | ||
|
||
``` | ||
USAGE | ||
$ accent help [COMMAND] | ||
ARGUMENTS | ||
COMMAND command to show help for | ||
OPTIONS | ||
--all see all commands in CLI | ||
``` | ||
|
||
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v2.1.4/src/commands/help.ts)_ | ||
|
||
## `accent jipt PSEUDOLANGUAGENAME` | ||
|
||
Export jipt files from Accent and write them to your local filesystem | ||
|
||
``` | ||
USAGE | ||
$ accent jipt PSEUDOLANGUAGENAME | ||
ARGUMENTS | ||
PSEUDOLANGUAGENAME The pseudo language for in-place-translation-editing | ||
EXAMPLE | ||
$ accent jipt | ||
``` | ||
|
||
## `accent stats` | ||
|
||
Fetch stats from the API and display it beautifully | ||
|
||
``` | ||
USAGE | ||
$ accent stats | ||
EXAMPLE | ||
$ accent stats | ||
``` | ||
|
||
## `accent sync` | ||
|
||
Sync files in Accent and write them to your local filesystem | ||
|
||
``` | ||
USAGE | ||
$ accent sync | ||
OPTIONS | ||
--add-translations Add translations in Accent to help translators if you already have translated | ||
strings | ||
--merge-type=smart|passive|force [default: smart] Will be used in the add translations call as the "merge_type" param | ||
--order-by=index|key-asc [default: index] Will be used in the export call as the order of the keys | ||
--sync-type=smart|passive [default: smart] Will be used in the sync call as the "sync_type" param | ||
--write Write the file from the export _after_ the operation | ||
EXAMPLE | ||
$ accent sync | ||
``` | ||
<!-- commandsstop --> | ||
|
||
# License | ||
|
||
`accent-cli` is © 2019 [Mirego](http://www.mirego.com) and may be freely distributed under the [New BSD license](http://opensource.org/licenses/BSD-3-Clause). See the [`LICENSE.md`](https://github.com/mirego/accent-cli/blob/master/LICENSE.md) file. | ||
|
||
# About Mirego | ||
|
||
[Mirego](http://mirego.com) is a team of passionate people who believe that work is a place where you can innovate and have fun. We’re a team of [talented people](http://life.mirego.com) who imagine and build beautiful Web and mobile applications. We come together to share ideas and [change the world](http://mirego.org). | ||
|
||
We also [love open-source software](http://open.mirego.com) and we try to give back to the community as much as we can. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env node | ||
|
||
require('@oclif/command').run() | ||
.catch(require('@oclif/errors/handle')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@echo off | ||
|
||
node "%~dp0\run" %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"files": [ | ||
{ | ||
"language": "fr", | ||
"format": "json", | ||
"source": "core/*.json", | ||
"target": "core/%original_file_name%-%slug%.json", | ||
"hooks": { | ||
"beforeSync": [ | ||
"rm -rf core", | ||
"mkdir -p core", | ||
"ruby core.rb unmerge translations.json fr > core/core-is-awesome.json" | ||
], | ||
"beforeAddTranslations": [ | ||
"ruby core.rb unmerge translations.json en > core/core-is-awesome-en.json" | ||
], | ||
"afterExport": [ | ||
"ruby core.rb merge core/core-is-awesome-en.json core/core-is-awesome-fr.json > translations.json", | ||
"rm -rf core" | ||
] | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Merge and unmerge files to be "core translations" compliant and Accent compliant. | ||
|
||
# ## Merge | ||
# The file used in this command contains en and fr translations and outputs | ||
# "key" => value in the specified language. | ||
# | ||
# Given the file en.json: | ||
# {"key": "foo"} | ||
# Given the file fr.json: | ||
# {"key": "bar"} | ||
# ruby core.rb merge en.json fr.json | ||
# { | ||
# "key": { | ||
# "en": "bar", | ||
# "fr": "foo" | ||
# } | ||
# } | ||
# | ||
# ## Unmerge | ||
# The file used in this command contains en and fr translations and outputs | ||
# "key" => value in the specified language. | ||
# | ||
# Given the file: | ||
# { | ||
# "key": { | ||
# "en": "bar", | ||
# "fr": "foo" | ||
# } | ||
# } | ||
# `ruby core.rb unmerge file.json fr` | ||
# | ||
# { | ||
# "key": "foo" | ||
# } | ||
|
||
require 'json' | ||
|
||
if ARGV[0] === 'merge' | ||
en_json = JSON.parse(File.read(ARGV[1])) | ||
fr_json = JSON.parse(File.read(ARGV[2])) | ||
|
||
output = en_json.each_with_object({}) { |(key, value), memo| memo[key] = {fr: fr_json[key], en: value} } | ||
puts JSON.pretty_generate(output) | ||
end | ||
|
||
if ARGV[0] === 'unmerge' | ||
output = JSON.parse(File.read(ARGV[1])).each_with_object({}) { |(key, value), memo| memo[key] = value[ARGV[2]] } | ||
puts JSON.pretty_generate(output) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"key": { | ||
"fr": "valeur", | ||
"en": "value" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"files": [ | ||
{ | ||
"language": "en", | ||
"format": "json", | ||
"source": "translations/en.json", | ||
"target": "translations/%slug%.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"key": { | ||
"nested": "Value" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"key": { | ||
"nested": "Valeur" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"files": [ | ||
{ | ||
"language": "en", | ||
"format": "gettext", | ||
"source": "priv/en/*.po", | ||
"target": "priv/%slug%/%original_file_name%.po" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
msgid "" | ||
msgstr "" | ||
"Language: en" | ||
|
||
msgid "key" | ||
msgstr "Value" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
msgid "" | ||
msgstr "" | ||
"Language: fr" | ||
|
||
msgid "key" | ||
msgstr "Valeur" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
output-directory: config/locales | ||
input-directory: config/locales |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'aigu' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
aigu (1.2) | ||
nokogiri (~> 1.6) | ||
mini_portile2 (2.3.0) | ||
nokogiri (1.8.5) | ||
mini_portile2 (~> 2.3.0) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
aigu | ||
|
||
BUNDLED WITH | ||
1.16.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"files": [ | ||
{ | ||
"language": "en", | ||
"format": "json", | ||
"source": "aigu/*.json", | ||
"target": "aigu/%original_file_name%-%slug%.json", | ||
"hooks": { | ||
"beforeSync": [ | ||
"rm -rf aigu", | ||
"mkdir -p aigu", | ||
"aigu rails-export --locale=en --output-file=aigu/aigu-is-awesome.json >/dev/null 2>&1" | ||
], | ||
"beforeAddTranslations": [ | ||
"aigu rails-export --locale=fr --output-file=aigu/aigu-is-awesome-fr.json >/dev/null 2>&1" | ||
], | ||
"beforeExport": [ | ||
"rm -rf aigu", | ||
"mkdir -p aigu" | ||
], | ||
"afterExport": [ | ||
"aigu rails-import --locale=en --input-file=aigu/aigu-is-awesome-en.json >/dev/null 2>&1", | ||
"aigu rails-import --locale=fr --input-file=aigu/aigu-is-awesome-fr.json >/dev/null 2>&1", | ||
"rm -rf aigu" | ||
] | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
en: | ||
my_file: | ||
key: Value |
Oops, something went wrong.