Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feat/password-veri…
Browse files Browse the repository at this point in the history
…fication
  • Loading branch information
hugocostadev committed Jun 16, 2023
2 parents 3077f9b + 71e82d1 commit 90c2de6
Show file tree
Hide file tree
Showing 30 changed files with 154 additions and 80 deletions.
5 changes: 5 additions & 0 deletions .changeset/dull-apples-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

regression: asciiart slashcommands breaking client
5 changes: 5 additions & 0 deletions .changeset/popular-llamas-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/release-action': patch
---

Use CI user PAT token
8 changes: 8 additions & 0 deletions .changeset/registration-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@rocket.chat/web-ui-registration": patch
---

fix: Manually approved user registration flow
The new user gets redirected to the login page with a toast message saying:

> Before you can login, your account must be manually activated by an administrator.
5 changes: 5 additions & 0 deletions .changeset/soft-rabbits-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': minor
---

Fix message composer popup bug
5 changes: 5 additions & 0 deletions .changeset/wet-cherries-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/release-action': patch
---

Update versions in configured files
7 changes: 4 additions & 3 deletions .github/workflows/new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.CI_PAT }}

- name: Setup NodeJS
uses: ./.github/actions/setup-node
Expand All @@ -48,7 +49,7 @@ jobs:
action: bump
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.CI_PAT }}

- name: Start patch release
if: ${{ github.event.inputs.name == 'patch' }}
Expand All @@ -58,7 +59,7 @@ jobs:
base-ref: ${{ github.event.inputs.base-ref }}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.CI_PAT }}

- name: Publish release
if: ${{ github.event.inputs.name == 'publish' }}
Expand All @@ -68,4 +69,4 @@ jobs:
base-ref: ${{ github.event.inputs.base-ref }}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.CI_PAT }}
4 changes: 3 additions & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
token: ${{ secrets.CI_PAT }}

