@atlaskit/codemod-utils 4.2.0 → 4.2.2

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.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure legacy types are published for TS 4.5-4.8
8
+
9
+ ## 4.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`41fae2c6f68`](https://bitbucket.org/atlassian/atlassian-frontend/commits/41fae2c6f68) - Upgrade Typescript from `4.5.5` to `4.9.5`
14
+
3
15
  ## 4.2.0
4
16
 
5
17
  ### Minor Changes
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/codemod-utils",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/codemod-utils",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/codemod-utils",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,6 +1,6 @@
1
1
  import core, { API, ASTPath, FileInfo, Options } from 'jscodeshift';
2
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;
3
+ declare const createRemoveFuncFor: (component: string, importName: string, prop: string, predicate?: (j: core.JSCodeshift, element: ASTPath<any>) => boolean, comment?: string) => (j: core.JSCodeshift, source: Collection<Node>) => void;
4
4
  declare const createRenameFuncFor: (component: string, from: string, to: string) => (j: core.JSCodeshift, source: Collection<Node>) => void;
5
5
  declare const createConvertFuncFor: (component: string, from: string, to: string, predicate?: ((value: any) => boolean) | undefined) => (j: core.JSCodeshift, source: Collection<Node>) => void;
6
6
  declare const replaceImportStatementFor: (pkg: string, convertMap: any) => (j: core.JSCodeshift, root: Collection<Node>) => void;
