@clerk/upgrade 1.0.7 → 1.0.8-canary.v1e57618

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Clerk, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,10 +1,46 @@
1
+ <p align="center">
2
+ <a href="https://clerk.com?utm_source=github&utm_medium=clerk_upgrade" target="_blank" rel="noopener noreferrer">
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="https://images.clerk.com/static/logo-dark-mode-400x400.png">
5
+ <img src="https://images.clerk.com/static/logo-light-mode-400x400.png" height="64">
6
+ </picture>
7
+ </a>
8
+ <br />
9
+ </p>
10
+
1
11
  # @clerk/upgrade
2
12
 
13
+ <div align="center">
14
+
15
+ [![Chat on Discord](https://img.shields.io/discord/856971667393609759.svg?logo=discord)](https://clerk.com/discord)
16
+ [![Clerk documentation](https://img.shields.io/badge/documentation-clerk-green.svg)](https://clerk.com/docs?utm_source=github&utm_medium=clerk_upgrade)
17
+ [![Follow on Twitter](https://img.shields.io/twitter/follow/ClerkDev?style=social)](https://twitter.com/intent/follow?screen_name=ClerkDev)
18
+
19
+ [Changelog](https://github.com/clerk/javascript/blob/main/packages/upgrade/CHANGELOG.md)
20
+ ·
21
+ [Report a Bug](https://github.com/clerk/javascript/issues/new?assignees=&labels=needs-triage&projects=&template=BUG_REPORT.yml)
22
+ ·
23
+ [Request a Feature](https://feedback.clerk.com/roadmap)
24
+ ·
25
+ [Ask a Question](https://github.com/clerk/javascript/discussions)
26
+
27
+ </div>
28
+
29
+ ---
30
+
31
+ ## Overview
32
+
3
33
  A tool that helps with upgrading major versions of Clerk's SDKs.
4
34
 
5
- ## Usage
35
+ ## Getting Started
36
+
37
+ ### Prerequisites
38
+
39
+ - Node.js `>=18.17.0` or later
6
40
 
7
- ```bash
41
+ ### Usage
42
+
43
+ ```sh
8
44
  npx @clerk/upgrade
9
45
  ```
10
46
 
@@ -12,7 +48,7 @@ npx @clerk/upgrade
12
48
 
13
49
  This tool uses regular expressions to scan for patterns that match breaking changes. This makes it run substantially faster and makes it more accessible for us at Clerk to author matchers for each breaking change, however it means that _we cannot gurarantee 100% accuracy of the results_. As such, it's important to treat this as a tool that can help you to complete your major version upgrades, rather than an automatic fix to all issues.
14
50
 
15
- The main thing that this tool will miss is cases where _unusual import patterns_ are used in your codebase.As an example, if we made a breaking change to the `getAuth` function exported from `@clerk/nextjs`, we would likely look for something like `import { getAuth } from "@clerk/nextjs"` in order to detect whether you need to make some changes. If you were running your imports like `import * as ClerkNext from "@clerk/nextjs"`, you could use `getAuth` without us detecting it with our matcher.
51
+ The main thing that this tool will miss is cases where _unusual import patterns_ are used in your codebase. As an example, if Clerk made a breaking change to the `getAuth` function exported from `@clerk/nextjs`, `@clerk/upgrade` would likely look for something like `import { getAuth } from "@clerk/nextjs"` in order to detect whether you need to make some changes. If you were using your imports like `import * as ClerkNext from "@clerk/nextjs"`, you could use `getAuth` without it detecting it with its matcher.
16
52
 
17
53
  It will also be very likely to miss if you bind a method on an object to a separate variable and call it from there, or pass a bound method through a function param. For example, something like this:
18
54
 
@@ -22,4 +58,30 @@ const updateUser = user.update.bind(user);
22
58
  updateUser({ username: 'foo' });
23
59
  ```
24
60
 
25
- Overall, there's a very good chance that this tool catches everything, but it's not a guarantee, so make sure that you also test your app before deploying, and that you have good e2e test coverage, which are good practices normally anyway, rather than blindly trusting that since the clerk upgrade tool was run, you are for sure covered.
61
+ Overall, there's a very good chance that this tool catches everything, but it's not a guarantee. Make sure that you also test your app before deploying, and that you have good E2E test coverage.
62
+
63
+ ## Support
64
+
65
+ You can get in touch with us in any of the following ways:
66
+
67
+ - Join our official community [Discord server](https://clerk.com/discord)
68
+ - Create a [GitHub Discussion](https://github.com/clerk/javascript/discussions)
69
+ - Contact options listed on [our Support page](https://clerk.com/support?utm_source=github&utm_medium=clerk_upgrade)
70
+
71
+ ## Contributing
72
+
73
+ We're open to all community contributions! If you'd like to contribute in any way, please read [our contribution guidelines](https://github.com/clerk/javascript/blob/main/docs/CONTRIBUTING.md).
74
+
75
+ ## Security
76
+
77
+ `@clerk/upgrade` follows good practices of security, but 100% security cannot be assured.
78
+
79
+ `@clerk/upgrade` is provided **"as is"** without any **warranty**. Use at your own risk.
80
+
81
+ _For more information and to report security issues, please refer to our [security documentation](https://github.com/clerk/javascript/blob/main/docs/SECURITY.md)._
82
+
83
+ ## License
84
+
85
+ This project is licensed under the **MIT license**.
86
+
87
+ See [LICENSE](https://github.com/clerk/javascript/blob/main/packages/upgrade/LICENSE) for more information.
package/dist/app.js CHANGED
@@ -22,8 +22,11 @@ export default function App({
22
22
  const [sdkGuesses, setSdkGuesses] = useState([]);
23
23
  const [sdkGuessConfirmed, setSdkGuessConfirmed] = useState(false);
24
24
  const [sdkGuessAttempted, setSdkGuessAttempted] = useState(false);
25
+ // See comments below, can be enabled on next major
26
+ // eslint-disable-next-line no-unused-vars
25
27
  const [fromVersion, setFromVersion] = useState(_fromVersion);
26
28
  const [fromVersionGuessAttempted, setFromVersionGuessAttempted] = useState(false);
29
+ // eslint-disable-next-line no-unused-vars
27
30
  const [toVersion, setToVersion] = useState(_toVersion);
28
31
  const [dir, setDir] = useState(_dir);
29
32
  const [ignore, setIgnore] = useState(_ignore);
@@ -38,11 +41,17 @@ export default function App({
38
41
 
39
42
  // We try to guess which SDK they are using
40
43
  if (isEmpty(sdks) && isEmpty(sdkGuesses) && !sdkGuessAttempted) {
41
- if (!dir) return setDir(process.cwd());
44
+ if (!dir) {
45
+ return setDir(process.cwd());
46
+ }
42
47
  const {
43
48
  guesses,
44
49
  _uuid
45
50
  } = guessFrameworks(dir, disableTelemetry);
51
+ console.log({
52
+ guesses,
53
+ _uuid
54
+ });
46
55
  setUuid(_uuid);
47
56
  setSdkGuesses(guesses);
48
57
  setSdkGuessAttempted(true);
@@ -87,7 +96,9 @@ export default function App({
87
96
  onChange: item => {
88
97
  setSdkGuessConfirmed(true);
89
98
  // if true, we were right so we set the sdk
90
- if (item === 'yes') setSdks(sdkGuesses.map(guess => guess.value));
99
+ if (item === 'yes') {
100
+ setSdks(sdkGuesses.map(guess => guess.value));
101
+ }
91
102
  }
92
103
  })), isEmpty(sdks) && isEmpty(sdkGuesses) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, null, "Please select which Clerk SDK(s) you're using for your app:"), /*#__PURE__*/React.createElement(Text, {
93
104
  color: "gray"
@@ -65,7 +65,9 @@ export const accordionForCategory = partial((categories, options, {
65
65
  }) => {
66
66
  const items = filterCategories(data, categories);
67
67
  options ||= {};
68
- if (options.additionalItems) items.push(...[].concat(options.additionalItems));
68
+ if (options.additionalItems) {
69
+ items.push(...[].concat(options.additionalItems));
70
+ }
69
71
  return `<Accordion titles={[${items.map(i => `"${parseInline(i.title)}"`).join(', ')}]}>
70
72
  ${items.map(i => ` <AccordionPanel>${indent('\n' + i.content.trim(), 4)}\n </AccordionPanel>`).join('\n')}
71
73
  </Accordion>`;
package/dist/scan.js CHANGED
@@ -53,7 +53,6 @@ export default function Scan({
53
53
  // common image files
54
54
  '**/*.(mp4|mkv|wmv|m4v|mov|avi|flv|webm|flac|mka|m4a|aac|ogg)+' // common video files
55
55
  );
56
-
57
56
  globby(convertPathToPattern(path.resolve(dir)), {
58
57
  ignore: ignore.filter(Boolean)
59
58
  }).then(files => {
@@ -65,7 +64,9 @@ export default function Scan({
65
64
  // ---------------------------
66
65
  // result = `results` set to format
67
66
  useEffect(() => {
68
- if (!matchers || !files) return;
67
+ if (!matchers || !files) {
68
+ return;
69
+ }
69
70
  const allResults = {};
70
71
  Promise.all(
71
72
  // first we read all the files
@@ -86,17 +87,23 @@ export default function Scan({
86
87
  } else {
87
88
  matches = Array.from(content.matchAll(matcherConfig.matcher));
88
89
  }
89
- if (matches.length < 1) return;
90
+ if (matches.length < 1) {
91
+ return;
92
+ }
90
93
 
91
94
  // for each match, add to `instances` array
92
95
  matches.map(match => {
93
- if (noWarnings && matcherConfig.warning) return;
96
+ if (noWarnings && matcherConfig.warning) {
97
+ return;
98
+ }
94
99
 
95
100
  // create if not exists
96
- if (!allResults[matcherConfig.title]) allResults[matcherConfig.title] = {
97
- instances: [],
98
- ...matcherConfig
99
- };
101
+ if (!allResults[matcherConfig.title]) {
102
+ allResults[matcherConfig.title] = {
103
+ instances: [],
104
+ ...matcherConfig
105
+ };
106
+ }
100
107
  const position = indexToPosition(content, match.index, {
101
108
  oneBased: true
102
109
  });
@@ -105,7 +112,9 @@ export default function Scan({
105
112
  // when scanning for multiple SDKs, you can get a double match, this logic ensures you don't
106
113
  if (allResults[matcherConfig.title].instances.filter(i => {
107
114
  return i.position.line === position.line && i.position.column === position.column && i.file === fileRelative;
108
- }).length > 0) return;
115
+ }).length > 0) {
116
+ return;
117
+ }
109
118
  allResults[matcherConfig.title].instances.push({
110
119
  sdk,
111
120
  position,
@@ -162,7 +171,7 @@ export default function Scan({
162
171
  }).catch(err => {
163
172
  console.error(err);
164
173
  });
165
- }, [matchers, files, noWarnings]);
174
+ }, [matchers, files, noWarnings, disableTelemetry]);
166
175
  return complete ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
167
176
  color: "green"
168
177
  }, "\u2713 ", status), /*#__PURE__*/React.createElement(Newline, null), !!results.length && /*#__PURE__*/React.createElement(ExpandableList, {
@@ -50,7 +50,9 @@ export default function ExpandableList({
50
50
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
51
51
  color: "blue"
52
52
  }, "Navigation Instructions:"), /*#__PURE__*/React.createElement(Text, null, "Navigate through items with \u2191 and \u2193 arrow keys. Expand the details of any item with space bar. \u2193 key on the last item goes to the next page, \u2191 on the first item goes to the previous page. To exit this interface, use \"control + c\"."), /*#__PURE__*/React.createElement(Newline, null), state.all.reduce((memo, item, idx) => {
53
- if (idx < state.visible[0] || idx >= state.visible[1]) return memo;
53
+ if (idx < state.visible[0] || idx >= state.visible[1]) {
54
+ return memo;
55
+ }
54
56
  const locations = item.instances.map(instance => `${instance.file}:${instance.position.line}:${instance.position.column}`);
55
57
  const singleBorderStyle = {
56
58
  topLeft: ' ',
@@ -1,10 +1,12 @@
1
- import { randomUUID } from 'crypto';
1
+ import { createHash, randomUUID } from 'crypto';
2
2
  import fs from 'fs';
3
- import md5 from 'md5';
4
3
  import path from 'path';
5
4
  import { readPackageSync } from 'read-pkg';
6
5
  import tempDir from 'temp-dir';
7
6
  import SDKS from '../constants/sdks.js';
7
+ function md5(data) {
8
+ return createHash('md5').update(data).digest('hex');
9
+ }
8
10
 
9
11
  // Telemetry Note
10
12
  // --------------
@@ -41,10 +43,12 @@ export default function guessFrameworks(dir, disableTelemetry) {
41
43
  const _uuid = md5(JSON.stringify(pkg));
42
44
 
43
45
  // no guessing if there are no deps
44
- if (!pkg.dependencies && !pkg.devDependencies) return {
45
- guesses: [],
46
- _uuid
47
- };
46
+ if (!pkg.dependencies && !pkg.devDependencies) {
47
+ return {
48
+ guesses: [],
49
+ _uuid
50
+ };
51
+ }
48
52
  const deps = pkg.dependencies ? Object.keys(pkg.dependencies) : [];
49
53
  const devDeps = pkg.devDependencies ? Object.keys(pkg.devDependencies) : [];
50
54
  return {
@@ -53,10 +57,12 @@ export default function guessFrameworks(dir, disableTelemetry) {
53
57
  label,
54
58
  value
55
59
  }) => {
56
- if (deps.includes(label) || devDeps.includes(label)) m.push({
57
- label,
58
- value
59
- });
60
+ if (deps.includes(label) || devDeps.includes(label)) {
61
+ m.push({
62
+ label,
63
+ value
64
+ });
65
+ }
60
66
  return m;
61
67
  }, [])
62
68
  };
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: '`GASTBY_CLERK_FRONTEND_API` replaced by `GATSBY_CLERK_PUBLISHABLE_KEY`'
2
+ title: '`GATSBY_CLERK_FRONTEND_API` replaced by `GATSBY_CLERK_PUBLISHABLE_KEY`'
3
3
  category: 'deprecation-removal'
4
4
  matcher: 'GATSBY_CLERK_FRONTEND_API'
5
5
  ---
@@ -21,7 +21,6 @@ export default {
21
21
  'signup-attemptweb3walletverification-generatedsignature', 'redirecttohome', 'organizationprofile-settings', 'userprofile-security', 'connected-accounts-dropdown', 'userbuttonpopoveractionbuttontext-removed', 'userbuttontrigger-userbuttonbox-invert', 'organizationswitcherpopoveractionbuttontext-removed', 'card-changes', 'alternativemethods-backlink', 'button-to-organizationlistcreateorganizationactionbutton', 'remove-socialbuttonsblockbuttonarrow', 'remove-identitypreview-avatar', 'clerk-isready-removed', 'new-localization-keys', 'removed-localization-keys', 'changed-localization-keys', 'signoutcallback-to-redirecturl', 'externalaccount-avatarurl', 'organizationmembershippublicuserdata-profileimageurl', 'clerk-import'])),
22
22
  shared: load('shared', ['magiclinkerror', 'ismagiclinkerror', 'magiclinkerrorcode', 'usemagiclink', 'getrequesturl', 'organizationcontext', 'useorganizationlist-organizationlist' // shared outside this pkg?
23
23
  ]),
24
-
25
24
  'chrome-extension': load('chrome-extension', dedupeMerge(changesAffectingAll, jsChanges, ['clerkprovider-tokencache'])),
26
25
  localizations: load('localization', ['new-localization-keys', 'removed-localization-keys', 'changed-localization-keys']),
27
26
  backend: load('backend', dedupeMerge(changesAffectingAll, ['api-url-value-changed', 'verifyjwt-import-path-move', 'decodejwt-import-path-move', 'signjwt-import-path-move', 'constants-import-path-move', 'redirect-import-path-move', 'createauthenticaterequest-import-path-move', 'createisomorphicrequest-import-path-move', 'createclerkclient-frontendapi', 'authenticaterequest-params-change', 'clerk-import', 'externalaccount-picture', 'externalaccountjson-avatarurl', 'organizationjson-logourl', 'userjson-profileimageurl', 'organizationmembershippublicuserdata-profileimageurl', 'organizationmembershippublicuserdatajson-profileimageurl', 'clockskewinseconds', 'pkgversion', 'client-unstableoptions-removed', 'httpoptions-removed', 'createisomorphicrequest-removed', 'createemail-removed', 'signjwterror-import-move', 'tokenverificationerror-import-move', 'tokenverificationerroraction-import-move', 'tokenverificationerrorreason-import-move', 'membershiprole', 'getorganizationmembershiplist-return-signature', 'buildrequesturl-removed', 'createclerkclient-apikey', 'getclientlist-arguments', 'getsessionlist-arguments', 'members-count'])),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clerk/upgrade",
3
- "version": "1.0.7",
3
+ "version": "1.0.8-canary.v1e57618",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/cli.js",
@@ -11,9 +11,16 @@
11
11
  "dist"
12
12
  ],
13
13
  "scripts": {
14
- "build": "npm run clean && NODE_ENV=production babel --out-dir=dist source --copy-files",
14
+ "build": "npm run clean && NODE_ENV=production babel --out-dir=dist src --copy-files",
15
15
  "clean": "del-cli dist/*",
16
- "dev": "babel --out-dir=dist --watch source --copy-files"
16
+ "dev": "babel --out-dir=dist --watch src --copy-files",
17
+ "lint": "eslint src/",
18
+ "lint:publint": "publint"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/clerk/javascript.git",
23
+ "directory": "packages/upgrade"
17
24
  },
18
25
  "babel": {
19
26
  "presets": [
@@ -23,8 +30,8 @@
23
30
  "dependencies": {
24
31
  "@inkjs/ui": "^1.0.0",
25
32
  "@jescalan/ink-markdown": "^2.0.0",
26
- "ejs": "3.1.9",
27
- "globby": "^14.0.0",
33
+ "ejs": "3.1.10",
34
+ "globby": "^14.0.1",
28
35
  "gray-matter": "^4.0.3",
29
36
  "index-to-position": "^0.1.2",
30
37
  "ink": "^4.4.1",
@@ -32,17 +39,16 @@
32
39
  "ink-gradient": "^3.0.0",
33
40
  "ink-link": "^3.0.0",
34
41
  "marked": "^11.1.1",
35
- "md5": "^2.3.0",
36
42
  "meow": "^11.0.0",
37
- "react": "^18.2.0",
43
+ "react": "^18.3.1",
38
44
  "read-pkg": "^9.0.1",
39
45
  "semver-regex": "^4.0.5",
40
46
  "temp-dir": "^3.0.0"
41
47
  },
42
48
  "devDependencies": {
43
- "@babel/cli": "^7.21.0",
44
- "@babel/preset-react": "^7.18.6",
45
- "chalk": "^5.2.0",
49
+ "@babel/cli": "^7.24.7",
50
+ "@babel/preset-react": "^7.24.7",
51
+ "chalk": "^5.3.0",
46
52
  "del-cli": "^5.1.0",
47
53
  "eslint-config-custom": "*"
48
54
  },