@exdst-sitecore-content-sdk/astro 0.0.16 → 0.0.20
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/README.md +3 -3
- package/package.json +41 -42
- package/src/client/index.ts +1 -1
- package/src/client/sitecore-astro-client.test.ts +41 -20
- package/src/client/sitecore-astro-client.ts +74 -57
- package/src/components/AstroImage.astro +2 -2
- package/src/components/AstroImage.astro.test.ts +542 -0
- package/src/components/Date.astro +5 -1
- package/src/components/Date.astro.test.ts +197 -0
- package/src/components/DefaultEmptyFieldEditingComponentImage.astro +4 -0
- package/src/components/DefaultEmptyFieldEditingComponentText.astro +4 -0
- package/src/components/EditingScripts.astro +2 -2
- package/src/components/EditingScripts.astro.test.ts +267 -0
- package/src/components/ErrorBoundary.astro +8 -9
- package/src/components/ErrorBoundary.astro.test.ts +252 -0
- package/src/components/ErrorComponent.astro +16 -0
- package/src/components/ErrorComponent.astro.test.ts +31 -0
- package/src/components/FieldMetadata.astro +1 -1
- package/src/components/FieldMetadata.astro.test.ts +40 -0
- package/src/components/File.astro +5 -1
- package/src/components/File.astro.test.ts +68 -0
- package/src/components/HiddenRendering.astro.test.ts +36 -0
- package/src/components/Image.astro +18 -4
- package/src/components/Image.astro.test.ts +438 -0
- package/src/components/Link.astro +13 -1
- package/src/components/Link.astro.test.ts +261 -0
- package/src/components/MissingComponent.astro.test.ts +21 -0
- package/src/components/Placeholder/Placeholder.astro +18 -23
- package/src/components/Placeholder/Placeholder.astro.test.ts +1088 -0
- package/src/components/Placeholder/PlaceholderMetadata.astro +24 -18
- package/src/components/Placeholder/PlaceholderMetadata.astro.test.ts +228 -0
- package/src/components/Placeholder/PlaceholderUtils.astro +21 -40
- package/src/components/Placeholder/PlaceholderUtils.astro.test.ts +149 -0
- package/src/components/Placeholder/models.ts +26 -17
- package/src/components/Placeholder/placeholder-utils.test.ts +153 -6
- package/src/components/Placeholder/placeholder-utils.ts +33 -11
- package/src/components/RichText.astro +9 -1
- package/src/components/RichText.astro.test.ts +205 -0
- package/src/components/Text.astro +15 -3
- package/src/components/Text.astro.test.ts +273 -0
- package/src/config/define-config.test.ts +5 -5
- package/src/config/define-config.ts +22 -42
- package/src/config-cli/define-cli-config.test.ts +5 -12
- package/src/config-cli/define-cli-config.ts +4 -8
- package/src/context.ts +42 -11
- package/src/debug.ts +13 -0
- package/src/editing/editing-config-middleware.test.ts +5 -7
- package/src/editing/editing-config-middleware.ts +11 -7
- package/src/editing/editing-render-middleware.test.ts +366 -24
- package/src/editing/editing-render-middleware.ts +34 -12
- package/src/editing/index.ts +2 -0
- package/src/editing/render-middleware.test.ts +1 -1
- package/src/editing/render-middleware.ts +1 -1
- package/src/editing/types.ts +39 -0
- package/src/editing/utils.test.ts +364 -4
- package/src/editing/utils.ts +82 -24
- package/src/enhancers/WithEmptyFieldEditingComponent.astro +1 -1
- package/src/enhancers/WithEmptyFieldEditingComponent.astro.test.ts +380 -0
- package/src/enhancers/WithFieldMetadata.astro.test.ts +113 -0
- package/src/index.ts +10 -7
- package/src/middleware/index.ts +4 -12
- package/src/middleware/middleware.test.ts +13 -0
- package/src/middleware/middleware.ts +12 -3
- package/src/middleware/multisite-middleware.test.ts +45 -50
- package/src/middleware/multisite-middleware.ts +33 -6
- package/src/middleware/robots-middleware.test.ts +20 -4
- package/src/middleware/robots-middleware.ts +10 -3
- package/src/middleware/sitemap-middleware.test.ts +35 -3
- package/src/middleware/sitemap-middleware.ts +7 -6
- package/src/services/component-props-service.ts +7 -6
- package/src/sharedTypes/component-props.ts +15 -4
- package/src/site/index.ts +1 -1
- package/src/tests/astro-helpers.ts +61 -0
- package/src/tests/test-components/CustomErrorComponent.astro +3 -0
- package/src/tests/test-components/CustomHiddenRendering.astro +10 -0
- package/src/tests/test-components/CustomMissingComponent.astro +9 -0
- package/src/tests/test-components/DownloadCallout.astro +12 -0
- package/src/tests/test-components/EmptyFieldEditingComponent.astro +5 -0
- package/src/tests/test-components/ErrorBoundaryWithError.astro +10 -0
- package/src/tests/test-components/Home.astro +12 -0
- package/src/tests/test-components/SxaRichText.astro +23 -0
- package/src/tests/test-components/SxaRichTextDefault.astro +7 -0
- package/src/tests/test-components/SxaRichTextWithTitle.astro +8 -0
- package/src/tests/test-components/TestComponent.astro +9 -0
- package/src/tests/test-components/TestComponentWithError.astro +4 -0
- package/src/tests/test-components/TestComponentWithField.astro +17 -0
- package/src/tests/test-components/TestHeader.astro +8 -0
- package/src/tests/test-components/TestLogo.astro +5 -0
- package/src/tests/test-components/TestParentWrapperComponent.astro +5 -0
- package/src/tests/test-components/TestWrapperComponent.astro +5 -0
- package/src/tests/test-data/metadata-data.ts +86 -0
- package/src/tests/test-data/normal-mode-data.ts +466 -0
- package/src/tests/vitest.setup.ts +4 -0
- package/src/tools/generate-map.ts +4 -3
- package/src/tools/index.ts +2 -4
- package/src/tools/templating/components.test.ts +100 -87
- package/src/tools/templating/components.ts +2 -1
- package/src/tools/templating/default-component.ts +3 -8
- package/src/utils/utils.ts +20 -2
- /package/src/{test-data → tests}/helpers.ts +0 -0
- /package/src/{test-data → tests}/personalizeData.ts +0 -0
- /package/src/{test-data/components → tests/test-components/map-components}/Bar.astro +0 -0
- /package/src/{test-data/components → tests/test-components/map-components}/Baz.astro +0 -0
- /package/src/{test-data/components → tests/test-components/map-components}/Foo.astro +0 -0
- /package/src/{test-data/components → tests/test-components/map-components}/Hero.variant.astro +0 -0
- /package/src/{test-data/components → tests/test-components/map-components}/NotComponent.bsx +0 -0
- /package/src/{test-data/components → tests/test-components/map-components}/Qux.astro +0 -0
- /package/src/{test-data/components → tests/test-components/map-components}/folded/Folded.astro +0 -0
- /package/src/{test-data/components → tests/test-components/map-components}/folded/random-file-2.docx +0 -0
- /package/src/{test-data/components → tests/test-components/map-components}/random-file.txt +0 -0
|
@@ -2,14 +2,15 @@ import {
|
|
|
2
2
|
GenerateMapArgs,
|
|
3
3
|
GenerateMapFunction,
|
|
4
4
|
ComponentMapTemplate,
|
|
5
|
-
} from '@sitecore-content-sdk/
|
|
5
|
+
} from '@sitecore-content-sdk/content/tools';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import fs from 'fs';
|
|
8
8
|
import { getComponentList } from './templating/components';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Generate and write componentMap.ts file based on provided params.
|
|
12
|
-
* @param {GenerateMapArgs}
|
|
12
|
+
* @param {GenerateMapArgs} param - the parameters for the generateMap function.
|
|
13
|
+
* @public
|
|
13
14
|
*/
|
|
14
15
|
export const generateMap: GenerateMapFunction = ({
|
|
15
16
|
paths,
|
|
@@ -64,7 +65,7 @@ const buildAstroMapContent: ComponentMapTemplate = (components, componentImports
|
|
|
64
65
|
});
|
|
65
66
|
|
|
66
67
|
return `//@ts-nocheck
|
|
67
|
-
import { AstroContentSdkComponent } from '@
|
|
68
|
+
import type { AstroContentSdkComponent } from '@exdst-sitecore-content-sdk/astro';
|
|
68
69
|
|
|
69
70
|
// Components imported from the app itself
|
|
70
71
|
${wildcardImports.join('\n')}
|
package/src/tools/index.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
generateMetadata,
|
|
4
|
-
} from '@sitecore-content-sdk/core/tools';
|
|
1
|
+
export { generateMetadata } from '@sitecore-content-sdk/core/node-tools';
|
|
2
|
+
export { generateSites } from '@sitecore-content-sdk/content/node-tools';
|
|
5
3
|
|
|
6
4
|
export { generateMap } from './generate-map';
|
|
7
5
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { expect } from 'chai';
|
|
3
3
|
import sinon from 'sinon';
|
|
4
4
|
import { getComponentList } from './components';
|
|
5
|
-
import { ComponentFile } from '@sitecore-content-sdk/
|
|
5
|
+
import { ComponentFile } from '@sitecore-content-sdk/content/tools';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
|
|
8
8
|
describe('components', () => {
|
|
@@ -19,151 +19,160 @@ describe('components', () => {
|
|
|
19
19
|
it('should return results when one of "paths" is a glob pattern', () => {
|
|
20
20
|
const items = [
|
|
21
21
|
{
|
|
22
|
-
importPath: 'src/test-
|
|
23
|
-
filePath: path.normalize('src/test-
|
|
22
|
+
importPath: 'src/tests/test-components/map-components/Qux',
|
|
23
|
+
filePath: path.normalize('src/tests/test-components/map-components/Qux.astro'),
|
|
24
24
|
componentName: 'Qux',
|
|
25
25
|
moduleName: 'Qux',
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
|
-
importPath: 'src/test-
|
|
29
|
-
filePath: path.normalize('src/test-
|
|
28
|
+
importPath: 'src/tests/test-components/map-components/Foo',
|
|
29
|
+
filePath: path.normalize('src/tests/test-components/map-components/Foo.astro'),
|
|
30
30
|
componentName: 'Foo',
|
|
31
31
|
moduleName: 'Foo',
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
|
-
importPath: 'src/test-
|
|
35
|
-
filePath: path.normalize('src/test-
|
|
34
|
+
importPath: 'src/tests/test-components/map-components/Baz',
|
|
35
|
+
filePath: path.normalize('src/tests/test-components/map-components/Baz.astro'),
|
|
36
36
|
componentName: 'Baz',
|
|
37
37
|
moduleName: 'Baz',
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
|
-
importPath: 'src/test-
|
|
41
|
-
filePath: path.normalize('src/test-
|
|
40
|
+
importPath: 'src/tests/test-components/map-components/Bar',
|
|
41
|
+
filePath: path.normalize('src/tests/test-components/map-components/Bar.astro'),
|
|
42
42
|
componentName: 'Bar',
|
|
43
43
|
moduleName: 'Bar',
|
|
44
44
|
},
|
|
45
45
|
] as ComponentFile[];
|
|
46
46
|
|
|
47
|
-
const result = getComponentList(
|
|
47
|
+
const result = getComponentList(
|
|
48
|
+
['src/tests/test-components/map-components/*.astro'],
|
|
49
|
+
['**/*.test.*'],
|
|
50
|
+
false
|
|
51
|
+
);
|
|
48
52
|
expect(result).to.deep.equal(items);
|
|
49
53
|
});
|
|
50
54
|
|
|
51
55
|
it('should return results with all folded paths when path is a non-glob path', () => {
|
|
52
56
|
const items = [
|
|
53
57
|
{
|
|
54
|
-
importPath: 'src/test-
|
|
55
|
-
filePath: path.normalize('src/test-
|
|
58
|
+
importPath: 'src/tests/test-components/map-components/Qux',
|
|
59
|
+
filePath: path.normalize('src/tests/test-components/map-components/Qux.astro'),
|
|
56
60
|
componentName: 'Qux',
|
|
57
61
|
moduleName: 'Qux',
|
|
58
62
|
},
|
|
59
63
|
{
|
|
60
|
-
importPath: 'src/test-
|
|
61
|
-
filePath: path.normalize('src/test-
|
|
64
|
+
importPath: 'src/tests/test-components/map-components/Foo',
|
|
65
|
+
filePath: path.normalize('src/tests/test-components/map-components/Foo.astro'),
|
|
62
66
|
componentName: 'Foo',
|
|
63
67
|
moduleName: 'Foo',
|
|
64
68
|
},
|
|
65
69
|
{
|
|
66
|
-
importPath: 'src/test-
|
|
67
|
-
filePath: path.normalize('src/test-
|
|
70
|
+
importPath: 'src/tests/test-components/map-components/Baz',
|
|
71
|
+
filePath: path.normalize('src/tests/test-components/map-components/Baz.astro'),
|
|
68
72
|
componentName: 'Baz',
|
|
69
73
|
moduleName: 'Baz',
|
|
70
74
|
},
|
|
71
75
|
{
|
|
72
|
-
importPath: 'src/test-
|
|
73
|
-
filePath: path.normalize('src/test-
|
|
76
|
+
importPath: 'src/tests/test-components/map-components/Bar',
|
|
77
|
+
filePath: path.normalize('src/tests/test-components/map-components/Bar.astro'),
|
|
74
78
|
componentName: 'Bar',
|
|
75
79
|
moduleName: 'Bar',
|
|
76
80
|
},
|
|
77
81
|
{
|
|
78
|
-
importPath: 'src/test-
|
|
79
|
-
filePath: path.normalize('src/test-
|
|
82
|
+
importPath: 'src/tests/test-components/map-components/folded/Folded',
|
|
83
|
+
filePath: path.normalize('src/tests/test-components/map-components/folded/Folded.astro'),
|
|
80
84
|
componentName: 'Folded',
|
|
81
85
|
moduleName: 'Folded',
|
|
82
86
|
},
|
|
83
87
|
] as ComponentFile[];
|
|
84
88
|
|
|
85
|
-
const result = getComponentList(
|
|
89
|
+
const result = getComponentList(
|
|
90
|
+
['src/tests/test-components/map-components'],
|
|
91
|
+
['**/*.test.*'],
|
|
92
|
+
false
|
|
93
|
+
);
|
|
86
94
|
expect(result).to.deep.equal(items);
|
|
87
95
|
});
|
|
88
96
|
|
|
89
97
|
it('should filter out results that are not components', () => {
|
|
90
98
|
const items = [
|
|
91
99
|
{
|
|
92
|
-
importPath: 'src/test-
|
|
93
|
-
filePath: path.normalize('src/test-
|
|
100
|
+
importPath: 'src/tests/test-components/map-components/Qux',
|
|
101
|
+
filePath: path.normalize('src/tests/test-components/map-components/Qux.astro'),
|
|
94
102
|
componentName: 'Qux',
|
|
95
103
|
moduleName: 'Qux',
|
|
96
104
|
},
|
|
97
105
|
{
|
|
98
|
-
importPath: 'src/test-
|
|
99
|
-
filePath: path.normalize('src/test-
|
|
106
|
+
importPath: 'src/tests/test-components/map-components/Foo',
|
|
107
|
+
filePath: path.normalize('src/tests/test-components/map-components/Foo.astro'),
|
|
100
108
|
componentName: 'Foo',
|
|
101
109
|
moduleName: 'Foo',
|
|
102
110
|
},
|
|
103
111
|
{
|
|
104
|
-
importPath: 'src/test-
|
|
105
|
-
filePath: path.normalize('src/test-
|
|
112
|
+
importPath: 'src/tests/test-components/map-components/Baz',
|
|
113
|
+
filePath: path.normalize('src/tests/test-components/map-components/Baz.astro'),
|
|
106
114
|
componentName: 'Baz',
|
|
107
115
|
moduleName: 'Baz',
|
|
108
116
|
},
|
|
109
117
|
{
|
|
110
|
-
importPath: 'src/test-
|
|
111
|
-
filePath: path.normalize('src/test-
|
|
118
|
+
importPath: 'src/tests/test-components/map-components/Bar',
|
|
119
|
+
filePath: path.normalize('src/tests/test-components/map-components/Bar.astro'),
|
|
112
120
|
componentName: 'Bar',
|
|
113
121
|
moduleName: 'Bar',
|
|
114
122
|
},
|
|
115
123
|
{
|
|
116
|
-
importPath: 'src/test-
|
|
117
|
-
filePath: path.normalize('src/test-
|
|
124
|
+
importPath: 'src/tests/test-components/map-components/folded/Folded',
|
|
125
|
+
filePath: path.normalize('src/tests/test-components/map-components/folded/Folded.astro'),
|
|
118
126
|
componentName: 'Folded',
|
|
119
127
|
moduleName: 'Folded',
|
|
120
128
|
},
|
|
121
129
|
] as ComponentFile[];
|
|
122
130
|
|
|
123
|
-
const result = getComponentList(['src/test-
|
|
131
|
+
const result = getComponentList(['src/tests/test-components/map-components/**/*']);
|
|
124
132
|
expect(result).to.deep.equal(items);
|
|
125
133
|
});
|
|
126
134
|
|
|
127
135
|
it('should return result when "paths" contain exact paths to Astro components', () => {
|
|
128
136
|
const items = [
|
|
129
137
|
{
|
|
130
|
-
importPath: 'src/test-
|
|
131
|
-
filePath: path.normalize('src/test-
|
|
138
|
+
importPath: 'src/tests/test-components/map-components/Foo',
|
|
139
|
+
filePath: path.normalize('src/tests/test-components/map-components/Foo.astro'),
|
|
132
140
|
componentName: 'Foo',
|
|
133
141
|
moduleName: 'Foo',
|
|
134
142
|
},
|
|
135
143
|
{
|
|
136
|
-
importPath: 'src/test-
|
|
137
|
-
filePath: path.normalize('src/test-
|
|
144
|
+
importPath: 'src/tests/test-components/map-components/Bar',
|
|
145
|
+
filePath: path.normalize('src/tests/test-components/map-components/Bar.astro'),
|
|
138
146
|
componentName: 'Bar',
|
|
139
147
|
moduleName: 'Bar',
|
|
140
148
|
},
|
|
141
149
|
{
|
|
142
|
-
importPath: 'src/test-
|
|
143
|
-
filePath: path.normalize('src/test-
|
|
150
|
+
importPath: 'src/tests/test-components/map-components/Baz',
|
|
151
|
+
filePath: path.normalize('src/tests/test-components/map-components/Baz.astro'),
|
|
144
152
|
componentName: 'Baz',
|
|
145
153
|
moduleName: 'Baz',
|
|
146
154
|
},
|
|
147
155
|
{
|
|
148
|
-
importPath: 'src/test-
|
|
149
|
-
filePath: path.normalize('src/test-
|
|
156
|
+
importPath: 'src/tests/test-components/map-components/Qux',
|
|
157
|
+
filePath: path.normalize('src/tests/test-components/map-components/Qux.astro'),
|
|
150
158
|
componentName: 'Qux',
|
|
151
159
|
moduleName: 'Qux',
|
|
152
160
|
},
|
|
153
161
|
];
|
|
154
162
|
|
|
155
163
|
const result = getComponentList([
|
|
156
|
-
'src/test-
|
|
157
|
-
'src/test-
|
|
158
|
-
'src/test-
|
|
159
|
-
'src/test-
|
|
164
|
+
'src/tests/test-components/map-components/Foo.astro',
|
|
165
|
+
'src/tests/test-components/map-components/Bar.astro',
|
|
166
|
+
'src/tests/test-components/map-components/Baz.astro',
|
|
167
|
+
'src/tests/test-components/map-components/Qux.astro',
|
|
160
168
|
]);
|
|
161
169
|
expect(result).to.deep.equal(items);
|
|
162
170
|
});
|
|
163
171
|
|
|
164
172
|
it('should return filtered results when "exclude" contains a glob pattern', () => {
|
|
165
|
-
const exclude = ['**/components/**'];
|
|
166
|
-
expect(getComponentList(['src/test-
|
|
173
|
+
const exclude = ['**/test-components/map-components/**'];
|
|
174
|
+
expect(getComponentList(['src/tests/test-components/map-components/*.astro'], exclude)).to.be
|
|
175
|
+
.empty;
|
|
167
176
|
});
|
|
168
177
|
|
|
169
178
|
it('should return variants in results when includeVariants is true', () => {
|
|
@@ -171,82 +180,86 @@ describe('components', () => {
|
|
|
171
180
|
|
|
172
181
|
const items = [
|
|
173
182
|
{
|
|
174
|
-
importPath: 'src/test-
|
|
175
|
-
filePath: path.normalize('src/test-
|
|
183
|
+
importPath: 'src/tests/test-components/map-components/Qux',
|
|
184
|
+
filePath: path.normalize('src/tests/test-components/map-components/Qux.astro'),
|
|
176
185
|
componentName: 'Qux',
|
|
177
186
|
moduleName: 'Qux',
|
|
178
187
|
},
|
|
179
188
|
// variant component
|
|
180
189
|
{
|
|
181
|
-
importPath: 'src/test-
|
|
182
|
-
filePath: path.normalize('src/test-
|
|
190
|
+
importPath: 'src/tests/test-components/map-components/Hero.variant',
|
|
191
|
+
filePath: path.normalize('src/tests/test-components/map-components/Hero.variant.astro'),
|
|
183
192
|
componentName: 'Hero.variant',
|
|
184
193
|
moduleName: 'Herovariant',
|
|
185
194
|
},
|
|
186
195
|
{
|
|
187
|
-
importPath: 'src/test-
|
|
188
|
-
filePath: path.normalize('src/test-
|
|
196
|
+
importPath: 'src/tests/test-components/map-components/Foo',
|
|
197
|
+
filePath: path.normalize('src/tests/test-components/map-components/Foo.astro'),
|
|
189
198
|
componentName: 'Foo',
|
|
190
199
|
moduleName: 'Foo',
|
|
191
200
|
},
|
|
192
201
|
{
|
|
193
|
-
importPath: 'src/test-
|
|
194
|
-
filePath: path.normalize('src/test-
|
|
202
|
+
importPath: 'src/tests/test-components/map-components/Baz',
|
|
203
|
+
filePath: path.normalize('src/tests/test-components/map-components/Baz.astro'),
|
|
195
204
|
componentName: 'Baz',
|
|
196
205
|
moduleName: 'Baz',
|
|
197
206
|
},
|
|
198
207
|
{
|
|
199
|
-
importPath: 'src/test-
|
|
200
|
-
filePath: path.normalize('src/test-
|
|
208
|
+
importPath: 'src/tests/test-components/map-components/Bar',
|
|
209
|
+
filePath: path.normalize('src/tests/test-components/map-components/Bar.astro'),
|
|
201
210
|
componentName: 'Bar',
|
|
202
211
|
moduleName: 'Bar',
|
|
203
212
|
},
|
|
204
213
|
{
|
|
205
|
-
importPath: 'src/test-
|
|
206
|
-
filePath: path.normalize('src/test-
|
|
214
|
+
importPath: 'src/tests/test-components/map-components/folded/Folded',
|
|
215
|
+
filePath: path.normalize('src/tests/test-components/map-components/folded/Folded.astro'),
|
|
207
216
|
componentName: 'Folded',
|
|
208
217
|
moduleName: 'Folded',
|
|
209
218
|
},
|
|
210
219
|
] as ComponentFile[];
|
|
211
220
|
|
|
212
|
-
const result = getComponentList(
|
|
221
|
+
const result = getComponentList(
|
|
222
|
+
['src/tests/test-components/map-components'],
|
|
223
|
+
['**/*.test.*'],
|
|
224
|
+
true
|
|
225
|
+
);
|
|
213
226
|
expect(result).to.deep.equal(items);
|
|
214
227
|
});
|
|
215
228
|
|
|
216
229
|
it('should return filtered results when "exclude" contains an exact path', () => {
|
|
217
|
-
const exclude = ['src/test-
|
|
218
|
-
getComponentList(['src/test-
|
|
230
|
+
const exclude = ['src/tests/test-components/map-components/Foo.astro'];
|
|
231
|
+
getComponentList(['src/tests/test-components/map-components/*.astro'], exclude);
|
|
219
232
|
});
|
|
220
233
|
|
|
221
234
|
it('should return correct result in unix file systems', () => {
|
|
222
235
|
const stubbedPaths = [
|
|
223
|
-
'src/test-
|
|
224
|
-
'src/test-
|
|
225
|
-
'src/test-
|
|
226
|
-
'src/test-
|
|
236
|
+
'src/tests/test-components/map-components/Foo.astro',
|
|
237
|
+
'src/tests/test-components/map-components/Bar.astro',
|
|
238
|
+
'src/tests/test-components/map-components/Baz.astro',
|
|
239
|
+
'src/tests/test-components/map-components/Qux.astro',
|
|
227
240
|
];
|
|
228
241
|
const expected = [
|
|
229
242
|
{
|
|
230
|
-
importPath: 'src/test-
|
|
231
|
-
filePath: 'src/test-
|
|
243
|
+
importPath: 'src/tests/test-components/map-components/Foo',
|
|
244
|
+
filePath: 'src/tests/test-components/map-components/Foo.astro',
|
|
232
245
|
componentName: 'Foo',
|
|
233
246
|
moduleName: 'Foo',
|
|
234
247
|
},
|
|
235
248
|
{
|
|
236
|
-
importPath: 'src/test-
|
|
237
|
-
filePath: 'src/test-
|
|
249
|
+
importPath: 'src/tests/test-components/map-components/Bar',
|
|
250
|
+
filePath: 'src/tests/test-components/map-components/Bar.astro',
|
|
238
251
|
componentName: 'Bar',
|
|
239
252
|
moduleName: 'Bar',
|
|
240
253
|
},
|
|
241
254
|
{
|
|
242
|
-
importPath: 'src/test-
|
|
243
|
-
filePath: 'src/test-
|
|
255
|
+
importPath: 'src/tests/test-components/map-components/Baz',
|
|
256
|
+
filePath: 'src/tests/test-components/map-components/Baz.astro',
|
|
244
257
|
componentName: 'Baz',
|
|
245
258
|
moduleName: 'Baz',
|
|
246
259
|
},
|
|
247
260
|
{
|
|
248
|
-
importPath: 'src/test-
|
|
249
|
-
filePath: 'src/test-
|
|
261
|
+
importPath: 'src/tests/test-components/map-components/Qux',
|
|
262
|
+
filePath: 'src/tests/test-components/map-components/Qux.astro',
|
|
250
263
|
componentName: 'Qux',
|
|
251
264
|
moduleName: 'Qux',
|
|
252
265
|
},
|
|
@@ -254,7 +267,7 @@ describe('components', () => {
|
|
|
254
267
|
|
|
255
268
|
const globSyncStub = sandbox.stub(require('glob'), 'sync').returns(stubbedPaths);
|
|
256
269
|
|
|
257
|
-
const result = getComponentList(['src/test-
|
|
270
|
+
const result = getComponentList(['src/tests/test-components/map-components/*.astro']);
|
|
258
271
|
expect(result).to.deep.equal(expected);
|
|
259
272
|
|
|
260
273
|
globSyncStub.restore();
|
|
@@ -262,33 +275,33 @@ describe('components', () => {
|
|
|
262
275
|
|
|
263
276
|
it('should return correct result in windows file systems', () => {
|
|
264
277
|
const stubbedPaths = [
|
|
265
|
-
'src\\test-
|
|
266
|
-
'src\\test-
|
|
267
|
-
'src\\test-
|
|
268
|
-
'src\\test-
|
|
278
|
+
'src\\tests\\test-components\\map-components\\Foo.astro',
|
|
279
|
+
'src\\tests\\test-components\\map-components\\Bar.astro',
|
|
280
|
+
'src\\tests\\test-components\\map-components\\Baz.astro',
|
|
281
|
+
'src\\tests\\test-components\\map-components\\Qux.astro',
|
|
269
282
|
];
|
|
270
283
|
const expected = [
|
|
271
284
|
{
|
|
272
|
-
importPath: 'src/test-
|
|
273
|
-
filePath: 'src\\test-
|
|
285
|
+
importPath: 'src/tests/test-components/map-components/Foo',
|
|
286
|
+
filePath: 'src\\tests\\test-components\\map-components\\Foo.astro',
|
|
274
287
|
componentName: 'Foo',
|
|
275
288
|
moduleName: 'Foo',
|
|
276
289
|
},
|
|
277
290
|
{
|
|
278
|
-
importPath: 'src/test-
|
|
279
|
-
filePath: 'src\\test-
|
|
291
|
+
importPath: 'src/tests/test-components/map-components/Bar',
|
|
292
|
+
filePath: 'src\\tests\\test-components\\map-components\\Bar.astro',
|
|
280
293
|
componentName: 'Bar',
|
|
281
294
|
moduleName: 'Bar',
|
|
282
295
|
},
|
|
283
296
|
{
|
|
284
|
-
importPath: 'src/test-
|
|
285
|
-
filePath: 'src\\test-
|
|
297
|
+
importPath: 'src/tests/test-components/map-components/Baz',
|
|
298
|
+
filePath: 'src\\tests\\test-components\\map-components\\Baz.astro',
|
|
286
299
|
componentName: 'Baz',
|
|
287
300
|
moduleName: 'Baz',
|
|
288
301
|
},
|
|
289
302
|
{
|
|
290
|
-
importPath: 'src/test-
|
|
291
|
-
filePath: 'src\\test-
|
|
303
|
+
importPath: 'src/tests/test-components/map-components/Qux',
|
|
304
|
+
filePath: 'src\\tests\\test-components\\map-components\\Qux.astro',
|
|
292
305
|
componentName: 'Qux',
|
|
293
306
|
moduleName: 'Qux',
|
|
294
307
|
},
|
|
@@ -296,7 +309,7 @@ describe('components', () => {
|
|
|
296
309
|
|
|
297
310
|
const globSyncStub = sandbox.stub(require('glob'), 'sync').returns(stubbedPaths);
|
|
298
311
|
|
|
299
|
-
const result = getComponentList(['src/test-
|
|
312
|
+
const result = getComponentList(['src/tests/test-components/map-components/*.astro']);
|
|
300
313
|
expect(result).to.deep.equal(expected);
|
|
301
314
|
|
|
302
315
|
globSyncStub.restore();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as glob from 'glob';
|
|
2
|
-
import { ComponentFile } from '@sitecore-content-sdk/
|
|
2
|
+
import { ComponentFile } from '@sitecore-content-sdk/content/tools';
|
|
3
3
|
|
|
4
4
|
const componentNamePattern = /^[\/]*(.+[\/\\])*(.+)\.astro?$/;
|
|
5
5
|
|
|
@@ -16,6 +16,7 @@ const componentPathPattern = /^([\/]*.+[\/\\].+)\..+$/;
|
|
|
16
16
|
* @param {string[]} paths paths to search
|
|
17
17
|
* @param {string[]} [exclude] paths and glob patterns to exclude from final result
|
|
18
18
|
* @param {boolean} [includeVariants] whether to include variant components
|
|
19
|
+
* @internal
|
|
19
20
|
*/
|
|
20
21
|
export function getComponentList(
|
|
21
22
|
paths: string[],
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import {
|
|
3
|
-
ScaffoldTemplate,
|
|
4
|
-
ComponentTemplateType,
|
|
5
|
-
} from '@sitecore-content-sdk/core/config';
|
|
2
|
+
import { ScaffoldTemplate, ComponentTemplateType } from '@sitecore-content-sdk/content/config';
|
|
6
3
|
import { COMPONENT_FILE_EXTENSION } from './constants';
|
|
7
4
|
|
|
8
5
|
/**
|
|
@@ -13,7 +10,7 @@ import { COMPONENT_FILE_EXTENSION } from './constants';
|
|
|
13
10
|
const generateTemplate = (componentName: string): string => {
|
|
14
11
|
return `
|
|
15
12
|
---
|
|
16
|
-
import { Field } from "@
|
|
13
|
+
import { Field } from "@exdst-sitecore-content-sdk/astro";
|
|
17
14
|
|
|
18
15
|
interface Fields {
|
|
19
16
|
Title: Field<string>;
|
|
@@ -47,9 +44,7 @@ const getNextSteps = (componentOutputPath: string): string[] => {
|
|
|
47
44
|
const nextSteps = [];
|
|
48
45
|
|
|
49
46
|
if (componentOutputPath) {
|
|
50
|
-
nextSteps.push(
|
|
51
|
-
`* Implement the Astro component in ${chalk.green(componentOutputPath)}`
|
|
52
|
-
);
|
|
47
|
+
nextSteps.push(`* Implement the Astro component in ${chalk.green(componentOutputPath)}`);
|
|
53
48
|
}
|
|
54
49
|
|
|
55
50
|
return nextSteps;
|
package/src/utils/utils.ts
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/
|
|
1
4
|
export const getEditingSecret = (): string => {
|
|
2
|
-
const secret =
|
|
5
|
+
const secret = process.env.SITECORE_EDITING_SECRET;
|
|
3
6
|
|
|
4
7
|
if (!secret || secret.length === 0) {
|
|
5
8
|
throw new Error('The SITECORE_EDITING_SECRET environment variable is missing or invalid.');
|
|
6
9
|
}
|
|
7
|
-
return secret
|
|
10
|
+
return secret;
|
|
8
11
|
};
|
|
9
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Extracts the path from the Astro context parameters.
|
|
15
|
+
* @param {Record<string, string | undefined>} params - The Astro context parameters.
|
|
16
|
+
* @returns The extracted path.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
10
19
|
export const extractPath = (params: Record<string, string | undefined>) => {
|
|
11
20
|
return params === undefined
|
|
12
21
|
? '/'
|
|
@@ -15,6 +24,14 @@ export const extractPath = (params: Record<string, string | undefined>) => {
|
|
|
15
24
|
: params.path ?? '/';
|
|
16
25
|
};
|
|
17
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Removes a leading language segment from a given path.
|
|
29
|
+
* Handles paths with or without a preceding `_site_` segment (e.g. `/en/About`, `/_site_Basic/en/About`).
|
|
30
|
+
* @param {string} path - The path that may contain a language segment.
|
|
31
|
+
* @param {string[]} languages - The list of supported language codes to strip from the path.
|
|
32
|
+
* @returns The path without the leading language segment, defaulting to `'/'` when empty.
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
18
35
|
export const removeLanguageFromPath = (path: string, languages: string[]): string => {
|
|
19
36
|
const segments = path.split('/');
|
|
20
37
|
|
|
@@ -36,6 +53,7 @@ export const removeLanguageFromPath = (path: string, languages: string[]): strin
|
|
|
36
53
|
* "class" property will be transformed into or appended to "className" instead.
|
|
37
54
|
* @param {string} otherAttrs all other props included on the image component
|
|
38
55
|
* @returns {void}
|
|
56
|
+
* @public
|
|
39
57
|
*/
|
|
40
58
|
export const addClassName = (otherAttrs: { [key: string]: unknown }): void => {
|
|
41
59
|
if (otherAttrs.class) {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/{test-data/components → tests/test-components/map-components}/Hero.variant.astro
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/{test-data/components → tests/test-components/map-components}/folded/Folded.astro
RENAMED
|
File without changes
|
/package/src/{test-data/components → tests/test-components/map-components}/folded/random-file-2.docx
RENAMED
|
File without changes
|
|
File without changes
|