contensis-cli 1.1.2-beta.3 → 1.1.2-beta.4
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/dist/mappers/DevRequests-to-RequestHanderCliArgs.js +46 -28
- package/dist/mappers/DevRequests-to-RequestHanderCliArgs.js.map +3 -3
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -3
- package/src/mappers/DevRequests-to-RequestHanderCliArgs.ts +55 -34
- package/src/version.ts +1 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,12 +17,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
18
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
25
|
var DevRequests_to_RequestHanderCliArgs_exports = {};
|
|
20
26
|
__export(DevRequests_to_RequestHanderCliArgs_exports, {
|
|
21
27
|
default: () => DevRequests_to_RequestHanderCliArgs_default
|
|
22
28
|
});
|
|
23
29
|
module.exports = __toCommonJS(DevRequests_to_RequestHanderCliArgs_exports);
|
|
30
|
+
var import_p_queue = __toESM(require("p-queue"));
|
|
24
31
|
class RequestHandlerArgs {
|
|
25
32
|
cli;
|
|
26
33
|
args;
|
|
@@ -35,10 +42,13 @@ class RequestHandlerArgs {
|
|
|
35
42
|
};
|
|
36
43
|
buildSiteConfig = async () => {
|
|
37
44
|
var _a;
|
|
38
|
-
const { currentEnv, currentProject, env, log, messages } = this.cli;
|
|
45
|
+
const { currentEnv, currentProject, env, log, messages, urls } = this.cli;
|
|
46
|
+
const contensis = await this.cli.ConnectContensis();
|
|
39
47
|
const siteConfig = {
|
|
40
48
|
alias: currentEnv,
|
|
41
49
|
projectId: currentProject,
|
|
50
|
+
iisHostname: (urls == null ? void 0 : urls.iisPreviewWeb.split("//")[1]) || "",
|
|
51
|
+
podClusterId: "hq",
|
|
42
52
|
accessToken: "",
|
|
43
53
|
clientId: "",
|
|
44
54
|
sharedSecret: "",
|
|
@@ -50,44 +60,47 @@ class RequestHandlerArgs {
|
|
|
50
60
|
if (err)
|
|
51
61
|
log.error(messages.blocks.noList(currentEnv, env.currentProject));
|
|
52
62
|
const blocks = [];
|
|
63
|
+
const queue = new import_p_queue.default({ concurrency: 4 });
|
|
53
64
|
for (const block of blocksRaw || []) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (err2 || (versions == null ? void 0 : versions.length) === 0)
|
|
60
|
-
log.warning(
|
|
61
|
-
messages.blocks.noGet(
|
|
62
|
-
block.id,
|
|
63
|
-
"default",
|
|
64
|
-
"latest",
|
|
65
|
-
currentEnv,
|
|
66
|
-
env.currentProject
|
|
67
|
-
)
|
|
65
|
+
queue.add(async () => {
|
|
66
|
+
const [err2, versions] = await contensis2.blocks.GetBlockVersions(
|
|
67
|
+
block.id,
|
|
68
|
+
"default",
|
|
69
|
+
"latest"
|
|
68
70
|
);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
if (err2 || (versions == null ? void 0 : versions.length) === 0)
|
|
72
|
+
log.warning(
|
|
73
|
+
messages.blocks.noGet(
|
|
74
|
+
block.id,
|
|
75
|
+
"default",
|
|
76
|
+
"latest",
|
|
77
|
+
currentEnv,
|
|
78
|
+
env.currentProject
|
|
79
|
+
)
|
|
80
|
+
);
|
|
81
|
+
if (versions == null ? void 0 : versions[0]) {
|
|
82
|
+
const v = versions[0];
|
|
83
|
+
blocks.push({
|
|
84
|
+
id: v.id,
|
|
85
|
+
baseUri: v.previewUrl,
|
|
86
|
+
staticPaths: v.staticPaths,
|
|
87
|
+
endpoints: v.endpoints,
|
|
88
|
+
versionNo: v.version.versionNo,
|
|
89
|
+
branch: v.source.branch
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
80
93
|
}
|
|
94
|
+
await queue.onIdle();
|
|
81
95
|
return blocks;
|
|
82
96
|
};
|
|
83
|
-
const contensis = await this.cli.ConnectContensis();
|
|
84
97
|
if (contensis) {
|
|
85
98
|
const [blocks, renderers] = await Promise.all([
|
|
86
99
|
getBlocks(contensis),
|
|
87
100
|
contensis.renderers.GetRenderers()
|
|
88
101
|
]);
|
|
89
102
|
siteConfig.blocks = blocks;
|
|
90
|
-
siteConfig.renderers = (_a = renderers == null ? void 0 : renderers[1]) == null ? void 0 : _a.map((r) => ({
|
|
103
|
+
siteConfig.renderers = (_a = renderers == null ? void 0 : renderers[1]) == null ? void 0 : _a.filter((r) => blocks.find((b) => b.id === r.id)).map((r) => ({
|
|
91
104
|
id: r.id,
|
|
92
105
|
name: r.name,
|
|
93
106
|
assignedContentTypes: r.assignedContentTypes,
|
|
@@ -105,6 +118,10 @@ class RequestHandlerArgs {
|
|
|
105
118
|
args.push("--alias", cli.currentEnv);
|
|
106
119
|
if (!args.find((a) => a === "--project-api-id"))
|
|
107
120
|
args.push("--project-api-id", cli.currentProject);
|
|
121
|
+
if (!args.find((a) => a === "--iis-hostname"))
|
|
122
|
+
args.push("--iis-hostname", siteConfig.iisHostname);
|
|
123
|
+
if (!args.find((a) => a === "--pod-cluster-id"))
|
|
124
|
+
args.push("--pod-cluster-id", siteConfig.podClusterId);
|
|
108
125
|
if (!args.find((a) => a === "--blocks-json"))
|
|
109
126
|
args.push("--blocks-json", JSON.stringify(siteConfig.blocks));
|
|
110
127
|
if (!args.find((a) => a === "--renderers-json"))
|
|
@@ -131,6 +148,7 @@ class RequestHandlerArgs {
|
|
|
131
148
|
);
|
|
132
149
|
if (typeof blockIndex === "number" && !isNaN(blockIndex) && ((_b = this.siteConfig) == null ? void 0 : _b.blocks[blockIndex])) {
|
|
133
150
|
this.siteConfig.blocks[blockIndex].baseUri = overrideUri;
|
|
151
|
+
this.siteConfig.blocks[blockIndex].staticPaths.push("/*.js");
|
|
134
152
|
}
|
|
135
153
|
}
|
|
136
154
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/mappers/DevRequests-to-RequestHanderCliArgs.ts"],
|
|
4
|
-
"sourcesContent": ["import { ContensisMigrationService } from 'migratortron';\nimport ContensisCli from '~/services/ContensisCliService';\n\ntype EndpointJson = {\n id: string;\n path: string;\n};\n\ntype BlockJson = {\n id: string;\n baseUri: string;\n staticPaths: string[];\n endpoints: EndpointJson[];\n versionNo: number;\n branch: string;\n};\n\ntype RendererJson = {\n id: string;\n name: string;\n rules: RendererRuleJson[];\n assignedContentTypes: string[];\n};\n\ntype RendererRuleJson = {\n return?: {\n blockId?: string;\n endpointId?: string | null;\n version?: string;\n };\n};\ninterface ISiteConfigYaml {\n alias: string;\n projectId: string;\n accessToken: string; // needed?\n clientId: string;\n sharedSecret: string;\n blocks: BlockJson[];\n renderers: RendererJson[];\n}\n\nclass RequestHandlerArgs {\n private cli;\n args?: string[];\n siteConfig?: ISiteConfigYaml;\n\n constructor(cli: ContensisCli) {\n this.cli = cli;\n }\n\n Create = async () => {\n this.siteConfig = await this.buildSiteConfig();\n await this.cli.Login(this.cli.env.lastUserId, { silent: true }); // to hydrate the auth service\n this.args = this.getArgs();\n };\n\n buildSiteConfig = async () => {\n const { currentEnv, currentProject, env, log, messages } = this.cli;\n const siteConfig: ISiteConfigYaml = {\n alias: currentEnv,\n projectId: currentProject,\n accessToken: '',\n clientId: '',\n sharedSecret: '',\n blocks: [],\n renderers: [],\n };\n\n const getBlocks = async (contensis: ContensisMigrationService) => {\n const [err, blocksRaw] = await contensis.blocks.GetBlocks();\n if (err)\n log.error(messages.blocks.noList(currentEnv, env.currentProject));\n\n // const blocksRaw = await cli.PrintBlocks();\n\n const blocks: BlockJson[] = [];\n for (const block of blocksRaw || []) {\n // Retrieve block version\n
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["contensis", "err"]
|
|
4
|
+
"sourcesContent": ["import { ContensisMigrationService } from 'migratortron';\nimport PQueue from 'p-queue';\nimport ContensisCli from '~/services/ContensisCliService';\n\ntype EndpointJson = {\n id: string;\n path: string;\n};\n\ntype BlockJson = {\n id: string;\n baseUri: string;\n staticPaths: string[];\n endpoints: EndpointJson[];\n versionNo: number;\n branch: string;\n};\n\ntype RendererJson = {\n id: string;\n name: string;\n rules: RendererRuleJson[];\n assignedContentTypes: string[];\n};\n\ntype RendererRuleJson = {\n return?: {\n blockId?: string;\n endpointId?: string | null;\n version?: string;\n };\n};\ninterface ISiteConfigYaml {\n alias: string;\n projectId: string;\n iisHostname: string;\n podClusterId: string;\n accessToken: string; // needed?\n clientId: string;\n sharedSecret: string;\n blocks: BlockJson[];\n renderers: RendererJson[];\n}\n\nclass RequestHandlerArgs {\n private cli;\n args?: string[];\n siteConfig?: ISiteConfigYaml;\n\n constructor(cli: ContensisCli) {\n this.cli = cli;\n }\n\n Create = async () => {\n this.siteConfig = await this.buildSiteConfig();\n await this.cli.Login(this.cli.env.lastUserId, { silent: true }); // to hydrate the auth service\n this.args = this.getArgs();\n };\n\n buildSiteConfig = async () => {\n const { currentEnv, currentProject, env, log, messages, urls } = this.cli;\n const contensis = await this.cli.ConnectContensis();\n\n const siteConfig: ISiteConfigYaml = {\n alias: currentEnv,\n projectId: currentProject,\n iisHostname: urls?.iisPreviewWeb.split('//')[1] || '',\n podClusterId: 'hq',\n accessToken: '',\n clientId: '',\n sharedSecret: '',\n blocks: [],\n renderers: [],\n };\n\n const getBlocks = async (contensis: ContensisMigrationService) => {\n const [err, blocksRaw] = await contensis.blocks.GetBlocks();\n if (err)\n log.error(messages.blocks.noList(currentEnv, env.currentProject));\n\n // const blocksRaw = await cli.PrintBlocks();\n\n const blocks: BlockJson[] = [];\n const queue = new PQueue({ concurrency: 4 });\n for (const block of blocksRaw || []) {\n queue.add(async () => {\n // Retrieve block version\n const [err, versions] = await contensis.blocks.GetBlockVersions(\n block.id,\n 'default',\n 'latest'\n );\n if (err || versions?.length === 0)\n log.warning(\n messages.blocks.noGet(\n block.id,\n 'default',\n 'latest',\n currentEnv,\n env.currentProject\n )\n );\n if (versions?.[0]) {\n const v = versions[0];\n blocks.push({\n id: v.id,\n baseUri: v.previewUrl,\n staticPaths: v.staticPaths,\n endpoints: v.endpoints,\n versionNo: v.version.versionNo,\n branch: v.source.branch,\n });\n }\n });\n }\n\n await queue.onIdle();\n return blocks;\n };\n\n if (contensis) {\n const [blocks, renderers] = await Promise.all([\n getBlocks(contensis),\n contensis.renderers.GetRenderers(),\n ]);\n\n siteConfig.blocks = blocks;\n siteConfig.renderers = renderers?.[1]\n ?.filter(r => blocks.find(b => b.id === r.id))\n .map(r => ({\n id: r.id,\n name: r.name,\n assignedContentTypes: r.assignedContentTypes,\n rules: r.rules,\n }));\n }\n return siteConfig;\n };\n\n getArgs = (overrideArgs: string[] = []) => {\n const args = overrideArgs\n ? typeof overrideArgs?.[0] === 'string' &&\n overrideArgs[0].includes(' ', 2)\n ? overrideArgs[0].split(' ')\n : overrideArgs\n : []; // args could be [ '-c .\\\\site_config.yaml' ] or [ '-c', '.\\\\site_config.yaml' ]\n\n const { cli, siteConfig } = this;\n if (siteConfig) {\n // Add required args\n if (!args.find(a => a === '--alias'))\n args.push('--alias', cli.currentEnv);\n if (!args.find(a => a === '--project-api-id'))\n args.push('--project-api-id', cli.currentProject);\n if (!args.find(a => a === '--iis-hostname'))\n args.push('--iis-hostname', siteConfig.iisHostname);\n if (!args.find(a => a === '--pod-cluster-id'))\n args.push('--pod-cluster-id', siteConfig.podClusterId);\n if (!args.find(a => a === '--blocks-json'))\n args.push('--blocks-json', JSON.stringify(siteConfig.blocks));\n if (!args.find(a => a === '--renderers-json'))\n args.push('--renderers-json', JSON.stringify(siteConfig.renderers));\n }\n\n const client = cli.auth?.clientDetails;\n if (client) {\n if (!args.find(a => a === '--client-id') && 'clientId' in client)\n args.push('--client-id', client.clientId);\n if (!args.find(a => a === '--client-secret') && 'clientSecret' in client)\n args.push('--client-secret', client.clientSecret);\n if (!args.find(a => a === '--username') && 'username' in client)\n args.push('--username', client.username);\n if (!args.find(a => a === '--password') && 'password' in client)\n args.push('--password', client.password);\n }\n\n return args;\n };\n\n overrideBlock = (blockId: string, overrideUri: string) => {\n if (blockId && blockId !== 'none') {\n const blockIndex = this.siteConfig?.blocks.findIndex(\n b => b.id.toLowerCase() === blockId.toLowerCase()\n );\n if (\n typeof blockIndex === 'number' &&\n !isNaN(blockIndex) &&\n this.siteConfig?.blocks[blockIndex]\n ) {\n this.siteConfig.blocks[blockIndex].baseUri = overrideUri;\n // this.siteConfig.blocks[blockIndex].staticPaths.push(\n // ...['/static/*', '/image-library/*']\n // );\n this.siteConfig.blocks[blockIndex].staticPaths.push('/*.js');\n }\n }\n };\n}\n\nexport default RequestHandlerArgs;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAAmB;AA2CnB,MAAM,mBAAmB;AAAA,EACf;AAAA,EACR;AAAA,EACA;AAAA,EAEA,YAAY,KAAmB;AAC7B,SAAK,MAAM;AAAA,EACb;AAAA,E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 -21,7 +21,7 @@ __export(version_exports, {
|
|
|
21
21
|
LIB_VERSION: () => LIB_VERSION
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(version_exports);
|
|
24
|
-
const LIB_VERSION = "1.1.2-beta.
|
|
24
|
+
const LIB_VERSION = "1.1.2-beta.4";
|
|
25
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
26
|
0 && (module.exports = {
|
|
27
27
|
LIB_VERSION
|
package/dist/version.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/version.ts"],
|
|
4
|
-
"sourcesContent": ["export const LIB_VERSION = \"1.1.2-beta.
|
|
4
|
+
"sourcesContent": ["export const LIB_VERSION = \"1.1.2-beta.4\";\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "contensis-cli",
|
|
3
|
-
"version": "1.1.2-beta.
|
|
3
|
+
"version": "1.1.2-beta.4",
|
|
4
4
|
"description": "A fully featured Contensis command line interface with a shell UI provides simple and intuitive ways to manage or profile your content in any NodeJS terminal.",
|
|
5
5
|
"repository": "https://github.com/contensis/cli",
|
|
6
6
|
"homepage": "https://github.com/contensis/cli/tree/main/packages/contensis-cli#readme",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"app-root-path": "^3.1.0",
|
|
29
29
|
"chalk": "^4.1.2",
|
|
30
30
|
"commander": "^9.4.1",
|
|
31
|
-
"contensis-management-api": "^2.1.2",
|
|
32
31
|
"csv": "^6.1.0",
|
|
33
32
|
"dayjs": "^1.11.6",
|
|
34
33
|
"diff": "^5.1.0",
|
|
@@ -40,7 +39,7 @@
|
|
|
40
39
|
"jsonpath-mapper": "^1.1.0",
|
|
41
40
|
"keytar": "^7.9.0",
|
|
42
41
|
"lodash": "^4.17.21",
|
|
43
|
-
"migratortron": "^1.0.0-beta.
|
|
42
|
+
"migratortron": "^1.0.0-beta.40",
|
|
44
43
|
"nanospinner": "^1.1.0",
|
|
45
44
|
"node-fetch": "^2.6.7",
|
|
46
45
|
"parse-git-config": "^3.0.0",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ContensisMigrationService } from 'migratortron';
|
|
2
|
+
import PQueue from 'p-queue';
|
|
2
3
|
import ContensisCli from '~/services/ContensisCliService';
|
|
3
4
|
|
|
4
5
|
type EndpointJson = {
|
|
@@ -32,6 +33,8 @@ type RendererRuleJson = {
|
|
|
32
33
|
interface ISiteConfigYaml {
|
|
33
34
|
alias: string;
|
|
34
35
|
projectId: string;
|
|
36
|
+
iisHostname: string;
|
|
37
|
+
podClusterId: string;
|
|
35
38
|
accessToken: string; // needed?
|
|
36
39
|
clientId: string;
|
|
37
40
|
sharedSecret: string;
|
|
@@ -55,10 +58,14 @@ class RequestHandlerArgs {
|
|
|
55
58
|
};
|
|
56
59
|
|
|
57
60
|
buildSiteConfig = async () => {
|
|
58
|
-
const { currentEnv, currentProject, env, log, messages } = this.cli;
|
|
61
|
+
const { currentEnv, currentProject, env, log, messages, urls } = this.cli;
|
|
62
|
+
const contensis = await this.cli.ConnectContensis();
|
|
63
|
+
|
|
59
64
|
const siteConfig: ISiteConfigYaml = {
|
|
60
65
|
alias: currentEnv,
|
|
61
66
|
projectId: currentProject,
|
|
67
|
+
iisHostname: urls?.iisPreviewWeb.split('//')[1] || '',
|
|
68
|
+
podClusterId: 'hq',
|
|
62
69
|
accessToken: '',
|
|
63
70
|
clientId: '',
|
|
64
71
|
sharedSecret: '',
|
|
@@ -74,39 +81,43 @@ class RequestHandlerArgs {
|
|
|
74
81
|
// const blocksRaw = await cli.PrintBlocks();
|
|
75
82
|
|
|
76
83
|
const blocks: BlockJson[] = [];
|
|
84
|
+
const queue = new PQueue({ concurrency: 4 });
|
|
77
85
|
for (const block of blocksRaw || []) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (err || versions?.length === 0)
|
|
85
|
-
log.warning(
|
|
86
|
-
messages.blocks.noGet(
|
|
87
|
-
block.id,
|
|
88
|
-
'default',
|
|
89
|
-
'latest',
|
|
90
|
-
currentEnv,
|
|
91
|
-
env.currentProject
|
|
92
|
-
)
|
|
86
|
+
queue.add(async () => {
|
|
87
|
+
// Retrieve block version
|
|
88
|
+
const [err, versions] = await contensis.blocks.GetBlockVersions(
|
|
89
|
+
block.id,
|
|
90
|
+
'default',
|
|
91
|
+
'latest'
|
|
93
92
|
);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
93
|
+
if (err || versions?.length === 0)
|
|
94
|
+
log.warning(
|
|
95
|
+
messages.blocks.noGet(
|
|
96
|
+
block.id,
|
|
97
|
+
'default',
|
|
98
|
+
'latest',
|
|
99
|
+
currentEnv,
|
|
100
|
+
env.currentProject
|
|
101
|
+
)
|
|
102
|
+
);
|
|
103
|
+
if (versions?.[0]) {
|
|
104
|
+
const v = versions[0];
|
|
105
|
+
blocks.push({
|
|
106
|
+
id: v.id,
|
|
107
|
+
baseUri: v.previewUrl,
|
|
108
|
+
staticPaths: v.staticPaths,
|
|
109
|
+
endpoints: v.endpoints,
|
|
110
|
+
versionNo: v.version.versionNo,
|
|
111
|
+
branch: v.source.branch,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
});
|
|
105
115
|
}
|
|
116
|
+
|
|
117
|
+
await queue.onIdle();
|
|
106
118
|
return blocks;
|
|
107
119
|
};
|
|
108
120
|
|
|
109
|
-
const contensis = await this.cli.ConnectContensis();
|
|
110
121
|
if (contensis) {
|
|
111
122
|
const [blocks, renderers] = await Promise.all([
|
|
112
123
|
getBlocks(contensis),
|
|
@@ -114,12 +125,14 @@ class RequestHandlerArgs {
|
|
|
114
125
|
]);
|
|
115
126
|
|
|
116
127
|
siteConfig.blocks = blocks;
|
|
117
|
-
siteConfig.renderers = renderers?.[1]
|
|
118
|
-
id
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
128
|
+
siteConfig.renderers = renderers?.[1]
|
|
129
|
+
?.filter(r => blocks.find(b => b.id === r.id))
|
|
130
|
+
.map(r => ({
|
|
131
|
+
id: r.id,
|
|
132
|
+
name: r.name,
|
|
133
|
+
assignedContentTypes: r.assignedContentTypes,
|
|
134
|
+
rules: r.rules,
|
|
135
|
+
}));
|
|
123
136
|
}
|
|
124
137
|
return siteConfig;
|
|
125
138
|
};
|
|
@@ -139,6 +152,10 @@ class RequestHandlerArgs {
|
|
|
139
152
|
args.push('--alias', cli.currentEnv);
|
|
140
153
|
if (!args.find(a => a === '--project-api-id'))
|
|
141
154
|
args.push('--project-api-id', cli.currentProject);
|
|
155
|
+
if (!args.find(a => a === '--iis-hostname'))
|
|
156
|
+
args.push('--iis-hostname', siteConfig.iisHostname);
|
|
157
|
+
if (!args.find(a => a === '--pod-cluster-id'))
|
|
158
|
+
args.push('--pod-cluster-id', siteConfig.podClusterId);
|
|
142
159
|
if (!args.find(a => a === '--blocks-json'))
|
|
143
160
|
args.push('--blocks-json', JSON.stringify(siteConfig.blocks));
|
|
144
161
|
if (!args.find(a => a === '--renderers-json'))
|
|
@@ -171,6 +188,10 @@ class RequestHandlerArgs {
|
|
|
171
188
|
this.siteConfig?.blocks[blockIndex]
|
|
172
189
|
) {
|
|
173
190
|
this.siteConfig.blocks[blockIndex].baseUri = overrideUri;
|
|
191
|
+
// this.siteConfig.blocks[blockIndex].staticPaths.push(
|
|
192
|
+
// ...['/static/*', '/image-library/*']
|
|
193
|
+
// );
|
|
194
|
+
this.siteConfig.blocks[blockIndex].staticPaths.push('/*.js');
|
|
174
195
|
}
|
|
175
196
|
}
|
|
176
197
|
};
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = "1.1.2-beta.
|
|
1
|
+
export const LIB_VERSION = "1.1.2-beta.4";
|