@zimbra/zimlet-cli 12.13.0 → 14.2.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/.browserslistrc +1 -0
- package/dist/cli.js +11 -17
- package/dist/commands/create.js +206 -324
- package/dist/commands/package.js +144 -93
- package/dist/entry.js +14 -12
- package/dist/index.js +89 -114
- package/dist/lib/async-command.js +8 -14
- package/dist/lib/setup.js +55 -133
- package/dist/lib/webpack/transform-config.js +8 -8
- package/dist/shims/@apollo/client/index.js +92 -82
- package/dist/shims/@apollo/client/react/components/index.js +6 -6
- package/dist/shims/@apollo/client/react/hoc/index.js +8 -8
- package/dist/shims/@apollo/client/react/index.js +16 -16
- package/dist/shims/@zimbra-client/blocks/index.js +28 -28
- package/dist/shims/@zimbra-client/browser/index.js +4 -4
- package/dist/shims/@zimbra-client/components/index.js +53 -51
- package/dist/shims/@zimbra-client/constants/index.js +7 -7
- package/dist/shims/@zimbra-client/enhancers/index.js +10 -10
- package/dist/shims/@zimbra-client/errors/index.js +5 -5
- package/dist/shims/@zimbra-client/graphql/index.js +29 -29
- package/dist/shims/@zimbra-client/hooks/graphql/index.js +8 -8
- package/dist/shims/@zimbra-client/hooks/index.js +8 -8
- package/dist/shims/@zimbra-client/platform/index.js +5 -5
- package/dist/shims/@zimbra-client/util/contacts/index.js +4 -4
- package/dist/shims/@zimbra-client/util/index.js +15 -13
- package/dist/shims/@zimbra-client/util/redux/index.js +8 -8
- package/dist/shims/clipboard-polyfill/index.js +4 -4
- package/dist/shims/index.js +2 -2
- package/dist/shims/moment/index.js +43 -43
- package/dist/shims/preact/compat/index.js +40 -52
- package/dist/shims/preact/hooks/index.js +14 -14
- package/dist/shims/preact/index.js +15 -15
- package/dist/shims/preact-context-provider/index.js +6 -6
- package/dist/shims/preact-i18n/index.js +12 -12
- package/dist/shims/preact-pwa-install/index.js +3 -3
- package/dist/shims/preact-render-to-string/index.js +5 -5
- package/dist/shims/preact-router/index.js +9 -9
- package/dist/shims/preact-router/match/index.js +4 -4
- package/dist/shims/react-redux/index.js +16 -16
- package/dist/shims/recompose/index.js +46 -46
- package/dist/shims/redux-actions/index.js +9 -9
- package/dist/util.js +11 -11
- package/dist/zimlet-style-loader.js +8 -4
- package/package-lock.json +6400 -6926
- package/package.json +41 -44
package/dist/commands/package.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
|
|
8
8
|
var _fs = _interopRequireDefault(require("fs"));
|
|
9
9
|
|
|
@@ -15,13 +15,9 @@ var _util = require("../util");
|
|
|
15
15
|
|
|
16
16
|
var _asyncCommand = _interopRequireDefault(require("../lib/async-command"));
|
|
17
17
|
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : {
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
23
|
-
|
|
24
|
-
var _default = (0, _asyncCommand["default"])({
|
|
20
|
+
var _default = (0, _asyncCommand.default)({
|
|
25
21
|
command: 'package',
|
|
26
22
|
desc: 'Package a zimlet for deployment',
|
|
27
23
|
builder: {
|
|
@@ -41,22 +37,21 @@ var _default = (0, _asyncCommand["default"])({
|
|
|
41
37
|
description: {
|
|
42
38
|
alias: 'desc',
|
|
43
39
|
description: 'Description for your zimlet',
|
|
44
|
-
|
|
45
|
-
requiresArg: true
|
|
40
|
+
default: null
|
|
46
41
|
},
|
|
47
42
|
label: {
|
|
48
43
|
alias: 'l',
|
|
49
44
|
description: 'Display name for your zimlet',
|
|
50
|
-
|
|
45
|
+
default: null
|
|
51
46
|
},
|
|
52
47
|
zimbraXVersion: {
|
|
53
48
|
description: 'https://semver.org version range of Zimbra X that the Zimlet is compatible with.',
|
|
54
|
-
|
|
49
|
+
default: '>=1.0.0',
|
|
55
50
|
requiresArg: true
|
|
56
51
|
},
|
|
57
52
|
builddir: {
|
|
58
53
|
alias: 'b',
|
|
59
|
-
|
|
54
|
+
default: './build',
|
|
60
55
|
description: 'Source directory of built artifacts to publish'
|
|
61
56
|
},
|
|
62
57
|
dest: {
|
|
@@ -65,88 +60,144 @@ var _default = (0, _asyncCommand["default"])({
|
|
|
65
60
|
description: 'Directory for packaged artifacts'
|
|
66
61
|
}
|
|
67
62
|
},
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
zimletProperties += "description = ".concat(argv.description, "\n");
|
|
122
|
-
_context.prev = 25;
|
|
123
|
-
|
|
124
|
-
_fs["default"].writeFileSync(_path["default"].resolve(builddir, propertiesFile), zimletProperties);
|
|
125
|
-
|
|
126
|
-
_context.next = 32;
|
|
127
|
-
break;
|
|
128
|
-
|
|
129
|
-
case 29:
|
|
130
|
-
_context.prev = 29;
|
|
131
|
-
_context.t2 = _context["catch"](25);
|
|
132
|
-
return _context.abrupt("return", (0, _util.error)("Failed to write properties file: ".concat(_context.t2), 1));
|
|
133
|
-
|
|
134
|
-
case 32:
|
|
135
|
-
//Zip up the contents of the build dir along with the xml file as the final zimlet deliverable
|
|
136
|
-
zipFile = new _admZip["default"]();
|
|
137
|
-
zipFile.addLocalFolder(builddir, '');
|
|
138
|
-
zipFile.writeZip(dest);
|
|
139
|
-
return _context.abrupt("return", "Successfully packaged zimlet to: ".concat(dest, "\n"));
|
|
140
|
-
|
|
141
|
-
case 36:
|
|
142
|
-
case "end":
|
|
143
|
-
return _context.stop();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}, _callee, null, [[5, 9], [14, 18], [25, 29]]);
|
|
147
|
-
}))();
|
|
63
|
+
|
|
64
|
+
async handler(argv) {
|
|
65
|
+
// normalize built files source directory and desination package dir
|
|
66
|
+
let cwd = process.cwd();
|
|
67
|
+
|
|
68
|
+
let builddir = _path.default.resolve(cwd, argv.builddir || 'build');
|
|
69
|
+
|
|
70
|
+
let dest = _path.default.resolve(cwd, argv.dest || 'pkg', `${argv.name}.zip`); // Get label and description from src/intl/en_US.json or from argument
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
const {
|
|
74
|
+
label,
|
|
75
|
+
description
|
|
76
|
+
} = getZimletLabelDescription() || argv;
|
|
77
|
+
|
|
78
|
+
if (!(label && description)) {
|
|
79
|
+
return (0, _util.error)('label and description string are not provided as argument');
|
|
80
|
+
} // Create the xml descriptor file for the zimlet
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
let xmlFile = `${argv.name}.xml`;
|
|
84
|
+
let zimletXML = `<zimlet name="${argv.name}" version="${argv.pkgVersion}" description="${description}" label="${label}" zimbraXZimletCompatibleSemVer="${argv.zimbraXVersion}">`;
|
|
85
|
+
let files;
|
|
86
|
+
|
|
87
|
+
try {
|
|
88
|
+
files = _fs.default.readdirSync(builddir);
|
|
89
|
+
} catch (err) {
|
|
90
|
+
return (0, _util.error)(`Failed to read ${builddir}: ${err}`, 1);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
files.filter(file => !file.match(/\.properties$/)).forEach(file => {
|
|
94
|
+
if (file.match(/\.js$/)) {
|
|
95
|
+
zimletXML += `\n\t<include>${file}</include>`;
|
|
96
|
+
} else if (file.match(/\.css$/)) {
|
|
97
|
+
zimletXML += `\n\t<includeCSS>${file}</includeCSS>`;
|
|
98
|
+
} else if (file !== xmlFile) {
|
|
99
|
+
zimletXML += `\n\t<resource>${file}</resource>`;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
zimletXML += '\n</zimlet>';
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
_fs.default.writeFileSync(_path.default.resolve(builddir, xmlFile), zimletXML);
|
|
106
|
+
} catch (err) {
|
|
107
|
+
return (0, _util.error)(`Failed to write XML file: ${err}`, 1);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
createLocalizationFiles(argv.name, label, description); //Zip up the contents of the build dir along with the xml file as the final zimlet deliverable
|
|
111
|
+
|
|
112
|
+
let zipFile = new _admZip.default();
|
|
113
|
+
zipFile.addLocalFolder(builddir, '');
|
|
114
|
+
zipFile.writeZip(dest);
|
|
115
|
+
return `Successfully packaged zimlet to: ${dest}\n`;
|
|
148
116
|
}
|
|
117
|
+
|
|
149
118
|
});
|
|
150
119
|
|
|
151
|
-
exports
|
|
120
|
+
exports.default = _default;
|
|
121
|
+
|
|
122
|
+
function getZimletLabelDescription() {
|
|
123
|
+
const intlDir = _path.default.resolve(process.cwd(), 'src', 'intl');
|
|
124
|
+
|
|
125
|
+
try {
|
|
126
|
+
const content = JSON.parse(_fs.default.readFileSync(_path.default.resolve(intlDir, 'en_US.json')));
|
|
127
|
+
|
|
128
|
+
if (!(content.zimlet?.label && content.zimlet?.description)) {
|
|
129
|
+
throw new Error('label or description not found');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
label: content.zimlet.label,
|
|
134
|
+
description: content.zimlet.description
|
|
135
|
+
};
|
|
136
|
+
} catch (err) {
|
|
137
|
+
(0, _util.warn)(`Failed to read src/intl/en_US.json file: ${err}. \nMake sure below content present in src/intl/en_US.json file \n
|
|
138
|
+
"zimlet": {
|
|
139
|
+
"label": "<zimlet label>",
|
|
140
|
+
"description": "<zimlet description>"
|
|
141
|
+
} \nAs a fallback we are using strings from package.json which is deprecated.\n`);
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
} // Add properties file for description and label
|
|
145
|
+
// As admin console requires properties file to display label and desciption
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
function createLocalizationFiles(zimletName, label, description) {
|
|
149
|
+
const cwd = process.cwd();
|
|
150
|
+
|
|
151
|
+
const intlDir = _path.default.resolve(cwd, 'src', 'intl');
|
|
152
|
+
|
|
153
|
+
let intlFiles;
|
|
154
|
+
createPropertyFile(zimletName, label, description);
|
|
155
|
+
|
|
156
|
+
try {
|
|
157
|
+
intlFiles = _fs.default.readdirSync(intlDir);
|
|
158
|
+
} catch (err) {
|
|
159
|
+
console.error(`Failed to read ${intlDir}: ${err}`, 1);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
intlFiles.filter(file => file.match(/\.json$/) && !file.includes('en_US')).forEach(intl => {
|
|
163
|
+
try {
|
|
164
|
+
const content = JSON.parse(_fs.default.readFileSync(_path.default.resolve(intlDir, intl)));
|
|
165
|
+
const propertiesFileName = `${zimletName}_${intl.replace('.json', '')}`;
|
|
166
|
+
const labelValue = getUnicode(content.zimlet?.label || '');
|
|
167
|
+
const descriptionValue = getUnicode(content.zimlet?.description || '');
|
|
168
|
+
createPropertyFile(propertiesFileName, labelValue, descriptionValue);
|
|
169
|
+
} catch (ex) {
|
|
170
|
+
(0, _util.error)(`Error while reading file: ${ex}`, 1);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function createPropertyFile(fileName, label, description) {
|
|
176
|
+
const builddir = _path.default.resolve(process.cwd(), 'build');
|
|
177
|
+
|
|
178
|
+
const propertiesFile = `${fileName}.properties`;
|
|
179
|
+
let zimletProperties = '\n';
|
|
180
|
+
zimletProperties += `label = ${label}\n`;
|
|
181
|
+
zimletProperties += `description = ${description}\n`;
|
|
182
|
+
|
|
183
|
+
try {
|
|
184
|
+
_fs.default.writeFileSync(_path.default.resolve(builddir, propertiesFile), zimletProperties);
|
|
185
|
+
} catch (err) {
|
|
186
|
+
return (0, _util.error)(`Failed to write properties file: ${err}`, 1);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function getUnicode(txt) {
|
|
191
|
+
let hex = '';
|
|
192
|
+
if (txt.length === 0) return;
|
|
193
|
+
|
|
194
|
+
for (let i = 0; i < txt.length; i++) {
|
|
195
|
+
const h = txt.codePointAt(i).toString(16);
|
|
196
|
+
hex += '\\u' + h.padStart(4, 0);
|
|
197
|
+
if (h.length > 4) i++;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return hex;
|
|
201
|
+
}
|
|
202
|
+
|
|
152
203
|
module.exports = exports.default;
|
package/dist/entry.js
CHANGED
|
@@ -3,16 +3,18 @@
|
|
|
3
3
|
/** This is the real webpack entry file. It manages setting up the zimlet and HMR.
|
|
4
4
|
* The user-defined entry file (index.js) is imported here via a `zimlet-cli-entrypoint` alias.
|
|
5
5
|
*/
|
|
6
|
-
(
|
|
6
|
+
(() => {
|
|
7
7
|
function init() {
|
|
8
|
-
zimlet(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
zimlet(context => {
|
|
9
|
+
let {
|
|
10
|
+
zimbra,
|
|
11
|
+
config,
|
|
12
|
+
plugins,
|
|
13
|
+
shims,
|
|
14
|
+
components,
|
|
15
|
+
store,
|
|
16
|
+
meta
|
|
17
|
+
} = context; // Add shims to the global scope to expose dependencies to Zimlets
|
|
16
18
|
// Shimmed dependencies include preact, preact-router, react-apollo
|
|
17
19
|
|
|
18
20
|
global.shims = shims;
|
|
@@ -24,11 +26,11 @@
|
|
|
24
26
|
global.ZIMLET_STYLES = [];
|
|
25
27
|
global.meta = meta;
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
let entry = require('zimlet-cli-entrypoint');
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
let r = entry && entry.default || entry; // If export is a factory, pass it context. Otherwise it's a singleton.
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
let instance = typeof r === 'function' ? r(context) : r;
|
|
32
34
|
context.styles.set(global.ZIMLET_STYLES.join('\n'));
|
|
33
35
|
return instance;
|
|
34
36
|
});
|