Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
keremgunduz86 committed Aug 25, 2020
1 parent fb892fb commit 0c2a8b8
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 58 deletions.
90 changes: 37 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,92 +1,76 @@
# Changelog Script
# SDK Copy Management

Changelog script helps projects to generate changelogs and update their markdown files during release process.
This repo helps projects to integrate with SDK copy management tool (currently Lokalise).

- [Getting started](#getting-started)
- [Pre-requisites](#pre-requisites)
- [Tools](#tools)
- [Generating Changelog Entry](#generating-changelog-entry)
- [Updating Changelog Files](#updating-changelog-files)
- [Retrieving Released Changelogs](#retrieving-released-changelogs)
- [Fetching Strings](#fetching-strings)
- [Checking Strings](#checking-strings)

## Getting started

This section will contain the necessary instructions to enable you to run the project.

### Pre-requisites

Before starting changelog script you should update your project structure with creating changelogs/ folder under your project root.

#### Tools

- Ruby must be installed in system where you run changelog scripts. Suggested version is 2.6.x.
- Ruby must be installed in system where you run scripts. Suggested version is 2.6.x.
- Run `gem install bundler` to install ruby dependency manager
- Run `bundle install` to install necessary ruby packages

## Generating Changelog Entry
## Fetching Strings

When you start to work on new ticket, most probably you will want to create changelog entry for it. Rather than updating your CHANGELOG.Md file, you should run this script. Basically this script:
- Copies sample changelog entry from this repository to {YOUR_PROJECT_PATH}/changelogs/unreleased folder.
- It also checks your current git branch name. if there is any CX-XXXX pattern in the branch name, script renames json file same as your current branch name.
When copies are updated on lokalise, at some point SDK projects will have to adopt those changes. Rather than moving copy changes manually from lokalise to the project, this script helps you to fetch changes in one go.

Example script usage:
So this script:

```shell
$ ./bin/create_changelog_entry.rb --project-path '/Users/admin/Desktop/dev/repo/onfido-ios-sdk'
```
### Parameters

| Paremeter Name | Required | Description |
|--------------------------------|---------------|----------------------------------|
| project-path | YES | Root path of your project |

**Note**: --project-path parameter is required

## Updating Changelog Files

During release process, you may want to update your changelog or migration files based on the changelog entries generated until that time. This script allows you to update your internal/public changelog and migration files to be updated.
- Finds string changes with the given tag.
- Retrieves those changes and applies changes to string files of the project.

Example script usage:

```shell
$ ./bin/update_changelog_files.rb --project-path '/Users/admin/Desktop/dev/repo/onfido-ios-sdk' \
--sdk-version '18.0.0' \
--platform 'ios' \
--internal-changelog-file-path 'CHANGELOG-INTERNAL.md' \
--public-changelog-file-path 'documentation/CHANGELOG.md' \
--migration-file-path 'documentation/MIGRATION.md'
$ ./bin/fetch-strings.rb --tag 'CX-5433 NFC UI' \
--platform ios \
--project-path /Users/kerem.gunduz/Desktop/dev/repo/onfido-ios-sdk \
--lokalise-project-id YYY \
--lokalise-token XXX
```

### Parameters

| Paremeter Name | Required | Description |
|--------------------------------|---------------|----------------------------------|
| project-path | YES | Root path of your project
| sdk-version | YES| New SDK version you're about to release |
|platform | YES | Can be either `ios`, `android` or `js` |
| internal-changelog-file-path | NO | Relative path of internal changelog file, don't pass this parameter if you don't use internal change log in your project |
| public-changelog-file-path | YES | Relative path of public changelog file |
| migration-file-path | NO | Relative path of migration file, don't pass this parameter if you don't use migration document or you want to manage it on your own |
| tag | YES | Tag name you want to use on lokalise to fetch updates |
| platform | YES | Platform value, can be either ios or android |
| project-path | YES | Root path of your project |
| lokalise-project-id | YES | Lokalise project id value, can be retrieved from https://app.lokalise.com/ |
| lokalise-token | YES | Lokalise token value, can be retrieved from https://app.lokalise.com/ |

## Retrieving Released Changelogs
## Checking Strings

At any time, you may want to retrieve released changelogs. This script prints you to know what changes has been done for given version.
This script helps you to understand whether strings on lokalise and project are consistent. It checks missing, extra strings along with mismatched translations.

Example script usage:

```shell
$ ./bin/retrieve_released_changelogs.rb --project-path '/Users/admin/Desktop/dev/repo/onfido-ios-sdk' \
--sdk-version '18.0.0' \
--public-only
$ ./bin/check-strings.rb --lang en_US \
--platform android \
--branch new_auto_capture_alert \
--project-path /Users/kerem.gunduz/Desktop/dev/repo/android-capture-sdk/onfido-capture-sdk-core/src/main/res \
--lokalise-project-id XXX \
--lokalise-token YYY
```

### Parameters

| Paremeter Name | Required | Description |
|--------------------------------|---------------|----------------------------------|
| project-path | YES | Root path of your project
| sdk-version | YES| SDK version you want to get information |
| public-only | NO | Indicates that you want to get only `public` changelog entries. Don't pass it if you want to get all changes|

| Paremeter Name | Required | Description |
|----------------|-------------------|----------------------------------|
| project-path | YES | Root path of your project |
| platform | YES | Platform value, can be either ios or android |
| lang | YES | Language code |
| branch | YES | Lokalise branch name |
| lokalise-project-id | YES | Lokalise project id value, can be retrieved from https://app.lokalise.com/ |
| lokalise-token | YES | Lokalise token value, can be retrieved from https://app.lokalise.com/ |

**Hint**: You can run scripts with `-h` option to get more detailed usage explanation.
**Hint**: You can create bash or ruby script wrappers to prevent sending same parameters over and over again.
13 changes: 9 additions & 4 deletions bin/check-strings.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env ruby
require 'slop'

require 'terminal-table'
require_relative '../src/string-check-runner'
require_relative '../src/common/constants'

options = Slop.parse do |o|
o.string '--lang', '-l', 'Language code', required: true
o.string '--platform', '-p', 'Platform value, can be either ios or android', required: true
o.string '--lang', '-l', "Language code, options: #{LANGUAGES.join(', ')}", required: true
o.string '--platform', '-p', "Platform value, options: #{PLARFORMS.join(', ')}, required: true
o.string '--lokalise-token', '-lt', 'Lokalise token to access strings', required: true
o.string '--lokalise-project-id', '-lpi', 'Lokalise project id', required: true
o.string '--project-path', '-pp', 'Path to project root', required: true
Expand All @@ -16,6 +17,10 @@
end
end

Onfido::StringCheckRunner.new(lang: options[:lang], platform: options[:platform],
result = Onfido::StringCheckRunner.new(lang: options[:lang], platform: options[:platform],
project_path: options[:project_path], branch: options[:branch], lokalise_project_id: options[:lokalise_project_id],
lokalise_token: options[:lokalise_token]).run

puts Terminal::Table.new title: 'Extra keys in lokalise', rows: result[0]
puts Terminal::Table.new title: 'Missing keys in lokalise', rows: result[1]
puts Terminal::Table.new title: 'Mismatched translation values', headings: ['key', 'Value in Project', 'Value in Lokalise'], rows: result[2]
3 changes: 2 additions & 1 deletion bin/fetch-strings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
require 'slop'

require_relative '../src/localisation-file-updater'
require_relative '../src/common/constants'

options = Slop.parse do |o|
o.string '--tag', '-t', 'Tag name that you want to fetch from lokalise', required: true
o.string '--lokalise-project-id', '-lpi', 'Lokalise project id', required: true
o.string '--lokalise-token', '-lt', 'Lokalise token to access strings', required: true
o.string '--platform', '-p', 'Platform value, can be either ios or android', required: true
o.string '--platform', '-p', "Platform value, options: #{PLARFORMS.join(', ')}, required: true
o.string '--project-path', '-pp', 'Path to project root', required: true
o.on '--help', '-h' do
puts o
Expand Down
2 changes: 2 additions & 0 deletions src/common/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
module Onfido

LOCALIZE_RESULTS_REGEX_IOS = /"(.+)"\s*=\s*"(.+)"/
PLARFORMS = ['ios', 'android']
LANGUAGES = ['en_US', 'de_DE', 'es_ES', 'fr_FR']

end

0 comments on commit 0c2a8b8

Please sign in to comment.