@atlaskit/codemod-utils 4.1.2 → 4.1.3
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/CHANGELOG.md +6 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types-ts4.0/index.d.ts +2 -0
- package/dist/types-ts4.0/utils/index.d.ts +15 -0
- package/dist/types-ts4.0/utils/support.d.ts +47 -0
- package/package.json +9 -2
- package/report.api.md +65 -32
package/CHANGELOG.md
CHANGED
package/dist/cjs/version.json
CHANGED
package/dist/es2019/version.json
CHANGED
package/dist/esm/version.json
CHANGED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { createRenameFuncFor, createConvertFuncFor, createRenameImportFor, createRemoveFuncFor, replaceImportStatementFor, elevateComponentToNewEntryPoint, createTransformer, renameNamedImportWithAliasName, flattenCertainChildPropsAsProp, createRenameJSXFunc, createRemoveFuncAddCommentFor, changeImportEntryPoint, } from './utils';
|
|
2
|
+
export { getDefaultSpecifier, getNamedSpecifier, getJSXAttributesByName, hasJSXAttributesByName, doesIdentifierExist, hasImportDeclaration, hasImportDeclarationFromAnyPackageEntrypoint, addCommentBefore, addCommentToStartOfFile, callExpressionArgMatchesString, testMethodVariantEach, getSafeImportName, removeImport, getDynamicImportName, addDynamicImport, tryCreateImport, addToImport, } from './utils/support';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import core, { API, ASTPath, FileInfo, Options } from 'jscodeshift';
|
|
2
|
+
import { Collection } from 'jscodeshift/src/Collection';
|
|
3
|
+
declare const createRemoveFuncFor: (component: string, importName: string, prop: string, predicate?: (j: core.JSCodeshift, element: ASTPath<any>) => boolean, comment?: string | undefined) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
4
|
+
declare const createRenameFuncFor: (component: string, from: string, to: string) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
5
|
+
declare const createConvertFuncFor: (component: string, from: string, to: string, predicate?: ((value: any) => boolean) | undefined) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
6
|
+
declare const replaceImportStatementFor: (pkg: string, convertMap: any) => (j: core.JSCodeshift, root: Collection<Node>) => void;
|
|
7
|
+
declare const createRenameImportFor: (component: string, from: string, to: string) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
8
|
+
declare const createTransformer: (migrates: ((j: core.JSCodeshift, source: Collection<Node>) => void)[], shouldApplyTransform?: ((j: core.JSCodeshift, source: Collection<Node>) => boolean) | undefined) => (fileInfo: FileInfo, { jscodeshift: j }: API, options: Options) => string;
|
|
9
|
+
declare const elevateComponentToNewEntryPoint: (pkg: string, toPkg: string, innerElementName: string) => (j: core.JSCodeshift, root: any) => void;
|
|
10
|
+
declare const flattenCertainChildPropsAsProp: (component: string, propName: string, childProps: string[]) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
11
|
+
declare const createRenameJSXFunc: (packagePath: string, from: string, to: string, fallback?: string | undefined) => (j: core.JSCodeshift, source: any) => void;
|
|
12
|
+
declare const createRemoveFuncAddCommentFor: (component: string, prop: string, comment?: string | undefined) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
13
|
+
declare const renameNamedImportWithAliasName: (component: string, from: string, to: string) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
14
|
+
declare const changeImportEntryPoint: (oldPackageName: string, importToConvert: string, newPackageName: string, shouldBeTypeImport?: boolean | undefined) => (j: core.JSCodeshift, root: Collection<Node>) => void;
|
|
15
|
+
export { createRenameFuncFor, createConvertFuncFor, createRenameImportFor, createRemoveFuncFor, replaceImportStatementFor, elevateComponentToNewEntryPoint, createTransformer, renameNamedImportWithAliasName, flattenCertainChildPropsAsProp, createRenameJSXFunc, createRemoveFuncAddCommentFor, changeImportEntryPoint, };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import core, { ASTPath, CallExpression, ImportDeclaration, ImportDefaultSpecifier, ImportSpecifier, JSXAttribute, JSXElement, Program, VariableDeclaration, VariableDeclarator } from 'jscodeshift';
|
|
2
|
+
import { Collection } from 'jscodeshift/src/Collection';
|
|
3
|
+
declare function getNamedSpecifier(j: core.JSCodeshift, source: Collection<Node>, specifier: string, importName: string): string | null;
|
|
4
|
+
declare const getDynamicImportName: (j: core.JSCodeshift, source: Collection<any>, importPath: string) => string | null;
|
|
5
|
+
declare const addDynamicImport: (j: core.JSCodeshift, target: Collection<VariableDeclaration>, name: string, packageEndpoint: string) => void;
|
|
6
|
+
declare function clean(value: string): string;
|
|
7
|
+
declare const addCommentToStartOfFile: ({ j, base, message, }: {
|
|
8
|
+
j: core.JSCodeshift;
|
|
9
|
+
base: Collection<Node>;
|
|
10
|
+
message: string;
|
|
11
|
+
}) => void;
|
|
12
|
+
declare function addCommentBefore(j: core.JSCodeshift, target: Collection<Program> | Collection<ImportDeclaration> | Collection<JSXElement> | Collection<JSXAttribute> | Collection<CallExpression> | Collection<VariableDeclarator>, message: string, commentType?: 'block' | 'line', messagePrefix?: string): void;
|
|
13
|
+
declare const getDefaultSpecifier: (j: core.JSCodeshift, source: Collection<Node>, specifier: string) => string | null;
|
|
14
|
+
declare const getJSXAttributesByName: (j: core.JSCodeshift, element: ASTPath<any>, attributeName: string) => Collection<JSXAttribute>;
|
|
15
|
+
declare const isEmpty: any;
|
|
16
|
+
declare const hasImportDeclaration: (j: core.JSCodeshift, source: Collection<Node>, importPath: string) => boolean;
|
|
17
|
+
declare const hasImportDeclarationFromAnyPackageEntrypoint: (j: core.JSCodeshift, source: Collection<Node>, packageName: string) => boolean;
|
|
18
|
+
declare const debug: (component: string) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
19
|
+
export declare function placeholderStringMatches(placeholderStr: string, resolvedStr: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Check whether a value contains a Format Specifier (printf placeholder)
|
|
22
|
+
*
|
|
23
|
+
* @see https://jestjs.io/docs/api#testeachtablename-fn-timeout
|
|
24
|
+
* @see https://nodejs.org/api/util.html#utilformatformat-args
|
|
25
|
+
*
|
|
26
|
+
* @param argValue The string potentially containing a format specifier (e.g. 'Foo %s')
|
|
27
|
+
* @param str The string that has replaced a format specifier with a tangible value (e.g. 'Foo Bar`)
|
|
28
|
+
*
|
|
29
|
+
* @returns Boolean: True if the strings matched (after considering the placeholder), or false if not.
|
|
30
|
+
*/
|
|
31
|
+
export declare function matchesStringWithFormatSpecifier(argValue: string | number | boolean | RegExp | null, str: string): boolean;
|
|
32
|
+
declare const callExpressionArgMatchesString: (arg: CallExpression['arguments'][number], str: string) => boolean;
|
|
33
|
+
declare const testMethodVariantEach: (path: ASTPath<CallExpression>, testMethods: Set<string>) => boolean;
|
|
34
|
+
declare const hasJSXAttributesByName: (j: core.JSCodeshift, element: ASTPath<any>, attributeName: string) => boolean;
|
|
35
|
+
declare const doesIdentifierExist: (j: core.JSCodeshift, base: Collection<any>, name: string) => boolean;
|
|
36
|
+
declare function removeImport(j: core.JSCodeshift, base: Collection<any>, packageName: string): void;
|
|
37
|
+
declare function tryCreateImport(j: core.JSCodeshift, base: Collection<any>, relativeToPackage: string, packageName: string, shouldBeTypeImport?: boolean): void;
|
|
38
|
+
declare function addToImport(j: core.JSCodeshift, base: Collection<any>, importSpecifier: ImportSpecifier | ImportDefaultSpecifier, packageName: string): void;
|
|
39
|
+
declare const shiftDefaultImport: (j: core.JSCodeshift, base: Collection<any>, defaultName: string, oldPackagePath: string, newPackagePath: string) => void;
|
|
40
|
+
declare function getSafeImportName({ j, base, currentDefaultSpecifierName, desiredName, fallbackName, }: {
|
|
41
|
+
j: core.JSCodeshift;
|
|
42
|
+
base: Collection<any>;
|
|
43
|
+
currentDefaultSpecifierName: string | null;
|
|
44
|
+
desiredName: string;
|
|
45
|
+
fallbackName: string;
|
|
46
|
+
}): string;
|
|
47
|
+
export { getDefaultSpecifier, getNamedSpecifier, getJSXAttributesByName, hasJSXAttributesByName, hasImportDeclaration, hasImportDeclarationFromAnyPackageEntrypoint, addCommentBefore, addCommentToStartOfFile, doesIdentifierExist, removeImport, tryCreateImport, addToImport, shiftDefaultImport, isEmpty, clean, debug, callExpressionArgMatchesString, testMethodVariantEach, getSafeImportName, getDynamicImportName, addDynamicImport, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/codemod-utils",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.3",
|
|
4
4
|
"author": "Atlassian Pty Ltd",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": " jscodeshift-compatible codemod utilities",
|
|
@@ -17,6 +17,13 @@
|
|
|
17
17
|
"module": "dist/esm/index.js",
|
|
18
18
|
"module:es2019": "dist/es2019/index.js",
|
|
19
19
|
"types": "dist/types/index.d.ts",
|
|
20
|
+
"typesVersions": {
|
|
21
|
+
">=4.0 <4.5": {
|
|
22
|
+
"*": [
|
|
23
|
+
"dist/types-ts4.0/*"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
20
27
|
"sideEffects": false,
|
|
21
28
|
"atlaskit:src": "src/index.ts",
|
|
22
29
|
"af:exports": {
|
|
@@ -30,7 +37,7 @@
|
|
|
30
37
|
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
31
38
|
"@types/jscodeshift": "^0.11.0",
|
|
32
39
|
"jscodeshift": "^0.13.0",
|
|
33
|
-
"typescript": "4.
|
|
40
|
+
"typescript": "4.5.5"
|
|
34
41
|
},
|
|
35
42
|
"techstack": {
|
|
36
43
|
"@atlassian/frontend": {
|
package/report.api.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
## API Report File for "@atlaskit/codemod-utils"
|
|
1
|
+
## API Report File for "@atlaskit/codemod-utils"
|
|
2
2
|
|
|
3
|
-
> Do not edit this file.
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
<!--
|
|
6
|
+
Generated API Report version: 2.0
|
|
7
|
+
-->
|
|
4
8
|
|
|
5
9
|
[Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports)
|
|
6
10
|
|
|
@@ -21,7 +25,8 @@ import { Program } from 'jscodeshift';
|
|
|
21
25
|
import { VariableDeclaration } from 'jscodeshift';
|
|
22
26
|
import { VariableDeclarator } from 'jscodeshift';
|
|
23
27
|
|
|
24
|
-
|
|
28
|
+
// @public (undocumented)
|
|
29
|
+
export function addCommentBefore(
|
|
25
30
|
j: core.JSCodeshift,
|
|
26
31
|
target:
|
|
27
32
|
| Collection<Program>
|
|
@@ -35,7 +40,8 @@ export declare function addCommentBefore(
|
|
|
35
40
|
messagePrefix?: string,
|
|
36
41
|
): void;
|
|
37
42
|
|
|
38
|
-
|
|
43
|
+
// @public (undocumented)
|
|
44
|
+
export const addCommentToStartOfFile: ({
|
|
39
45
|
j,
|
|
40
46
|
base,
|
|
41
47
|
message,
|
|
@@ -45,46 +51,53 @@ export declare const addCommentToStartOfFile: ({
|
|
|
45
51
|
message: string;
|
|
46
52
|
}) => void;
|
|
47
53
|
|
|
48
|
-
|
|
54
|
+
// @public (undocumented)
|
|
55
|
+
export const addDynamicImport: (
|
|
49
56
|
j: core.JSCodeshift,
|
|
50
57
|
target: Collection<VariableDeclaration>,
|
|
51
58
|
name: string,
|
|
52
59
|
packageEndpoint: string,
|
|
53
60
|
) => void;
|
|
54
61
|
|
|
55
|
-
|
|
62
|
+
// @public (undocumented)
|
|
63
|
+
export function addToImport(
|
|
56
64
|
j: core.JSCodeshift,
|
|
57
65
|
base: Collection<any>,
|
|
58
66
|
importSpecifier: ImportSpecifier | ImportDefaultSpecifier,
|
|
59
67
|
packageName: string,
|
|
60
68
|
): void;
|
|
61
69
|
|
|
62
|
-
|
|
70
|
+
// @public (undocumented)
|
|
71
|
+
export const callExpressionArgMatchesString: (
|
|
63
72
|
arg: CallExpression['arguments'][number],
|
|
64
73
|
str: string,
|
|
65
74
|
) => boolean;
|
|
66
75
|
|
|
67
|
-
|
|
76
|
+
// @public (undocumented)
|
|
77
|
+
export const changeImportEntryPoint: (
|
|
68
78
|
oldPackageName: string,
|
|
69
79
|
importToConvert: string,
|
|
70
80
|
newPackageName: string,
|
|
71
81
|
shouldBeTypeImport?: boolean | undefined,
|
|
72
82
|
) => (j: core.JSCodeshift, root: Collection<Node>) => void;
|
|
73
83
|
|
|
74
|
-
|
|
84
|
+
// @public (undocumented)
|
|
85
|
+
export const createConvertFuncFor: (
|
|
75
86
|
component: string,
|
|
76
87
|
from: string,
|
|
77
88
|
to: string,
|
|
78
89
|
predicate?: ((value: any) => boolean) | undefined,
|
|
79
90
|
) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
80
91
|
|
|
81
|
-
|
|
92
|
+
// @public (undocumented)
|
|
93
|
+
export const createRemoveFuncAddCommentFor: (
|
|
82
94
|
component: string,
|
|
83
95
|
prop: string,
|
|
84
96
|
comment?: string | undefined,
|
|
85
97
|
) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
86
98
|
|
|
87
|
-
|
|
99
|
+
// @public (undocumented)
|
|
100
|
+
export const createRemoveFuncFor: (
|
|
88
101
|
component: string,
|
|
89
102
|
importName: string,
|
|
90
103
|
prop: string,
|
|
@@ -92,76 +105,88 @@ export declare const createRemoveFuncFor: (
|
|
|
92
105
|
comment?: string | undefined,
|
|
93
106
|
) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
94
107
|
|
|
95
|
-
|
|
108
|
+
// @public (undocumented)
|
|
109
|
+
export const createRenameFuncFor: (
|
|
96
110
|
component: string,
|
|
97
111
|
from: string,
|
|
98
112
|
to: string,
|
|
99
113
|
) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
100
114
|
|
|
101
|
-
|
|
115
|
+
// @public (undocumented)
|
|
116
|
+
export const createRenameImportFor: (
|
|
102
117
|
component: string,
|
|
103
118
|
from: string,
|
|
104
119
|
to: string,
|
|
105
120
|
) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
106
121
|
|
|
107
|
-
|
|
122
|
+
// @public (undocumented)
|
|
123
|
+
export const createRenameJSXFunc: (
|
|
108
124
|
packagePath: string,
|
|
109
125
|
from: string,
|
|
110
126
|
to: string,
|
|
111
127
|
fallback?: string | undefined,
|
|
112
128
|
) => (j: core.JSCodeshift, source: any) => void;
|
|
113
129
|
|
|
114
|
-
|
|
130
|
+
// @public (undocumented)
|
|
131
|
+
export const createTransformer: (
|
|
115
132
|
migrates: ((j: core.JSCodeshift, source: Collection<Node>) => void)[],
|
|
116
133
|
shouldApplyTransform?:
|
|
117
134
|
| ((j: core.JSCodeshift, source: Collection<Node>) => boolean)
|
|
118
135
|
| undefined,
|
|
119
136
|
) => (fileInfo: FileInfo, { jscodeshift: j }: API, options: Options) => string;
|
|
120
137
|
|
|
121
|
-
|
|
138
|
+
// @public (undocumented)
|
|
139
|
+
export const doesIdentifierExist: (
|
|
122
140
|
j: core.JSCodeshift,
|
|
123
141
|
base: Collection<any>,
|
|
124
142
|
name: string,
|
|
125
143
|
) => boolean;
|
|
126
144
|
|
|
127
|
-
|
|
145
|
+
// @public (undocumented)
|
|
146
|
+
export const elevateComponentToNewEntryPoint: (
|
|
128
147
|
pkg: string,
|
|
129
148
|
toPkg: string,
|
|
130
149
|
innerElementName: string,
|
|
131
150
|
) => (j: core.JSCodeshift, root: any) => void;
|
|
132
151
|
|
|
133
|
-
|
|
152
|
+
// @public (undocumented)
|
|
153
|
+
export const flattenCertainChildPropsAsProp: (
|
|
134
154
|
component: string,
|
|
135
155
|
propName: string,
|
|
136
156
|
childProps: string[],
|
|
137
157
|
) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
138
158
|
|
|
139
|
-
|
|
159
|
+
// @public (undocumented)
|
|
160
|
+
export const getDefaultSpecifier: (
|
|
140
161
|
j: core.JSCodeshift,
|
|
141
162
|
source: Collection<Node>,
|
|
142
163
|
specifier: string,
|
|
143
164
|
) => string | null;
|
|
144
165
|
|
|
145
|
-
|
|
166
|
+
// @public (undocumented)
|
|
167
|
+
export const getDynamicImportName: (
|
|
146
168
|
j: core.JSCodeshift,
|
|
147
169
|
source: Collection<any>,
|
|
148
170
|
importPath: string,
|
|
149
171
|
) => string | null;
|
|
150
172
|
|
|
151
|
-
|
|
173
|
+
// @public (undocumented)
|
|
174
|
+
export const getJSXAttributesByName: (
|
|
152
175
|
j: core.JSCodeshift,
|
|
153
176
|
element: ASTPath<any>,
|
|
154
177
|
attributeName: string,
|
|
155
178
|
) => Collection<JSXAttribute>;
|
|
156
179
|
|
|
157
|
-
|
|
180
|
+
// @public (undocumented)
|
|
181
|
+
export function getNamedSpecifier(
|
|
158
182
|
j: core.JSCodeshift,
|
|
159
183
|
source: Collection<Node>,
|
|
160
184
|
specifier: string,
|
|
161
185
|
importName: string,
|
|
162
186
|
): string | null;
|
|
163
187
|
|
|
164
|
-
|
|
188
|
+
// @public (undocumented)
|
|
189
|
+
export function getSafeImportName({
|
|
165
190
|
j,
|
|
166
191
|
base,
|
|
167
192
|
currentDefaultSpecifierName,
|
|
@@ -175,47 +200,55 @@ export declare function getSafeImportName({
|
|
|
175
200
|
fallbackName: string;
|
|
176
201
|
}): string;
|
|
177
202
|
|
|
178
|
-
|
|
203
|
+
// @public (undocumented)
|
|
204
|
+
export const hasImportDeclaration: (
|
|
179
205
|
j: core.JSCodeshift,
|
|
180
206
|
source: Collection<Node>,
|
|
181
207
|
importPath: string,
|
|
182
208
|
) => boolean;
|
|
183
209
|
|
|
184
|
-
|
|
210
|
+
// @public (undocumented)
|
|
211
|
+
export const hasImportDeclarationFromAnyPackageEntrypoint: (
|
|
185
212
|
j: core.JSCodeshift,
|
|
186
213
|
source: Collection<Node>,
|
|
187
214
|
packageName: string,
|
|
188
215
|
) => boolean;
|
|
189
216
|
|
|
190
|
-
|
|
217
|
+
// @public (undocumented)
|
|
218
|
+
export const hasJSXAttributesByName: (
|
|
191
219
|
j: core.JSCodeshift,
|
|
192
220
|
element: ASTPath<any>,
|
|
193
221
|
attributeName: string,
|
|
194
222
|
) => boolean;
|
|
195
223
|
|
|
196
|
-
|
|
224
|
+
// @public (undocumented)
|
|
225
|
+
export function removeImport(
|
|
197
226
|
j: core.JSCodeshift,
|
|
198
227
|
base: Collection<any>,
|
|
199
228
|
packageName: string,
|
|
200
229
|
): void;
|
|
201
230
|
|
|
202
|
-
|
|
231
|
+
// @public (undocumented)
|
|
232
|
+
export const renameNamedImportWithAliasName: (
|
|
203
233
|
component: string,
|
|
204
234
|
from: string,
|
|
205
235
|
to: string,
|
|
206
236
|
) => (j: core.JSCodeshift, source: Collection<Node>) => void;
|
|
207
237
|
|
|
208
|
-
|
|
238
|
+
// @public (undocumented)
|
|
239
|
+
export const replaceImportStatementFor: (
|
|
209
240
|
pkg: string,
|
|
210
241
|
convertMap: any,
|
|
211
242
|
) => (j: core.JSCodeshift, root: Collection<Node>) => void;
|
|
212
243
|
|
|
213
|
-
|
|
244
|
+
// @public (undocumented)
|
|
245
|
+
export const testMethodVariantEach: (
|
|
214
246
|
path: ASTPath<CallExpression>,
|
|
215
247
|
testMethods: Set<string>,
|
|
216
248
|
) => boolean;
|
|
217
249
|
|
|
218
|
-
|
|
250
|
+
// @public (undocumented)
|
|
251
|
+
export function tryCreateImport(
|
|
219
252
|
j: core.JSCodeshift,
|
|
220
253
|
base: Collection<any>,
|
|
221
254
|
relativeToPackage: string,
|
|
@@ -223,5 +256,5 @@ export declare function tryCreateImport(
|
|
|
223
256
|
shouldBeTypeImport?: boolean,
|
|
224
257
|
): void;
|
|
225
258
|
|
|
226
|
-
|
|
259
|
+
// (No @packageDocumentation comment for this package)
|
|
227
260
|
```
|