@atlaskit/adf-utils 16.0.2 → 17.1.1
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 +84 -0
- package/builders/package.json +1 -0
- package/codemods/17.0.0-update-imports-to-new-entry-points.ts +175 -0
- package/codemods/__tests__/next-update-imports-to-new-entry-points.ts +175 -0
- package/codemods/helpers/entry-points.ts +33 -0
- package/codemods/types/entry-points.ts +12 -0
- package/dist/cjs/index.js +1 -447
- package/dist/cjs/scrub/scrub-content.js +5 -5
- package/dist/cjs/transforms/dedupe-marks-transform.js +120 -0
- package/dist/cjs/transforms/indentation-marks-transform.js +66 -0
- package/dist/cjs/{media-link-transform.js → transforms/media-link-transform.js} +1 -1
- package/dist/cjs/transforms/nodes-missing-content-transform.js +205 -0
- package/dist/cjs/transforms.js +45 -0
- package/dist/cjs/validator/specs/block_content.js +1 -1
- package/dist/cjs/validator/specs/mediaInline.js +5 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/index.js +2 -7
- package/dist/es2019/transforms/dedupe-marks-transform.js +97 -0
- package/dist/es2019/transforms/indentation-marks-transform.js +45 -0
- package/dist/es2019/{media-link-transform.js → transforms/media-link-transform.js} +1 -1
- package/dist/es2019/transforms/nodes-missing-content-transform.js +175 -0
- package/dist/es2019/transforms.js +5 -0
- package/dist/es2019/validator/specs/block_content.js +1 -1
- package/dist/es2019/validator/specs/mediaInline.js +5 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/index.js +2 -7
- package/dist/esm/scrub/scrub-content.js +5 -5
- package/dist/esm/transforms/dedupe-marks-transform.js +108 -0
- package/dist/esm/transforms/indentation-marks-transform.js +55 -0
- package/dist/esm/{media-link-transform.js → transforms/media-link-transform.js} +1 -1
- package/dist/esm/transforms/nodes-missing-content-transform.js +192 -0
- package/dist/esm/transforms.js +5 -0
- package/dist/esm/validator/specs/block_content.js +1 -1
- package/dist/esm/validator/specs/mediaInline.js +5 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/index.d.ts +1 -9
- package/dist/types/transforms/dedupe-marks-transform.d.ts +8 -0
- package/dist/types/transforms/indentation-marks-transform.d.ts +7 -0
- package/dist/types/{media-link-transform.d.ts → transforms/media-link-transform.d.ts} +1 -1
- package/dist/types/transforms/nodes-missing-content-transform.d.ts +7 -0
- package/dist/types/transforms.d.ts +5 -0
- package/dist/types/validator/specs/mediaInline.d.ts +5 -0
- package/dist/types/validator.d.ts +0 -1
- package/empty-adf/package.json +1 -0
- package/package.json +14 -3
- package/report.api.md +7 -0
- package/scrub/package.json +1 -0
- package/transforms/package.json +8 -0
- package/traverse/package.json +1 -0
- package/tsconfig.json +2 -1
- package/types/package.json +8 -0
- package/validator/package.json +1 -0
- package/validatorTypes/package.json +8 -0
- package/media-link-transform/package.json +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,89 @@
|
|
|
1
1
|
# @atlaskit/adf-utils
|
|
2
2
|
|
|
3
|
+
## 17.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`fecd5f5c96c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fecd5f5c96c) - ED-15067 Added paragraph_with_indentation to block content to allow indented paragraphs inside of layout columns. Prior to this change, it was possible to add indentation but it resulted in an unsupported mark.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 17.1.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [`4d8c675bd2a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4d8c675bd2a) - EDM-3779 Hotfix: Extend Media Inline ADF Schema to have type attribute
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
20
|
+
## 17.0.0
|
|
21
|
+
|
|
22
|
+
### Major Changes
|
|
23
|
+
|
|
24
|
+
- [`844b8278b4d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/844b8278b4d) - ED-14608: Migrate adf-utils to modern child entry points, remove default entry point, add codemods to enforce migration.
|
|
25
|
+
|
|
26
|
+
As we will no longer support the default entry point, imports such as the example below:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
import { breakout, scrubAdf, map } from '@atlaskit/adf-utils';
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
would need to become:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
import { breakout } from '@atlaskit/adf-utils/builders';
|
|
36
|
+
import { scrubADF } from '@atlaskit/adf-utils/scrub';
|
|
37
|
+
import { map } from '@atlaskit/adf-utils/traverse';
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**The new (and only) @atlaskit/adf-utils entry points supported now are listed below:**
|
|
41
|
+
|
|
42
|
+
@atlaskit/adf-utils/builders for:
|
|
43
|
+
|
|
44
|
+
- breakout, code, em, link, link, strike, strong, strong, subsup, text-color, underline, underline, alignment, indentation, data-consumer fragment, blockquote, bodied-extension, block-card, bullet-list, bullet-list, code-block, date, decision-item, decision-list, doc, emoji, extension, expand, nested-expand, hard-break, hard-break, heading, inline-extension, inline-card, layout-column, layout-section, list-item, list-item, media-group, media-single, media, mention, ordered-list, ordered-list, panel, paragraph, paragraph, placeholder, rule, rule, status, table-cell, table-cell, table-header, table-header, table-row, table-row, table, task-item, task-list, text, embed-card,
|
|
45
|
+
|
|
46
|
+
@atlaskit/adf-utils/empty-adf for:
|
|
47
|
+
|
|
48
|
+
- getEmptyADF
|
|
49
|
+
|
|
50
|
+
@atlaskit/adf-utils/scrub for:
|
|
51
|
+
|
|
52
|
+
- scrubAdf
|
|
53
|
+
|
|
54
|
+
@atlaskit/adf-utils/transforms for:
|
|
55
|
+
|
|
56
|
+
- transformMediaLinkMarks, transformTextLinkCodeMarks, transformDedupeMarks, transformNodesMissingContent, transformIndentationMarks
|
|
57
|
+
|
|
58
|
+
@atlaskit/adf-utils/traverse for:
|
|
59
|
+
|
|
60
|
+
- traverse, map, reduce, filter
|
|
61
|
+
|
|
62
|
+
@atlaskit/adf-utils/validator for:
|
|
63
|
+
|
|
64
|
+
- validateAttrs, validator
|
|
65
|
+
|
|
66
|
+
@atlaskit/adf-utils/types for:
|
|
67
|
+
|
|
68
|
+
- ADFEntityMark, ADFEntity, Visitor, VisitorCollection, EntityParent
|
|
69
|
+
|
|
70
|
+
@atlaskit/adf-utils/validatorTypes for:
|
|
71
|
+
|
|
72
|
+
- MarkValidationResult, Output, NodeValidationResult, ValidatorContent, AttributesSpec, ValidatorSpec, ValidationErrorMap, RequiredContentLength, Content, ValidationErrorType, ValidationError, ErrorCallback, ValidationMode, ValidationOptions, SpecValidatorResult, Err, ErrorCallbackOptions, Validate
|
|
73
|
+
|
|
74
|
+
**Since there are significant changes (including the breaking change of dropping the default entry point to @atlaskit/adf-utils), we will be providing a codemod to help consumers upgrade their usage of adf-utils**
|
|
75
|
+
|
|
76
|
+
Once you've upgraded `@atlaskit/adf-utils`, use the Atlaskit codemod CLI.
|
|
77
|
+
|
|
78
|
+
`npx @atlaskit/codemod-cli /path/to/target/directory`
|
|
79
|
+
|
|
80
|
+
See [documentation on DAC](https://developer.atlassian.com/cloud/framework/atlassian-frontend/codemods/01-atlassian-codemods/) for general codemod guidance.
|
|
81
|
+
|
|
82
|
+
### Patch Changes
|
|
83
|
+
|
|
84
|
+
- [`8300a668772`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8300a668772) - [ux] ED-14488: Extend ADF sanitising coverage to prevent Prosemirror failing validation checks on adf that can be repaired
|
|
85
|
+
- Updated dependencies
|
|
86
|
+
|
|
3
87
|
## 16.0.2
|
|
4
88
|
|
|
5
89
|
### Patch Changes
|
package/builders/package.json
CHANGED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { createTransformer } from '@atlaskit/codemod-utils';
|
|
2
|
+
import { createMigratesFromEntryPointChangeRequests } from './helpers/entry-points';
|
|
3
|
+
import type { EntryPointChangeRequest } from './types/entry-points';
|
|
4
|
+
|
|
5
|
+
const DEFAULT_ADF_UTILS_IMPORT = '@atlaskit/adf-utils';
|
|
6
|
+
|
|
7
|
+
const types: EntryPointChangeRequest = {
|
|
8
|
+
importSpecifiers: [
|
|
9
|
+
'ADFEntity',
|
|
10
|
+
'ADFEntityMark',
|
|
11
|
+
'Visitor',
|
|
12
|
+
'VisitorCollection',
|
|
13
|
+
],
|
|
14
|
+
oldEntryPointsToRemove: [DEFAULT_ADF_UTILS_IMPORT],
|
|
15
|
+
newEntryPoint: `${DEFAULT_ADF_UTILS_IMPORT}/types`,
|
|
16
|
+
shouldBeTypeImport: true,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const validatorTypes: EntryPointChangeRequest = {
|
|
20
|
+
importSpecifiers: [
|
|
21
|
+
'Content',
|
|
22
|
+
'ErrorCallback',
|
|
23
|
+
'Output',
|
|
24
|
+
'ValidationError',
|
|
25
|
+
'ValidationErrorMap',
|
|
26
|
+
'ValidationErrorType',
|
|
27
|
+
'ValidationMode',
|
|
28
|
+
'ValidationOptions',
|
|
29
|
+
'ErrorCallbackOptions',
|
|
30
|
+
'Validate',
|
|
31
|
+
'NodeValidationResult',
|
|
32
|
+
'ValidatorSpec',
|
|
33
|
+
'AttributesSpec',
|
|
34
|
+
'ValidatorContent',
|
|
35
|
+
'MarkValidationResult',
|
|
36
|
+
'SpecValidatorResult',
|
|
37
|
+
'Err',
|
|
38
|
+
],
|
|
39
|
+
oldEntryPointsToRemove: [
|
|
40
|
+
DEFAULT_ADF_UTILS_IMPORT,
|
|
41
|
+
`${DEFAULT_ADF_UTILS_IMPORT}/validator`,
|
|
42
|
+
],
|
|
43
|
+
newEntryPoint: `${DEFAULT_ADF_UTILS_IMPORT}/validatorTypes`,
|
|
44
|
+
shouldBeTypeImport: true,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const transforms: EntryPointChangeRequest = {
|
|
48
|
+
importSpecifiers: [
|
|
49
|
+
'transformMediaLinkMarks',
|
|
50
|
+
'transformTextLinkCodeMarks',
|
|
51
|
+
'transformDedupeMarks',
|
|
52
|
+
'transformNodesMissingContent',
|
|
53
|
+
'transformIndentationMarks',
|
|
54
|
+
],
|
|
55
|
+
oldEntryPointsToRemove: [DEFAULT_ADF_UTILS_IMPORT],
|
|
56
|
+
newEntryPoint: `${DEFAULT_ADF_UTILS_IMPORT}/transforms`,
|
|
57
|
+
shouldBeTypeImport: false,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const traverse: EntryPointChangeRequest = {
|
|
61
|
+
importSpecifiers: ['traverse', 'map', 'reduce', 'filter'],
|
|
62
|
+
oldEntryPointsToRemove: [DEFAULT_ADF_UTILS_IMPORT],
|
|
63
|
+
newEntryPoint: `${DEFAULT_ADF_UTILS_IMPORT}/traverse`,
|
|
64
|
+
shouldBeTypeImport: false,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const builders: EntryPointChangeRequest = {
|
|
68
|
+
importSpecifiers: [
|
|
69
|
+
'a',
|
|
70
|
+
'alignment',
|
|
71
|
+
'b',
|
|
72
|
+
'blockCard',
|
|
73
|
+
'blockQuote',
|
|
74
|
+
'bodiedExtension',
|
|
75
|
+
'br',
|
|
76
|
+
'breakout',
|
|
77
|
+
'bulletList',
|
|
78
|
+
'code',
|
|
79
|
+
'codeBlock',
|
|
80
|
+
'date',
|
|
81
|
+
'decisionItem',
|
|
82
|
+
'decisionList',
|
|
83
|
+
'doc',
|
|
84
|
+
'em',
|
|
85
|
+
'embedCard',
|
|
86
|
+
'emoji',
|
|
87
|
+
'expand',
|
|
88
|
+
'extension',
|
|
89
|
+
'hardBreak',
|
|
90
|
+
'heading',
|
|
91
|
+
'hr',
|
|
92
|
+
'indentation',
|
|
93
|
+
'inlineCard',
|
|
94
|
+
'inlineExtension',
|
|
95
|
+
'layoutColumn',
|
|
96
|
+
'layoutSection',
|
|
97
|
+
'li',
|
|
98
|
+
'link',
|
|
99
|
+
'listItem',
|
|
100
|
+
'media',
|
|
101
|
+
'mediaGroup',
|
|
102
|
+
'mediaSingle',
|
|
103
|
+
'mention',
|
|
104
|
+
'nestedExpand',
|
|
105
|
+
'ol',
|
|
106
|
+
'orderedList',
|
|
107
|
+
'p',
|
|
108
|
+
'panel',
|
|
109
|
+
'paragraph',
|
|
110
|
+
'placeholder',
|
|
111
|
+
'rule',
|
|
112
|
+
'status',
|
|
113
|
+
'strike',
|
|
114
|
+
'strong',
|
|
115
|
+
'subsup',
|
|
116
|
+
'table',
|
|
117
|
+
'tableCell',
|
|
118
|
+
'tableHeader',
|
|
119
|
+
'tableRow',
|
|
120
|
+
'taskItem',
|
|
121
|
+
'taskList',
|
|
122
|
+
'td',
|
|
123
|
+
'text',
|
|
124
|
+
'textColor',
|
|
125
|
+
'th',
|
|
126
|
+
'tr',
|
|
127
|
+
'u',
|
|
128
|
+
'ul',
|
|
129
|
+
'underline',
|
|
130
|
+
'dataConsumer',
|
|
131
|
+
],
|
|
132
|
+
oldEntryPointsToRemove: [DEFAULT_ADF_UTILS_IMPORT],
|
|
133
|
+
newEntryPoint: `${DEFAULT_ADF_UTILS_IMPORT}/builders`,
|
|
134
|
+
shouldBeTypeImport: false,
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const emptyAdf: EntryPointChangeRequest = {
|
|
138
|
+
importSpecifiers: ['getEmptyADF'],
|
|
139
|
+
oldEntryPointsToRemove: [DEFAULT_ADF_UTILS_IMPORT],
|
|
140
|
+
newEntryPoint: `${DEFAULT_ADF_UTILS_IMPORT}/empty-adf`,
|
|
141
|
+
shouldBeTypeImport: false,
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const validator: EntryPointChangeRequest = {
|
|
145
|
+
importSpecifiers: ['validator', 'validateAttrs'],
|
|
146
|
+
oldEntryPointsToRemove: [DEFAULT_ADF_UTILS_IMPORT],
|
|
147
|
+
newEntryPoint: `${DEFAULT_ADF_UTILS_IMPORT}/validator`,
|
|
148
|
+
shouldBeTypeImport: false,
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const scrub: EntryPointChangeRequest = {
|
|
152
|
+
importSpecifiers: ['scrubAdf'],
|
|
153
|
+
oldEntryPointsToRemove: [DEFAULT_ADF_UTILS_IMPORT],
|
|
154
|
+
newEntryPoint: `${DEFAULT_ADF_UTILS_IMPORT}/scrub`,
|
|
155
|
+
shouldBeTypeImport: false,
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const entryPointChangeRequests: EntryPointChangeRequest[] = [
|
|
159
|
+
transforms,
|
|
160
|
+
validatorTypes,
|
|
161
|
+
types,
|
|
162
|
+
traverse,
|
|
163
|
+
builders,
|
|
164
|
+
validator,
|
|
165
|
+
emptyAdf,
|
|
166
|
+
scrub,
|
|
167
|
+
];
|
|
168
|
+
|
|
169
|
+
export const entryPointChangeMigrates = createMigratesFromEntryPointChangeRequests(
|
|
170
|
+
entryPointChangeRequests,
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
const transformer = createTransformer(entryPointChangeMigrates);
|
|
174
|
+
|
|
175
|
+
export default transformer;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import transformer from '../17.0.0-update-imports-to-new-entry-points';
|
|
2
|
+
|
|
3
|
+
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
4
|
+
|
|
5
|
+
describe('updates adf-util imports to new child entry points', () => {
|
|
6
|
+
defineInlineTest(
|
|
7
|
+
{ default: transformer, parser: 'tsx' },
|
|
8
|
+
{},
|
|
9
|
+
`
|
|
10
|
+
import { traverse } from "@atlaskit/adf-utils";
|
|
11
|
+
import { ADFEntity, ADFEntityMark } from "@atlaskit/adf-utils";
|
|
12
|
+
import { validateAttrs, validator, ValidationErrorMap } from '@atlaskit/adf-utils';
|
|
13
|
+
import type { NodeValidationResult } from '@atlaskit/adf-utils';
|
|
14
|
+
import { type ValidationMode } from '@atlaskit/adf-utils';
|
|
15
|
+
|
|
16
|
+
export default () => (
|
|
17
|
+
<div>
|
|
18
|
+
hello
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
`,
|
|
22
|
+
`
|
|
23
|
+
import type { ValidationErrorMap, ValidationMode, NodeValidationResult } from "@atlaskit/adf-utils/validatorTypes";
|
|
24
|
+
import type { ADFEntity, ADFEntityMark } from "@atlaskit/adf-utils/types";
|
|
25
|
+
import { traverse } from "@atlaskit/adf-utils/traverse";
|
|
26
|
+
import { validator, validateAttrs } from "@atlaskit/adf-utils/validator";
|
|
27
|
+
|
|
28
|
+
export default () => (
|
|
29
|
+
<div>
|
|
30
|
+
hello
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
`,
|
|
34
|
+
'should handle migrating any combination of old entry points (including type imports and imports with type modifiers) to new child entry points',
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
defineInlineTest(
|
|
38
|
+
{ default: transformer, parser: 'tsx' },
|
|
39
|
+
{},
|
|
40
|
+
`
|
|
41
|
+
import { traverse, teamRocketAndMeowth, scrubAdf } from "@atlaskit/adf-utils";
|
|
42
|
+
import { Pokemon, ADFEntityMark, AshKetchum } from "@atlaskit/adf-utils";
|
|
43
|
+
import type { PsyDuck } from "@atlaskit/adf-utils/pokemon-types";
|
|
44
|
+
import Boogeyman from "@deep/the-mariana-trench";
|
|
45
|
+
|
|
46
|
+
export default () => (
|
|
47
|
+
<div>
|
|
48
|
+
hello
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
`,
|
|
52
|
+
`
|
|
53
|
+
import type { ADFEntityMark } from "@atlaskit/adf-utils/types";
|
|
54
|
+
import { traverse } from "@atlaskit/adf-utils/traverse";
|
|
55
|
+
import { scrubAdf } from "@atlaskit/adf-utils/scrub";
|
|
56
|
+
import { teamRocketAndMeowth } from "@atlaskit/adf-utils";
|
|
57
|
+
import { Pokemon, AshKetchum } from "@atlaskit/adf-utils";
|
|
58
|
+
import type { PsyDuck } from "@atlaskit/adf-utils/pokemon-types";
|
|
59
|
+
import Boogeyman from "@deep/the-mariana-trench";
|
|
60
|
+
|
|
61
|
+
export default () => (
|
|
62
|
+
<div>
|
|
63
|
+
hello
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
`,
|
|
67
|
+
'should leave unknown entry points or import specifiers untouched (and unmerged if initially unmerged)',
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
defineInlineTest(
|
|
71
|
+
{ default: transformer, parser: 'tsx' },
|
|
72
|
+
{},
|
|
73
|
+
`
|
|
74
|
+
import { VisitorCollection } from "@atlaskit/adf-utils/types";
|
|
75
|
+
import type { Visitor } from "@atlaskit/adf-utils";
|
|
76
|
+
|
|
77
|
+
export default () => (
|
|
78
|
+
<div>
|
|
79
|
+
hello
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
`,
|
|
83
|
+
`
|
|
84
|
+
import type { VisitorCollection, Visitor } from "@atlaskit/adf-utils/types";
|
|
85
|
+
|
|
86
|
+
export default () => (
|
|
87
|
+
<div>
|
|
88
|
+
hello
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
`,
|
|
92
|
+
'should handle migrating new child entry points with mismatched importKinds (e.g. non-type when should be type import)',
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
defineInlineTest(
|
|
96
|
+
{ default: transformer, parser: 'tsx' },
|
|
97
|
+
{},
|
|
98
|
+
`
|
|
99
|
+
import { scrubAdf, doc, p, link } from "@atlaskit/adf-utils";
|
|
100
|
+
import { blockCard, paragraph } from "@atlaskit/adf-utils/builders";
|
|
101
|
+
import { placeholder, transformDedupeMarks } from "@atlaskit/adf-utils";
|
|
102
|
+
import { VisitorCollection } from "@atlaskit/adf-utils/types";
|
|
103
|
+
import type { Visitor } from "@atlaskit/adf-utils";
|
|
104
|
+
import { getEmptyADF } from "@atlaskit/adf-utils";
|
|
105
|
+
|
|
106
|
+
export default () => (
|
|
107
|
+
<div>
|
|
108
|
+
hello
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
`,
|
|
112
|
+
`
|
|
113
|
+
import { transformDedupeMarks } from "@atlaskit/adf-utils/transforms";
|
|
114
|
+
import { getEmptyADF } from "@atlaskit/adf-utils/empty-adf";
|
|
115
|
+
import { scrubAdf } from "@atlaskit/adf-utils/scrub";
|
|
116
|
+
import { blockCard, paragraph, doc, link, p, placeholder } from "@atlaskit/adf-utils/builders";
|
|
117
|
+
import type { VisitorCollection, Visitor } from "@atlaskit/adf-utils/types";
|
|
118
|
+
|
|
119
|
+
export default () => (
|
|
120
|
+
<div>
|
|
121
|
+
hello
|
|
122
|
+
</div>
|
|
123
|
+
);
|
|
124
|
+
`,
|
|
125
|
+
'should handle migrating any combination of old and new entry points to new child entry points',
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
defineInlineTest(
|
|
129
|
+
{ default: transformer, parser: 'tsx' },
|
|
130
|
+
{},
|
|
131
|
+
`
|
|
132
|
+
const { scrubAdf } = require("@atlaskit/adf-utils");
|
|
133
|
+
import * as adfUtils from "@atlaskit/adf-utils";
|
|
134
|
+
|
|
135
|
+
export default () => {
|
|
136
|
+
if (shouldFetchModule) {
|
|
137
|
+
import("@atlaskit/adf-utils").then(module => ({
|
|
138
|
+
something: "else"
|
|
139
|
+
}));
|
|
140
|
+
import("@atlaskit/adf-utils/traverse").then(module => {
|
|
141
|
+
const traverse = module.traverse;
|
|
142
|
+
traverse();
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return (
|
|
146
|
+
<div>
|
|
147
|
+
hello
|
|
148
|
+
</div>
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
`,
|
|
152
|
+
`
|
|
153
|
+
const { scrubAdf } = require("@atlaskit/adf-utils");
|
|
154
|
+
import * as adfUtils from "@atlaskit/adf-utils";
|
|
155
|
+
|
|
156
|
+
export default () => {
|
|
157
|
+
if (shouldFetchModule) {
|
|
158
|
+
import("@atlaskit/adf-utils").then(module => ({
|
|
159
|
+
something: "else"
|
|
160
|
+
}));
|
|
161
|
+
import("@atlaskit/adf-utils/traverse").then(module => {
|
|
162
|
+
const traverse = module.traverse;
|
|
163
|
+
traverse();
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return (
|
|
167
|
+
<div>
|
|
168
|
+
hello
|
|
169
|
+
</div>
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
`,
|
|
173
|
+
'should skip migrating other import syntaxes (namespace imports, CJS, dyamic imports)',
|
|
174
|
+
);
|
|
175
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { changeImportEntryPoint } from '@atlaskit/codemod-utils';
|
|
2
|
+
import type {
|
|
3
|
+
EntryPointChangeRequest,
|
|
4
|
+
EntryPointChangeMigrates,
|
|
5
|
+
} from '../types/entry-points';
|
|
6
|
+
|
|
7
|
+
export const createMigratesFromEntryPointChangeRequests = (
|
|
8
|
+
changeRequests: EntryPointChangeRequest[],
|
|
9
|
+
) => {
|
|
10
|
+
const entryPointChangeMigrates: EntryPointChangeMigrates = [];
|
|
11
|
+
changeRequests.forEach(
|
|
12
|
+
({
|
|
13
|
+
importSpecifiers,
|
|
14
|
+
oldEntryPointsToRemove,
|
|
15
|
+
newEntryPoint,
|
|
16
|
+
shouldBeTypeImport,
|
|
17
|
+
}) => {
|
|
18
|
+
oldEntryPointsToRemove.forEach((oldEntryPoint) => {
|
|
19
|
+
importSpecifiers.forEach((importSpecifier) => {
|
|
20
|
+
entryPointChangeMigrates.push(
|
|
21
|
+
changeImportEntryPoint(
|
|
22
|
+
oldEntryPoint,
|
|
23
|
+
importSpecifier,
|
|
24
|
+
newEntryPoint,
|
|
25
|
+
shouldBeTypeImport,
|
|
26
|
+
),
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
);
|
|
32
|
+
return entryPointChangeMigrates;
|
|
33
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { changeImportEntryPoint } from '@atlaskit/codemod-utils';
|
|
2
|
+
|
|
3
|
+
export type EntryPointChangeRequest = {
|
|
4
|
+
importSpecifiers: string[];
|
|
5
|
+
oldEntryPointsToRemove: string[];
|
|
6
|
+
newEntryPoint: string;
|
|
7
|
+
shouldBeTypeImport: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type EntryPointChange = ReturnType<typeof changeImportEntryPoint>;
|
|
11
|
+
|
|
12
|
+
export type EntryPointChangeMigrates = EntryPointChange[];
|