@tridion-sites/extensions-cli 0.3.3 → 0.3.5
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 +33 -0
- package/dist/addon/template/extension/package.json.hbs +28 -20
- package/dist/{addonManifest-30c25a45.js → addonManifest-45b9450a.js} +210 -210
- package/dist/cli.js +240 -240
- package/dist/index.js +72 -72
- package/package.json +5 -5
- package/dist/addon/template/extension/.npmrc.hbs +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @tridion-sites/extensions-cli
|
|
2
2
|
|
|
3
|
+
## 0.3.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [81cb87a018]
|
|
8
|
+
- Updated dependencies [8881ae361a]
|
|
9
|
+
- Updated dependencies [49558c48b9]
|
|
10
|
+
- Updated dependencies [31bdf04adf]
|
|
11
|
+
- Updated dependencies [7a8ec38aa2]
|
|
12
|
+
- Updated dependencies [06964d8222]
|
|
13
|
+
- Updated dependencies [282794f3f6]
|
|
14
|
+
- Updated dependencies [57199c67f2]
|
|
15
|
+
- Updated dependencies [b803ef7b33]
|
|
16
|
+
- Updated dependencies [9b78d6d626]
|
|
17
|
+
- Updated dependencies [31bdf04adf]
|
|
18
|
+
- @tridion-sites/extensions@0.5.2
|
|
19
|
+
- @tridion-sites/models@0.1.2
|
|
20
|
+
|
|
21
|
+
## 0.3.4
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- 2a21aa8c1d: upgrade tinymce
|
|
26
|
+
- 1845a12377: use the latest typescript version
|
|
27
|
+
- 9348205cee: Update of tinyMCE dependency
|
|
28
|
+
- Updated dependencies [2ea2c9d543]
|
|
29
|
+
- Updated dependencies [226cc4cce1]
|
|
30
|
+
- Updated dependencies [1845a12377]
|
|
31
|
+
- Updated dependencies [9348205cee]
|
|
32
|
+
- @tridion-sites/extensions@0.5.1
|
|
33
|
+
- @tridion-sites/models@0.1.1
|
|
34
|
+
- @tridion-sites/open-api-client@1.0.5
|
|
35
|
+
|
|
3
36
|
## 0.3.3
|
|
4
37
|
|
|
5
38
|
### Patch Changes
|
|
@@ -24,33 +24,41 @@
|
|
|
24
24
|
"react": "18.2.0",
|
|
25
25
|
"react-dom": "18.2.0",
|
|
26
26
|
"styled-components": "5.3.6",
|
|
27
|
-
"tinymce": "6.
|
|
27
|
+
"tinymce": "6.4.2"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@babel/core": "7.
|
|
31
|
-
"@babel/plugin-transform-runtime": "7.
|
|
32
|
-
"@babel/preset-env": "7.
|
|
30
|
+
"@babel/core": "7.21.8",
|
|
31
|
+
"@babel/plugin-transform-runtime": "7.21.4",
|
|
32
|
+
"@babel/preset-env": "7.21.5",
|
|
33
33
|
"@babel/preset-react": "7.18.6",
|
|
34
|
-
"@babel/preset-typescript": "7.
|
|
35
|
-
"@babel/runtime": "7.
|
|
34
|
+
"@babel/preset-typescript": "7.21.5",
|
|
35
|
+
"@babel/runtime": "7.21.5",
|
|
36
|
+
"@tridion-sites/extensions": "{{extensionsApiVersion}}",
|
|
36
37
|
"@tridion-sites/extensions-cli": "{{extensionsCliVersion}}",
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"@types/react
|
|
38
|
+
"@tridion-sites/models": "{{modelsVersion}}",
|
|
39
|
+
"@tridion-sites/open-api-client": "{{openApiClientVersion}}",
|
|
40
|
+
"@types/react": "18.2.6",
|
|
41
|
+
"@types/react-dom": "18.2.4",
|
|
42
|
+
"@types/react-is": "18.2.0",
|
|
40
43
|
"@types/styled-components": "5.1.26",
|
|
41
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
42
|
-
"@typescript-eslint/parser": "5.
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "5.59.5",
|
|
45
|
+
"@typescript-eslint/parser": "5.59.5",
|
|
43
46
|
"babel-loader": "9.1.2",
|
|
44
|
-
"babel-plugin-styled-components": "2.
|
|
45
|
-
"eslint": "8.
|
|
46
|
-
"eslint-config-prettier": "8.
|
|
47
|
-
"eslint-formatter-pretty": "
|
|
48
|
-
"eslint-plugin-react": "7.32.
|
|
47
|
+
"babel-plugin-styled-components": "2.1.1",
|
|
48
|
+
"eslint": "8.40.0",
|
|
49
|
+
"eslint-config-prettier": "8.8.0",
|
|
50
|
+
"eslint-formatter-pretty": "5.0.0",
|
|
51
|
+
"eslint-plugin-react": "7.32.2",
|
|
49
52
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
50
|
-
"fork-ts-checker-webpack-plugin": "
|
|
51
|
-
"prettier": "2.8.
|
|
52
|
-
"
|
|
53
|
-
"
|
|
53
|
+
"fork-ts-checker-webpack-plugin": "8.0.0",
|
|
54
|
+
"prettier": "2.8.8",
|
|
55
|
+
"react": "18.2.0",
|
|
56
|
+
"react-dom": "18.2.0",
|
|
57
|
+
"react-is": "18.2.0",
|
|
58
|
+
"styled-components": "5.3.6",
|
|
59
|
+
"tinymce": "6.4.2",
|
|
60
|
+
"tsconfig-paths-webpack-plugin": "4.0.1",
|
|
61
|
+
"typescript": "5.0.4",
|
|
54
62
|
"webpack": "5.82.1",
|
|
55
63
|
"webpack-cli": "5.1.1",
|
|
56
64
|
"webpack-dev-server": "4.15.0"
|
|
@@ -2,224 +2,224 @@
|
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
4
4
|
|
|
5
|
-
const readJsonFile = (path) => {
|
|
6
|
-
const file = readFileSync(path, { encoding: 'utf-8' });
|
|
7
|
-
return JSON.parse(file);
|
|
8
|
-
};
|
|
9
|
-
const writeJsonFile = (path, value) => {
|
|
10
|
-
const json = JSON.stringify(value, null, 4);
|
|
11
|
-
writeFileSync(path, json);
|
|
5
|
+
const readJsonFile = (path) => {
|
|
6
|
+
const file = readFileSync(path, { encoding: 'utf-8' });
|
|
7
|
+
return JSON.parse(file);
|
|
8
|
+
};
|
|
9
|
+
const writeJsonFile = (path, value) => {
|
|
10
|
+
const json = JSON.stringify(value, null, 4);
|
|
11
|
+
writeFileSync(path, json);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
class AddonExtension {
|
|
15
|
-
constructor(name, type) {
|
|
16
|
-
Object.defineProperty(this, "name", {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
configurable: true,
|
|
19
|
-
writable: true,
|
|
20
|
-
value: void 0
|
|
21
|
-
});
|
|
22
|
-
Object.defineProperty(this, "type", {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
configurable: true,
|
|
25
|
-
writable: true,
|
|
26
|
-
value: void 0
|
|
27
|
-
});
|
|
28
|
-
this.name = name;
|
|
29
|
-
this.type = type;
|
|
30
|
-
}
|
|
14
|
+
class AddonExtension {
|
|
15
|
+
constructor(name, type) {
|
|
16
|
+
Object.defineProperty(this, "name", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
value: void 0
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(this, "type", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
value: void 0
|
|
27
|
+
});
|
|
28
|
+
this.name = name;
|
|
29
|
+
this.type = type;
|
|
30
|
+
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
const frontendExtensionType = 'ExperienceSpaceExtension';
|
|
34
|
-
class FrontendExtension extends AddonExtension {
|
|
35
|
-
constructor({ name, files, main }) {
|
|
36
|
-
super(name, frontendExtensionType);
|
|
37
|
-
Object.defineProperty(this, "main", {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
configurable: true,
|
|
40
|
-
writable: true,
|
|
41
|
-
value: void 0
|
|
42
|
-
});
|
|
43
|
-
Object.defineProperty(this, "files", {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
configurable: true,
|
|
46
|
-
writable: true,
|
|
47
|
-
value: void 0
|
|
48
|
-
});
|
|
49
|
-
this.main = main;
|
|
50
|
-
this.files = files;
|
|
51
|
-
}
|
|
33
|
+
const frontendExtensionType = 'ExperienceSpaceExtension';
|
|
34
|
+
class FrontendExtension extends AddonExtension {
|
|
35
|
+
constructor({ name, files, main }) {
|
|
36
|
+
super(name, frontendExtensionType);
|
|
37
|
+
Object.defineProperty(this, "main", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true,
|
|
41
|
+
value: void 0
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(this, "files", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
configurable: true,
|
|
46
|
+
writable: true,
|
|
47
|
+
value: void 0
|
|
48
|
+
});
|
|
49
|
+
this.main = main;
|
|
50
|
+
this.files = files;
|
|
51
|
+
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
class UnknownExtension extends AddonExtension {
|
|
55
|
-
constructor(name, type, extensionData) {
|
|
56
|
-
super(name, type);
|
|
57
|
-
Object.defineProperty(this, "extensionData", {
|
|
58
|
-
enumerable: true,
|
|
59
|
-
configurable: true,
|
|
60
|
-
writable: true,
|
|
61
|
-
value: void 0
|
|
62
|
-
});
|
|
63
|
-
this.extensionData = extensionData;
|
|
64
|
-
}
|
|
54
|
+
class UnknownExtension extends AddonExtension {
|
|
55
|
+
constructor(name, type, extensionData) {
|
|
56
|
+
super(name, type);
|
|
57
|
+
Object.defineProperty(this, "extensionData", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
configurable: true,
|
|
60
|
+
writable: true,
|
|
61
|
+
value: void 0
|
|
62
|
+
});
|
|
63
|
+
this.extensionData = extensionData;
|
|
64
|
+
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
class AddonManifest {
|
|
68
|
-
constructor({ id, author, description, name, version, requireConfiguration }) {
|
|
69
|
-
Object.defineProperty(this, "id", {
|
|
70
|
-
enumerable: true,
|
|
71
|
-
configurable: true,
|
|
72
|
-
writable: true,
|
|
73
|
-
value: void 0
|
|
74
|
-
});
|
|
75
|
-
Object.defineProperty(this, "author", {
|
|
76
|
-
enumerable: true,
|
|
77
|
-
configurable: true,
|
|
78
|
-
writable: true,
|
|
79
|
-
value: void 0
|
|
80
|
-
});
|
|
81
|
-
Object.defineProperty(this, "description", {
|
|
82
|
-
enumerable: true,
|
|
83
|
-
configurable: true,
|
|
84
|
-
writable: true,
|
|
85
|
-
value: void 0
|
|
86
|
-
});
|
|
87
|
-
Object.defineProperty(this, "name", {
|
|
88
|
-
enumerable: true,
|
|
89
|
-
configurable: true,
|
|
90
|
-
writable: true,
|
|
91
|
-
value: void 0
|
|
92
|
-
});
|
|
93
|
-
Object.defineProperty(this, "version", {
|
|
94
|
-
enumerable: true,
|
|
95
|
-
configurable: true,
|
|
96
|
-
writable: true,
|
|
97
|
-
value: void 0
|
|
98
|
-
});
|
|
99
|
-
Object.defineProperty(this, "manifestVersion", {
|
|
100
|
-
enumerable: true,
|
|
101
|
-
configurable: true,
|
|
102
|
-
writable: true,
|
|
103
|
-
value: void 0
|
|
104
|
-
});
|
|
105
|
-
Object.defineProperty(this, "requireConfiguration", {
|
|
106
|
-
enumerable: true,
|
|
107
|
-
configurable: true,
|
|
108
|
-
writable: true,
|
|
109
|
-
value: void 0
|
|
110
|
-
});
|
|
111
|
-
Object.defineProperty(this, "extensions", {
|
|
112
|
-
enumerable: true,
|
|
113
|
-
configurable: true,
|
|
114
|
-
writable: true,
|
|
115
|
-
value: void 0
|
|
116
|
-
});
|
|
117
|
-
Object.defineProperty(this, "addFrontendExtension", {
|
|
118
|
-
enumerable: true,
|
|
119
|
-
configurable: true,
|
|
120
|
-
writable: true,
|
|
121
|
-
value: (name, fileUrls, mainFileUrl) => {
|
|
122
|
-
this.extensions.set(name, new FrontendExtension({
|
|
123
|
-
name,
|
|
124
|
-
main: mainFileUrl,
|
|
125
|
-
files: fileUrls,
|
|
126
|
-
}));
|
|
127
|
-
return this;
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
Object.defineProperty(this, "addUnknownExtension", {
|
|
131
|
-
enumerable: true,
|
|
132
|
-
configurable: true,
|
|
133
|
-
writable: true,
|
|
134
|
-
value: (name, type, extensionData) => {
|
|
135
|
-
this.extensions.set(name, new UnknownExtension(name, type, extensionData));
|
|
136
|
-
return this;
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
Object.defineProperty(this, "getFrontendExtensions", {
|
|
140
|
-
enumerable: true,
|
|
141
|
-
configurable: true,
|
|
142
|
-
writable: true,
|
|
143
|
-
value: () => {
|
|
144
|
-
const frontendExtensions = [];
|
|
145
|
-
this.extensions.forEach(extension => {
|
|
146
|
-
if (extension instanceof FrontendExtension) {
|
|
147
|
-
frontendExtensions.push(extension);
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
return frontendExtensions;
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
Object.defineProperty(this, "writeFile", {
|
|
154
|
-
enumerable: true,
|
|
155
|
-
configurable: true,
|
|
156
|
-
writable: true,
|
|
157
|
-
value: (path) => {
|
|
158
|
-
const extensionsJson = [];
|
|
159
|
-
this.extensions.forEach(extension => {
|
|
160
|
-
if (extension instanceof FrontendExtension) {
|
|
161
|
-
extensionsJson.push({
|
|
162
|
-
name: extension.name,
|
|
163
|
-
type: extension.type,
|
|
164
|
-
properties: {
|
|
165
|
-
main: extension.main,
|
|
166
|
-
files: extension.files,
|
|
167
|
-
},
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
else if (extension instanceof UnknownExtension) {
|
|
171
|
-
extensionsJson.push(extension.extensionData);
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
const manifestPath = resolve(path, 'manifest.json');
|
|
175
|
-
writeJsonFile(manifestPath, {
|
|
176
|
-
id: this.id,
|
|
177
|
-
name: this.name,
|
|
178
|
-
author: this.author,
|
|
179
|
-
description: this.description,
|
|
180
|
-
manifestVersion: this.manifestVersion,
|
|
181
|
-
requireConfiguration: this.requireConfiguration,
|
|
182
|
-
version: this.version,
|
|
183
|
-
extensions: extensionsJson,
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
this.id = id;
|
|
188
|
-
this.author = author || '';
|
|
189
|
-
this.description = description;
|
|
190
|
-
this.name = name;
|
|
191
|
-
this.manifestVersion = '1.0.0';
|
|
192
|
-
this.requireConfiguration = requireConfiguration || 'optional';
|
|
193
|
-
this.version = version;
|
|
194
|
-
this.extensions = new Map();
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
Object.defineProperty(AddonManifest, "fromFile", {
|
|
198
|
-
enumerable: true,
|
|
199
|
-
configurable: true,
|
|
200
|
-
writable: true,
|
|
201
|
-
value: (manifestPath) => {
|
|
202
|
-
const manifestFile = readJsonFile(manifestPath);
|
|
203
|
-
const manifest = new AddonManifest({
|
|
204
|
-
id: manifestFile.id,
|
|
205
|
-
author: manifestFile.author,
|
|
206
|
-
description: manifestFile.description,
|
|
207
|
-
name: manifestFile.name,
|
|
208
|
-
version: manifestFile.version,
|
|
209
|
-
requireConfiguration: manifestFile.requireConfiguration,
|
|
210
|
-
});
|
|
211
|
-
for (const extension of manifestFile.extensions) {
|
|
212
|
-
if (extension.type === frontendExtensionType) {
|
|
213
|
-
const main = extension.properties.main;
|
|
214
|
-
const files = extension.properties.files;
|
|
215
|
-
manifest.addFrontendExtension(extension.name, files, main);
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
manifest.addUnknownExtension(extension.name, extension.type, extension);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
return manifest;
|
|
222
|
-
}
|
|
67
|
+
class AddonManifest {
|
|
68
|
+
constructor({ id, author, description, name, version, requireConfiguration }) {
|
|
69
|
+
Object.defineProperty(this, "id", {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
configurable: true,
|
|
72
|
+
writable: true,
|
|
73
|
+
value: void 0
|
|
74
|
+
});
|
|
75
|
+
Object.defineProperty(this, "author", {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
configurable: true,
|
|
78
|
+
writable: true,
|
|
79
|
+
value: void 0
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(this, "description", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
configurable: true,
|
|
84
|
+
writable: true,
|
|
85
|
+
value: void 0
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(this, "name", {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
configurable: true,
|
|
90
|
+
writable: true,
|
|
91
|
+
value: void 0
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(this, "version", {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
configurable: true,
|
|
96
|
+
writable: true,
|
|
97
|
+
value: void 0
|
|
98
|
+
});
|
|
99
|
+
Object.defineProperty(this, "manifestVersion", {
|
|
100
|
+
enumerable: true,
|
|
101
|
+
configurable: true,
|
|
102
|
+
writable: true,
|
|
103
|
+
value: void 0
|
|
104
|
+
});
|
|
105
|
+
Object.defineProperty(this, "requireConfiguration", {
|
|
106
|
+
enumerable: true,
|
|
107
|
+
configurable: true,
|
|
108
|
+
writable: true,
|
|
109
|
+
value: void 0
|
|
110
|
+
});
|
|
111
|
+
Object.defineProperty(this, "extensions", {
|
|
112
|
+
enumerable: true,
|
|
113
|
+
configurable: true,
|
|
114
|
+
writable: true,
|
|
115
|
+
value: void 0
|
|
116
|
+
});
|
|
117
|
+
Object.defineProperty(this, "addFrontendExtension", {
|
|
118
|
+
enumerable: true,
|
|
119
|
+
configurable: true,
|
|
120
|
+
writable: true,
|
|
121
|
+
value: (name, fileUrls, mainFileUrl) => {
|
|
122
|
+
this.extensions.set(name, new FrontendExtension({
|
|
123
|
+
name,
|
|
124
|
+
main: mainFileUrl,
|
|
125
|
+
files: fileUrls,
|
|
126
|
+
}));
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(this, "addUnknownExtension", {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
configurable: true,
|
|
133
|
+
writable: true,
|
|
134
|
+
value: (name, type, extensionData) => {
|
|
135
|
+
this.extensions.set(name, new UnknownExtension(name, type, extensionData));
|
|
136
|
+
return this;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
Object.defineProperty(this, "getFrontendExtensions", {
|
|
140
|
+
enumerable: true,
|
|
141
|
+
configurable: true,
|
|
142
|
+
writable: true,
|
|
143
|
+
value: () => {
|
|
144
|
+
const frontendExtensions = [];
|
|
145
|
+
this.extensions.forEach(extension => {
|
|
146
|
+
if (extension instanceof FrontendExtension) {
|
|
147
|
+
frontendExtensions.push(extension);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
return frontendExtensions;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
Object.defineProperty(this, "writeFile", {
|
|
154
|
+
enumerable: true,
|
|
155
|
+
configurable: true,
|
|
156
|
+
writable: true,
|
|
157
|
+
value: (path) => {
|
|
158
|
+
const extensionsJson = [];
|
|
159
|
+
this.extensions.forEach(extension => {
|
|
160
|
+
if (extension instanceof FrontendExtension) {
|
|
161
|
+
extensionsJson.push({
|
|
162
|
+
name: extension.name,
|
|
163
|
+
type: extension.type,
|
|
164
|
+
properties: {
|
|
165
|
+
main: extension.main,
|
|
166
|
+
files: extension.files,
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
else if (extension instanceof UnknownExtension) {
|
|
171
|
+
extensionsJson.push(extension.extensionData);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
const manifestPath = resolve(path, 'manifest.json');
|
|
175
|
+
writeJsonFile(manifestPath, {
|
|
176
|
+
id: this.id,
|
|
177
|
+
name: this.name,
|
|
178
|
+
author: this.author,
|
|
179
|
+
description: this.description,
|
|
180
|
+
manifestVersion: this.manifestVersion,
|
|
181
|
+
requireConfiguration: this.requireConfiguration,
|
|
182
|
+
version: this.version,
|
|
183
|
+
extensions: extensionsJson,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
this.id = id;
|
|
188
|
+
this.author = author || '';
|
|
189
|
+
this.description = description;
|
|
190
|
+
this.name = name;
|
|
191
|
+
this.manifestVersion = '1.0.0';
|
|
192
|
+
this.requireConfiguration = requireConfiguration || 'optional';
|
|
193
|
+
this.version = version;
|
|
194
|
+
this.extensions = new Map();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
Object.defineProperty(AddonManifest, "fromFile", {
|
|
198
|
+
enumerable: true,
|
|
199
|
+
configurable: true,
|
|
200
|
+
writable: true,
|
|
201
|
+
value: (manifestPath) => {
|
|
202
|
+
const manifestFile = readJsonFile(manifestPath);
|
|
203
|
+
const manifest = new AddonManifest({
|
|
204
|
+
id: manifestFile.id,
|
|
205
|
+
author: manifestFile.author,
|
|
206
|
+
description: manifestFile.description,
|
|
207
|
+
name: manifestFile.name,
|
|
208
|
+
version: manifestFile.version,
|
|
209
|
+
requireConfiguration: manifestFile.requireConfiguration,
|
|
210
|
+
});
|
|
211
|
+
for (const extension of manifestFile.extensions) {
|
|
212
|
+
if (extension.type === frontendExtensionType) {
|
|
213
|
+
const main = extension.properties.main;
|
|
214
|
+
const files = extension.properties.files;
|
|
215
|
+
manifest.addFrontendExtension(extension.name, files, main);
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
manifest.addUnknownExtension(extension.name, extension.type, extension);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return manifest;
|
|
222
|
+
}
|
|
223
223
|
});
|
|
224
224
|
|
|
225
225
|
export { AddonManifest as A, readJsonFile as r, writeJsonFile as w };
|
package/dist/cli.js
CHANGED
|
@@ -6,274 +6,274 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync, createWriteStream }
|
|
|
6
6
|
import { resolve, dirname, basename } from 'node:path';
|
|
7
7
|
import Handlebars from 'handlebars';
|
|
8
8
|
import { fileURLToPath } from 'node:url';
|
|
9
|
-
import { r as readJsonFile, A as AddonManifest } from './addonManifest-
|
|
9
|
+
import { r as readJsonFile, A as AddonManifest } from './addonManifest-45b9450a.js';
|
|
10
10
|
import inquirer from 'inquirer';
|
|
11
11
|
import isValidFilename from 'valid-filename';
|
|
12
12
|
import archiver from 'archiver';
|
|
13
13
|
|
|
14
|
-
const installDependencies = (cwd) => {
|
|
15
|
-
spawn.sync('npm', ['install'], {
|
|
16
|
-
stdio: 'inherit',
|
|
17
|
-
cwd,
|
|
18
|
-
});
|
|
14
|
+
const installDependencies = (cwd) => {
|
|
15
|
+
spawn.sync('npm', ['install'], {
|
|
16
|
+
stdio: 'inherit',
|
|
17
|
+
cwd,
|
|
18
|
+
});
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
const runLinters = (cwd) => {
|
|
22
|
-
spawn.sync('npm', ['run', 'lint'], {
|
|
23
|
-
stdio: 'inherit',
|
|
24
|
-
cwd,
|
|
25
|
-
});
|
|
21
|
+
const runLinters = (cwd) => {
|
|
22
|
+
spawn.sync('npm', ['run', 'lint'], {
|
|
23
|
+
stdio: 'inherit',
|
|
24
|
+
cwd,
|
|
25
|
+
});
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
const createFolder = (parentFolder, folderName) => {
|
|
29
|
-
const path = resolve(parentFolder, folderName);
|
|
30
|
-
if (!existsSync(path)) {
|
|
31
|
-
mkdirSync(path);
|
|
32
|
-
}
|
|
33
|
-
return path;
|
|
28
|
+
const createFolder = (parentFolder, folderName) => {
|
|
29
|
+
const path = resolve(parentFolder, folderName);
|
|
30
|
+
if (!existsSync(path)) {
|
|
31
|
+
mkdirSync(path);
|
|
32
|
+
}
|
|
33
|
+
return path;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
const createFileFromTemplate = (templateFilePath, destinationFilePath, templateParams) => {
|
|
37
|
-
const templateFile = readFileSync(templateFilePath, 'utf-8');
|
|
38
|
-
const template = Handlebars.compile(templateFile);
|
|
39
|
-
const file = template(templateParams);
|
|
40
|
-
mkdirSync(dirname(destinationFilePath), { recursive: true });
|
|
41
|
-
writeFileSync(destinationFilePath, file);
|
|
36
|
+
const createFileFromTemplate = (templateFilePath, destinationFilePath, templateParams) => {
|
|
37
|
+
const templateFile = readFileSync(templateFilePath, 'utf-8');
|
|
38
|
+
const template = Handlebars.compile(templateFile);
|
|
39
|
+
const file = template(templateParams);
|
|
40
|
+
mkdirSync(dirname(destinationFilePath), { recursive: true });
|
|
41
|
+
writeFileSync(destinationFilePath, file);
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
/**
|
|
45
|
-
* Return the path to currently executing binary (in node_modules)
|
|
46
|
-
* @note This function is going to return an incorrect path if
|
|
47
|
-
* a build does not bundle all files into a single javascript file!
|
|
48
|
-
*/
|
|
49
|
-
const getBinaryPath = () => {
|
|
50
|
-
const filepath = fileURLToPath(import.meta.url);
|
|
51
|
-
const binaryPath = dirname(filepath);
|
|
52
|
-
return binaryPath;
|
|
44
|
+
/**
|
|
45
|
+
* Return the path to currently executing binary (in node_modules)
|
|
46
|
+
* @note This function is going to return an incorrect path if
|
|
47
|
+
* a build does not bundle all files into a single javascript file!
|
|
48
|
+
*/
|
|
49
|
+
const getBinaryPath = () => {
|
|
50
|
+
const filepath = fileURLToPath(import.meta.url);
|
|
51
|
+
const binaryPath = dirname(filepath);
|
|
52
|
+
return binaryPath;
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
const getPackageJson = () => {
|
|
56
|
-
const binaryPath = getBinaryPath();
|
|
57
|
-
const packageJsonPath = resolve(binaryPath, '../package.json');
|
|
58
|
-
const packageJson = readJsonFile(packageJsonPath);
|
|
59
|
-
return packageJson;
|
|
55
|
+
const getPackageJson = () => {
|
|
56
|
+
const binaryPath = getBinaryPath();
|
|
57
|
+
const packageJsonPath = resolve(binaryPath, '../package.json');
|
|
58
|
+
const packageJson = readJsonFile(packageJsonPath);
|
|
59
|
+
return packageJson;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
const copyTemplate = ({ addonId, addonRootFolderPath, author, extensionDescription, extensionName, extensionRootFolderPath, sitesUrl, }) => {
|
|
63
|
-
const binaryPath = getBinaryPath();
|
|
64
|
-
const templatePath = resolve(binaryPath, 'addon/template');
|
|
65
|
-
const packageJson = getPackageJson();
|
|
66
|
-
createFileFromTemplate(resolve(templatePath, 'addonId.config.json.hbs'), resolve(addonRootFolderPath, `${addonId}.config.json`), {
|
|
67
|
-
extensionName,
|
|
68
|
-
});
|
|
69
|
-
[
|
|
70
|
-
'.browserslistrc',
|
|
71
|
-
'.editorconfig',
|
|
72
|
-
'.eslintrc.json',
|
|
73
|
-
'.gitignore',
|
|
74
|
-
'.prettierrc',
|
|
75
|
-
'babel.config.js',
|
|
76
|
-
'devServer.js',
|
|
77
|
-
'tsconfig.json',
|
|
78
|
-
'src/globals.ts',
|
|
79
|
-
'src/index.tsx',
|
|
80
|
-
].forEach(fileName => {
|
|
81
|
-
createFileFromTemplate(resolve(templatePath, `extension/${fileName}.hbs`), resolve(extensionRootFolderPath, fileName));
|
|
82
|
-
});
|
|
83
|
-
createFileFromTemplate(resolve(templatePath, 'extension/package.json.hbs'), resolve(extensionRootFolderPath, 'package.json'), {
|
|
84
|
-
extensionName,
|
|
85
|
-
extensionDescription,
|
|
86
|
-
author,
|
|
87
|
-
addonId,
|
|
88
|
-
sitesUrl,
|
|
89
|
-
extensionsApiVersion: packageJson.dependencies['@tridion-sites/extensions'],
|
|
90
|
-
modelsVersion: packageJson.dependencies['@tridion-sites/models'],
|
|
91
|
-
openApiClientVersion: packageJson.dependencies['@tridion-sites/open-api-client'],
|
|
92
|
-
extensionsCliVersion: packageJson.version,
|
|
93
|
-
});
|
|
94
|
-
createFileFromTemplate(resolve(templatePath, 'extension/webpack.dev.config.js.hbs'), resolve(extensionRootFolderPath, 'webpack.dev.config.js'), {
|
|
95
|
-
extensionName,
|
|
96
|
-
});
|
|
97
|
-
createFileFromTemplate(resolve(templatePath, 'extension/webpack.prod.config.js.hbs'), resolve(extensionRootFolderPath, 'webpack.prod.config.js'), {
|
|
98
|
-
extensionName,
|
|
99
|
-
});
|
|
62
|
+
const copyTemplate = ({ addonId, addonRootFolderPath, author, extensionDescription, extensionName, extensionRootFolderPath, sitesUrl, }) => {
|
|
63
|
+
const binaryPath = getBinaryPath();
|
|
64
|
+
const templatePath = resolve(binaryPath, 'addon/template');
|
|
65
|
+
const packageJson = getPackageJson();
|
|
66
|
+
createFileFromTemplate(resolve(templatePath, 'addonId.config.json.hbs'), resolve(addonRootFolderPath, `${addonId}.config.json`), {
|
|
67
|
+
extensionName,
|
|
68
|
+
});
|
|
69
|
+
[
|
|
70
|
+
'.browserslistrc',
|
|
71
|
+
'.editorconfig',
|
|
72
|
+
'.eslintrc.json',
|
|
73
|
+
'.gitignore',
|
|
74
|
+
'.prettierrc',
|
|
75
|
+
'babel.config.js',
|
|
76
|
+
'devServer.js',
|
|
77
|
+
'tsconfig.json',
|
|
78
|
+
'src/globals.ts',
|
|
79
|
+
'src/index.tsx',
|
|
80
|
+
].forEach(fileName => {
|
|
81
|
+
createFileFromTemplate(resolve(templatePath, `extension/${fileName}.hbs`), resolve(extensionRootFolderPath, fileName));
|
|
82
|
+
});
|
|
83
|
+
createFileFromTemplate(resolve(templatePath, 'extension/package.json.hbs'), resolve(extensionRootFolderPath, 'package.json'), {
|
|
84
|
+
extensionName,
|
|
85
|
+
extensionDescription,
|
|
86
|
+
author,
|
|
87
|
+
addonId,
|
|
88
|
+
sitesUrl,
|
|
89
|
+
extensionsApiVersion: packageJson.dependencies['@tridion-sites/extensions'],
|
|
90
|
+
modelsVersion: packageJson.dependencies['@tridion-sites/models'],
|
|
91
|
+
openApiClientVersion: packageJson.dependencies['@tridion-sites/open-api-client'],
|
|
92
|
+
extensionsCliVersion: packageJson.version,
|
|
93
|
+
});
|
|
94
|
+
createFileFromTemplate(resolve(templatePath, 'extension/webpack.dev.config.js.hbs'), resolve(extensionRootFolderPath, 'webpack.dev.config.js'), {
|
|
95
|
+
extensionName,
|
|
96
|
+
});
|
|
97
|
+
createFileFromTemplate(resolve(templatePath, 'extension/webpack.prod.config.js.hbs'), resolve(extensionRootFolderPath, 'webpack.prod.config.js'), {
|
|
98
|
+
extensionName,
|
|
99
|
+
});
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
const createAddonPrompt = async () => {
|
|
103
|
-
return inquirer.prompt([
|
|
104
|
-
{
|
|
105
|
-
type: 'input',
|
|
106
|
-
name: 'addonId',
|
|
107
|
-
message: 'Provide id of the addon:',
|
|
108
|
-
default: 'my-addon',
|
|
109
|
-
validate: (input) => {
|
|
110
|
-
if (/\s+/g.test(input)) {
|
|
111
|
-
return "Addon id can't have whitespace";
|
|
112
|
-
}
|
|
113
|
-
if (!isValidFilename(input)) {
|
|
114
|
-
return "Addon id can't have reserved symbols";
|
|
115
|
-
}
|
|
116
|
-
return true;
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
type: 'input',
|
|
121
|
-
name: 'addonName',
|
|
122
|
-
message: 'Provide name of the addon:',
|
|
123
|
-
default: 'My addon',
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
type: 'input',
|
|
127
|
-
name: 'addonDescription',
|
|
128
|
-
message: 'Provide description of the addon:',
|
|
129
|
-
default: 'My addon for Tridion Experience Space',
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
type: 'input',
|
|
133
|
-
name: 'author',
|
|
134
|
-
message: `Provide author's name:`,
|
|
135
|
-
default: 'RWS',
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
type: 'input',
|
|
139
|
-
name: 'extensionName',
|
|
140
|
-
message: 'Provide the name of the frontend extension:',
|
|
141
|
-
default: 'my-extension',
|
|
142
|
-
validate: (input) => {
|
|
143
|
-
if (!/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(input)) {
|
|
144
|
-
return 'Extension name should adhere to package.json name requirements!';
|
|
145
|
-
}
|
|
146
|
-
return true;
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
type: 'input',
|
|
151
|
-
name: 'extensionDescription',
|
|
152
|
-
message: 'Provide description of the extension:',
|
|
153
|
-
default: 'My first extension',
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
type: 'input',
|
|
157
|
-
name: 'url',
|
|
158
|
-
message: `Provide the url to Tridion Sites:`,
|
|
159
|
-
validate: (input) => {
|
|
160
|
-
if (!/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}(\.[a-zA-Z0-9()]{1,6})?\b([-a-zA-Z0-9()@:%_\+.~#?&\/=]*)/gm.test(input)) {
|
|
161
|
-
return `Make sure it's a valid URL`;
|
|
162
|
-
}
|
|
163
|
-
return true;
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
|
-
]);
|
|
102
|
+
const createAddonPrompt = async () => {
|
|
103
|
+
return inquirer.prompt([
|
|
104
|
+
{
|
|
105
|
+
type: 'input',
|
|
106
|
+
name: 'addonId',
|
|
107
|
+
message: 'Provide id of the addon:',
|
|
108
|
+
default: 'my-addon',
|
|
109
|
+
validate: (input) => {
|
|
110
|
+
if (/\s+/g.test(input)) {
|
|
111
|
+
return "Addon id can't have whitespace";
|
|
112
|
+
}
|
|
113
|
+
if (!isValidFilename(input)) {
|
|
114
|
+
return "Addon id can't have reserved symbols";
|
|
115
|
+
}
|
|
116
|
+
return true;
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
type: 'input',
|
|
121
|
+
name: 'addonName',
|
|
122
|
+
message: 'Provide name of the addon:',
|
|
123
|
+
default: 'My addon',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
type: 'input',
|
|
127
|
+
name: 'addonDescription',
|
|
128
|
+
message: 'Provide description of the addon:',
|
|
129
|
+
default: 'My addon for Tridion Experience Space',
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
type: 'input',
|
|
133
|
+
name: 'author',
|
|
134
|
+
message: `Provide author's name:`,
|
|
135
|
+
default: 'RWS',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
type: 'input',
|
|
139
|
+
name: 'extensionName',
|
|
140
|
+
message: 'Provide the name of the frontend extension:',
|
|
141
|
+
default: 'my-extension',
|
|
142
|
+
validate: (input) => {
|
|
143
|
+
if (!/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(input)) {
|
|
144
|
+
return 'Extension name should adhere to package.json name requirements!';
|
|
145
|
+
}
|
|
146
|
+
return true;
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
type: 'input',
|
|
151
|
+
name: 'extensionDescription',
|
|
152
|
+
message: 'Provide description of the extension:',
|
|
153
|
+
default: 'My first extension',
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
type: 'input',
|
|
157
|
+
name: 'url',
|
|
158
|
+
message: `Provide the url to Tridion Sites:`,
|
|
159
|
+
validate: (input) => {
|
|
160
|
+
if (!/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}(\.[a-zA-Z0-9()]{1,6})?\b([-a-zA-Z0-9()@:%_\+.~#?&\/=]*)/gm.test(input)) {
|
|
161
|
+
return `Make sure it's a valid URL`;
|
|
162
|
+
}
|
|
163
|
+
return true;
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
]);
|
|
167
167
|
};
|
|
168
168
|
|
|
169
|
-
const createAddonRootFolder = ({ path, addonDescription, addonId, addonName, author, extensionName, }) => {
|
|
170
|
-
const addonFolderPath = createFolder(path, addonId);
|
|
171
|
-
const manifest = new AddonManifest({
|
|
172
|
-
version: '1.0.0',
|
|
173
|
-
id: addonId,
|
|
174
|
-
name: addonName,
|
|
175
|
-
description: addonDescription,
|
|
176
|
-
author: author,
|
|
177
|
-
});
|
|
178
|
-
manifest.addFrontendExtension(extensionName, [`dist\\${extensionName}\\main.js`], `dist\\${extensionName}\\main.js`);
|
|
179
|
-
manifest.writeFile(addonFolderPath);
|
|
180
|
-
return addonFolderPath;
|
|
169
|
+
const createAddonRootFolder = ({ path, addonDescription, addonId, addonName, author, extensionName, }) => {
|
|
170
|
+
const addonFolderPath = createFolder(path, addonId);
|
|
171
|
+
const manifest = new AddonManifest({
|
|
172
|
+
version: '1.0.0',
|
|
173
|
+
id: addonId,
|
|
174
|
+
name: addonName,
|
|
175
|
+
description: addonDescription,
|
|
176
|
+
author: author,
|
|
177
|
+
});
|
|
178
|
+
manifest.addFrontendExtension(extensionName, [`dist\\${extensionName}\\main.js`], `dist\\${extensionName}\\main.js`);
|
|
179
|
+
manifest.writeFile(addonFolderPath);
|
|
180
|
+
return addonFolderPath;
|
|
181
181
|
};
|
|
182
182
|
|
|
183
|
-
const createAddon = async (path) => {
|
|
184
|
-
const answers = await createAddonPrompt();
|
|
185
|
-
const addonRootFolderPath = createAddonRootFolder({
|
|
186
|
-
path,
|
|
187
|
-
addonId: answers.addonId,
|
|
188
|
-
addonName: answers.addonName,
|
|
189
|
-
addonDescription: answers.addonDescription,
|
|
190
|
-
author: answers.author,
|
|
191
|
-
extensionName: answers.extensionName,
|
|
192
|
-
});
|
|
193
|
-
const extensionRootFolderPath = createFolder(addonRootFolderPath, answers.extensionName);
|
|
194
|
-
copyTemplate({
|
|
195
|
-
addonRootFolderPath,
|
|
196
|
-
extensionRootFolderPath,
|
|
197
|
-
addonId: answers.addonId,
|
|
198
|
-
author: answers.author,
|
|
199
|
-
extensionDescription: answers.extensionDescription,
|
|
200
|
-
extensionName: answers.extensionName,
|
|
201
|
-
sitesUrl: answers.url,
|
|
202
|
-
});
|
|
203
|
-
return {
|
|
204
|
-
addonFolderPath: addonRootFolderPath,
|
|
205
|
-
extensionFolderPath: extensionRootFolderPath,
|
|
206
|
-
};
|
|
183
|
+
const createAddon = async (path) => {
|
|
184
|
+
const answers = await createAddonPrompt();
|
|
185
|
+
const addonRootFolderPath = createAddonRootFolder({
|
|
186
|
+
path,
|
|
187
|
+
addonId: answers.addonId,
|
|
188
|
+
addonName: answers.addonName,
|
|
189
|
+
addonDescription: answers.addonDescription,
|
|
190
|
+
author: answers.author,
|
|
191
|
+
extensionName: answers.extensionName,
|
|
192
|
+
});
|
|
193
|
+
const extensionRootFolderPath = createFolder(addonRootFolderPath, answers.extensionName);
|
|
194
|
+
copyTemplate({
|
|
195
|
+
addonRootFolderPath,
|
|
196
|
+
extensionRootFolderPath,
|
|
197
|
+
addonId: answers.addonId,
|
|
198
|
+
author: answers.author,
|
|
199
|
+
extensionDescription: answers.extensionDescription,
|
|
200
|
+
extensionName: answers.extensionName,
|
|
201
|
+
sitesUrl: answers.url,
|
|
202
|
+
});
|
|
203
|
+
return {
|
|
204
|
+
addonFolderPath: addonRootFolderPath,
|
|
205
|
+
extensionFolderPath: extensionRootFolderPath,
|
|
206
|
+
};
|
|
207
207
|
};
|
|
208
208
|
|
|
209
|
-
const configureHandlebars = () => {
|
|
210
|
-
Handlebars.registerHelper('camelCase', (text) => {
|
|
211
|
-
return text.replace(/^./gm, match => match.toLowerCase());
|
|
212
|
-
});
|
|
213
|
-
Handlebars.registerHelper('kebabCase', (text) => {
|
|
214
|
-
return text.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
215
|
-
});
|
|
209
|
+
const configureHandlebars = () => {
|
|
210
|
+
Handlebars.registerHelper('camelCase', (text) => {
|
|
211
|
+
return text.replace(/^./gm, match => match.toLowerCase());
|
|
212
|
+
});
|
|
213
|
+
Handlebars.registerHelper('kebabCase', (text) => {
|
|
214
|
+
return text.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
215
|
+
});
|
|
216
216
|
};
|
|
217
217
|
|
|
218
|
-
configureHandlebars();
|
|
219
|
-
const createCommand = async () => {
|
|
220
|
-
const currentProcessPath = process.cwd();
|
|
221
|
-
console.info(chalk.green(`Creating a new addon at: ${currentProcessPath}`));
|
|
222
|
-
const { extensionFolderPath } = await createAddon(currentProcessPath);
|
|
223
|
-
console.info(chalk.green(`Installing dependencies`));
|
|
224
|
-
installDependencies(extensionFolderPath);
|
|
225
|
-
console.info(chalk.green(`Running linters`));
|
|
226
|
-
runLinters(extensionFolderPath);
|
|
227
|
-
console.info(chalk.green('🎉️️ All done! Happy hacking!'));
|
|
228
|
-
console.info(chalk.green(`Your extension is available at: ${extensionFolderPath}`));
|
|
218
|
+
configureHandlebars();
|
|
219
|
+
const createCommand = async () => {
|
|
220
|
+
const currentProcessPath = process.cwd();
|
|
221
|
+
console.info(chalk.green(`Creating a new addon at: ${currentProcessPath}`));
|
|
222
|
+
const { extensionFolderPath } = await createAddon(currentProcessPath);
|
|
223
|
+
console.info(chalk.green(`Installing dependencies`));
|
|
224
|
+
installDependencies(extensionFolderPath);
|
|
225
|
+
console.info(chalk.green(`Running linters`));
|
|
226
|
+
runLinters(extensionFolderPath);
|
|
227
|
+
console.info(chalk.green('🎉️️ All done! Happy hacking!'));
|
|
228
|
+
console.info(chalk.green(`Your extension is available at: ${extensionFolderPath}`));
|
|
229
229
|
};
|
|
230
230
|
|
|
231
|
-
const packCommand = ({ inputFilesPath, manifestPath, outputPath }) => {
|
|
232
|
-
console.info(chalk.green(`Creating an addon package from folder: ${inputFilesPath}`));
|
|
233
|
-
console.info(chalk.green(`Manifest file path: ${manifestPath}`));
|
|
234
|
-
const manifest = AddonManifest.fromFile(manifestPath);
|
|
235
|
-
const packageName = `${manifest.id}-${manifest.version}.zip`;
|
|
236
|
-
const archive = archiver('zip');
|
|
237
|
-
const zipPath = resolve(outputPath, packageName);
|
|
238
|
-
const stream = createWriteStream(zipPath);
|
|
239
|
-
stream.on('close', () => {
|
|
240
|
-
console.info(chalk.green(`Addon package "${packageName}" has been created at: ${zipPath}.`));
|
|
241
|
-
console.info(chalk.green('It can be uploaded into Addon Manager now.'));
|
|
242
|
-
});
|
|
243
|
-
archive.on('error', error => {
|
|
244
|
-
console.warn('We were unable to create a package.');
|
|
245
|
-
throw error;
|
|
246
|
-
});
|
|
247
|
-
archive.pipe(stream);
|
|
248
|
-
archive.file(manifestPath, { name: basename(manifestPath) });
|
|
249
|
-
archive.directory(inputFilesPath, basename(resolve(inputFilesPath)));
|
|
250
|
-
archive.finalize();
|
|
231
|
+
const packCommand = ({ inputFilesPath, manifestPath, outputPath }) => {
|
|
232
|
+
console.info(chalk.green(`Creating an addon package from folder: ${inputFilesPath}`));
|
|
233
|
+
console.info(chalk.green(`Manifest file path: ${manifestPath}`));
|
|
234
|
+
const manifest = AddonManifest.fromFile(manifestPath);
|
|
235
|
+
const packageName = `${manifest.id}-${manifest.version}.zip`;
|
|
236
|
+
const archive = archiver('zip');
|
|
237
|
+
const zipPath = resolve(outputPath, packageName);
|
|
238
|
+
const stream = createWriteStream(zipPath);
|
|
239
|
+
stream.on('close', () => {
|
|
240
|
+
console.info(chalk.green(`Addon package "${packageName}" has been created at: ${zipPath}.`));
|
|
241
|
+
console.info(chalk.green('It can be uploaded into Addon Manager now.'));
|
|
242
|
+
});
|
|
243
|
+
archive.on('error', error => {
|
|
244
|
+
console.warn('We were unable to create a package.');
|
|
245
|
+
throw error;
|
|
246
|
+
});
|
|
247
|
+
archive.pipe(stream);
|
|
248
|
+
archive.file(manifestPath, { name: basename(manifestPath) });
|
|
249
|
+
archive.directory(inputFilesPath, basename(resolve(inputFilesPath)));
|
|
250
|
+
archive.finalize();
|
|
251
251
|
};
|
|
252
252
|
|
|
253
|
-
const packageJson = getPackageJson();
|
|
254
|
-
const program = new Command();
|
|
255
|
-
const programName = Object.keys(packageJson.bin)[0];
|
|
256
|
-
program
|
|
257
|
-
.name(programName)
|
|
258
|
-
.description('Provides helpers to build, run and deploy addons for Tridion Experience Space')
|
|
259
|
-
.version(packageJson.version);
|
|
260
|
-
program
|
|
261
|
-
.command('create')
|
|
262
|
-
.description('Create new Tridion Experience Space addon')
|
|
263
|
-
.usage(`${programName} create`)
|
|
264
|
-
.action(createCommand);
|
|
265
|
-
program
|
|
266
|
-
.command('pack')
|
|
267
|
-
.description('Creates a package ready to be used in Addon Manager')
|
|
268
|
-
.usage(`${programName} pack`)
|
|
269
|
-
.requiredOption('-i, --input <string>', 'path to the directory with addon files')
|
|
270
|
-
.requiredOption('-m, --manifest <string>', 'path to the addon manifest file')
|
|
271
|
-
.requiredOption('-o, --output <string>', 'path where to output the package')
|
|
272
|
-
.action(args => {
|
|
273
|
-
packCommand({
|
|
274
|
-
inputFilesPath: args.input,
|
|
275
|
-
manifestPath: args.manifest,
|
|
276
|
-
outputPath: args.output,
|
|
277
|
-
});
|
|
278
|
-
});
|
|
253
|
+
const packageJson = getPackageJson();
|
|
254
|
+
const program = new Command();
|
|
255
|
+
const programName = Object.keys(packageJson.bin)[0];
|
|
256
|
+
program
|
|
257
|
+
.name(programName)
|
|
258
|
+
.description('Provides helpers to build, run and deploy addons for Tridion Experience Space')
|
|
259
|
+
.version(packageJson.version);
|
|
260
|
+
program
|
|
261
|
+
.command('create')
|
|
262
|
+
.description('Create new Tridion Experience Space addon')
|
|
263
|
+
.usage(`${programName} create`)
|
|
264
|
+
.action(createCommand);
|
|
265
|
+
program
|
|
266
|
+
.command('pack')
|
|
267
|
+
.description('Creates a package ready to be used in Addon Manager')
|
|
268
|
+
.usage(`${programName} pack`)
|
|
269
|
+
.requiredOption('-i, --input <string>', 'path to the directory with addon files')
|
|
270
|
+
.requiredOption('-m, --manifest <string>', 'path to the addon manifest file')
|
|
271
|
+
.requiredOption('-o, --output <string>', 'path where to output the package')
|
|
272
|
+
.action(args => {
|
|
273
|
+
packCommand({
|
|
274
|
+
inputFilesPath: args.input,
|
|
275
|
+
manifestPath: args.manifest,
|
|
276
|
+
outputPath: args.output,
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
279
|
program.parse(process.argv);
|
package/dist/index.js
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { resolve, basename } from 'node:path';
|
|
3
|
-
import { w as writeJsonFile, r as readJsonFile, A as AddonManifest } from './addonManifest-
|
|
3
|
+
import { w as writeJsonFile, r as readJsonFile, A as AddonManifest } from './addonManifest-45b9450a.js';
|
|
4
4
|
import 'node:fs';
|
|
5
5
|
|
|
6
|
-
class AddonConfiguration {
|
|
7
|
-
constructor(fileName, configPerExtension) {
|
|
8
|
-
Object.defineProperty(this, "fileName", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: void 0
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(this, "configPerExtension", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true,
|
|
18
|
-
value: void 0
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(this, "writeFile", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
configurable: true,
|
|
23
|
-
writable: true,
|
|
24
|
-
value: (path) => {
|
|
25
|
-
const configPath = resolve(path, this.fileName);
|
|
26
|
-
writeJsonFile(configPath, {
|
|
27
|
-
configuration: this.configPerExtension,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
this.fileName = fileName;
|
|
32
|
-
this.configPerExtension = configPerExtension;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
Object.defineProperty(AddonConfiguration, "fromFile", {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
configurable: true,
|
|
38
|
-
writable: true,
|
|
39
|
-
value: (configurationFilePath) => {
|
|
40
|
-
const configurationFile = readJsonFile(configurationFilePath);
|
|
41
|
-
const configuration = new AddonConfiguration(basename(configurationFilePath), configurationFile.configuration);
|
|
42
|
-
return configuration;
|
|
43
|
-
}
|
|
6
|
+
class AddonConfiguration {
|
|
7
|
+
constructor(fileName, configPerExtension) {
|
|
8
|
+
Object.defineProperty(this, "fileName", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true,
|
|
12
|
+
value: void 0
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(this, "configPerExtension", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true,
|
|
18
|
+
value: void 0
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(this, "writeFile", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
value: (path) => {
|
|
25
|
+
const configPath = resolve(path, this.fileName);
|
|
26
|
+
writeJsonFile(configPath, {
|
|
27
|
+
configuration: this.configPerExtension,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
this.fileName = fileName;
|
|
32
|
+
this.configPerExtension = configPerExtension;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
Object.defineProperty(AddonConfiguration, "fromFile", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
configurable: true,
|
|
38
|
+
writable: true,
|
|
39
|
+
value: (configurationFilePath) => {
|
|
40
|
+
const configurationFile = readJsonFile(configurationFilePath);
|
|
41
|
+
const configuration = new AddonConfiguration(basename(configurationFilePath), configurationFile.configuration);
|
|
42
|
+
return configuration;
|
|
43
|
+
}
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
const extensionsRequestBasePath = '/api/uiExtensionsRepository';
|
|
47
|
-
const getLocalFrontendAddon = ({ manifestPath, addonConfigPath }) => {
|
|
48
|
-
const manifest = AddonManifest.fromFile(manifestPath);
|
|
49
|
-
const addonConfiguration = addonConfigPath ? AddonConfiguration.fromFile(addonConfigPath) : undefined;
|
|
50
|
-
const localAddon = {
|
|
51
|
-
Hash: Date.now().toString(),
|
|
52
|
-
Id: 'LocalAddon',
|
|
53
|
-
Configuration: {},
|
|
54
|
-
Extensions: [],
|
|
55
|
-
};
|
|
56
|
-
const localExtensions = manifest.getFrontendExtensions();
|
|
57
|
-
localExtensions.forEach(extension => {
|
|
58
|
-
var _a;
|
|
59
|
-
localAddon.Configuration[extension.name] = (addonConfiguration === null || addonConfiguration === void 0 ? void 0 : addonConfiguration.configPerExtension[extension.name]) || {};
|
|
60
|
-
const extensionFiles = extension.files.map(filePath => `${extensionsRequestBasePath}/${extension.name}/${filePath}?hash=${Date.now()}`);
|
|
61
|
-
(_a = localAddon.Extensions) === null || _a === void 0 ? void 0 : _a.push({
|
|
62
|
-
Name: extension.name,
|
|
63
|
-
MainFile: `${extensionsRequestBasePath}/${extension.name}/${extension.main}`,
|
|
64
|
-
Contents: extensionFiles,
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
return localAddon;
|
|
46
|
+
const extensionsRequestBasePath = '/api/uiExtensionsRepository';
|
|
47
|
+
const getLocalFrontendAddon = ({ manifestPath, addonConfigPath }) => {
|
|
48
|
+
const manifest = AddonManifest.fromFile(manifestPath);
|
|
49
|
+
const addonConfiguration = addonConfigPath ? AddonConfiguration.fromFile(addonConfigPath) : undefined;
|
|
50
|
+
const localAddon = {
|
|
51
|
+
Hash: Date.now().toString(),
|
|
52
|
+
Id: 'LocalAddon',
|
|
53
|
+
Configuration: {},
|
|
54
|
+
Extensions: [],
|
|
55
|
+
};
|
|
56
|
+
const localExtensions = manifest.getFrontendExtensions();
|
|
57
|
+
localExtensions.forEach(extension => {
|
|
58
|
+
var _a;
|
|
59
|
+
localAddon.Configuration[extension.name] = (addonConfiguration === null || addonConfiguration === void 0 ? void 0 : addonConfiguration.configPerExtension[extension.name]) || {};
|
|
60
|
+
const extensionFiles = extension.files.map(filePath => `${extensionsRequestBasePath}/${extension.name}/${filePath}?hash=${Date.now()}`);
|
|
61
|
+
(_a = localAddon.Extensions) === null || _a === void 0 ? void 0 : _a.push({
|
|
62
|
+
Name: extension.name,
|
|
63
|
+
MainFile: `${extensionsRequestBasePath}/${extension.name}/${extension.main}`,
|
|
64
|
+
Contents: extensionFiles,
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
return localAddon;
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
const setupExtensionsResponse = ({ app, webAppPath, manifestPath, addonConfigPath, }) => {
|
|
71
|
-
const basePath = webAppPath.endsWith('/') ? webAppPath : `${webAppPath}/`;
|
|
72
|
-
app.get(`${basePath}api/v2.0/extensions`, (request, response) => {
|
|
73
|
-
const localAddon = getLocalFrontendAddon({
|
|
74
|
-
manifestPath,
|
|
75
|
-
addonConfigPath,
|
|
76
|
-
});
|
|
77
|
-
const liveAddons = /*await ExtensionsService.getExtensions()*/ [];
|
|
78
|
-
const result = [...liveAddons, localAddon];
|
|
79
|
-
response.json(result);
|
|
80
|
-
});
|
|
70
|
+
const setupExtensionsResponse = ({ app, webAppPath, manifestPath, addonConfigPath, }) => {
|
|
71
|
+
const basePath = webAppPath.endsWith('/') ? webAppPath : `${webAppPath}/`;
|
|
72
|
+
app.get(`${basePath}api/v2.0/extensions`, (request, response) => {
|
|
73
|
+
const localAddon = getLocalFrontendAddon({
|
|
74
|
+
manifestPath,
|
|
75
|
+
addonConfigPath,
|
|
76
|
+
});
|
|
77
|
+
const liveAddons = /*await ExtensionsService.getExtensions()*/ [];
|
|
78
|
+
const result = [...liveAddons, localAddon];
|
|
79
|
+
response.json(result);
|
|
80
|
+
});
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
export { extensionsRequestBasePath, getLocalFrontendAddon, setupExtensionsResponse };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tridion-sites/extensions-cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "CLI to develop, build and package extensions for Tridion Experience Space",
|
|
5
5
|
"author": "RWS",
|
|
6
6
|
"homepage": "https://www.rws.com",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"test": "sites-extensions"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@tridion-sites/extensions": "0.5.
|
|
35
|
-
"@tridion-sites/models": "0.1.
|
|
36
|
-
"@tridion-sites/open-api-client": "1.0.
|
|
34
|
+
"@tridion-sites/extensions": "0.5.2",
|
|
35
|
+
"@tridion-sites/models": "0.1.2",
|
|
36
|
+
"@tridion-sites/open-api-client": "1.0.5",
|
|
37
37
|
"archiver": "5.3.1",
|
|
38
38
|
"chalk": "5.2.0",
|
|
39
39
|
"commander": "10.0.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"rollup": "3.11.0",
|
|
60
60
|
"rollup-plugin-delete": "2.0.0",
|
|
61
61
|
"rollup-plugin-node-externals": "5.1.0",
|
|
62
|
-
"typescript": "
|
|
62
|
+
"typescript": "5.0.4",
|
|
63
63
|
"typescript-transform-paths": "3.4.6"
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@tridion-sites:registry=https://nexus.sdl.com/repository/npm/
|