@codegouvfr/sill
Advanced tools
Comparing version 1.16.4 to 1.16.6
@@ -53,3 +53,2 @@ "use strict"; | ||
console.log("Performing cache initialization..."); | ||
core.dispatch(usecases_1.usecases.readWriteSillData.protectedThunks.cacheInitialization()); | ||
await Promise.all([initializeDbApiCache(), initializeUserApiCache()]); | ||
@@ -56,0 +55,0 @@ } |
@@ -194,53 +194,2 @@ import type { PayloadAction } from "@reduxjs/toolkit"; | ||
}) => Promise<void>; | ||
cacheInitialization: () => (dispatch: import("@reduxjs/toolkit").ThunkDispatch<{ | ||
readWriteSillData: State; | ||
}, { | ||
createStoreParams: { | ||
gitDbApiParams: import("../adapters/dbApi").GitDbApiParams; | ||
keycloakUserApiParams: import("../adapters/userApi").KeycloakUserApiParams | undefined; | ||
githubPersonalAccessTokenForApiRateLimit: string; | ||
doPerPerformPeriodicalCompilation: boolean; | ||
doPerformCacheInitialization: boolean; | ||
}; | ||
dbApi: import("../ports/DbApi").DbApi; | ||
userApi: import("../ports/UserApi").UserApi; | ||
compileData: import("../ports/CompileData").CompileData; | ||
getWikidataSoftwareOptions: import("../ports/GetWikidataSoftwareOptions").GetWikidataSoftwareOptions; | ||
comptoirDuLibreApi: import("../ports/GetComptoirDuLibre").ComptoirDuLibreApi; | ||
getWikidataSoftware: import("../ports/GetWikidataSoftware").GetWikidataSoftware; | ||
getSoftwareLatestVersion: import("../ports/GetSoftwareLatestVersion").GetSoftwareLatestVersion; | ||
} & { | ||
evtAction: import("evt").NonPostableEvt<{ | ||
sliceName: "readWriteSillData"; | ||
} & { | ||
actionName: "updated"; | ||
} & { | ||
payload: State; | ||
}>; | ||
}, import("redux").Action<string>>, getState: () => { | ||
readWriteSillData: State; | ||
}, extraArgument: { | ||
createStoreParams: { | ||
gitDbApiParams: import("../adapters/dbApi").GitDbApiParams; | ||
keycloakUserApiParams: import("../adapters/userApi").KeycloakUserApiParams | undefined; | ||
githubPersonalAccessTokenForApiRateLimit: string; | ||
doPerPerformPeriodicalCompilation: boolean; | ||
doPerformCacheInitialization: boolean; | ||
}; | ||
dbApi: import("../ports/DbApi").DbApi; | ||
userApi: import("../ports/UserApi").UserApi; | ||
compileData: import("../ports/CompileData").CompileData; | ||
getWikidataSoftwareOptions: import("../ports/GetWikidataSoftwareOptions").GetWikidataSoftwareOptions; | ||
comptoirDuLibreApi: import("../ports/GetComptoirDuLibre").ComptoirDuLibreApi; | ||
getWikidataSoftware: import("../ports/GetWikidataSoftware").GetWikidataSoftware; | ||
getSoftwareLatestVersion: import("../ports/GetSoftwareLatestVersion").GetSoftwareLatestVersion; | ||
} & { | ||
evtAction: import("evt").NonPostableEvt<{ | ||
sliceName: "readWriteSillData"; | ||
} & { | ||
actionName: "updated"; | ||
} & { | ||
payload: State; | ||
}>; | ||
}) => void; | ||
}; | ||
@@ -247,0 +196,0 @@ export declare const thunks: { |
@@ -36,4 +36,4 @@ "use strict"; | ||
const { doPerPerformPeriodicalCompilation } = params; | ||
const [dispatch, , extraArg] = args; | ||
const { dbApi } = extraArg; | ||
const [dispatch, getState, extraArg] = args; | ||
const { dbApi, evtAction } = extraArg; | ||
const [db, compiledData] = await Promise.all([dbApi.fetchDb(), dbApi.fetchCompiledData()]); | ||
@@ -61,9 +61,10 @@ dispatch(exports.actions.updated({ | ||
} | ||
}, | ||
"cacheInitialization": () => (...args) => { | ||
const [, getState] = args; | ||
const start = Date.now(); | ||
console.log("Starting cache refresh of readWriteSillData selectors"); | ||
(0, objectKeys_1.objectKeys)(exports.selectors).forEach(selectorName => exports.selectors[selectorName](getState())); | ||
console.log(`Cache refresh of readWriteSillData selectors done in ${Date.now() - start}ms`); | ||
evtAction.attach(action => action.sliceName === exports.name && action.actionName === "updated", () => { | ||
setTimeout(() => { | ||
const start = Date.now(); | ||
console.log("Starting cache refresh of readWriteSillData selectors"); | ||
(0, objectKeys_1.objectKeys)(exports.selectors).forEach(selectorName => exports.selectors[selectorName](getState())); | ||
console.log(`Cache refresh of readWriteSillData selectors done in ${Date.now() - start}ms`); | ||
}, 500); | ||
}); | ||
} | ||
@@ -497,3 +498,2 @@ }; | ||
}); | ||
setTimeout(() => dispatch(exports.protectedThunks.cacheInitialization()), 500); | ||
}, | ||
@@ -500,0 +500,0 @@ "triggerNonIncrementalCompilation": (params) => async (...args) => { |
{ | ||
"name": "@codegouvfr/sill", | ||
"version": "1.16.4", | ||
"version": "1.16.6", | ||
"description": "The backend of etalab.gouv.fr/sill", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -79,4 +79,2 @@ import type { ReturnType } from "tsafe"; | ||
core.dispatch(usecases.readWriteSillData.protectedThunks.cacheInitialization()); | ||
await Promise.all([initializeDbApiCache(), initializeUserApiCache()]); | ||
@@ -83,0 +81,0 @@ } |
@@ -189,5 +189,5 @@ import structuredClone from "@ungap/structured-clone"; | ||
const [dispatch, , extraArg] = args; | ||
const [dispatch, getState, extraArg] = args; | ||
const { dbApi } = extraArg; | ||
const { dbApi, evtAction } = extraArg; | ||
@@ -224,15 +224,17 @@ const [db, compiledData] = await Promise.all([dbApi.fetchDb(), dbApi.fetchCompiledData()]); | ||
} | ||
}, | ||
"cacheInitialization": | ||
() => | ||
(...args) => { | ||
const [, getState] = args; | ||
const start = Date.now(); | ||
evtAction.attach( | ||
action => action.sliceName === name && action.actionName === "updated", | ||
() => { | ||
setTimeout(() => { | ||
const start = Date.now(); | ||
console.log("Starting cache refresh of readWriteSillData selectors"); | ||
console.log("Starting cache refresh of readWriteSillData selectors"); | ||
objectKeys(selectors).forEach(selectorName => selectors[selectorName](getState())); | ||
objectKeys(selectors).forEach(selectorName => selectors[selectorName](getState())); | ||
console.log(`Cache refresh of readWriteSillData selectors done in ${Date.now() - start}ms`); | ||
console.log(`Cache refresh of readWriteSillData selectors done in ${Date.now() - start}ms`); | ||
}, 500); | ||
} | ||
); | ||
} | ||
@@ -929,4 +931,2 @@ } satisfies Thunks; | ||
}); | ||
setTimeout(() => dispatch(protectedThunks.cacheInitialization()), 500); | ||
}, | ||
@@ -933,0 +933,0 @@ "triggerNonIncrementalCompilation": |
@@ -48,3 +48,3 @@ import { exec } from "./exec"; | ||
return mutex.runExclusive(async () => { | ||
return mutex.runExclusive(async function callee() { | ||
await configureOpenSshClient({ sshPrivateKeyName, sshPrivateKey }); | ||
@@ -78,3 +78,14 @@ | ||
console.log("Performing git pull"); | ||
await exec(`git pull`, { "cwd": repoPath }); | ||
try { | ||
await exec(`git pull`, { "cwd": repoPath }); | ||
} catch { | ||
console.log("There's been a force push, so we're going to re-clone the repo"); | ||
await fs.promises.rm(repoPath, { "recursive": true, "force": true }); | ||
await callee(); | ||
return; | ||
} | ||
} | ||
@@ -81,0 +92,0 @@ |
@@ -52,3 +52,3 @@ "use strict"; | ||
const mutex = ((_a = mutexes[_b = sshUrl + (shaish || "")]) !== null && _a !== void 0 ? _a : (mutexes[_b] = new async_mutex_1.Mutex())); | ||
return mutex.runExclusive(async () => { | ||
return mutex.runExclusive(async function callee() { | ||
await configureOpenSshClient({ sshPrivateKeyName, sshPrivateKey }); | ||
@@ -82,3 +82,11 @@ const repoHash = crypto_1.default | ||
console.log("Performing git pull"); | ||
await (0, exec_1.exec)(`git pull`, { "cwd": repoPath }); | ||
try { | ||
await (0, exec_1.exec)(`git pull`, { "cwd": repoPath }); | ||
} | ||
catch { | ||
console.log("There's been a force push, so we're going to re-clone the repo"); | ||
await fs.promises.rm(repoPath, { "recursive": true, "force": true }); | ||
await callee(); | ||
return; | ||
} | ||
} | ||
@@ -85,0 +93,0 @@ const changesResult = await action({ repoPath }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
714571
13057