@squiz/component-cli-lib 1.69.1 → 1.70.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/lib/index.js +63 -63
- package/lib/index.js.map +2 -2
- package/package.json +10 -7
- package/.env.example +0 -11
- package/.gitlab-ci.yml +0 -141
- package/CHANGELOG.md +0 -664
- package/build.js +0 -28
- package/jest.config.ts +0 -28
- package/jest.integration.config.ts +0 -27
- package/job-runner-lib.tgz +0 -0
- package/lib/job-runner-lib.tgz +0 -0
- package/localStart.ts +0 -11
- package/src/component-dev-folder-structures.integration.spec.ts +0 -91
- package/src/component-dev.integration.spec.ts +0 -71
- package/src/component-dev.ts +0 -102
- package/src/component-edge-dev.ts +0 -75
- package/src/component-init.spec.ts +0 -258
- package/src/component-init.ts +0 -81
- package/src/index.ts +0 -5
- package/src/integration-tests/__components__/big-package/manifest.json +0 -36
- package/src/integration-tests/__components__/big-package/render-json.js +0 -5
- package/src/integration-tests/__components__/cmp-format-string/main.js +0 -7
- package/src/integration-tests/__components__/cmp-format-string/manifest.json +0 -41
- package/src/integration-tests/__components__/cmp-no-api-key/main.js +0 -25
- package/src/integration-tests/__components__/cmp-no-api-key/manifest.json +0 -41
- package/src/integration-tests/__components__/cmp-property-order/main.js +0 -6
- package/src/integration-tests/__components__/cmp-property-order/manifest.json +0 -60
- package/src/integration-tests/__components__/cmp-static-file-test/main.js +0 -6
- package/src/integration-tests/__components__/cmp-static-file-test/manifest.json +0 -42
- package/src/integration-tests/__components__/cmp-static-file-test/public/static-library-file.js +0 -1
- package/src/integration-tests/__components__/invalid-manifest/main.js +0 -3
- package/src/integration-tests/__components__/invalid-manifest/manifest.json +0 -29
- package/src/integration-tests/__components__/invalid-upload/main.js +0 -3
- package/src/integration-tests/__components__/matrix-asset-uri/main.js +0 -7
- package/src/integration-tests/__components__/matrix-asset-uri/manifest.json +0 -42
- package/src/integration-tests/__components__/test-page-render/main.js +0 -3
- package/src/integration-tests/__components__/test-page-render/manifest.json +0 -46
- package/src/integration-tests/__components__/test-page-render/public/static-library-script.js +0 -1
- package/src/integration-tests/__components__/test-page-render/public/static-library-styles.css +0 -3
- package/src/integration-tests/__jobs__/invalid-manifest/main.js +0 -3
- package/src/integration-tests/__jobs__/invalid-manifest/manifest.json +0 -28
- package/src/integration-tests/__jobs__/invalid-upload/main.js +0 -3
- package/src/integration-tests/__jobs__/simple-job/main.js +0 -3
- package/src/integration-tests/__jobs__/simple-job/manifest.json +0 -25
- package/src/integration-tests/helper.ts +0 -227
- package/src/integration-tests/service-deployment.integration.spec.ts +0 -74
- package/src/integration-tests/test-setup.ts +0 -1
- package/src/upload-component-folder.ts +0 -130
- package/src/upload-job.ts +0 -101
- package/src/utils.spec.ts +0 -370
- package/src/utils.ts +0 -149
- package/templates/advanced/build.js +0 -43
- package/templates/advanced/main.js +0 -3
- package/templates/advanced/manifest.json +0 -60
- package/templates/advanced/package-lock.json +0 -916
- package/templates/advanced/package.json +0 -11
- package/templates/advanced/previews/example.data.json +0 -1
- package/templates/advanced/previews/preview.html +0 -9
- package/templates/advanced/static/default.js +0 -1
- package/templates/advanced/static/default.scss +0 -1
- package/templates/basic/main.js +0 -3
- package/templates/basic/manifest.json +0 -62
- package/templates/basic/previews/example.data.json +0 -1
- package/templates/basic/previews/preview.html +0 -9
- package/templates/basic/static/default.css +0 -1
- package/templates/basic/static/default.js +0 -1
- package/tsconfig.json +0 -26
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
import componentInit from './component-init';
|
|
2
|
-
import fs from 'fs-extra';
|
|
3
|
-
import * as logger from '@squiz/dx-logger-lib';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
|
|
6
|
-
jest.mock('fs-extra');
|
|
7
|
-
jest.mock('path', () => {
|
|
8
|
-
return {
|
|
9
|
-
...jest.requireActual('path'),
|
|
10
|
-
};
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
const fsMocked = jest.mocked(fs);
|
|
14
|
-
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
jest.restoreAllMocks();
|
|
17
|
-
fsMocked.readJSON.mockResolvedValue({});
|
|
18
|
-
|
|
19
|
-
// Reset our process.env.NODE_ENV variable
|
|
20
|
-
process.env.NODE_ENV = 'test';
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
describe('componentInit', () => {
|
|
24
|
-
it('should setup a new logger instance with the correct options', async () => {
|
|
25
|
-
const loggerSpy = jest.spyOn(logger, 'getLogger');
|
|
26
|
-
|
|
27
|
-
// Mock the process.env.NODE_ENV variable to be "development"
|
|
28
|
-
process.env.NODE_ENV = 'development';
|
|
29
|
-
|
|
30
|
-
await componentInit({
|
|
31
|
-
componentType: 'basic',
|
|
32
|
-
destination: '',
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
expect(loggerSpy).toHaveBeenCalledWith({
|
|
36
|
-
name: 'component-dev',
|
|
37
|
-
format: 'human',
|
|
38
|
-
silent: false,
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('path.resolve should be called with __dirname to get the current script directory', async () => {
|
|
43
|
-
const pathResolveSpy = jest.spyOn(path, 'resolve');
|
|
44
|
-
|
|
45
|
-
await componentInit({
|
|
46
|
-
componentType: 'basic',
|
|
47
|
-
destination: '',
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
expect(pathResolveSpy).toHaveBeenCalledWith(__dirname);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('path.join should be called with the current script directory and the component type to get the source folder', async () => {
|
|
54
|
-
const pathJoinSpy = jest.spyOn(path, 'join');
|
|
55
|
-
|
|
56
|
-
jest
|
|
57
|
-
.spyOn(path, 'resolve')
|
|
58
|
-
.mockReturnValue('/Users/username/Projects/squiz/component-cli-lib/packages/component-cli-lib/src');
|
|
59
|
-
|
|
60
|
-
await componentInit({
|
|
61
|
-
componentType: 'basic',
|
|
62
|
-
destination: '',
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
expect(pathJoinSpy).toHaveBeenCalledWith(
|
|
66
|
-
'/Users/username/Projects/squiz/component-cli-lib/packages/component-cli-lib/src',
|
|
67
|
-
'templates',
|
|
68
|
-
'basic',
|
|
69
|
-
);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('path.resolve should be called with the destination folder to get the destination folder', async () => {
|
|
73
|
-
const pathResolveSpy = jest.spyOn(path, 'resolve');
|
|
74
|
-
|
|
75
|
-
jest.spyOn(path, 'resolve').mockReturnValue('/Users/username/Projects/squiz/new-component');
|
|
76
|
-
|
|
77
|
-
await componentInit({
|
|
78
|
-
componentType: 'basic',
|
|
79
|
-
destination: '/Users/username/Projects/squiz/new-component',
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
expect(pathResolveSpy).toHaveBeenCalledWith('/Users/username/Projects/squiz/new-component');
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('should fail if the destination folder already exists and there are files in it', async () => {
|
|
86
|
-
// Mock the current script directory
|
|
87
|
-
jest.spyOn(path, 'resolve').mockImplementationOnce(() => {
|
|
88
|
-
return '/Users/username/Projects/squiz/component-cli-lib/packages/component-cli-lib/src';
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
// Mock the destination folder
|
|
92
|
-
jest.spyOn(path, 'resolve').mockImplementationOnce(() => {
|
|
93
|
-
return '/Users/username/Projects/squiz/new-component';
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
// Mock the fs.pathExists function to return true
|
|
97
|
-
jest.spyOn(fs, 'pathExists').mockImplementationOnce(() => {
|
|
98
|
-
return Promise.resolve(true);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// Mock the fs.readdirSync function to return an array of files
|
|
102
|
-
jest.spyOn(fs, 'readdir').mockImplementationOnce(() => {
|
|
103
|
-
return Promise.resolve(['file1.txt', 'file2.txt']);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
await expect(
|
|
107
|
-
componentInit({
|
|
108
|
-
componentType: 'basic',
|
|
109
|
-
destination: '/Users/username/Projects/squiz/new-component',
|
|
110
|
-
}),
|
|
111
|
-
).rejects.toThrowError('The destination folder already exists and is not empty.');
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('should create the destination folder if it does not exist', async () => {
|
|
115
|
-
// Mock the current script directory
|
|
116
|
-
jest.spyOn(path, 'resolve').mockImplementationOnce(() => {
|
|
117
|
-
return '/Users/username/Projects/squiz/component-cli-lib/packages/component-cli-lib/src';
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
// Mock the destination folder
|
|
121
|
-
jest.spyOn(path, 'resolve').mockImplementationOnce(() => {
|
|
122
|
-
return '/Users/username/Projects/squiz/new-component';
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
// Mock the fs.pathExists function to return false
|
|
126
|
-
jest.spyOn(fs, 'pathExists').mockImplementationOnce(() => {
|
|
127
|
-
return Promise.resolve(false);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
await componentInit({
|
|
131
|
-
componentType: 'basic',
|
|
132
|
-
destination: '/Users/username/Projects/squiz/new-component',
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
expect(fs.mkdirp).toHaveBeenCalledWith('/Users/username/Projects/squiz/new-component');
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it('should not fail if the destination folder already exists and there are no files in it', async () => {
|
|
139
|
-
// Mock the current script directory
|
|
140
|
-
jest.spyOn(path, 'resolve').mockImplementationOnce(() => {
|
|
141
|
-
return '/Users/username/Projects/squiz/component-cli-lib/packages/component-cli-lib/src';
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
// Mock the destination folder
|
|
145
|
-
jest.spyOn(path, 'resolve').mockImplementationOnce(() => {
|
|
146
|
-
return '/Users/username/Projects/squiz/new-component';
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
// Mock the fs.pathExists function to return true
|
|
150
|
-
jest.spyOn(fs, 'pathExists').mockImplementationOnce(() => {
|
|
151
|
-
return Promise.resolve(true);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
// Mock the fs.readdir function to return an empty array
|
|
155
|
-
jest.spyOn(fs, 'readdir').mockImplementationOnce(() => {
|
|
156
|
-
return Promise.resolve([]);
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
await expect(
|
|
160
|
-
componentInit({
|
|
161
|
-
componentType: 'basic',
|
|
162
|
-
destination: '/Users/username/Projects/squiz/new-component',
|
|
163
|
-
}),
|
|
164
|
-
).resolves.toBeUndefined();
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it('fs.copy should be called with the source folder and the destination folder', async () => {
|
|
168
|
-
// Mock the fs.copy function
|
|
169
|
-
const fsCopySpy = jest.spyOn(fs, 'copy');
|
|
170
|
-
|
|
171
|
-
// Mock the current script directory
|
|
172
|
-
jest.spyOn(path, 'resolve').mockImplementationOnce(() => {
|
|
173
|
-
return '/Users/username/Projects/squiz/component-cli-lib/packages/component-cli-lib/src';
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
// Mock the source folder
|
|
177
|
-
jest.spyOn(path, 'join').mockImplementationOnce(() => {
|
|
178
|
-
return '/Users/username/Projects/squiz/component-cli-lib/packages/component-cli-lib/templates/basic';
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
// Mock the destination folder
|
|
182
|
-
jest.spyOn(path, 'resolve').mockImplementationOnce(() => {
|
|
183
|
-
return '/Users/username/Projects/squiz/new-component';
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
// Mock the fs.pathExists function to return true
|
|
187
|
-
jest.spyOn(fs, 'pathExists').mockImplementationOnce(() => {
|
|
188
|
-
return Promise.resolve(true);
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
// Mock the fs.readdir function to return an empty array
|
|
192
|
-
jest.spyOn(fs, 'readdir').mockImplementationOnce(() => {
|
|
193
|
-
return Promise.resolve([]);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
await componentInit({
|
|
197
|
-
componentType: 'basic',
|
|
198
|
-
destination: '/Users/username/Projects/squiz/new-component',
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
expect(fsCopySpy).toHaveBeenCalledWith(
|
|
202
|
-
'/Users/username/Projects/squiz/component-cli-lib/packages/component-cli-lib/templates/basic',
|
|
203
|
-
'/Users/username/Projects/squiz/new-component',
|
|
204
|
-
);
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
describe('prompts', () => {
|
|
208
|
-
it('should default when no prompts provided', async () => {
|
|
209
|
-
await componentInit({ componentType: 'basic', destination: '' });
|
|
210
|
-
|
|
211
|
-
expect(fsMocked.writeJSON).toHaveBeenCalledWith(
|
|
212
|
-
expect.any(String),
|
|
213
|
-
expect.objectContaining({
|
|
214
|
-
name: 'default',
|
|
215
|
-
namespace: 'default-namespace',
|
|
216
|
-
displayName: 'Default',
|
|
217
|
-
}),
|
|
218
|
-
expect.objectContaining({ spaces: 2 }),
|
|
219
|
-
);
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it('should overwrite default values with provided values', async () => {
|
|
223
|
-
await componentInit({
|
|
224
|
-
componentType: 'basic',
|
|
225
|
-
destination: '',
|
|
226
|
-
prompts: {
|
|
227
|
-
name: 'my-component',
|
|
228
|
-
namespace: 'my-namespace',
|
|
229
|
-
displayName: 'My Component',
|
|
230
|
-
},
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
expect(fsMocked.writeJSON).toHaveBeenCalledWith(
|
|
234
|
-
expect.any(String),
|
|
235
|
-
expect.objectContaining({
|
|
236
|
-
name: 'my-component',
|
|
237
|
-
namespace: 'my-namespace',
|
|
238
|
-
displayName: 'My Component',
|
|
239
|
-
}),
|
|
240
|
-
expect.objectContaining({ spaces: 2 }),
|
|
241
|
-
);
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
it('should read and write the destination manifest file', async () => {
|
|
245
|
-
await componentInit({
|
|
246
|
-
componentType: 'basic',
|
|
247
|
-
destination: '/Users/username/Projects/squiz/new-component',
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
expect(fsMocked.readJSON).toHaveBeenCalledWith('/Users/username/Projects/squiz/new-component/manifest.json');
|
|
251
|
-
expect(fsMocked.writeJSON).toHaveBeenCalledWith(
|
|
252
|
-
'/Users/username/Projects/squiz/new-component/manifest.json',
|
|
253
|
-
expect.any(Object),
|
|
254
|
-
expect.objectContaining({ spaces: 2 }),
|
|
255
|
-
);
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
});
|
package/src/component-init.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import fse from 'fs-extra';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { getLogger, LoggerOptions } from '@squiz/dx-logger-lib';
|
|
4
|
-
|
|
5
|
-
export interface InitPrompts {
|
|
6
|
-
name: string;
|
|
7
|
-
displayName: string;
|
|
8
|
-
description: string;
|
|
9
|
-
namespace: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const DEFAULT_PROMPTS: InitPrompts = {
|
|
13
|
-
name: 'default',
|
|
14
|
-
displayName: 'Default',
|
|
15
|
-
description: 'Default component',
|
|
16
|
-
namespace: 'default-namespace',
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
interface InitOptions {
|
|
20
|
-
componentType: 'basic' | 'advanced';
|
|
21
|
-
destination: string;
|
|
22
|
-
loggingFormat?: LoggerOptions['format'];
|
|
23
|
-
prompts?: Partial<InitPrompts>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* componentInit initializes a new component
|
|
28
|
-
* @param {object} options - The options object
|
|
29
|
-
* @param {string} options.componentType - The type of component to initialize
|
|
30
|
-
* @returns {void}
|
|
31
|
-
*/
|
|
32
|
-
export default async function componentInit(options: InitOptions) {
|
|
33
|
-
const logger = getLogger({
|
|
34
|
-
name: 'component-dev',
|
|
35
|
-
format: options.loggingFormat || 'human',
|
|
36
|
-
silent: process.env.NODE_ENV === 'test',
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
logger.info('Initializing component...');
|
|
40
|
-
|
|
41
|
-
// Get our current script directory
|
|
42
|
-
const currentScriptDir = path.resolve(__dirname);
|
|
43
|
-
|
|
44
|
-
// Define the file source to move from
|
|
45
|
-
const sourceFolder = path.join(currentScriptDir, 'templates', options.componentType);
|
|
46
|
-
|
|
47
|
-
// Define the file destination to move to
|
|
48
|
-
const destination = path.resolve(options.destination);
|
|
49
|
-
|
|
50
|
-
// If the destination folder already exists, and it's not empty, throw an error
|
|
51
|
-
if (await fse.pathExists(destination)) {
|
|
52
|
-
const files = await fse.readdir(destination);
|
|
53
|
-
if (files.length > 0) {
|
|
54
|
-
throw new Error('The destination folder already exists and is not empty.');
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
// If the destination folder doesn't exist, create it
|
|
58
|
-
await fse.mkdirp(destination);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Copy the contents of the source folder to the destination folder
|
|
62
|
-
await fse.copy(sourceFolder, destination);
|
|
63
|
-
await writeManifestVariables({ destination, prompts: Object.assign({}, DEFAULT_PROMPTS, options.prompts) });
|
|
64
|
-
|
|
65
|
-
logger.info('Component initialized!');
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async function writeManifestVariables(options: { destination: string; prompts: InitPrompts }) {
|
|
69
|
-
const { destination, prompts } = options;
|
|
70
|
-
|
|
71
|
-
const manifestPath = path.resolve(destination, 'manifest.json');
|
|
72
|
-
|
|
73
|
-
const manifest = await fse.readJSON(manifestPath);
|
|
74
|
-
|
|
75
|
-
manifest.name = prompts.name;
|
|
76
|
-
manifest.displayName = prompts.displayName;
|
|
77
|
-
manifest.description = prompts.description;
|
|
78
|
-
manifest.namespace = prompts.namespace;
|
|
79
|
-
|
|
80
|
-
await fse.writeJSON(manifestPath, manifest, { spaces: 2 });
|
|
81
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { uploadComponentFolder } from './upload-component-folder';
|
|
2
|
-
export { startDevelopmentRender } from './component-dev';
|
|
3
|
-
export { startEdgeDevelopmentRender } from './component-edge-dev';
|
|
4
|
-
export { default as componentInit, InitPrompts } from './component-init';
|
|
5
|
-
export { uploadJobFolder } from './upload-job';
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://localhost:3000/schemas/v1.json#",
|
|
3
|
-
|
|
4
|
-
"name": "big-package",
|
|
5
|
-
"version": "1.0.2",
|
|
6
|
-
"mainFunction": "render-json",
|
|
7
|
-
"namespace": "smoke-test-components",
|
|
8
|
-
"displayName": "some-displayName",
|
|
9
|
-
"description": "some-description",
|
|
10
|
-
"functions": [
|
|
11
|
-
{
|
|
12
|
-
"name": "render-json",
|
|
13
|
-
"entry": "render-json.js",
|
|
14
|
-
"input": {
|
|
15
|
-
"type": "object",
|
|
16
|
-
"properties": {
|
|
17
|
-
"something": {
|
|
18
|
-
"type": "string"
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"required": ["something"]
|
|
22
|
-
},
|
|
23
|
-
"output": {
|
|
24
|
-
"responseType": "json",
|
|
25
|
-
"definition": {
|
|
26
|
-
"properties": {
|
|
27
|
-
"my-prop": {
|
|
28
|
-
"type": "string"
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"required": ["my-prop"]
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
]
|
|
36
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://localhost:3000/schemas/v1.json#",
|
|
3
|
-
|
|
4
|
-
"name": "cmp-format-string",
|
|
5
|
-
"version": "1.0.0",
|
|
6
|
-
"mainFunction": "main",
|
|
7
|
-
"displayName": "some-display-name",
|
|
8
|
-
"namespace": "smoke-test-components",
|
|
9
|
-
"description": "some-description",
|
|
10
|
-
"functions": [
|
|
11
|
-
{
|
|
12
|
-
"name": "main",
|
|
13
|
-
"entry": "main.js",
|
|
14
|
-
"input": {
|
|
15
|
-
"type": "object",
|
|
16
|
-
"properties": {
|
|
17
|
-
"text": {
|
|
18
|
-
"type": "string",
|
|
19
|
-
"format": "multi-line"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"required": ["text"]
|
|
23
|
-
},
|
|
24
|
-
"output": { "responseType": "html" }
|
|
25
|
-
}
|
|
26
|
-
],
|
|
27
|
-
"previews": {
|
|
28
|
-
"test-preview": {
|
|
29
|
-
"functionData": {
|
|
30
|
-
"main": {
|
|
31
|
-
"inputData": {
|
|
32
|
-
"type": "inline",
|
|
33
|
-
"value": {
|
|
34
|
-
"text": "this is a test"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {object} input
|
|
3
|
-
* @param {ComponentInfo} info
|
|
4
|
-
*/
|
|
5
|
-
module.exports = async function (input, info) {
|
|
6
|
-
function hasDxpApiKey(obj) {
|
|
7
|
-
if (typeof obj === 'object' && obj !== null) {
|
|
8
|
-
if (obj.hasOwnProperty('dxpApiKey')) {
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
for (const prop in obj) {
|
|
12
|
-
if (hasDxpApiKey(obj[prop])) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (hasDxpApiKey(input) || hasDxpApiKey(info)) {
|
|
21
|
-
return 'true';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return 'false';
|
|
25
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://localhost:3000/schemas/v1.json#",
|
|
3
|
-
|
|
4
|
-
"name": "cmp-no-api-key",
|
|
5
|
-
"version": "1.0.0",
|
|
6
|
-
"mainFunction": "main",
|
|
7
|
-
"displayName": "some-display-name",
|
|
8
|
-
"namespace": "smoke-test-components",
|
|
9
|
-
"description": "some-description",
|
|
10
|
-
"functions": [
|
|
11
|
-
{
|
|
12
|
-
"name": "main",
|
|
13
|
-
"entry": "main.js",
|
|
14
|
-
"input": {
|
|
15
|
-
"type": "object",
|
|
16
|
-
"properties": {
|
|
17
|
-
"text": {
|
|
18
|
-
"type": "string",
|
|
19
|
-
"format": "multi-line"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"required": []
|
|
23
|
-
},
|
|
24
|
-
"output": { "responseType": "html" }
|
|
25
|
-
}
|
|
26
|
-
],
|
|
27
|
-
"previews": {
|
|
28
|
-
"test-preview": {
|
|
29
|
-
"functionData": {
|
|
30
|
-
"main": {
|
|
31
|
-
"inputData": {
|
|
32
|
-
"type": "inline",
|
|
33
|
-
"value": {
|
|
34
|
-
"text": "this is a test"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://localhost:3000/schemas/v1.json#",
|
|
3
|
-
|
|
4
|
-
"name": "cmp-property-order",
|
|
5
|
-
"version": "1.0.0",
|
|
6
|
-
"mainFunction": "main",
|
|
7
|
-
"displayName": "some-display-name",
|
|
8
|
-
"namespace": "smoke-test-components",
|
|
9
|
-
"description": "some-description",
|
|
10
|
-
"functions": [
|
|
11
|
-
{
|
|
12
|
-
"name": "main",
|
|
13
|
-
"entry": "main.js",
|
|
14
|
-
"input": {
|
|
15
|
-
"type": "object",
|
|
16
|
-
"properties": {
|
|
17
|
-
"input1": {
|
|
18
|
-
"type": "string"
|
|
19
|
-
},
|
|
20
|
-
"333": {
|
|
21
|
-
"type": "string"
|
|
22
|
-
},
|
|
23
|
-
"input333": {
|
|
24
|
-
"type": "string"
|
|
25
|
-
},
|
|
26
|
-
"\"": {
|
|
27
|
-
"type": "string"
|
|
28
|
-
},
|
|
29
|
-
"~": {
|
|
30
|
-
"type": "string"
|
|
31
|
-
},
|
|
32
|
-
"": {
|
|
33
|
-
"type": "string"
|
|
34
|
-
},
|
|
35
|
-
"$": {
|
|
36
|
-
"type": "string"
|
|
37
|
-
},
|
|
38
|
-
"111": {
|
|
39
|
-
"type": "string"
|
|
40
|
-
},
|
|
41
|
-
"input22": {
|
|
42
|
-
"type": "string"
|
|
43
|
-
},
|
|
44
|
-
"222": {
|
|
45
|
-
"type": "string"
|
|
46
|
-
},
|
|
47
|
-
"*": {
|
|
48
|
-
"type": "string"
|
|
49
|
-
},
|
|
50
|
-
"null": {
|
|
51
|
-
"type": "null",
|
|
52
|
-
"default": null
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
"required": []
|
|
56
|
-
},
|
|
57
|
-
"output": { "responseType": "html" }
|
|
58
|
-
}
|
|
59
|
-
]
|
|
60
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://localhost:3000/schemas/v1.json#",
|
|
3
|
-
|
|
4
|
-
"name": "cmp-static-file-test",
|
|
5
|
-
"version": "1.0.0",
|
|
6
|
-
"mainFunction": "main",
|
|
7
|
-
"namespace": "smoke-test-components",
|
|
8
|
-
"displayName": "some-displayName",
|
|
9
|
-
"description": "some-description",
|
|
10
|
-
"functions": [
|
|
11
|
-
{
|
|
12
|
-
"entry": "main.js",
|
|
13
|
-
"name": "main",
|
|
14
|
-
"input": {
|
|
15
|
-
"type": "object",
|
|
16
|
-
"properties": {
|
|
17
|
-
"something": {
|
|
18
|
-
"type": "string"
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"required": []
|
|
22
|
-
},
|
|
23
|
-
"output": {
|
|
24
|
-
"responseType": "html",
|
|
25
|
-
|
|
26
|
-
"staticFiles": [
|
|
27
|
-
{
|
|
28
|
-
"location": "header",
|
|
29
|
-
"file": {
|
|
30
|
-
"filepath": "static-library-file.js",
|
|
31
|
-
"type": "js"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
],
|
|
38
|
-
|
|
39
|
-
"staticFiles": {
|
|
40
|
-
"locationRoot": "public"
|
|
41
|
-
}
|
|
42
|
-
}
|
package/src/integration-tests/__components__/cmp-static-file-test/public/static-library-file.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const name = 'foo';
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://localhost:3000/schemas/v1.json#",
|
|
3
|
-
|
|
4
|
-
"name": "invalid-manifes@t",
|
|
5
|
-
"version": "1.0.0",
|
|
6
|
-
"mainFunction": "main",
|
|
7
|
-
"namespace": "smoke-test-components",
|
|
8
|
-
"displayName": "some-displayName",
|
|
9
|
-
"description": "some-description",
|
|
10
|
-
|
|
11
|
-
"functions": [
|
|
12
|
-
{
|
|
13
|
-
"entry": "main.js",
|
|
14
|
-
"name": "main",
|
|
15
|
-
"input": {
|
|
16
|
-
"type": "object",
|
|
17
|
-
"properties": {
|
|
18
|
-
"something": {
|
|
19
|
-
"type": "string"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"required": ["something"]
|
|
23
|
-
},
|
|
24
|
-
"output": {
|
|
25
|
-
"responseType": "html"
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
]
|
|
29
|
-
}
|