Skip to content

Commit d57c9ba

Browse files
authored
Merge pull request #164 from Libertech-FR/dependabot/npm_and_yarn/lodash-4.18.1
chore(deps): bump lodash from 4.17.23 to 4.18.1 #165 correction of cron
2 parents f3c6827 + 9698b90 commit d57c9ba

6 files changed

Lines changed: 22 additions & 11 deletions

File tree

apps/api/defaults/cron/identities-init-invitation-expire.yml renamed to apps/api/defaults/cron/identities-init-expire.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
tasks:
2-
- name: "identities-init-invitation-expire"
2+
- name: "identities-init-expire"
33
description: "Expiration des invitations d'initialisation de compte"
44
enabled: true
55
schedule: "1 * * * *" # Tous les jours à 08:00
6-
handler: "identities-init-invitation-expire"
6+
handler: "identities-init-expire"
77
options:

apps/api/src/core/cron/_functions/cron-command-options.function.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ function getHandlerDescriptor(handler: string) {
88
return getCronConsoleHandlers().find((entry) => entry.handler === handler);
99
}
1010

11+
/**
12+
* Mots de la commande console d'un handler : utilise `command` déclaré via @CronConsoleHandler,
13+
* sinon (handler non déclaré) découpe l'identifiant sur les tirets.
14+
*/
15+
export function resolveCronConsoleCommandWords(handler: string): string[] {
16+
const descriptor = getHandlerDescriptor(handler);
17+
return (descriptor?.command || handler.replace(/-/g, ' ')).split(/\s+/).filter(Boolean);
18+
}
19+
1120
export function resolveCronConsoleArgumentFlag(argument: CronConsoleHandlerArgument): string {
1221
return argument.flag || `--${argument.name}`;
1322
}

apps/api/src/core/cron/cron-hooks.service.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { loadcronTasks } from './_functions/load-cron-tasks.function';
99
import { ConfigService } from '@nestjs/config';
1010
import { createHandlerLogger } from '~/_common/functions/handler-logger';
1111
import { resolveConfigVariables } from '~/_common/functions/resolve-config-variables.function';
12-
import { buildCronCommandArgs } from './_functions/cron-command-options.function';
12+
import { buildCronCommandArgs, resolveCronConsoleCommandWords } from './_functions/cron-command-options.function';
1313

1414
@Injectable()
1515
export class CronHooksService {
@@ -177,7 +177,9 @@ export class CronHooksService {
177177
}
178178

179179
// Supprimer les jobs qui ne sont plus dans les tâches désirées
180-
for (const [name, job] of existingJobs) {
180+
// Itère sur une copie : getCronJobs() renvoie la Map interne du registre, et un delete + add
181+
// sur la même clé la replace en fin de Map, ce qui la ferait revisiter indéfiniment.
182+
for (const [name, job] of Array.from(existingJobs)) {
181183
if (!name.startsWith('cron-task-')) continue;
182184

183185
const desired = desiredTasks.get(name);
@@ -301,7 +303,7 @@ export class CronHooksService {
301303
const { positionalArgs, flagArgs } = buildCronCommandArgs(handler, resolvedOptions);
302304

303305
const cmd = 'yarn';
304-
const cmdArgs = ['run', 'console', ...handler.split('-'), ...positionalArgs, ...flagArgs];
306+
const cmdArgs = ['run', 'console', ...resolveCronConsoleCommandWords(handler), ...positionalArgs, ...flagArgs];
305307

306308
const handlerLogger = createHandlerLogger(this.configService, name);
307309
this.logger.log(`Spawning command: ${cmd} ${cmdArgs.join(' ')}`);

apps/api/src/management/identities/identities.command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ type IdentitiesInitExpireOptions = {
331331
};
332332

333333
@CronConsoleHandler({
334-
handler: 'identities-init-invitation-expire',
334+
handler: 'identities-init-expire',
335335
command: 'identities init expire',
336336
label: "Expiration des invitations d'initialisation de compte",
337337
arguments: [

apps/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"fast-password-entropy": "^1.1.1",
4747
"hibp": "^15.0.1",
4848
"highlight.js": "^11.11.1",
49-
"lodash": "^4.17.23",
49+
"lodash": "^4.18.1",
5050
"lodash-es": "^4.17.23",
5151
"moment": "^2.30.1",
5252
"monaco-editor": "^0.53.0",

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13036,10 +13036,10 @@ lodash@4.17.21:
1303613036
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
1303713037
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
1303813038

13039-
lodash@^4.17.15, lodash@^4.17.21, lodash@^4.17.23:
13040-
version "4.17.23"
13041-
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.23.tgz#f113b0378386103be4f6893388c73d0bde7f2c5a"
13042-
integrity sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==
13039+
lodash@^4.17.15, lodash@^4.17.21, lodash@^4.18.1:
13040+
version "4.18.1"
13041+
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.18.1.tgz#ff2b66c1f6326d59513de2407bf881439812771c"
13042+
integrity sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==
1304313043

1304413044
log-symbols@^4.1.0:
1304513045
version "4.1.0"

0 commit comments

Comments
 (0)