Skip to content

Commit

Permalink
Merge pull request #238 from creative-commoners/pulls/master/remove-t…
Browse files Browse the repository at this point in the history
…ranslations

ENH Remove translation functionality
  • Loading branch information
GuySartorelli committed Mar 3, 2023
2 parents 5682d6d + e96527c commit cf476b0
Show file tree
Hide file tree
Showing 15 changed files with 2 additions and 898 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The ineptly named tool which may one day supercede the older [build tools](https
![moo](https://media.giphy.com/media/8AsXV477ls6LS/giphy.gif)

## DEV_MODE
Enable DEV_MODE by adding DEV_MODE=1 to a .env file. This will prevent pushing to github and transifex.
Enable DEV_MODE by adding DEV_MODE=1 to a .env file. This will prevent pushing to github.

Do not perform a release on a directory if you previously used DEV_MODE on that directory because the steps will be out of order. Instead, delete the directory that had DEV_MODE run on it and start the entire release again with DEV_MODE disabled.

Expand Down Expand Up @@ -63,7 +63,6 @@ To run Cow without Docker, reference the `Dockerfile` for system requirements.

## Extra setup

* For translation steps you may need the Transifex API Key and ~/.transifexrc (run `./docker/bin/tx init` to generate it).
* When publishing to GitHub make sure you have `ssh-agent` running and your SSH keys loaded (run `ssh-add`)

## Commands
Expand Down
2 changes: 0 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ FROM php as base

RUN apt-get update -y \
&& apt-get install -y git python3-pip openssh-client \
&& pip3 install -U pip \
&& pip install transifex-client awscli \
&& apt-get install -y ruby \
&& gem install yamlclean

Expand Down
7 changes: 1 addition & 6 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ but only used within `docker-compose.yml`

### Scripts

When you run Cow via one of these scripts, Docker will be given access to the contents of the folder you ran it from, along with some of your environment variables, .transifexrc and SSH agent, to allow creating / modifying releases and publishing them to GitHub.
When you run Cow via one of these scripts, Docker will be given access to the contents of the folder you ran it from, along with some of your environment variables, and SSH agent, to allow creating / modifying releases and publishing them to GitHub.

#### ./docker/bin/debug

Expand Down Expand Up @@ -105,8 +105,3 @@ Runs a stable Cow release, based on the latest published Docker container.

Runs `./vendor/bin/phpunit` within a container with Xdebug knocking to port 9000 (configurable through `docker/.env`).
Can be used for Cow tests development and debugging.


#### ./docker/bin/tx

Runs transifex client within the latest stable container published.
3 changes: 0 additions & 3 deletions docker/bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ docker_compose_params()

docker_compose_run()
{
# make sure .transifexrc exists (otherwise docker creates a folder there
[ -f ~/.transifexrc ] || touch ~/.transifexrc;

cd $DOCKER_DIR && \
docker-compose run --rm $(docker_compose_params) $EXTRA_FLAGS $1 ${@:2}
}
Expand Down
13 changes: 0 additions & 13 deletions docker/bin/tx

This file was deleted.

1 change: 0 additions & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ x-volumes: &volumes
- '${GIT_CONFIG}:/home/cow/.gitconfig:ro'
# - '${SSH_AUTH_SOCK}:${SSH_AUTH_SOCK}:rw' # macOS socket is not writeable by non-root users
- '~/.ssh:/home/cow/.ssh'
- '~/.transifexrc:/home/cow/.transifexrc'

x-debug-env-var: &x-debug-env-var 'remote_enable=1 remote_mode=req remote_port=${XDEBUG_PORT} remote_host=${XDEBUG_HOST} remote_connect_back=0'

Expand Down
5 changes: 0 additions & 5 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ if [ ! -z "$COW_MODE_RELEASE" ] ; then
ssh -qT [email protected] 2>&1 | grep "successfully authenticated" || (echo "GitHub authentication error" && exit 1)
fi

if [ ! -z "$COW_MODE_TRANSIFEX" ] ; then
tx $@
exit;
fi

if [ ! -z "$COW_MODE_COMPOSER" ] ; then
composer $@
exit;
Expand Down
2 changes: 0 additions & 2 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ protected function getDefaultCommands(): array
$commands[] = new Commands\Release\Create();
$commands[] = new Commands\Release\Plan();
$commands[] = new Commands\Release\Branch();
$commands[] = new Commands\Release\Translate();
$commands[] = new Commands\Release\Test();
$commands[] = new Commands\Release\Changelog($this);
$commands[] = new Commands\Release\MergeUp();
Expand All @@ -114,7 +113,6 @@ protected function getDefaultCommands(): array
$commands[] = new Commands\Release\Publish();

// Module commands
$commands[] = new Commands\Module\TranslateBuild();
$commands[] = new Commands\Module\Sync\Metadata($supportedModuleLoader);

// Schema commands
Expand Down
37 changes: 0 additions & 37 deletions src/Commands/Module/TranslateBuild.php

This file was deleted.

29 changes: 0 additions & 29 deletions src/Commands/Release/Release.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use SilverStripe\Cow\Steps\Release\PlanRelease;
use SilverStripe\Cow\Steps\Release\RewriteReleaseBranches;
use SilverStripe\Cow\Steps\Release\RunTests;
use SilverStripe\Cow\Steps\Release\UpdateTranslations;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\Output;
Expand Down Expand Up @@ -39,24 +38,6 @@ protected function configureOptions()
InputOption::VALUE_NONE,
'Skip the tests suite run when performing the release'
)
->addOption(
'skip-i18n',
null,
InputOption::VALUE_NONE,
'Skip the text collection task when performing the release'
)
->addOption(
'skip-i18n-translations-pull-and-update',
null,
InputOption::VALUE_NONE,
'Skip running tx pull, i18nTextCollectorTask and js/json updates'
)
->addOption(
'i18n-translations-push',
null,
InputOption::VALUE_NONE,
'Run tx push -s - only do this during the beta1 release of a new minor'
)
->addOption(
'skip-emulate-requirements',
null,
Expand Down Expand Up @@ -127,16 +108,6 @@ protected function fire()
$branchAlias = new RewriteReleaseBranches($this, $project, $releasePlan);
$branchAlias->run($this->input, $this->output);

// Update all translations
if (!$this->input->getOption('skip-i18n')) {
$translate = new UpdateTranslations($this, $project, $releasePlan);
$doTxPullAndUpdate = !$this->input->getOption('skip-i18n-translations-pull-and-update');
$translate->setDoTransifexPullAndUpdate($doTxPullAndUpdate);
$doTxPush = $this->input->getOption('i18n-translations-push');
$translate->setDoTransifexPush($doTxPush);
$translate->run($this->input, $this->output);
}

// Run tests
if (!$this->input->getOption('skip-tests')) {
$test = new RunTests($this, $project);
Expand Down
39 changes: 0 additions & 39 deletions src/Commands/Release/Translate.php

This file was deleted.

97 changes: 0 additions & 97 deletions src/Model/Modules/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,6 @@
*/
class Module extends Library
{
/**
* Gets the module lang dir
*
* @return string
*/
public function getLangDirectory()
{
$sources = $this->getTransifexSources();
foreach ($sources as $source) {
if (preg_match('#^(?<dir>.+)\\/(?<file>[^\\/]+)\\.yml$#', $source, $matches)) {
return $this->getDirectory() . '/' . $matches['dir'];
}
}
return null;
}

/**
* Gets the directories of the JS lang folder.
*
* @return array
*/
public function getJSLangDirectories()
{
$sources = $this->getTransifexSources();
$dirs = [];
foreach ($sources as $source) {
// Strip out /src/ dir and trailing file.js
if (preg_match('#^(?<dir>.+)\\/src\\/(?<file>[^\\/]+)\\.js(on)?$#', $source, $matches)) {
$dirs[] = $this->getDirectory() . '/' . $matches['dir'];
}
}
return $dirs;
}

/**
* Get list of transifex source files. E.g. lang/en.yml
*
* @return string[]
*/
public function getTransifexSources()
{
if (!$this->isTranslatable()) {
return [];
}

$path = $this->getDirectory() . '/.tx/config';
$content = file_get_contents($path);
$sources = [];
foreach (preg_split('~\R~u', $content) as $line) {
if (preg_match('#source_file\s=\s(?<path>\S+)#', $line, $matches)) {
$sources[] = $matches['path'];
}
}
return $sources;
}

/**
* Directory where module files exist; Usually the one that sits just below the top level project
*
Expand All @@ -73,47 +17,6 @@ public function getMainDirectory()
return $this->getDirectory();
}

/**
* Get path of main directory (with sources, lang, etc) relative to BASE_DIR.
* This is necessary for i18nTextCollector
*
* @return string
*/
public function getRelativeMainDirectory()
{
$dir = $this->getMainDirectory();
$base = $this->getProject()->getDirectory();

// Remove base dir (plus /) from main directory
return substr($dir, strlen($base) + 1);
}

/**
* Get parameter to pass to i18n text collector
*
* @return string
*/
public function getI18nTextCollectorName()
{
$dir = $this->getRelativeMainDirectory();
// If short name has any slashes just use composer name instead
if (preg_match('#\w[\\/]\w#', $dir)) {
return $this->getName();
}
return $dir;
}
/**
* Determine if this project has a .tx configured
*
* @return bool
*/
public function isTranslatable()
{
return $this->getDirectory() && realpath($this->getDirectory() . '/.tx/config');
}


/**
* Cached link
*
Expand Down
36 changes: 0 additions & 36 deletions src/Steps/Module/BuildTranslations.php

This file was deleted.

Loading

0 comments on commit cf476b0

Please sign in to comment.