@squiz/component-cli-lib 1.2.1-alpha.68 → 1.2.1-alpha.70

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 (33) hide show
  1. package/.gitlab-ci.yml +69 -7
  2. package/CHANGELOG.md +16 -0
  3. package/lib/component-dev.js +1 -0
  4. package/lib/component-dev.js.map +1 -1
  5. package/lib/component-dev.spec.js +72 -45
  6. package/lib/component-dev.spec.js.map +1 -1
  7. package/lib/index.d.ts +1 -1
  8. package/lib/index.js +3 -87
  9. package/lib/index.js.map +1 -1
  10. package/lib/integration-tests/__components__/big-package/manifest.json +32 -0
  11. package/lib/integration-tests/helper.d.ts +2 -0
  12. package/lib/integration-tests/helper.js +12 -1
  13. package/lib/integration-tests/helper.js.map +1 -1
  14. package/lib/integration-tests/test-setup.js +1 -1
  15. package/lib/integration-tests/upload-and-render-component.spec.js +36 -9
  16. package/lib/integration-tests/upload-and-render-component.spec.js.map +1 -1
  17. package/lib/test.js +4 -10
  18. package/lib/test.js.map +1 -1
  19. package/lib/upload-component-folder.d.ts +1 -0
  20. package/lib/upload-component-folder.js +90 -0
  21. package/lib/upload-component-folder.js.map +1 -0
  22. package/package.json +8 -8
  23. package/src/component-dev.spec.ts +82 -42
  24. package/src/component-dev.ts +2 -0
  25. package/src/index.ts +1 -91
  26. package/src/integration-tests/__components__/big-package/manifest.json +33 -0
  27. package/src/integration-tests/__components__/big-package/render-json.js +5 -0
  28. package/src/integration-tests/helper.ts +10 -0
  29. package/src/integration-tests/test-setup.ts +1 -1
  30. package/src/integration-tests/upload-and-render-component.spec.ts +42 -14
  31. package/src/test.ts +4 -7
  32. package/src/upload-component-folder.ts +91 -0
  33. package/tsconfig.tsbuildinfo +1 -1
package/.gitlab-ci.yml CHANGED
@@ -12,14 +12,35 @@
12
12
  when: on_success
13
13
  - when: never
14
14
 
15
+ .rules:when-other-branch:
16
+ rules:
17
+ - if: $CI_COMMIT_BRANCH != $TARGET_BRANCH_DEVELOPMENT && $CI_COMMIT_BRANCH != $TARGET_BRANCH_UAT
18
+ when: on_success
19
+ - when: never
20
+
21
+ .get-service-urls:
22
+ stage: smoke-test-setup
23
+ image:
24
+ name: amazon/aws-cli
25
+ variables:
26
+ GIT_LAB_CI: "true"
27
+ DEPLOYMENT_LABEL: $CI_COMMIT_BRANCH
28
+ tags:
29
+ - access/aws-dx-nonprod
30
+ script:
31
+ - set -e
32
+ - echo "COMPONENT_MANAGEMENT_SERVICE_URL=$(aws --region $AWS_REGION cloudformation describe-stacks --stack-name dx-${DEPLOYMENT_LABEL}-cmp --max-items 1 --query "Stacks[].Outputs[?contains(OutputKey,'managementServiceURL')].OutputValue" --output text)" >> service-urls.env
33
+ - echo "COMPONENT_RENDER_SERVICE_URL=$(aws --region $AWS_REGION cloudformation describe-stacks --stack-name dx-${DEPLOYMENT_LABEL}-cmp --max-items 1 --query "Stacks[].Outputs[?contains(OutputKey,'renderServiceURL')].OutputValue" --output text)" >> service-urls.env
34
+ artifacts:
35
+ reports:
36
+ dotenv: service-urls.env
37
+
15
38
  .smoke-test:
16
39
  stage: smoke-test
17
40
  tags:
18
41
  - access/aws-dx-nonprod
19
- variables:
20
- COMPONENT_MANAGEMENT_SERVICE_URL: $COMPONENT_MANAGEMENT_SERVICE_URL
21
- COMPONENT_RENDER_SERVICE_URL: $COMPONENT_RENDER_SERVICE_URL
22
42
  script:
43
+ - env
23
44
  - npm i
24
45
  - npm run bootstrap
25
46
  - npm run clean
@@ -34,10 +55,21 @@
34
55
  - runner_system_failure
