@commercetools-frontend/mc-scripts 21.7.0 → 21.8.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/LICENSE +1 -1
- package/README.md +1 -42
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts +1 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.js +7 -0
- package/{build/config/application-runtime.js → application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js} +2 -2
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.esm.js +5 -0
- package/application-runtime/package.json +4 -0
- package/bin/cli.js +1 -1
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts +1 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +354 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.js +7 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +354 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +338 -0
- package/cli/package.json +4 -0
- package/config/create-webpack-config-for-development.js +7 -1
- package/config/create-webpack-config-for-production.js +7 -1
- package/config/vendors-to-transpile.js +5 -1
- package/dist/build-8582b673.esm.js +209 -0
- package/dist/build-9395925a.cjs.prod.js +224 -0
- package/dist/build-97278377.cjs.dev.js +224 -0
- package/dist/build-vite-6c987a60.cjs.dev.js +109 -0
- package/dist/build-vite-76d44332.cjs.prod.js +109 -0
- package/dist/build-vite-a9602b19.esm.js +97 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.d.ts +1 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +30 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.js +7 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +30 -0
- package/dist/commercetools-frontend-mc-scripts.esm.js +22 -0
- package/dist/compile-html-0c588a89.cjs.dev.js +93 -0
- package/dist/compile-html-4832f8c5.esm.js +83 -0
- package/dist/compile-html-7654b5e6.cjs.prod.js +93 -0
- package/dist/config-sync-20bc05e8.esm.js +868 -0
- package/dist/config-sync-62824317.cjs.prod.js +887 -0
- package/dist/config-sync-d52e73f6.cjs.dev.js +892 -0
- package/dist/create-postcss-config-4cbe10ab.cjs.dev.js +90 -0
- package/dist/create-postcss-config-8ea16440.cjs.prod.js +90 -0
- package/{build/config/create-postcss-config.js → dist/create-postcss-config-c1aa3525.esm.js} +27 -25
- package/{build/config/create-webpack-config-for-development.js → dist/create-webpack-config-for-development-8a8b84d6.esm.js} +92 -56
- package/dist/create-webpack-config-for-development-a5e73092.cjs.prod.js +418 -0
- package/dist/create-webpack-config-for-development-e2735e02.cjs.dev.js +418 -0
- package/dist/create-webpack-config-for-production-4e7b56c0.cjs.prod.js +468 -0
- package/{build/config/create-webpack-config-for-production.js → dist/create-webpack-config-for-production-7dc669e5.esm.js} +117 -52
- package/dist/create-webpack-config-for-production-d9bf281c.cjs.dev.js +468 -0
- package/dist/declarations/src/application-runtime.d.ts +1 -0
- package/dist/declarations/src/cli.d.ts +4 -0
- package/dist/declarations/src/commands/build-vite.d.ts +2 -0
- package/dist/declarations/src/commands/build.d.ts +2 -0
- package/dist/declarations/src/commands/compile-html.d.ts +3 -0
- package/dist/declarations/src/commands/config-sync.d.ts +3 -0
- package/dist/declarations/src/commands/login.d.ts +2 -0
- package/dist/declarations/src/commands/serve.d.ts +2 -0
- package/dist/declarations/src/commands/start-vite.d.ts +2 -0
- package/dist/declarations/src/commands/start.d.ts +2 -0
- package/dist/declarations/src/config/create-postcss-config.d.ts +4 -0
- package/dist/declarations/src/config/create-webpack-config-for-development.d.ts +10 -0
- package/dist/declarations/src/config/create-webpack-config-for-production.d.ts +10 -0
- package/dist/declarations/src/config/has-jsx-runtime.d.ts +2 -0
- package/dist/declarations/src/config/paths.d.ts +12 -0
- package/dist/declarations/src/config/vendors-to-transpile.d.ts +2 -0
- package/dist/declarations/src/config/webpack-dev-server.config.d.ts +6 -0
- package/dist/declarations/src/deprecated-entry-points.d.ts +7 -0
- package/dist/declarations/src/generated/core.d.ts +710 -0
- package/dist/declarations/src/generated/settings.d.ts +2383 -0
- package/dist/declarations/src/index.d.ts +3 -0
- package/dist/declarations/src/postcss.d.ts +1 -0
- package/dist/declarations/src/types.d.ts +82 -0
- package/dist/declarations/src/utils/auth.d.ts +6 -0
- package/dist/declarations/src/utils/credentials-storage.d.ts +11 -0
- package/dist/declarations/src/utils/get-config-diff.d.ts +3 -0
- package/dist/declarations/src/utils/graphql-requests.d.ts +80 -0
- package/dist/declarations/src/utils/user-agent.d.ts +2 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/dist/declarations/src/webpack-plugins/final-stats-writer-plugin.d.ts +12 -0
- package/dist/declarations/src/webpack-plugins/local-html-webpack-plugin.d.ts +5 -0
- package/dist/declarations/src/webpack.d.ts +2 -0
- package/dist/has-jsx-runtime-0b03b72e.cjs.prod.js +17 -0
- package/dist/has-jsx-runtime-3d4bb633.cjs.dev.js +17 -0
- package/{build/config/has-jsx-runtime.js → dist/has-jsx-runtime-8314226e.esm.js} +1 -3
- package/dist/login-706ccc9a.cjs.prod.js +165 -0
- package/dist/login-779552b7.cjs.dev.js +165 -0
- package/dist/login-7d94659e.esm.js +155 -0
- package/dist/package-a98de907.esm.js +133 -0
- package/dist/package-aaf61bf0.cjs.dev.js +135 -0
- package/dist/package-b5c040f3.cjs.prod.js +135 -0
- package/dist/paths-16823f56.cjs.dev.js +55 -0
- package/dist/paths-76b66e74.cjs.prod.js +55 -0
- package/dist/paths-ed23d5a1.esm.js +46 -0
- package/dist/serve-12de323b.cjs.dev.js +70 -0
- package/dist/serve-784f4fcd.cjs.prod.js +70 -0
- package/dist/serve-d6b437b1.esm.js +62 -0
- package/dist/start-2b953ab0.cjs.dev.js +209 -0
- package/dist/start-e3ccd672.cjs.prod.js +209 -0
- package/dist/start-e924bd5d.esm.js +194 -0
- package/dist/start-vite-737bacca.cjs.dev.js +149 -0
- package/dist/start-vite-b0f58ae4.cjs.prod.js +149 -0
- package/dist/start-vite-ec5d40b5.esm.js +136 -0
- package/dist/user-agent-5da1830b.cjs.dev.js +106 -0
- package/dist/user-agent-8044acd6.esm.js +94 -0
- package/dist/user-agent-d18809af.cjs.prod.js +106 -0
- package/dist/vendors-to-transpile-367e0ba8.cjs.prod.js +5 -0
- package/dist/vendors-to-transpile-68e03526.esm.js +3 -0
- package/dist/vendors-to-transpile-b51af5d3.cjs.dev.js +5 -0
- package/package.json +41 -39
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts +1 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +14 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.js +7 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +14 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +6 -0
- package/postcss/package.json +4 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts +1 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +51 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.js +7 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +51 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +42 -0
- package/webpack/package.json +4 -0
- package/build/bin/cli.js +0 -264
- package/build/commands/build-vite.js +0 -91
- package/build/commands/build.js +0 -140
- package/build/commands/compile-html.js +0 -53
- package/build/commands/config-sync.js +0 -176
- package/build/commands/login.js +0 -60
- package/build/commands/serve.js +0 -37
- package/build/commands/start-vite.js +0 -138
- package/build/commands/start.js +0 -108
- package/build/config/paths.js +0 -38
- package/build/config/vendors-to-transpile.js +0 -3
- package/build/config/webpack-dev-server.config.js +0 -69
- package/build/index.js +0 -16
- package/build/utils/auth.js +0 -34
- package/build/utils/auth.spec.js +0 -61
- package/build/utils/create-custom-application.settings.graphql +0 -8
- package/build/utils/credentials-storage.js +0 -72
- package/build/utils/credentials-storage.spec.js +0 -69
- package/build/utils/fetch-custom-application.settings.graphql +0 -36
- package/build/utils/fetch-user-organizations.core.graphql +0 -9
- package/build/utils/get-config-diff.js +0 -308
- package/build/utils/get-config-diff.spec.js +0 -285
- package/build/utils/graphql-requests.js +0 -105
- package/build/utils/graphql-requests.spec.js +0 -159
- package/build/utils/require-graphql.js +0 -15
- package/build/utils/update-custom-application.settings.graphql +0 -13
- package/build/utils/user-agent.js +0 -15
- package/build/webpack-plugins/final-stats-writer-plugin.js +0 -50
- package/build/webpack-plugins/local-html-webpack-plugin.js +0 -38
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const getConfigDiff = require('./get-config-diff');
|
|
4
|
-
|
|
5
|
-
const createTestConfig = customConfig => ({
|
|
6
|
-
entryPointUriPath: 'my-test-app',
|
|
7
|
-
name: 'test name',
|
|
8
|
-
description: 'test description',
|
|
9
|
-
url: 'https://test.com',
|
|
10
|
-
icon: '<svg><path fill="#000000"></path></svg>',
|
|
11
|
-
permissions: [],
|
|
12
|
-
mainMenuLink: {},
|
|
13
|
-
submenuLinks: [],
|
|
14
|
-
...customConfig
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
describe('when there are no changes', () => {
|
|
18
|
-
it('should display no diff', () => {
|
|
19
|
-
expect(getConfigDiff(createTestConfig(), createTestConfig())).toBe('');
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
describe('when there are changes', () => {
|
|
23
|
-
it('should display diff if "name", "description", "icon", "url" changed', () => {
|
|
24
|
-
const newConfig = createTestConfig({
|
|
25
|
-
name: 'updated test name',
|
|
26
|
-
description: 'updated description',
|
|
27
|
-
url: 'https://updated-test.com',
|
|
28
|
-
icon: '<svg><path fill="#ffffff"></path></svg>'
|
|
29
|
-
});
|
|
30
|
-
expect(getConfigDiff(createTestConfig(), newConfig)).toMatchInlineSnapshot(`
|
|
31
|
-
"name changed: <color-red>test name</color-red> => <color-green>updated test name</color-green>
|
|
32
|
-
description changed: <color-red>test description</color-red> => <color-green>updated description</color-green>
|
|
33
|
-
url changed: <color-red>https://test.com</color-red> => <color-green>https://updated-test.com</color-green>
|
|
34
|
-
icon changed: <color-red><svg><path fill=\\"#000000\\"></path></svg></color-red> => <color-green><svg><path fill=\\"#ffffff\\"></path></svg></color-green>"
|
|
35
|
-
`);
|
|
36
|
-
});
|
|
37
|
-
it('should display diff if "description" is removed', () => {
|
|
38
|
-
const newConfig = createTestConfig({
|
|
39
|
-
description: undefined
|
|
40
|
-
});
|
|
41
|
-
expect(getConfigDiff(createTestConfig(), newConfig)).toMatchInlineSnapshot(`"description removed: <color-red>test description</color-red>"`);
|
|
42
|
-
});
|
|
43
|
-
it('should display diff for "permissions"', () => {
|
|
44
|
-
const oldConfig = createTestConfig({
|
|
45
|
-
permissions: [{
|
|
46
|
-
oAuthScopes: ['manage_product'],
|
|
47
|
-
name: 'manageMyTestApp'
|
|
48
|
-
}, {
|
|
49
|
-
oAuthScopes: ['view_products', 'view_customers'],
|
|
50
|
-
name: 'viewMyTestApp'
|
|
51
|
-
}]
|
|
52
|
-
});
|
|
53
|
-
const newConfig = createTestConfig({
|
|
54
|
-
permissions: [{
|
|
55
|
-
oAuthScopes: ['manage_customer'],
|
|
56
|
-
name: 'manageMyTestApp'
|
|
57
|
-
}, {
|
|
58
|
-
oAuthScopes: ['view_products', 'view_customers', 'view_orders'],
|
|
59
|
-
name: 'viewMyTestApp'
|
|
60
|
-
}]
|
|
61
|
-
});
|
|
62
|
-
expect(getConfigDiff(oldConfig, newConfig)).toMatchInlineSnapshot(`
|
|
63
|
-
"permissions changed
|
|
64
|
-
\\"manageMyTestApp\\" changed
|
|
65
|
-
oauth scope added: <color-green>manage_customer</color-green>
|
|
66
|
-
oauth scope removed: <color-red>manage_product</color-red>
|
|
67
|
-
\\"viewMyTestApp\\" changed
|
|
68
|
-
oauth scope added: <color-green>view_orders</color-green>"
|
|
69
|
-
`);
|
|
70
|
-
});
|
|
71
|
-
describe('for "mainMenuLink"', () => {
|
|
72
|
-
it('should display diff for "mainMenuLink" when assigning new permissions', () => {
|
|
73
|
-
const oldConfig = createTestConfig({
|
|
74
|
-
mainMenuLink: {
|
|
75
|
-
defaultLabel: 'Avengers',
|
|
76
|
-
permissions: [],
|
|
77
|
-
labelAllLocales: []
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
const newConfig = createTestConfig({
|
|
81
|
-
mainMenuLink: {
|
|
82
|
-
defaultLabel: 'Avengers',
|
|
83
|
-
permissions: ['ViewMyTestApp'],
|
|
84
|
-
labelAllLocales: []
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
expect(getConfigDiff(oldConfig, newConfig)).toMatchInlineSnapshot(`
|
|
88
|
-
"mainMenuLink changed
|
|
89
|
-
permissions changed
|
|
90
|
-
applied permission added: <color-green>ViewMyTestApp</color-green>"
|
|
91
|
-
`);
|
|
92
|
-
});
|
|
93
|
-
it('should display diff for "mainMenuLink" when removing permissions', () => {
|
|
94
|
-
const oldConfig = createTestConfig({
|
|
95
|
-
mainMenuLink: {
|
|
96
|
-
defaultLabel: 'Avengers',
|
|
97
|
-
permissions: ['ViewMyTestApp'],
|
|
98
|
-
labelAllLocales: []
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
const newConfig = createTestConfig({
|
|
102
|
-
mainMenuLink: {
|
|
103
|
-
defaultLabel: 'Avengers',
|
|
104
|
-
permissions: [],
|
|
105
|
-
labelAllLocales: []
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
expect(getConfigDiff(oldConfig, newConfig)).toMatchInlineSnapshot(`
|
|
109
|
-
"mainMenuLink changed
|
|
110
|
-
permissions changed
|
|
111
|
-
applied permission removed: <color-red>ViewMyTestApp</color-red>"
|
|
112
|
-
`);
|
|
113
|
-
});
|
|
114
|
-
it('should display diff for "mainMenuLink" when assigning new labels', () => {
|
|
115
|
-
const oldConfig = createTestConfig({
|
|
116
|
-
mainMenuLink: {
|
|
117
|
-
defaultLabel: 'Avengers',
|
|
118
|
-
permissions: [],
|
|
119
|
-
labelAllLocales: []
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
const newConfig = createTestConfig({
|
|
123
|
-
mainMenuLink: {
|
|
124
|
-
defaultLabel: 'Avengers',
|
|
125
|
-
permissions: [],
|
|
126
|
-
labelAllLocales: [{
|
|
127
|
-
locale: 'de',
|
|
128
|
-
value: 'Die Avengers'
|
|
129
|
-
}]
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
expect(getConfigDiff(oldConfig, newConfig)).toMatchInlineSnapshot(`
|
|
133
|
-
"mainMenuLink changed
|
|
134
|
-
labelAllLocales changed
|
|
135
|
-
locale added: <color-green>de</color-green>"
|
|
136
|
-
`);
|
|
137
|
-
});
|
|
138
|
-
it('should display diff for "mainMenuLink" when removing labels', () => {
|
|
139
|
-
const oldConfig = createTestConfig({
|
|
140
|
-
mainMenuLink: {
|
|
141
|
-
defaultLabel: 'Avengers',
|
|
142
|
-
permissions: [],
|
|
143
|
-
labelAllLocales: [{
|
|
144
|
-
locale: 'de',
|
|
145
|
-
value: 'Die Avengers'
|
|
146
|
-
}]
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
const newConfig = createTestConfig({
|
|
150
|
-
mainMenuLink: {
|
|
151
|
-
defaultLabel: 'Avengers',
|
|
152
|
-
permissions: [],
|
|
153
|
-
labelAllLocales: []
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
expect(getConfigDiff(oldConfig, newConfig)).toMatchInlineSnapshot(`
|
|
157
|
-
"mainMenuLink changed
|
|
158
|
-
labelAllLocales changed
|
|
159
|
-
locale removed: <color-red>de</color-red>"
|
|
160
|
-
`);
|
|
161
|
-
});
|
|
162
|
-
it('should display multiple diff for changes of existing "mainMenuLink"', () => {
|
|
163
|
-
const oldConfig = createTestConfig({
|
|
164
|
-
mainMenuLink: {
|
|
165
|
-
defaultLabel: 'Avengers',
|
|
166
|
-
permissions: ['ViewMyTestApp'],
|
|
167
|
-
labelAllLocales: [{
|
|
168
|
-
locale: 'de',
|
|
169
|
-
value: 'Die Avengers'
|
|
170
|
-
}, {
|
|
171
|
-
locale: 'en',
|
|
172
|
-
value: 'The Avengers'
|
|
173
|
-
}]
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
const newConfig = createTestConfig({
|
|
177
|
-
mainMenuLink: {
|
|
178
|
-
defaultLabel: 'Justice League',
|
|
179
|
-
permissions: ['ManageMyTestApp'],
|
|
180
|
-
labelAllLocales: [{
|
|
181
|
-
locale: 'de',
|
|
182
|
-
value: 'Die Justice League'
|
|
183
|
-
}, {
|
|
184
|
-
locale: 'it',
|
|
185
|
-
value: 'La Justice League'
|
|
186
|
-
}]
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
expect(getConfigDiff(oldConfig, newConfig)).toMatchInlineSnapshot(`
|
|
190
|
-
"mainMenuLink changed
|
|
191
|
-
defaultLabel changed: <color-red>Avengers</color-red> => <color-green>Justice League</color-green>
|
|
192
|
-
permissions changed
|
|
193
|
-
applied permission added: <color-green>ManageMyTestApp</color-green>
|
|
194
|
-
applied permission removed: <color-red>ViewMyTestApp</color-red>
|
|
195
|
-
labelAllLocales changed
|
|
196
|
-
locale \\"de\\" changed: <color-red>Die Avengers</color-red> => <color-green>Die Justice League</color-green>
|
|
197
|
-
locale added: <color-green>it</color-green>
|
|
198
|
-
locale removed: <color-red>en</color-red>"
|
|
199
|
-
`);
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
describe('for "submenuLinks"', () => {
|
|
203
|
-
it('should display diff for "submenuLinks" when adding a new menu link', () => {
|
|
204
|
-
const oldConfig = createTestConfig({
|
|
205
|
-
submenuLinks: []
|
|
206
|
-
});
|
|
207
|
-
const newConfig = createTestConfig({
|
|
208
|
-
submenuLinks: [{
|
|
209
|
-
uriPath: 'my-test-app/new',
|
|
210
|
-
defaultLabel: 'New Avenger',
|
|
211
|
-
permissions: ['ManageMyTestApp'],
|
|
212
|
-
labelAllLocales: [{
|
|
213
|
-
locale: 'de',
|
|
214
|
-
value: 'Neu Avenger'
|
|
215
|
-
}]
|
|
216
|
-
}]
|
|
217
|
-
});
|
|
218
|
-
expect(getConfigDiff(oldConfig, newConfig)).toMatchInlineSnapshot(`
|
|
219
|
-
"submenuLink changed
|
|
220
|
-
menu link added: <color-green>my-test-app/new</color-green>"
|
|
221
|
-
`);
|
|
222
|
-
});
|
|
223
|
-
it('should display diff for "submenuLinks" when removing a menu link', () => {
|
|
224
|
-
const oldConfig = createTestConfig({
|
|
225
|
-
submenuLinks: [{
|
|
226
|
-
uriPath: 'my-test-app/new',
|
|
227
|
-
defaultLabel: 'New Avenger',
|
|
228
|
-
permissions: ['ManageMyTestApp'],
|
|
229
|
-
labelAllLocales: [{
|
|
230
|
-
locale: 'de',
|
|
231
|
-
value: 'Neu Avenger'
|
|
232
|
-
}]
|
|
233
|
-
}]
|
|
234
|
-
});
|
|
235
|
-
const newConfig = createTestConfig({
|
|
236
|
-
submenuLinks: []
|
|
237
|
-
});
|
|
238
|
-
expect(getConfigDiff(oldConfig, newConfig)).toMatchInlineSnapshot(`
|
|
239
|
-
"submenuLink changed
|
|
240
|
-
menu link removed: <color-red>my-test-app/new</color-red>"
|
|
241
|
-
`);
|
|
242
|
-
});
|
|
243
|
-
it('should display multiple diff for changes of existing "submenuLinks"', () => {
|
|
244
|
-
const oldConfig = createTestConfig({
|
|
245
|
-
submenuLinks: [{
|
|
246
|
-
uriPath: 'my-test-app/new',
|
|
247
|
-
defaultLabel: 'New Avenger',
|
|
248
|
-
permissions: ['ManageMyTestApp'],
|
|
249
|
-
labelAllLocales: [{
|
|
250
|
-
locale: 'de',
|
|
251
|
-
value: 'Neu Avenger'
|
|
252
|
-
}, {
|
|
253
|
-
locale: 'en',
|
|
254
|
-
value: 'Add Avenger'
|
|
255
|
-
}]
|
|
256
|
-
}]
|
|
257
|
-
});
|
|
258
|
-
const newConfig = createTestConfig({
|
|
259
|
-
submenuLinks: [{
|
|
260
|
-
uriPath: 'my-test-app/new',
|
|
261
|
-
defaultLabel: 'Add Avenger',
|
|
262
|
-
permissions: [],
|
|
263
|
-
labelAllLocales: [{
|
|
264
|
-
locale: 'de',
|
|
265
|
-
value: 'Avenger hinzufügen'
|
|
266
|
-
}, {
|
|
267
|
-
locale: 'it',
|
|
268
|
-
value: 'Nuovo Avenger'
|
|
269
|
-
}]
|
|
270
|
-
}]
|
|
271
|
-
});
|
|
272
|
-
expect(getConfigDiff(oldConfig, newConfig)).toMatchInlineSnapshot(`
|
|
273
|
-
"submenuLink changed
|
|
274
|
-
menu link \\"my-test-app/new\\" changed
|
|
275
|
-
defaultLabel changed: <color-red>New Avenger</color-red> => <color-green>Add Avenger</color-green>
|
|
276
|
-
permissions changed
|
|
277
|
-
applied permission removed: <color-red>ManageMyTestApp</color-red>
|
|
278
|
-
labelAllLocales changed
|
|
279
|
-
locale \\"de\\" changed: <color-red>Neu Avenger</color-red> => <color-green>Avenger hinzufügen</color-green>
|
|
280
|
-
locale added: <color-green>it</color-green>
|
|
281
|
-
locale removed: <color-red>en</color-red>"
|
|
282
|
-
`);
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
});
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
GraphQLClient
|
|
5
|
-
} = require('graphql-request');
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
GRAPHQL_TARGETS
|
|
9
|
-
} = require('@commercetools-frontend/constants');
|
|
10
|
-
|
|
11
|
-
const userAgent = require('./user-agent');
|
|
12
|
-
|
|
13
|
-
const requireGraphqlHelper = require('./require-graphql');
|
|
14
|
-
|
|
15
|
-
const requireGraphql = requireGraphqlHelper(__dirname);
|
|
16
|
-
const FetchCustomApplicationFromCli = requireGraphql('./fetch-custom-application.settings.graphql');
|
|
17
|
-
const UpdateCustomApplicationFromCli = requireGraphql('./update-custom-application.settings.graphql');
|
|
18
|
-
const CreateCustomApplicationFromCli = requireGraphql('./create-custom-application.settings.graphql');
|
|
19
|
-
const FetchMyOrganizationsFromCli = requireGraphql('./fetch-user-organizations.core.graphql');
|
|
20
|
-
|
|
21
|
-
const graphQLClient = (uri, token, target = GRAPHQL_TARGETS.SETTINGS_SERVICE) => new GraphQLClient(`${uri}/graphql`, {
|
|
22
|
-
headers: {
|
|
23
|
-
Accept: 'application/json',
|
|
24
|
-
'Content-Type': 'application/json',
|
|
25
|
-
'x-graphql-target': target,
|
|
26
|
-
'x-mc-cli-access-token': token,
|
|
27
|
-
'x-user-agent': userAgent
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const fetchCustomApplication = async ({
|
|
32
|
-
mcApiUrl,
|
|
33
|
-
token,
|
|
34
|
-
entryPointUriPath
|
|
35
|
-
}) => {
|
|
36
|
-
const variables = {
|
|
37
|
-
entryPointUriPath
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
try {
|
|
41
|
-
const customAppData = await graphQLClient(mcApiUrl, token).request(FetchCustomApplicationFromCli, variables);
|
|
42
|
-
return customAppData.organizationExtensionForCustomApplication;
|
|
43
|
-
} catch (error) {
|
|
44
|
-
throw new Error(error.response.message);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const updateCustomApplication = async ({
|
|
49
|
-
mcApiUrl,
|
|
50
|
-
token,
|
|
51
|
-
applicationId,
|
|
52
|
-
organizationId,
|
|
53
|
-
data
|
|
54
|
-
}) => {
|
|
55
|
-
const variables = {
|
|
56
|
-
organizationId,
|
|
57
|
-
applicationId,
|
|
58
|
-
data
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
const updatedCustomAppsData = await graphQLClient(mcApiUrl, token).request(UpdateCustomApplicationFromCli, variables);
|
|
63
|
-
return updatedCustomAppsData.updateCustomApplication;
|
|
64
|
-
} catch (error) {
|
|
65
|
-
throw new Error(error.response.message);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const createCustomApplication = async ({
|
|
70
|
-
mcApiUrl,
|
|
71
|
-
token,
|
|
72
|
-
organizationId,
|
|
73
|
-
data
|
|
74
|
-
}) => {
|
|
75
|
-
const variables = {
|
|
76
|
-
organizationId,
|
|
77
|
-
data
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
try {
|
|
81
|
-
const createdCustomAppData = await graphQLClient(mcApiUrl, token).request(CreateCustomApplicationFromCli, variables);
|
|
82
|
-
return createdCustomAppData.createCustomApplication;
|
|
83
|
-
} catch (error) {
|
|
84
|
-
throw new Error(error.response.message);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const fetchUserOrganizations = async ({
|
|
89
|
-
mcApiUrl,
|
|
90
|
-
token
|
|
91
|
-
}) => {
|
|
92
|
-
try {
|
|
93
|
-
const userOrganizations = await graphQLClient(mcApiUrl, token, GRAPHQL_TARGETS.ADMINISTRATION_SERVICE).request(FetchMyOrganizationsFromCli);
|
|
94
|
-
return userOrganizations.myOrganizations;
|
|
95
|
-
} catch (error) {
|
|
96
|
-
throw new Error(error.response.message);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
module.exports = {
|
|
101
|
-
fetchCustomApplication,
|
|
102
|
-
updateCustomApplication,
|
|
103
|
-
createCustomApplication,
|
|
104
|
-
fetchUserOrganizations
|
|
105
|
-
};
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
graphql
|
|
5
|
-
} = require('msw');
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
setupServer
|
|
9
|
-
} = require('msw/node');
|
|
10
|
-
|
|
11
|
-
const {
|
|
12
|
-
createCustomApplication,
|
|
13
|
-
updateCustomApplication,
|
|
14
|
-
fetchCustomApplication,
|
|
15
|
-
fetchUserOrganizations
|
|
16
|
-
} = require('./graphql-requests');
|
|
17
|
-
|
|
18
|
-
const mockServer = setupServer();
|
|
19
|
-
afterEach(() => {
|
|
20
|
-
mockServer.resetHandlers();
|
|
21
|
-
});
|
|
22
|
-
beforeAll(() => mockServer.listen({
|
|
23
|
-
onUnhandledRequest: 'bypass'
|
|
24
|
-
}));
|
|
25
|
-
afterAll(() => mockServer.close());
|
|
26
|
-
const mcApiUrl = 'https://mc-api.europe-west1.gcp.commercetools.com';
|
|
27
|
-
describe('fetch custom application data', () => {
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
mockServer.use(graphql.query('FetchCustomApplicationFromCli', (req, res, ctx) => {
|
|
30
|
-
return res(ctx.data({
|
|
31
|
-
organizationExtensionForCustomApplication: {
|
|
32
|
-
id: 'test-id',
|
|
33
|
-
organizationId: 'org-id',
|
|
34
|
-
application: {
|
|
35
|
-
url: 'https://test.com',
|
|
36
|
-
name: 'Test name',
|
|
37
|
-
description: 'Test description',
|
|
38
|
-
entryPointUriPath: 'test-custom-app',
|
|
39
|
-
icon: '<svg><path fill="#000000"></path></svg>',
|
|
40
|
-
submenuLinks: [],
|
|
41
|
-
mainMenuLink: [],
|
|
42
|
-
permissions: [{
|
|
43
|
-
oAuthScopes: ['view_products', 'view_customers'],
|
|
44
|
-
name: 'viewTestCustomApp'
|
|
45
|
-
}, {
|
|
46
|
-
oAuthScopes: [],
|
|
47
|
-
name: 'manageTestCustomApp'
|
|
48
|
-
}]
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}));
|
|
52
|
-
}));
|
|
53
|
-
});
|
|
54
|
-
it('should match returned data', async () => {
|
|
55
|
-
const organizationExtensionForCustomApplication = await fetchCustomApplication({
|
|
56
|
-
entryPointUriPath: 'test-custom-app',
|
|
57
|
-
mcApiUrl,
|
|
58
|
-
token: 'test-token'
|
|
59
|
-
});
|
|
60
|
-
expect(organizationExtensionForCustomApplication.application.entryPointUriPath).toEqual('test-custom-app');
|
|
61
|
-
expect(organizationExtensionForCustomApplication.id).toEqual('test-id');
|
|
62
|
-
expect(organizationExtensionForCustomApplication.organizationId).toEqual('org-id');
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
describe('register custom application', () => {
|
|
66
|
-
beforeEach(() => {
|
|
67
|
-
mockServer.use(graphql.mutation('CreateCustomApplicationFromCli', (req, res, ctx) => {
|
|
68
|
-
return res(ctx.data({
|
|
69
|
-
createCustomApplication: {
|
|
70
|
-
id: 'new-test-id',
|
|
71
|
-
application: {
|
|
72
|
-
url: 'https://test.com',
|
|
73
|
-
name: 'New Test name',
|
|
74
|
-
description: 'Test description',
|
|
75
|
-
entryPointUriPath: 'new-test-custom-app',
|
|
76
|
-
icon: '<svg><path fill="#000000"></path></svg>',
|
|
77
|
-
submenuLinks: [],
|
|
78
|
-
mainMenuLink: [],
|
|
79
|
-
permissions: [{
|
|
80
|
-
oAuthScopes: ['view_products', 'view_customers'],
|
|
81
|
-
name: 'viewNewTestCustomApp'
|
|
82
|
-
}, {
|
|
83
|
-
oAuthScopes: [],
|
|
84
|
-
name: 'manageNewTestCustomApp'
|
|
85
|
-
}]
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}));
|
|
89
|
-
}));
|
|
90
|
-
});
|
|
91
|
-
it('should match returned data', async () => {
|
|
92
|
-
const createdCustomAppsData = await createCustomApplication({
|
|
93
|
-
entryPointUriPath: 'new-test-custom-app',
|
|
94
|
-
mcApiUrl,
|
|
95
|
-
token: 'new-test-token'
|
|
96
|
-
});
|
|
97
|
-
expect(createdCustomAppsData.application.entryPointUriPath).toEqual('new-test-custom-app');
|
|
98
|
-
expect(createdCustomAppsData.id).toEqual('new-test-id');
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
describe('update custom application', () => {
|
|
102
|
-
beforeEach(() => {
|
|
103
|
-
mockServer.use(graphql.mutation('UpdateCustomApplicationFromCli', (req, res, ctx) => {
|
|
104
|
-
return res(ctx.data({
|
|
105
|
-
updateCustomApplication: {
|
|
106
|
-
id: 'test-id',
|
|
107
|
-
application: {
|
|
108
|
-
url: 'https://test.com',
|
|
109
|
-
name: 'Updated Test name',
|
|
110
|
-
description: 'Updated Test description',
|
|
111
|
-
entryPointUriPath: 'updated-test-custom-app',
|
|
112
|
-
icon: '<svg><path fill="#000000"></path></svg>',
|
|
113
|
-
submenuLinks: [],
|
|
114
|
-
mainMenuLink: [],
|
|
115
|
-
permissions: [{
|
|
116
|
-
oAuthScopes: ['view_products', 'view_customers'],
|
|
117
|
-
name: 'viewNewTestCustomApp'
|
|
118
|
-
}, {
|
|
119
|
-
oAuthScopes: [],
|
|
120
|
-
name: 'manageNewTestCustomApp'
|
|
121
|
-
}]
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}));
|
|
125
|
-
}));
|
|
126
|
-
});
|
|
127
|
-
it('should match returned data', async () => {
|
|
128
|
-
const updatedCustomAppsData = await updateCustomApplication({
|
|
129
|
-
entryPointUriPath: 'updated-test-custom-app',
|
|
130
|
-
mcApiUrl,
|
|
131
|
-
token: 'test-token'
|
|
132
|
-
});
|
|
133
|
-
expect(updatedCustomAppsData.application.name).toEqual('Updated Test name');
|
|
134
|
-
expect(updatedCustomAppsData.application.description).toEqual('Updated Test description');
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
describe('fetch user organizations', () => {
|
|
138
|
-
beforeEach(() => {
|
|
139
|
-
mockServer.use(graphql.query('FetchMyOrganizationsFromCli', (req, res, ctx) => {
|
|
140
|
-
return res(ctx.data({
|
|
141
|
-
myOrganizations: {
|
|
142
|
-
total: 1,
|
|
143
|
-
results: [{
|
|
144
|
-
id: 'test-organization-id',
|
|
145
|
-
name: 'test-organization-name'
|
|
146
|
-
}]
|
|
147
|
-
}
|
|
148
|
-
}));
|
|
149
|
-
}));
|
|
150
|
-
});
|
|
151
|
-
it('should match returned data', async () => {
|
|
152
|
-
const data = await fetchUserOrganizations({
|
|
153
|
-
mcApiUrl,
|
|
154
|
-
token: 'test-token'
|
|
155
|
-
});
|
|
156
|
-
expect(data.results[0].id).toEqual('test-organization-id');
|
|
157
|
-
expect(data.results[0].name).toEqual('test-organization-name');
|
|
158
|
-
});
|
|
159
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
readFileSync
|
|
7
|
-
} = require('fs'); // At the moment there is no proper way of loading `.graphql` files
|
|
8
|
-
// in nodejs. This workaround basically uses `readFileSync` to read the file
|
|
9
|
-
// content as a string.
|
|
10
|
-
// https://github.com/apollographql/graphql-tools/issues/273
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const requireGraphql = folderPath => filePath => readFileSync(path.join(folderPath, filePath), 'utf-8');
|
|
14
|
-
|
|
15
|
-
module.exports = requireGraphql;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
mutation UpdateCustomApplicationFromCli(
|
|
2
|
-
$organizationId: String!
|
|
3
|
-
$data: CustomApplicationDraftDataInput!
|
|
4
|
-
$applicationId: ID!
|
|
5
|
-
) {
|
|
6
|
-
updateCustomApplication(
|
|
7
|
-
organizationId: $organizationId
|
|
8
|
-
data: $data
|
|
9
|
-
applicationId: $applicationId
|
|
10
|
-
) {
|
|
11
|
-
id
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const createHttpUserAgent = require('@commercetools/http-user-agent');
|
|
4
|
-
|
|
5
|
-
const pkgJson = require('../../package.json');
|
|
6
|
-
|
|
7
|
-
const userAgent = createHttpUserAgent({
|
|
8
|
-
name: 'cli-login',
|
|
9
|
-
libraryName: 'mc-scripts',
|
|
10
|
-
libraryVersion: pkgJson.version,
|
|
11
|
-
contactUrl: 'https://git.io/fjuyC',
|
|
12
|
-
// points to the appkit repo issues
|
|
13
|
-
contactEmail: 'support@commercetools.com'
|
|
14
|
-
});
|
|
15
|
-
module.exports = userAgent;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
|
|
5
|
-
const path = require('path');
|
|
6
|
-
|
|
7
|
-
class FinalStatsWriterPlugin {
|
|
8
|
-
// Expected options:
|
|
9
|
-
// - `outputPath`
|
|
10
|
-
// - `includeFields`
|
|
11
|
-
constructor(config) {
|
|
12
|
-
if (!config) throw new Error('Missing config options');
|
|
13
|
-
this.config = config;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
apply(compiler) {
|
|
17
|
-
// This is the only hook that return the `stats` plugin
|
|
18
|
-
// with the `time` info. It also contains all the stats that
|
|
19
|
-
// we would get from the original `emit` hook.
|
|
20
|
-
// https://webpack.js.org/api/compiler-hooks/#done
|
|
21
|
-
// https://webpack.js.org/api/plugins/#plugin-types
|
|
22
|
-
if (compiler.hooks) {
|
|
23
|
-
compiler.hooks.done.tap('custom-stats-writer-plugin', this.writeStats.bind(this));
|
|
24
|
-
} else {
|
|
25
|
-
compiler.plugin('done', this.writeStats.bind(this));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
writeStats(stats) {
|
|
30
|
-
let finalStats = stats.toJson(); // Filter only included fields
|
|
31
|
-
|
|
32
|
-
if (this.config.includeFields) {
|
|
33
|
-
finalStats = this.config.includeFields.reduce((aggregatedStats, key) => // eslint-disable-next-line
|
|
34
|
-
Object.assign({}, aggregatedStats, {
|
|
35
|
-
[key]: finalStats[key]
|
|
36
|
-
}), {});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
fs.accessSync(this.config.outputPath, fs.F_OK);
|
|
41
|
-
fs.writeFileSync(path.join(this.config.outputPath, 'stats.json'), JSON.stringify(finalStats, null, 2));
|
|
42
|
-
} catch (error) {
|
|
43
|
-
// eslint-disable-next-line no-console
|
|
44
|
-
console.warn(`[FinalStatsWriterPlugin] The dist folder could not be found at ${this.config.outputPath}. Check the console for errors during the webpack compilation.`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
module.exports = FinalStatsWriterPlugin;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/* eslint-disable class-methods-use-this,no-param-reassign */
|
|
4
|
-
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
5
|
-
|
|
6
|
-
const {
|
|
7
|
-
processConfig
|
|
8
|
-
} = require('@commercetools-frontend/application-config');
|
|
9
|
-
|
|
10
|
-
const {
|
|
11
|
-
replaceHtmlPlaceholders
|
|
12
|
-
} = require('@commercetools-frontend/mc-html-template');
|
|
13
|
-
|
|
14
|
-
const applicationConfig = processConfig();
|
|
15
|
-
const enhancedLocalEnv = Object.assign({}, applicationConfig.env, // Now that the app config is defined as a `env.json`, when we start the FE app
|
|
16
|
-
// to point to the local backend API by passing the `MC_API_URL` env does not
|
|
17
|
-
// work anymore). To make it work again, we can override the `env.json` config
|
|
18
|
-
// with the env variable before injecting the values into the index.html.
|
|
19
|
-
// NOTE: this is only necessary for development.
|
|
20
|
-
process.env.MC_API_URL ? {
|
|
21
|
-
mcApiUrl: process.env.MC_API_URL
|
|
22
|
-
} : {});
|
|
23
|
-
|
|
24
|
-
class LocalHtmlWebpackPlugin {
|
|
25
|
-
apply(compiler) {
|
|
26
|
-
compiler.hooks.compilation.tap('LocalHtmlWebpackPlugin', compilation => {
|
|
27
|
-
HtmlWebpackPlugin.getHooks(compilation).beforeEmit.tapAsync('LocalHtmlWebpackPlugin', (data, cb) => {
|
|
28
|
-
data.html = replaceHtmlPlaceholders(data.html, {
|
|
29
|
-
env: enhancedLocalEnv
|
|
30
|
-
});
|
|
31
|
-
cb(null, data);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
module.exports = LocalHtmlWebpackPlugin;
|