@squiz/component-cli-lib 1.2.1-alpha.99 → 1.2.3
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/.gitlab-ci.yml +42 -27
- package/CHANGELOG.md +88 -0
- package/jest.config.ts +3 -0
- package/jest.integration.config.ts +4 -0
- package/lib/component-dev-folder-structures.spec.d.ts +1 -0
- package/lib/component-dev-folder-structures.spec.js +58 -0
- package/lib/component-dev-folder-structures.spec.js.map +1 -0
- package/lib/component-dev.d.ts +4 -1
- package/lib/component-dev.js +24 -18
- package/lib/component-dev.js.map +1 -1
- package/lib/component-dev.spec.js +28 -65
- package/lib/component-dev.spec.js.map +1 -1
- package/lib/integration-tests/__components__/big-package/manifest.json +5 -2
- package/lib/integration-tests/__components__/cmp-static-file-test/manifest.json +8 -5
- package/lib/integration-tests/__components__/invalid-manifest/manifest.json +5 -2
- package/lib/integration-tests/helper.d.ts +6 -0
- package/lib/integration-tests/helper.js +31 -6
- package/lib/integration-tests/helper.js.map +1 -1
- package/lib/integration-tests/service-deployment.spec.js +36 -1
- package/lib/integration-tests/service-deployment.spec.js.map +1 -1
- package/lib/integration-tests/upload-and-render-component.spec.js +38 -17
- package/lib/integration-tests/upload-and-render-component.spec.js.map +1 -1
- package/lib/upload-component-folder.d.ts +1 -1
- package/lib/upload-component-folder.js +10 -6
- package/lib/upload-component-folder.js.map +1 -1
- package/package.json +10 -10
- package/src/component-dev-folder-structures.spec.ts +69 -0
- package/src/component-dev.spec.ts +31 -83
- package/src/component-dev.ts +40 -18
- package/src/integration-tests/__components__/big-package/manifest.json +5 -2
- package/src/integration-tests/__components__/cmp-static-file-test/manifest.json +8 -6
- package/src/integration-tests/__components__/invalid-manifest/manifest.json +5 -2
- package/src/integration-tests/helper.ts +28 -1
- package/src/integration-tests/service-deployment.spec.ts +51 -2
- package/src/integration-tests/upload-and-render-component.spec.ts +78 -17
- package/src/upload-component-folder.ts +16 -7
- package/tsconfig.tsbuildinfo +1 -1
package/.gitlab-ci.yml
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
.rules:when-production:
|
|
4
|
+
rules:
|
|
5
|
+
- if: $CI_DEPLOY_TO_PROD && $CI_COMMIT_REF_NAME == $TARGET_BRANCH_PRODUCTION
|
|
6
|
+
when: on_success
|
|
7
|
+
|
|
3
8
|
.rules:when-uat:
|
|
4
9
|
rules:
|
|
5
|
-
- if: $CI_COMMIT_REF_NAME == $TARGET_BRANCH_UAT
|
|
10
|
+
- if: $CI_COMMIT_REF_NAME == $TARGET_BRANCH_UAT && $CI_DEPLOY_TO_PROD == null
|
|
6
11
|
when: on_success
|
|
7
|
-
- when: never
|
|
8
12
|
|
|
9
13
|
.rules:when-development:
|
|
10
14
|
rules:
|
|
11
|
-
- if: $CI_COMMIT_REF_NAME == $TARGET_BRANCH_DEVELOPMENT
|
|
15
|
+
- if: $CI_COMMIT_REF_NAME == $TARGET_BRANCH_DEVELOPMENT && $CI_DEPLOY_TO_PROD == null
|
|
12
16
|
when: on_success
|
|
13
|
-
- when: never
|
|
14
17
|
|
|
15
18
|
.rules:when-other-branch:
|
|
16
19
|
rules:
|
|
17
|
-
- if: $CI_COMMIT_REF_NAME != $TARGET_BRANCH_DEVELOPMENT && $CI_COMMIT_REF_NAME != $TARGET_BRANCH_UAT
|
|
20
|
+
- if: $CI_COMMIT_REF_NAME != $TARGET_BRANCH_DEVELOPMENT && $CI_COMMIT_REF_NAME != $TARGET_BRANCH_UAT && $CI_COMMIT_REF_NAME != $TARGET_BRANCH_PRODUCTION && $CI_DEPLOY_TO_PROD == null
|
|
18
21
|
when: on_success
|
|
19
|
-
- when: never
|
|
20
22
|
|
|
21
23
|
.get-service-urls:
|
|
22
24
|
stage: smoke-test-setup
|
|
@@ -45,26 +47,39 @@
|
|
|
45
47
|
exit 1;
|
|
46
48
|
}
|
|
47
49
|
echo "✔︎"
|
|
50
|
+
- |2
|
|
51
|
+
echo -n "Getting 'CONTENT_API_URL' from CloudFormation stack: 'dx-${DEPLOYMENT_LABEL}-cmp' output: 'contentServiceURL'... "
|
|
52
|
+
CONTENT_API_URL="$(aws --region $AWS_REGION cloudformation describe-stacks --stack-name dx-${DEPLOYMENT_LABEL}-cmp --max-items 1 --query "Stacks[].Outputs[?contains(OutputKey,'contentServiceURL')].OutputValue" --output text)"
|
|
53
|
+
[[ $CONTENT_API_URL ]] || {
|
|
54
|
+
echo "✘";
|
|
55
|
+
echo "CONTENT_API_URL is empty or unset";
|
|
56
|
+
exit 1;
|
|
57
|
+
}
|
|
58
|
+
echo "✔︎"
|
|
48
59
|
- echo "COMPONENT_MANAGEMENT_SERVICE_URL=${COMPONENT_MANAGEMENT_SERVICE_URL}" >> dot.env
|
|
49
60
|
- echo "COMPONENT_RENDER_SERVICE_URL=${COMPONENT_RENDER_SERVICE_URL}" >> dot.env
|
|
61
|
+
- echo "CONTENT_API_URL=${CONTENT_API_URL}" >> dot.env
|
|
50
62
|
- >2
|
|
51
63
|
echo "COMPONENT_MANAGEMENT_SERVICE_URL now has value: '${COMPONENT_MANAGEMENT_SERVICE_URL}'
|
|
52
64
|
and will be inherited by other jobs via \"dotenv\" artifact"
|
|
53
65
|
- >2
|
|
54
66
|
echo "COMPONENT_RENDER_SERVICE_URL now has value: '${COMPONENT_RENDER_SERVICE_URL}'
|
|
55
67
|
and will be inherited by other jobs via \"dotenv\" artifact"
|
|
68
|
+
- >2
|
|
69
|
+
echo "CONTENT_API_URL now has value: '${CONTENT_API_URL}'
|
|
70
|
+
and will be inherited by other jobs via \"dotenv\" artifact"
|
|
56
71
|
artifacts:
|
|
57
72
|
reports:
|
|
58
73
|
dotenv: dot.env
|
|
59
74
|
|
|
60
|
-
smoke-test:
|
|
75
|
+
.smoke-test:
|
|
61
76
|
stage: smoke-test
|
|
62
77
|
tags:
|
|
63
78
|
- size/l
|
|
64
79
|
script:
|
|
65
80
|
- export
|
|
66
|
-
- npm
|
|
67
|
-
- npm run bootstrap
|
|
81
|
+
- npm ci
|
|
82
|
+
- npm run bootstrap -- --ci
|
|
68
83
|
- npm run clean
|
|
69
84
|
- npm run lint
|
|
70
85
|
- npm run format-code
|
|
@@ -77,13 +92,24 @@ smoke-test:
|
|
|
77
92
|
- runner_system_failure
|
|
78
93
|
- stuck_or_timeout_failure
|
|
79
94
|
|
|
80
|
-
|
|
95
|
+
smoke-test:development:
|
|
81
96
|
extends:
|
|
82
|
-
- .
|
|
83
|
-
- .
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
97
|
+
- .smoke-test
|
|
98
|
+
- .rules:when-development
|
|
99
|
+
|
|
100
|
+
smoke-test:uat:
|
|
101
|
+
extends:
|
|
102
|
+
- .smoke-test
|
|
103
|
+
- .rules:when-uat
|
|
104
|
+
|
|
105
|
+
# TODO: Do we need this running for feature branches?
|
|
106
|
+
# get-branch-service-urls:
|
|
107
|
+
# extends:
|
|
108
|
+
# - .rules:when-other-branch
|
|
109
|
+
# - .get-service-urls
|
|
110
|
+
# environment:
|
|
111
|
+
# name: non-production-development
|
|
112
|
+
# url: components.dev.dx.squiz.cloud
|
|
87
113
|
|
|
88
114
|
get-development-service-urls:
|
|
89
115
|
extends:
|
|
@@ -100,14 +126,3 @@ get-uat-service-urls:
|
|
|
100
126
|
environment:
|
|
101
127
|
name: non-production-development
|
|
102
128
|
url: components.dev.dx.squiz.cloud
|
|
103
|
-
|
|
104
|
-
get-production-service-urls:
|
|
105
|
-
extends:
|
|
106
|
-
- .get-service-urls
|
|
107
|
-
environment:
|
|
108
|
-
name: production
|
|
109
|
-
url: components.prod.dx.squiz.cloud
|
|
110
|
-
rules:
|
|
111
|
-
- if: $CI_DEPLOY_TO_PROD && $CI_COMMIT_REF_NAME == $TARGET_BRANCH_PRODUCTION
|
|
112
|
-
when: manual
|
|
113
|
-
- when: never
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,94 @@
|
|
|
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.3](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.2...v1.2.3) (2022-10-10)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @squiz/component-cli-lib
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [1.2.2](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1...v1.2.2) (2022-09-26)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @squiz/component-cli-lib
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [1.2.1](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1) (2022-09-23)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @squiz/component-cli-lib
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [1.2.1-alpha.107](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.107) (2022-09-21)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @squiz/component-cli-lib
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## [1.2.1-alpha.106](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.106) (2022-09-02)
|
|
39
|
+
|
|
40
|
+
**Note:** Version bump only for package @squiz/component-cli-lib
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## [1.2.1-alpha.105](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.105) (2022-08-26)
|
|
47
|
+
|
|
48
|
+
**Note:** Version bump only for package @squiz/component-cli-lib
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## [1.2.1-alpha.104](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.104) (2022-08-23)
|
|
55
|
+
|
|
56
|
+
**Note:** Version bump only for package @squiz/component-cli-lib
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## [1.2.1-alpha.103](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.103) (2022-08-23)
|
|
63
|
+
|
|
64
|
+
**Note:** Version bump only for package @squiz/component-cli-lib
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## [1.2.1-alpha.102](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.102) (2022-08-23)
|
|
71
|
+
|
|
72
|
+
**Note:** Version bump only for package @squiz/component-cli-lib
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
## [1.2.1-alpha.101](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.101) (2022-08-19)
|
|
79
|
+
|
|
80
|
+
**Note:** Version bump only for package @squiz/component-cli-lib
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
## [1.2.1-alpha.100](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.100) (2022-08-18)
|
|
87
|
+
|
|
88
|
+
**Note:** Version bump only for package @squiz/component-cli-lib
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
6
94
|
## [1.2.1-alpha.99](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.99) (2022-08-18)
|
|
7
95
|
|
|
8
96
|
**Note:** Version bump only for package @squiz/component-cli-lib
|
package/jest.config.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
1
2
|
import type { Config } from 'jest';
|
|
2
3
|
|
|
4
|
+
process.env.CI_COMMIT_SHORT_SHA ??= execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }).trim();
|
|
5
|
+
process.env.CI_COMMIT_REF_NAME ??= execSync('git branch --show-current', { encoding: 'utf-8' }).trim();
|
|
6
|
+
|
|
3
7
|
// Sync object
|
|
4
8
|
const config: Config = {
|
|
5
9
|
preset: 'ts-jest',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
const supertest_1 = __importDefault(require("supertest"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
|
+
const render_runtime_lib_1 = require("@squiz/render-runtime-lib");
|
|
10
|
+
const component_dev_1 = require("./component-dev");
|
|
11
|
+
jest.setTimeout(20000);
|
|
12
|
+
describe('component-dev', () => {
|
|
13
|
+
describe('production style folder structure', () => {
|
|
14
|
+
let server;
|
|
15
|
+
let request;
|
|
16
|
+
beforeAll(async () => {
|
|
17
|
+
server = (0, component_dev_1.startDevelopmentRender)(render_runtime_lib_1.TestHelpers.getTestComponentFolder(), { port: 0 });
|
|
18
|
+
request = (0, supertest_1.default)(server);
|
|
19
|
+
});
|
|
20
|
+
afterAll(async () => {
|
|
21
|
+
server.close();
|
|
22
|
+
});
|
|
23
|
+
it('should find the component', async () => {
|
|
24
|
+
const response = await request.get(`/r/set/unit-test-components/test-component/1.0.0?something=hello`);
|
|
25
|
+
expect(response.text).toEqual('<h1>hello</h1>');
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
describe('local developer style folders', () => {
|
|
29
|
+
let version;
|
|
30
|
+
let componentName;
|
|
31
|
+
let fixtureDirectory;
|
|
32
|
+
let server;
|
|
33
|
+
let request;
|
|
34
|
+
beforeAll(async () => {
|
|
35
|
+
const { fixtureDirectory: createdFixtureDirectory, version: createdVersion, componentName: createdName, } = await render_runtime_lib_1.TestHelpers.ComponentFixture.setupFullComponentDirectory('<h1>Hello World</h1>');
|
|
36
|
+
version = createdVersion;
|
|
37
|
+
fixtureDirectory = createdFixtureDirectory;
|
|
38
|
+
componentName = createdName;
|
|
39
|
+
server = (0, component_dev_1.startDevelopmentRender)(fixtureDirectory, { port: 0 });
|
|
40
|
+
request = (0, supertest_1.default)(server);
|
|
41
|
+
});
|
|
42
|
+
afterAll(async () => {
|
|
43
|
+
server.close();
|
|
44
|
+
});
|
|
45
|
+
afterAll(async () => {
|
|
46
|
+
await promises_1.default.rm(path_1.default.join(fixtureDirectory, componentName), { force: true, recursive: true });
|
|
47
|
+
});
|
|
48
|
+
it('should handle recursing folders to find the component', async () => {
|
|
49
|
+
const response = await request.get(`/r/set/some-namespace/${componentName}/${version}/`);
|
|
50
|
+
expect(response.text).toEqual('<h1>Hello World</h1>');
|
|
51
|
+
});
|
|
52
|
+
it('should handle serving static files from single component directory', async () => {
|
|
53
|
+
const response = await request.get(`/s/some-namespace/${componentName}/${version}/static.txt`);
|
|
54
|
+
expect(response.text).toEqual('hello');
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=component-dev-folder-structures.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-dev-folder-structures.spec.js","sourceRoot":"","sources":["../src/component-dev-folder-structures.spec.ts"],"names":[],"mappings":";;;;;AAAA,0DAAkC;AAClC,gDAA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z/dx-logger-lib';
|
|
1
3
|
/**
|
|
2
4
|
* startDevelopmentRender starts a dev-mode render stack for any
|
|
3
5
|
* local directory. This should start an express server on a random unused port
|
|
@@ -10,4 +12,5 @@
|
|
|
10
12
|
export declare function startDevelopmentRender(componentPath: string, options: {
|
|
11
13
|
port: number;
|
|
12
14
|
previewFile?: string;
|
|
13
|
-
|
|
15
|
+
loggingFormat?: LoggerOptions['format'];
|
|
16
|
+
}): import("http").Server;
|
package/lib/component-dev.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.startDevelopmentRender = void 0;
|
|
|
7
7
|
const render_runtime_lib_1 = require("@squiz/render-runtime-lib");
|
|
8
8
|
const dx_logger_lib_1 = require("@squiz/dx-logger-lib");
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const component_lib_1 = require("@squiz/component-lib");
|
|
10
11
|
/**
|
|
11
12
|
* startDevelopmentRender starts a dev-mode render stack for any
|
|
12
13
|
* local directory. This should start an express server on a random unused port
|
|
@@ -16,25 +17,30 @@ const path_1 = __importDefault(require("path"));
|
|
|
16
17
|
* @param {object} options - Additional configuration for the dev stack
|
|
17
18
|
* @returns a function to stop the render stack
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
-
const logger = (0, dx_logger_lib_1.getLogger)({ name: 'component-dev', format: 'human' });
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
function startDevelopmentRender(componentPath, options) {
|
|
21
|
+
const logger = (0, dx_logger_lib_1.getLogger)({ name: 'component-dev', format: options.loggingFormat || 'human' });
|
|
22
|
+
const rootUrl = `http://localhost:${options.port}`;
|
|
23
|
+
const dataMountPoint = path_1.default.resolve(process.cwd(), componentPath);
|
|
24
|
+
const componentRunnerService = new render_runtime_lib_1.ComponentRunnerServiceWithWorkers({
|
|
25
|
+
dataMountPoint,
|
|
26
|
+
shouldCacheResponses: false,
|
|
27
|
+
workerTimeout: 5000,
|
|
28
|
+
}, logger);
|
|
29
|
+
const webServer = (0, render_runtime_lib_1.setupRenderRuntimeServer)({
|
|
30
|
+
logger,
|
|
31
|
+
componentRunnerService,
|
|
32
|
+
componentSetService: new component_lib_1.ComponentSetServiceForLocalDev(logger),
|
|
33
|
+
componentFunctionService: new component_lib_1.ComponentFunctionService(rootUrl),
|
|
34
|
+
componentPreviewService: new render_runtime_lib_1.ComponentPreviewService(options.previewFile),
|
|
35
|
+
manifestService: new component_lib_1.ManifestServiceForDev(dataMountPoint, logger),
|
|
36
|
+
}, { rootUrl });
|
|
37
|
+
const server = webServer.listen(options.port, () => {
|
|
38
|
+
logger.info(`Component development webserver started on port ${options.port}`);
|
|
36
39
|
});
|
|
37
|
-
|
|
40
|
+
server.on('close', async () => {
|
|
41
|
+
await componentRunnerService.stop();
|
|
42
|
+
});
|
|
43
|
+
return server;
|
|
38
44
|
}
|
|
39
45
|
exports.startDevelopmentRender = startDevelopmentRender;
|
|
40
46
|
//# sourceMappingURL=component-dev.js.map
|
package/lib/component-dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-dev.js","sourceRoot":"","sources":["../src/component-dev.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"component-dev.js","sourceRoot":"","sources":["../src/component-dev.ts"],"names":[],"mappings":";;;;;;AAAA,kEAImC;AACnC,wDAAgE;AAChE,gDAAwB;AACxB,wDAAuH;AAEvH;;;;;;;;GAQG;AACH,SAAgB,sBAAsB,CACpC,aAAqB,EACrB,OAAwF;IAExF,MAAM,MAAM,GAAG,IAAA,yBAAS,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC,aAAa,IAAI,OAAO,EAAE,CAAC,CAAC;IAC9F,MAAM,OAAO,GAAG,oBAAoB,OAAO,CAAC,IAAI,EAAE,CAAC;IACnD,MAAM,cAAc,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC,CAAC;IAElE,MAAM,sBAAsB,GAAG,IAAI,sDAAiC,CAClE;QACE,cAAc;QACd,oBAAoB,EAAE,KAAK;QAC3B,aAAa,EAAE,IAAK;KACrB,EACD,MAAM,CACP,CAAC;IACF,MAAM,SAAS,GAAG,IAAA,6CAAwB,EACxC;QACE,MAAM;QACN,sBAAsB;QACtB,mBAAmB,EAAE,IAAI,8CAA8B,CAAC,MAAM,CAAC;QAC/D,wBAAwB,EAAE,IAAI,wCAAwB,CAAC,OAAO,CAAC;QAC/D,uBAAuB,EAAE,IAAI,4CAAuB,CAAC,OAAO,CAAC,WAAW,CAAC;QACzE,eAAe,EAAE,IAAI,qCAAqB,CAAC,cAAc,EAAE,MAAM,CAAC;KACnE,EACD,EAAE,OAAO,EAAE,CACZ,CAAC;IAEF,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE;QACjD,MAAM,CAAC,IAAI,CAAC,mDAAmD,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACjF,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;QAC5B,MAAM,sBAAsB,CAAC,IAAI,EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AArCD,wDAqCC"}
|
|
@@ -3,87 +3,50 @@ 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
|
-
const path_1 = __importDefault(require("path"));
|
|
7
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
6
|
const render_runtime_lib_1 = require("@squiz/render-runtime-lib");
|
|
9
7
|
const component_dev_1 = require("./component-dev");
|
|
10
8
|
const supertest_1 = __importDefault(require("supertest"));
|
|
11
9
|
jest.setTimeout(20000);
|
|
12
10
|
describe('component-dev', () => {
|
|
13
|
-
describe('
|
|
14
|
-
let
|
|
15
|
-
|
|
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;
|
|
11
|
+
describe('accessing local dev routes', () => {
|
|
12
|
+
let server;
|
|
13
|
+
let request;
|
|
32
14
|
beforeAll(async () => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
fixtureDirectory = ceratedFixtureDirectory;
|
|
36
|
-
componentName = createdName;
|
|
37
|
-
doStopStack = await (0, component_dev_1.startDevelopmentRender)(fixtureDirectory, { port: 0 });
|
|
15
|
+
server = (0, component_dev_1.startDevelopmentRender)(render_runtime_lib_1.TestHelpers.getTestComponentFolder(), { port: 0 });
|
|
16
|
+
request = (0, supertest_1.default)(server);
|
|
38
17
|
});
|
|
39
18
|
afterAll(async () => {
|
|
40
|
-
|
|
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
|
-
it('should handle serving static files from single component directory', async () => {
|
|
49
|
-
const testServer = render_runtime_lib_1.TestHelpers.getTestServer();
|
|
50
|
-
const response = await testServer.get(`/s/${componentName}/${version}/static.txt`);
|
|
51
|
-
expect(response.text).toEqual('hello');
|
|
19
|
+
server.close();
|
|
52
20
|
});
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const url = `http://localhost:${port}`;
|
|
58
|
-
const request = (0, supertest_1.default)(url);
|
|
59
|
-
beforeAll(async () => {
|
|
60
|
-
const compDir = path_1.default.join(__dirname, '../', '../../test-components');
|
|
61
|
-
stopServer = await (0, component_dev_1.startDevelopmentRender)(compDir, {
|
|
62
|
-
port: port,
|
|
21
|
+
it('should fail validation when requesting a function with a missing entry file', async () => {
|
|
22
|
+
const response = await request.get('/r/set/unit-test-components/test-component/1.0.3/non-existent-entry-file?something=not-used');
|
|
23
|
+
expect(response.body).toEqual({
|
|
24
|
+
message: '"main\'s" entry file "missing-entry-file.js" is inaccessible',
|
|
63
25
|
});
|
|
64
|
-
|
|
65
|
-
afterAll(async () => {
|
|
66
|
-
await stopServer();
|
|
26
|
+
expect(response.statusCode).toEqual(500);
|
|
67
27
|
});
|
|
68
28
|
describe('definition routes', () => {
|
|
69
|
-
render_runtime_lib_1.
|
|
29
|
+
const server = (0, component_dev_1.startDevelopmentRender)(render_runtime_lib_1.TestHelpers.getTestComponentFolder(), { port: 0 });
|
|
30
|
+
const request = () => (0, supertest_1.default)(server);
|
|
31
|
+
render_runtime_lib_1.routeTests.definition(request, 'http://localhost:0');
|
|
32
|
+
afterAll(() => {
|
|
33
|
+
server.close();
|
|
34
|
+
});
|
|
70
35
|
});
|
|
71
36
|
describe('static routes', () => {
|
|
72
|
-
render_runtime_lib_1.
|
|
37
|
+
const server = (0, component_dev_1.startDevelopmentRender)(render_runtime_lib_1.TestHelpers.getTestComponentFolder(), { port: 0 });
|
|
38
|
+
const request = () => (0, supertest_1.default)(server);
|
|
39
|
+
render_runtime_lib_1.routeTests.static(request);
|
|
40
|
+
afterAll(() => {
|
|
41
|
+
server.close();
|
|
42
|
+
});
|
|
73
43
|
});
|
|
74
44
|
describe('render routes', () => {
|
|
75
|
-
render_runtime_lib_1.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// this is should 500 in prod and 404 locally
|
|
81
|
-
it('should fail validation if trying to render a component with an invalid schema', async () => {
|
|
82
|
-
const response = await request.get('/r/set/test-component/1.0.1?something=not-used');
|
|
83
|
-
expect(response.statusCode).toEqual(404);
|
|
84
|
-
expect(response.body).toEqual({
|
|
85
|
-
message: 'manifest could not be found',
|
|
86
|
-
});
|
|
45
|
+
const server = (0, component_dev_1.startDevelopmentRender)(render_runtime_lib_1.TestHelpers.getTestComponentFolder(), { port: 0 });
|
|
46
|
+
const request = () => (0, supertest_1.default)(server);
|
|
47
|
+
render_runtime_lib_1.routeTests.render(request, 'http://localhost:0');
|
|
48
|
+
afterAll(() => {
|
|
49
|
+
server.close();
|
|
87
50
|
});
|
|
88
51
|
});
|
|
89
52
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-dev.spec.js","sourceRoot":"","sources":["../src/component-dev.spec.ts"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"component-dev.spec.js","sourceRoot":"","sources":["../src/component-dev.spec.ts"],"names":[],"mappings":";;;;;AAAA,kEAAoE;AACpE,mDAAyD;AACzD,0DAAkC;AAGlC,IAAI,CAAC,UAAU,CAAC,KAAM,CAAC,CAAC;AAExB,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;QAC1C,IAAI,MAAc,CAAC;QACnB,IAAI,OAA4C,CAA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AAE,CAAC,EAAE,CAAC,CAAC;YACzF,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,IAAA,mBAAS,EAAC,MAAM,CAAC,CAAC;YACxC,+BAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC3B,QAAQ,CAAC,GAAG,EAAE;gBACZ,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;YAC7B,MAAM,MAAM,GAAG,IAAA,sCAAsB,EAAC,gCAAW,CAAC,sBAAsB,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;YACzF,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,IAAA,mBAAS,EAAC,MAAM,CAAC,CAAC;YACxC,+BAAU,CAAC,MAAM,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;YACjD,QAAQ,CAAC,GAAG,EAAE;gBACZ,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
"$schema": "http://localhost:3000/schemas/v1.json#",
|
|
3
3
|
"name": "big-package",
|
|
4
4
|
"version": "1.0.2",
|
|
5
|
-
"
|
|
5
|
+
"mainFunction": "render-json",
|
|
6
|
+
"namespace": "smoke-test-components",
|
|
7
|
+
"displayName": "some-displayName",
|
|
8
|
+
"description": "some-description",
|
|
6
9
|
"functions": [
|
|
7
10
|
{
|
|
8
11
|
"name": "render-json",
|
|
@@ -17,7 +20,7 @@
|
|
|
17
20
|
"required": ["something"]
|
|
18
21
|
},
|
|
19
22
|
"output": {
|
|
20
|
-
"
|
|
23
|
+
"responseType": "json",
|
|
21
24
|
"definition": {
|
|
22
25
|
"properties": {
|
|
23
26
|
"my-prop": {
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
"$schema": "http://localhost:3000/schemas/v1.json#",
|
|
3
3
|
"name": "cmp-static-file-test",
|
|
4
4
|
"version": "1.0.0",
|
|
5
|
-
"
|
|
5
|
+
"mainFunction": "main",
|
|
6
|
+
"namespace": "smoke-test-components",
|
|
7
|
+
"displayName": "some-displayName",
|
|
8
|
+
"description": "some-description",
|
|
6
9
|
"functions": [
|
|
7
10
|
{
|
|
8
11
|
"entry": "main.js",
|
|
@@ -17,8 +20,8 @@
|
|
|
17
20
|
"required": ["something"]
|
|
18
21
|
},
|
|
19
22
|
"output": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
23
|
+
"responseType": "html",
|
|
24
|
+
"staticFiles": [
|
|
22
25
|
{
|
|
23
26
|
"location": "header",
|
|
24
27
|
"file": {
|
|
@@ -30,7 +33,7 @@
|
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
35
|
],
|
|
33
|
-
"
|
|
34
|
-
"
|
|
36
|
+
"staticFiles": {
|
|
37
|
+
"locationRoot": "public"
|
|
35
38
|
}
|
|
36
39
|
}
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
"$schema": "http://localhost:3000/schemas/v1.json#",
|
|
3
3
|
"name": "invalid-manifes@t",
|
|
4
4
|
"version": "1.0.0",
|
|
5
|
-
"
|
|
5
|
+
"mainFunction": "main",
|
|
6
|
+
"namespace": "smoke-test-components",
|
|
7
|
+
"displayName": "some-displayName",
|
|
8
|
+
"description": "some-description",
|
|
6
9
|
"functions": [
|
|
7
10
|
{
|
|
8
11
|
"entry": "main.js",
|
|
@@ -17,7 +20,7 @@
|
|
|
17
20
|
"required": ["something"]
|
|
18
21
|
},
|
|
19
22
|
"output": {
|
|
20
|
-
"
|
|
23
|
+
"responseType": "html"
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
26
|
]
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
+
import { ComponentSetWebModel } from '@squiz/component-lib';
|
|
1
2
|
interface Config {
|
|
2
3
|
managementServiceUrl: string;
|
|
3
4
|
renderServiceUrl: string;
|
|
5
|
+
contentServiceUrl: string;
|
|
4
6
|
ci_buildVersion: string;
|
|
5
7
|
ci_buildBranch: string;
|
|
6
8
|
}
|
|
7
9
|
declare const configObj: Config;
|
|
8
10
|
export default configObj;
|
|
9
11
|
export declare const managementService: import("axios").AxiosInstance;
|
|
12
|
+
export declare const managementServiceRoot: import("axios").AxiosInstance;
|
|
10
13
|
export declare const renderService: import("axios").AxiosInstance;
|
|
14
|
+
export declare const contentService: import("axios").AxiosInstance;
|
|
11
15
|
export declare const ci_buildVersion: string;
|
|
12
16
|
export declare const ci_buildBranch: string;
|
|
13
17
|
export declare function getTestComponents(): string[];
|
|
14
18
|
export declare function createFile(filePath: string, sizeInMB: number): Promise<void>;
|
|
15
19
|
export declare function removeFile(filePath: string): void;
|
|
20
|
+
export declare function deleteComponentSet(webPath: string): Promise<void>;
|
|
21
|
+
export declare function addComponentSet(componentSet: ComponentSetWebModel): Promise<void>;
|