@squiz/component-cli-lib 1.2.1-alpha.107 → 1.2.1-alpha.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -730
- package/jest.config.ts +3 -11
- package/lib/index.d.ts +1 -2
- package/lib/index.js +79 -5
- package/lib/index.js.map +1 -1
- package/lib/{component-dev-folder-structures.spec.d.ts → test.d.ts} +0 -0
- package/lib/test.js +12 -0
- package/lib/test.js.map +1 -0
- package/lib/utils/zipDirectory.d.ts +1 -0
- package/lib/utils/zipDirectory.js +32 -0
- package/lib/utils/zipDirectory.js.map +1 -0
- package/package.json +16 -22
- package/src/index.ts +90 -2
- package/src/test.ts +9 -0
- package/src/utils/zipDirectory.ts +31 -0
- package/tsconfig.json +1 -6
- package/tsconfig.tsbuildinfo +1 -1
- package/.gitlab-ci.yml +0 -115
- package/jest.integration.config.ts +0 -17
- package/lib/component-dev-folder-structures.spec.js +0 -58
- package/lib/component-dev-folder-structures.spec.js.map +0 -1
- package/lib/component-dev.d.ts +0 -16
- package/lib/component-dev.js +0 -49
- package/lib/component-dev.js.map +0 -1
- package/lib/component-dev.spec.d.ts +0 -1
- package/lib/component-dev.spec.js +0 -54
- package/lib/component-dev.spec.js.map +0 -1
- package/lib/integration-tests/__components__/big-package/manifest.json +0 -35
- package/lib/integration-tests/__components__/cmp-static-file-test/manifest.json +0 -39
- package/lib/integration-tests/__components__/invalid-manifest/manifest.json +0 -27
- package/lib/integration-tests/helper.d.ts +0 -19
- package/lib/integration-tests/helper.js +0 -73
- package/lib/integration-tests/helper.js.map +0 -1
- package/lib/integration-tests/service-deployment.spec.d.ts +0 -1
- package/lib/integration-tests/service-deployment.spec.js +0 -36
- package/lib/integration-tests/service-deployment.spec.js.map +0 -1
- package/lib/integration-tests/test-setup.d.ts +0 -0
- package/lib/integration-tests/test-setup.js +0 -3
- package/lib/integration-tests/test-setup.js.map +0 -1
- package/lib/integration-tests/upload-and-render-component.spec.d.ts +0 -1
- package/lib/integration-tests/upload-and-render-component.spec.js +0 -141
- package/lib/integration-tests/upload-and-render-component.spec.js.map +0 -1
- package/lib/upload-component-folder.d.ts +0 -3
- package/lib/upload-component-folder.js +0 -131
- package/lib/upload-component-folder.js.map +0 -1
- package/src/component-dev-folder-structures.spec.ts +0 -69
- package/src/component-dev.spec.ts +0 -59
- package/src/component-dev.ts +0 -60
- 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-static-file-test/main.js +0 -10
- 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 -7
- package/src/integration-tests/__components__/invalid-manifest/manifest.json +0 -29
- package/src/integration-tests/__components__/invalid-upload/main.js +0 -7
- package/src/integration-tests/helper.ts +0 -79
- package/src/integration-tests/service-deployment.spec.ts +0 -45
- package/src/integration-tests/test-setup.ts +0 -1
- package/src/integration-tests/upload-and-render-component.spec.ts +0 -173
- package/src/upload-component-folder.ts +0 -145
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://localhost:3000/schemas/v1.json#",
|
|
3
|
-
"name": "cmp-static-file-test",
|
|
4
|
-
"version": "1.0.0",
|
|
5
|
-
"main-function": "main",
|
|
6
|
-
"namespace": "smoke-test-components",
|
|
7
|
-
"display-name": "some-display-name",
|
|
8
|
-
"description": "some-description",
|
|
9
|
-
"functions": [
|
|
10
|
-
{
|
|
11
|
-
"entry": "main.js",
|
|
12
|
-
"name": "main",
|
|
13
|
-
"input": {
|
|
14
|
-
"type": "object",
|
|
15
|
-
"properties": {
|
|
16
|
-
"something": {
|
|
17
|
-
"type": "string"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"required": ["something"]
|
|
21
|
-
},
|
|
22
|
-
"output": {
|
|
23
|
-
"response-type": "html",
|
|
24
|
-
"static-files": [
|
|
25
|
-
{
|
|
26
|
-
"location": "header",
|
|
27
|
-
"file": {
|
|
28
|
-
"filepath": "static-library-file.js",
|
|
29
|
-
"type": "js"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
],
|
|
36
|
-
"static-files": {
|
|
37
|
-
"location-root": "public"
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://localhost:3000/schemas/v1.json#",
|
|
3
|
-
"name": "invalid-manifes@t",
|
|
4
|
-
"version": "1.0.0",
|
|
5
|
-
"main-function": "main",
|
|
6
|
-
"namespace": "smoke-test-components",
|
|
7
|
-
"display-name": "some-display-name",
|
|
8
|
-
"description": "some-description",
|
|
9
|
-
"functions": [
|
|
10
|
-
{
|
|
11
|
-
"entry": "main.js",
|
|
12
|
-
"name": "main",
|
|
13
|
-
"input": {
|
|
14
|
-
"type": "object",
|
|
15
|
-
"properties": {
|
|
16
|
-
"something": {
|
|
17
|
-
"type": "string"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"required": ["something"]
|
|
21
|
-
},
|
|
22
|
-
"output": {
|
|
23
|
-
"response-type": "html"
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ComponentSetWebModel } from '@squiz/component-lib';
|
|
2
|
-
interface Config {
|
|
3
|
-
managementServiceUrl: string;
|
|
4
|
-
renderServiceUrl: string;
|
|
5
|
-
ci_buildVersion: string;
|
|
6
|
-
ci_buildBranch: string;
|
|
7
|
-
}
|
|
8
|
-
declare const configObj: Config;
|
|
9
|
-
export default configObj;
|
|
10
|
-
export declare const managementService: import("axios").AxiosInstance;
|
|
11
|
-
export declare const managementServiceRoot: import("axios").AxiosInstance;
|
|
12
|
-
export declare const renderService: import("axios").AxiosInstance;
|
|
13
|
-
export declare const ci_buildVersion: string;
|
|
14
|
-
export declare const ci_buildBranch: string;
|
|
15
|
-
export declare function getTestComponents(): string[];
|
|
16
|
-
export declare function createFile(filePath: string, sizeInMB: number): Promise<void>;
|
|
17
|
-
export declare function removeFile(filePath: string): void;
|
|
18
|
-
export declare function deleteComponentSet(webPath: string): Promise<void>;
|
|
19
|
-
export declare function addComponentSet(componentSet: ComponentSetWebModel): Promise<void>;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.addComponentSet = exports.deleteComponentSet = exports.removeFile = exports.createFile = exports.getTestComponents = exports.ci_buildBranch = exports.ci_buildVersion = exports.renderService = exports.managementServiceRoot = exports.managementService = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
11
|
-
const crypto_1 = require("crypto");
|
|
12
|
-
const dx_common_lib_1 = require("@squiz/dx-common-lib");
|
|
13
|
-
const dotenv_1 = require("dotenv");
|
|
14
|
-
(0, dotenv_1.config)();
|
|
15
|
-
const configObj = {
|
|
16
|
-
managementServiceUrl: (0, dx_common_lib_1.parseEnvVarForVar)('COMPONENT_MANAGEMENT_SERVICE_URL').replace(/\/+$/, ''),
|
|
17
|
-
renderServiceUrl: (0, dx_common_lib_1.parseEnvVarForVar)('COMPONENT_RENDER_SERVICE_URL').replace(/\/+$/, ''),
|
|
18
|
-
ci_buildVersion: (0, dx_common_lib_1.parseEnvVarForVar)('CI_COMMIT_SHORT_SHA'),
|
|
19
|
-
ci_buildBranch: (0, dx_common_lib_1.parseEnvVarForVar)('CI_COMMIT_REF_NAME'),
|
|
20
|
-
};
|
|
21
|
-
exports.default = configObj;
|
|
22
|
-
exports.managementService = axios_1.default.create({
|
|
23
|
-
baseURL: configObj.managementServiceUrl + '/v1',
|
|
24
|
-
});
|
|
25
|
-
exports.managementServiceRoot = axios_1.default.create({
|
|
26
|
-
baseURL: configObj.managementServiceUrl,
|
|
27
|
-
});
|
|
28
|
-
exports.renderService = axios_1.default.create({
|
|
29
|
-
baseURL: configObj.renderServiceUrl,
|
|
30
|
-
});
|
|
31
|
-
exports.ci_buildVersion = configObj.ci_buildVersion;
|
|
32
|
-
exports.ci_buildBranch = configObj.ci_buildBranch;
|
|
33
|
-
function getTestComponents() {
|
|
34
|
-
const componets = [];
|
|
35
|
-
const componentsDir = path_1.default.join(__dirname, '/__components__/');
|
|
36
|
-
const files = fs_1.default.readdirSync(componentsDir);
|
|
37
|
-
for (const file of files) {
|
|
38
|
-
const stat = fs_1.default.statSync(path_1.default.join(componentsDir, file));
|
|
39
|
-
if (stat.isDirectory() && file.substring(0, 4) === 'cmp-') {
|
|
40
|
-
componets.push(file);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return componets;
|
|
44
|
-
}
|
|
45
|
-
exports.getTestComponents = getTestComponents;
|
|
46
|
-
async function createFile(filePath, sizeInMB) {
|
|
47
|
-
const content = (0, crypto_1.randomBytes)(sizeInMB * 1000000);
|
|
48
|
-
await promises_1.default.writeFile(`${filePath}`, content);
|
|
49
|
-
}
|
|
50
|
-
exports.createFile = createFile;
|
|
51
|
-
function removeFile(filePath) {
|
|
52
|
-
promises_1.default.unlink(filePath);
|
|
53
|
-
}
|
|
54
|
-
exports.removeFile = removeFile;
|
|
55
|
-
async function deleteComponentSet(webPath) {
|
|
56
|
-
try {
|
|
57
|
-
await exports.managementService.delete(`/component-set/${webPath}`);
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
// no ops
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.deleteComponentSet = deleteComponentSet;
|
|
64
|
-
async function addComponentSet(componentSet) {
|
|
65
|
-
try {
|
|
66
|
-
await exports.managementService.post(`/component-set`, componentSet);
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
//no ops
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.addComponentSet = addComponentSet;
|
|
73
|
-
//# sourceMappingURL=helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../src/integration-tests/helper.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,4CAAoB;AACpB,gDAAwB;AAExB,2DAA8B;AAC9B,mCAAqC;AAErC,wDAAyD;AACzD,mCAAgC;AAEhC,IAAA,eAAM,GAAE,CAAC;AAST,MAAM,SAAS,GAAW;IACxB,oBAAoB,EAAE,IAAA,iCAAiB,EAAC,kCAAkC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;IAC/F,gBAAgB,EAAE,IAAA,iCAAiB,EAAC,8BAA8B,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;IACvF,eAAe,EAAE,IAAA,iCAAiB,EAAC,qBAAqB,CAAC;IACzD,cAAc,EAAE,IAAA,iCAAiB,EAAC,oBAAoB,CAAC;CACxD,CAAC;AAEF,kBAAe,SAAS,CAAC;AAEZ,QAAA,iBAAiB,GAAG,eAAK,CAAC,MAAM,CAAC;IAC5C,OAAO,EAAE,SAAS,CAAC,oBAAoB,GAAG,KAAK;CAChD,CAAC,CAAC;AAEU,QAAA,qBAAqB,GAAG,eAAK,CAAC,MAAM,CAAC;IAChD,OAAO,EAAE,SAAS,CAAC,oBAAoB;CACxC,CAAC,CAAC;AAEU,QAAA,aAAa,GAAG,eAAK,CAAC,MAAM,CAAC;IACxC,OAAO,EAAE,SAAS,CAAC,gBAAgB;CACpC,CAAC,CAAC;AAEU,QAAA,eA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AAI;QACF,MAAM,yBAAiB,CAAC,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC;KAC9D;IAAC,OAAO,KAAK,EAAE;QACd,QAAQ;KACT;AACH,CAAC;AAND,0CAMC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const helper_1 = require("./helper");
|
|
4
|
-
describe('Verify latest services deployments', () => {
|
|
5
|
-
it('Should have latest Management API service', async () => {
|
|
6
|
-
const response = (await helper_1.managementServiceRoot.get('/health')).data;
|
|
7
|
-
expect(response.buildVersion).toBe(helper_1.ci_buildVersion);
|
|
8
|
-
expect(response.buildBranch).toBe(helper_1.ci_buildBranch);
|
|
9
|
-
});
|
|
10
|
-
it('Should return 200 for Management API docs', async () => {
|
|
11
|
-
const req = await helper_1.managementService.get('/docs');
|
|
12
|
-
expect(req.status).toBe(200);
|
|
13
|
-
expect(req.headers['content-type']).toEqual('text/html; charset=utf-8');
|
|
14
|
-
});
|
|
15
|
-
it('Should return 200 for Management API docs.json', async () => {
|
|
16
|
-
const req = await helper_1.managementService.get('/docs.json');
|
|
17
|
-
expect(req.status).toBe(200);
|
|
18
|
-
expect(req.headers['content-type']).toEqual('application/json; charset=UTF-8');
|
|
19
|
-
});
|
|
20
|
-
it('Should have latest Render Runtime service', async () => {
|
|
21
|
-
const response = (await helper_1.renderService.get('/health')).data;
|
|
22
|
-
expect(response.buildVersion).toBe(helper_1.ci_buildVersion);
|
|
23
|
-
expect(response.buildBranch).toBe(helper_1.ci_buildBranch);
|
|
24
|
-
});
|
|
25
|
-
it('Should return 200 for Render Runtime API docs', async () => {
|
|
26
|
-
const req = await helper_1.renderService.get('/docs');
|
|
27
|
-
expect(req.status).toBe(200);
|
|
28
|
-
expect(req.headers['content-type']).toEqual('text/html; charset=utf-8');
|
|
29
|
-
});
|
|
30
|
-
it('Should return 200 for Render Runtime API docs.json', async () => {
|
|
31
|
-
const req = await helper_1.renderService.get('/docs.json');
|
|
32
|
-
expect(req.status).toBe(200);
|
|
33
|
-
expect(req.headers['content-type']).toEqual('application/json; charset=UTF-8');
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
//# sourceMappingURL=service-deployment.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service-deployment.spec.js","sourceRoot":"","sources":["../../src/integration-tests/service-deployment.spec.ts"],"names":[],"mappings":";;AAAA,qCAAoH;AAQpH,QAAQ,CAAC,oCAAoC,EAAE,GAAG,EAAE;IAClD,EAAE,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;QACzD,MAAM,QAAQ,GAAe,CAAC,MAAM,8BAAqB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;QAC/E,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,wBAAe,CAAC,CAAC;QACpD,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,uBAAc,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;QACzD,MAAM,GAAG,GAAG,MAAM,0BAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACjD,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7B,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EAAE,KAAK,IAAI,EAAE;QAC9D,MAAM,GAAG,GAAG,MAAM,0BAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QACtD,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,C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"test-setup.js","sourceRoot":"","sources":["../../src/integration-tests/test-setup.ts"],"names":[],"mappings":";AAAA,IAAI,CAAC,UAAU,CAAC,KAAM,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const index_1 = require("../index");
|
|
30
|
-
const helper_1 = __importStar(require("./helper"));
|
|
31
|
-
const cli_color_1 = __importDefault(require("cli-color"));
|
|
32
|
-
const path_1 = __importDefault(require("path"));
|
|
33
|
-
const supertest_1 = __importDefault(require("supertest"));
|
|
34
|
-
const upload_component_folder_1 = require("../upload-component-folder");
|
|
35
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
36
|
-
const mockConsoleError = jest.fn();
|
|
37
|
-
const mockConsoleLog = jest.fn();
|
|
38
|
-
const orgConsoleError = console.error;
|
|
39
|
-
const webPath = 'set';
|
|
40
|
-
const testFilesDir = path_1.default.resolve(__dirname, 'test-files');
|
|
41
|
-
beforeAll(async () => {
|
|
42
|
-
await promises_1.default.rm(testFilesDir, { force: true, recursive: true });
|
|
43
|
-
await promises_1.default.mkdir(testFilesDir);
|
|
44
|
-
});
|
|
45
|
-
afterAll(async () => {
|
|
46
|
-
// clean up the component added by the test
|
|
47
|
-
await (0, helper_1.deleteComponentSet)(webPath);
|
|
48
|
-
for (const componentName of (0, helper_1.getTestComponents)()) {
|
|
49
|
-
try {
|
|
50
|
-
await helper_1.managementService.delete(`/component/smoke-test-components/${componentName}`);
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
// no op
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
// clean up the test componnet files
|
|
57
|
-
await promises_1.default.rm(testFilesDir, { force: true, recursive: true });
|
|
58
|
-
});
|
|
59
|
-
describe('Test isolated test cases', () => {
|
|
60
|
-
beforeEach(() => {
|
|
61
|
-
jest.spyOn(upload_component_folder_1.logger, 'error').mockImplementation(mockConsoleError);
|
|
62
|
-
jest.spyOn(upload_component_folder_1.logger, 'info').mockImplementation(mockConsoleLog);
|
|
63
|
-
});
|
|
64
|
-
it('Should fail uploading a component without manifest.json', async () => {
|
|
65
|
-
mockConsoleError.mockClear();
|
|
66
|
-
const componentPath = path_1.default.join(__dirname, '/__components__/invalid-upload');
|
|
67
|
-
await (0, index_1.uploadComponentFolder)(componentPath, helper_1.default.managementServiceUrl + '/v1', helper_1.default.renderServiceUrl, testFilesDir);
|
|
68
|
-
expect(mockConsoleError.mock.calls[0][0]).toEqual(cli_color_1.default.red('manifest could not be found'));
|
|
69
|
-
});
|
|
70
|
-
it('Should fail uploading a component that has invalid manifest.json', async () => {
|
|
71
|
-
mockConsoleError.mockClear();
|
|
72
|
-
const componentPath = path_1.default.join(__dirname, '/__components__/invalid-manifest');
|
|
73
|
-
await (0, index_1.uploadComponentFolder)(componentPath, helper_1.default.managementServiceUrl + '/v1', helper_1.default.renderServiceUrl, testFilesDir);
|
|
74
|
-
expect(mockConsoleError.mock.calls[0][0]).toEqual(cli_color_1.default.red('failed validation: /name pattern must match pattern "^[a-zA-Z0-9_\\-]+$"'));
|
|
75
|
-
});
|
|
76
|
-
it('Should fail uploading the component that has size more than 100MB', async () => {
|
|
77
|
-
mockConsoleError.mockClear();
|
|
78
|
-
const componentPath = path_1.default.join(__dirname, '/__components__/big-package');
|
|
79
|
-
const filePath = `${componentPath}/105mb-file`;
|
|
80
|
-
await (0, helper_1.createFile)(filePath, 105); // Higher limit has been used because compression reduces the size if you use closer to 100MB
|
|
81
|
-
await (0, index_1.uploadComponentFolder)(componentPath, helper_1.default.managementServiceUrl + '/v1', helper_1.default.renderServiceUrl, testFilesDir);
|
|
82
|
-
expect(mockConsoleError.mock.calls[0][0]).toEqual(cli_color_1.default.red(['File size exceeds the maximum limit of 100MB'].join('')));
|
|
83
|
-
(0, helper_1.removeFile)(filePath);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
describe('Deploy basic component having a static file', () => {
|
|
87
|
-
// component to deploy for this test
|
|
88
|
-
const componentPath = path_1.default.join(__dirname, '/__components__/cmp-static-file-test');
|
|
89
|
-
beforeAll(async () => {
|
|
90
|
-
await (0, helper_1.deleteComponentSet)(webPath);
|
|
91
|
-
for (const componentName of (0, helper_1.getTestComponents)()) {
|
|
92
|
-
try {
|
|
93
|
-
await helper_1.managementService.delete(`/component/${componentName}`);
|
|
94
|
-
}
|
|
95
|
-
catch {
|
|
96
|
-
// no op
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
beforeEach(() => {
|
|
101
|
-
console.error = mockConsoleError;
|
|
102
|
-
console.log = mockConsoleLog;
|
|
103
|
-
});
|
|
104
|
-
afterEach(() => {
|
|
105
|
-
console.error = orgConsoleError;
|
|
106
|
-
});
|
|
107
|
-
it('Should upload the component and return a valid url to preview', async () => {
|
|
108
|
-
var _a;
|
|
109
|
-
await (0, index_1.uploadComponentFolder)(componentPath, helper_1.default.managementServiceUrl + '/v1', helper_1.default.renderServiceUrl, testFilesDir);
|
|
110
|
-
const uploadedComponent = '<a href="/r/set/smoke-test-components/cmp-static-file-test/1.0.0">1.0.0</a>';
|
|
111
|
-
const get = await (0, supertest_1.default)(helper_1.default.renderServiceUrl).get('/');
|
|
112
|
-
expect(get.status).toEqual(200);
|
|
113
|
-
expect((_a = get === null || get === void 0 ? void 0 : get.res) === null || _a === void 0 ? void 0 : _a.text).toContain(uploadedComponent);
|
|
114
|
-
});
|
|
115
|
-
it('Should fail upload the component with same version', async () => {
|
|
116
|
-
mockConsoleError.mockClear();
|
|
117
|
-
await (0, index_1.uploadComponentFolder)(componentPath, helper_1.default.managementServiceUrl + '/v1', helper_1.default.renderServiceUrl, testFilesDir);
|
|
118
|
-
expect(mockConsoleError.mock.calls[0][0]).toEqual(cli_color_1.default.red('Cannot upload component version, smoke-test-components/cmp-static-file-test 1.0.0 already exists'));
|
|
119
|
-
});
|
|
120
|
-
it('Should render component', async () => {
|
|
121
|
-
const componentSet = {
|
|
122
|
-
webPath,
|
|
123
|
-
displayName: 'Set',
|
|
124
|
-
description: 'Set description',
|
|
125
|
-
headers: {},
|
|
126
|
-
envVars: {},
|
|
127
|
-
components: {
|
|
128
|
-
'smoke-test-components/cmp-static-file-test': [{ envVars: {}, version: '1.0.0' }],
|
|
129
|
-
},
|
|
130
|
-
};
|
|
131
|
-
await (0, helper_1.addComponentSet)(componentSet);
|
|
132
|
-
const response = await helper_1.renderService.get('/r/set/smoke-test-components/cmp-static-file-test/1.0.0/?something=hello');
|
|
133
|
-
expect(response.status).toEqual(200);
|
|
134
|
-
expect(response.data).toEqual([
|
|
135
|
-
'<div>Input: hello</div>',
|
|
136
|
-
'<div>smoke-test-components/cmp-static-file-test 1.0.0 ',
|
|
137
|
-
`${helper_1.default.renderServiceUrl}/s/smoke-test-components/cmp-static-file-test/1.0.0/birthday-cake.png</div>`,
|
|
138
|
-
].join(''));
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
//# sourceMappingURL=upload-and-render-component.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upload-and-render-component.spec.js","sourceRoot":"","sources":["../../src/integration-tests/upload-and-render-component.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAiD;AACjD,mDAQkB;AAClB,0DAA8B;AAC9B,gDAAwB;AACxB,0DAAkC;AAClC,wEAAoD;AAEpD,2DAA8B;AAE9B,MAAM,gBAAgB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AACnC,MAAM,cAAc,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAEjC,MAAM,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC;AACtC,MAAM,OAAO,GAAG,KAAK,CAAC;AACtB,MAAM,YAAY,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AAE3D,SAAS,CAAC,KAAK,IAAI,EAAE;IACnB,MAAM,kBAAG,CAAC,EAAE,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,MAAM,kBAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AAChC,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,KAAK,IAAI,EAAE;IAClB,2CAA2C;IAC3C,MAAM,IAAA,2BAAkB,EAAC,OAAO,CAAC,CAAC;IAElC,KAAK,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,GAAG,KAAK,EACtC,gBAAS,CAAC,gBAAgB,EAC1B,YAAY,CACb,CAAC;QACF,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAC/C,mBAAK,CAAC,GAAG,CAAC,kGAAkG,CAAC,CAC9G,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yBAAyB,EAAE,KAAK,IAAI,EAAE;QACvC,MAAM,YAAY,GAAyB;YACzC,OAAO;YACP,WAAW,EAAE,KAAK;YAClB,WAAW,EAAE,iBAAiB;YAC9B,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,EAAE;YACX,UAAU,EAAE;gBACV,4CAA4C,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;aAClF;SACF,CAAC;QAEF,MAAM,IAAA,wBAAe,EAAC,YAAY,CAAC,CAAC;QAEpC,MAAM,QAAQ,GAAG,MAAM,sBAAa,CAAC,GAAG,CACtC,0EAA0E,CAC3E,CAAC;QACF,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAC3B;YACE,yBAAyB;YACzB,wDAAwD;YACxD,GAAG,gBAAS,CAAC,gBAAgB,6EAA6E;SAC3G,CAAC,IAAI,CAAC,EAAE,CAAC,CACX,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.uploadComponentFolder = exports.logger = void 0;
|
|
7
|
-
const virus_scanner_lib_1 = require("@squiz/virus-scanner-lib");
|
|
8
|
-
const dx_common_lib_1 = require("@squiz/dx-common-lib");
|
|
9
|
-
const component_lib_1 = require("@squiz/component-lib");
|
|
10
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
11
|
-
const path_1 = __importDefault(require("path"));
|
|
12
|
-
const axios_1 = __importDefault(require("axios"));
|
|
13
|
-
const cli_color_1 = __importDefault(require("cli-color"));
|
|
14
|
-
const dx_logger_lib_1 = require("@squiz/dx-logger-lib");
|
|
15
|
-
exports.logger = (0, dx_logger_lib_1.getLogger)({ name: 'upload-component', format: 'human' });
|
|
16
|
-
async function uploadComponentFolder(folderPath, componentServiceManagementUrl, componentRenderServiceUrl, baseTempDir = '') {
|
|
17
|
-
const tmpDir = await promises_1.default.mkdtemp(path_1.default.resolve(baseTempDir, 'cmp-upload'));
|
|
18
|
-
try {
|
|
19
|
-
const axiosInstance = axios_1.default.create({
|
|
20
|
-
baseURL: componentServiceManagementUrl,
|
|
21
|
-
headers: {
|
|
22
|
-
'content-type': 'application/json',
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
await preUploadChecks(folderPath, componentRenderServiceUrl);
|
|
26
|
-
exports.logger.info('Initial scanning');
|
|
27
|
-
const zip = await (0, dx_common_lib_1.zipDirectory)(folderPath, tmpDir);
|
|
28
|
-
const initialUpload = await handleResponse(axiosInstance.post('upload-component'));
|
|
29
|
-
exports.logger.info(`deployment id: ${initialUpload.id} status: transferring`);
|
|
30
|
-
await (0, virus_scanner_lib_1.uploadFile)(initialUpload, zip);
|
|
31
|
-
await watchAndWaitForUploadAndScanComplete(initialUpload.id, axiosInstance);
|
|
32
|
-
exports.logger.info(`deployment id: ${initialUpload.id} status: deploying component folder`);
|
|
33
|
-
const result = await handleResponse(axiosInstance.post(`upload-component/next/${initialUpload.id}`));
|
|
34
|
-
await promises_1.default.rm(tmpDir, { force: true, recursive: true });
|
|
35
|
-
if (result.status === 'successful') {
|
|
36
|
-
exports.logger.info(`deployment id: ${initialUpload.id} status: ${cli_color_1.default.green('success')}`);
|
|
37
|
-
exports.logger.info(`uploaded location: ${result.accessLink}`);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
exports.logger.error('failed for an unknown reason', cli_color_1.default.red(result));
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
await promises_1.default.rm(tmpDir, { force: true, recursive: true });
|
|
45
|
-
if (e instanceof Error) {
|
|
46
|
-
exports.logger.error(cli_color_1.default.red(e.message));
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
throw e;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.uploadComponentFolder = uploadComponentFolder;
|
|
54
|
-
async function preUploadChecks(folderPath, renderService) {
|
|
55
|
-
const service = new component_lib_1.ManifestServiceForDev(folderPath, exports.logger);
|
|
56
|
-
const manifestPath = path_1.default.join(folderPath, `manifest.json`);
|
|
57
|
-
const result = await service.readManifest(manifestPath);
|
|
58
|
-
await service.assertManifestIsValid(manifestPath, result.getModel());
|
|
59
|
-
if (await checkIfVersionExists(result, renderService)) {
|
|
60
|
-
throw new Error(`Cannot upload component version, ${result.getName()} ${result.getVersion()} already exists`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
async function checkIfVersionExists(inputManifest, renderService) {
|
|
64
|
-
const axiosInstance = axios_1.default.create({
|
|
65
|
-
baseURL: renderService,
|
|
66
|
-
});
|
|
67
|
-
try {
|
|
68
|
-
const response = await axiosInstance.get(`d/${inputManifest.getName()}/${inputManifest.getVersion()}/manifest.json`);
|
|
69
|
-
if (response.status === 200) {
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
throw new Error(`Unexpected response code ${response.status}`);
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
if (isAxiosError(error)) {
|
|
76
|
-
const { response } = error;
|
|
77
|
-
if ((response === null || response === void 0 ? void 0 : response.status) === 404) {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
throw error;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
async function watchAndWaitForUploadAndScanComplete(id, axiosInstance) {
|
|
85
|
-
const poll = () => handleResponse(axiosInstance.get('upload-component/status/' + id));
|
|
86
|
-
return new Promise((resolve, reject) => {
|
|
87
|
-
const recurse = () => poll().then(async (req) => {
|
|
88
|
-
if (req.status == 'Success') {
|
|
89
|
-
resolve();
|
|
90
|
-
}
|
|
91
|
-
else if (req.status == 'Flagged') {
|
|
92
|
-
reject(new Error('upload has been flagged as a virus'));
|
|
93
|
-
}
|
|
94
|
-
else if (req.status == 'Error') {
|
|
95
|
-
reject(new Error('there has been an error'));
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
setTimeout(async () => {
|
|
99
|
-
await recurse();
|
|
100
|
-
}, 1000);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
recurse();
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
async function handleResponse(axiosInstance) {
|
|
107
|
-
try {
|
|
108
|
-
const response = await axiosInstance;
|
|
109
|
-
return response.data;
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
throw handleError(error);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
function handleError(error) {
|
|
116
|
-
const { response } = error;
|
|
117
|
-
if (!response || !isAxiosError(error)) {
|
|
118
|
-
return error;
|
|
119
|
-
}
|
|
120
|
-
const message = response.data.message;
|
|
121
|
-
if (message) {
|
|
122
|
-
return new Error(`Unexpected response code ${response.status}. message: ${message}`);
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
return new Error(`Unexpected response code ${response.status}.`);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
function isAxiosError(error) {
|
|
129
|
-
return error && error.isAxiosError === true;
|
|
130
|
-
}
|
|
131
|
-
//# sourceMappingURL=upload-component-folder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upload-component-folder.js","sourceRoot":"","sources":["../src/upload-component-folder.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAkE;AAElE,wDAAoD;AACpD,wDAAuE;AACvE,2DAA8B;AAC9B,gDAAwB;AACxB,kDAAwE;AACxE,0DAA8B;AAC9B,wDAAyD;AAE5C,QAAA,MAAM,GAAW,IAAA,yBAAS,EAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;AAEhF,KAAK,UAAU,qBAAqB,CACzC,UAAkB,EAClB,6BAAqC,EACrC,yBAAiC,EACjC,cAAsB,EAAE;IAExB,MAAM,MAAM,GAAG,MAAM,kBAAG,CAAC,OAAO,CAAC,cAAI,CAAC,OAAO,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC;IAE1E,IAAI;QACF,MAAM,aAAa,GAAG,eAAK,CAAC,MAAM,CAAC;YACjC,OAAO,EAAE,6BAA6B;YACtC,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;QAEH,MAAM,eAAe,CAAC,UAAU,EAAE,yBAAyB,CAAC,CAAC;QAC7D,cAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAChC,MAAM,GAAG,GAAG,MAAM,IAAA,4BAAY,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAEnD,MAAM,aAAa,GAAG,MAAM,cAAc,CAAM,aAAa,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC;QAExF,cAAM,CAAC,IAAI,CAAC,kBAAkB,aAAa,CAAC,EAAE,uBAAuB,CAAC,CAAC;QACvE,MAAM,IAAA,8BAAU,EAAC,aAAa,EAAE,GAAG,CAAC,CAAC;QAErC,MAAM,oCAAoC,CAAC,aAAa,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;QAE5E,cAAM,CAAC,IAAI,CAAC,kB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IAAI,KAAK,CAAC,4BAA4B,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;KAClE;AACH,CAAC;AAED,SAAS,YAAY,CAAC,KAAU;IAC9B,OAAO,KAAK,IAAI,KAAK,CAAC,YAAY,KAAK,IAAI,CAAC;AAC9C,CAAC"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import supertest from 'supertest';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import fsp from 'fs/promises';
|
|
4
|
-
|
|
5
|
-
import { TestHelpers } from '@squiz/render-runtime-lib';
|
|
6
|
-
import { startDevelopmentRender } from './component-dev';
|
|
7
|
-
import { Server } from 'http';
|
|
8
|
-
|
|
9
|
-
jest.setTimeout(20_000);
|
|
10
|
-
|
|
11
|
-
describe('component-dev', () => {
|
|
12
|
-
describe('production style folder structure', () => {
|
|
13
|
-
let server: Server;
|
|
14
|
-
let request: supertest.SuperTest<supertest.Test>;
|
|
15
|
-
beforeAll(async () => {
|
|
16
|
-
server = startDevelopmentRender(TestHelpers.getTestComponentFolder(), { port: 0 });
|
|
17
|
-
request = supertest(server);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
afterAll(async () => {
|
|
21
|
-
server.close();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('should find the component', async () => {
|
|
25
|
-
const response = await request.get(`/r/set/unit-test-components/test-component/1.0.0?something=hello`);
|
|
26
|
-
expect(response.text).toEqual('<h1>hello</h1>');
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe('local developer style folders', () => {
|
|
31
|
-
let version: string;
|
|
32
|
-
let componentName: string;
|
|
33
|
-
let fixtureDirectory: string;
|
|
34
|
-
let server: Server;
|
|
35
|
-
let request: supertest.SuperTest<supertest.Test>;
|
|
36
|
-
|
|
37
|
-
beforeAll(async () => {
|
|
38
|
-
const {
|
|
39
|
-
fixtureDirectory: createdFixtureDirectory,
|
|
40
|
-
version: createdVersion,
|
|
41
|
-
componentName: createdName,
|
|
42
|
-
} = await TestHelpers.ComponentFixture.setupFullComponentDirectory('<h1>Hello World</h1>');
|
|
43
|
-
|
|
44
|
-
version = createdVersion;
|
|
45
|
-
fixtureDirectory = createdFixtureDirectory;
|
|
46
|
-
componentName = createdName;
|
|
47
|
-
|
|
48
|
-
server = startDevelopmentRender(fixtureDirectory, { port: 0 });
|
|
49
|
-
request = supertest(server);
|
|
50
|
-
});
|
|
51
|
-
afterAll(async () => {
|
|
52
|
-
server.close();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
afterAll(async () => {
|
|
56
|
-
await fsp.rm(path.join(fixtureDirectory, componentName), { force: true, recursive: true });
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('should handle recursing folders to find the component', async () => {
|
|
60
|
-
const response = await request.get(`/r/set/some-namespace/${componentName}/${version}/`);
|
|
61
|
-
expect(response.text).toEqual('<h1>Hello World</h1>');
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('should handle serving static files from single component directory', async () => {
|
|
65
|
-
const response = await request.get(`/s/some-namespace/${componentName}/${version}/static.txt`);
|
|
66
|
-
expect(response.text).toEqual('hello');
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
});
|