@squiz/component-cli-lib 1.69.0 → 1.70.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.
Files changed (67) hide show
  1. package/lib/index.js +63 -63
  2. package/lib/index.js.map +2 -2
  3. package/package.json +9 -6
  4. package/.env.example +0 -11
  5. package/.gitlab-ci.yml +0 -141
  6. package/CHANGELOG.md +0 -656
  7. package/build.js +0 -28
  8. package/jest.config.ts +0 -28
  9. package/jest.integration.config.ts +0 -27
  10. package/job-runner-lib.tgz +0 -0
  11. package/localStart.ts +0 -11
  12. package/src/component-dev-folder-structures.integration.spec.ts +0 -91
  13. package/src/component-dev.integration.spec.ts +0 -71
  14. package/src/component-dev.ts +0 -102
  15. package/src/component-edge-dev.ts +0 -75
  16. package/src/component-init.spec.ts +0 -258
  17. package/src/component-init.ts +0 -81
  18. package/src/index.ts +0 -5
  19. package/src/integration-tests/__components__/big-package/manifest.json +0 -36
  20. package/src/integration-tests/__components__/big-package/render-json.js +0 -5
  21. package/src/integration-tests/__components__/cmp-format-string/main.js +0 -7
  22. package/src/integration-tests/__components__/cmp-format-string/manifest.json +0 -41
  23. package/src/integration-tests/__components__/cmp-no-api-key/main.js +0 -25
  24. package/src/integration-tests/__components__/cmp-no-api-key/manifest.json +0 -41
  25. package/src/integration-tests/__components__/cmp-property-order/main.js +0 -6
  26. package/src/integration-tests/__components__/cmp-property-order/manifest.json +0 -60
  27. package/src/integration-tests/__components__/cmp-static-file-test/main.js +0 -6
  28. package/src/integration-tests/__components__/cmp-static-file-test/manifest.json +0 -42
  29. package/src/integration-tests/__components__/cmp-static-file-test/public/static-library-file.js +0 -1
  30. package/src/integration-tests/__components__/invalid-manifest/main.js +0 -3
  31. package/src/integration-tests/__components__/invalid-manifest/manifest.json +0 -29
  32. package/src/integration-tests/__components__/invalid-upload/main.js +0 -3
  33. package/src/integration-tests/__components__/matrix-asset-uri/main.js +0 -7
  34. package/src/integration-tests/__components__/matrix-asset-uri/manifest.json +0 -42
  35. package/src/integration-tests/__components__/test-page-render/main.js +0 -3
  36. package/src/integration-tests/__components__/test-page-render/manifest.json +0 -46
  37. package/src/integration-tests/__components__/test-page-render/public/static-library-script.js +0 -1
  38. package/src/integration-tests/__components__/test-page-render/public/static-library-styles.css +0 -3
  39. package/src/integration-tests/__jobs__/invalid-manifest/main.js +0 -3
  40. package/src/integration-tests/__jobs__/invalid-manifest/manifest.json +0 -28
  41. package/src/integration-tests/__jobs__/invalid-upload/main.js +0 -3
  42. package/src/integration-tests/__jobs__/simple-job/main.js +0 -3
  43. package/src/integration-tests/__jobs__/simple-job/manifest.json +0 -25
  44. package/src/integration-tests/helper.ts +0 -227
  45. package/src/integration-tests/service-deployment.integration.spec.ts +0 -74
  46. package/src/integration-tests/test-setup.ts +0 -1
  47. package/src/upload-component-folder.ts +0 -130
  48. package/src/upload-job.ts +0 -101
  49. package/src/utils.spec.ts +0 -370
  50. package/src/utils.ts +0 -149
  51. package/templates/advanced/build.js +0 -43
  52. package/templates/advanced/main.js +0 -3
  53. package/templates/advanced/manifest.json +0 -60
  54. package/templates/advanced/package-lock.json +0 -916
  55. package/templates/advanced/package.json +0 -11
  56. package/templates/advanced/previews/example.data.json +0 -1
  57. package/templates/advanced/previews/preview.html +0 -9
  58. package/templates/advanced/static/default.js +0 -1
  59. package/templates/advanced/static/default.scss +0 -1
  60. package/templates/basic/main.js +0 -3
  61. package/templates/basic/manifest.json +0 -62
  62. package/templates/basic/previews/example.data.json +0 -1
  63. package/templates/basic/previews/preview.html +0 -9
  64. package/templates/basic/static/default.css +0 -1
  65. package/templates/basic/static/default.js +0 -1
  66. package/tsconfig.json +0 -26
  67. package/tsconfig.tsbuildinfo +0 -1
