feat: polish release v2 experience (#6800)
This commit is contained in:
1 parent
925b0fb801
commit
a4a903d7c3
295 files changed
+10627
-7115
No files matched your search
@@ -9,8 +9,7 @@ export const fixUsernames = command({
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
handler: async () => {
|
||||
if (!process.env.AUTH_PROVIDERS?.toLowerCase().includes("credentials")) {
|
||||
console.error("Credentials provider is not enabled");
|
||||
return;
|
||||
throw new Error("Credentials provider is not enabled");
|
||||
}
|
||||
|
||||
const credentialUsers = await db.query.users.findMany({
|
||||
|
||||
@@ -13,8 +13,11 @@ export const integrationsDelete = command({
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
handler: async (options) => {
|
||||
if (!options.id && !options.name) {
|
||||
console.error("Either --id or --name must be provided");
|
||||
return;
|
||||
throw new Error("Either --id or --name must be provided");
|
||||
}
|
||||
|
||||
if (options.id && options.name) {
|
||||
throw new Error("Use either --id or --name, not both");
|
||||
}
|
||||
|
||||
let entry;
|
||||
@@ -29,8 +32,7 @@ export const integrationsDelete = command({
|
||||
}
|
||||
|
||||
if (!entry) {
|
||||
console.error("Integration not found");
|
||||
return;
|
||||
throw new Error("Integration not found");
|
||||
}
|
||||
|
||||
await db.delete(integrations).where(eq(integrations.id, entry.id));
|
||||
|
||||
@@ -17,16 +17,14 @@ export const recreateAdmin = command({
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
handler: async (options) => {
|
||||
if (!process.env.AUTH_PROVIDERS?.toLowerCase().includes("credentials")) {
|
||||
console.error("Credentials provider is not enabled");
|
||||
return;
|
||||
throw new Error("Credentials provider is not enabled");
|
||||
}
|
||||
|
||||
const result = await usernameSchema.safeParseAsync(options.username);
|
||||
|
||||
if (!result.success) {
|
||||
console.error("Invalid username:");
|
||||
console.error(result.error.issues.map((error) => `- ${error.message}`).join("\n"));
|
||||
return;
|
||||
const issues = result.error.issues.map((error) => `- ${error.message}`).join("\n");
|
||||
throw new Error(`Invalid username:\n${issues}`);
|
||||
}
|
||||
|
||||
const totalCount = await db
|
||||
@@ -40,8 +38,7 @@ export const recreateAdmin = command({
|
||||
.then((rows) => rows.at(0)?.count ?? 0);
|
||||
|
||||
if (totalCount > 0) {
|
||||
console.error("Credentials admin user exists");
|
||||
return;
|
||||
throw new Error("Credentials admin user exists");
|
||||
}
|
||||
|
||||
const existingUser = await db.query.users.findFirst({
|
||||
@@ -49,8 +46,7 @@ export const recreateAdmin = command({
|
||||
});
|
||||
|
||||
if (existingUser) {
|
||||
console.error("User with this name already exists");
|
||||
return;
|
||||
throw new Error("User with this name already exists");
|
||||
}
|
||||
|
||||
const temporaryGroupId = createId();
|
||||
|
||||
@@ -14,8 +14,7 @@ export const resetPassword = command({
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
handler: async (options) => {
|
||||
if (!process.env.AUTH_PROVIDERS?.toLowerCase().includes("credentials")) {
|
||||
console.error("Credentials provider is not enabled");
|
||||
return;
|
||||
throw new Error("Credentials provider is not enabled");
|
||||
}
|
||||
|
||||
const user = await db.query.users.findFirst({
|
||||
@@ -23,8 +22,7 @@ export const resetPassword = command({
|
||||
});
|
||||
|
||||
if (!user?.password) {
|
||||
console.error(`User ${options.username} not found`);
|
||||
return;
|
||||
throw new Error(`User ${options.username} not found`);
|
||||
}
|
||||
|
||||
// Generates a new password with 48 characters
|
||||
|
||||
@@ -13,8 +13,11 @@ export const usersDelete = command({
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
handler: async (options) => {
|
||||
if (!options.id && !options.username) {
|
||||
console.error("Either --id or --username must be provided");
|
||||
return;
|
||||
throw new Error("Either --id or --username must be provided");
|
||||
}
|
||||
|
||||
if (options.id && options.username) {
|
||||
throw new Error("Use either --id or --username, not both");
|
||||
}
|
||||
|
||||
let user;
|
||||
@@ -29,8 +32,7 @@ export const usersDelete = command({
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
console.error("User not found");
|
||||
return;
|
||||
throw new Error("User not found");
|
||||
}
|
||||
|
||||
await db.delete(users).where(eq(users.id, user.id));
|
||||
|
||||
@@ -15,13 +15,15 @@ export const usersUpdatePassword = command({
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
handler: async (options) => {
|
||||
if (!process.env.AUTH_PROVIDERS?.toLowerCase().includes("credentials")) {
|
||||
console.error("Credentials provider is not enabled");
|
||||
return;
|
||||
throw new Error("Credentials provider is not enabled");
|
||||
}
|
||||
|
||||
if (!options.id && !options.username) {
|
||||
console.error("Either --id or --username must be provided");
|
||||
return;
|
||||
throw new Error("Either --id or --username must be provided");
|
||||
}
|
||||
|
||||
if (options.id && options.username) {
|
||||
throw new Error("Use either --id or --username, not both");
|
||||
}
|
||||
|
||||
const user = await db.query.users.findFirst({
|
||||
@@ -30,8 +32,7 @@ export const usersUpdatePassword = command({
|
||||
});
|
||||
|
||||
if (!user?.password) {
|
||||
console.error("User not found or has no credentials record");
|
||||
return;
|
||||
throw new Error("User not found or has no credentials record");
|
||||
}
|
||||
|
||||
await db
|
||||
|
||||
Reference in new issue
Block a user