@tridion-sites/extensions-cli 1.0.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# @tridion-sites/extensions-cli
|
|
2
|
+
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1b257d330c: CLI supports serving local extensions with deployed ones, fix for package fields of open-api-client (`targetUrl` should be passed to `setupExtensionsResponse`)
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- d46c465289: run build before packing addon
|
|
12
|
+
- d0875fe171: update dependencies
|
|
13
|
+
- Updated dependencies [d398729dce]
|
|
14
|
+
- Updated dependencies [b37272386a]
|
|
15
|
+
- Updated dependencies [d0875fe171]
|
|
16
|
+
- Updated dependencies [151fa1d3b2]
|
|
17
|
+
- Updated dependencies [7ff24d55b8]
|
|
18
|
+
- Updated dependencies [14288f4588]
|
|
19
|
+
- Updated dependencies [c75025f64f]
|
|
20
|
+
- Updated dependencies [334d76210f]
|
|
21
|
+
- Updated dependencies [9e7f89cdc1]
|
|
22
|
+
- Updated dependencies [cc40577cf7]
|
|
23
|
+
- Updated dependencies [1b257d330c]
|
|
24
|
+
- @tridion-sites/open-api-client@3.0.0
|
|
25
|
+
- @tridion-sites/extensions@2.0.0
|
|
26
|
+
- @tridion-sites/models@1.1.0
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"build": "webpack --config ./webpack.prod.config.js --progress",
|
|
16
16
|
"dev": "webpack serve --config ./webpack.dev.config.js --progress --env target={{sitesUrl}} manifest=../manifest.json config=../{{addonId}}.config.json",
|
|
17
17
|
"pack": "sites-extensions pack --manifest=../manifest.json --input=../dist --output=../",
|
|
18
|
+
"prepack": "npm run build",
|
|
18
19
|
"lint": "eslint . --fix && prettier --write \"src/**/*\""
|
|
19
20
|
},
|
|
20
21
|
"peerDependencies": {
|
|
@@ -24,7 +25,7 @@
|
|
|
24
25
|
"react": "18.2.0",
|
|
25
26
|
"react-dom": "18.2.0",
|
|
26
27
|
"styled-components": "5.3.6",
|
|
27
|
-
"tinymce": "6.
|
|
28
|
+
"tinymce": "6.7.1"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@babel/core": "7.21.8",
|
|
@@ -58,7 +59,7 @@
|
|
|
58
59
|
"react-dom": "18.2.0",
|
|
59
60
|
"react-is": "18.2.0",
|
|
60
61
|
"styled-components": "5.3.6",
|
|
61
|
-
"tinymce": "6.
|
|
62
|
+
"tinymce": "6.7.1",
|
|
62
63
|
"tsconfig-paths-webpack-plugin": "4.0.1",
|
|
63
64
|
"typescript": "5.0.4",
|
|
64
65
|
"webpack": "5.82.1",
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Application } from 'express';
|
|
1
2
|
import type { FrontendAddon } from '@tridion-sites/open-api-client';
|
|
2
3
|
|
|
3
4
|
export declare const extensionsRequestBasePath = "/api/uiExtensionsRepository";
|
|
@@ -9,26 +10,14 @@ export declare interface GetLocalFrontendAddonParams {
|
|
|
9
10
|
addonConfigPath?: string;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
declare
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
declare type RequestListener = (request: Request_2, response: Response_2) => void;
|
|
16
|
-
|
|
17
|
-
declare interface Response_2 extends Record<string, any> {
|
|
18
|
-
json: (result: any) => void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export declare const setupExtensionsResponse: ({ app, webAppPath, manifestPath, addonConfigPath, }: SetupExtensionsResponseParams) => void;
|
|
22
|
-
|
|
23
|
-
declare interface SetupExtensionsResponseApp extends Record<string, any> {
|
|
24
|
-
get: (path: string, listener: RequestListener) => void;
|
|
25
|
-
}
|
|
13
|
+
export declare const setupExtensionsResponse: ({ app, webAppPath, manifestPath, addonConfigPath, targetUrl, }: SetupExtensionsResponseParams) => void;
|
|
26
14
|
|
|
27
15
|
export declare interface SetupExtensionsResponseParams {
|
|
28
|
-
app:
|
|
16
|
+
app: Application;
|
|
29
17
|
webAppPath: string;
|
|
30
18
|
manifestPath: string;
|
|
31
19
|
addonConfigPath?: string;
|
|
20
|
+
targetUrl?: string;
|
|
32
21
|
}
|
|
33
22
|
|
|
34
23
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { resolve, basename } from 'node:path';
|
|
3
3
|
import { w as writeJsonFile, r as readJsonFile, A as AddonManifest } from './addonManifest-45b9450a.js';
|
|
4
|
+
import { OpenAPI, ExtensionsService } from '@tridion-sites/open-api-client';
|
|
4
5
|
import 'node:fs';
|
|
5
6
|
|
|
6
7
|
class AddonConfiguration {
|
|
@@ -67,15 +68,45 @@ const getLocalFrontendAddon = ({ manifestPath, addonConfigPath }) => {
|
|
|
67
68
|
return localAddon;
|
|
68
69
|
};
|
|
69
70
|
|
|
70
|
-
const
|
|
71
|
+
const getHeadersFromRequest = (request) => {
|
|
72
|
+
const headers = {};
|
|
73
|
+
// The keys and values are in the same list. It is not a list of tuples. So, the even-numbered offsets are key values, and the odd-numbered offsets are the associated values.
|
|
74
|
+
// So iteration goes over n+2 starting from 0.
|
|
75
|
+
for (let index = 0; index < request.rawHeaders.length; index = index + 2) {
|
|
76
|
+
const key = request.rawHeaders[index];
|
|
77
|
+
const value = request.rawHeaders[index + 1];
|
|
78
|
+
headers[key] = value;
|
|
79
|
+
}
|
|
80
|
+
return headers;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Regexp to catch slashes at the end of url.
|
|
84
|
+
* @example
|
|
85
|
+
* http://domain.com/
|
|
86
|
+
* http://domain.com/ui/
|
|
87
|
+
* http://domain.com/broken//
|
|
88
|
+
*/
|
|
89
|
+
const endlineSlashesRegexp = /\/+$/gm;
|
|
90
|
+
const setupExtensionsResponse = ({ app, webAppPath, manifestPath, addonConfigPath, targetUrl, }) => {
|
|
71
91
|
const basePath = webAppPath.endsWith('/') ? webAppPath : `${webAppPath}/`;
|
|
72
|
-
app.get(`${basePath}api/v2.0/extensions`, (request, response) => {
|
|
92
|
+
app.get(`${basePath}api/v2.0/extensions`, async (request, response) => {
|
|
73
93
|
const localAddon = getLocalFrontendAddon({
|
|
74
94
|
manifestPath,
|
|
75
95
|
addonConfigPath,
|
|
76
96
|
});
|
|
77
|
-
const
|
|
78
|
-
|
|
97
|
+
const result = [localAddon];
|
|
98
|
+
if (targetUrl) {
|
|
99
|
+
/**
|
|
100
|
+
* Extension service uses OpenAPI parameters for every call it makes.
|
|
101
|
+
* `BASE` should be assigned to base URL where API lives.
|
|
102
|
+
* `HEADERS` should include original request's cookies for authorization.
|
|
103
|
+
*/
|
|
104
|
+
OpenAPI.BASE =
|
|
105
|
+
`${targetUrl.replace(endlineSlashesRegexp, '')}${basePath.replace(endlineSlashesRegexp, '')}` || '';
|
|
106
|
+
OpenAPI.HEADERS = getHeadersFromRequest(request);
|
|
107
|
+
const liveAddons = (await ExtensionsService.getExtensions()) || [];
|
|
108
|
+
result.push(...liveAddons);
|
|
109
|
+
}
|
|
79
110
|
response.json(result);
|
|
80
111
|
});
|
|
81
112
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tridion-sites/extensions-cli",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "CLI to create, develop, build and package extensions for Tridion Sites",
|
|
5
5
|
"author": "RWS",
|
|
6
6
|
"homepage": "https://www.rws.com",
|
|
@@ -24,35 +24,36 @@
|
|
|
24
24
|
"test": "sites-extensions"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@tridion-sites/extensions": "
|
|
28
|
-
"@tridion-sites/models": "1.
|
|
29
|
-
"@tridion-sites/open-api-client": "
|
|
30
|
-
"archiver": "
|
|
31
|
-
"chalk": "5.
|
|
32
|
-
"commander": "
|
|
27
|
+
"@tridion-sites/extensions": "2.0.0",
|
|
28
|
+
"@tridion-sites/models": "1.1.0",
|
|
29
|
+
"@tridion-sites/open-api-client": "3.0.0",
|
|
30
|
+
"archiver": "6.0.1",
|
|
31
|
+
"chalk": "5.3.0",
|
|
32
|
+
"commander": "11.0.0",
|
|
33
33
|
"cross-spawn": "7.0.3",
|
|
34
34
|
"decamelize": "6.0.0",
|
|
35
|
-
"fs-extra": "11.1.
|
|
36
|
-
"handlebars": "4.7.
|
|
37
|
-
"inquirer": "9.
|
|
35
|
+
"fs-extra": "11.1.1",
|
|
36
|
+
"handlebars": "4.7.8",
|
|
37
|
+
"inquirer": "9.2.11",
|
|
38
38
|
"valid-filename": "4.0.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@rollup/plugin-commonjs": "
|
|
42
|
-
"@rollup/plugin-node-resolve": "15.
|
|
43
|
-
"@rollup/plugin-typescript": "11.
|
|
44
|
-
"@types/archiver": "5.3.
|
|
45
|
-
"@types/compression": "1.7.
|
|
46
|
-
"@types/cross-spawn": "6.0.
|
|
41
|
+
"@rollup/plugin-commonjs": "25.0.4",
|
|
42
|
+
"@rollup/plugin-node-resolve": "15.2.1",
|
|
43
|
+
"@rollup/plugin-typescript": "11.1.3",
|
|
44
|
+
"@types/archiver": "5.3.2",
|
|
45
|
+
"@types/compression": "1.7.3",
|
|
46
|
+
"@types/cross-spawn": "6.0.3",
|
|
47
|
+
"@types/express": "4.17.18",
|
|
47
48
|
"@types/fs-extra": "11.0.1",
|
|
48
49
|
"@types/inquirer": "9.0.3",
|
|
49
|
-
"@types/node": "
|
|
50
|
-
"@web/rollup-plugin-copy": "0.
|
|
51
|
-
"rimraf": "
|
|
52
|
-
"rollup": "3.
|
|
50
|
+
"@types/node": "20.6.0",
|
|
51
|
+
"@web/rollup-plugin-copy": "0.4.0",
|
|
52
|
+
"rimraf": "5.0.1",
|
|
53
|
+
"rollup": "3.29.1",
|
|
53
54
|
"rollup-plugin-delete": "2.0.0",
|
|
54
|
-
"rollup-plugin-node-externals": "
|
|
55
|
-
"typescript": "5.
|
|
55
|
+
"rollup-plugin-node-externals": "6.1.1",
|
|
56
|
+
"typescript": "5.2.2",
|
|
56
57
|
"typescript-transform-paths": "3.4.6"
|
|
57
58
|
}
|
|
58
59
|
}
|