Repository: TheOdinProject/odin-bot-v2
Pull request #444 (2023-10-02 07:40:44)

Bump prettier from 3.0.2 to 3.0.3
Bumps [prettier](https://github.com/prettier/prettier) from 3.0.2 to 3.0.3.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/prettier/prettier/releases">prettier's releases</a>.</em></p>
<blockquote>
<h2>3.0.3</h2>
<p>🔗 <a href="https://github.com/prettier/prettier/blob/main/CHANGELOG.md#303">Changelog</a></p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/prettier/prettier/blob/main/CHANGELOG.md">prettier's changelog</a>.</em></p>
<blockquote>
<h1>3.0.3</h1>
<p><a href="https://github.com/prettier/prettier/compare/3.0.2...3.0.3">diff</a></p>
<h4>Add <code>preferUnplugged: true</code> to <code>package.json</code> (<a href="https://redirect.github.com/prettier/prettier/pull/15169">#15169</a> by <a href="https://github.com/fisker"><code>@​fisker</code></a> and <a href="https://github.com/so1ve"><code>@​so1ve</code></a>)</h4>
<p>Prettier v3 uses dynamic imports, user <a href="https://redirect.github.com/yarnpkg/berry/pull/5411#issuecomment-1523502224">will need to unplug Prettier</a> when Yarn's PnP mode is enabled, add <a href="https://yarnpkg.com/configuration/manifest#preferUnplugged"><code>preferUnplugged: true</code></a> to <code>package.json</code>, so Yarn will install Prettier as unplug by default.</p>
<h4>Support shared config that forbids <code>require()</code> (<a href="https://redirect.github.com/prettier/prettier/pull/15233">#15233</a> by <a href="https://github.com/fisker"><code>@​fisker</code></a>)</h4>
<p>If an external shared config package is used, and the package <code>exports</code> don't have <code>require</code> or <code>default</code> export.</p>
<p>In Prettier 3.0.2 Prettier fails when attempt to <code>require()</code> the package, and throws an error.</p>
<pre lang="text"><code>Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No &quot;exports&quot; main defined in &lt;packageName&gt;/package.json
</code></pre>
<h4>Allow argument of <code>require()</code> to break (<a href="https://redirect.github.com/prettier/prettier/pull/15256">#15256</a> by <a href="https://github.com/fisker"><code>@​fisker</code></a>)</h4>
<!-- raw HTML omitted -->
<pre lang="jsx"><code>// Input
const plugin = require(
  global.STANDALONE
    ? path.join(__dirname, &quot;../standalone.js&quot;)
    : path.join(__dirname, &quot;..&quot;)
);
<p>// Prettier 3.0.2
const plugin = require(global.STANDALONE
? path.join(__dirname, &quot;../standalone.js&quot;)
: path.join(__dirname, &quot;..&quot;));</p>
<p>// Prettier 3.0.3
const plugin = require(
global.STANDALONE
? path.join(__dirname, &quot;../standalone.js&quot;)
: path.join(__dirname, &quot;..&quot;)
);
</code></pre></p>
<h4>Do not print trailing commas in arrow function type parameter lists in <code>ts</code> code blocks (<a href="https://redirect.github.com/prettier/prettier/pull/15286">#15286</a> by <a href="https://github.com/sosukesuzuki"><code>@​sosukesuzuki</code></a>)</h4>
<!-- raw HTML omitted -->
<pre lang="md"><code>&lt;!-- Input --&gt;
```ts
const foo = &lt;T&gt;() =&gt; {}
```
&lt;/tr&gt;&lt;/table&gt; 
</code></pre>
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/prettier/prettier/commit/d5f31710b2fc25f3f472e86f9ee00a561a17ffa2"><code>d5f3171</code></a> Release 3.0.3</li>
<li><a href="https://github.com/prettier/prettier/commit/a35008fb0a010f92c1002ee074c6a7f3c0d8da41"><code>a35008f</code></a> Support shared config that forbids <code>require()</code> (<a href="https://redirect.github.com/prettier/prettier/issues/15233">#15233</a>)</li>
<li><a href="https://github.com/prettier/prettier/commit/1ce97d13a3008bf6be1c17a374d2a80138a83fe1"><code>1ce97d1</code></a> Support TypeScript 5.2 <code>using</code> / <code>await using</code> declaration (<a href="https://redirect.github.com/prettier/prettier/issues/15321">#15321</a>)</li>
<li><a href="https://github.com/prettier/prettier/commit/a73cfa0ec43d575d35dbf7779dcec3694d57b3e9"><code>a73cfa0</code></a> Fix build script <code>--report</code> option (<a href="https://redirect.github.com/prettier/prettier/issues/15323">#15323</a>)</li>
<li><a href="https://github.com/prettier/prettier/commit/941c6b3a3cda41e6940b1682437f12065c635dab"><code>941c6b3</code></a> Minor refactor to <code>getSupportedFilesGlob</code> (<a href="https://redirect.github.com/prettier/prettier/issues/15319">#15319</a>)</li>
<li><a href="https://github.com/prettier/prettier/commit/f6c9e9b0b8e5affce678dd8286be301b298a47f4"><code>f6c9e9b</code></a> Assert uniqueness in language properties (<a href="https://redirect.github.com/prettier/prettier/issues/15320">#15320</a>)</li>
<li><a href="https://github.com/prettier/prettier/commit/288ea7e911f83d79453034681f951d307520e1e5"><code>288ea7e</code></a> chore(deps): update dependency webpack to v5.88.2 (<a href="https://redirect.github.com/prettier/prettier/issues/15147">#15147</a>)</li>
<li><a href="https://github.com/prettier/prettier/commit/6654451d9eced219f10fe8f763e9bd8c4e98a7b6"><code>6654451</code></a> chore(deps): update dependency webpack to v5.88.2 (<a href="https://redirect.github.com/prettier/prettier/issues/15148">#15148</a>)</li>
<li><a href="https://github.com/prettier/prettier/commit/d05964460d9681ea16f479f449b7ce042663ead9"><code>d059644</code></a> chore(deps): update dependency fast-glob to v3.3.1 (<a href="https://redirect.github.com/prettier/prettier/issues/15001">#15001</a>)</li>
<li><a href="https://github.com/prettier/prettier/commit/423011dcab464aaab18d233bbee34c37eb56bfd6"><code>423011d</code></a> Minor refactor to <code>expandPatterns</code> (<a href="https://redirect.github.com/prettier/prettier/issues/15317">#15317</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/prettier/prettier/compare/3.0.2...3.0.3">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=prettier&package-manager=npm_and_yarn&previous-version=3.0.2&new-version=3.0.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/botCommands/searchtop-legacy.js b/botCommands/searchtop-legacy.js
new file mode 100644
index 0000000..77672ea
--- /dev/null
+++ b/botCommands/searchtop-legacy.js
@@ -0,0 +1,18 @@
+const { EmbedBuilder } = require('discord.js');
+const { registerBotCommand } = require('../botEngine');
+
+const command = {
+  regex: /\B!searchtop\s+.+/,
+  cb: ({ content }) => {
+    const prompt = content.match(/\B!searchtop\s+(.+)/)[1];
+    const searchUrl = `https://www.google.com/search?q=site:theodinproject.com+${prompt.replaceAll(' ', '+')}`;
+    const topEmbed = new EmbedBuilder()
+      .setColor('#cc9543')
+      .setTitle('Search TOP')
+      .setDescription(`Here are the [Google results for TOP lessons containing "${prompt}"](${searchUrl})`);
+    return { embeds: [topEmbed]};
+  }
+};
+registerBotCommand(command.regex, command.cb);
+
+module.exports = command;
diff --git a/package-lock.json b/package-lock.json
index 970554b..c5833b8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -16,7 +16,7 @@
         "dotenv": "^16.3.1",
         "glob": "^10.3.3",
         "ioredis": "^5.3.2",
-        "prettier": "^3.0.2"
+        "prettier": "^3.0.3"
       },
       "devDependencies": {
         "@babel/eslint-parser": "^7.22.9",
@@ -7334,9 +7334,9 @@
       }
     },
     "node_modules/prettier": {
-      "version": "3.0.2",
-      "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.2.tgz",
-      "integrity": "sha512-o2YR9qtniXvwEZlOKbveKfDQVyqxbEIWn48Z8m3ZJjBjcCmUy3xZGIv+7AkaeuaTr6yPXJjwv07ZWlsWbEy1rQ==",
+      "version": "3.0.3",
+      "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz",
+      "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==",
       "bin": {
         "prettier": "bin/prettier.cjs"
       },
@@ -14049,9 +14049,9 @@
       "dev": true
     },
     "prettier": {
-      "version": "3.0.2",
-      "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.2.tgz",
-      "integrity": "sha512-o2YR9qtniXvwEZlOKbveKfDQVyqxbEIWn48Z8m3ZJjBjcCmUy3xZGIv+7AkaeuaTr6yPXJjwv07ZWlsWbEy1rQ=="
+      "version": "3.0.3",
+      "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz",
+      "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg=="
     },
     "pretty-format": {
       "version": "29.6.1",
diff --git a/package.json b/package.json
index 94c571a..9238032 100644
--- a/package.json
+++ b/package.json
@@ -19,7 +19,7 @@
     "dotenv": "^16.3.1",
     "glob": "^10.3.3",
     "ioredis": "^5.3.2",
-    "prettier": "^3.0.2"
+    "prettier": "^3.0.3"
   },
   "devDependencies": {
     "@babel/eslint-parser": "^7.22.9",


Test patch:
diff --git a/botCommands/__snapshots__/code.test.js.snap b/botCommands/__snapshots__/code-legacy.test.js.snap
similarity index 100%
rename from botCommands/__snapshots__/code.test.js.snap
rename to botCommands/__snapshots__/code-legacy.test.js.snap
diff --git a/botCommands/__snapshots__/searchtop-legacy.test.js.snap b/botCommands/__snapshots__/searchtop-legacy.test.js.snap
new file mode 100644
index 0000000..cb898e9
--- /dev/null
+++ b/botCommands/__snapshots__/searchtop-legacy.test.js.snap
@@ -0,0 +1,13 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`!searchtop callback returns correct output 1`] = `
+{
+  "embeds": [
+    {
+      "color": 13407555,
+      "description": "Here are the [Google results for TOP lessons containing "The Odin Project"](https://www.google.com/search?q=site:theodinproject.com+The+Odin+Project)",
+      "title": "Search TOP",
+    },
+  ],
+}
+`;
diff --git a/botCommands/__snapshots__/top.test.js.snap b/botCommands/__snapshots__/top-legacy.test.js.snap
similarity index 100%
rename from botCommands/__snapshots__/top.test.js.snap
rename to botCommands/__snapshots__/top-legacy.test.js.snap
diff --git a/botCommands/code.js b/botCommands/code-legacy.js
similarity index 100%
rename from botCommands/code.js
rename to botCommands/code-legacy.js
diff --git a/botCommands/code.test.js b/botCommands/code-legacy.test.js
similarity index 97%
rename from botCommands/code.test.js
rename to botCommands/code-legacy.test.js
index e7e670b..0a17632 100644
--- a/botCommands/code.test.js
+++ b/botCommands/code-legacy.test.js
@@ -1,4 +1,4 @@
-const commands = require('./code');
+const commands = require('./code-legacy');
 const { generateMentions } = require('./mockData');
 
 describe('!code', () => {
diff --git a/botCommands/searchtop-legacy.test.js b/botCommands/searchtop-legacy.test.js
new file mode 100644
index 0000000..609cd98
--- /dev/null
+++ b/botCommands/searchtop-legacy.test.js
@@ -0,0 +1,65 @@
+const command = require('./searchtop-legacy');
+
+describe('!searchtop', () => {
+  describe('regex', () => {
+    it.each([
+      ['!searchtop query'],
+      [' !searchtop query'],
+      ['!searchtop query @odin-bot'],
+      ['@odin-bot !searchtop query'],
+    ])('correct strings trigger the callback', (string) => {
+      expect(command.regex.test(string)).toBeTruthy();
+    });
+
+    it.each([
+      ['!searchto'],
+      ['searchtop'],
+      ['!searcht'],
+      ['!search top'],
+      ['```function("!searchtop", () => {}```'],
+      ['!searchingtop'],
+      [''],
+      [' '],
+      [' !'],
+      ['@odin-bot ! searchtop'],
+      ['!search-top'],
+      ['!searc^htop'],
+      ['!searchtop!'],
+      ['@odin-bot! searchtop'],
+      ['https:!!searchtop.com'],
+    ])("'%s' does not trigger the callback", (string) => {
+      expect(command.regex.test(string)).toBeFalsy();
+    });
+
+    it.each([
+      ['Check this out! !searchtop query'],
+      ["Don't worry about !searchtop query"],
+      ['Hey @odin-bot, !searchtop query'],
+      ['!@odin-bot ^ !me !searchtop !tests$*'],
+    ])("'%s' - command can be anywhere in the string", (string) => {
+      expect(command.regex.test(string)).toBeTruthy();
+    });
+
+    it.each([
+      ['@user!searchtop'],
+      ["it's about!searchtop"],
+      ['!searchtopnow'],
+      ['!searchtop!'],
+      ['!searchtop*'],
+      ['!searchtop...'],
+    ])(
+      "'%s' - command should be its own word!group - no leading or trailing characters",
+      (string) => {
+        expect(command.regex.test(string)).toBeFalsy();
+      },
+    );
+  });
+
+  describe('callback', () => {
+    it('returns correct output', () => {
+      expect(
+        command.cb({ content: '!searchtop The Odin Project' }),
+      ).toMatchSnapshot();
+    });
+  });
+});
diff --git a/botCommands/top.js b/botCommands/top-legacy.js
similarity index 100%
rename from botCommands/top.js
rename to botCommands/top-legacy.js
diff --git a/botCommands/top.test.js b/botCommands/top-legacy.test.js
similarity index 96%
rename from botCommands/top.test.js
rename to botCommands/top-legacy.test.js
index 50e2507..1437cca 100644
--- a/botCommands/top.test.js
+++ b/botCommands/top-legacy.test.js
@@ -1,4 +1,4 @@
-const command = require('./top');
+const command = require('./top-legacy');
 
 describe('!top', () => {
   describe('regex', () => {