@atlaskit/icon 23.10.0 → 23.11.0
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 +49 -0
- package/core/align-center.d.ts +4 -1
- package/core/align-left.d.ts +4 -1
- package/core/align-right.d.ts +4 -1
- package/core/border-weight-medium.d.ts +4 -1
- package/core/border-weight-thick.d.ts +4 -1
- package/core/border-weight-thin.d.ts +4 -1
- package/core/content-align-center.d.ts +4 -1
- package/core/content-align-left.d.ts +4 -1
- package/core/content-align-right.d.ts +4 -1
- package/core/drag-handle-horizontal.d.ts +13 -0
- package/core/drag-handle-horizontal.js +31 -0
- package/core/drag-handle-vertical.d.ts +13 -0
- package/core/drag-handle-vertical.js +31 -0
- package/core/drag-handle.d.ts +4 -1
- package/core/drag-handle.js +2 -2
- package/core/migration/align-image-center--editor-align-image-center.d.ts +15 -0
- package/core/migration/align-image-center--editor-align-image-center.js +33 -0
- package/core/migration/align-image-left--editor-align-image-left.d.ts +15 -0
- package/core/migration/align-image-left--editor-align-image-left.js +33 -0
- package/core/migration/align-image-right--editor-align-image-right.d.ts +15 -0
- package/core/migration/align-image-right--editor-align-image-right.js +33 -0
- package/core/migration/align-text-center--editor-align-center.d.ts +15 -0
- package/core/migration/align-text-center--editor-align-center.js +33 -0
- package/core/migration/align-text-left--editor-align-left.d.ts +15 -0
- package/core/migration/align-text-left--editor-align-left.js +33 -0
- package/core/migration/align-text-right--editor-align-right.d.ts +15 -0
- package/core/migration/align-text-right--editor-align-right.js +33 -0
- package/core/migration/drag-handle--drag-handler.js +2 -2
- package/core/migration/drag-handle-vertical--drag-handler.d.ts +15 -0
- package/core/migration/drag-handle-vertical--drag-handler.js +33 -0
- package/core/migration/refresh.js +2 -2
- package/core/migration/stroke-weight-small--media-services-line.d.ts +15 -0
- package/core/migration/stroke-weight-small--media-services-line.js +33 -0
- package/core/refresh.js +3 -3
- package/dist/cjs/deprecated-core.js +57 -2
- package/dist/cjs/deprecated-utility.js +10 -2
- package/dist/cjs/metadata-core.js +80 -4
- package/dist/cjs/metadata-utility.js +26 -2
- package/dist/cjs/migration-map.js +48 -8
- package/dist/es2019/deprecated-core.js +57 -2
- package/dist/es2019/deprecated-utility.js +10 -2
- package/dist/es2019/metadata-core.js +80 -4
- package/dist/es2019/metadata-utility.js +26 -2
- package/dist/es2019/migration-map.js +48 -8
- package/dist/esm/deprecated-core.js +57 -2
- package/dist/esm/deprecated-utility.js +10 -2
- package/dist/esm/metadata-core.js +80 -4
- package/dist/esm/metadata-utility.js +26 -2
- package/dist/esm/migration-map.js +48 -8
- package/dist/types/deprecated-core.d.ts +1 -1
- package/dist/types/deprecated-utility.d.ts +1 -1
- package/dist/types/metadata-core.d.ts +1 -1
- package/dist/types/metadata-utility.d.ts +1 -1
- package/dist/types-ts4.5/deprecated-core.d.ts +1 -1
- package/dist/types-ts4.5/deprecated-utility.d.ts +1 -1
- package/dist/types-ts4.5/metadata-core.d.ts +1 -1
- package/dist/types-ts4.5/metadata-utility.d.ts +1 -1
- package/glyph/drag-handler.js +2 -2
- package/glyph/editor/align-center.js +2 -2
- package/glyph/editor/align-image-center.js +2 -2
- package/glyph/editor/align-image-left.js +2 -2
- package/glyph/editor/align-image-right.js +2 -2
- package/glyph/editor/align-left.js +2 -2
- package/glyph/editor/align-right.js +2 -2
- package/glyph/media-services/line.js +2 -2
- package/package.json +1 -1
- package/svgs/core/drag-handle-horizontal.svg +1 -0
- package/svgs/core/drag-handle-vertical.svg +1 -0
- package/svgs/core/refresh.svg +1 -1
- package/svgs/utility/drag-handle-horizontal.svg +1 -0
- package/svgs/utility/drag-handle-vertical.svg +1 -0
- package/utility/drag-handle-horizontal.d.ts +13 -0
- package/utility/drag-handle-horizontal.js +32 -0
- package/utility/drag-handle-vertical.d.ts +13 -0
- package/utility/drag-handle-vertical.js +32 -0
- package/utility/drag-handle.d.ts +4 -1
- package/utility/drag-handle.js +2 -2
- package/utility/migration/drag-handle--drag-handler.js +2 -2
- package/utility/migration/drag-handle-vertical--drag-handler.d.ts +15 -0
- package/utility/migration/drag-handle-vertical--drag-handler.js +33 -0
- package/codemods/21.2.0-metadata-entry.tsx +0 -111
- package/codemods/__tests__/21.2.0-metadata-entry.test.tsx +0 -126
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
* @codegen <<SignedSource::207c34ce1c830137342bd2bda8211fdb>>
|
|
4
|
+
* @codegenCommand yarn build:icon-glyphs
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { NewUtilityIconProps } from '@atlaskit/icon/base-new';
|
|
8
|
+
|
|
9
|
+
declare const DragHandleHorizontalIcon: {
|
|
10
|
+
(props: NewUtilityIconProps): JSX.Element;
|
|
11
|
+
displayName: string;
|
|
12
|
+
};
|
|
13
|
+
export default DragHandleHorizontalIcon;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
* @codegen <<SignedSource::8a1bad36676d1d31f8288ef8ad8a703e>>
|
|
4
|
+
* @codegenCommand yarn build:icon-glyphs
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "__esModule", {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
exports.default = void 0;
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
var _baseNew = _interopRequireDefault(require("@atlaskit/icon/base-new"));
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
/**
|
|
16
|
+
* ⚠️ EXPERIMENTAL ⚠️ - New icons are in alpha - and subject to change or removal in future minor or patch releases.
|
|
17
|
+
* Please reach out in #icon-contributions before using these in production.
|
|
18
|
+
*
|
|
19
|
+
* Icon: "DragHandleHorizontal".
|
|
20
|
+
* Category: utility
|
|
21
|
+
* Location: @atlaskit/icon
|
|
22
|
+
* Usage guidance: Reserved for draggable elements, like columns.
|
|
23
|
+
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/icon)
|
|
24
|
+
* - [Code](https://atlaskit.atlassian.com/packages/design-system/icon/docs/custom-icons)
|
|
25
|
+
*/
|
|
26
|
+
const DragHandleHorizontalIcon = props => /*#__PURE__*/_react.default.createElement(_baseNew.default, Object.assign({
|
|
27
|
+
dangerouslySetGlyph: `<path fill="currentcolor" d="M9.75 5a1.25 1.25 0 1 1 0-2.5 1.25 1.25 0 0 1 0 2.5m0 4.5a1.25 1.25 0 1 1 0-2.5 1.25 1.25 0 0 1 0 2.5M6 5a1.25 1.25 0 1 1 0-2.5A1.25 1.25 0 0 1 6 5m0 4.5A1.25 1.25 0 1 1 6 7a1.25 1.25 0 0 1 0 2.5M2.25 5a1.25 1.25 0 1 1 0-2.5 1.25 1.25 0 0 1 0 2.5m0 4.5a1.25 1.25 0 1 1 0-2.5 1.25 1.25 0 0 1 0 2.5"/>`,
|
|
28
|
+
type: 'utility'
|
|
29
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
30
|
+
}, props));
|
|
31
|
+
DragHandleHorizontalIcon.displayName = 'DragHandleHorizontalIcon';
|
|
32
|
+
var _default = exports.default = DragHandleHorizontalIcon;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
* @codegen <<SignedSource::e7cd56570cfd773f0727ff7d8664babe>>
|
|
4
|
+
* @codegenCommand yarn build:icon-glyphs
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { NewUtilityIconProps } from '@atlaskit/icon/base-new';
|
|
8
|
+
|
|
9
|
+
declare const DragHandleVerticalIcon: {
|
|
10
|
+
(props: NewUtilityIconProps): JSX.Element;
|
|
11
|
+
displayName: string;
|
|
12
|
+
};
|
|
13
|
+
export default DragHandleVerticalIcon;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
* @codegen <<SignedSource::c774d61f8c99d81f0dbd4a601b5a2640>>
|
|
4
|
+
* @codegenCommand yarn build:icon-glyphs
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "__esModule", {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
exports.default = void 0;
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
var _baseNew = _interopRequireDefault(require("@atlaskit/icon/base-new"));
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
/**
|
|
16
|
+
* ⚠️ EXPERIMENTAL ⚠️ - New icons are in alpha - and subject to change or removal in future minor or patch releases.
|
|
17
|
+
* Please reach out in #icon-contributions before using these in production.
|
|
18
|
+
*
|
|
19
|
+
* Icon: "DragHandleVertical".
|
|
20
|
+
* Category: utility
|
|
21
|
+
* Location: @atlaskit/icon
|
|
22
|
+
* Usage guidance: Reserved for draggable elements, like rows.
|
|
23
|
+
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/icon)
|
|
24
|
+
* - [Code](https://atlaskit.atlassian.com/packages/design-system/icon/docs/custom-icons)
|
|
25
|
+
*/
|
|
26
|
+
const DragHandleVerticalIcon = props => /*#__PURE__*/_react.default.createElement(_baseNew.default, Object.assign({
|
|
27
|
+
dangerouslySetGlyph: `<path fill="currentcolor" d="M5 2.25a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0m4.5 0a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0M5 6a1.25 1.25 0 1 1-2.5 0A1.25 1.25 0 0 1 5 6m4.5 0A1.25 1.25 0 1 1 7 6a1.25 1.25 0 0 1 2.5 0M5 9.75a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0m4.5 0a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0"/>`,
|
|
28
|
+
type: 'utility'
|
|
29
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
30
|
+
}, props));
|
|
31
|
+
DragHandleVerticalIcon.displayName = 'DragHandleVerticalIcon';
|
|
32
|
+
var _default = exports.default = DragHandleVerticalIcon;
|
package/utility/drag-handle.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::5c57eb6f9a340d8e7750b90915242067>>
|
|
4
4
|
* @codegenCommand yarn build:icon-glyphs
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { NewUtilityIconProps } from '@atlaskit/icon/base-new';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated The icon "drag-handle" is deprecated in favour of "drag-handle-vertical" from “@atlaskit/icon/utility”
|
|
11
|
+
*/
|
|
9
12
|
declare const DragHandleIcon: {
|
|
10
13
|
(props: NewUtilityIconProps): JSX.Element;
|
|
11
14
|
displayName: string;
|
package/utility/drag-handle.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::bd19f7355c1583637def5fcd8c5ced43>>
|
|
4
4
|
* @codegenCommand yarn build:icon-glyphs
|
|
5
5
|
*/
|
|
6
6
|
"use strict";
|
|
@@ -19,7 +19,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
19
19
|
* Icon: "DragHandle".
|
|
20
20
|
* Category: utility
|
|
21
21
|
* Location: @atlaskit/icon
|
|
22
|
-
* Usage guidance: Reserved for draggable elements.
|
|
22
|
+
* Usage guidance: Reserved for draggable elements, like rows.
|
|
23
23
|
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/icon)
|
|
24
24
|
* - [Code](https://atlaskit.atlassian.com/packages/design-system/icon/docs/custom-icons)
|
|
25
25
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::28f3eb3664044b93368e3fef7d78315a>>
|
|
4
4
|
* @codegenCommand yarn build:icon-glyphs
|
|
5
5
|
*/
|
|
6
6
|
"use strict";
|
|
@@ -21,7 +21,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
21
21
|
*
|
|
22
22
|
* Category: utility
|
|
23
23
|
* Location: @atlaskit/icon
|
|
24
|
-
* Usage guidance: Reserved for draggable elements.
|
|
24
|
+
* Usage guidance: Reserved for draggable elements, like rows.
|
|
25
25
|
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/icon)
|
|
26
26
|
* - [Code](https://atlaskit.atlassian.com/packages/design-system/icon/docs/custom-icons)
|
|
27
27
|
*/
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
* @codegen <<SignedSource::4faf2c4e8e8664ee6dcd8a52453ac578>>
|
|
4
|
+
* @codegenCommand yarn build:icon-glyphs
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import type { NewUtilityIconProps } from '@atlaskit/icon/base-new';
|
|
9
|
+
import Icon from '@atlaskit/icon/base-new';
|
|
10
|
+
|
|
11
|
+
declare const DragHandleVerticalIconMigration: {
|
|
12
|
+
(props: Omit<NewUtilityIconProps, | 'LEGACY_fallbackIcon'> ): JSX.Element;
|
|
13
|
+
displayName: string;
|
|
14
|
+
};
|
|
15
|
+
export default DragHandleVerticalIconMigration;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
* @codegen <<SignedSource::7dcab57e1a5296ed5da9181f33797fc0>>
|
|
4
|
+
* @codegenCommand yarn build:icon-glyphs
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "__esModule", {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
exports.default = void 0;
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
var _dragHandleVertical = _interopRequireDefault(require("@atlaskit/icon/utility/drag-handle-vertical"));
|
|
14
|
+
var _dragHandler = _interopRequireDefault(require("@atlaskit/icon/glyph/drag-handler"));
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
/**
|
|
17
|
+
* ⚠️ EXPERIMENTAL ⚠️ - New icons are in alpha - and subject to change or removal in future minor or patch releases.
|
|
18
|
+
*
|
|
19
|
+
* Migration Icon component for DragHandleVerticalIcon.
|
|
20
|
+
* This component is DragHandleVerticalIcon, with `UNSAFE_fallbackIcon` set to "DragHandlerIcon".
|
|
21
|
+
*
|
|
22
|
+
* Category: utility
|
|
23
|
+
* Location: @atlaskit/icon
|
|
24
|
+
* Usage guidance: Reserved for draggable elements, like rows.
|
|
25
|
+
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/icon)
|
|
26
|
+
* - [Code](https://atlaskit.atlassian.com/packages/design-system/icon/docs/custom-icons)
|
|
27
|
+
*/
|
|
28
|
+
const DragHandleVerticalIcon = props => /*#__PURE__*/_react.default.createElement(_dragHandleVertical.default, Object.assign({
|
|
29
|
+
LEGACY_fallbackIcon: _dragHandler.default
|
|
30
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
31
|
+
}, props));
|
|
32
|
+
DragHandleVerticalIcon.Name = 'DragHandleVerticalIconMigration';
|
|
33
|
+
var _default = exports.default = DragHandleVerticalIcon;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
default as core,
|
|
3
|
-
API,
|
|
4
|
-
FileInfo,
|
|
5
|
-
ImportSpecifier,
|
|
6
|
-
ASTPath,
|
|
7
|
-
ImportDefaultSpecifier,
|
|
8
|
-
Options,
|
|
9
|
-
} from 'jscodeshift';
|
|
10
|
-
import { type Collection } from 'jscodeshift/src/Collection';
|
|
11
|
-
|
|
12
|
-
export const packageName = '@atlaskit/icon';
|
|
13
|
-
|
|
14
|
-
export default function transformer(file: FileInfo, api: API, options: Options) {
|
|
15
|
-
const j = api.jscodeshift;
|
|
16
|
-
const root = j(file.source, { quote: 'auto' });
|
|
17
|
-
if (hasImportDeclaration(j, root, packageName)) {
|
|
18
|
-
const imports = root.find(j.ImportSpecifier, {
|
|
19
|
-
imported: { name: 'metadata' },
|
|
20
|
-
});
|
|
21
|
-
imports.forEach((p: ASTPath<ImportSpecifier | ImportDefaultSpecifier>) => {
|
|
22
|
-
if (p.parentPath.parentPath.node.source.value !== packageName) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if (p.parentPath.node.specifiers.length === 1) {
|
|
26
|
-
p.node.type = 'ImportDefaultSpecifier';
|
|
27
|
-
p.parentPath.node.source.value = `${packageName}/metadata`;
|
|
28
|
-
} else if (p.node.local) {
|
|
29
|
-
tryCreateImport({
|
|
30
|
-
j,
|
|
31
|
-
base: root,
|
|
32
|
-
packageName: `${packageName}/metadata`,
|
|
33
|
-
relativeToPackage: packageName,
|
|
34
|
-
});
|
|
35
|
-
addToImport({
|
|
36
|
-
j,
|
|
37
|
-
base: root,
|
|
38
|
-
packageName: `${packageName}/metadata`,
|
|
39
|
-
importSpecifier: j.importDefaultSpecifier(j.identifier(p.node.local.name)),
|
|
40
|
-
});
|
|
41
|
-
p.replace();
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
return root.toSource(options.printOptions || { quote: 'single' });
|
|
45
|
-
}
|
|
46
|
-
return file.source;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function hasImportDeclaration(
|
|
50
|
-
j: core.JSCodeshift,
|
|
51
|
-
source: ReturnType<typeof j>,
|
|
52
|
-
importPath: string,
|
|
53
|
-
) {
|
|
54
|
-
return !!source.find(j.ImportDeclaration).filter((path) => path.node.source.value === importPath)
|
|
55
|
-
.length;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function tryCreateImport({
|
|
59
|
-
j,
|
|
60
|
-
base,
|
|
61
|
-
relativeToPackage,
|
|
62
|
-
packageName,
|
|
63
|
-
}: {
|
|
64
|
-
j: core.JSCodeshift;
|
|
65
|
-
base: Collection<any>;
|
|
66
|
-
relativeToPackage: string;
|
|
67
|
-
packageName: string;
|
|
68
|
-
}) {
|
|
69
|
-
const exists: boolean =
|
|
70
|
-
base.find(j.ImportDeclaration).filter((path) => path.value.source.value === packageName)
|
|
71
|
-
.length > 0;
|
|
72
|
-
|
|
73
|
-
if (exists) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
base
|
|
78
|
-
.find(j.ImportDeclaration)
|
|
79
|
-
.filter((path) => path.value.source.value === relativeToPackage)
|
|
80
|
-
.insertBefore(j.importDeclaration([], j.literal(packageName)));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function addToImport({
|
|
84
|
-
j,
|
|
85
|
-
base,
|
|
86
|
-
importSpecifier,
|
|
87
|
-
packageName,
|
|
88
|
-
}: {
|
|
89
|
-
j: core.JSCodeshift;
|
|
90
|
-
base: Collection<any>;
|
|
91
|
-
importSpecifier: ImportSpecifier | ImportDefaultSpecifier;
|
|
92
|
-
packageName: string;
|
|
93
|
-
}) {
|
|
94
|
-
base
|
|
95
|
-
.find(j.ImportDeclaration)
|
|
96
|
-
.filter((path) => path.value.source.value === packageName)
|
|
97
|
-
.replaceWith((declaration) => {
|
|
98
|
-
return j.importDeclaration(
|
|
99
|
-
[
|
|
100
|
-
// we are appending to the existing specifiers
|
|
101
|
-
// We are doing a filter hear because sometimes specifiers can be removed
|
|
102
|
-
// but they hand around in the declaration
|
|
103
|
-
...(declaration.value.specifiers || []).filter(
|
|
104
|
-
(item) => item.type === 'ImportSpecifier' && item.imported != null,
|
|
105
|
-
),
|
|
106
|
-
importSpecifier,
|
|
107
|
-
],
|
|
108
|
-
j.literal(packageName),
|
|
109
|
-
);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
jest.disableAutomock();
|
|
2
|
-
|
|
3
|
-
import transformer, { packageName } from '../21.2.0-metadata-entry';
|
|
4
|
-
|
|
5
|
-
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
6
|
-
|
|
7
|
-
describe('Update imports', () => {
|
|
8
|
-
defineInlineTest(
|
|
9
|
-
{ default: transformer, parser: 'tsx' },
|
|
10
|
-
{},
|
|
11
|
-
`
|
|
12
|
-
import { metadata } from '${packageName}';
|
|
13
|
-
console.log(metadata);
|
|
14
|
-
`,
|
|
15
|
-
`
|
|
16
|
-
import metadata from '${packageName}/metadata';
|
|
17
|
-
console.log(metadata);
|
|
18
|
-
`,
|
|
19
|
-
'should replace named metadata import from main entry point with default import from dedicated entry point',
|
|
20
|
-
);
|
|
21
|
-
defineInlineTest(
|
|
22
|
-
{ default: transformer, parser: 'tsx' },
|
|
23
|
-
{},
|
|
24
|
-
`
|
|
25
|
-
import { metadata as data } from '${packageName}';
|
|
26
|
-
console.log(data);
|
|
27
|
-
`,
|
|
28
|
-
`
|
|
29
|
-
import data from '${packageName}/metadata';
|
|
30
|
-
console.log(data);
|
|
31
|
-
`,
|
|
32
|
-
'should preserve renaming when converting from named import to default import',
|
|
33
|
-
);
|
|
34
|
-
defineInlineTest(
|
|
35
|
-
{ default: transformer, parser: 'tsx' },
|
|
36
|
-
{},
|
|
37
|
-
`
|
|
38
|
-
import { a, metadata, b } from '${packageName}';
|
|
39
|
-
console.log(metadata);
|
|
40
|
-
`,
|
|
41
|
-
`
|
|
42
|
-
import metadata from '${packageName}/metadata';
|
|
43
|
-
import { a, b } from '${packageName}';
|
|
44
|
-
console.log(metadata);
|
|
45
|
-
`,
|
|
46
|
-
'should preserve other named imports',
|
|
47
|
-
);
|
|
48
|
-
defineInlineTest(
|
|
49
|
-
{ default: transformer, parser: 'tsx' },
|
|
50
|
-
{},
|
|
51
|
-
`
|
|
52
|
-
import { a, metadata as data, b } from '${packageName}';
|
|
53
|
-
console.log(data);
|
|
54
|
-
`,
|
|
55
|
-
`
|
|
56
|
-
import data from '${packageName}/metadata';
|
|
57
|
-
import { a, b } from '${packageName}';
|
|
58
|
-
console.log(data);
|
|
59
|
-
`,
|
|
60
|
-
'should preserve other named imports, as well as metadata renaming',
|
|
61
|
-
);
|
|
62
|
-
defineInlineTest(
|
|
63
|
-
{ default: transformer, parser: 'tsx' },
|
|
64
|
-
{},
|
|
65
|
-
`
|
|
66
|
-
import Icon, { a, metadata as data, b } from '${packageName}';
|
|
67
|
-
console.log(a, data, b);
|
|
68
|
-
`,
|
|
69
|
-
`
|
|
70
|
-
import data from '${packageName}/metadata';
|
|
71
|
-
import Icon, { a, b } from '${packageName}';
|
|
72
|
-
console.log(a, data, b);
|
|
73
|
-
`,
|
|
74
|
-
'should preserve other named imports and default import, as well as metadata renaming',
|
|
75
|
-
);
|
|
76
|
-
defineInlineTest(
|
|
77
|
-
{ default: transformer, parser: 'tsx' },
|
|
78
|
-
{},
|
|
79
|
-
`
|
|
80
|
-
import metadata from '${packageName}/metadata';
|
|
81
|
-
console.log(metadata);
|
|
82
|
-
`,
|
|
83
|
-
`
|
|
84
|
-
import metadata from '${packageName}/metadata';
|
|
85
|
-
console.log(metadata);
|
|
86
|
-
`,
|
|
87
|
-
'should not affect existing good imports',
|
|
88
|
-
);
|
|
89
|
-
defineInlineTest(
|
|
90
|
-
{ default: transformer, parser: 'tsx' },
|
|
91
|
-
{},
|
|
92
|
-
`
|
|
93
|
-
import { metadata } from 'not-${packageName}';
|
|
94
|
-
`,
|
|
95
|
-
`
|
|
96
|
-
import { metadata } from 'not-${packageName}';
|
|
97
|
-
`,
|
|
98
|
-
'should not affect other packages',
|
|
99
|
-
);
|
|
100
|
-
defineInlineTest(
|
|
101
|
-
{ default: transformer, parser: 'tsx' },
|
|
102
|
-
{},
|
|
103
|
-
`
|
|
104
|
-
import { metadata } from '${packageName}/foo';
|
|
105
|
-
`,
|
|
106
|
-
`
|
|
107
|
-
import { metadata } from '${packageName}/foo';
|
|
108
|
-
`,
|
|
109
|
-
'should not affect other entrypoints',
|
|
110
|
-
);
|
|
111
|
-
defineInlineTest(
|
|
112
|
-
{ default: transformer, parser: 'tsx' },
|
|
113
|
-
{},
|
|
114
|
-
`
|
|
115
|
-
import { metadata } from '@atlaskit/icon';
|
|
116
|
-
import { metadata as objectIconMetadata } from '@atlaskit/icon-object';
|
|
117
|
-
import { metadata as fileTypeIconMetadata } from '@atlaskit/icon-file-type';
|
|
118
|
-
`,
|
|
119
|
-
`
|
|
120
|
-
import metadata from '@atlaskit/icon/metadata';
|
|
121
|
-
import { metadata as objectIconMetadata } from '@atlaskit/icon-object';
|
|
122
|
-
import { metadata as fileTypeIconMetadata } from '@atlaskit/icon-file-type';
|
|
123
|
-
`,
|
|
124
|
-
'should work as expected on a real-world case',
|
|
125
|
-
);
|
|
126
|
-
});
|