- name: Setup NodeJS
uses: ./.github/actions/setup-node
Expand All @@ -36,4 +38,4 @@ jobs:
action: publish-final
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.CI_PAT }}
1 change: 1 addition & 0 deletions apps/meteor/app/slashcommand-asciiarts/client/gimme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ slashCommands.add({
options: {
description: 'Slash_Gimme_Description',
params: 'your_message_optional',
clientOnly: true,
},
});
1 change: 1 addition & 0 deletions apps/meteor/app/slashcommand-asciiarts/client/lenny.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ slashCommands.add({
options: {
description: 'Slash_LennyFace_Description',
params: 'your_message_optional',
clientOnly: true,
},
});
1 change: 1 addition & 0 deletions apps/meteor/app/slashcommand-asciiarts/client/shrug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ slashCommands.add({
options: {
description: 'Slash_Shrug_Description',
params: 'your_message_optional',
clientOnly: true,
},
});
1 change: 1 addition & 0 deletions apps/meteor/app/slashcommand-asciiarts/client/tableflip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ slashCommands.add({
options: {
description: 'Slash_Tableflip_Description',
params: 'your_message_optional',
clientOnly: true,
},
});
1 change: 1 addition & 0 deletions apps/meteor/app/slashcommand-asciiarts/client/unflip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ slashCommands.add({
options: {
description: 'Slash_TableUnflip_Description',
params: 'your_message_optional',
clientOnly: true,
},
});
1 change: 1 addition & 0 deletions apps/meteor/app/slashcommand-asciiarts/server/gimme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ slashCommands.add({
options: {
description: 'Slash_Gimme_Description',
params: 'your_message_optional',
clientOnly: true,
},
});
1 change: 1 addition & 0 deletions apps/meteor/app/slashcommand-asciiarts/server/lenny.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ slashCommands.add({
options: {
description: 'Slash_LennyFace_Description',
params: 'your_message_optional',
clientOnly: true,
},
});
1 change: 1 addition & 0 deletions apps/meteor/app/slashcommand-asciiarts/server/shrug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ slashCommands.add({
options: {
description: 'Slash_Shrug_Description',
params: 'your_message_optional',
clientOnly: true,
},
});
1 change: 1 addition & 0 deletions apps/meteor/app/slashcommand-asciiarts/server/tableflip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ slashCommands.add({
options: {
description: 'Slash_Tableflip_Description',
params: 'your_message_optional',
clientOnly: true,
},
});
1 change: 1 addition & 0 deletions apps/meteor/app/slashcommand-asciiarts/server/unflip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ slashCommands.add({
options: {
description: 'Slash_TableUnflip_Description',
params: 'your_message_optional',
clientOnly: true,
},
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ComposerPopupOption } from '../../../../../client/views/room/contexts/ComposerPopupContext';

export const useEnablePopupPreview = <T extends { _id: string; sort?: number }>(filter: unknown, popup?: ComposerPopupOption<T>) =>
popup && !popup.preview && popup?.triggerLength ? typeof filter === 'string' && popup.triggerLength - 1 < filter.length : true;
popup && !popup.preview && (popup?.triggerLength ? typeof filter === 'string' && popup.triggerLength - 1 < filter.length : true);
25 changes: 0 additions & 25 deletions apps/meteor/app/utils/lib/slashCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type {
SlashCommandPreviewItem,
SlashCommandPreviews,
} from '@rocket.chat/core-typings';
import type { ServerMethods } from '@rocket.chat/ui-contexts';

interface ISlashCommandAddParams<T extends string> {
command: string;
Expand Down Expand Up @@ -133,27 +132,3 @@ declare module '@rocket.chat/ui-contexts' {
slashCommand(params: { cmd: string; params: string; msg: IMessage; triggerId: string }): unknown;
}
}

Meteor.methods<ServerMethods>({
async slashCommand(command) {
const userId = Meteor.userId();
if (!userId) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'slashCommand',
});
}

if (!command?.cmd || !slashCommands.commands[command.cmd]) {
throw new Meteor.Error('error-invalid-command', 'Invalid Command Provided', {
method: 'executeSlashCommandPreview',
});
}
return slashCommands.run({
command: command.cmd,
params: command.params,
message: command.msg,
triggerId: command.triggerId,
userId,
});
},
});
2 changes: 1 addition & 1 deletion apps/meteor/app/utils/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export { getUserPreference } from './lib/getUserPreference';
export { fileUploadIsValidContentType } from './restrictions';
export { isDocker } from './functions/isDocker';
export { getMongoInfo } from './functions/getMongoInfo';
export { slashCommands } from '../lib/slashCommand';
export { slashCommands } from './slashCommand';
export { getUserNotificationPreference } from './getUserNotificationPreference';
export { getAvatarColor } from '../lib/getAvatarColor';
export { getURL } from './getURL';
Expand Down
31 changes: 31 additions & 0 deletions apps/meteor/app/utils/server/slashCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { ServerMethods } from '@rocket.chat/ui-contexts';
import { Meteor } from 'meteor/meteor';

import { slashCommands } from '../lib/slashCommand';

Meteor.methods<ServerMethods>({
async slashCommand(command) {
const userId = Meteor.userId();
if (!userId) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'slashCommand',
});
}

if (!command?.cmd || !slashCommands.commands[command.cmd]) {
throw new Meteor.Error('error-invalid-command', 'Invalid Command Provided', {
method: 'executeSlashCommandPreview',
});
}

return slashCommands.run({
command: command.cmd,
params: command.params,
message: command.msg,
triggerId: command.triggerId,
userId,
});
},
});

export { slashCommands };
5 changes: 4 additions & 1 deletion apps/meteor/server/services/apps-engine/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ export class AppsEngineService extends ServiceClassInternal implements IAppsEngi