@@ -9,7 +9,7 @@ declare const createTransformer: (migrates: ((j: core.JSCodeshift, source: Colle
9
9
  declare const elevateComponentToNewEntryPoint: (pkg: string, toPkg: string, innerElementName: string) => (j: core.JSCodeshift, root: any) => void;
10
10
  declare const flattenCertainChildPropsAsProp: (component: string, propName: string, childProps: string[]) => (j: core.JSCodeshift, source: Collection<Node>) => void;
11
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;
12
+ declare const createRemoveFuncAddCommentFor: (component: string, prop: string, comment?: string) => (j: core.JSCodeshift, source: Collection<Node>) => void;
13
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;
14
+ declare const changeImportEntryPoint: (oldPackageName: string, importToConvert: string, newPackageName: string, shouldBeTypeImport?: boolean) => (j: core.JSCodeshift, root: Collection<Node>) => void;
15
15
  export { createRenameFuncFor, createConvertFuncFor, createRenameImportFor, createRemoveFuncFor, replaceImportStatementFor, elevateComponentToNewEntryPoint, createTransformer, renameNamedImportWithAliasName, flattenCertainChildPropsAsProp, createRenameJSXFunc, createRemoveFuncAddCommentFor, changeImportEntryPoint, };
@@ -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) => (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) => (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) => (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.2.0",
3
+ "version": "4.2.2",
4
4
  "author": "Atlassian Pty Ltd",
5
5
  "license": "Apache-2.0",
6
6
  "description": " jscodeshift-compatible codemod utilities",
@@ -17,6 +17,14 @@
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.5 <4.9": {
22
+ "*": [
23
+ "dist/types-ts4.5/*",
24
+ "dist/types-ts4.5/index.d.ts"
25
+ ]
26
+ }
27
+ },
20
28
  "sideEffects": false,
21
29
  "atlaskit:src": "src/index.ts",
22
30
  "af:exports": {
@@ -30,7 +38,7 @@
30
38
  "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
31
39
  "@types/jscodeshift": "^0.11.0",
32
40
  "jscodeshift": "^0.13.0",
33
- "typescript": "4.5.5"
41
+ "typescript": "~4.9.5"
34
42
  },
35
43
  "techstack": {
36
44
  "@atlassian/frontend": {
package/report.api.md CHANGED
@@ -84,7 +84,7 @@ export const changeImportEntryPoint: (
84
84
  oldPackageName: string,
85
85
  importToConvert: string,
86
86
  newPackageName: string,
87
- shouldBeTypeImport?: boolean | undefined,
87
+ shouldBeTypeImport?: boolean,
88
88
  ) => (j: core.JSCodeshift, root: Collection<Node>) => void;
89
89
 
90
90
  // @public (undocumented)
@@ -99,7 +99,7 @@ export const createConvertFuncFor: (
99
99
  export const createRemoveFuncAddCommentFor: (
100
100
  component: string,
101
101
  prop: string,
102
- comment?: string | undefined,
102
+ comment?: string,
103
103
  ) => (j: core.JSCodeshift, source: Collection<Node>) => void;
104
104
 
105
105
  // @public (undocumented)
@@ -108,7 +108,7 @@ export const createRemoveFuncFor: (
108
108
  importName: string,
109
109
  prop: string,
110
110
  predicate?: (j: core.JSCodeshift, element: ASTPath<any>) => boolean,
111
- comment?: string | undefined,
111
+ comment?: string,
112
112
  ) => (j: core.JSCodeshift, source: Collection<Node>) => void;
113
113
 
114
114
  // @public (undocumented)
@@ -0,0 +1,122 @@
1
+ ## API Report File for "@atlaskit/codemod-utils"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ import { API } from 'jscodeshift';
8
+ import { ASTPath } from 'jscodeshift';
9
+ import { CallExpression } from 'jscodeshift';
10
+ import { Collection } from 'jscodeshift/src/Collection';
11
+ import core from 'jscodeshift';
12
+ import { FileInfo } from 'jscodeshift';
13
+ import { ImportDeclaration } from 'jscodeshift';
14
+ import { ImportDefaultSpecifier } from 'jscodeshift';
15
+ import { ImportSpecifier } from 'jscodeshift';
16
+ import { JSXAttribute } from 'jscodeshift';
17
+ import { JSXElement } from 'jscodeshift';
18
+ import { Options } from 'jscodeshift';
19
+ import { Program } from 'jscodeshift';
20
+ import { VariableDeclaration } from 'jscodeshift';
21
+ import { VariableDeclarator } from 'jscodeshift';
22
+
23
+ // @public (undocumented)
24
+ export function addCommentBefore(j: core.JSCodeshift, target: Collection<CallExpression> | Collection<ImportDeclaration> | Collection<JSXAttribute> | Collection<JSXElement> | Collection<Program> | Collection<VariableDeclarator>, message: string, commentType?: 'block' | 'line', messagePrefix?: string): void;
25
+
26
+ // @public (undocumented)
27
+ export const addCommentToStartOfFile: ({ j, base, message, }: {
28
+ j: core.JSCodeshift;
29
+ base: Collection<Node>;
30
+ message: string;
31
+ }) => void;
32
+
33
+ // @public (undocumented)
34
+ export const addDynamicImport: (j: core.JSCodeshift, target: Collection<VariableDeclaration>, name: string, packageEndpoint: string) => void;
35
+
36
+ // @public (undocumented)
37
+ export function addToImport(j: core.JSCodeshift, base: Collection<any>, importSpecifier: ImportDefaultSpecifier | ImportSpecifier, packageName: string): void;
38
+
39
+ // @public (undocumented)
40
+ export const callExpressionArgMatchesString: (arg: CallExpression['arguments'][number], str: string) => boolean;
41
+
42
+ // @public (undocumented)
43
+ export const changeImportEntryPoint: (oldPackageName: string, importToConvert: string, newPackageName: string, shouldBeTypeImport?: boolean) => (j: core.JSCodeshift, root: Collection<Node>) => void;
44
+
45
+ // @public (undocumented)
46
+ export const createConvertFuncFor: (component: string, from: string, to: string, predicate?: ((value: any) => boolean) | undefined) => (j: core.JSCodeshift, source: Collection<Node>) => void;
47
+
48
+ // @public (undocumented)
49
+ export const createRemoveFuncAddCommentFor: (component: string, prop: string, comment?: string) => (j: core.JSCodeshift, source: Collection<Node>) => void;
50
+
51
+ // @public (undocumented)
52
+ export const createRemoveFuncFor: (component: string, importName: string, prop: string, predicate?: (j: core.JSCodeshift, element: ASTPath<any>) => boolean, comment?: string) => (j: core.JSCodeshift, source: Collection<Node>) => void;
53
+
54
+ // @public (undocumented)
55
+ export const createRenameFuncFor: (component: string, from: string, to: string) => (j: core.JSCodeshift, source: Collection<Node>) => void;
56
+
57
+ // @public (undocumented)
58
+ export const createRenameImportFor: (component: string, from: string, to: string) => (j: core.JSCodeshift, source: Collection<Node>) => void;
59
+
60
+ // @public (undocumented)
61
+ export const createRenameJSXFunc: (packagePath: string, from: string, to: string, fallback?: string | undefined) => (j: core.JSCodeshift, source: any) => void;
62
+
63
+ // @public (undocumented)
64
+ export 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;
65
+
66
+ // @public (undocumented)
67
+ export const doesIdentifierExist: (j: core.JSCodeshift, base: Collection<any>, name: string) => boolean;
68
+
69
+ // @public (undocumented)
70
+ export const elevateComponentToNewEntryPoint: (pkg: string, toPkg: string, innerElementName: string) => (j: core.JSCodeshift, root: any) => void;
71
+
72
+ // @public (undocumented)
73
+ export const flattenCertainChildPropsAsProp: (component: string, propName: string, childProps: string[]) => (j: core.JSCodeshift, source: Collection<Node>) => void;
74
+
75
+ // @public (undocumented)
76
+ export const getDefaultSpecifier: (j: core.JSCodeshift, source: Collection<Node>, specifier: string) => null | string;
77
+
78
+ // @public (undocumented)
79
+ export const getDynamicImportName: (j: core.JSCodeshift, source: Collection<any>, importPath: string) => null | string;
80
+
81
+ // @public (undocumented)
82
+ export const getJSXAttributesByName: (j: core.JSCodeshift, element: ASTPath<any>, attributeName: string) => Collection<JSXAttribute>;
83
+
84
+ // @public (undocumented)
85
+ export function getNamedSpecifier(j: core.JSCodeshift, source: Collection<Node>, specifier: string, importName: string): null | string;
86
+
87
+ // @public (undocumented)
88
+ export function getSafeImportName({ j, base, currentDefaultSpecifierName, desiredName, fallbackName, }: {
89
+ j: core.JSCodeshift;
90
+ base: Collection<any>;
91
+ currentDefaultSpecifierName: null | string;
92
+ desiredName: string;
93
+ fallbackName: string;
94
+ }): string;
95
+
96
+ // @public (undocumented)
97
+ export const hasImportDeclaration: (j: core.JSCodeshift, source: Collection<Node>, importPath: string) => boolean;
98
+
99
+ // @public (undocumented)
100
+ export const hasImportDeclarationFromAnyPackageEntrypoint: (j: core.JSCodeshift, source: Collection<Node>, packageName: string) => boolean;
101
+
102
+ // @public (undocumented)
103
+ export const hasJSXAttributesByName: (j: core.JSCodeshift, element: ASTPath<any>, attributeName: string) => boolean;
104
+
105
+ // @public (undocumented)
106
+ export function removeImport(j: core.JSCodeshift, base: Collection<any>, packageName: string): void;
107
+
108
+ // @public (undocumented)
109
+ export const renameNamedImportWithAliasName: (component: string, from: string, to: string) => (j: core.JSCodeshift, source: Collection<Node>) => void;
110
+
111
+ // @public (undocumented)
112
+ export const replaceImportStatementFor: (pkg: string, convertMap: any) => (j: core.JSCodeshift, root: Collection<Node>) => void;
113
+
114
+ // @public (undocumented)
115
+ export const testMethodVariantEach: (path: ASTPath<CallExpression>, testMethods: Set<string>) => boolean;
116
+
117
+ // @public (undocumented)
118
+ export function tryCreateImport(j: core.JSCodeshift, base: Collection<any>, relativeToPackage: string, packageName: string, shouldBeTypeImport?: boolean): void;
119
+
120
+ // (No @packageDocumentation comment for this package)
121
+
122
+ ```