Files
twenty/packages/twenty-server/src/command/command-logger.ts
Charles Bochet 03204021cb Refactor onboarding user vars to be absent when user is fully onboarded (#6531)
In this PR:
- take feedbacks from: https://github.com/twentyhq/twenty/pull/6530 /
https://github.com/twentyhq/twenty/pull/6529 /
https://github.com/twentyhq/twenty/pull/6526 /
https://github.com/twentyhq/twenty/pull/6512
- refactor onboarding uservars to be absent when the user is fully
onboarded: isStepComplete ==> isStepIncomplete
- introduce a new workspace.activationStatus: CREATION_ONGOING

I'm retesting the whole flow:
- with/without BILLING
- sign in with/without SSO
- sign up with/without SSO
- another workspaceMembers join the team
- subscriptionCanceled
- access to billingPortal
2024-08-04 20:37:36 +02:00

54 lines
1.2 KiB
TypeScript

/* eslint-disable no-console */
import { Injectable } from '@nestjs/common';
import { existsSync } from 'fs';
import fs from 'fs/promises';
import { join as joinPath } from 'path';
import { kebabCase } from 'src/utils/kebab-case';
@Injectable()
export class CommandLogger {
constructor(private readonly className: string) {}
async createSubDirectory(subDirectory: string): Promise<void> {
const path = `./logs/${kebabCase(this.className)}/${subDirectory}`;
if (existsSync(path) === false) {
await fs.mkdir(path, { recursive: true });
}
return;
}
async writeLog(
fileName: string,
data: unknown,
append = false,
): Promise<string> {
const path = `./logs/${kebabCase(this.className)}`;
if (existsSync(path) === false) {
await fs.mkdir(path, { recursive: true });
}
try {
const logFilePath = `${path}/${fileName}.json`;
await fs.writeFile(logFilePath, JSON.stringify(data, null, 2), {
flag: append ? 'a' : 'w',
});
const absoluteLogFilePath = joinPath(process.cwd(), logFilePath);
return absoluteLogFilePath;
} catch (err) {
console.error(
`Error writing to file ${path}/${fileName}.json: ${err?.message}`,
);
throw err;
}
}
}