@@ -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,5 +0,0 @@
1
- module.exports = async function () {
2
- return {
3
- 'my-prop': 'test value for my-prop',
4
- };
5
- };
@@ -1,7 +0,0 @@
1
- /**
2
- * @param {object} input
3
- * @param {ComponentInfo} info
4
- */
5
- module.exports = async function (input, info) {
6
- return `<div>Input: ${input.text}</div>`;
7
- };
@@ -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,6 +0,0 @@
1
- /**
2
- * @param {object} input
3
- */
4
- module.exports = async function (input) {
5
- return `<div>Input: ${JSON.stringify(input)}</div>`;
6
- };
@@ -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,6 +0,0 @@
1
- module.exports = async function (input, info) {
2
- return (
3
- `<div>Input: ${input.something}</div>` +
4
- `<div>${info.componentName} ${info.version} ${info.ctx.getStaticResourceUrl('birthday-cake.png')}</div>`
5
- );
6
- };
@@ -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
- }
@@ -1,3 +0,0 @@
1
- module.exports = async function (input, info) {
2
- return '<div>test</div>';
3
- };
@@ -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
- }
@@ -1,3 +0,0 @@
1
- module.exports = async function (input, info) {
2
- return '<div>test</div>';
3
- };
@@ -1,7 +0,0 @@
1
- /**
2
- * @param {object} input
3
- * @param {ComponentInfo} info
4
- */
5
- module.exports = async function (input, info) {
6
- return `<div>Input: ${input.text}</div>`;
7
- };
@@ -1,42 +0,0 @@
1
- {
2
- "$schema": "http://localhost:3000/schemas/v1.json#",
3
-
4
- "name": "matrix-asset-uri",
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": "matrix-asset-uri",
20
- "matrixAssetTypes": ["image"]
21
- }
22
- },
23
- "required": ["text"]
24
- },
25
- "output": { "responseType": "html" }
26
- }
27
- ],
28
- "previews": {
29
- "test-preview": {
30
- "functionData": {
31
- "main": {
32
- "inputData": {
33
- "type": "inline",
34
- "value": {
35
- "text": "matrix-asset://canary.uat.matrix.squiz.cloud/123"
36
- }
37
- }
38
- }
39
- }
40
- }
41
- }
42
- }
@@ -1,3 +0,0 @@
1
- module.exports = async function (input, info) {
2
- return `<div>component-html</div>`;
3
- };
@@ -1,46 +0,0 @@
1
- {
2
- "$schema": "http://localhost:3000/schemas/v1.json#",
3
- "name": "test-page-render",
4
- "version": "1.0.0",
5
- "mainFunction": "main",
6
- "displayName": "some-display-name",
7
- "namespace": "unit-test-components",
8
- "description": "some-description",
9
- "functions": [
10
- {
11
- "name": "main",
12
- "entry": "main.js",
13
- "input": {
14
- "type": "object",
15
- "properties": {
16
- "text ": {
17
- "type": "string"
18
- }
19
- },
20
- "required": []
21
- },
22
- "output": {
23
- "responseType": "html",
24
- "staticFiles": [
25
- {
26
- "location": "header",
27
- "file": {
28
- "filepath": "static-library-styles.css",
29
- "type": "css"
30
- }
31
- },
32
- {
33
- "location": "footer",
34
- "file": {
35
- "filepath": "static-library-script.js",
36
- "type": "js"
37
- }
38
- }
39
- ]
40
- }
41
- }
42
- ],
43
- "staticFiles": {
44
- "locationRoot": "public"
45
- }
46
- }
@@ -1,3 +0,0 @@
1
- .component-class {
2
- color: red;
3
- }
@@ -1,3 +0,0 @@
1
- module.exports = async function (input, info) {
2
- return 'this is a test job';
3
- };
@@ -1,28 +0,0 @@
1
- {
2
- "$schema": "http://localhost:3040/schemas/JobV1.json#",
3
- "name": "invalid manif@st",
4
- "version": "1.0.0",
5
- "mainFunction": "main",
6
- "displayName": "some-displayName",
7
- "description": "some-description",
8
- "concurrency": 1,
9
- "timeout": 10000,
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": ["something"]
22
- },
23
- "output": {
24
- "responseType": "html"
25
- }
26
- }
27
- ]
28
- }
@@ -1,3 +0,0 @@
1
- module.exports = async function (input, info) {
2
- return 'this is a test job';
3
- };
@@ -1,3 +0,0 @@
1
- module.exports = async function (input, info) {
2
- return 'this is a test job';
3
- };
@@ -1,25 +0,0 @@
1
- {
2
- "$schema": "http://localhost:3040/schemas/JobV1.json#",
3
- "name": "simple-job",
4
- "displayName": "Simple Job",
5
- "version": "1.0.2",
6
- "mainFunction": "main",
7
- "description": "some-description",
8
- "concurrency": 1,
9
- "timeout": 10000,
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": ["something"]
22
- }
23
- }
24
- ]
25
- }