@atlaskit/adf-utils 19.13.2 → 19.14.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 +8 -0
- package/afm-cc/tsconfig.json +1 -5
- package/package.json +1 -3
- package/codemods/17.0.0-update-imports-to-new-entry-points.ts +0 -166
- package/codemods/__tests__/next-update-imports-to-new-entry-points.ts +0 -175
- package/codemods/helpers/entry-points.ts +0 -25
- package/codemods/types/entry-points.ts +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/adf-utils
|
|
2
2
|
|
|
3
|
+
## 19.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#169499](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/169499)
|
|
8
|
+
[`7d83c833bbcb1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7d83c833bbcb1) -
|
|
9
|
+
Remove v16->v17 codemod, and associated jscodeshift/codemod-utils dependencies.
|
|
10
|
+
|
|
3
11
|
## 19.13.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/adf-utils",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.14.0",
|
|
4
4
|
"description": "Set of utilities to traverse, modify and create ADF documents.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -37,12 +37,10 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
40
|
-
"@atlaskit/codemod-utils": "^4.2.0",
|
|
41
40
|
"@babel/runtime": "^7.0.0"
|
|
42
41
|
},
|
|
43
42
|
"devDependencies": {
|
|
44
43
|
"@atlassian/adf-schema-json": "^1.22.0",
|
|
45
|
-
"jscodeshift": "^0.13.0",
|
|
46
44
|
"react": "^16.8.0",
|
|
47
45
|
"typescript": "~5.4.2",
|
|
48
46
|
"wait-for-expect": "^1.2.0"
|
|
@@ -1,166 +0,0 @@
|
|
|
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: ['ADFEntity', 'ADFEntityMark', 'Visitor', 'VisitorCollection'],
|
|
9
|
-
oldEntryPointsToRemove: [DEFAULT_ADF_UTILS_IMPORT],
|
|
10
|
-
newEntryPoint: `${DEFAULT_ADF_UTILS_IMPORT}/types`,
|
|
11
|
-
shouldBeTypeImport: true,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const validatorTypes: EntryPointChangeRequest = {
|
|
15
|
-
importSpecifiers: [
|
|
16
|
-
'Content',
|
|
17
|
-
'ErrorCallback',
|
|
18
|
-
'Output',
|
|
19
|
-
'ValidationError',
|
|
20
|
-
'ValidationErrorMap',
|
|
21
|
-
'ValidationErrorType',
|
|
22
|
-
'ValidationMode',
|
|
23
|
-
'ValidationOptions',
|
|
24
|
-
'ErrorCallbackOptions',
|
|
25
|
-
'Validate',
|
|
26
|
-
'NodeValidationResult',
|
|
27
|
-
'ValidatorSpec',
|
|
28
|
-
'AttributesSpec',
|
|
29
|
-
'ValidatorContent',
|
|
30
|
-
'MarkValidationResult',
|
|
31
|
-
'SpecValidatorResult',
|
|
32
|
-
'Err',
|
|
33
|
-
],
|
|
34
|
-
oldEntryPointsToRemove: [DEFAULT_ADF_UTILS_IMPORT, `${DEFAULT_ADF_UTILS_IMPORT}/validator`],
|
|
35
|
-
newEntryPoint: `${DEFAULT_ADF_UTILS_IMPORT}/validatorTypes`,
|
|
36
|
-
shouldBeTypeImport: true,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const transforms: EntryPointChangeRequest = {
|
|
40
|
-
importSpecifiers: [
|
|
41
|
-
'transformMediaLinkMarks',
|
|
42
|
-
'transformTextLinkCodeMarks',
|
|
43
|
-
'transformDedupeMarks',
|
|
44
|
-
'transformNodesMissingContent',
|
|
45
|
-
'transformIndentationMarks',
|
|
46
|
-
],
|
|
47
|
-
oldEntryPointsToRemove: [DEFAULT_ADF_UTILS_IMPORT],
|
|
48
|
-
newEntryPoint: `${DEFAULT_ADF_UTILS_IMPORT}/transforms`,
|
|
49
|
-
shouldBeTypeImport: false,
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const traverse: EntryPointChangeRequest = {
|
|
53
|
-
importSpecifiers: ['traverse', 'map', 'reduce', 'filter'],
|
|
54
|
-
oldEntryPointsToRemove: [DEFAULT_ADF_UTILS_IMPORT],
|
|
55
|
-
newEntryPoint: `${DEFAULT_ADF_UTILS_IMPORT}/traverse`,
|
|
56
|
-
shouldBeTypeImport: false,
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const builders: EntryPointChangeRequest = {
|
|
60
|
-
importSpecifiers: [
|
|
61
|
-
'a',
|
|
62
|
-
'alignment',
|
|
63
|
-
'b',
|
|
64
|
-
'blockCard',
|
|
65
|
-
'blockQuote',
|
|
66
|
-
'bodiedExtension',
|
|
67
|
-
'br',
|
|
68
|
-
'breakout',
|
|
69
|
-
'bulletList',
|
|
70
|
-
'code',
|
|
71
|
-
'codeBlock',
|
|
72
|
-
'date',
|
|
73
|
-
'decisionItem',
|
|
74
|
-
'decisionList',
|
|
75
|
-
'doc',
|
|
76
|
-
'em',
|
|
77
|
-
'embedCard',
|
|
78
|
-
'emoji',
|
|
79
|
-
'expand',
|
|
80
|
-
'extension',
|
|
81
|
-
'hardBreak',
|
|
82
|
-
'heading',
|
|
83
|
-
'hr',
|
|
84
|
-
'indentation',
|
|
85
|
-
'inlineCard',
|
|
86
|
-
'inlineExtension',
|
|
87
|
-
'layoutColumn',
|
|
88
|
-
'layoutSection',
|
|
89
|
-
'li',
|
|
90
|
-
'link',
|
|
91
|
-
'listItem',
|
|
92
|
-
'media',
|
|
93
|
-
'mediaGroup',
|
|
94
|
-
'mediaSingle',
|
|
95
|
-
'mention',
|
|
96
|
-
'nestedExpand',
|
|
97
|
-
'ol',
|
|
98
|
-
'orderedList',
|
|
99
|
-
'p',
|
|
100
|
-
'panel',
|
|
101
|
-
'paragraph',
|
|
102
|
-
'placeholder',
|
|
103
|
-
'rule',
|
|
104
|
-
'status',
|
|
105
|
-
'strike',
|
|
106
|
-
'strong',
|
|
107
|
-
'subsup',
|
|
108
|
-
'table',
|
|
109
|
-
'tableCell',
|
|
110
|
-
'tableHeader',
|
|
111
|
-
'tableRow',
|
|
112
|
-
'taskItem',
|
|
113
|
-
'taskList',
|
|
114
|
-
'td',
|
|
115
|
-
'text',
|
|
116
|
-
'textColor',
|
|
117
|
-
'th',
|
|
118
|
-
'tr',
|
|
119
|
-
'u',
|
|
120
|
-
'ul',
|
|
121
|
-
'underline',
|
|
122
|
-
'dataConsumer',
|
|
123
|
-
],
|
|
124
|
-
oldEntryPointsToRemove: [DEFAULT_ADF_UTILS_IMPORT],
|
|
125
|
-
newEntryPoint: `${DEFAULT_ADF_UTILS_IMPORT}/builders`,
|
|
126
|
-
shouldBeTypeImport: false,
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const emptyAdf: EntryPointChangeRequest = {
|
|
130
|
-
importSpecifiers: ['getEmptyADF'],
|
|
131
|
-
oldEntryPointsToRemove: [DEFAULT_ADF_UTILS_IMPORT],
|
|
132
|
-
newEntryPoint: `${DEFAULT_ADF_UTILS_IMPORT}/empty-adf`,
|
|
133
|
-
shouldBeTypeImport: false,
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const validator: EntryPointChangeRequest = {
|
|
137
|
-
importSpecifiers: ['validator', 'validateAttrs'],
|
|
138
|
-
oldEntryPointsToRemove: [DEFAULT_ADF_UTILS_IMPORT],
|
|
139
|
-
newEntryPoint: `${DEFAULT_ADF_UTILS_IMPORT}/validator`,
|
|
140
|
-
shouldBeTypeImport: false,
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const scrub: EntryPointChangeRequest = {
|
|
144
|
-
importSpecifiers: ['scrubAdf'],
|
|
145
|
-
oldEntryPointsToRemove: [DEFAULT_ADF_UTILS_IMPORT],
|
|
146
|
-
newEntryPoint: `${DEFAULT_ADF_UTILS_IMPORT}/scrub`,
|
|
147
|
-
shouldBeTypeImport: false,
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
const entryPointChangeRequests: EntryPointChangeRequest[] = [
|
|
151
|
-
transforms,
|
|
152
|
-
validatorTypes,
|
|
153
|
-
types,
|
|
154
|
-
traverse,
|
|
155
|
-
builders,
|
|
156
|
-
validator,
|
|
157
|
-
emptyAdf,
|
|
158
|
-
scrub,
|
|
159
|
-
];
|
|
160
|
-
|
|
161
|
-
export const entryPointChangeMigrates =
|
|
162
|
-
createMigratesFromEntryPointChangeRequests(entryPointChangeRequests);
|
|
163
|
-
|
|
164
|
-
const transformer = createTransformer(entryPointChangeMigrates);
|
|
165
|
-
|
|
166
|
-
export default transformer;
|
|
@@ -1,175 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { changeImportEntryPoint } from '@atlaskit/codemod-utils';
|
|
2
|
-
import type { EntryPointChangeRequest, EntryPointChangeMigrates } from '../types/entry-points';
|
|
3
|
-
|
|
4
|
-
export const createMigratesFromEntryPointChangeRequests = (
|
|
5
|
-
changeRequests: EntryPointChangeRequest[],
|
|
6
|
-
) => {
|
|
7
|
-
const entryPointChangeMigrates: EntryPointChangeMigrates = [];
|
|
8
|
-
changeRequests.forEach(
|
|
9
|
-
({ importSpecifiers, oldEntryPointsToRemove, newEntryPoint, shouldBeTypeImport }) => {
|
|
10
|
-
oldEntryPointsToRemove.forEach((oldEntryPoint) => {
|
|
11
|
-
importSpecifiers.forEach((importSpecifier) => {
|
|
12
|
-
entryPointChangeMigrates.push(
|
|
13
|
-
changeImportEntryPoint(
|
|
14
|
-
oldEntryPoint,
|
|
15
|
-
importSpecifier,
|
|
16
|
-
newEntryPoint,
|
|
17
|
-
shouldBeTypeImport,
|
|
18
|
-
),
|
|
19
|
-
);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
},
|
|
23
|
-
);
|
|
24
|
-
return entryPointChangeMigrates;
|
|
25
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
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[];
|