@next/codemod 15.0.0-canary.17 → 15.0.0-canary.170
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/bin/next-codemod.js +27 -3
- package/bin/transform.js +104 -0
- package/bin/upgrade.js +224 -0
- package/lib/codemods.js +103 -0
- package/lib/cra-to-next/global-css-transform.js +2 -3
- package/lib/cra-to-next/index-to-component.js +2 -3
- package/lib/handle-package.js +76 -0
- package/lib/install.js +2 -3
- package/lib/run-jscodeshift.js +9 -2
- package/lib/utils.js +92 -0
- package/package.json +8 -5
- package/transforms/add-missing-react-import.js +1 -1
- package/transforms/built-in-next-font.js +1 -1
- package/transforms/cra-to-next.js +238 -236
- package/transforms/lib/async-request-api/index.js +21 -0
- package/transforms/lib/async-request-api/next-async-dynamic-api.js +221 -0
- package/transforms/lib/async-request-api/next-async-dynamic-prop.js +345 -0
- package/transforms/lib/async-request-api/utils.js +198 -0
- package/transforms/metadata-to-viewport-export.js +1 -1
- package/transforms/name-default-component.js +3 -4
- package/transforms/new-link.js +5 -4
- package/transforms/next-async-request-api.js +9 -0
- package/transforms/next-dynamic-access-named-export.js +65 -0
- package/transforms/next-image-experimental.js +9 -13
- package/transforms/next-image-to-legacy-image.js +5 -7
- package/transforms/next-og-import.js +1 -1
- package/transforms/next-request-geo-ip.js +338 -0
- package/transforms/url-to-withrouter.js +1 -1
- package/transforms/withamp-to-config.js +1 -1
- package/bin/cli.js +0 -216
- package/lib/uninstall-package.js +0 -32
package/lib/utils.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TRANSFORMER_INQUIRER_CHOICES = void 0;
|
|
7
|
+
exports.checkGitStatus = checkGitStatus;
|
|
8
|
+
const picocolors_1 = require("picocolors");
|
|
9
|
+
const is_git_clean_1 = __importDefault(require("is-git-clean"));
|
|
10
|
+
function checkGitStatus(force) {
|
|
11
|
+
let clean = false;
|
|
12
|
+
let errorMessage = 'Unable to determine if git directory is clean';
|
|
13
|
+
try {
|
|
14
|
+
clean = is_git_clean_1.default.sync(process.cwd());
|
|
15
|
+
errorMessage = 'Git directory is not clean';
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
if (err && err.stderr && err.stderr.includes('Not a git repository')) {
|
|
19
|
+
clean = true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (!clean) {
|
|
23
|
+
if (force) {
|
|
24
|
+
console.log(`WARNING: ${errorMessage}. Forcibly continuing.`);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
console.log('Thank you for using @next/codemod!');
|
|
28
|
+
console.log((0, picocolors_1.yellow)('\nBut before we continue, please stash or commit your git changes.'));
|
|
29
|
+
console.log('\nYou may use the --force flag to override this safety check.');
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.TRANSFORMER_INQUIRER_CHOICES = [
|
|
35
|
+
{
|
|
36
|
+
title: 'name-default-component: Transforms anonymous components into named components to make sure they work with Fast Refresh',
|
|
37
|
+
value: 'name-default-component',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
title: 'add-missing-react-import: Transforms files that do not import `React` to include the import in order for the new React JSX transform',
|
|
41
|
+
value: 'add-missing-react-import',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
title: 'withamp-to-config: Transforms the withAmp HOC into Next.js 9 page configuration',
|
|
45
|
+
value: 'withamp-to-config',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
title: 'url-to-withrouter: Transforms the deprecated automatically injected url property on top level pages to using withRouter',
|
|
49
|
+
value: 'url-to-withrouter',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
title: 'cra-to-next (experimental): automatically migrates a Create React App project to Next.js',
|
|
53
|
+
value: 'cra-to-next',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
title: 'new-link: Ensures your <Link> usage is backwards compatible.',
|
|
57
|
+
value: 'new-link',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
title: 'next-og-import: Transforms imports from `next/server` to `next/og` for usage of Dynamic OG Image Generation.',
|
|
61
|
+
value: 'next-og-import',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
title: 'metadata-to-viewport-export: Migrates certain viewport related metadata from the `metadata` export to a new `viewport` export.',
|
|
65
|
+
value: 'metadata-to-viewport-export',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
title: 'next-dynamic-access-named-export: Transforms dynamic imports that return the named export itself to a module like object.',
|
|
69
|
+
value: 'next-dynamic-access-named-export',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
title: 'next-image-to-legacy-image: safely migrate Next.js 10, 11, 12 applications importing `next/image` to the renamed `next/legacy/image` import in Next.js 13',
|
|
73
|
+
value: 'next-image-to-legacy-image',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
title: 'next-image-experimental (experimental): dangerously migrates from `next/legacy/image` to the new `next/image` by adding inline styles and removing unused props',
|
|
77
|
+
value: 'next-image-experimental',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
title: 'built-in-next-font: Uninstall `@next/font` and transform imports to `next/font`',
|
|
81
|
+
value: 'built-in-next-font',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
title: 'next-async-request-api: Transforms usage of Next.js async Request APIs',
|
|
85
|
+
value: 'next-async-request-api',
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
title: 'next-request-geo-ip: Install `@vercel/functions` to replace `geo` and `ip` properties on `NextRequest`',
|
|
89
|
+
value: 'next-request-geo-ip',
|
|
90
|
+
},
|
|
91
|
+
];
|
|
92
|
+
//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next/codemod",
|
|
3
|
-
"version": "15.0.0-canary.
|
|
3
|
+
"version": "15.0.0-canary.170",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,17 +8,20 @@
|
|
|
8
8
|
"directory": "packages/next-codemod"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
+
"chalk": "4.1.2",
|
|
11
12
|
"cheerio": "1.0.0-rc.9",
|
|
13
|
+
"commander": "12.1.0",
|
|
14
|
+
"compare-versions": "6.1.1",
|
|
12
15
|
"execa": "4.0.3",
|
|
13
16
|
"globby": "11.0.1",
|
|
14
|
-
"inquirer": "7.3.3",
|
|
15
17
|
"is-git-clean": "1.1.0",
|
|
16
|
-
"jscodeshift": "0.
|
|
17
|
-
"
|
|
18
|
-
"
|
|
18
|
+
"jscodeshift": "17.0.0",
|
|
19
|
+
"picocolors": "1.0.0",
|
|
20
|
+
"prompts": "2.4.2"
|
|
19
21
|
},
|
|
20
22
|
"files": [
|
|
21
23
|
"transforms/*.js",
|
|
24
|
+
"transforms/lib/**/*.js",
|
|
22
25
|
"bin/*.js",
|
|
23
26
|
"lib/**/*.js",
|
|
24
27
|
"lib/cra-to-next/gitignore"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = transformer;
|
|
3
4
|
function addReactImport(j, root) {
|
|
4
5
|
// We create an import specifier, this is the value of an import, eg:
|
|
5
6
|
// import React from 'react'
|
|
@@ -60,5 +61,4 @@ function transformer(file, api, options) {
|
|
|
60
61
|
}
|
|
61
62
|
return root.toSource(options);
|
|
62
63
|
}
|
|
63
|
-
exports.default = transformer;
|
|
64
64
|
//# sourceMappingURL=add-missing-react-import.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = transformer;
|
|
3
4
|
function transformer(file, api, options) {
|
|
4
5
|
const j = api.jscodeshift.withParser('tsx');
|
|
5
6
|
const root = j(file.source);
|
|
@@ -36,5 +37,4 @@ function transformer(file, api, options) {
|
|
|
36
37
|
});
|
|
37
38
|
return hasChanges ? root.toSource(options) : file.source;
|
|
38
39
|
}
|
|
39
|
-
exports.default = transformer;
|
|
40
40
|
//# sourceMappingURL=built-in-next-font.js.map
|