@tridion-sites/extensions-cli 0.3.2 → 0.3.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/CHANGELOG.md +21 -0
- package/dist/addon/template/extension/package.json.hbs +31 -29
- package/dist/addon/template/extension/src/index.tsx.hbs +1 -3
- package/dist/addon/template/extension/tsconfig.json.hbs +4 -1
- package/dist/addon/template/extension/webpack.dev.config.js.hbs +1 -37
- package/dist/addon/template/extension/webpack.prod.config.js.hbs +1 -37
- package/dist/{addonManifest-30c25a45.js → addonManifest-45b9450a.js} +210 -210
- package/dist/cli.js +240 -242
- package/dist/index.js +72 -72
- package/package.json +5 -5
- package/dist/addon/template/extension/.npmrc.hbs +0 -1
- package/dist/addon/template/extension/src/index.css.hbs +0 -0
- package/dist/addon/template/extension/types/css.d.ts.hbs +0 -4
|
@@ -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 };
|