Skip to content

Commit 3f4cd9a

Browse files
committed
Merge remote-tracking branch 'origin/feature/FOUR-22569' into feature/FOUR-22569_deploy
2 parents c19a17e + 2f95f28 commit 3f4cd9a

111 files changed

Lines changed: 5007 additions & 644 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/deploy-pm4.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ on:
99
jobs:
1010
run:
1111
name: Run PM4-workflow
12-
uses: processmaker/.github/.github/workflows/deploy-pm4.yml@main
12+
uses: processmaker/.github/.github/workflows/deploy-pm4.yml@multitenancy
1313
secrets: inherit

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/public/css
66
/storage/*.key
77
/storage/*.index
8+
/storage/tenant_*
89
/vendor
910
/.idea
1011
/.vscode
@@ -44,5 +45,9 @@ coverage
4445
resources/lang/de
4546
resources/lang/es
4647
resources/lang/fr
48+
resources/sass/tenant_*
49+
resources/sass/_variables_bk.scss
4750
devhub/pm-font/dist
48-
test-db-snapshot.db
51+
test-db-snapshot.db
52+
snapshot_*.db
53+
storage/transitions

ProcessMaker/Application.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,14 @@ public function path($path = '')
7777
{
7878
return $this->basePath . DIRECTORY_SEPARATOR . 'ProcessMaker' . ($path ? DIRECTORY_SEPARATOR . $path : $path);
7979
}
80+
81+
public function setStoragePath($path)
82+
{
83+
$this->storagePath = $path;
84+
}
85+
86+
public function getStoragePath()
87+
{
88+
return $this->storagePath;
89+
}
8090
}

ProcessMaker/Cache/Monitoring/PrometheusMetricsManager.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Support\Facades\Redis;
66
use ProcessMaker\Facades\Metrics;
7+
use ProcessMaker\Services\MetricsService;
78
use Prometheus\CollectorRegistry;
89

910
class PrometheusMetricsManager implements CacheMetricsInterface
@@ -25,7 +26,7 @@ class PrometheusMetricsManager implements CacheMetricsInterface
2526
*/
2627
public function __construct(string $namespace = 'cache')
2728
{
28-
$this->metrics = Metrics::getFacadeRoot();
29+
$this->metrics = app(MetricsService::class);
2930
$this->namespace = $namespace;
3031
}
3132

ProcessMaker/Console/Commands/CreatePackageTranslationsBackup.php

Lines changed: 0 additions & 56 deletions
This file was deleted.