// avoid updating the setting if the value is the same,
// which caused an infinite loop
if (oldSetting === setting.value) {
// and sometimes the settings can be an array
// so we need to convert it to JSON stringified to compare it

if (JSON.stringify(oldSetting) === JSON.stringify(setting.value)) {
Apps.getRocketChatLogger().info(
`"apps.settingUpdated" event received for setting ${setting.id} of app "${appId}", but the setting value is the same`,
);
Expand Down
16 changes: 9 additions & 7 deletions packages/release-action/src/bumpNextVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as github from '@actions/github';

import { setupOctokit } from './setupOctokit';
import { createNpmFile } from './createNpmFile';
import { getChangelogEntry, updateVersionPackageJson } from './utils';
import { getChangelogEntry, bumpFileVersions, readPackageJson } from './utils';
import { fixWorkspaceVersionsBeforePublish } from './fixWorkspaceVersionsBeforePublish';

export async function bumpNextVersion({
Expand All @@ -27,16 +27,16 @@ export async function bumpNextVersion({
// TODO need to check if there is any change to 'main package', if not, there is no need to enter rc
// and instead a normal release of the other packages should be done

const { version: currentVersion } = await readPackageJson(cwd);

// start release candidate
await exec('yarn', ['changeset', 'pre', 'enter', 'rc']);

// bump version of all packages to rc
await exec('yarn', ['changeset', 'version']);

// get version from main package
const mainPackageJsonPath = path.join(mainPackagePath, 'package.json');
// eslint-disable-next-line import/no-dynamic-require, @typescript-eslint/no-var-requires
const { version: newVersion } = require(mainPackageJsonPath);
const { version: newVersion } = await readPackageJson(mainPackagePath);

const mainPackageChangelog = path.join(mainPackagePath, 'CHANGELOG.md');

Expand All @@ -55,8 +55,8 @@ export async function bumpNextVersion({
const newBranch = `release-${finalVersion}`;

// update root package.json
core.info('bump main package.json version');
updateVersionPackageJson(cwd, newVersion);
core.info('update version in all files to new');
await bumpFileVersions(cwd, currentVersion, newVersion);

// TODO check if branch exists
await exec('git', ['checkout', '-b', newBranch]);
Expand All @@ -67,7 +67,9 @@ export async function bumpNextVersion({
core.info('fix dependencies in workspace packages');
await fixWorkspaceVersionsBeforePublish();

await exec('yarn', ['changeset', 'publish']);
await exec('yarn', ['changeset', 'publish', '--no-git-tag']);

await exec('git', ['tag', newVersion]);

await exec('git', ['push', '--force', '--follow-tags', 'origin', `HEAD:refs/heads/${newBranch}`]);

Expand Down
10 changes: 5 additions & 5 deletions packages/release-action/src/fixWorkspaceVersionsBeforePublish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import path from 'node:path';

import { getExecOutput } from '@actions/exec';

import { readPackageJson } from './utils';

const DEPENDENCY_TYPES = ['dependencies', 'devDependencies', 'peerDependencies'];

export async function fixWorkspaceVersionsBeforePublish() {
Expand All @@ -26,15 +28,13 @@ export async function fixWorkspaceVersionsBeforePublish() {
// Get the version of each workspace package.
const workspaceVersions = new Map();
for await (const workspace of workspaces) {
const packageJsonPath = path.join(workspace.location, 'package.json');
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));
const packageJson = await readPackageJson(workspace.location);
workspaceVersions.set(workspace.name, packageJson.version);
}

// Replace any `workspace:^` version ranges with the actual version.
for await (const workspace of workspaces) {
const packageJsonPath = path.join(workspace.location, 'package.json');
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));
const packageJson = await readPackageJson(workspace.location);

for (const dependencyType of DEPENDENCY_TYPES) {
const dependencies = Object.keys(packageJson[dependencyType] ?? {});
Expand All @@ -55,6 +55,6 @@ export async function fixWorkspaceVersionsBeforePublish() {
}
}

await fs.writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`);
await fs.writeFile(path.join(workspace.location, 'package.json'), `${JSON.stringify(packageJson, null, 2)}\n`);
}
}
6 changes: 0 additions & 6 deletions packages/release-action/src/gitUtils.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/release-action/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import path from 'path';
import * as core from '@actions/core';

import { publishRelease } from './publishRelease';
import { setupGitUser } from './gitUtils';
import { bumpNextVersion } from './bumpNextVersion';
import { startPatchRelease } from './startPatchRelease';

Expand All @@ -23,9 +22,6 @@ import { startPatchRelease } from './startPatchRelease';
// process.chdir(inputCwd);
// }

core.info('setting git user');
await setupGitUser();

core.info('setting GitHub credentials');
fs.writeFileSync(`${process.env.HOME}/.netrc`, `machine github.com\nlogin github-actions[bot]\npassword ${githubToken}`);

Expand Down
Loading

0 comments on commit 90c2de6

Please sign in to comment.