@atlaskit/codemod-utils 4.2.1 → 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 +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.5/index.d.ts +2 -0
- package/dist/types-ts4.5/utils/index.d.ts +15 -0
- package/dist/types-ts4.5/utils/support.d.ts +47 -0
- package/package.json +1 -1
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) => (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, };
|