ProcessMaker/Console/Commands/GenerateSdk.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct()
4040
*/
4141
public function handle()
4242
{
43-
$jsonPath = base_path('storage/api-docs/api-docs.json');
43+
$jsonPath = storage_path('api-docs/api-docs.json');
4444
$builder = new BuildSdk($jsonPath, $this->argument('output'));
4545

4646
$userId = $this->options()['user-id'];

ProcessMaker/Console/Commands/ProcessMakerLicenseRemove.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ class ProcessMakerLicenseRemove extends Command
3434
*/
3535
public function handle()
3636
{
37-
if (Storage::disk('local')->exists('license.json')) {
37+
if (Storage::disk('root')->exists('license.json')) {
3838
if ($this->option('force') || $this->confirm('Are you sure you want to remove the license.json file?')) {
39-
Storage::disk('local')->delete('license.json');
39+
Storage::disk('root')->delete('license.json');
4040
$this->info('license.json removed successfully!');
4141

4242
$this->info('Calling package:discover to update the package cache with enabled packages');

ProcessMaker/Console/Commands/ProcessMakerLicenseUpdate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function handle()
4040
return 1;
4141
}
4242

43-
Storage::disk('local')->put('license.json', $content);
43+
Storage::disk('root')->put('license.json', $content);
4444

4545
$this->info('Calling package:discover to update the package cache with enabled packages');
4646
Artisan::call('package:discover');

ProcessMaker/Console/Commands/RegenerateCss.php

Lines changed: 2 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Support\Facades\File;
88
use Illuminate\Support\Facades\Log;
99
use ProcessMaker\Jobs\CompileSass;
10+
use ProcessMaker\Jobs\CompileUI;
1011
use ProcessMaker\Models\Setting;
1112
use ProcessMaker\PackageChecker;
1213

@@ -44,75 +45,7 @@ public function __construct()
4445
public function handle()
4546
{
4647
$this->info("\nStarting CSS compiling...");
47-
48-
$setting = Setting::byKey('css-override');
49-
50-
if ($setting) {
51-
$this->writeColors(json_decode($setting->attributesToArray()['config']['variables'], true));
52-
$this->writeFonts(json_decode($setting->attributesToArray()['config']['sansSerifFont']));
53-
}
54-
55-
// Compile the Sass files
56-
CompileSass::dispatch([
57-
'tag' => 'sidebar',
58-
'origin' => 'resources/sass/sidebar/sidebar.scss',
59-
'target' => 'public/css/sidebar.css',
60-
'user' => null,
61-
]);
62-
63-
CompileSass::dispatch([
64-
'tag' => 'app',
65-
'origin' => 'resources/sass/app.scss',
66-
'target' => 'public/css/app.css',
67-
'user' => null,
68-
]);
69-
70-
CompileSass::dispatch([
71-
'tag' => 'queues',
72-
'origin' => 'resources/sass/admin/queues.scss',
73-
'target' => 'public/css/admin/queues.css',
74-
'user' => null,
75-
]);
76-
48+
(new CompileUI())->handle();
7749
$this->info("\nCSS files have been generated.");
7850
}
79-
80-
/**
81-
* Write variables in file
82-
*
83-
* @param $request
84-
*/
85-
private function writeColors($data)
86-
{
87-
// Now generate the _colors.scss file
88-
$contents = "// Changed theme colors\n";
89-
foreach ($data as $key => $value) {
90-
$contents .= $value['id'] . ': ' . $value['value'] . ";\n";
91-
}
92-
File::put(app()->resourcePath('sass') . '/_colors.scss', $contents);
93-
}
94-
95-
/**
96-
* Write variables font in file
97-
*
98-
* @param $sansSerif
99-
* @param $serif
100-
*/
101-
private function writeFonts($sansSerif)
102-
{
103-
$sansSerif = $sansSerif ? $sansSerif : $this->sansSerifFontDefault();
104-
// Generate the _fonts.scss file
105-
$contents = "// Changed theme fonts\n";
106-
$contents .= '$font-family-sans-serif: ' . $sansSerif->id . " !default;\n";
107-
File::put(app()->resourcePath('sass') . '/_fonts.scss', $contents);
108-
}
109-
110-
private function sansSerifFontDefault()
111-
{
112-
$data = new \stdClass();
113-
$data->id = "'Open Sans'";
114-
$data->title = "'Open Sans'";
115-
116-
return $data;
117-
}
11851
}
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
<?php
2+
3+
namespace ProcessMaker\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use Illuminate\Support\Arr;
7+
use Illuminate\Support\Facades\App;
8+
use Illuminate\Support\Facades\File;
9+
use ProcessMaker\Managers\PackageManager;
10+
11+
class SyncPackageTranslations extends Command
12+
{
13+
/**
14+
* The name and signature of the console command.
15+
*
16+
* @var string
17+
*/
18+
protected $signature = 'processmaker:sync-package-translations';
19+
20+
/**
21+
* The console command description.
22+
*
23+
* @var string
24+
*/
25+
protected $description = 'Synchronize custom translations of packages to CORE';
26+
27+
/**
28+
* Execute the console command.
29+
*
30+
* @return int
31+
*/
32+
public function handle()
33+
{
34+
$this->info('Synchronize translations of packages to CORE');
35+
// get All packages installed
36+
$packages = App::make(PackageManager::class)->getJsonTranslationsRegistered();
37+
// review all packages by translations
38+
foreach ($packages as $pathLangPackage) {
39+
$package = explode('/src/', $pathLangPackage);
40+
$package = explode('/', $package[0]);
41+
42+
// verify if exists folder lang.orig
43+
$langOrig = $pathLangPackage . '/../lang.orig';
44+
if ($this->fileExists($langOrig)) {
45+
// get all files type json of langOrig
46+
$files = File::files($langOrig);
47+
foreach ($files as $file) {
48+
// get name of file
49+
$nameFile = basename($file);
50+
51+
if ($this->fileExists($pathLangPackage . '/' . $nameFile)) {
52+
try {
53+
$origTranslations = $this->parseFile($file);
54+
$langTranslations = $this->parseFile($pathLangPackage . '/' . $nameFile);
55+
} catch (\Exception $e) {
56+
$this->error('Error parse file: ' . $e->getMessage());
57+
continue;
58+
}
59+
60+
$diff = $langTranslations->diff($origTranslations);
61+
62+
if ($this->fileExists(lang_path() . '/' . $nameFile) && $diff->isNotEmpty()) {
63+
$targetLang = $this->parseFile(lang_path() . '/' . $nameFile);
64+
65+
// Add new keys to targetLang
66+
foreach ($diff as $key => $value) {
67+
$targetLang[$key] = $value;
68+
}
69+
70+
try {
71+
$contents = $this->generateFile($targetLang, 'json');
72+
73+
// Validate content before saving
74+
if (empty($contents)) {
75+
throw new \Exception('Generated content is empty');
76+
}
77+
78+
// Use atomic file writing
79+
$tempFile = lang_path() . '/' . $nameFile . '.tmp';
80+
if (file_put_contents($tempFile, $contents) === false) {
81+
throw new \Exception('Failed to write temporary file');
82+
}
83+
84+
if (!rename($tempFile, lang_path() . '/' . $nameFile)) {
85+
unlink($tempFile);
86+
throw new \Exception('Failed to move temporary file');
87+
}
88+
} catch (\Exception $e) {
89+
continue;
90+
}
91+
}
92+
}
93+
}
94+
}
95+
}
96+
}
97+
98+
private function fileExists($path)
99+
{
100+
return File::exists($path);
101+
}
102+
103+
private function parseFile($path)
104+
{
105+
$pathInfo = pathinfo($path);
106+
107+
$lines = [];
108+
109+
try {
110+
if ($pathInfo['extension'] === 'json') {
111+
$lines = json_decode(file_get_contents($path), true);
112+
} elseif ($pathInfo['extension'] === 'php') {
113+
$lines = include $path;
114+
}
115+
} catch (\Exception $e) {
116+
$lines = [];
117+
}
118+
119+
$lines = Arr::dot($lines);
120+
121+
return collect($lines);
122+
}
123+
124+
private function generateFile($lines, $type)
125+
{
126+
$array = [];
127+
128+
foreach ($lines as $key => $line) {
129+
$array[$key] = $line;
130+
}
131+
132+
if ($type === 'json') {
133+
return json_encode($array, JSON_PRETTY_PRINT);
134+
} elseif ($type === 'php') {
135+
$contents = "<?php\n\nreturn [\n\n";
136+
foreach ($array as $key => $value) {
137+
$key = addslashes($key);
138+
$value = addslashes($value);
139+
$contents .= "\t'$key' => '$value',\n";
140+
}
141+
$contents .= '];';
142+
143+
return $contents;
144+
}
145+
}
146+
}

0 commit comments

Comments
 (0)