35
56
  - stuck_or_timeout_failure
36
57
 
37
- smoke-test-development:
58
+ get-branch-service-urls:
59
+ extends:
60
+ - .rules:when-other-branch
61
+ - .get-service-urls
62
+ needs:
63
+ - job: deploy-update-branch-render-service
64
+ - job: deploy-update-branch-management-service
65
+ environment:
66
+ name: non-production-development
67
+ url: components.dev.dx.squiz.cloud
68
+
69
+ get-development-service-urls:
38
70
  extends:
39
71
  - .rules:when-development
40
- - .smoke-test
72
+ - .get-service-urls
41
73
  needs:
42
74
  - job: deploy-update-development-render-service
43
75
  - job: deploy-update-development-management-service
@@ -45,13 +77,43 @@ smoke-test-development:
45
77
  name: non-production-development
46
78
  url: components.dev.dx.squiz.cloud
47
79
 
48
- smoke-test-uat:
80
+ get-uat-service-urls:
49
81
  extends:
50
82
  - .rules:when-uat
51
- - .smoke-test
83
+ - .get-service-urls
52
84
  needs:
53
85
  - job: deploy-update-uat-render-service
54
86
  - job: deploy-update-uat-management-service
87
+ environment:
88
+ name: non-production-development
89
+ url: components.dev.dx.squiz.cloud
90
+
91
+ smoke-test-branch:
92
+ extends:
93
+ - .rules:when-other-branch
94
+ - .smoke-test
95
+ needs:
96
+ - job: get-branch-service-urls
97
+ environment:
98
+ name: non-production-development
99
+ url: components.dev.dx.squiz.cloud
100
+
101
+ smoke-test-development:
102
+ extends:
103
+ - .rules:when-development
104
+ - .smoke-test
105
+ needs:
106
+ - job: get-development-service-urls
107
+ environment:
108
+ name: non-production-development
109
+ url: components.dev.dx.squiz.cloud
110
+
111
+ smoke-test-uat:
112
+ extends:
113
+ - .rules:when-uat
114
+ - .smoke-test
115
+ needs:
116
+ - job: get-uat-service-urls
55
117
  environment:
56
118
  name: non-production-uat
57
119
  url: components.uat.dx.squiz.cloud
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.2.1-alpha.70](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.67...v1.2.1-alpha.70) (2022-07-19)
7
+
8
+ **Note:** Version bump only for package @squiz/component-cli-lib
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.2.1-alpha.69](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.67...v1.2.1-alpha.69) (2022-07-19)
15
+
16
+ **Note:** Version bump only for package @squiz/component-cli-lib
17
+
18
+
19
+
20
+
21
+
6
22
  ## [1.2.1-alpha.68](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.67...v1.2.1-alpha.68) (2022-07-05)
7
23
 
8
24
  **Note:** Version bump only for package @squiz/component-cli-lib
