@todesktop/cli 1.1.0 → 1.1.1
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/build/commands/build.js +4740 -115
- package/build/commands/build.js.map +1 -1
- package/build/commands/builds.js +4224 -109
- package/build/commands/builds.js.map +1 -1
- package/build/commands/logout.js +2511 -57
- package/build/commands/logout.js.map +1 -1
- package/build/commands/release.js +3606 -89
- package/build/commands/release.js.map +1 -1
- package/build/commands/whoami.js +2511 -57
- package/build/commands/whoami.js.map +1 -1
- package/build/commands.json +28 -28
- package/package.json +9 -9
package/build/commands/whoami.js
CHANGED
|
@@ -1,58 +1,2512 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
1
|
+
// modules are defined as an array
|
|
2
|
+
// [ module function, map of requires ]
|
|
3
|
+
//
|
|
4
|
+
// map of requires is short require name -> numeric require
|
|
5
|
+
//
|
|
6
|
+
// anything defined in a previous bundle is accessed via the
|
|
7
|
+
// orig method which is the require for previous bundles
|
|
8
|
+
parcelRequire = (function (modules, cache, entry, globalName) {
|
|
9
|
+
// Save the require from previous bundle to this closure if any
|
|
10
|
+
var previousRequire = typeof parcelRequire === 'function' && parcelRequire;
|
|
11
|
+
var nodeRequire = typeof require === 'function' && require;
|
|
12
|
+
|
|
13
|
+
function newRequire(name, jumped) {
|
|
14
|
+
if (!cache[name]) {
|
|
15
|
+
if (!modules[name]) {
|
|
16
|
+
// if we cannot find the module within our internal map or
|
|
17
|
+
// cache jump to the current global require ie. the last bundle
|
|
18
|
+
// that was added to the page.
|
|
19
|
+
var currentRequire = typeof parcelRequire === 'function' && parcelRequire;
|
|
20
|
+
if (!jumped && currentRequire) {
|
|
21
|
+
return currentRequire(name, true);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// If there are other bundles on this page the require from the
|
|
25
|
+
// previous one is saved to 'previousRequire'. Repeat this as
|
|
26
|
+
// many times as there are bundles until the module is found or
|
|
27
|
+
// we exhaust the require chain.
|
|
28
|
+
if (previousRequire) {
|
|
29
|
+
return previousRequire(name, true);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Try the node require function if it exists.
|
|
33
|
+
if (nodeRequire && typeof name === 'string') {
|
|
34
|
+
return nodeRequire(name);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var err = new Error('Cannot find module \'' + name + '\'');
|
|
38
|
+
err.code = 'MODULE_NOT_FOUND';
|
|
39
|
+
throw err;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
localRequire.resolve = resolve;
|
|
43
|
+
localRequire.cache = {};
|
|
44
|
+
|
|
45
|
+
var module = cache[name] = new newRequire.Module(name);
|
|
46
|
+
|
|
47
|
+
modules[name][0].call(module.exports, localRequire, module, module.exports, this);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return cache[name].exports;
|
|
51
|
+
|
|
52
|
+
function localRequire(x){
|
|
53
|
+
return newRequire(localRequire.resolve(x));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function resolve(x){
|
|
57
|
+
return modules[name][1][x] || x;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function Module(moduleName) {
|
|
62
|
+
this.id = moduleName;
|
|
63
|
+
this.bundle = newRequire;
|
|
64
|
+
this.exports = {};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
newRequire.isParcelRequire = true;
|
|
68
|
+
newRequire.Module = Module;
|
|
69
|
+
newRequire.modules = modules;
|
|
70
|
+
newRequire.cache = cache;
|
|
71
|
+
newRequire.parent = previousRequire;
|
|
72
|
+
newRequire.register = function (id, exports) {
|
|
73
|
+
modules[id] = [function (require, module) {
|
|
74
|
+
module.exports = exports;
|
|
75
|
+
}, {}];
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
var error;
|
|
79
|
+
for (var i = 0; i < entry.length; i++) {
|
|
80
|
+
try {
|
|
81
|
+
newRequire(entry[i]);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
// Save first error but execute all entries
|
|
84
|
+
if (!error) {
|
|
85
|
+
error = e;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (entry.length) {
|
|
91
|
+
// Expose entry point to Node, AMD or browser globals
|
|
92
|
+
// Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
|
|
93
|
+
var mainExports = newRequire(entry[entry.length - 1]);
|
|
94
|
+
|
|
95
|
+
// CommonJS
|
|
96
|
+
if (typeof exports === "object" && typeof module !== "undefined") {
|
|
97
|
+
module.exports = mainExports;
|
|
98
|
+
|
|
99
|
+
// RequireJS
|
|
100
|
+
} else if (typeof define === "function" && define.amd) {
|
|
101
|
+
define(function () {
|
|
102
|
+
return mainExports;
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// <script>
|
|
106
|
+
} else if (globalName) {
|
|
107
|
+
this[globalName] = mainExports;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Override the current require with this new one
|
|
112
|
+
parcelRequire = newRequire;
|
|
113
|
+
|
|
114
|
+
if (error) {
|
|
115
|
+
// throw error from earlier, _after updating parcelRequire_
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return newRequire;
|
|
120
|
+
})({"../lib/utilities/checkIfReactIsUsable.js":[function(require,module,exports) {
|
|
121
|
+
"use strict";
|
|
122
|
+
|
|
123
|
+
Object.defineProperty(exports, "__esModule", {
|
|
124
|
+
value: true
|
|
125
|
+
});
|
|
126
|
+
exports.default = void 0;
|
|
127
|
+
|
|
128
|
+
var _react = require("react");
|
|
129
|
+
|
|
130
|
+
/*
|
|
131
|
+
This should be called at the top of all commands to test if React
|
|
132
|
+
is OK and if not, to exit cleanly.
|
|
133
|
+
|
|
134
|
+
If React throws an error (e.g. when there are multiple versions of
|
|
135
|
+
React in the customer's dependency tree), then we need to exit with
|
|
136
|
+
a non-zero error code and not with an uncaught exception somewhere.
|
|
137
|
+
|
|
138
|
+
These parameters exist only to make things more testable
|
|
139
|
+
*/
|
|
140
|
+
var _default = ({
|
|
141
|
+
cons = console,
|
|
142
|
+
proc = process
|
|
143
|
+
} = {}) => {
|
|
144
|
+
try {
|
|
145
|
+
(0, _react.useState)(null);
|
|
146
|
+
} catch (e) {
|
|
147
|
+
cons.error(e);
|
|
148
|
+
proc.exit(1);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
exports.default = _default;
|
|
153
|
+
},{}],"../lib/utilities/configStore.js":[function(require,module,exports) {
|
|
154
|
+
"use strict";
|
|
155
|
+
|
|
156
|
+
Object.defineProperty(exports, "__esModule", {
|
|
157
|
+
value: true
|
|
158
|
+
});
|
|
159
|
+
exports.setConfig = exports.setAuthConfig = exports.jwtTokenConfigKey = exports.getConfig = exports.getAuthConfig = exports.emailConfigKey = exports.deleteAuthConfig = exports.accessTokenConfigKey = void 0;
|
|
160
|
+
|
|
161
|
+
var fs = _interopRequireWildcard(require("fs"));
|
|
162
|
+
|
|
163
|
+
var _del = _interopRequireDefault(require("del"));
|
|
164
|
+
|
|
165
|
+
var _conf = _interopRequireDefault(require("conf"));
|
|
166
|
+
|
|
167
|
+
var _xdgBasedir = _interopRequireDefault(require("xdg-basedir"));
|
|
168
|
+
|
|
169
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
170
|
+
|
|
171
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
172
|
+
|
|
173
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
174
|
+
|
|
175
|
+
const config = new _conf.default({
|
|
176
|
+
configName: "todesktop-cli"
|
|
177
|
+
});
|
|
178
|
+
const accessTokenConfigKey = "accessToken";
|
|
179
|
+
exports.accessTokenConfigKey = accessTokenConfigKey;
|
|
180
|
+
const emailConfigKey = "email";
|
|
181
|
+
exports.emailConfigKey = emailConfigKey;
|
|
182
|
+
const jwtTokenConfigKey = "jwtToken";
|
|
183
|
+
exports.jwtTokenConfigKey = jwtTokenConfigKey;
|
|
184
|
+
|
|
185
|
+
const setConfig = (key, value) => config.set(key, value);
|
|
186
|
+
|
|
187
|
+
exports.setConfig = setConfig;
|
|
188
|
+
|
|
189
|
+
const getConfig = key => config.get(key);
|
|
190
|
+
|
|
191
|
+
exports.getConfig = getConfig;
|
|
192
|
+
|
|
193
|
+
const setAuthConfig = (email, accessToken, jwtToken) => {
|
|
194
|
+
setConfig(emailConfigKey, email);
|
|
195
|
+
setConfig(accessTokenConfigKey, accessToken);
|
|
196
|
+
setConfig(jwtTokenConfigKey, jwtToken);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
exports.setAuthConfig = setAuthConfig;
|
|
200
|
+
|
|
201
|
+
const getAuthConfig = () => {
|
|
202
|
+
const accessToken = getConfig(accessTokenConfigKey);
|
|
203
|
+
const jwtToken = getConfig(jwtTokenConfigKey);
|
|
204
|
+
const email = getConfig(emailConfigKey);
|
|
205
|
+
return {
|
|
206
|
+
accessToken,
|
|
207
|
+
jwtToken,
|
|
208
|
+
email
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
exports.getAuthConfig = getAuthConfig;
|
|
213
|
+
|
|
214
|
+
const deleteAuthConfig = () => {
|
|
215
|
+
config.delete(emailConfigKey);
|
|
216
|
+
config.delete(accessTokenConfigKey);
|
|
217
|
+
config.delete(jwtTokenConfigKey);
|
|
218
|
+
}; // TODO - Delete by end of April: backwards compatibility for old configstore
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
exports.deleteAuthConfig = deleteAuthConfig;
|
|
222
|
+
const oldConfigPath = `${_xdgBasedir.default.config}/configstore/config.json.json`;
|
|
223
|
+
|
|
224
|
+
if (fs.existsSync(oldConfigPath)) {
|
|
225
|
+
try {
|
|
226
|
+
// copy config from old json file to new json file, delete old file
|
|
227
|
+
const {
|
|
228
|
+
email,
|
|
229
|
+
accessToken,
|
|
230
|
+
jwtToken
|
|
231
|
+
} = require(oldConfigPath);
|
|
232
|
+
|
|
233
|
+
setAuthConfig(email, accessToken, jwtToken);
|
|
234
|
+
(0, _del.default)(oldConfigPath, {
|
|
235
|
+
force: true
|
|
236
|
+
});
|
|
237
|
+
} catch (err) {
|
|
238
|
+
// if invalid json, delete file to prompt new login
|
|
239
|
+
(0, _del.default)(oldConfigPath, {
|
|
240
|
+
force: true
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
},{}],"../lib/components/ErrorBoundary.js":[function(require,module,exports) {
|
|
245
|
+
"use strict";
|
|
246
|
+
|
|
247
|
+
Object.defineProperty(exports, "__esModule", {
|
|
248
|
+
value: true
|
|
249
|
+
});
|
|
250
|
+
exports.default = void 0;
|
|
251
|
+
|
|
252
|
+
var _react = _interopRequireDefault(require("react"));
|
|
253
|
+
|
|
254
|
+
var Sentry = _interopRequireWildcard(require("@sentry/node"));
|
|
255
|
+
|
|
256
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
257
|
+
|
|
258
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
259
|
+
|
|
260
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
261
|
+
|
|
262
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
263
|
+
|
|
264
|
+
class ErrorBoundary extends _react.default.Component {
|
|
265
|
+
constructor(props) {
|
|
266
|
+
super(props);
|
|
267
|
+
this.state = {
|
|
268
|
+
eventId: null,
|
|
269
|
+
error: null
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
static getDerivedStateFromError(error) {
|
|
274
|
+
return {
|
|
275
|
+
error
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
componentDidCatch(error, errorInfo) {
|
|
280
|
+
Sentry.withScope(scope => {
|
|
281
|
+
scope.setExtras(errorInfo);
|
|
282
|
+
const eventId = Sentry.captureException(error);
|
|
283
|
+
this.setState({
|
|
284
|
+
eventId
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
render() {
|
|
290
|
+
if (this.state.error) {
|
|
291
|
+
throw this.state.error;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return this.props.children;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
ErrorBoundary.propTypes = {
|
|
300
|
+
children: _propTypes.default.object
|
|
301
|
+
};
|
|
302
|
+
var _default = ErrorBoundary;
|
|
303
|
+
exports.default = _default;
|
|
304
|
+
},{}],"../lib/utilities/exitIfCLIOutOfDate.js":[function(require,module,exports) {
|
|
305
|
+
"use strict";
|
|
306
|
+
|
|
307
|
+
Object.defineProperty(exports, "__esModule", {
|
|
308
|
+
value: true
|
|
309
|
+
});
|
|
310
|
+
exports.default = void 0;
|
|
311
|
+
|
|
312
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
313
|
+
|
|
314
|
+
var _isInstalledGlobally = _interopRequireDefault(require("is-installed-globally"));
|
|
315
|
+
|
|
316
|
+
var _latestVersion = _interopRequireDefault(require("latest-version"));
|
|
317
|
+
|
|
318
|
+
var _pkgUp = _interopRequireDefault(require("pkg-up"));
|
|
319
|
+
|
|
320
|
+
var _semver = _interopRequireDefault(require("semver"));
|
|
321
|
+
|
|
322
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
323
|
+
|
|
324
|
+
var _default = () => {
|
|
325
|
+
// Ignore during tests
|
|
326
|
+
if (process.env.AVA_PATH) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
const pkg = require(_pkgUp.default.sync({
|
|
331
|
+
cwd: __dirname
|
|
332
|
+
}));
|
|
333
|
+
|
|
334
|
+
(0, _latestVersion.default)(pkg.name).then(latest => {
|
|
335
|
+
if (_semver.default.gt(latest, pkg.version)) {
|
|
336
|
+
const commandToUpdate = _chalk.default.greenBright(`npm install ${_isInstalledGlobally.default ? "-g" : "--save-dev"} @todesktop/cli`);
|
|
337
|
+
|
|
338
|
+
console.log(`Your version of @todesktop/cli is out of date.\nRun ${commandToUpdate} to update to v${latest}.`);
|
|
339
|
+
|
|
340
|
+
if (!_semver.default.satisfies(latest, `^${pkg.version}`)) {
|
|
341
|
+
console.log(`CLI is exiting because it is out out of date.`);
|
|
342
|
+
process.exit(1);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
exports.default = _default;
|
|
349
|
+
},{}],"../package.json":[function(require,module,exports) {
|
|
350
|
+
module.exports = {
|
|
351
|
+
"private": false,
|
|
352
|
+
"publishConfig": {
|
|
353
|
+
"access": "public"
|
|
354
|
+
},
|
|
355
|
+
"name": "@todesktop/cli",
|
|
356
|
+
"version": "1.1.1",
|
|
357
|
+
"license": "MIT",
|
|
358
|
+
"author": "Dave Jeffery <dave@todesktop.com> (http://www.todesktop.com/)",
|
|
359
|
+
"homepage": "https://todesktop.com/cli",
|
|
360
|
+
"bugs": {
|
|
361
|
+
"email": "dave@todesktop.com"
|
|
362
|
+
},
|
|
363
|
+
"bin": {
|
|
364
|
+
"todesktop": "./build/cli.js"
|
|
365
|
+
},
|
|
366
|
+
"engines": {
|
|
367
|
+
"node": ">=12"
|
|
368
|
+
},
|
|
369
|
+
"scripts": {
|
|
370
|
+
"prepare": "npx force-resolutions",
|
|
371
|
+
"dev": "cp-cli dev.env .env && pastel dev",
|
|
372
|
+
"dev:prod": "cp-cli prod.env .env && pastel dev",
|
|
373
|
+
"build": "cross-env NODE_ENV=production pastel build && cp-cli prod.env .env && cp node_modules/pastel/boot.js build/boot.js && sed -i'.bak' 's@pastel\\/boot@.\\/boot@g' build/cli.js",
|
|
374
|
+
"lint": "eslint .",
|
|
375
|
+
"lint--fix": "eslint . --fix",
|
|
376
|
+
"release": "npm run build && npx np --tag=latest",
|
|
377
|
+
"release-beta": "npm run build && npx np --any-branch --no-tests --tag=beta",
|
|
378
|
+
"test": "npm run build && ava",
|
|
379
|
+
"test--watch": "npm test -- --watch"
|
|
380
|
+
},
|
|
381
|
+
"files": ["build", "docs", ".env", "LICENSE", "README.md"],
|
|
382
|
+
"dependencies": {
|
|
383
|
+
"@sentry/node": "^5.27.2",
|
|
384
|
+
"ajv": "^6.12.6",
|
|
385
|
+
"analytics-node": "^4.0.1",
|
|
386
|
+
"archiver": "^5.2.0",
|
|
387
|
+
"axios": "^0.21.1",
|
|
388
|
+
"better-ajv-errors": "^1.2.0",
|
|
389
|
+
"bunyan": "^1.8.14",
|
|
390
|
+
"camelcase-keys": "^5.2.0",
|
|
391
|
+
"chalk": "^4.1.0",
|
|
392
|
+
"conf": "^7.1.2",
|
|
393
|
+
"date-fns": "^2.28.0",
|
|
394
|
+
"decamelize": "^1.2.0",
|
|
395
|
+
"del": "^6.0.0",
|
|
396
|
+
"dotenv": "^8.2.0",
|
|
397
|
+
"du": "^1.0.0",
|
|
398
|
+
"email-regex": "^4.0.0",
|
|
399
|
+
"fast-glob": "^3.2.4",
|
|
400
|
+
"final-form": "^4.20.1",
|
|
401
|
+
"find-up": "^5.0.0",
|
|
402
|
+
"firebase": "^7.24.0",
|
|
403
|
+
"git-rev-sync": "^3.0.2",
|
|
404
|
+
"ink": "^3.2.0",
|
|
405
|
+
"ink-gradient": "^2.0.0",
|
|
406
|
+
"ink-link": "^2.0.0",
|
|
407
|
+
"ink-progress-bar": "^3.0.0",
|
|
408
|
+
"ink-select-input": "^4.2.1",
|
|
409
|
+
"ink-text-input": "^4.0.1",
|
|
410
|
+
"is-installed-globally": "^0.3.2",
|
|
411
|
+
"latest-version": "^5.1.0",
|
|
412
|
+
"lodash.throttle": "^4.1.1",
|
|
413
|
+
"parse-author": "^2.0.0",
|
|
414
|
+
"pkg-up": "^3.1.0",
|
|
415
|
+
"pretty-bytes": "^5.4.1",
|
|
416
|
+
"prop-types": "^15.7.2",
|
|
417
|
+
"react": "^17.0.2",
|
|
418
|
+
"react-final-form": "^6.5.1",
|
|
419
|
+
"semver": "^7.3.2",
|
|
420
|
+
"stream-to-array": "^2.3.0",
|
|
421
|
+
"superagent": "^7.1.3",
|
|
422
|
+
"uuid": "^8.3.1",
|
|
423
|
+
"xdg-basedir": "^4.0.0",
|
|
424
|
+
"yargs": "^15.4.1"
|
|
425
|
+
},
|
|
426
|
+
"devDependencies": {
|
|
427
|
+
"@ava/babel": "^1.0.1",
|
|
428
|
+
"@babel/core": "^7.12.3",
|
|
429
|
+
"@babel/plugin-transform-runtime": "^7.12.1",
|
|
430
|
+
"@babel/preset-env": "^7.11.5",
|
|
431
|
+
"@babel/register": "^7.12.1",
|
|
432
|
+
"@types/bunyan": "^1.8.6",
|
|
433
|
+
"ava": "^4.3.1",
|
|
434
|
+
"babel-preset-es2015": "^6.24.1",
|
|
435
|
+
"cp-cli": "^2.0.0",
|
|
436
|
+
"cross-env": "^7.0.2",
|
|
437
|
+
"eslint": "^7.6.0",
|
|
438
|
+
"eslint-config-prettier": "^6.11.0",
|
|
439
|
+
"eslint-config-standard": "^14.1.1",
|
|
440
|
+
"eslint-plugin-import": "^2.22.1",
|
|
441
|
+
"eslint-plugin-node": "^11.1.0",
|
|
442
|
+
"eslint-plugin-prettier": "^3.1.4",
|
|
443
|
+
"eslint-plugin-promise": "^4.2.1",
|
|
444
|
+
"eslint-plugin-react": "^7.21.4",
|
|
445
|
+
"eslint-plugin-react-hooks": "^4.2.0",
|
|
446
|
+
"eslint-plugin-standard": "^4.0.1",
|
|
447
|
+
"execa": "^4.0.3",
|
|
448
|
+
"extract-zip": "^2.0.1",
|
|
449
|
+
"fs-extra": "^9.0.1",
|
|
450
|
+
"husky": "^4.3.0",
|
|
451
|
+
"is-ci": "^2.0.0",
|
|
452
|
+
"lint-staged": "^10.2.11",
|
|
453
|
+
"pastel": "^1.1.1",
|
|
454
|
+
"prettier": "^2.1.2",
|
|
455
|
+
"proxyquire": "^2.1.3",
|
|
456
|
+
"sinon": "^9.0.3"
|
|
457
|
+
},
|
|
458
|
+
"ava": {
|
|
459
|
+
"files": ["test/**/*.js", "!test/fixtures/**/*", "!test/utilities/**/*"],
|
|
460
|
+
"require": ["@babel/register"],
|
|
461
|
+
"timeout": "10m"
|
|
462
|
+
},
|
|
463
|
+
"lint-staged": {
|
|
464
|
+
"**/*.js": ["eslint . --fix", "git add"]
|
|
465
|
+
},
|
|
466
|
+
"husky": {
|
|
467
|
+
"hooks": {
|
|
468
|
+
"pre-commit": "lint-staged"
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
"overrides": {
|
|
472
|
+
"pastel": {
|
|
473
|
+
"parcel-bundler": {
|
|
474
|
+
"deasync": "0.1.24"
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
"resolutions": {
|
|
479
|
+
"pastel/parcel-bundler/deasync": "0.1.24",
|
|
480
|
+
"ink": "3.2.0",
|
|
481
|
+
"react": "17.0.2"
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
},{}],"../lib/utilities/projectConfig/loadConfig.js":[function(require,module,exports) {
|
|
485
|
+
"use strict";
|
|
486
|
+
|
|
487
|
+
Object.defineProperty(exports, "__esModule", {
|
|
488
|
+
value: true
|
|
489
|
+
});
|
|
490
|
+
exports.default = void 0;
|
|
491
|
+
|
|
492
|
+
// This is its own file just so we can mock it more easily
|
|
493
|
+
var _default = configPath => require(configPath);
|
|
494
|
+
|
|
495
|
+
exports.default = _default;
|
|
496
|
+
},{}],"../lib/utilities/projectConfig/resolveConfigPaths.js":[function(require,module,exports) {
|
|
497
|
+
"use strict";
|
|
498
|
+
|
|
499
|
+
Object.defineProperty(exports, "__esModule", {
|
|
500
|
+
value: true
|
|
501
|
+
});
|
|
502
|
+
exports.default = void 0;
|
|
503
|
+
|
|
504
|
+
var path = _interopRequireWildcard(require("path"));
|
|
505
|
+
|
|
506
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
507
|
+
|
|
508
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
509
|
+
|
|
510
|
+
var _default = ({
|
|
511
|
+
config,
|
|
512
|
+
projectRoot
|
|
513
|
+
}) => {
|
|
514
|
+
const appRoot = config.appPath ? path.isAbsolute(config.appPath) ? config.appPath : path.join(projectRoot, config.appPath) : projectRoot;
|
|
515
|
+
|
|
516
|
+
const transformIfExists = (value, transformer) => value ? transformer(value) : undefined;
|
|
517
|
+
|
|
518
|
+
const resolvePath = filePath => path.isAbsolute(filePath) ? filePath : path.join(projectRoot, filePath);
|
|
519
|
+
|
|
520
|
+
const result = { ...config,
|
|
521
|
+
appPath: appRoot,
|
|
522
|
+
icon: resolvePath(config.icon)
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
if (config.extraContentFiles) {
|
|
526
|
+
result.extraContentFiles = transformIfExists(config.extraContentFiles, extraContentFiles => extraContentFiles.map(extraContentFile => ({ ...extraContentFile,
|
|
527
|
+
from: resolvePath(extraContentFile.from)
|
|
528
|
+
})));
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
if (config.extraResources) {
|
|
532
|
+
result.extraResources = transformIfExists(config.extraResources, extraResources => extraResources.map(extraResource => ({ ...extraResource,
|
|
533
|
+
from: resolvePath(extraResource.from)
|
|
534
|
+
})));
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
if (config.linux) {
|
|
538
|
+
result.linux = { ...config.linux
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
if (config.linux.icon) {
|
|
542
|
+
result.linux.icon = resolvePath(config.linux.icon);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
if (config.mac) {
|
|
547
|
+
result.mac = { ...config.mac
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
if (config.mac.entitlements) {
|
|
551
|
+
result.mac.entitlements = resolvePath(config.mac.entitlements);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
if (config.mac.icon) {
|
|
555
|
+
result.mac.icon = resolvePath(config.mac.icon);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
if (config.dmg) {
|
|
560
|
+
if (config.dmg.background) {
|
|
561
|
+
result.dmg.background = resolvePath(config.dmg.background);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
if (config.windows) {
|
|
566
|
+
result.windows = { ...config.windows
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
if (config.windows.icon) {
|
|
570
|
+
result.windows.icon = resolvePath(config.windows.icon);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
return result;
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
exports.default = _default;
|
|
578
|
+
},{}],"../lib/utilities/projectConfig/schema/packageJSON.js":[function(require,module,exports) {
|
|
579
|
+
"use strict";
|
|
580
|
+
|
|
581
|
+
Object.defineProperty(exports, "__esModule", {
|
|
582
|
+
value: true
|
|
583
|
+
});
|
|
584
|
+
exports.default = void 0;
|
|
585
|
+
|
|
586
|
+
var _default = context => {
|
|
587
|
+
return {
|
|
588
|
+
type: "object",
|
|
589
|
+
required: ["author", "dependencies", "devDependencies", "homepage", "name", "version"],
|
|
590
|
+
properties: {
|
|
591
|
+
author: {
|
|
592
|
+
npmAuthor: {}
|
|
593
|
+
},
|
|
594
|
+
dependencies: {
|
|
595
|
+
type: "object",
|
|
596
|
+
required: ["@todesktop/runtime"],
|
|
597
|
+
// custom keyword that checks package names aren't included in dependencies
|
|
598
|
+
excludedDependencies: {
|
|
599
|
+
dependencyKey: "dependencies",
|
|
600
|
+
blacklist: ["@todesktop/cli"]
|
|
601
|
+
},
|
|
602
|
+
properties: {
|
|
603
|
+
"@todesktop/runtime": {
|
|
604
|
+
type: "string"
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
},
|
|
608
|
+
devDependencies: {
|
|
609
|
+
type: "object",
|
|
610
|
+
required: ["electron"],
|
|
611
|
+
properties: {
|
|
612
|
+
electron: {
|
|
613
|
+
type: "string",
|
|
614
|
+
semanticVersion: {
|
|
615
|
+
packageName: "electron",
|
|
616
|
+
mustBeExact: true
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
},
|
|
621
|
+
name: {
|
|
622
|
+
type: "string",
|
|
623
|
+
minLength: 1
|
|
624
|
+
},
|
|
625
|
+
scripts: {
|
|
626
|
+
type: "object",
|
|
627
|
+
properties: {
|
|
628
|
+
"todesktop:beforeInstall": {
|
|
629
|
+
type: "string",
|
|
630
|
+
file: {
|
|
631
|
+
from: context.projectRoot,
|
|
632
|
+
mustBeFile: true
|
|
633
|
+
}
|
|
634
|
+
},
|
|
635
|
+
"todesktop:afterPack": {
|
|
636
|
+
type: "string",
|
|
637
|
+
file: {
|
|
638
|
+
from: context.projectRoot,
|
|
639
|
+
mustBeFile: true
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
},
|
|
644
|
+
version: {
|
|
645
|
+
type: "string",
|
|
646
|
+
semanticVersion: {}
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
exports.default = _default;
|
|
653
|
+
},{}],"../lib/utilities/projectConfig/validatePackageJSON.js":[function(require,module,exports) {
|
|
654
|
+
"use strict";
|
|
655
|
+
|
|
656
|
+
Object.defineProperty(exports, "__esModule", {
|
|
657
|
+
value: true
|
|
658
|
+
});
|
|
659
|
+
exports.default = void 0;
|
|
660
|
+
|
|
661
|
+
var _ajv = _interopRequireDefault(require("ajv"));
|
|
662
|
+
|
|
663
|
+
var _betterAjvErrors = _interopRequireDefault(require("better-ajv-errors"));
|
|
664
|
+
|
|
665
|
+
var _addCustomKeywords = _interopRequireDefault(require("./addCustomKeywords"));
|
|
666
|
+
|
|
667
|
+
var _packageJSON = _interopRequireDefault(require("./schema/packageJSON"));
|
|
668
|
+
|
|
669
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
670
|
+
|
|
671
|
+
var _default = (pkg, pkgPath, context) => {
|
|
672
|
+
const ajv = new _ajv.default({
|
|
673
|
+
allErrors: true,
|
|
674
|
+
jsonPointers: true
|
|
675
|
+
});
|
|
676
|
+
(0, _addCustomKeywords.default)(ajv, context);
|
|
677
|
+
const schema = (0, _packageJSON.default)(context);
|
|
678
|
+
const validate = ajv.compile(schema);
|
|
679
|
+
|
|
680
|
+
if (!validate(pkg)) {
|
|
681
|
+
const output = (0, _betterAjvErrors.default)(schema, pkg, validate.errors, {
|
|
682
|
+
indent: 2
|
|
683
|
+
});
|
|
684
|
+
const error = new Error(`package.json invalid (${pkgPath}); \n${output}`);
|
|
685
|
+
error.isValidationError = true; // This throws and bubbles all the way up to the user
|
|
686
|
+
|
|
687
|
+
throw error;
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
|
|
691
|
+
exports.default = _default;
|
|
692
|
+
},{"./addCustomKeywords":"../lib/utilities/projectConfig/addCustomKeywords.js","./schema/packageJSON":"../lib/utilities/projectConfig/schema/packageJSON.js"}],"../lib/utilities/projectConfig/addCustomKeywords.js":[function(require,module,exports) {
|
|
693
|
+
"use strict";
|
|
694
|
+
|
|
695
|
+
Object.defineProperty(exports, "__esModule", {
|
|
696
|
+
value: true
|
|
697
|
+
});
|
|
698
|
+
exports.default = void 0;
|
|
699
|
+
|
|
700
|
+
var _emailRegex = _interopRequireDefault(require("email-regex"));
|
|
701
|
+
|
|
702
|
+
var fs = _interopRequireWildcard(require("fs"));
|
|
703
|
+
|
|
704
|
+
var path = _interopRequireWildcard(require("path"));
|
|
705
|
+
|
|
706
|
+
var _parseAuthor = _interopRequireDefault(require("parse-author"));
|
|
707
|
+
|
|
708
|
+
var semver = _interopRequireWildcard(require("semver"));
|
|
709
|
+
|
|
710
|
+
var _validatePackageJSON = _interopRequireDefault(require("./validatePackageJSON"));
|
|
711
|
+
|
|
712
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
713
|
+
|
|
714
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
715
|
+
|
|
716
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
717
|
+
|
|
718
|
+
/*
|
|
719
|
+
See https://ajv.js.org/custom.html
|
|
720
|
+
*/
|
|
721
|
+
var _default = (ajv, context) => {
|
|
722
|
+
// validate that dependencies object doesn't contain packageNames in the blacklist
|
|
723
|
+
ajv.addKeyword("excludedDependencies", {
|
|
724
|
+
validate: function validate(schema, data) {
|
|
725
|
+
let matchingPackages = schema.blacklist.filter(packageName => data[packageName]);
|
|
726
|
+
|
|
727
|
+
if (matchingPackages.length) {
|
|
728
|
+
validate.errors = [{
|
|
729
|
+
keyword: "Dependency",
|
|
730
|
+
message: `${matchingPackages.join(", ")} should not be in ${schema.dependencyKey}`,
|
|
731
|
+
dataPath: `/${schema.dependencyKey}`
|
|
732
|
+
}];
|
|
733
|
+
return false;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
return true;
|
|
737
|
+
}
|
|
738
|
+
});
|
|
739
|
+
ajv.addKeyword("email", {
|
|
740
|
+
type: "string",
|
|
741
|
+
minLength: 5,
|
|
742
|
+
validate: function validate(schema, data) {
|
|
743
|
+
if (!(0, _emailRegex.default)({
|
|
744
|
+
exact: true
|
|
745
|
+
}).test(data)) {
|
|
746
|
+
validate.errors = [{
|
|
747
|
+
keyword: "email",
|
|
748
|
+
message: "invalid"
|
|
749
|
+
}];
|
|
750
|
+
return false;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
return true;
|
|
754
|
+
}
|
|
755
|
+
});
|
|
756
|
+
ajv.addKeyword("file", {
|
|
757
|
+
type: "string",
|
|
758
|
+
validate: function validate(schema, data) {
|
|
759
|
+
const mustBeDirectory = schema.mustBeDirectory || schema.mustBeElectronApp; // Value is empty
|
|
760
|
+
|
|
761
|
+
if (!data.trim().length) {
|
|
762
|
+
if (schema.isOptional) {
|
|
763
|
+
return true;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
validate.errors = [{
|
|
767
|
+
keyword: schema.mustBeDirectory ? "Directory" : "File",
|
|
768
|
+
message: "is empty"
|
|
769
|
+
}];
|
|
770
|
+
return false;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
const filePath = path.isAbsolute(data) ? data : path.join(schema.from, data); // Isn't in project
|
|
774
|
+
|
|
775
|
+
if (path.relative(schema.from, filePath).startsWith("..")) {
|
|
776
|
+
validate.errors = [{
|
|
777
|
+
keyword: mustBeDirectory ? "Directory" : "File",
|
|
778
|
+
message: `is not in project (${filePath})`
|
|
779
|
+
}];
|
|
780
|
+
return false;
|
|
781
|
+
} // Extension isn't allowed
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
if (schema.extensions && !schema.extensions.includes(path.extname(filePath).substr(1))) {
|
|
785
|
+
validate.errors = [{
|
|
786
|
+
keyword: "File extension",
|
|
787
|
+
message: `invalid. ${path.extname(data)} Must be${schema.extensions > 1 ? "one of the following:" : ""} "${schema.extensions.join('", "')}"`
|
|
788
|
+
}];
|
|
789
|
+
return false;
|
|
790
|
+
} // Doesn't exist
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
if (!fs.existsSync(filePath)) {
|
|
794
|
+
validate.errors = [{
|
|
795
|
+
keyword: mustBeDirectory ? "Directory" : "File",
|
|
796
|
+
message: `does not exist (${filePath})`
|
|
797
|
+
}];
|
|
798
|
+
return false;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
const stats = fs.statSync(filePath);
|
|
802
|
+
|
|
803
|
+
if (mustBeDirectory && stats.isFile()) {
|
|
804
|
+
validate.errors = [{
|
|
805
|
+
keyword: "Directory",
|
|
806
|
+
message: `must be a directory, not a file (${filePath})`
|
|
807
|
+
}];
|
|
808
|
+
return false;
|
|
809
|
+
} else if (schema.mustBeFile && stats.isDirectory()) {
|
|
810
|
+
validate.errors = [{
|
|
811
|
+
keyword: "File",
|
|
812
|
+
message: `must be a file, not a directory (${filePath})`
|
|
813
|
+
}];
|
|
814
|
+
return false;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
if (schema.mustBeElectronApp) {
|
|
818
|
+
const appRoot = path.resolve(filePath);
|
|
819
|
+
const pkgPath = path.join(appRoot, "package.json");
|
|
820
|
+
|
|
821
|
+
if (!fs.existsSync(pkgPath)) {
|
|
822
|
+
validate.errors = [{
|
|
823
|
+
keyword: "App",
|
|
824
|
+
message: `invalid. There is no package.json at ${pkgPath}`
|
|
825
|
+
}];
|
|
826
|
+
return false;
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
let pkg;
|
|
830
|
+
|
|
831
|
+
try {
|
|
832
|
+
pkg = require(pkgPath);
|
|
833
|
+
} catch (e) {
|
|
834
|
+
validate.errors = [{
|
|
835
|
+
keyword: "App",
|
|
836
|
+
message: `invalid. Invalid JSON in package.json (${pkgPath})`
|
|
837
|
+
}];
|
|
838
|
+
return false;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
context.projectRoot = appRoot; // This throws and bubbles all the way up to the user
|
|
842
|
+
|
|
843
|
+
(0, _validatePackageJSON.default)(pkg, pkgPath, context); // Validate that either an index.js or valid "main" property exists
|
|
844
|
+
|
|
845
|
+
const mainFilePath = pkg.main;
|
|
846
|
+
|
|
847
|
+
if (mainFilePath) {
|
|
848
|
+
const resolvedMainFilePath = path.join(appRoot, mainFilePath);
|
|
849
|
+
|
|
850
|
+
if (!fs.existsSync(resolvedMainFilePath)) {
|
|
851
|
+
validate.errors = [{
|
|
852
|
+
keyword: "App",
|
|
853
|
+
message: `invalid. The "main" file specified in your package.json (${mainFilePath}) does not exist (${resolvedMainFilePath})`
|
|
854
|
+
}];
|
|
855
|
+
return false;
|
|
856
|
+
}
|
|
857
|
+
} else {
|
|
858
|
+
if (!fs.existsSync(path.join(appRoot, "index.js"))) {
|
|
859
|
+
validate.errors = [{
|
|
860
|
+
keyword: "App",
|
|
861
|
+
message: 'invalid. There is neither a "main" property in your package.json nor an index.js at the root of your app'
|
|
862
|
+
}];
|
|
863
|
+
return false;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
return true;
|
|
869
|
+
},
|
|
870
|
+
errors: true
|
|
871
|
+
});
|
|
872
|
+
ajv.addKeyword("npmAuthor", {
|
|
873
|
+
validate: function validate(schema, data) {
|
|
874
|
+
const dataType = typeof data;
|
|
875
|
+
|
|
876
|
+
if (dataType === "undefined") {
|
|
877
|
+
return true;
|
|
878
|
+
} else if (dataType === "string") {
|
|
879
|
+
const parsedAuthor = (0, _parseAuthor.default)(data);
|
|
880
|
+
|
|
881
|
+
if (!parsedAuthor || !parsedAuthor.email) {
|
|
882
|
+
validate.errors = [{
|
|
883
|
+
keyword: "author",
|
|
884
|
+
message: 'invalid. If you\'re using a string, it must look something like "Barney Rubble <b@rubble.com>", see https://docs.npmjs.com/files/package.json#people-fields-author-contributors'
|
|
885
|
+
}];
|
|
886
|
+
return false;
|
|
887
|
+
}
|
|
888
|
+
} else if (dataType === "object") {
|
|
889
|
+
if (typeof data.name === "undefined") {
|
|
890
|
+
validate.errors = [{
|
|
891
|
+
keyword: "author",
|
|
892
|
+
message: `invalid. "name" property is missing.`
|
|
893
|
+
}];
|
|
894
|
+
return false;
|
|
895
|
+
} else {
|
|
896
|
+
if (typeof data.name !== "string") {
|
|
897
|
+
validate.errors = [{
|
|
898
|
+
keyword: "author",
|
|
899
|
+
message: `.name invalid. It must be a string`
|
|
900
|
+
}];
|
|
901
|
+
return false;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
if (typeof data.email === "undefined") {
|
|
905
|
+
validate.errors = [{
|
|
906
|
+
keyword: "author",
|
|
907
|
+
message: `invalid. "email" property is missing.`
|
|
908
|
+
}];
|
|
909
|
+
return false;
|
|
910
|
+
} else {
|
|
911
|
+
if (typeof data.email === "string") {
|
|
912
|
+
if (!(0, _emailRegex.default)({
|
|
913
|
+
exact: true
|
|
914
|
+
}).test(data.email)) {
|
|
915
|
+
validate.errors = [{
|
|
916
|
+
keyword: "author",
|
|
917
|
+
message: `.email invalid. It does not look like an email.`
|
|
918
|
+
}];
|
|
919
|
+
return false;
|
|
920
|
+
}
|
|
921
|
+
} else {
|
|
922
|
+
validate.errors = [{
|
|
923
|
+
keyword: "author",
|
|
924
|
+
message: `.email invalid. It must be a string.`
|
|
925
|
+
}];
|
|
926
|
+
return false;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
} else {
|
|
931
|
+
// Neither object nor string
|
|
932
|
+
validate.errors = [{
|
|
933
|
+
keyword: "author",
|
|
934
|
+
message: "invalid. It must either be an object or string. See https://docs.npmjs.com/files/package.json#people-fields-author-contributors"
|
|
935
|
+
}];
|
|
936
|
+
return false;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
return true;
|
|
940
|
+
},
|
|
941
|
+
errors: true
|
|
942
|
+
});
|
|
943
|
+
ajv.addKeyword("semanticVersion", {
|
|
944
|
+
type: "string",
|
|
945
|
+
minLength: 5,
|
|
946
|
+
validate: function validate(schema, data) {
|
|
947
|
+
const keyword = (schema.packageName ? `${schema.packageName} ` : "") + "version";
|
|
948
|
+
|
|
949
|
+
if (!(semver.valid(data) || semver.validRange(data))) {
|
|
950
|
+
validate.errors = [{
|
|
951
|
+
keyword,
|
|
952
|
+
message: "invalid. It must be a semantic version (see https://semver.org/)"
|
|
953
|
+
}];
|
|
954
|
+
return false;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
if (schema.mustBeExact && (data.startsWith("~") || data.startsWith("^"))) {
|
|
958
|
+
validate.errors = [{
|
|
959
|
+
keyword,
|
|
960
|
+
message: "invalid. It must be an exact version. Good: 9.0.0. Bad: ^9.0.0"
|
|
961
|
+
}];
|
|
962
|
+
return false;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
return true;
|
|
966
|
+
}
|
|
967
|
+
});
|
|
968
|
+
};
|
|
969
|
+
|
|
970
|
+
exports.default = _default;
|
|
971
|
+
},{"./validatePackageJSON":"../lib/utilities/projectConfig/validatePackageJSON.js"}],"../lib/utilities/projectConfig/schema/full.js":[function(require,module,exports) {
|
|
972
|
+
"use strict";
|
|
973
|
+
|
|
974
|
+
Object.defineProperty(exports, "__esModule", {
|
|
975
|
+
value: true
|
|
976
|
+
});
|
|
977
|
+
exports.default = void 0;
|
|
978
|
+
|
|
979
|
+
const getItemOrArrayOfItemsSchema = itemSchema => {
|
|
980
|
+
return {
|
|
981
|
+
oneOf: [itemSchema, {
|
|
982
|
+
type: "array",
|
|
983
|
+
items: itemSchema
|
|
984
|
+
}]
|
|
985
|
+
};
|
|
986
|
+
};
|
|
987
|
+
|
|
988
|
+
var _default = context => {
|
|
989
|
+
const getIconSchema = (additionalAllowedExtensions = []) => {
|
|
990
|
+
return {
|
|
991
|
+
type: "string",
|
|
992
|
+
file: {
|
|
993
|
+
from: context.projectRoot,
|
|
994
|
+
extensions: ["icns", "png", ...additionalAllowedExtensions],
|
|
995
|
+
mustBeFile: true
|
|
996
|
+
},
|
|
997
|
+
minLength: 3
|
|
998
|
+
};
|
|
999
|
+
};
|
|
1000
|
+
|
|
1001
|
+
return {
|
|
1002
|
+
type: "object",
|
|
1003
|
+
required: ["id", "icon", "schemaVersion"],
|
|
1004
|
+
properties: {
|
|
1005
|
+
appId: {
|
|
1006
|
+
type: "string",
|
|
1007
|
+
minLength: 1
|
|
1008
|
+
},
|
|
1009
|
+
appFiles: {
|
|
1010
|
+
type: "array",
|
|
1011
|
+
items: {
|
|
1012
|
+
type: "string",
|
|
1013
|
+
minLength: 1
|
|
1014
|
+
},
|
|
1015
|
+
minItems: 1
|
|
1016
|
+
},
|
|
1017
|
+
appProtocolScheme: {
|
|
1018
|
+
type: "string",
|
|
1019
|
+
minLength: 1
|
|
1020
|
+
},
|
|
1021
|
+
appPath: {
|
|
1022
|
+
type: "string",
|
|
1023
|
+
file: {
|
|
1024
|
+
from: context.projectRoot,
|
|
1025
|
+
isOptional: true,
|
|
1026
|
+
mustBeElectronApp: true
|
|
1027
|
+
}
|
|
1028
|
+
},
|
|
1029
|
+
copyright: {
|
|
1030
|
+
type: "string",
|
|
1031
|
+
minLength: 1
|
|
1032
|
+
},
|
|
1033
|
+
electronMirror: {
|
|
1034
|
+
type: "string",
|
|
1035
|
+
format: "uri"
|
|
1036
|
+
},
|
|
1037
|
+
electronVersion: {
|
|
1038
|
+
type: "string",
|
|
1039
|
+
minLength: 1
|
|
1040
|
+
},
|
|
1041
|
+
extraContentFiles: {
|
|
1042
|
+
type: "array",
|
|
1043
|
+
items: {
|
|
1044
|
+
type: "object",
|
|
1045
|
+
required: ["from"],
|
|
1046
|
+
properties: {
|
|
1047
|
+
from: {
|
|
1048
|
+
type: "string",
|
|
1049
|
+
file: {
|
|
1050
|
+
from: context.projectRoot
|
|
1051
|
+
}
|
|
1052
|
+
},
|
|
1053
|
+
to: {
|
|
1054
|
+
type: "string"
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
},
|
|
1059
|
+
extraResources: {
|
|
1060
|
+
type: "array",
|
|
1061
|
+
items: {
|
|
1062
|
+
type: "object",
|
|
1063
|
+
required: ["from"],
|
|
1064
|
+
properties: {
|
|
1065
|
+
from: {
|
|
1066
|
+
type: "string",
|
|
1067
|
+
file: {
|
|
1068
|
+
from: context.projectRoot
|
|
1069
|
+
}
|
|
1070
|
+
},
|
|
1071
|
+
to: {
|
|
1072
|
+
type: "string"
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
},
|
|
1077
|
+
fileAssociations: {
|
|
1078
|
+
type: "array",
|
|
1079
|
+
items: {
|
|
1080
|
+
type: "object",
|
|
1081
|
+
required: ["ext"],
|
|
1082
|
+
properties: {
|
|
1083
|
+
ext: getItemOrArrayOfItemsSchema({
|
|
1084
|
+
type: "string",
|
|
1085
|
+
minLength: 1
|
|
1086
|
+
}),
|
|
1087
|
+
description: {
|
|
1088
|
+
type: "string",
|
|
1089
|
+
minLength: 1
|
|
1090
|
+
},
|
|
1091
|
+
name: {
|
|
1092
|
+
type: "string",
|
|
1093
|
+
minLength: 1
|
|
1094
|
+
},
|
|
1095
|
+
mimeType: {
|
|
1096
|
+
type: "string",
|
|
1097
|
+
minLength: 1
|
|
1098
|
+
},
|
|
1099
|
+
icon: {
|
|
1100
|
+
type: "string",
|
|
1101
|
+
minLength: 1
|
|
1102
|
+
},
|
|
1103
|
+
role: {
|
|
1104
|
+
type: "string",
|
|
1105
|
+
minLength: 1
|
|
1106
|
+
},
|
|
1107
|
+
isPackage: {
|
|
1108
|
+
type: "boolean"
|
|
1109
|
+
},
|
|
1110
|
+
rank: {
|
|
1111
|
+
type: "string",
|
|
1112
|
+
minLength: 1
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
},
|
|
1116
|
+
minItems: 1
|
|
1117
|
+
},
|
|
1118
|
+
filesForDistribution: {
|
|
1119
|
+
type: "array",
|
|
1120
|
+
items: {
|
|
1121
|
+
type: "string",
|
|
1122
|
+
minLength: 1
|
|
1123
|
+
},
|
|
1124
|
+
minItems: 1
|
|
1125
|
+
},
|
|
1126
|
+
icon: getIconSchema(),
|
|
1127
|
+
linux: {
|
|
1128
|
+
properties: {
|
|
1129
|
+
category: {
|
|
1130
|
+
type: "string",
|
|
1131
|
+
minLength: 1
|
|
1132
|
+
},
|
|
1133
|
+
icon: getIconSchema()
|
|
1134
|
+
}
|
|
1135
|
+
},
|
|
1136
|
+
id: {
|
|
1137
|
+
type: "string",
|
|
1138
|
+
minLength: 1
|
|
1139
|
+
},
|
|
1140
|
+
mac: {
|
|
1141
|
+
properties: {
|
|
1142
|
+
category: {
|
|
1143
|
+
type: "string",
|
|
1144
|
+
minLength: 1
|
|
1145
|
+
},
|
|
1146
|
+
additionalBinariesToSign: {
|
|
1147
|
+
type: "array",
|
|
1148
|
+
items: {
|
|
1149
|
+
type: "string",
|
|
1150
|
+
minLength: 1
|
|
1151
|
+
}
|
|
1152
|
+
},
|
|
1153
|
+
entitlements: {
|
|
1154
|
+
type: "string",
|
|
1155
|
+
file: {
|
|
1156
|
+
from: context.projectRoot,
|
|
1157
|
+
extensions: ["plist"],
|
|
1158
|
+
mustBeFile: true
|
|
1159
|
+
},
|
|
1160
|
+
minLength: 1
|
|
1161
|
+
},
|
|
1162
|
+
extendInfo: {
|
|
1163
|
+
type: "object"
|
|
1164
|
+
},
|
|
1165
|
+
icon: getIconSchema()
|
|
1166
|
+
}
|
|
1167
|
+
},
|
|
1168
|
+
dmg: {
|
|
1169
|
+
properties: {
|
|
1170
|
+
background: {
|
|
1171
|
+
type: "string",
|
|
1172
|
+
file: {
|
|
1173
|
+
from: context.projectRoot,
|
|
1174
|
+
extensions: ["tiff"],
|
|
1175
|
+
mustBeFile: true
|
|
1176
|
+
},
|
|
1177
|
+
minLength: 1
|
|
1178
|
+
},
|
|
1179
|
+
artifactName: {
|
|
1180
|
+
type: "string",
|
|
1181
|
+
minLength: 1
|
|
1182
|
+
},
|
|
1183
|
+
backgroundColor: {
|
|
1184
|
+
type: "string",
|
|
1185
|
+
minLength: 1
|
|
1186
|
+
},
|
|
1187
|
+
iconSize: {
|
|
1188
|
+
type: "number"
|
|
1189
|
+
},
|
|
1190
|
+
iconTextSize: {
|
|
1191
|
+
type: "number"
|
|
1192
|
+
},
|
|
1193
|
+
title: {
|
|
1194
|
+
type: "string",
|
|
1195
|
+
minLength: 1
|
|
1196
|
+
},
|
|
1197
|
+
contents: {
|
|
1198
|
+
type: "array",
|
|
1199
|
+
items: {
|
|
1200
|
+
type: "object",
|
|
1201
|
+
properties: {
|
|
1202
|
+
x: {
|
|
1203
|
+
type: "number"
|
|
1204
|
+
},
|
|
1205
|
+
y: {
|
|
1206
|
+
type: "number"
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
},
|
|
1211
|
+
window: {
|
|
1212
|
+
type: "object",
|
|
1213
|
+
properties: {
|
|
1214
|
+
x: {
|
|
1215
|
+
type: "number"
|
|
1216
|
+
},
|
|
1217
|
+
y: {
|
|
1218
|
+
type: "number"
|
|
1219
|
+
},
|
|
1220
|
+
width: {
|
|
1221
|
+
type: "number"
|
|
1222
|
+
},
|
|
1223
|
+
height: {
|
|
1224
|
+
type: "number"
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
},
|
|
1230
|
+
schemaVersion: {
|
|
1231
|
+
type: "number",
|
|
1232
|
+
minimum: 1,
|
|
1233
|
+
maximum: 1
|
|
1234
|
+
},
|
|
1235
|
+
snap: {
|
|
1236
|
+
properties: {
|
|
1237
|
+
after: {
|
|
1238
|
+
type: "array",
|
|
1239
|
+
items: {
|
|
1240
|
+
type: "string",
|
|
1241
|
+
minLength: 1
|
|
1242
|
+
}
|
|
1243
|
+
},
|
|
1244
|
+
appPartStage: {
|
|
1245
|
+
type: "array",
|
|
1246
|
+
items: {
|
|
1247
|
+
type: "string",
|
|
1248
|
+
minLength: 1
|
|
1249
|
+
}
|
|
1250
|
+
},
|
|
1251
|
+
assumes: getItemOrArrayOfItemsSchema({
|
|
1252
|
+
type: "string",
|
|
1253
|
+
minLength: 1
|
|
1254
|
+
}),
|
|
1255
|
+
autoStart: {
|
|
1256
|
+
type: "boolean"
|
|
1257
|
+
},
|
|
1258
|
+
buildPackages: {
|
|
1259
|
+
type: "array",
|
|
1260
|
+
items: {
|
|
1261
|
+
type: "string",
|
|
1262
|
+
minLength: 1
|
|
1263
|
+
}
|
|
1264
|
+
},
|
|
1265
|
+
confinement: {
|
|
1266
|
+
type: "string",
|
|
1267
|
+
enum: ["classic", "devmode", "strict"]
|
|
1268
|
+
},
|
|
1269
|
+
environment: {
|
|
1270
|
+
type: "object"
|
|
1271
|
+
},
|
|
1272
|
+
grade: {
|
|
1273
|
+
type: "string",
|
|
1274
|
+
enum: ["devel", "stable"]
|
|
1275
|
+
},
|
|
1276
|
+
layout: {
|
|
1277
|
+
type: "object"
|
|
1278
|
+
},
|
|
1279
|
+
plugs: {
|
|
1280
|
+
type: "array",
|
|
1281
|
+
items: {
|
|
1282
|
+
anyOf: [{
|
|
1283
|
+
type: "string",
|
|
1284
|
+
minLength: 1
|
|
1285
|
+
}, {
|
|
1286
|
+
type: "object"
|
|
1287
|
+
}]
|
|
1288
|
+
}
|
|
1289
|
+
},
|
|
1290
|
+
stagePackages: {
|
|
1291
|
+
type: "array",
|
|
1292
|
+
items: {
|
|
1293
|
+
type: "string",
|
|
1294
|
+
minLength: 1
|
|
1295
|
+
}
|
|
1296
|
+
},
|
|
1297
|
+
summary: {
|
|
1298
|
+
type: "string",
|
|
1299
|
+
maxLength: 78
|
|
1300
|
+
},
|
|
1301
|
+
useTemplateApp: {
|
|
1302
|
+
type: "boolean"
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
},
|
|
1306
|
+
uploadSizeLimit: {
|
|
1307
|
+
type: "number"
|
|
1308
|
+
},
|
|
1309
|
+
windows: {
|
|
1310
|
+
properties: {
|
|
1311
|
+
icon: getIconSchema(["ico"])
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
};
|
|
1316
|
+
};
|
|
1317
|
+
|
|
1318
|
+
exports.default = _default;
|
|
1319
|
+
},{}],"../lib/utilities/projectConfig/validateConfig.js":[function(require,module,exports) {
|
|
1320
|
+
"use strict";
|
|
1321
|
+
|
|
1322
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1323
|
+
value: true
|
|
1324
|
+
});
|
|
1325
|
+
exports.default = void 0;
|
|
1326
|
+
|
|
1327
|
+
var _ajv = _interopRequireDefault(require("ajv"));
|
|
1328
|
+
|
|
1329
|
+
var _betterAjvErrors = _interopRequireDefault(require("better-ajv-errors"));
|
|
1330
|
+
|
|
1331
|
+
var _addCustomKeywords = _interopRequireDefault(require("./addCustomKeywords"));
|
|
1332
|
+
|
|
1333
|
+
var _full = _interopRequireDefault(require("./schema/full"));
|
|
1334
|
+
|
|
1335
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1336
|
+
|
|
1337
|
+
var _default = ({
|
|
1338
|
+
config,
|
|
1339
|
+
projectRoot
|
|
1340
|
+
}) => {
|
|
1341
|
+
const context = {
|
|
1342
|
+
projectRoot
|
|
1343
|
+
};
|
|
1344
|
+
const schema = (0, _full.default)(context);
|
|
1345
|
+
const ajv = new _ajv.default({
|
|
1346
|
+
allErrors: true,
|
|
1347
|
+
jsonPointers: true
|
|
1348
|
+
});
|
|
1349
|
+
(0, _addCustomKeywords.default)(ajv, context);
|
|
1350
|
+
const validate = ajv.compile(schema);
|
|
1351
|
+
|
|
1352
|
+
if (!validate(config)) {
|
|
1353
|
+
const output = (0, _betterAjvErrors.default)(schema, config, validate.errors, {
|
|
1354
|
+
indent: 2
|
|
1355
|
+
});
|
|
1356
|
+
throw new Error(`todesktop.json invalid. \nLearn more here: https://www.npmjs.com/package/@todesktop/cli#project-configuration-todesktopjson \n\n${output}`);
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
if (config.productName) {
|
|
1360
|
+
throw new Error(`todesktop.json invalid.
|
|
1361
|
+
|
|
1362
|
+
The "productName" property is no longer supported in todesktop.json. Please remove it and add it to your app's package.json instead.
|
|
1363
|
+
|
|
1364
|
+
We made this change because Electron also uses the "productName" if it exists in your app's package.json. If you do not add it to your package.json, your app name will default to the value of the "name" property in your package.json.`);
|
|
1365
|
+
}
|
|
1366
|
+
};
|
|
1367
|
+
|
|
1368
|
+
exports.default = _default;
|
|
1369
|
+
},{"./addCustomKeywords":"../lib/utilities/projectConfig/addCustomKeywords.js","./schema/full":"../lib/utilities/projectConfig/schema/full.js"}],"../lib/utilities/projectConfig/getProjectConfig.js":[function(require,module,exports) {
|
|
1370
|
+
"use strict";
|
|
1371
|
+
|
|
1372
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1373
|
+
value: true
|
|
1374
|
+
});
|
|
1375
|
+
exports.default = void 0;
|
|
1376
|
+
|
|
1377
|
+
var _path = require("path");
|
|
1378
|
+
|
|
1379
|
+
var _findUp = _interopRequireDefault(require("find-up"));
|
|
1380
|
+
|
|
1381
|
+
var _loadConfig = _interopRequireDefault(require("./loadConfig"));
|
|
1382
|
+
|
|
1383
|
+
var _resolveConfigPaths = _interopRequireDefault(require("./resolveConfigPaths"));
|
|
1384
|
+
|
|
1385
|
+
var _validateConfig = _interopRequireDefault(require("./validateConfig"));
|
|
1386
|
+
|
|
1387
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1388
|
+
|
|
1389
|
+
var _default = () => {
|
|
1390
|
+
const configPath = _findUp.default.sync("todesktop.json");
|
|
1391
|
+
|
|
1392
|
+
if (!configPath) {
|
|
1393
|
+
throw new Error("Can not find todesktop.json in this folder or any parent folders");
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
const projectRoot = (0, _path.dirname)(configPath); // This will throw if it's not valid JSON
|
|
1397
|
+
|
|
1398
|
+
const config = (0, _loadConfig.default)(configPath);
|
|
1399
|
+
config.appPath = config.appPath || "."; // This will throw if invalid
|
|
1400
|
+
|
|
1401
|
+
(0, _validateConfig.default)({
|
|
1402
|
+
config,
|
|
1403
|
+
projectRoot
|
|
1404
|
+
});
|
|
1405
|
+
const result = (0, _resolveConfigPaths.default)({
|
|
1406
|
+
config,
|
|
1407
|
+
projectRoot
|
|
1408
|
+
});
|
|
1409
|
+
return {
|
|
1410
|
+
config: result,
|
|
1411
|
+
unprocessedConfig: config,
|
|
1412
|
+
projectRoot
|
|
1413
|
+
};
|
|
1414
|
+
};
|
|
1415
|
+
|
|
1416
|
+
exports.default = _default;
|
|
1417
|
+
},{"./loadConfig":"../lib/utilities/projectConfig/loadConfig.js","./resolveConfigPaths":"../lib/utilities/projectConfig/resolveConfigPaths.js","./validateConfig":"../lib/utilities/projectConfig/validateConfig.js"}],"../lib/utilities/getEnvironmentVariables.js":[function(require,module,exports) {
|
|
1418
|
+
"use strict";
|
|
1419
|
+
|
|
1420
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1421
|
+
value: true
|
|
1422
|
+
});
|
|
1423
|
+
exports.default = void 0;
|
|
1424
|
+
|
|
1425
|
+
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
1426
|
+
|
|
1427
|
+
var path = _interopRequireWildcard(require("path"));
|
|
1428
|
+
|
|
1429
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
1430
|
+
|
|
1431
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
1432
|
+
|
|
1433
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1434
|
+
|
|
1435
|
+
let hasInitialized = false;
|
|
1436
|
+
|
|
1437
|
+
const init = () => {
|
|
1438
|
+
if (hasInitialized) {
|
|
1439
|
+
return;
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
_dotenv.default.config({
|
|
1443
|
+
path: path.resolve(__dirname, "..", "..", ".env")
|
|
1444
|
+
});
|
|
1445
|
+
|
|
1446
|
+
hasInitialized = true;
|
|
1447
|
+
};
|
|
1448
|
+
|
|
1449
|
+
var _default = () => {
|
|
1450
|
+
init();
|
|
1451
|
+
return process.env;
|
|
1452
|
+
};
|
|
1453
|
+
|
|
1454
|
+
exports.default = _default;
|
|
1455
|
+
},{}],"../lib/utilities/initSentry.js":[function(require,module,exports) {
|
|
1456
|
+
"use strict";
|
|
1457
|
+
|
|
1458
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1459
|
+
value: true
|
|
1460
|
+
});
|
|
1461
|
+
exports.default = void 0;
|
|
1462
|
+
|
|
1463
|
+
var Sentry = _interopRequireWildcard(require("@sentry/node"));
|
|
1464
|
+
|
|
1465
|
+
var _os = _interopRequireDefault(require("os"));
|
|
1466
|
+
|
|
1467
|
+
var _package = _interopRequireDefault(require("../../package.json"));
|
|
1468
|
+
|
|
1469
|
+
var _configStore = require("../utilities/configStore");
|
|
1470
|
+
|
|
1471
|
+
var _getProjectConfig = _interopRequireDefault(require("../utilities/projectConfig/getProjectConfig"));
|
|
1472
|
+
|
|
1473
|
+
var _path = _interopRequireDefault(require("path"));
|
|
1474
|
+
|
|
1475
|
+
var _getEnvironmentVariables = _interopRequireDefault(require("./getEnvironmentVariables"));
|
|
1476
|
+
|
|
1477
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1478
|
+
|
|
1479
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
1480
|
+
|
|
1481
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
1482
|
+
|
|
1483
|
+
var _default = () => {
|
|
1484
|
+
const {
|
|
1485
|
+
TODESKTOP_CLI_SENTRY_DSN
|
|
1486
|
+
} = (0, _getEnvironmentVariables.default)();
|
|
1487
|
+
|
|
1488
|
+
if (!TODESKTOP_CLI_SENTRY_DSN) {
|
|
1489
|
+
// Don't initialise Sentry
|
|
1490
|
+
return;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
Sentry.init({
|
|
1494
|
+
dsn: TODESKTOP_CLI_SENTRY_DSN
|
|
1495
|
+
});
|
|
1496
|
+
Sentry.configureScope(scope => {
|
|
1497
|
+
try {
|
|
1498
|
+
scope.setUser({
|
|
1499
|
+
email: (0, _configStore.getAuthConfig)().email
|
|
1500
|
+
});
|
|
1501
|
+
} catch (err) {}
|
|
1502
|
+
|
|
1503
|
+
try {
|
|
1504
|
+
scope.setContext("os", {
|
|
1505
|
+
name: _os.default.platform(),
|
|
1506
|
+
version: _os.default.release()
|
|
1507
|
+
});
|
|
1508
|
+
} catch (err) {}
|
|
1509
|
+
|
|
1510
|
+
try {
|
|
1511
|
+
scope.setContext("runtime", {
|
|
1512
|
+
name: "Node.js",
|
|
1513
|
+
version: process.version
|
|
1514
|
+
});
|
|
1515
|
+
} catch (err) {}
|
|
1516
|
+
|
|
1517
|
+
try {
|
|
1518
|
+
scope.setContext("app", {
|
|
1519
|
+
app_name: _package.default.name,
|
|
1520
|
+
app_version: _package.default.version
|
|
1521
|
+
});
|
|
1522
|
+
} catch (err) {}
|
|
1523
|
+
|
|
1524
|
+
try {
|
|
1525
|
+
const configResult = (0, _getProjectConfig.default)();
|
|
1526
|
+
scope.setExtra("config", configResult);
|
|
1527
|
+
} catch (err) {}
|
|
1528
|
+
});
|
|
1529
|
+
};
|
|
1530
|
+
|
|
1531
|
+
exports.default = _default;
|
|
1532
|
+
},{"../../package.json":"../package.json","../utilities/configStore":"../lib/utilities/configStore.js","../utilities/projectConfig/getProjectConfig":"../lib/utilities/projectConfig/getProjectConfig.js","./getEnvironmentVariables":"../lib/utilities/getEnvironmentVariables.js"}],"../lib/utilities/onCommand.js":[function(require,module,exports) {
|
|
1533
|
+
"use strict";
|
|
1534
|
+
|
|
1535
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1536
|
+
value: true
|
|
1537
|
+
});
|
|
1538
|
+
exports.default = void 0;
|
|
1539
|
+
|
|
1540
|
+
var _exitIfCLIOutOfDate = _interopRequireDefault(require("./exitIfCLIOutOfDate"));
|
|
1541
|
+
|
|
1542
|
+
var _initSentry = _interopRequireDefault(require("./initSentry"));
|
|
1543
|
+
|
|
1544
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1545
|
+
|
|
1546
|
+
const defaultOptions = {
|
|
1547
|
+
sentry: true,
|
|
1548
|
+
exitIfOutOfDate: true
|
|
1549
|
+
};
|
|
1550
|
+
|
|
1551
|
+
var _default = options => {
|
|
1552
|
+
const {
|
|
1553
|
+
sentry,
|
|
1554
|
+
exitIfOutOfDate
|
|
1555
|
+
} = { ...defaultOptions,
|
|
1556
|
+
...options
|
|
1557
|
+
};
|
|
1558
|
+
|
|
1559
|
+
if (sentry) {
|
|
1560
|
+
(0, _initSentry.default)();
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
if (exitIfOutOfDate) {
|
|
1564
|
+
(0, _exitIfCLIOutOfDate.default)();
|
|
1565
|
+
}
|
|
1566
|
+
};
|
|
1567
|
+
|
|
1568
|
+
exports.default = _default;
|
|
1569
|
+
},{"./exitIfCLIOutOfDate":"../lib/utilities/exitIfCLIOutOfDate.js","./initSentry":"../lib/utilities/initSentry.js"}],"../lib/components/TextInput.js":[function(require,module,exports) {
|
|
1570
|
+
"use strict";
|
|
1571
|
+
|
|
1572
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1573
|
+
value: true
|
|
1574
|
+
});
|
|
1575
|
+
exports.default = void 0;
|
|
1576
|
+
|
|
1577
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
1578
|
+
|
|
1579
|
+
var _inkTextInput = _interopRequireDefault(require("ink-text-input"));
|
|
1580
|
+
|
|
1581
|
+
var _react = _interopRequireDefault(require("react"));
|
|
1582
|
+
|
|
1583
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
1584
|
+
|
|
1585
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1586
|
+
|
|
1587
|
+
const TextInput = ({
|
|
1588
|
+
onBlur,
|
|
1589
|
+
onFocus,
|
|
1590
|
+
...props
|
|
1591
|
+
}) => {
|
|
1592
|
+
_react.default.useEffect(() => {
|
|
1593
|
+
onFocus();
|
|
1594
|
+
return onBlur;
|
|
1595
|
+
}, [onFocus, onBlur]);
|
|
1596
|
+
|
|
1597
|
+
return /*#__PURE__*/_react.default.createElement(_inkTextInput.default, (0, _extends2.default)({}, props, {
|
|
1598
|
+
showCursor: true
|
|
1599
|
+
}));
|
|
1600
|
+
};
|
|
1601
|
+
|
|
1602
|
+
TextInput.propTypes = {
|
|
1603
|
+
onBlur: _propTypes.default.func,
|
|
1604
|
+
onFocus: _propTypes.default.func
|
|
1605
|
+
};
|
|
1606
|
+
var _default = TextInput;
|
|
1607
|
+
exports.default = _default;
|
|
1608
|
+
},{}],"../lib/utilities/getCliVersion.js":[function(require,module,exports) {
|
|
1609
|
+
"use strict";
|
|
1610
|
+
|
|
1611
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1612
|
+
value: true
|
|
1613
|
+
});
|
|
1614
|
+
exports.default = void 0;
|
|
1615
|
+
|
|
1616
|
+
var _pkgUp = _interopRequireDefault(require("pkg-up"));
|
|
1617
|
+
|
|
1618
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1619
|
+
|
|
1620
|
+
const cliVersion = require(_pkgUp.default.sync({
|
|
1621
|
+
cwd: __dirname
|
|
1622
|
+
})).version;
|
|
1623
|
+
|
|
1624
|
+
var _default = () => cliVersion;
|
|
1625
|
+
|
|
1626
|
+
exports.default = _default;
|
|
1627
|
+
},{}],"../lib/utilities/logger.js":[function(require,module,exports) {
|
|
1628
|
+
"use strict";
|
|
1629
|
+
|
|
1630
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1631
|
+
value: true
|
|
1632
|
+
});
|
|
1633
|
+
exports.default = void 0;
|
|
1634
|
+
|
|
1635
|
+
var _bunyan = _interopRequireDefault(require("bunyan"));
|
|
1636
|
+
|
|
1637
|
+
var fs = _interopRequireWildcard(require("fs"));
|
|
1638
|
+
|
|
1639
|
+
var os = _interopRequireWildcard(require("os"));
|
|
1640
|
+
|
|
1641
|
+
var path = _interopRequireWildcard(require("path"));
|
|
1642
|
+
|
|
1643
|
+
var Sentry = _interopRequireWildcard(require("@sentry/node"));
|
|
1644
|
+
|
|
1645
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
1646
|
+
|
|
1647
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
1648
|
+
|
|
1649
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1650
|
+
|
|
1651
|
+
let logger;
|
|
1652
|
+
|
|
1653
|
+
try {
|
|
1654
|
+
const name = "todesktop-cli";
|
|
1655
|
+
let parentDirectory;
|
|
1656
|
+
const homePath = os.homedir();
|
|
1657
|
+
|
|
1658
|
+
if (process.platform === "darwin") {
|
|
1659
|
+
parentDirectory = path.join(homePath, "Library", "Logs", name);
|
|
1660
|
+
} else if (process.platform === "win32") {
|
|
1661
|
+
parentDirectory = path.join(process.env.APPDATA || path.join(homePath, "AppData", "Roaming"), name, "logs");
|
|
1662
|
+
} else {
|
|
1663
|
+
parentDirectory = path.join(process.env.XDG_CONFIG_HOME || path.join(homePath, ".config"), name, "logs");
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
fs.mkdirSync(parentDirectory, {
|
|
1667
|
+
recursive: true
|
|
1668
|
+
});
|
|
1669
|
+
logger = _bunyan.default.createLogger({
|
|
1670
|
+
name,
|
|
1671
|
+
src: true,
|
|
1672
|
+
streams: [{
|
|
1673
|
+
level: "debug",
|
|
1674
|
+
path: path.join(parentDirectory, "main.log")
|
|
1675
|
+
}]
|
|
1676
|
+
});
|
|
1677
|
+
} catch (e) {
|
|
1678
|
+
// Ignore
|
|
1679
|
+
const noOp = () => {};
|
|
1680
|
+
|
|
1681
|
+
logger = {
|
|
1682
|
+
debug: noOp,
|
|
1683
|
+
error: noOp,
|
|
1684
|
+
fatal: noOp,
|
|
1685
|
+
info: noOp,
|
|
1686
|
+
trace: noOp,
|
|
1687
|
+
warn: noOp
|
|
1688
|
+
};
|
|
1689
|
+
|
|
1690
|
+
try {
|
|
1691
|
+
Sentry.captureException(e);
|
|
1692
|
+
} catch (err) {// Ignore
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
var _default = logger;
|
|
1697
|
+
exports.default = _default;
|
|
1698
|
+
},{}],"../lib/utilities/firestore.js":[function(require,module,exports) {
|
|
1699
|
+
"use strict";
|
|
1700
|
+
|
|
1701
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1702
|
+
value: true
|
|
1703
|
+
});
|
|
1704
|
+
exports.signInWithCustomToken = exports.onUserAuth = exports.default = exports.currentUser = void 0;
|
|
1705
|
+
|
|
1706
|
+
var firebase = _interopRequireWildcard(require("firebase/app"));
|
|
1707
|
+
|
|
1708
|
+
require("firebase/firestore");
|
|
1709
|
+
|
|
1710
|
+
require("firebase/auth");
|
|
1711
|
+
|
|
1712
|
+
var _getEnvironmentVariables = _interopRequireDefault(require("./getEnvironmentVariables"));
|
|
1713
|
+
|
|
1714
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1715
|
+
|
|
1716
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
1717
|
+
|
|
1718
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
1719
|
+
|
|
1720
|
+
const environmentVariables = (0, _getEnvironmentVariables.default)(); // if (environmentVariables.NODE_ENV === "development") {
|
|
1721
|
+
// if (true) {
|
|
1722
|
+
// firebase.firestore.setLogLevel("debug");
|
|
1723
|
+
// }
|
|
1724
|
+
|
|
1725
|
+
const firebaseDB = firebase.initializeApp({
|
|
1726
|
+
apiKey: environmentVariables.TODESKTOP_CLI_FIREBASE_API_KEY,
|
|
1727
|
+
authDomain: environmentVariables.TODESKTOP_CLI_FIREBASE_AUTH_DOMAIN,
|
|
1728
|
+
databaseURL: environmentVariables.TODESKTOP_CLI_FIREBASE_DATABASE_URL,
|
|
1729
|
+
projectId: environmentVariables.TODESKTOP_CLI_FIREBASE_PROJECT_ID,
|
|
1730
|
+
storageBucket: environmentVariables.TODESKTOP_CLI_FIREBASE_STORAGE_BUCKET,
|
|
1731
|
+
messagingSenderId: environmentVariables.TODESKTOP_CLI_FIREBASE_MESSAGING_SENDER_ID,
|
|
1732
|
+
appId: environmentVariables.TODESKTOP_CLI_FIREBASE_ID
|
|
1733
|
+
});
|
|
1734
|
+
|
|
1735
|
+
const currentUser = () => firebase.auth().currentUser;
|
|
1736
|
+
|
|
1737
|
+
exports.currentUser = currentUser;
|
|
1738
|
+
|
|
1739
|
+
const signInWithCustomToken = async token => {
|
|
1740
|
+
return firebase.auth().signInWithCustomToken(token);
|
|
1741
|
+
};
|
|
1742
|
+
/**
|
|
1743
|
+
* onUserAuth is only triggered on sign-in. This
|
|
1744
|
+
* happens once signInWithCustomToken is successful.
|
|
1745
|
+
*
|
|
1746
|
+
* It technically also triggers on sign-out but there's
|
|
1747
|
+
* no concept of signing out of firebase with the CLI app.
|
|
1748
|
+
* (See logout command which just deletes a local file)
|
|
1749
|
+
*/
|
|
1750
|
+
|
|
1751
|
+
|
|
1752
|
+
exports.signInWithCustomToken = signInWithCustomToken;
|
|
1753
|
+
|
|
1754
|
+
const onUserAuth = handler => firebase.auth().onAuthStateChanged(user => {
|
|
1755
|
+
handler(user || {});
|
|
1756
|
+
});
|
|
1757
|
+
|
|
1758
|
+
exports.onUserAuth = onUserAuth;
|
|
1759
|
+
|
|
1760
|
+
var _default = firebaseDB.firestore();
|
|
1761
|
+
|
|
1762
|
+
exports.default = _default;
|
|
1763
|
+
},{"./getEnvironmentVariables":"../lib/utilities/getEnvironmentVariables.js"}],"../lib/utilities/analytics.js":[function(require,module,exports) {
|
|
1764
|
+
"use strict";
|
|
1765
|
+
|
|
1766
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1767
|
+
value: true
|
|
1768
|
+
});
|
|
1769
|
+
exports.track = exports.identify = exports.flush = exports.ANALYTICS_EVENT = void 0;
|
|
1770
|
+
|
|
1771
|
+
var _os = _interopRequireDefault(require("os"));
|
|
1772
|
+
|
|
1773
|
+
var _uuid = require("uuid");
|
|
1774
|
+
|
|
1775
|
+
var _analyticsNode = _interopRequireDefault(require("analytics-node"));
|
|
1776
|
+
|
|
1777
|
+
var _getEnvironmentVariables = _interopRequireDefault(require("./getEnvironmentVariables"));
|
|
1778
|
+
|
|
1779
|
+
var _firestore = require("./firestore");
|
|
1780
|
+
|
|
1781
|
+
var _configStore = require("./configStore");
|
|
1782
|
+
|
|
1783
|
+
var _getCliVersion = _interopRequireDefault(require("./getCliVersion"));
|
|
1784
|
+
|
|
1785
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1786
|
+
|
|
1787
|
+
const environmentVariables = (0, _getEnvironmentVariables.default)();
|
|
1788
|
+
const analytics = new _analyticsNode.default(environmentVariables.SEGMENT_WRITE_KEY, {
|
|
1789
|
+
flushAt: 1,
|
|
1790
|
+
flushInterval: 1
|
|
1791
|
+
});
|
|
1792
|
+
const ANALYTICS_EVENT = {
|
|
1793
|
+
CLI_COMMAND: "CLI Command"
|
|
1794
|
+
};
|
|
1795
|
+
exports.ANALYTICS_EVENT = ANALYTICS_EVENT;
|
|
1796
|
+
|
|
1797
|
+
function getAnalyticsBaseProperties() {
|
|
1798
|
+
let baseProps = {
|
|
1799
|
+
client: "cli"
|
|
1800
|
+
};
|
|
1801
|
+
|
|
1802
|
+
try {
|
|
1803
|
+
baseProps.os = {
|
|
1804
|
+
name: _os.default.platform(),
|
|
1805
|
+
version: _os.default.release()
|
|
1806
|
+
};
|
|
1807
|
+
} catch (err) {}
|
|
1808
|
+
|
|
1809
|
+
try {
|
|
1810
|
+
baseProps.user = {
|
|
1811
|
+
email: (0, _configStore.getAuthConfig)().email
|
|
1812
|
+
};
|
|
1813
|
+
} catch (err) {}
|
|
1814
|
+
|
|
1815
|
+
try {
|
|
1816
|
+
baseProps.app = {
|
|
1817
|
+
cliVersion: (0, _getCliVersion.default)()
|
|
1818
|
+
};
|
|
1819
|
+
} catch (err) {}
|
|
1820
|
+
|
|
1821
|
+
try {
|
|
1822
|
+
baseProps.runtime = {
|
|
1823
|
+
name: "Node.js",
|
|
1824
|
+
version: process.version
|
|
1825
|
+
};
|
|
1826
|
+
} catch (err) {}
|
|
1827
|
+
|
|
1828
|
+
return baseProps;
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
const anonymousId = (0, _uuid.v4)();
|
|
1832
|
+
|
|
1833
|
+
const track = (event, properties = {}, callback = () => {}) => {
|
|
1834
|
+
try {
|
|
1835
|
+
const user = (0, _firestore.currentUser)();
|
|
1836
|
+
analytics.track({
|
|
1837
|
+
event,
|
|
1838
|
+
userId: user ? user.uid : undefined,
|
|
1839
|
+
anonymousId,
|
|
1840
|
+
properties: { ...properties,
|
|
1841
|
+
...getAnalyticsBaseProperties()
|
|
1842
|
+
}
|
|
1843
|
+
}, callback);
|
|
1844
|
+
} catch (err) {}
|
|
1845
|
+
};
|
|
1846
|
+
|
|
1847
|
+
exports.track = track;
|
|
1848
|
+
|
|
1849
|
+
const identify = (id, traits = {}, callback = () => {}) => {
|
|
1850
|
+
try {
|
|
1851
|
+
analytics.identify({
|
|
1852
|
+
userId: id,
|
|
1853
|
+
anonymousId,
|
|
1854
|
+
traits
|
|
1855
|
+
}, callback);
|
|
1856
|
+
} catch (err) {}
|
|
1857
|
+
};
|
|
1858
|
+
|
|
1859
|
+
exports.identify = identify;
|
|
1860
|
+
|
|
1861
|
+
const flush = (callback = () => {}) => analytics.flush(callback);
|
|
1862
|
+
|
|
1863
|
+
exports.flush = flush;
|
|
1864
|
+
},{"./getEnvironmentVariables":"../lib/utilities/getEnvironmentVariables.js","./firestore":"../lib/utilities/firestore.js","./configStore":"../lib/utilities/configStore.js","./getCliVersion":"../lib/utilities/getCliVersion.js"}],"../lib/utilities/useExit.js":[function(require,module,exports) {
|
|
1865
|
+
"use strict";
|
|
1866
|
+
|
|
1867
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1868
|
+
value: true
|
|
1869
|
+
});
|
|
1870
|
+
exports.default = void 0;
|
|
1871
|
+
|
|
1872
|
+
var _ink = require("ink");
|
|
1873
|
+
|
|
1874
|
+
var _analytics = require("./analytics");
|
|
1875
|
+
|
|
1876
|
+
var _firestore = _interopRequireDefault(require("./firestore"));
|
|
1877
|
+
|
|
1878
|
+
var _logger = _interopRequireDefault(require("./logger"));
|
|
1879
|
+
|
|
1880
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1881
|
+
|
|
1882
|
+
var _default = () => {
|
|
1883
|
+
const {
|
|
1884
|
+
exit
|
|
1885
|
+
} = (0, _ink.useApp)();
|
|
1886
|
+
return error => {
|
|
1887
|
+
_logger.default.debug({
|
|
1888
|
+
error
|
|
1889
|
+
}, "Exit called");
|
|
1890
|
+
/*
|
|
1891
|
+
First, destroy connections.
|
|
1892
|
+
Why do we need to do this if we're going to call process.exit
|
|
1893
|
+
below anyway? Just to be safe in case a Firestore subscription
|
|
1894
|
+
triggers a state update after the React app is exited.
|
|
1895
|
+
*/
|
|
1896
|
+
|
|
1897
|
+
|
|
1898
|
+
_firestore.default.terminate().catch(e => // Ignore
|
|
1899
|
+
_logger.default.error(e));
|
|
1900
|
+
|
|
1901
|
+
let timeoutId;
|
|
1902
|
+
Promise.race([// flush the analytics to make sure all outstanding events are pushed to segment
|
|
1903
|
+
new Promise(resolve => (0, _analytics.flush)(() => resolve())), // If it takes longer than 1 second, resolve early to proceed with program exit
|
|
1904
|
+
new Promise(resolve => timeoutId = setTimeout(() => resolve(), 1000))]).catch(() => {}).finally(() => {
|
|
1905
|
+
clearTimeout(timeoutId);
|
|
1906
|
+
/*
|
|
1907
|
+
Then, exit the React app. We don't pass the error because:
|
|
1908
|
+
1. We don't want it displayed. We could give it a dummy error but
|
|
1909
|
+
that will output an empty line.
|
|
1910
|
+
2. It doesn't exit with the correct code anyway, see
|
|
1911
|
+
https://github.com/vadimdemedes/pastel/issues/39.
|
|
1912
|
+
Side note: your component must not perform state updates after
|
|
1913
|
+
calling this, it will error.
|
|
1914
|
+
The try-catch shouldn't be needed here, but let's be safe
|
|
1915
|
+
*/
|
|
1916
|
+
|
|
1917
|
+
try {
|
|
1918
|
+
exit();
|
|
1919
|
+
} catch (e) {
|
|
1920
|
+
_logger.default.error(e); // Ignore
|
|
1921
|
+
|
|
1922
|
+
}
|
|
1923
|
+
/*
|
|
1924
|
+
Then exit the process.
|
|
1925
|
+
It should happen if all connections, etc. are destroyed. We manually
|
|
1926
|
+
exit with a code because:
|
|
1927
|
+
1. We might not clean up properly, it could fail or take a long time.
|
|
1928
|
+
2. The exit function above doesn't exit the CLI with the correct
|
|
1929
|
+
code anyway.
|
|
1930
|
+
If we had a way to detect when the app exits, we would use that
|
|
1931
|
+
and then call process.exit / destroy connections appropriately
|
|
1932
|
+
(https://github.com/vadimdemedes/pastel/issues/38).
|
|
1933
|
+
*/
|
|
1934
|
+
|
|
1935
|
+
|
|
1936
|
+
setTimeout(() => process.exit(error ? 1 : 0), 10);
|
|
1937
|
+
});
|
|
1938
|
+
};
|
|
1939
|
+
};
|
|
1940
|
+
|
|
1941
|
+
exports.default = _default;
|
|
1942
|
+
},{"./analytics":"../lib/utilities/analytics.js","./firestore":"../lib/utilities/firestore.js","./logger":"../lib/utilities/logger.js"}],"../lib/components/ErrorDisplay.js":[function(require,module,exports) {
|
|
1943
|
+
"use strict";
|
|
1944
|
+
|
|
1945
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1946
|
+
value: true
|
|
1947
|
+
});
|
|
1948
|
+
exports.default = void 0;
|
|
1949
|
+
|
|
1950
|
+
var _ink = require("ink");
|
|
1951
|
+
|
|
1952
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
1953
|
+
|
|
1954
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
1955
|
+
|
|
1956
|
+
var _getCliVersion = _interopRequireDefault(require("../utilities/getCliVersion"));
|
|
1957
|
+
|
|
1958
|
+
var _logger = _interopRequireDefault(require("../utilities/logger"));
|
|
1959
|
+
|
|
1960
|
+
var _useExit = _interopRequireDefault(require("../utilities/useExit"));
|
|
1961
|
+
|
|
1962
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
1963
|
+
|
|
1964
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
1965
|
+
|
|
1966
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1967
|
+
|
|
1968
|
+
const ErrorDisplay = ({
|
|
1969
|
+
commandUsed,
|
|
1970
|
+
error
|
|
1971
|
+
}) => {
|
|
1972
|
+
const exit = (0, _useExit.default)();
|
|
1973
|
+
|
|
1974
|
+
_logger.default.error({
|
|
1975
|
+
error
|
|
1976
|
+
}); // After an error is set, exit
|
|
1977
|
+
|
|
1978
|
+
|
|
1979
|
+
(0, _react.useEffect)(() => {
|
|
1980
|
+
if (!error) {
|
|
1981
|
+
return;
|
|
1982
|
+
} // Just to avoid updating state after exiting the React app
|
|
1983
|
+
|
|
1984
|
+
|
|
1985
|
+
setTimeout(() => exit(error), 10);
|
|
1986
|
+
}, [exit, error]);
|
|
1987
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_ink.Text, {
|
|
1988
|
+
backgroundColor: "red",
|
|
1989
|
+
color: "white"
|
|
1990
|
+
}, " ", "ERROR", " "), /*#__PURE__*/_react.default.createElement(_ink.Text, null, error.message || error.stack || error.toString()), /*#__PURE__*/_react.default.createElement(_ink.Box, {
|
|
1991
|
+
flexDirection: "column",
|
|
1992
|
+
marginTop: 1
|
|
1993
|
+
}, commandUsed ? /*#__PURE__*/_react.default.createElement(_ink.Text, {
|
|
1994
|
+
dimColor: true,
|
|
1995
|
+
color: "gray"
|
|
1996
|
+
}, "Command: ", commandUsed) : null, /*#__PURE__*/_react.default.createElement(_ink.Text, {
|
|
1997
|
+
dimColor: true,
|
|
1998
|
+
color: "gray"
|
|
1999
|
+
}, "@todesktop/cli: ", (0, _getCliVersion.default)()), /*#__PURE__*/_react.default.createElement(_ink.Text, {
|
|
2000
|
+
dimColor: true,
|
|
2001
|
+
color: "gray"
|
|
2002
|
+
}, "Node: ", process.version), /*#__PURE__*/_react.default.createElement(_ink.Text, {
|
|
2003
|
+
dimColor: true,
|
|
2004
|
+
color: "gray"
|
|
2005
|
+
}, "cwd: ", process.cwd())));
|
|
2006
|
+
};
|
|
2007
|
+
|
|
2008
|
+
ErrorDisplay.propTypes = {
|
|
2009
|
+
commandUsed: _propTypes.default.string,
|
|
2010
|
+
error: _propTypes.default.object.isRequired
|
|
2011
|
+
};
|
|
2012
|
+
var _default = ErrorDisplay;
|
|
2013
|
+
exports.default = _default;
|
|
2014
|
+
},{"../utilities/getCliVersion":"../lib/utilities/getCliVersion.js","../utilities/logger":"../lib/utilities/logger.js","../utilities/useExit":"../lib/utilities/useExit.js"}],"../lib/utilities/postToFirebaseFunction.js":[function(require,module,exports) {
|
|
2015
|
+
"use strict";
|
|
2016
|
+
|
|
2017
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2018
|
+
value: true
|
|
2019
|
+
});
|
|
2020
|
+
exports.default = _default;
|
|
2021
|
+
|
|
2022
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
2023
|
+
|
|
2024
|
+
var _getEnvironmentVariables = _interopRequireDefault(require("./getEnvironmentVariables"));
|
|
2025
|
+
|
|
2026
|
+
var _logger = _interopRequireDefault(require("./logger"));
|
|
2027
|
+
|
|
2028
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2029
|
+
|
|
2030
|
+
const {
|
|
2031
|
+
TODESKTOP_CLI_FIREBASE_FUNCTIONS_BASE
|
|
2032
|
+
} = (0, _getEnvironmentVariables.default)();
|
|
2033
|
+
|
|
2034
|
+
async function _default(functionName, body = {}, config = {}) {
|
|
2035
|
+
_logger.default.debug({
|
|
2036
|
+
functionName,
|
|
2037
|
+
body,
|
|
2038
|
+
config
|
|
2039
|
+
}, "postToFirebaseFunction");
|
|
2040
|
+
|
|
2041
|
+
try {
|
|
2042
|
+
const response = await _axios.default.post(`${TODESKTOP_CLI_FIREBASE_FUNCTIONS_BASE}${functionName}`, body, config);
|
|
2043
|
+
|
|
2044
|
+
_logger.default.debug({
|
|
2045
|
+
responseData: response.data
|
|
2046
|
+
}, "postToFirebaseFunction: success");
|
|
2047
|
+
|
|
2048
|
+
return response.data;
|
|
2049
|
+
} catch (e) {
|
|
2050
|
+
_logger.default.error({
|
|
2051
|
+
error: e
|
|
2052
|
+
}, "postToFirebaseFunction: error");
|
|
2053
|
+
|
|
2054
|
+
throw e;
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
},{"./getEnvironmentVariables":"../lib/utilities/getEnvironmentVariables.js","./logger":"../lib/utilities/logger.js"}],"../lib/components/Login.js":[function(require,module,exports) {
|
|
2058
|
+
"use strict";
|
|
2059
|
+
|
|
2060
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2061
|
+
value: true
|
|
2062
|
+
});
|
|
2063
|
+
exports.default = void 0;
|
|
2064
|
+
|
|
2065
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
2066
|
+
|
|
2067
|
+
var _ink = require("ink");
|
|
2068
|
+
|
|
2069
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
2070
|
+
|
|
2071
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
2072
|
+
|
|
2073
|
+
var _reactFinalForm = require("react-final-form");
|
|
2074
|
+
|
|
2075
|
+
var _TextInput = _interopRequireDefault(require("../components/TextInput"));
|
|
2076
|
+
|
|
2077
|
+
var _ErrorDisplay = _interopRequireDefault(require("./ErrorDisplay"));
|
|
2078
|
+
|
|
2079
|
+
var _postToFirebaseFunction = _interopRequireDefault(require("../utilities/postToFirebaseFunction"));
|
|
2080
|
+
|
|
2081
|
+
var _firestore = require("../utilities/firestore");
|
|
2082
|
+
|
|
2083
|
+
var _configStore = require("../utilities/configStore");
|
|
2084
|
+
|
|
2085
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
2086
|
+
|
|
2087
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
2088
|
+
|
|
2089
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2090
|
+
|
|
2091
|
+
// modules
|
|
2092
|
+
// components
|
|
2093
|
+
// logic
|
|
2094
|
+
const loginFields = [{
|
|
2095
|
+
name: "email",
|
|
2096
|
+
label: "Your email",
|
|
2097
|
+
placeholder: "name@email.com",
|
|
2098
|
+
Input: _TextInput.default,
|
|
2099
|
+
validate: value => {
|
|
2100
|
+
if (!value) return "Required";
|
|
2101
|
+
}
|
|
2102
|
+
}, {
|
|
2103
|
+
name: "accessToken",
|
|
2104
|
+
label: "Your access token",
|
|
2105
|
+
placeholder: "********",
|
|
2106
|
+
Input: _TextInput.default,
|
|
2107
|
+
validate: value => {
|
|
2108
|
+
if (!value) return "Required";
|
|
2109
|
+
},
|
|
2110
|
+
mask: "*"
|
|
2111
|
+
}];
|
|
2112
|
+
|
|
2113
|
+
const Login = ({
|
|
2114
|
+
setIsLoggedIn
|
|
2115
|
+
}) => {
|
|
2116
|
+
const [activeField, setActiveField] = (0, _react.useState)(0);
|
|
2117
|
+
const [error, setError] = (0, _react.useState)(null);
|
|
2118
|
+
const [failureMessage, setFailureMessage] = (0, _react.useState)(null);
|
|
2119
|
+
const [isSubmittingForm, setIsSubmittingForm] = (0, _react.useState)(false);
|
|
2120
|
+
|
|
2121
|
+
const onFailure = message => {
|
|
2122
|
+
setIsSubmittingForm(false);
|
|
2123
|
+
setFailureMessage(message);
|
|
2124
|
+
setActiveField(0);
|
|
2125
|
+
}; // login handler that verifies accessToken and email with that in firebase
|
|
2126
|
+
|
|
2127
|
+
|
|
2128
|
+
const onSubmitLogin = async ({
|
|
2129
|
+
email,
|
|
2130
|
+
accessToken
|
|
2131
|
+
}) => {
|
|
2132
|
+
setFailureMessage(null);
|
|
2133
|
+
setIsSubmittingForm(true);
|
|
2134
|
+
|
|
2135
|
+
try {
|
|
2136
|
+
const jwtToken = await (0, _postToFirebaseFunction.default)("loginWithAccessToken", {
|
|
2137
|
+
email,
|
|
2138
|
+
accessToken
|
|
2139
|
+
});
|
|
2140
|
+
|
|
2141
|
+
if (jwtToken) {
|
|
2142
|
+
await (0, _firestore.signInWithCustomToken)(jwtToken);
|
|
2143
|
+
(0, _configStore.setAuthConfig)(email, accessToken, jwtToken);
|
|
2144
|
+
setIsLoggedIn(true);
|
|
2145
|
+
} else {
|
|
2146
|
+
onFailure("Incorrrect credentials. Try again");
|
|
2147
|
+
}
|
|
2148
|
+
} catch (err) {
|
|
2149
|
+
if (err.code === 500) {
|
|
2150
|
+
setError(err);
|
|
2151
|
+
} else {
|
|
2152
|
+
onFailure(`Login unsuccessful: ${err.message}`);
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
};
|
|
2156
|
+
|
|
2157
|
+
if (error) return /*#__PURE__*/_react.default.createElement(_ErrorDisplay.default, {
|
|
2158
|
+
error: error
|
|
2159
|
+
});
|
|
2160
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_ink.Text, null, "You are not currently logged in."), /*#__PURE__*/_react.default.createElement(_ink.Text, null, "Log in below:"), /*#__PURE__*/_react.default.createElement(_ink.Box, {
|
|
2161
|
+
marginBottom: 1
|
|
2162
|
+
}), /*#__PURE__*/_react.default.createElement(_reactFinalForm.Form, {
|
|
2163
|
+
onSubmit: onSubmitLogin
|
|
2164
|
+
}, ({
|
|
2165
|
+
handleSubmit,
|
|
2166
|
+
validating,
|
|
2167
|
+
form
|
|
2168
|
+
}) => /*#__PURE__*/_react.default.createElement(_ink.Box, {
|
|
2169
|
+
flexDirection: "column"
|
|
2170
|
+
}, loginFields.map(({
|
|
2171
|
+
name,
|
|
2172
|
+
label,
|
|
2173
|
+
placeholder,
|
|
2174
|
+
validate,
|
|
2175
|
+
Input,
|
|
2176
|
+
mask
|
|
2177
|
+
}, index) => /*#__PURE__*/_react.default.createElement(_reactFinalForm.Field, {
|
|
2178
|
+
name: name,
|
|
2179
|
+
key: name,
|
|
2180
|
+
validate: validate
|
|
2181
|
+
}, ({
|
|
2182
|
+
input,
|
|
2183
|
+
meta
|
|
2184
|
+
}) => /*#__PURE__*/_react.default.createElement(_ink.Box, {
|
|
2185
|
+
flexDirection: "column"
|
|
2186
|
+
}, activeField >= index ? /*#__PURE__*/_react.default.createElement(_ink.Box, null, /*#__PURE__*/_react.default.createElement(_ink.Text, {
|
|
2187
|
+
bold: activeField === index
|
|
2188
|
+
}, label, ": "), activeField === index ? /*#__PURE__*/_react.default.createElement(Input, (0, _extends2.default)({}, input, {
|
|
2189
|
+
mask: mask,
|
|
2190
|
+
placeholder: placeholder,
|
|
2191
|
+
onSubmit: () => {
|
|
2192
|
+
if (meta.valid && !validating) {
|
|
2193
|
+
setActiveField(value => value + 1); // go to next field
|
|
2194
|
+
|
|
2195
|
+
if (activeField === loginFields.length - 1) {
|
|
2196
|
+
// last field, so submit
|
|
2197
|
+
handleSubmit();
|
|
2198
|
+
}
|
|
2199
|
+
} else {
|
|
2200
|
+
input.onBlur(); // mark as touched to show error
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
})) : input.value && /*#__PURE__*/_react.default.createElement(_ink.Text, null, name === "accessToken" ? input.value.replace(/./gi, "*") : input.value) || placeholder && /*#__PURE__*/_react.default.createElement(_ink.Text, {
|
|
2204
|
+
color: "gray"
|
|
2205
|
+
}, placeholder), meta.invalid && meta.touched && /*#__PURE__*/_react.default.createElement(_ink.Box, {
|
|
2206
|
+
marginLeft: 2,
|
|
2207
|
+
marginRight: 1
|
|
2208
|
+
}, /*#__PURE__*/_react.default.createElement(_ink.Text, {
|
|
2209
|
+
color: "red"
|
|
2210
|
+
}, "\u2716")), meta.error && meta.touched && /*#__PURE__*/_react.default.createElement(Error, {
|
|
2211
|
+
errorMessage: meta.error
|
|
2212
|
+
})) : null))))), isSubmittingForm && /*#__PURE__*/_react.default.createElement(_ink.Box, {
|
|
2213
|
+
marginTop: 1
|
|
2214
|
+
}, /*#__PURE__*/_react.default.createElement(_ink.Text, null, "Logging in...")), failureMessage && /*#__PURE__*/_react.default.createElement(Error, {
|
|
2215
|
+
errorMessage: failureMessage,
|
|
2216
|
+
marginTop: true
|
|
2217
|
+
}));
|
|
2218
|
+
};
|
|
2219
|
+
|
|
2220
|
+
const Error = ({
|
|
2221
|
+
errorMessage,
|
|
2222
|
+
marginTop
|
|
2223
|
+
}) => /*#__PURE__*/_react.default.createElement(_ink.Box, {
|
|
2224
|
+
marginTop: marginTop ? 1 : 0
|
|
2225
|
+
}, /*#__PURE__*/_react.default.createElement(_ink.Text, {
|
|
2226
|
+
color: "red"
|
|
2227
|
+
}, errorMessage));
|
|
2228
|
+
|
|
2229
|
+
Error.propTypes = {
|
|
2230
|
+
errorMessage: _propTypes.default.string.isRequired,
|
|
2231
|
+
marginTop: _propTypes.default.bool
|
|
2232
|
+
};
|
|
2233
|
+
Login.propTypes = {
|
|
2234
|
+
setIsLoggedIn: _propTypes.default.func.isRequired
|
|
2235
|
+
};
|
|
2236
|
+
var _default = Login;
|
|
2237
|
+
exports.default = _default;
|
|
2238
|
+
},{"../components/TextInput":"../lib/components/TextInput.js","./ErrorDisplay":"../lib/components/ErrorDisplay.js","../utilities/postToFirebaseFunction":"../lib/utilities/postToFirebaseFunction.js","../utilities/firestore":"../lib/utilities/firestore.js","../utilities/configStore":"../lib/utilities/configStore.js"}],"../lib/components/LoginHOC.js":[function(require,module,exports) {
|
|
2239
|
+
"use strict";
|
|
2240
|
+
|
|
2241
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2242
|
+
value: true
|
|
2243
|
+
});
|
|
2244
|
+
exports.default = void 0;
|
|
2245
|
+
|
|
2246
|
+
var _ink = require("ink");
|
|
2247
|
+
|
|
2248
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
2249
|
+
|
|
2250
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
2251
|
+
|
|
2252
|
+
var _isCi = _interopRequireDefault(require("is-ci"));
|
|
2253
|
+
|
|
2254
|
+
var _Login = _interopRequireDefault(require("./Login"));
|
|
2255
|
+
|
|
2256
|
+
var _firestore = require("../utilities/firestore");
|
|
2257
|
+
|
|
2258
|
+
var _configStore = require("../utilities/configStore");
|
|
2259
|
+
|
|
2260
|
+
var _postToFirebaseFunction = _interopRequireDefault(require("../utilities/postToFirebaseFunction"));
|
|
2261
|
+
|
|
2262
|
+
var _getEnvironmentVariables = _interopRequireDefault(require("../utilities/getEnvironmentVariables"));
|
|
2263
|
+
|
|
2264
|
+
var _ErrorDisplay = _interopRequireDefault(require("./ErrorDisplay"));
|
|
2265
|
+
|
|
2266
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2267
|
+
|
|
2268
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
2269
|
+
|
|
2270
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
2271
|
+
|
|
2272
|
+
// components
|
|
2273
|
+
// logic
|
|
2274
|
+
const LoginHOC = ({
|
|
2275
|
+
children,
|
|
2276
|
+
isInteractive = true
|
|
2277
|
+
}) => {
|
|
2278
|
+
const [isLoggedIn, setIsLoggedIn] = (0, _react.useState)(false);
|
|
2279
|
+
const [isEffectDone, setEffectDone] = (0, _react.useState)(false);
|
|
2280
|
+
const [error, setError] = (0, _react.useState)(null);
|
|
2281
|
+
const {
|
|
2282
|
+
isRawModeSupported
|
|
2283
|
+
} = (0, _ink.useStdin)();
|
|
2284
|
+
|
|
2285
|
+
const onFailure = (message, err = {}) => {
|
|
2286
|
+
setError({ ...err,
|
|
2287
|
+
message
|
|
2288
|
+
});
|
|
2289
|
+
}; // use effect for determining if tokens exist and are valid
|
|
2290
|
+
|
|
2291
|
+
|
|
2292
|
+
(0, _react.useEffect)(() => {
|
|
2293
|
+
async function isAccessTokenValid() {
|
|
2294
|
+
const {
|
|
2295
|
+
accessToken,
|
|
2296
|
+
email,
|
|
2297
|
+
jwtToken
|
|
2298
|
+
} = (0, _configStore.getAuthConfig)();
|
|
2299
|
+
let userCreds = null;
|
|
2300
|
+
const {
|
|
2301
|
+
TODESKTOP_ACCESS_TOKEN,
|
|
2302
|
+
TODESKTOP_EMAIL
|
|
2303
|
+
} = (0, _getEnvironmentVariables.default)(); // 1. attempt log in with environment variables if present
|
|
2304
|
+
|
|
2305
|
+
try {
|
|
2306
|
+
if (TODESKTOP_ACCESS_TOKEN && TODESKTOP_EMAIL) {
|
|
2307
|
+
const newJwtToken = await (0, _postToFirebaseFunction.default)("loginWithAccessToken", {
|
|
2308
|
+
email: TODESKTOP_EMAIL,
|
|
2309
|
+
accessToken: TODESKTOP_ACCESS_TOKEN
|
|
2310
|
+
});
|
|
2311
|
+
|
|
2312
|
+
if (newJwtToken) {
|
|
2313
|
+
userCreds = await (0, _firestore.signInWithCustomToken)(newJwtToken);
|
|
2314
|
+
if (userCreds.user) setIsLoggedIn(true);
|
|
2315
|
+
} // if no environment variables set and is in a CI, set alert message and exit
|
|
2316
|
+
|
|
2317
|
+
} else if (!isRawModeSupported || _isCi.default) {
|
|
2318
|
+
onFailure("ToDesktop environment variables not found. When automating builds with your CI provider, you need to specify environment variables for TODESKTOP_EMAIL and TODESKTOP_ACCESS_TOKEN.");
|
|
2319
|
+
}
|
|
2320
|
+
} catch (err) {
|
|
2321
|
+
// print error and stop the app execution if env variables attempted
|
|
2322
|
+
onFailure("Log in with environment variables failed.", err);
|
|
2323
|
+
} // 2. attempt log in with jwtToken if present
|
|
2324
|
+
|
|
2325
|
+
|
|
2326
|
+
try {
|
|
2327
|
+
if (!userCreds && jwtToken) {
|
|
2328
|
+
userCreds = await (0, _firestore.signInWithCustomToken)(jwtToken);
|
|
2329
|
+
if (userCreds.user) setIsLoggedIn(true);
|
|
2330
|
+
}
|
|
2331
|
+
} catch (err) {// do nothing, attempt login with accessToken and email
|
|
2332
|
+
} // 3. attempt log in with accessToken and email on disk
|
|
2333
|
+
|
|
2334
|
+
|
|
2335
|
+
try {
|
|
2336
|
+
if (!userCreds && accessToken && email) {
|
|
2337
|
+
const newJwtToken = await (0, _postToFirebaseFunction.default)("loginWithAccessToken", {
|
|
2338
|
+
email,
|
|
2339
|
+
accessToken
|
|
2340
|
+
});
|
|
2341
|
+
|
|
2342
|
+
if (newJwtToken) {
|
|
2343
|
+
userCreds = await (0, _firestore.signInWithCustomToken)(newJwtToken);
|
|
2344
|
+
(0, _configStore.setAuthConfig)(email, accessToken, newJwtToken);
|
|
2345
|
+
if (userCreds.user) setIsLoggedIn(true);
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
} catch (err) {// do nothing: no error state and not logged in state means render login
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2351
|
+
setEffectDone(true);
|
|
2352
|
+
}
|
|
2353
|
+
|
|
2354
|
+
isAccessTokenValid();
|
|
2355
|
+
}, []);
|
|
2356
|
+
|
|
2357
|
+
if (error && isInteractive) {
|
|
2358
|
+
return /*#__PURE__*/_react.default.createElement(_ErrorDisplay.default, {
|
|
2359
|
+
error: error
|
|
2360
|
+
});
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2363
|
+
if (!isEffectDone) {
|
|
2364
|
+
return /*#__PURE__*/_react.default.createElement(_ink.Text, null, "...");
|
|
2365
|
+
}
|
|
2366
|
+
|
|
2367
|
+
if (!isLoggedIn && isInteractive) {
|
|
2368
|
+
return /*#__PURE__*/_react.default.createElement(_Login.default, {
|
|
2369
|
+
setIsLoggedIn: setIsLoggedIn
|
|
2370
|
+
});
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2373
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, children);
|
|
2374
|
+
};
|
|
2375
|
+
|
|
2376
|
+
LoginHOC.propTypes = {
|
|
2377
|
+
children: _propTypes.default.object,
|
|
2378
|
+
isInteractive: _propTypes.default.bool
|
|
2379
|
+
};
|
|
2380
|
+
var _default = LoginHOC;
|
|
2381
|
+
exports.default = _default;
|
|
2382
|
+
},{"./Login":"../lib/components/Login.js","../utilities/firestore":"../lib/utilities/firestore.js","../utilities/configStore":"../lib/utilities/configStore.js","../utilities/postToFirebaseFunction":"../lib/utilities/postToFirebaseFunction.js","../utilities/getEnvironmentVariables":"../lib/utilities/getEnvironmentVariables.js","./ErrorDisplay":"../lib/components/ErrorDisplay.js"}],"../lib/utilities/useAnalytics.js":[function(require,module,exports) {
|
|
2383
|
+
"use strict";
|
|
2384
|
+
|
|
2385
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2386
|
+
value: true
|
|
2387
|
+
});
|
|
2388
|
+
exports.useAnalyticsCommand = void 0;
|
|
2389
|
+
|
|
2390
|
+
var _react = require("react");
|
|
2391
|
+
|
|
2392
|
+
var _firestore = require("./firestore");
|
|
2393
|
+
|
|
2394
|
+
var _analytics = require("./analytics");
|
|
2395
|
+
|
|
2396
|
+
var _logger = _interopRequireDefault(require("../utilities/logger"));
|
|
2397
|
+
|
|
2398
|
+
var _getProjectConfig = _interopRequireDefault(require("../utilities/projectConfig/getProjectConfig"));
|
|
2399
|
+
|
|
2400
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2401
|
+
|
|
2402
|
+
const useAnalyticsCommand = (command, flags = {}, properties = {}) => {
|
|
2403
|
+
const [hasAttemptedTracking, setTrackingAttempt] = (0, _react.useState)(false);
|
|
2404
|
+
|
|
2405
|
+
_logger.default.info({
|
|
2406
|
+
command,
|
|
2407
|
+
flags,
|
|
2408
|
+
properties
|
|
2409
|
+
}, "useAnalyticsCommand");
|
|
2410
|
+
|
|
2411
|
+
try {
|
|
2412
|
+
if (flags.projectPath) {
|
|
2413
|
+
properties = { ...properties,
|
|
2414
|
+
...(0, _getProjectConfig.default)()
|
|
2415
|
+
};
|
|
2416
|
+
}
|
|
2417
|
+
} catch (err) {}
|
|
2418
|
+
|
|
2419
|
+
(0, _react.useEffect)(() => {
|
|
2420
|
+
const authUnsubscribe = (0, _firestore.onUserAuth)(async user => {
|
|
2421
|
+
/**
|
|
2422
|
+
* Only identify if there's a user id (stops use of anon id).
|
|
2423
|
+
* Subsequent track callback will thus always be tied to a user.
|
|
2424
|
+
*/
|
|
2425
|
+
if (user.uid) {
|
|
2426
|
+
(0, _analytics.identify)(user.uid, {
|
|
2427
|
+
email: user.email,
|
|
2428
|
+
displayName: user.displayName
|
|
2429
|
+
}, () => {
|
|
2430
|
+
(0, _analytics.track)(_analytics.ANALYTICS_EVENT.CLI_COMMAND, { ...properties,
|
|
2431
|
+
flags,
|
|
2432
|
+
command
|
|
2433
|
+
}, () => setTrackingAttempt(true));
|
|
2434
|
+
authUnsubscribe && authUnsubscribe();
|
|
2435
|
+
});
|
|
2436
|
+
}
|
|
2437
|
+
}); // if it takes longer than 5 secs to identify a user, just set the
|
|
2438
|
+
// tracking attempt to true so that other commands aren't waiting
|
|
2439
|
+
// forever to terminate (see whoami component)
|
|
2440
|
+
|
|
2441
|
+
setTimeout(() => setTrackingAttempt(true), 5000);
|
|
2442
|
+
}, []); // leave empty - this should only ever execute once (on mount)
|
|
2443
|
+
|
|
2444
|
+
return {
|
|
2445
|
+
hasAttemptedTracking
|
|
2446
|
+
};
|
|
2447
|
+
};
|
|
2448
|
+
|
|
2449
|
+
exports.useAnalyticsCommand = useAnalyticsCommand;
|
|
2450
|
+
},{"./firestore":"../lib/utilities/firestore.js","./analytics":"../lib/utilities/analytics.js","../utilities/logger":"../lib/utilities/logger.js","../utilities/projectConfig/getProjectConfig":"../lib/utilities/projectConfig/getProjectConfig.js"}],"whoami.js":[function(require,module,exports) {
|
|
2451
|
+
"use strict";
|
|
2452
|
+
|
|
2453
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2454
|
+
value: true
|
|
2455
|
+
});
|
|
2456
|
+
exports.default = void 0;
|
|
2457
|
+
|
|
2458
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
2459
|
+
|
|
2460
|
+
var _ink = require("ink");
|
|
2461
|
+
|
|
2462
|
+
var _checkIfReactIsUsable = _interopRequireDefault(require("../lib/utilities/checkIfReactIsUsable"));
|
|
2463
|
+
|
|
2464
|
+
var _configStore = require("../lib/utilities/configStore");
|
|
2465
|
+
|
|
2466
|
+
var _ErrorBoundary = _interopRequireDefault(require("../lib/components/ErrorBoundary"));
|
|
2467
|
+
|
|
2468
|
+
var _onCommand = _interopRequireDefault(require("../lib/utilities/onCommand"));
|
|
2469
|
+
|
|
2470
|
+
var _LoginHOC = _interopRequireDefault(require("../lib/components/LoginHOC"));
|
|
2471
|
+
|
|
2472
|
+
var _useAnalytics = require("../lib/utilities/useAnalytics");
|
|
2473
|
+
|
|
2474
|
+
var _useExit = _interopRequireDefault(require("../lib/utilities/useExit"));
|
|
2475
|
+
|
|
2476
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2477
|
+
|
|
2478
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
2479
|
+
|
|
2480
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
2481
|
+
|
|
2482
|
+
(0, _onCommand.default)(); /// Prints the email of the account you're signed into
|
|
2483
|
+
|
|
2484
|
+
const WhoAmI = () => {
|
|
2485
|
+
const exit = (0, _useExit.default)();
|
|
2486
|
+
(0, _checkIfReactIsUsable.default)();
|
|
2487
|
+
const auth = (0, _configStore.getAuthConfig)();
|
|
2488
|
+
const {
|
|
2489
|
+
hasAttemptedTracking
|
|
2490
|
+
} = (0, _useAnalytics.useAnalyticsCommand)("whoami", {}, {}); // exits the program once tracking of the "whoami" command has been attempted
|
|
2491
|
+
|
|
2492
|
+
(0, _react.useEffect)(() => {
|
|
2493
|
+
if (hasAttemptedTracking) {
|
|
2494
|
+
exit();
|
|
2495
|
+
}
|
|
2496
|
+
}, [exit, hasAttemptedTracking]);
|
|
2497
|
+
|
|
2498
|
+
if (!auth || !auth.email) {
|
|
2499
|
+
return /*#__PURE__*/_react.default.createElement(_ink.Text, null, "You're not signed in");
|
|
2500
|
+
}
|
|
2501
|
+
|
|
2502
|
+
return /*#__PURE__*/_react.default.createElement(_ink.Text, null, auth.email);
|
|
2503
|
+
};
|
|
2504
|
+
|
|
2505
|
+
const WhoAmIWrapper = () => /*#__PURE__*/_react.default.createElement(_ErrorBoundary.default, null, /*#__PURE__*/_react.default.createElement(_LoginHOC.default, {
|
|
2506
|
+
isInteractive: false
|
|
2507
|
+
}, /*#__PURE__*/_react.default.createElement(WhoAmI, null)));
|
|
2508
|
+
|
|
2509
|
+
var _default = WhoAmIWrapper;
|
|
2510
|
+
exports.default = _default;
|
|
2511
|
+
},{"../lib/utilities/checkIfReactIsUsable":"../lib/utilities/checkIfReactIsUsable.js","../lib/utilities/configStore":"../lib/utilities/configStore.js","../lib/components/ErrorBoundary":"../lib/components/ErrorBoundary.js","../lib/utilities/onCommand":"../lib/utilities/onCommand.js","../lib/components/LoginHOC":"../lib/components/LoginHOC.js","../lib/utilities/useAnalytics":"../lib/utilities/useAnalytics.js","../lib/utilities/useExit":"../lib/utilities/useExit.js"}]},{},["whoami.js"], null)
|
|
58
2512
|
//# sourceMappingURL=/whoami.js.map
|