@atlaskit/codemod-utils 4.1.1 → 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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/codemod-utils
2
2
 
3
+ ## 4.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`8cc2f888c83`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8cc2f888c83) - Upgrade Typescript from `4.3.5` to `4.5.5`
8
+
9
+ ## 4.1.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`8d4228767b0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8d4228767b0) - Upgrade Typescript from `4.2.4` to `4.3.5`.
14
+
3
15
  ## 4.1.1
4
16
 
5
17
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/codemod-utils",
3
- "version": "4.1.1",
3
+ "version": "4.1.3",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/codemod-utils",
3
- "version": "4.1.1",
3
+ "version": "4.1.3",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/codemod-utils",
3
- "version": "4.1.1",
3
+ "version": "4.1.3",
4
4
  "sideEffects": false
5
5
  }
@@ -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.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.2.4"
40
+ "typescript": "4.5.5"
34
41
  },
35
42
  "techstack": {
36
43
  "@atlassian/frontend": {
package/report.api.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
4
 
5
+ <!--
6
+ Generated API Report version: 2.0
7
+ -->
8
+
9
+ [Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports)
10
+
5
11
  ```ts
6
12
  import { API } from 'jscodeshift';
7
13
  import { ASTPath } from 'jscodeshift';
@@ -19,7 +25,8 @@ import { Program } from 'jscodeshift';
19
25
  import { VariableDeclaration } from 'jscodeshift';
20
26
  import { VariableDeclarator } from 'jscodeshift';
21
27
 
22
- export declare function addCommentBefore(
28
+ // @public (undocumented)
29
+ export function addCommentBefore(
23
30
  j: core.JSCodeshift,
24
31
  target:
25
32
  | Collection<Program>
@@ -33,7 +40,8 @@ export declare function addCommentBefore(
33
40
  messagePrefix?: string,
34
41
  ): void;
35
42
 
36
- export declare const addCommentToStartOfFile: ({
43
+ // @public (undocumented)
44
+ export const addCommentToStartOfFile: ({
37
45
  j,
38
46
  base,
39
47
  message,
@@ -43,46 +51,53 @@ export declare const addCommentToStartOfFile: ({
43
51
  message: string;
44
52
  }) => void;
45
53
 
46
- export declare const addDynamicImport: (
54
+ // @public (undocumented)
55
+ export const addDynamicImport: (
47
56
  j: core.JSCodeshift,
48
57
  target: Collection<VariableDeclaration>,
49
58
  name: string,
50
59
  packageEndpoint: string,
51
60
  ) => void;
52
61
 
53
- export declare function addToImport(
62
+ // @public (undocumented)
63
+ export function addToImport(
54
64
  j: core.JSCodeshift,
55
65
  base: Collection<any>,
56
66
  importSpecifier: ImportSpecifier | ImportDefaultSpecifier,
57
67
  packageName: string,
58
68
  ): void;
59
69
 
60
- export declare const callExpressionArgMatchesString: (
70
+ // @public (undocumented)
71
+ export const callExpressionArgMatchesString: (
61
72
  arg: CallExpression['arguments'][number],
62
73
  str: string,
63
74
  ) => boolean;
64
75
 
65
- export declare const changeImportEntryPoint: (
76
+ // @public (undocumented)
77
+ export const changeImportEntryPoint: (
66
78
  oldPackageName: string,
67
79
  importToConvert: string,
68
80
  newPackageName: string,
69
81
  shouldBeTypeImport?: boolean | undefined,
70
82
  ) => (j: core.JSCodeshift, root: Collection<Node>) => void;
71
83
 
72
- export declare const createConvertFuncFor: (
84
+ // @public (undocumented)
85
+ export const createConvertFuncFor: (
73
86
  component: string,
74
87
  from: string,
75
88
  to: string,
76
89
  predicate?: ((value: any) => boolean) | undefined,
77
90
  ) => (j: core.JSCodeshift, source: Collection<Node>) => void;
78
91
 
79
- export declare const createRemoveFuncAddCommentFor: (
92
+ // @public (undocumented)
93
+ export const createRemoveFuncAddCommentFor: (
80
94
  component: string,
81
95
  prop: string,
82
96
  comment?: string | undefined,
83
97
  ) => (j: core.JSCodeshift, source: Collection<Node>) => void;
84
98
 
85
- export declare const createRemoveFuncFor: (
99
+ // @public (undocumented)
100
+ export const createRemoveFuncFor: (
86
101
  component: string,
87
102
  importName: string,
88
103
  prop: string,
@@ -90,76 +105,88 @@ export declare const createRemoveFuncFor: (
90
105
  comment?: string | undefined,
91
106
  ) => (j: core.JSCodeshift, source: Collection<Node>) => void;
92
107
 
93
- export declare const createRenameFuncFor: (
108
+ // @public (undocumented)
109
+ export const createRenameFuncFor: (
94
110
  component: string,
95
111
  from: string,
96
112
  to: string,
97
113
  ) => (j: core.JSCodeshift, source: Collection<Node>) => void;
98
114
 
99
- export declare const createRenameImportFor: (
115
+ // @public (undocumented)
116
+ export const createRenameImportFor: (
100
117
  component: string,
101
118
  from: string,
102
119
  to: string,
103
120
  ) => (j: core.JSCodeshift, source: Collection<Node>) => void;
104
121
 
105
- export declare const createRenameJSXFunc: (
122
+ // @public (undocumented)
123
+ export const createRenameJSXFunc: (
106
124
  packagePath: string,
107
125
  from: string,
108
126
  to: string,
109
127
  fallback?: string | undefined,
110
128
  ) => (j: core.JSCodeshift, source: any) => void;
111
129
 
112
- export declare const createTransformer: (
130
+ // @public (undocumented)
131
+ export const createTransformer: (
113
132
  migrates: ((j: core.JSCodeshift, source: Collection<Node>) => void)[],
114
133
  shouldApplyTransform?:
115
134
  | ((j: core.JSCodeshift, source: Collection<Node>) => boolean)
116
135
  | undefined,
117
136
  ) => (fileInfo: FileInfo, { jscodeshift: j }: API, options: Options) => string;
118
137
 
119
- export declare const doesIdentifierExist: (
138
+ // @public (undocumented)
139
+ export const doesIdentifierExist: (
120
140
  j: core.JSCodeshift,
121
141
  base: Collection<any>,
122
142
  name: string,
123
143
  ) => boolean;
124
144
 
125
- export declare const elevateComponentToNewEntryPoint: (
145
+ // @public (undocumented)
146
+ export const elevateComponentToNewEntryPoint: (
126
147
  pkg: string,
127
148
  toPkg: string,
128
149
  innerElementName: string,
129
150
  ) => (j: core.JSCodeshift, root: any) => void;
130
151
 
131
- export declare const flattenCertainChildPropsAsProp: (
152
+ // @public (undocumented)
153
+ export const flattenCertainChildPropsAsProp: (
132
154
  component: string,
133
155
  propName: string,
134
156
  childProps: string[],
135
157
  ) => (j: core.JSCodeshift, source: Collection<Node>) => void;
136
158
 
137
- export declare const getDefaultSpecifier: (
159
+ // @public (undocumented)
160
+ export const getDefaultSpecifier: (
138
161
  j: core.JSCodeshift,
139
162
  source: Collection<Node>,
140
163
  specifier: string,
141
164
  ) => string | null;
142
165
 
143
- export declare const getDynamicImportName: (
166
+ // @public (undocumented)
167
+ export const getDynamicImportName: (
144
168
  j: core.JSCodeshift,
145
169
  source: Collection<any>,
146
170
  importPath: string,
147
171
  ) => string | null;
148
172
 
149
- export declare const getJSXAttributesByName: (
173
+ // @public (undocumented)
174
+ export const getJSXAttributesByName: (
150
175
  j: core.JSCodeshift,
151
176
  element: ASTPath<any>,
152
177
  attributeName: string,
153
178
  ) => Collection<JSXAttribute>;
154
179
 
155
- export declare function getNamedSpecifier(
180
+ // @public (undocumented)
181
+ export function getNamedSpecifier(
156
182
  j: core.JSCodeshift,
157
183
  source: Collection<Node>,
158
184
  specifier: string,
159
185
  importName: string,
160
186
  ): string | null;
161
187
 
162
- export declare function getSafeImportName({
188
+ // @public (undocumented)
189
+ export function getSafeImportName({
163
190
  j,
164
191
  base,
165
192
  currentDefaultSpecifierName,
@@ -173,47 +200,55 @@ export declare function getSafeImportName({
173
200
  fallbackName: string;
174
201
  }): string;
175
202
 
176
- export declare const hasImportDeclaration: (
203
+ // @public (undocumented)
204
+ export const hasImportDeclaration: (
177
205
  j: core.JSCodeshift,
178
206
  source: Collection<Node>,
179
207
  importPath: string,
180
208
  ) => boolean;
181
209
 
182
- export declare const hasImportDeclarationFromAnyPackageEntrypoint: (
210
+ // @public (undocumented)
211
+ export const hasImportDeclarationFromAnyPackageEntrypoint: (
183
212
  j: core.JSCodeshift,
184
213
  source: Collection<Node>,
185
214
  packageName: string,
186
215
  ) => boolean;
187
216
 
188
- export declare const hasJSXAttributesByName: (
217
+ // @public (undocumented)
218
+ export const hasJSXAttributesByName: (
189
219
  j: core.JSCodeshift,
190
220
  element: ASTPath<any>,
191
221
  attributeName: string,
192
222
  ) => boolean;
193
223
 
194
- export declare function removeImport(
224
+ // @public (undocumented)
225
+ export function removeImport(
195
226
  j: core.JSCodeshift,
196
227
  base: Collection<any>,
197
228
  packageName: string,
198
229
  ): void;
199
230
 
200
- export declare const renameNamedImportWithAliasName: (
231
+ // @public (undocumented)
232
+ export const renameNamedImportWithAliasName: (
201
233
  component: string,
202
234
  from: string,
203
235
  to: string,
204
236
  ) => (j: core.JSCodeshift, source: Collection<Node>) => void;
205
237
 
206
- export declare const replaceImportStatementFor: (
238
+ // @public (undocumented)
239
+ export const replaceImportStatementFor: (
207
240
  pkg: string,
208
241
  convertMap: any,
209
242
  ) => (j: core.JSCodeshift, root: Collection<Node>) => void;
210
243
 
211
- export declare const testMethodVariantEach: (
244
+ // @public (undocumented)
245
+ export const testMethodVariantEach: (
212
246
  path: ASTPath<CallExpression>,
213
247
  testMethods: Set<string>,
214
248
  ) => boolean;
215
249
 
216
- export declare function tryCreateImport(
250
+ // @public (undocumented)
251
+ export function tryCreateImport(
217
252
  j: core.JSCodeshift,
218
253
  base: Collection<any>,
219
254
  relativeToPackage: string,
@@ -221,5 +256,5 @@ export declare function tryCreateImport(
221
256
  shouldBeTypeImport?: boolean,
222
257
  ): void;
223
258
 
224
- export {};
259
+ // (No @packageDocumentation comment for this package)
225
260
  ```