@@ -21,6 +21,7 @@ async function startDevelopmentRender(componentPath, options) {
21
21
  webserver: {
22
22
  port: options.port,
23
23
  rootUrl: `http://localhost:${options.port}`,
24
+ shouldRunMigrations: false,
24
25
  },
25
26
  componentRunner: {
26
27
  // Considering the component path will be passed in from CLI
@@ -1 +1 @@
1
- {"version":3,"file":"component-dev.js","sourceRoot":"","sources":["../src/component-dev.ts"],"names":[],"mappings":";;;;;;AAAA,kEAA8E;AAC9E,gDAAwB;AAExB;;;;;;;;;GASG;AACI,KAAK,UAAU,sBAAsB,CAAC,aAAqB,EAAE,OAAyB;IAC3F,MAAM,IAAA,qCAAgB,EAAC;QACrB,SAAS,EAAE;YACT,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,OAAO,EAAE,oBAAoB,OAAO,CAAC,IAAI,EAAE;SAC5C;QACD,eAAe,EAAE;YACf,4DAA4D;YAC5D,0DAA0D;YAC1D,cAAc,EAAE,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC;YAC1D,WAAW,EAAE,IAAI;YACjB,aAAa,EAAE,KAAM;SACtB;KACF,CAAC,CAAC;IAEH,OAAO,GAAG,EAAE,CAAC,IAAA,oCAAe,GAAE,CAAC;AACjC,CAAC;AAhBD,wDAgBC"}
1
+ {"version":3,"file":"component-dev.js","sourceRoot":"","sources":["../src/component-dev.ts"],"names":[],"mappings":";;;;;;AAAA,kEAA8E;AAC9E,gDAAwB;AAExB;;;;;;;;;GASG;AACI,KAAK,UAAU,sBAAsB,CAAC,aAAqB,EAAE,OAAyB;IAC3F,MAAM,IAAA,qCAAgB,EAAC;QACrB,SAAS,EAAE;YACT,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,OAAO,EAAE,oBAAoB,OAAO,CAAC,IAAI,EAAE;YAC3C,mBAAmB,EAAE,KAAK;SAC3B;QACD,eAAe,EAAE;YACf,4DAA4D;YAC5D,0DAA0D;YAC1D,cAAc,EAAE,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC;YAC1D,WAAW,EAAE,IAAI;YAEjB,aAAa,EAAE,KAAM;SACtB;KACF,CAAC,CAAC;IAEH,OAAO,GAAG,EAAE,CAAC,IAAA,oCAAe,GAAE,CAAC;AACjC,CAAC;AAlBD,wDAkBC"}
@@ -4,55 +4,82 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const path_1 = __importDefault(require("path"));
7
+ const promises_1 = __importDefault(require("fs/promises"));
7
8
  const render_runtime_lib_1 = require("@squiz/render-runtime-lib");
8
9
  const component_dev_1 = require("./component-dev");
10
+ const supertest_1 = __importDefault(require("supertest"));
9
11
  jest.setTimeout(20000);
10
12
  describe('component-dev', () => {
11
- describe('folder structures', () => {
12
- beforeEach(() => {
13
- return (0, render_runtime_lib_1.stopRenderStack)().catch(() => null);
14
- });
15
- afterEach(() => {
16
- return (0, render_runtime_lib_1.stopRenderStack)().catch(() => null);
17
- });
18
- it('handles production style folder structure', async () => {
19
- const { fixtureDirectory, version, componentName } = await render_runtime_lib_1.TestHelpers.ComponentFixture.setupFullComponentDirectory('<h1>Hello World</h1>');
20
- // /fixtures/
21
- const doStopStack = await (0, component_dev_1.startDevelopmentRender)(path_1.default.dirname(fixtureDirectory), { port: 0 });
22
- try {
23
- const testServer = render_runtime_lib_1.TestHelpers.getTestServer();
24
- const response = await testServer.get(`/r/set/${componentName}/${version}/`);
25
- expect(response.text).toEqual('<h1>Hello World</h1>');
26
- }
27
- finally {
28
- await doStopStack();
29
- }
30
- });
31
- it('handles list of versions style folder structure', async () => {
32
- const { fixtureDirectory, version, componentName } = await render_runtime_lib_1.TestHelpers.ComponentFixture.setupFullComponentDirectory('<h1>Hello World</h1>');
33
- // /fixtures/${componentName}/
34
- const doStopStack = await (0, component_dev_1.startDevelopmentRender)(fixtureDirectory, { port: 0 });
35
- try {
36
- const testServer = render_runtime_lib_1.TestHelpers.getTestServer();
37
- const response = await testServer.get(`/r/set/${componentName}/${version}/`);
38
- expect(response.text).toEqual('<h1>Hello World</h1>');
39
- }
40
- finally {
41
- await doStopStack();
42
- }
43
- });
44
- it('handles specific component folder structure', async () => {
45
- const { fixtureDirectory, version, componentName } = await render_runtime_lib_1.TestHelpers.ComponentFixture.setupFullComponentDirectory('<h1>Hello World</h1>');
46
- // /fixtures/${componentName}/${version}/
47
- const doStopStack = await (0, component_dev_1.startDevelopmentRender)(path_1.default.resolve(fixtureDirectory, version), { port: 0 });
48
- try {
49
- const testServer = render_runtime_lib_1.TestHelpers.getTestServer();
50
- const response = await testServer.get(`/r/set/${componentName}/${version}/`);
51
- expect(response.text).toEqual('<h1>Hello World</h1>');
52
- }
53
- finally {
54
- await doStopStack();
55
- }
13
+ describe('production style folder structure', () => {
14
+ let doStopStack;
15
+ beforeAll(async () => {
16
+ doStopStack = await (0, component_dev_1.startDevelopmentRender)(path_1.default.join(__dirname, '../../../test-components'), { port: 0 });
17
+ });
18
+ afterAll(async () => {
19
+ await doStopStack();
20
+ });
21
+ it('should find the component', async () => {
22
+ const testServer = render_runtime_lib_1.TestHelpers.getTestServer();
23
+ const response = await testServer.get(`/r/set/test-component/1.0.0?something=hello`);
24
+ expect(response.text).toEqual('<h1>hello</h1>');
25
+ });
26
+ });
27
+ describe('local developer style folders', () => {
28
+ let doStopStack;
29
+ let version;
30
+ let componentName;
31
+ let fixtureDirectory;
32
+ beforeAll(async () => {
33
+ const { fixtureDirectory: ceratedFixtureDirectory, version: createdVersion, componentName: createdName, } = await render_runtime_lib_1.TestHelpers.ComponentFixture.setupFullComponentDirectory('<h1>Hello World</h1>');
34
+ version = createdVersion;
35
+ fixtureDirectory = ceratedFixtureDirectory;
36
+ componentName = createdName;
37
+ doStopStack = await (0, component_dev_1.startDevelopmentRender)(fixtureDirectory, { port: 0 });
38
+ });
39
+ afterAll(async () => {
40
+ await doStopStack();
41
+ await promises_1.default.rm(path_1.default.join(fixtureDirectory, componentName), { force: true, recursive: true });
42
+ });
43
+ it('should handle recursing folders to find the component', async () => {
44
+ const testServer = render_runtime_lib_1.TestHelpers.getTestServer();
45
+ const response = await testServer.get(`/r/set/${componentName}/${version}/`);
46
+ expect(response.text).toEqual('<h1>Hello World</h1>');
47
+ });
48
+ });
49
+ describe('accessing local dev routes', () => {
50
+ let stopServer;
51
+ const port = 3006;
52
+ const url = `http://localhost:${port}`;
53
+ const request = (0, supertest_1.default)(url);
54
+ beforeAll(async () => {
55
+ const compDir = path_1.default.join(__dirname, '../', '../../test-components');
56
+ stopServer = await (0, component_dev_1.startDevelopmentRender)(compDir, {
57
+ port: port,
58
+ });
59
+ });
60
+ afterAll(async () => {
61
+ await stopServer();
62
+ });
63
+ describe('definition routes', () => {
64
+ render_runtime_lib_1.routeTests.definition(url, url);
65
+ });
66
+ describe('static routes', () => {
67
+ render_runtime_lib_1.routeTests.static(url);
68
+ });
69
+ describe('render routes', () => {
70
+ render_runtime_lib_1.routeTests.render(url, url);
71
+ });
72
+ describe('GET /r/set/test-component/1.0.1', () => {
73
+ //
74
+ // this scenario is different to the 'production' tests
75
+ // this is should 500 in prod and 404 locally
76
+ it('should fail validation if trying to render a component with an invalid schema', async () => {
77
+ const response = await request.get('/r/set/test-component/1.0.1?something=not-used');
78
+ expect(response.statusCode).toEqual(404);
79
+ expect(response.body).toEqual({
80
+ message: 'manifest could not be found',
81
+ });
82
+ });
56
83
  });
57
84
  });
58
85
  });
@@ -1 +1 @@
1
- {"version":3,"file":"component-dev.spec.js","sourceRoot":"","sources":["../src/component-dev.spec.ts"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AAExB,kEAAyE;AACzE,mDAAyD;AAEzD,IAAI,CAAC,UAAU,CAAC,KAAM,CAAC,CAAC;AAC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C,CAAC,CAAC;QAEH,QAAQ,CAAC,KAAK,IAAI,EAAE;YAClB,MAAM,UAAU,EAAE,CAAC;QACrB,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;YACjC,+BAAU,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;YAC7B,+BAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;YAC7B,+BAAU,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;YAC/C,EAAE;YACF,uDAAuD;YACvD,6CAA6C;YAC7C,EAAE,CAAC,+EAA+E,EAAE,KAAK,IAAI,EAAE;gBAC7F,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,gDAAgD,CAAC,CAAC;gBAErF,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBACzC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;oBAC5B,OAAO,EAAE,6BAA6B;iBACvC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
+ export { uploadComponentFolder } from './upload-component-folder';
1
2
  export { startDevelopmentRender } from './component-dev';
2
- export declare function uploadComponentFolder(folderPath: string, componentServiceManagementUrl: string): Promise<void>;
package/lib/index.js CHANGED
@@ -1,92 +1,8 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.uploadComponentFolder = exports.startDevelopmentRender = void 0;
7
- const virus_scanner_lib_1 = require("@squiz/virus-scanner-lib");
8
- const component_lib_1 = require("@squiz/component-lib");
9
- const promises_1 = __importDefault(require("fs/promises"));
10
- const path_1 = __importDefault(require("path"));
11
- const axios_1 = __importDefault(require("axios"));
12
- const cli_color_1 = __importDefault(require("cli-color"));
3
+ exports.startDevelopmentRender = exports.uploadComponentFolder = void 0;
4
+ var upload_component_folder_1 = require("./upload-component-folder");
5
+ Object.defineProperty(exports, "uploadComponentFolder", { enumerable: true, get: function () { return upload_component_folder_1.uploadComponentFolder; } });
13
6
  var component_dev_1 = require("./component-dev");
14
7
  Object.defineProperty(exports, "startDevelopmentRender", { enumerable: true, get: function () { return component_dev_1.startDevelopmentRender; } });
15
- async function uploadComponentFolder(folderPath, componentServiceManagementUrl) {
16
- const tmpDir = path_1.default.resolve(await promises_1.default.mkdtemp('cmp-upload'));
17
- try {
18
- const axiosInstance = axios_1.default.create({
19
- baseURL: componentServiceManagementUrl,
20
- });
21
- console.log('Initial scanning');
22
- const zip = await (0, component_lib_1.zipDirectory)(folderPath, tmpDir);
23
- const initialUpload = await handleResponse(axiosInstance.post('upload-component'));
24
- console.log(`deployment id: ${initialUpload.id} status: transferring`);
25
- await (0, virus_scanner_lib_1.uploadFile)(initialUpload, zip);
26
- await watchAndWaitForUploadAndScanComplete(initialUpload.id, axiosInstance);
27
- console.log(`deployment id: ${initialUpload.id} status: deploying component folder`);
28
- const result = await handleResponse(axiosInstance.post(`upload-component/next/${initialUpload.id}`));
29
- await promises_1.default.rm(tmpDir, { force: true, recursive: true });
30
- if (result.status === 'successful') {
31
- console.log(`deployment id: ${initialUpload.id} status: ${cli_color_1.default.green('success')}`);
32
- console.log(`uploaded location: ${result.accessLink}`);
33
- }
34
- else {
35
- console.error('failed for an unknown reason', cli_color_1.default.red(result));
36
- }
37
- }
38
- catch (e) {
39
- await promises_1.default.rm(tmpDir, { force: true, recursive: true });
40
- if (e instanceof Error) {
41
- console.error(cli_color_1.default.red(e.message));
42
- }
43
- else {
44
- throw e;
45
- }
46
- }
47
- }
48
- exports.uploadComponentFolder = uploadComponentFolder;
49
- async function watchAndWaitForUploadAndScanComplete(id, axiosInstance) {
50
- const poll = () => handleResponse(axiosInstance.get('upload-component/status/' + id));
51
- return new Promise((resolve, reject) => {
52
- const recurse = () => poll().then(async (req) => {
53
- if (req.status == 'Success') {
54
- resolve();
55
- }
56
- else if (req.status == 'Flagged') {
57
- reject(new Error('upload has been flagged as a virus'));
58
- }
59
- else if (req.status == 'Error') {
60
- reject(new Error('there has been an error'));
61
- }
62
- else {
63
- setTimeout(async () => {
64
- await recurse();
65
- }, 1000);
66
- }
67
- });
68
- recurse();
69
- });
70
- }
71
- async function handleResponse(axiosInstance) {
72
- const result = axiosInstance
73
- .then((response) => response.data)
74
- .catch((error) => {
75
- throw handleAxiosError(error);
76
- });
77
- return result;
78
- }
79
- function handleAxiosError(error) {
80
- const { response } = error;
81
- if (!response || (typeof error == 'object' && !error.isAxiosError)) {
82
- return error;
83
- }
84
- const message = response.data.message;
85
- if (message) {
86
- return new Error(`Unexpected response code ${response.status}. message: ${message}`);
87
- }
88
- else {
89
- return new Error(`Unexpected response code ${response.status}.`);
90
- }
91
- }
92
8
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAkE;AAClE,wDAAoD;AACpD,2DAA8B;AAC9B,gDAAwB;AACxB,kDAAwE;AACxE,0DAA8B;AAE9B,iDAAyD;AAAhD,uHAAA,sBAAsB,OAAA;AAExB,KAAK,UAAU,qBAAqB,CAAC,UAAkB,EAAE,6BAAqC;IACnG,MAAM,MAAM,GAAG,cAAI,CAAC,OAAO,CAAC,MAAM,kBAAG,CAA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AwC;IACvE,MAAM,MAAM,GAAG,aAAa;SACzB,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;SACjC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACf,MAAM,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IACL,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAiB;IACzC,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC3B,IAAI,CAAC,QAAQ,IAAI,CAAC,OAAO,KAAK,IAAI,QAAQ,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE;QAClE,OAAO,KAAK,CAAC;KACd;IACD,MAAM,OAAO,GAAI,QAAQ,CAAC,IAAY,CAAC,OAAO,CAAC;IAC/C,IAAI,OAAO,EAAE;QACX,OAAO,IAAI,KAAK,CAAC,4BAA4B,QAAQ,CAAC,MAAM,cAAc,OAAO,EAAE,CAAC,CAAC;KACtF;SAAM;QACL,OAAO,IAAI,KAAK,CAAC,4BAA4B,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;KAClE;AACH,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA;AAC9B,iDAAyD;AAAhD,uHAAA,sBAAsB,OAAA"}
@@ -0,0 +1,32 @@
1
+ {
2
+ "$schema": "http://localhost:3000/schemas/v1.json#",
3
+ "name": "big-package",
4
+ "version": "1.0.2",
5
+ "main-function": "render-json",
6
+ "functions": [
7
+ {
8
+ "name": "render-json",
9
+ "entry": "render-json.js",
10
+ "input": {
11
+ "type": "object",
12
+ "properties": {
13
+ "something": {
14
+ "type": "string"
15
+ }
16
+ },
17
+ "required": ["something"]
18
+ },
19
+ "output": {
20
+ "response-type": "json",
21
+ "definition": {
22
+ "properties": {
23
+ "my-prop": {
24
+ "type": "string"
25
+ }
26
+ },
27
+ "required": ["my-prop"]
28
+ }
29
+ }
30
+ }
31
+ ]
32
+ }
@@ -1,3 +1,5 @@
1
1
  export declare const managementService: import("axios").AxiosInstance;
2
2
  export declare const renderService: import("axios").AxiosInstance;
3
3
  export declare function getTestComponents(): string[];
4
+ export declare function createFile(filePath: string, sizeInMB: number): Promise<void>;
5
+ export declare function removeFile(filePath: string): void;
@@ -3,11 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getTestComponents = exports.renderService = exports.managementService = void 0;
6
+ exports.removeFile = exports.createFile = exports.getTestComponents = exports.renderService = exports.managementService = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const path_1 = __importDefault(require("path"));
10
10
  const config_1 = __importDefault(require("../config"));
11
+ const promises_1 = __importDefault(require("fs/promises"));
12
+ const crypto_1 = require("crypto");
11
13
  exports.managementService = axios_1.default.create({
12
14
  baseURL: config_1.default.managementServiceUrl,
13
15
  });
@@ -27,4 +29,13 @@ function getTestComponents() {
27
29
  return componets;
28
30
  }
29
31
  exports.getTestComponents = getTestComponents;
32
+ async function createFile(filePath, sizeInMB) {
33
+ const content = (0, crypto_1.randomBytes)(sizeInMB * 1000000);
34
+ await promises_1.default.writeFile(`${filePath}`, content);
35
+ }
36
+ exports.createFile = createFile;
37
+ function removeFile(filePath) {
38
+ promises_1.default.unlink(filePath);
39
+ }
40
+ exports.removeFile = removeFile;
30
41
  //# sourceMappingURL=helper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helper.js","sourceRoot":"","sources":["../../src/integration-tests/helper.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,4CAAoB;AACpB,gDAAwB;AACxB,uDAAmC;AAEtB,QAAA,iBAAiB,GAAG,eAAK,CAAC,MA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AI,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;IAC/D,MAAM,KAAK,GAAG,YAAE,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAC5C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,IAAI,GAAG,YAAE,CAAC,QAAQ,CAAC,cAAI,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC;QACzD,IAAI,IAAI,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,EAAE;YACzD,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACtB;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAXD,8CAWC;AACM,KAAK,UAAU,UAAU,CAAC,QAAgB,EAAE,QAAgB;IACjE,MAAM,OAAO,GAAG,IAAA,oBAAW,EAAC,QAAQ,GAAG,OAAO,CAAC,CAAC;IAChD,MAAM,kBAAG,CAAC,SAAS,CAAC,GAAG,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAHD,gCAGC;AAED,SAAgB,UAAU,CAAC,QAAgB;IACzC,kBAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACvB,CAAC;AAFD,gCAEC"}
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
- jest.setTimeout(30000);
2
+ jest.setTimeout(60000);
3
3
  //# sourceMappingURL=test-setup.js.map
@@ -15,10 +15,15 @@ const orgConsoleError = console.error;
15
15
  afterAll(async () => {
16
16
  // clean up the component added by the test
17
17
  (0, helper_1.getTestComponents)().forEach(async (componentName) => {
18
- await helper_1.managementService.delete(`/component/${componentName}`);
18
+ try {
19
+ await helper_1.managementService.delete(`/component/${componentName}`);
20
+ }
21
+ catch {
22
+ // no op
23
+ }
19
24
  });
20
25
  });
21
- describe('Deploy basic component having a static file', () => {
26
+ describe('Test isolated test cases', () => {
22
27
  beforeEach(() => {
23
28
  console.error = mockConsoleError;
24
29
  console.log = mockConsoleLog;
@@ -26,25 +31,47 @@ describe('Deploy basic component having a static file', () => {
26
31
  afterEach(() => {
27
32
  console.error = orgConsoleError;
28
33
  });
34
+ it('Should fail uploading the component that has size more than 100MB', async () => {
35
+ const componentPath = path_1.default.join(__dirname, '/__components__/big-package');
36
+ const filePath = `${componentPath}/105mb-file`;
37
+ await (0, helper_1.createFile)(filePath, 105); // Higher limit has been used because compression reduces the size if you use closer to 100MB
38
+ await (0, index_1.uploadComponentFolder)(componentPath, config_1.default.managementServiceUrl);
39
+ expect(mockConsoleError.mock.calls[0][0]).toEqual(cli_color_1.default.red(['Request body larger than maxBodyLength limit'].join('')));
40
+ (0, helper_1.removeFile)(filePath);
41
+ });
42
+ });
43
+ describe('Deploy basic component having a static file', () => {
29
44
  // component to deploy for this test
30
45
  const componentPath = path_1.default.join(__dirname, '/__components__/cmp-static-file-test');
31
- let url = '';
46
+ beforeAll(async () => {
47
+ try {
48
+ await helper_1.managementService.delete(`/component/cmp-static-file-test`);
49
+ }
50
+ catch {
51
+ // no op
52
+ }
53
+ });
54
+ beforeEach(() => {
55
+ console.error = mockConsoleError;
56
+ console.log = mockConsoleLog;
57
+ });
58
+ afterEach(() => {
59
+ console.error = orgConsoleError;
60
+ });
32
61
  it('Should upload the component and return a valid url to preview', async () => {
33
62
  var _a, _b;
34
63
  mockConsoleLog.mockClear();
35
64
  await (0, index_1.uploadComponentFolder)(componentPath, config_1.default.managementServiceUrl);
36
- url = ((_a = /uploaded location: (.*)/.exec(mockConsoleLog.mock.lastCall)) === null || _a === void 0 ? void 0 : _a[1]) || '';
65
+ const url = ((_a = /uploaded location: (.*)/.exec(mockConsoleLog.mock.lastCall)) === null || _a === void 0 ? void 0 : _a[1]) || '';
37
66
  const uploadedComponent = '<a href="/r/set/cmp-static-file-test/1.0.0">1.0.0</a>';
38
- const get = await (0, supertest_1.default)(url).get('');
67
+ const get = await (0, supertest_1.default)(url).get('/');
39
68
  expect(get.status).toEqual(200);
40
69
  expect((_b = get === null || get === void 0 ? void 0 : get.res) === null || _b === void 0 ? void 0 : _b.text).toContain(uploadedComponent);
41
70
  });
42
71
  it('Should fail upload the component with same version', async () => {
72
+ mockConsoleError.mockClear();
43
73
  await (0, index_1.uploadComponentFolder)(componentPath, config_1.default.managementServiceUrl);
44
- expect(mockConsoleError.mock.calls[0][0]).toEqual(cli_color_1.default.red([
45
- 'Unexpected response code 400. message: ',
46
- 'cmp-static-file-test version 1.0.0 already exists and cannot be uploaded',
47
- ].join('')));
74
+ expect(mockConsoleError.mock.calls[0][0]).toEqual(cli_color_1.default.red('Unexpected response code 400. message: Component cmp-static-file-test 1.0.0 already exists'));
48
75
  });
49
76
  it('Should render component', async () => {
50
77
  const response = await helper_1.renderService.get('/r/set/cmp-static-file-test/1.0.0/?something=hello');
@@ -1 +1 @@
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,qCAA+E;AAC/E,uDAAmC;AACnC,0DAA8B;AAC9B,gDAAwB;AACxB,0DAAkC;AAElC,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;AAEtC,QAAQ,CAAC,KAAK,IAAI,EAAE;IAClB,2CAA2C;IAC3C,IAAA,0BAAiB,GAAE,CAAC,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;QAClD,MAAM,0BAAiB,CAAC,MAAM,CAAC,cAAc,aAAa,EAAE,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,6CAA6C,EAAE,GAAG,EAAE;IAC3D,UAAU,CAAC,GAAG,EAAE;QACd,OAAO,CAAC,KAAK,GAAG,gB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AG,CACP;YACE,yCAAyC;YACzC,0EAA0E;SAC3E,CAAC,IAAI,CAAC,EAAE,CAAC,CACX,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yBAAyB,EAAE,KAAK,IAAI,EAAE;QACvC,MAAM,QAAQ,GAAG,MAAM,sBAAa,CAAC,GAAG,CAAC,oDAAoD,CAAC,CAAC;QAC/F,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,kCAAkC;YAClC,GAAG,gBAAU,CAAC,gBAAgB,uDAAuD;SACtF,CAAC,IAAI,CAAC,EAAE,CAAC,CACX,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
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,qCAAuG;AACvG,uDAAmC;AACnC,0DAA8B;AAC9B,gDAAwB;AACxB,0DAAkC;AAElC,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;AAEtC,QAAQ,CAAC,KAAK,IAAI,EAAE;IAClB,2CAA2C;IAC3C,IAAA,0BAAiB,GAAE,CAAC,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;QAClD,IAAI;YACF,MAAM,0BAAiB,CAAC,MAAM,CAAC,cAAc,aAAa,EAAE,CAAC,CAAC;SAC/D;QAAC,MAAM;YACN,QAAQ;SACT;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;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,yBAAyB,EAAE,KAAK,IAAI,EAAE;QACvC,MAAM,QAAQ,GAAG,MAAM,sBAAa,CAAC,GAAG,CAAC,oDAAoD,CAAC,CAAC;QAC/F,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,kCAAkC;YAClC,GAAG,gBAAU,CAAC,gBAAgB,uDAAuD;SACtF,CAAC,IAAI,CAAC,EAAE,CAAC,CACX,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/lib/test.js CHANGED
@@ -1,13 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const _1 = require(".");
7
- const config_1 = __importDefault(require("./config"));
8
- const path_1 = __importDefault(require("path"));
9
- const dir = path_1.default.resolve(process.argv[2]);
10
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
11
- const componentManagementURL = config_1.default.managementServiceUrl || process.argv[3];
12
- (0, _1.uploadComponentFolder)(dir, componentManagementURL);
3
+ const component_dev_1 = require("./component-dev");
4
+ (0, component_dev_1.startDevelopmentRender)('/Users/wfagerstrom/Code/component-service/test-components', { port: 3000 }).then(() => {
5
+ console.log('starting');
6
+ });
13
7
  //# sourceMappingURL=test.js.map
package/lib/test.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":";;;;;AAAA,wBAA0C;AAC1C,sDAAkC;AAClC,gDAAwB;AAExB,MAAM,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1C,oEAAoE;AACpE,MAAM,sBAAsB,GAAG,gBAAU,CAAC,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClF,IAAA,wBAAqB,EAAC,GAAG,EAAE,sBAAsB,CAAC,CAAC"}
1
+ {"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":";;AAAA,mDAAyD;AAEzD,IAAA,sCAAsB,EAAC,2DAA2D,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;IAC5G,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AAC1B,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function uploadComponentFolder(folderPath: string, componentServiceManagementUrl: string): Promise<void>;