Skip to content

Commit 8e639d1

Browse files
committed
fix(cli): Pull and update project available services, auth security settings, and login methods.
1 parent f0be8ee commit 8e639d1

File tree

3 files changed

+110
-4
lines changed

3 files changed

+110
-4
lines changed

templates/cli/lib/commands/pull.js.twig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const pullProject = async () => {
2222
})
2323

2424
localConfig.setProject(response.$id, response.name);
25+
localConfig.setProjectSettings(response);
26+
2527
success();
2628
} catch (e) {
2729
throw e;

templates/cli/lib/commands/push.js.twig

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,17 @@ const {
4141
teamsUpdateName,
4242
teamsCreate
4343
} = require("./teams");
44-
const { projectsUpdate } = require("./projects");
44+
const {
45+
projectsUpdate,
46+
projectsUpdateServiceStatus,
47+
projectsUpdateAuthStatus,
48+
projectsUpdateAuthDuration,
49+
projectsUpdateAuthLimit,
50+
projectsUpdateAuthSessionsLimit,
51+
projectsUpdateAuthPasswordDictionary,
52+
projectsUpdateAuthPasswordHistory,
53+
projectsUpdatePersonalDataCheck,
54+
} = require("./projects");
4555
const { checkDeployConditions } = require('../utils');
4656

4757
const STEP_SIZE = 100; // Resources
@@ -258,11 +268,56 @@ const pushResources = async ({ all, yes } = {}) => {
258268

259269
const pushProject = async () => {
260270
try {
271+
const projectId = localConfig.getProject().projectId;
272+
const projectName = localConfig.getProject().projectName;
273+
274+
log('Updating project name');
275+
261276
await projectsUpdate({
262-
projectId: localConfig.getProject().projectId,
263-
name: localConfig.getProject().projectName,
277+
projectId,
278+
name: projectName,
264279
parseOutput: false
265-
})
280+
});
281+
282+
const settings = localConfig.getProjectSettings();
283+
284+
if (settings.services) {
285+
log('Updating services status');
286+
for (let [service, status] of Object.entries(settings.services)) {
287+
await projectsUpdateServiceStatus({
288+
projectId,
289+
service,
290+
status,
291+
parseOutput: false
292+
});
293+
}
294+
}
295+
296+
if (settings.auth) {
297+
if (settings.auth.security) {
298+
log('Updating Auth security settings');
299+
await projectsUpdateAuthDuration({ projectId, duration: settings.auth.security.duration, parseOutput: false });
300+
await projectsUpdateAuthLimit({ projectId, limit: settings.auth.security.limit, parseOutput: false });
301+
await projectsUpdateAuthSessionsLimit({ projectId, limit: settings.auth.security.sessionsLimit, parseOutput: false });
302+
await projectsUpdateAuthPasswordDictionary({ projectId, enabled: settings.auth.security.passwordDictionary, parseOutput: false });
303+
await projectsUpdateAuthPasswordHistory({ projectId, limit: settings.auth.security.passwordHistory, parseOutput: false });
304+
await projectsUpdatePersonalDataCheck({ projectId, enabled: settings.auth.security.personalDataCheck, parseOutput: false });
305+
}
306+
307+
if (settings.auth.methods) {
308+
log('Updating Auth available login methods');
309+
310+
for (let [method, status] of Object.entries(settings.auth.methods)) {
311+
await projectsUpdateAuthStatus({
312+
projectId,
313+
method,
314+
status,
315+
parseOutput: false
316+
});
317+
}
318+
}
319+
}
320+
266321
success();
267322
} catch (e) {
268323
throw e;

templates/cli/lib/config.js.twig

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,55 @@ class Local extends Config {
336336
this.set("projectId", projectId);
337337
this.set("projectName", projectName);
338338
}
339+
340+
341+
getProjectSettings() {
342+
if (!this.has("projectSettings")) {
343+
return {};
344+
}
345+
346+
return this.get('projectSettings')
347+
}
348+
349+
setProjectSettings(project) {
350+
const settings = {
351+
services: {
352+
account: project.serviceStatusForAccount,
353+
avatars: project.serviceStatusForAvatars,
354+
databases: project.serviceStatusForDatabases,
355+
locale: project.serviceStatusForLocale,
356+
health: project.serviceStatusForHealth,
357+
storage: project.serviceStatusForStorage,
358+
teams: project.serviceStatusForTeams,
359+
users: project.serviceStatusForUsers,
360+
functions: project.serviceStatusForFunctions,
361+
graphql: project.serviceStatusForGraphql,
362+
messaging: project.serviceStatusForMessaging,
363+
364+
},
365+
auth: {
366+
methods: {
367+
jwt: project.authJWT,
368+
phone: project.authPhone,
369+
invites: project.authInvites,
370+
anonymous: project.authAnonymous,
371+
"email-otp": project.authEmailOtp,
372+
"magic-url": project.authUsersAuthMagicURL,
373+
"email-password": project.authEmailPassword
374+
},
375+
security: {
376+
duration: project.authDuration,
377+
limit: project.authLimit,
378+
sessionsLimit: project.authSessionsLimit,
379+
passwordHistory: project.authPasswordHistory,
380+
passwordDictionary: project.authPasswordDictionary,
381+
personalDataCheck: project.authPersonalDataCheck
382+
}
383+
}
384+
};
385+
386+
this.set('projectSettings', settings)
387+
}
339388
}
340389

341390
class Global extends Config {

0 commit comments

Comments
 (0)