@teambit/application 0.0.523 → 0.0.525
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/dist/app-context.js +2 -8
- package/dist/app-context.js.map +1 -1
- package/dist/app-list.cmd.js +2 -17
- package/dist/app-list.cmd.js.map +1 -1
- package/dist/app-server.js +0 -4
- package/dist/app-server.js.map +1 -1
- package/dist/app-type.plugin.js +0 -15
- package/dist/app-type.plugin.js.map +1 -1
- package/dist/app.cmd.js +2 -22
- package/dist/app.cmd.js.map +1 -1
- package/dist/app.plugin.js +2 -11
- package/dist/app.plugin.js.map +1 -1
- package/dist/application.aspect.js +0 -5
- package/dist/application.aspect.js.map +1 -1
- package/dist/application.composition.js +0 -6
- package/dist/application.composition.js.map +1 -1
- package/dist/application.main.runtime.js +14 -116
- package/dist/application.main.runtime.js.map +1 -1
- package/dist/application.service.js +0 -9
- package/dist/application.service.js.map +1 -1
- package/dist/build.task.js +0 -32
- package/dist/build.task.js.map +1 -1
- package/dist/deploy.task.js +0 -28
- package/dist/deploy.task.js.map +1 -1
- package/dist/exceptions/app-no-ssr.js +0 -3
- package/dist/exceptions/app-no-ssr.js.map +1 -1
- package/dist/exceptions/app-not-found.js +0 -3
- package/dist/exceptions/app-not-found.js.map +1 -1
- package/dist/exceptions/index.js +0 -3
- package/dist/exceptions/index.js.map +1 -1
- package/dist/index.js +0 -24
- package/dist/index.js.map +1 -1
- package/dist/run.cmd.js +0 -23
- package/dist/run.cmd.js.map +1 -1
- package/package-tar/teambit-application-0.0.525.tgz +0 -0
- package/package.json +8 -8
- package/{preview-1666409808293.js → preview-1666582798766.js} +2 -2
- package/package-tar/teambit-application-0.0.523.tgz +0 -0
|
@@ -1,256 +1,180 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.array.iterator.js");
|
|
6
|
-
|
|
7
5
|
require("core-js/modules/es.promise.js");
|
|
8
|
-
|
|
9
6
|
Object.defineProperty(exports, "__esModule", {
|
|
10
7
|
value: true
|
|
11
8
|
});
|
|
12
9
|
exports.ApplicationMain = void 0;
|
|
13
|
-
|
|
14
10
|
function _defineProperty2() {
|
|
15
11
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
|
|
17
12
|
_defineProperty2 = function () {
|
|
18
13
|
return data;
|
|
19
14
|
};
|
|
20
|
-
|
|
21
15
|
return data;
|
|
22
16
|
}
|
|
23
|
-
|
|
24
17
|
function _cli() {
|
|
25
18
|
const data = require("@teambit/cli");
|
|
26
|
-
|
|
27
19
|
_cli = function () {
|
|
28
20
|
return data;
|
|
29
21
|
};
|
|
30
|
-
|
|
31
22
|
return data;
|
|
32
23
|
}
|
|
33
|
-
|
|
34
24
|
function _lodash() {
|
|
35
25
|
const data = require("lodash");
|
|
36
|
-
|
|
37
26
|
_lodash = function () {
|
|
38
27
|
return data;
|
|
39
28
|
};
|
|
40
|
-
|
|
41
29
|
return data;
|
|
42
30
|
}
|
|
43
|
-
|
|
44
31
|
function _aspectLoader() {
|
|
45
32
|
const data = require("@teambit/aspect-loader");
|
|
46
|
-
|
|
47
33
|
_aspectLoader = function () {
|
|
48
34
|
return data;
|
|
49
35
|
};
|
|
50
|
-
|
|
51
36
|
return data;
|
|
52
37
|
}
|
|
53
|
-
|
|
54
38
|
function _harmony() {
|
|
55
39
|
const data = require("@teambit/harmony");
|
|
56
|
-
|
|
57
40
|
_harmony = function () {
|
|
58
41
|
return data;
|
|
59
42
|
};
|
|
60
|
-
|
|
61
43
|
return data;
|
|
62
44
|
}
|
|
63
|
-
|
|
64
45
|
function _workspace() {
|
|
65
46
|
const data = _interopRequireDefault(require("@teambit/workspace"));
|
|
66
|
-
|
|
67
47
|
_workspace = function () {
|
|
68
48
|
return data;
|
|
69
49
|
};
|
|
70
|
-
|
|
71
50
|
return data;
|
|
72
51
|
}
|
|
73
|
-
|
|
74
52
|
function _bitError() {
|
|
75
53
|
const data = require("@teambit/bit-error");
|
|
76
|
-
|
|
77
54
|
_bitError = function () {
|
|
78
55
|
return data;
|
|
79
56
|
};
|
|
80
|
-
|
|
81
57
|
return data;
|
|
82
58
|
}
|
|
83
|
-
|
|
84
59
|
function _builder() {
|
|
85
60
|
const data = require("@teambit/builder");
|
|
86
|
-
|
|
87
61
|
_builder = function () {
|
|
88
62
|
return data;
|
|
89
63
|
};
|
|
90
|
-
|
|
91
64
|
return data;
|
|
92
65
|
}
|
|
93
|
-
|
|
94
66
|
function _logger() {
|
|
95
67
|
const data = require("@teambit/logger");
|
|
96
|
-
|
|
97
68
|
_logger = function () {
|
|
98
69
|
return data;
|
|
99
70
|
};
|
|
100
|
-
|
|
101
71
|
return data;
|
|
102
72
|
}
|
|
103
|
-
|
|
104
73
|
function _envs() {
|
|
105
74
|
const data = require("@teambit/envs");
|
|
106
|
-
|
|
107
75
|
_envs = function () {
|
|
108
76
|
return data;
|
|
109
77
|
};
|
|
110
|
-
|
|
111
78
|
return data;
|
|
112
79
|
}
|
|
113
|
-
|
|
114
80
|
function _component() {
|
|
115
81
|
const data = _interopRequireWildcard(require("@teambit/component"));
|
|
116
|
-
|
|
117
82
|
_component = function () {
|
|
118
83
|
return data;
|
|
119
84
|
};
|
|
120
|
-
|
|
121
85
|
return data;
|
|
122
86
|
}
|
|
123
|
-
|
|
124
87
|
function _exceptions() {
|
|
125
88
|
const data = require("./exceptions");
|
|
126
|
-
|
|
127
89
|
_exceptions = function () {
|
|
128
90
|
return data;
|
|
129
91
|
};
|
|
130
|
-
|
|
131
92
|
return data;
|
|
132
93
|
}
|
|
133
|
-
|
|
134
94
|
function _application() {
|
|
135
95
|
const data = require("./application.aspect");
|
|
136
|
-
|
|
137
96
|
_application = function () {
|
|
138
97
|
return data;
|
|
139
98
|
};
|
|
140
|
-
|
|
141
99
|
return data;
|
|
142
100
|
}
|
|
143
|
-
|
|
144
101
|
function _appList() {
|
|
145
102
|
const data = require("./app-list.cmd");
|
|
146
|
-
|
|
147
103
|
_appList = function () {
|
|
148
104
|
return data;
|
|
149
105
|
};
|
|
150
|
-
|
|
151
106
|
return data;
|
|
152
107
|
}
|
|
153
|
-
|
|
154
108
|
function _build() {
|
|
155
109
|
const data = require("./build.task");
|
|
156
|
-
|
|
157
110
|
_build = function () {
|
|
158
111
|
return data;
|
|
159
112
|
};
|
|
160
|
-
|
|
161
113
|
return data;
|
|
162
114
|
}
|
|
163
|
-
|
|
164
115
|
function _run() {
|
|
165
116
|
const data = require("./run.cmd");
|
|
166
|
-
|
|
167
117
|
_run = function () {
|
|
168
118
|
return data;
|
|
169
119
|
};
|
|
170
|
-
|
|
171
120
|
return data;
|
|
172
121
|
}
|
|
173
|
-
|
|
174
122
|
function _application2() {
|
|
175
123
|
const data = require("./application.service");
|
|
176
|
-
|
|
177
124
|
_application2 = function () {
|
|
178
125
|
return data;
|
|
179
126
|
};
|
|
180
|
-
|
|
181
127
|
return data;
|
|
182
128
|
}
|
|
183
|
-
|
|
184
129
|
function _app() {
|
|
185
130
|
const data = require("./app.cmd");
|
|
186
|
-
|
|
187
131
|
_app = function () {
|
|
188
132
|
return data;
|
|
189
133
|
};
|
|
190
|
-
|
|
191
134
|
return data;
|
|
192
135
|
}
|
|
193
|
-
|
|
194
136
|
function _app2() {
|
|
195
137
|
const data = require("./app.plugin");
|
|
196
|
-
|
|
197
138
|
_app2 = function () {
|
|
198
139
|
return data;
|
|
199
140
|
};
|
|
200
|
-
|
|
201
141
|
return data;
|
|
202
142
|
}
|
|
203
|
-
|
|
204
143
|
function _appType() {
|
|
205
144
|
const data = require("./app-type.plugin");
|
|
206
|
-
|
|
207
145
|
_appType = function () {
|
|
208
146
|
return data;
|
|
209
147
|
};
|
|
210
|
-
|
|
211
148
|
return data;
|
|
212
149
|
}
|
|
213
|
-
|
|
214
150
|
function _appContext() {
|
|
215
151
|
const data = require("./app-context");
|
|
216
|
-
|
|
217
152
|
_appContext = function () {
|
|
218
153
|
return data;
|
|
219
154
|
};
|
|
220
|
-
|
|
221
155
|
return data;
|
|
222
156
|
}
|
|
223
|
-
|
|
224
157
|
function _deploy() {
|
|
225
158
|
const data = require("./deploy.task");
|
|
226
|
-
|
|
227
159
|
_deploy = function () {
|
|
228
160
|
return data;
|
|
229
161
|
};
|
|
230
|
-
|
|
231
162
|
return data;
|
|
232
163
|
}
|
|
233
|
-
|
|
234
164
|
function _appNoSsr() {
|
|
235
165
|
const data = require("./exceptions/app-no-ssr");
|
|
236
|
-
|
|
237
166
|
_appNoSsr = function () {
|
|
238
167
|
return data;
|
|
239
168
|
};
|
|
240
|
-
|
|
241
169
|
return data;
|
|
242
170
|
}
|
|
243
|
-
|
|
244
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); }
|
|
245
|
-
|
|
246
172
|
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; }
|
|
247
|
-
|
|
248
173
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
249
|
-
|
|
250
174
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
251
|
-
|
|
252
175
|
class ApplicationMain {
|
|
253
|
-
constructor(appSlot,
|
|
176
|
+
constructor(appSlot,
|
|
177
|
+
// TODO unused
|
|
254
178
|
appTypeSlot, deploymentProviderSlot, envs, componentAspect, appService, aspectLoader, workspace, logger) {
|
|
255
179
|
this.appSlot = appSlot;
|
|
256
180
|
this.appTypeSlot = appTypeSlot;
|
|
@@ -268,114 +192,98 @@ class ApplicationMain {
|
|
|
268
192
|
defaultPortRange: [3100, 3500]
|
|
269
193
|
});
|
|
270
194
|
}
|
|
195
|
+
|
|
271
196
|
/**
|
|
272
197
|
* register a new app.
|
|
273
198
|
*/
|
|
274
|
-
|
|
275
|
-
|
|
276
199
|
registerApp(app) {
|
|
277
200
|
this.appSlot.register([app]);
|
|
278
201
|
return this;
|
|
279
202
|
}
|
|
203
|
+
|
|
280
204
|
/**
|
|
281
205
|
* list all registered apps.
|
|
282
206
|
*/
|
|
283
|
-
|
|
284
|
-
|
|
285
207
|
listApps() {
|
|
286
208
|
return (0, _lodash().flatten)(this.appSlot.values());
|
|
287
209
|
}
|
|
210
|
+
|
|
288
211
|
/**
|
|
289
212
|
* map all apps by component ID.
|
|
290
213
|
*/
|
|
291
|
-
|
|
292
|
-
|
|
293
214
|
mapApps() {
|
|
294
215
|
return this.appSlot.toArray();
|
|
295
216
|
}
|
|
217
|
+
|
|
296
218
|
/**
|
|
297
219
|
* list apps by a component id.
|
|
298
220
|
*/
|
|
299
|
-
|
|
300
|
-
|
|
301
221
|
listAppsById(id) {
|
|
302
222
|
if (!id) return undefined;
|
|
303
223
|
return this.appSlot.get(id.toString());
|
|
304
224
|
}
|
|
225
|
+
|
|
305
226
|
/**
|
|
306
227
|
* get an application by a component id.
|
|
307
228
|
*/
|
|
308
|
-
|
|
309
|
-
|
|
310
229
|
getAppById(id) {
|
|
311
230
|
const apps = this.listAppsById(id);
|
|
312
231
|
if (!apps) return undefined;
|
|
313
232
|
return (0, _lodash().head)(apps);
|
|
314
233
|
}
|
|
234
|
+
|
|
315
235
|
/**
|
|
316
236
|
* get an app.
|
|
317
237
|
*/
|
|
318
|
-
|
|
319
|
-
|
|
320
238
|
getApp(appName, id) {
|
|
321
239
|
const apps = this.listAppsById(id) || this.listApps();
|
|
322
240
|
return apps.find(app => app.name === appName);
|
|
323
241
|
}
|
|
324
|
-
|
|
325
242
|
getAppByNameOrId(appNameOrId) {
|
|
326
243
|
const byName = this.getApp(appNameOrId);
|
|
327
244
|
if (byName) return byName;
|
|
328
245
|
const byId = this.appSlot.get(appNameOrId);
|
|
329
246
|
if (!byId || !byId.length) return undefined;
|
|
330
|
-
|
|
331
247
|
if (byId.length > 1) {
|
|
332
248
|
throw new (_bitError().BitError)(`unable to figure out what app to retrieve. the id "${appNameOrId}" has more than one app. please use the app-name`);
|
|
333
249
|
}
|
|
334
|
-
|
|
335
250
|
return byId[0];
|
|
336
251
|
}
|
|
252
|
+
|
|
337
253
|
/**
|
|
338
254
|
* registers a new app and sets a plugin for it.
|
|
339
255
|
*/
|
|
340
|
-
|
|
341
|
-
|
|
342
256
|
registerAppType(appType) {
|
|
343
257
|
const plugin = new (_appType().AppTypePlugin)(`*.${appType.name}.*`, appType, this.appSlot);
|
|
344
258
|
this.aspectLoader.registerPlugins([plugin]);
|
|
345
259
|
this.appTypeSlot.register([appType]);
|
|
346
260
|
return this;
|
|
347
261
|
}
|
|
262
|
+
|
|
348
263
|
/**
|
|
349
264
|
* get an app AspectId.
|
|
350
265
|
*/
|
|
351
|
-
|
|
352
|
-
|
|
353
266
|
getAppAspect(appName) {
|
|
354
267
|
var _this$appSlot$toArray;
|
|
355
|
-
|
|
356
268
|
return (_this$appSlot$toArray = this.appSlot.toArray().find(([, apps]) => apps.find(app => app.name === appName))) === null || _this$appSlot$toArray === void 0 ? void 0 : _this$appSlot$toArray[0];
|
|
357
269
|
}
|
|
270
|
+
|
|
358
271
|
/**
|
|
359
272
|
* get app to throw.
|
|
360
273
|
*/
|
|
361
|
-
|
|
362
|
-
|
|
363
274
|
getAppOrThrow(appName) {
|
|
364
275
|
const app = this.getAppByNameOrId(appName);
|
|
365
276
|
if (!app) throw new (_exceptions().AppNotFound)(appName);
|
|
366
277
|
return app;
|
|
367
278
|
}
|
|
368
|
-
|
|
369
279
|
computeOptions(opts = {}) {
|
|
370
280
|
return _objectSpread(_objectSpread({}, this.defaultOpts), opts);
|
|
371
281
|
}
|
|
372
|
-
|
|
373
282
|
async runApp(appName, options) {
|
|
374
283
|
options = this.computeOptions(options);
|
|
375
284
|
const app = this.getAppOrThrow(appName);
|
|
376
285
|
const context = await this.createAppContext(app.name);
|
|
377
286
|
if (!context) throw new (_exceptions().AppNotFound)(appName);
|
|
378
|
-
|
|
379
287
|
if (options.ssr) {
|
|
380
288
|
if (!app.runSsr) throw new (_appNoSsr().AppNoSsr)(appName);
|
|
381
289
|
const result = await app.runSsr(context);
|
|
@@ -383,9 +291,7 @@ class ApplicationMain {
|
|
|
383
291
|
app
|
|
384
292
|
}, result);
|
|
385
293
|
}
|
|
386
|
-
|
|
387
294
|
const port = await app.run(context);
|
|
388
|
-
|
|
389
295
|
if (options.watch) {
|
|
390
296
|
this.workspace.watcher.watchAll({
|
|
391
297
|
preCompile: false
|
|
@@ -394,18 +300,16 @@ class ApplicationMain {
|
|
|
394
300
|
this.logger.error(`compilation failed`, err);
|
|
395
301
|
});
|
|
396
302
|
}
|
|
397
|
-
|
|
398
303
|
return {
|
|
399
304
|
app,
|
|
400
305
|
port,
|
|
401
306
|
errors: undefined
|
|
402
307
|
};
|
|
403
308
|
}
|
|
309
|
+
|
|
404
310
|
/**
|
|
405
311
|
* get the component ID of a certain app.
|
|
406
312
|
*/
|
|
407
|
-
|
|
408
|
-
|
|
409
313
|
getAppIdOrThrow(appName) {
|
|
410
314
|
const maybeApp = this.appSlot.toArray().find(([, apps]) => {
|
|
411
315
|
return apps.find(app => app.name === appName);
|
|
@@ -413,13 +317,13 @@ class ApplicationMain {
|
|
|
413
317
|
if (!maybeApp) throw new (_exceptions().AppNotFound)(appName);
|
|
414
318
|
return _component().ComponentID.fromString(maybeApp[0]);
|
|
415
319
|
}
|
|
416
|
-
|
|
417
320
|
async createAppContext(appName) {
|
|
418
321
|
const host = this.componentAspect.getHost();
|
|
419
322
|
const components = await host.list();
|
|
420
323
|
const id = this.getAppIdOrThrow(appName);
|
|
421
324
|
const component = components.find(c => c.id.isEqual(id));
|
|
422
|
-
if (!component) throw new (_exceptions().AppNotFound)(appName);
|
|
325
|
+
if (!component) throw new (_exceptions().AppNotFound)(appName);
|
|
326
|
+
// console.log(comp)
|
|
423
327
|
|
|
424
328
|
const env = await this.envs.createEnvironment([component]);
|
|
425
329
|
const res = await env.run(this.appService);
|
|
@@ -429,7 +333,6 @@ class ApplicationMain {
|
|
|
429
333
|
const appContext = new (_appContext().AppContext)(appName, context.dev, component, this.workspace.path, context, hostRootDir);
|
|
430
334
|
return appContext;
|
|
431
335
|
}
|
|
432
|
-
|
|
433
336
|
static async provider([cli, loggerAspect, builder, envs, component, aspectLoader, workspace], config, [appTypeSlot, appSlot, deploymentProviderSlot]) {
|
|
434
337
|
const logger = loggerAspect.createLogger(_application().ApplicationAspect.id);
|
|
435
338
|
const appService = new (_application2().AppService)();
|
|
@@ -442,7 +345,6 @@ class ApplicationMain {
|
|
|
442
345
|
builder.registerTagTasks([new (_deploy().DeployTask)(application, builder)]);
|
|
443
346
|
cli.registerGroup('apps', 'Applications');
|
|
444
347
|
cli.register(new (_run().RunCmd)(application, logger), new (_appList().AppListCmdDeprecated)(application), appCmd);
|
|
445
|
-
|
|
446
348
|
if (workspace) {
|
|
447
349
|
workspace.onComponentLoad(async loadedComponent => {
|
|
448
350
|
const app = application.getAppById(loadedComponent.id);
|
|
@@ -453,17 +355,13 @@ class ApplicationMain {
|
|
|
453
355
|
};
|
|
454
356
|
});
|
|
455
357
|
}
|
|
456
|
-
|
|
457
358
|
return application;
|
|
458
359
|
}
|
|
459
|
-
|
|
460
360
|
}
|
|
461
|
-
|
|
462
361
|
exports.ApplicationMain = ApplicationMain;
|
|
463
362
|
(0, _defineProperty2().default)(ApplicationMain, "runtime", _cli().MainRuntime);
|
|
464
363
|
(0, _defineProperty2().default)(ApplicationMain, "dependencies", [_cli().CLIAspect, _logger().LoggerAspect, _builder().BuilderAspect, _envs().EnvsAspect, _component().default, _aspectLoader().AspectLoaderAspect, _workspace().default]);
|
|
465
364
|
(0, _defineProperty2().default)(ApplicationMain, "slots", [_harmony().Slot.withType(), _harmony().Slot.withType(), _harmony().Slot.withType()]);
|
|
466
|
-
|
|
467
365
|
_application().ApplicationAspect.addRuntime(ApplicationMain);
|
|
468
366
|
|
|
469
367
|
//# sourceMappingURL=application.main.runtime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ApplicationMain","constructor","appSlot","appTypeSlot","deploymentProviderSlot","envs","componentAspect","appService","aspectLoader","workspace","logger","dev","ssr","watch","defaultPortRange","registerApp","app","register","listApps","flatten","values","mapApps","toArray","listAppsById","id","undefined","get","toString","getAppById","apps","head","getApp","appName","find","name","getAppByNameOrId","appNameOrId","byName","byId","length","BitError","registerAppType","appType","plugin","AppTypePlugin","registerPlugins","getAppAspect","getAppOrThrow","AppNotFound","computeOptions","opts","defaultOpts","runApp","options","context","createAppContext","runSsr","AppNoSsr","result","port","run","watcher","watchAll","preCompile","catch","err","error","errors","getAppIdOrThrow","maybeApp","ComponentID","fromString","host","getHost","components","list","component","c","isEqual","env","createEnvironment","res","results","data","hostRootDir","getComponentPackagePath","appContext","AppContext","path","provider","cli","loggerAspect","builder","config","createLogger","ApplicationAspect","AppService","application","appCmd","AppCmd","commands","AppListCmd","RunCmd","AppPlugin","registerBuildTasks","AppsBuildTask","registerSnapTasks","DeployTask","registerTagTasks","registerGroup","AppListCmdDeprecated","onComponentLoad","loadedComponent","type","applicationType","MainRuntime","CLIAspect","LoggerAspect","BuilderAspect","EnvsAspect","ComponentAspect","AspectLoaderAspect","WorkspaceAspect","Slot","withType","addRuntime"],"sources":["application.main.runtime.ts"],"sourcesContent":["import { MainRuntime, CLIMain, CLIAspect } from '@teambit/cli';\nimport { flatten, head } from 'lodash';\nimport { AspectLoaderMain, AspectLoaderAspect } from '@teambit/aspect-loader';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { BitError } from '@teambit/bit-error';\nimport { BuilderAspect, BuilderMain } from '@teambit/builder';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport ComponentAspect, { ComponentMain, ComponentID } from '@teambit/component';\nimport { ApplicationType } from './application-type';\nimport { Application } from './application';\nimport { DeploymentProvider } from './deployment-provider';\nimport { AppNotFound } from './exceptions';\nimport { ApplicationAspect } from './application.aspect';\nimport { AppListCmdDeprecated } from './app-list.cmd';\nimport { AppsBuildTask } from './build.task';\nimport { RunCmd } from './run.cmd';\nimport { AppService } from './application.service';\nimport { AppCmd, AppListCmd } from './app.cmd';\nimport { AppPlugin } from './app.plugin';\nimport { AppTypePlugin } from './app-type.plugin';\nimport { AppContext } from './app-context';\nimport { DeployTask } from './deploy.task';\nimport { AppNoSsr } from './exceptions/app-no-ssr';\n\nexport type ApplicationTypeSlot = SlotRegistry<ApplicationType<unknown>[]>;\nexport type ApplicationSlot = SlotRegistry<Application[]>;\nexport type DeploymentProviderSlot = SlotRegistry<DeploymentProvider[]>;\n\nexport type ApplicationAspectConfig = {};\n\nexport type ServeAppOptions = {\n /**\n * default port range used to serve applications.\n */\n defaultPortRange?: [start: number, end: number];\n\n /**\n * determine whether to start the application in dev mode.\n */\n dev: boolean;\n\n /**\n * actively watch and compile the workspace (like the bit watch command)\n * @default true\n */\n watch?: boolean;\n\n /**\n * determine whether to start the application in server side mode.\n * @default false\n */\n ssr?: boolean;\n};\n\nexport class ApplicationMain {\n constructor(\n private appSlot: ApplicationSlot,\n // TODO unused\n private appTypeSlot: ApplicationTypeSlot,\n private deploymentProviderSlot: DeploymentProviderSlot,\n private envs: EnvsMain,\n private componentAspect: ComponentMain,\n private appService: AppService,\n private aspectLoader: AspectLoaderMain,\n private workspace: Workspace,\n private logger: Logger\n ) {}\n\n /**\n * register a new app.\n */\n registerApp(app: Application) {\n this.appSlot.register([app]);\n return this;\n }\n\n /**\n * list all registered apps.\n */\n listApps(): Application[] {\n return flatten(this.appSlot.values());\n }\n\n /**\n * map all apps by component ID.\n */\n mapApps() {\n return this.appSlot.toArray();\n }\n\n /**\n * list apps by a component id.\n */\n listAppsById(id?: ComponentID): Application[] | undefined {\n if (!id) return undefined;\n return this.appSlot.get(id.toString());\n }\n\n /**\n * get an application by a component id.\n */\n getAppById(id: ComponentID) {\n const apps = this.listAppsById(id);\n if (!apps) return undefined;\n return head(apps);\n }\n\n /**\n * get an app.\n */\n getApp(appName: string, id?: ComponentID): Application | undefined {\n const apps = this.listAppsById(id) || this.listApps();\n return apps.find((app) => app.name === appName);\n }\n\n getAppByNameOrId(appNameOrId: string): Application | undefined {\n const byName = this.getApp(appNameOrId);\n if (byName) return byName;\n const byId = this.appSlot.get(appNameOrId);\n if (!byId || !byId.length) return undefined;\n if (byId.length > 1) {\n throw new BitError(\n `unable to figure out what app to retrieve. the id \"${appNameOrId}\" has more than one app. please use the app-name`\n );\n }\n return byId[0];\n }\n\n /**\n * registers a new app and sets a plugin for it.\n */\n registerAppType<T>(appType: ApplicationType<T>) {\n const plugin = new AppTypePlugin(`*.${appType.name}.*`, appType, this.appSlot);\n this.aspectLoader.registerPlugins([plugin]);\n this.appTypeSlot.register([appType]);\n return this;\n }\n\n /**\n * get an app AspectId.\n */\n getAppAspect(appName: string): string | undefined {\n return this.appSlot.toArray().find(([, apps]) => apps.find((app) => app.name === appName))?.[0];\n }\n\n /**\n * get app to throw.\n */\n getAppOrThrow(appName: string) {\n const app = this.getAppByNameOrId(appName);\n if (!app) throw new AppNotFound(appName);\n return app;\n }\n\n defaultOpts: ServeAppOptions = {\n dev: false,\n ssr: false,\n watch: true,\n defaultPortRange: [3100, 3500],\n };\n private computeOptions(opts: Partial<ServeAppOptions> = {}) {\n return {\n ...this.defaultOpts,\n ...opts,\n };\n }\n\n async runApp(appName: string, options?: ServeAppOptions) {\n options = this.computeOptions(options);\n const app = this.getAppOrThrow(appName);\n const context = await this.createAppContext(app.name);\n if (!context) throw new AppNotFound(appName);\n\n if (options.ssr) {\n if (!app.runSsr) throw new AppNoSsr(appName);\n\n const result = await app.runSsr(context);\n return { app, ...result };\n }\n\n const port = await app.run(context);\n if (options.watch) {\n this.workspace.watcher\n .watchAll({\n preCompile: false,\n })\n .catch((err) => {\n // don't throw an error, we don't want to break the \"run\" process\n this.logger.error(`compilation failed`, err);\n });\n }\n return { app, port, errors: undefined };\n }\n\n /**\n * get the component ID of a certain app.\n */\n getAppIdOrThrow(appName: string) {\n const maybeApp = this.appSlot.toArray().find(([, apps]) => {\n return apps.find((app) => app.name === appName);\n });\n\n if (!maybeApp) throw new AppNotFound(appName);\n return ComponentID.fromString(maybeApp[0]);\n }\n\n private async createAppContext(appName: string): Promise<AppContext> {\n const host = this.componentAspect.getHost();\n const components = await host.list();\n const id = this.getAppIdOrThrow(appName);\n const component = components.find((c) => c.id.isEqual(id));\n if (!component) throw new AppNotFound(appName);\n // console.log(comp)\n\n const env = await this.envs.createEnvironment([component]);\n const res = await env.run(this.appService);\n const context = res.results[0].data;\n if (!context) throw new AppNotFound(appName);\n const hostRootDir = this.workspace.getComponentPackagePath(component);\n const appContext = new AppContext(appName, context.dev, component, this.workspace.path, context, hostRootDir);\n return appContext;\n }\n\n static runtime = MainRuntime;\n static dependencies = [\n CLIAspect,\n LoggerAspect,\n BuilderAspect,\n EnvsAspect,\n ComponentAspect,\n AspectLoaderAspect,\n WorkspaceAspect,\n ];\n\n static slots = [\n Slot.withType<ApplicationType<unknown>[]>(),\n Slot.withType<Application[]>(),\n Slot.withType<DeploymentProvider[]>(),\n ];\n\n static async provider(\n [cli, loggerAspect, builder, envs, component, aspectLoader, workspace]: [\n CLIMain,\n LoggerMain,\n BuilderMain,\n EnvsMain,\n ComponentMain,\n AspectLoaderMain,\n Workspace\n ],\n config: ApplicationAspectConfig,\n [appTypeSlot, appSlot, deploymentProviderSlot]: [ApplicationTypeSlot, ApplicationSlot, DeploymentProviderSlot]\n ) {\n const logger = loggerAspect.createLogger(ApplicationAspect.id);\n const appService = new AppService();\n const application = new ApplicationMain(\n appSlot,\n appTypeSlot,\n deploymentProviderSlot,\n envs,\n component,\n appService,\n aspectLoader,\n workspace,\n logger\n );\n const appCmd = new AppCmd();\n appCmd.commands = [new AppListCmd(application), new RunCmd(application, logger)];\n aspectLoader.registerPlugins([new AppPlugin(appSlot)]);\n builder.registerBuildTasks([new AppsBuildTask(application)]);\n builder.registerSnapTasks([new DeployTask(application, builder)]);\n builder.registerTagTasks([new DeployTask(application, builder)]);\n cli.registerGroup('apps', 'Applications');\n cli.register(new RunCmd(application, logger), new AppListCmdDeprecated(application), appCmd);\n if (workspace) {\n workspace.onComponentLoad(async (loadedComponent) => {\n const app = application.getAppById(loadedComponent.id);\n if (!app) return {};\n return {\n appName: app?.name,\n type: app?.applicationType,\n };\n });\n }\n\n return application;\n }\n}\n\nApplicationAspect.addRuntime(ApplicationMain);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;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1B;IACAnB,GAAG,CAACzE,QAAJ,CAAa,KAAIqF,aAAJ,EAAWL,WAAX,EAAwBvF,MAAxB,CAAb,EAA8C,KAAIoG,+BAAJ,EAAyBb,WAAzB,CAA9C,EAAqFC,MAArF;;IACA,IAAIzF,SAAJ,EAAe;MACbA,SAAS,CAACsG,eAAV,CAA0B,MAAOC,eAAP,IAA2B;QACnD,MAAMhG,GAAG,GAAGiF,WAAW,CAACrE,UAAZ,CAAuBoF,eAAe,CAACxF,EAAvC,CAAZ;QACA,IAAI,CAACR,GAAL,EAAU,OAAO,EAAP;QACV,OAAO;UACLgB,OAAO,EAAEhB,GAAF,aAAEA,GAAF,uBAAEA,GAAG,CAAEkB,IADT;UAEL+E,IAAI,EAAEjG,GAAF,aAAEA,GAAF,uBAAEA,GAAG,CAAEkG;QAFN,CAAP;MAID,CAPD;IAQD;;IAED,OAAOjB,WAAP;EACD;;AAxO0B;;;gCAAhBjG,e,aAyKMmH,kB;gCAzKNnH,e,kBA0KW,CACpBoH,gBADoB,EAEpBC,sBAFoB,EAGpBC,wBAHoB,EAIpBC,kBAJoB,EAKpBC,oBALoB,EAMpBC,kCANoB,EAOpBC,oBAPoB,C;gCA1KX1H,e,WAoLI,CACb2H,eAAA,CAAKC,QAAL,EADa,EAEbD,eAAA,CAAKC,QAAL,EAFa,EAGbD,eAAA,CAAKC,QAAL,EAHa,C;;AAuDjB7B,gCAAA,CAAkB8B,UAAlB,CAA6B7H,eAA7B"}
|
|
1
|
+
{"version":3,"names":["ApplicationMain","constructor","appSlot","appTypeSlot","deploymentProviderSlot","envs","componentAspect","appService","aspectLoader","workspace","logger","dev","ssr","watch","defaultPortRange","registerApp","app","register","listApps","flatten","values","mapApps","toArray","listAppsById","id","undefined","get","toString","getAppById","apps","head","getApp","appName","find","name","getAppByNameOrId","appNameOrId","byName","byId","length","BitError","registerAppType","appType","plugin","AppTypePlugin","registerPlugins","getAppAspect","getAppOrThrow","AppNotFound","computeOptions","opts","defaultOpts","runApp","options","context","createAppContext","runSsr","AppNoSsr","result","port","run","watcher","watchAll","preCompile","catch","err","error","errors","getAppIdOrThrow","maybeApp","ComponentID","fromString","host","getHost","components","list","component","c","isEqual","env","createEnvironment","res","results","data","hostRootDir","getComponentPackagePath","appContext","AppContext","path","provider","cli","loggerAspect","builder","config","createLogger","ApplicationAspect","AppService","application","appCmd","AppCmd","commands","AppListCmd","RunCmd","AppPlugin","registerBuildTasks","AppsBuildTask","registerSnapTasks","DeployTask","registerTagTasks","registerGroup","AppListCmdDeprecated","onComponentLoad","loadedComponent","type","applicationType","MainRuntime","CLIAspect","LoggerAspect","BuilderAspect","EnvsAspect","ComponentAspect","AspectLoaderAspect","WorkspaceAspect","Slot","withType","addRuntime"],"sources":["application.main.runtime.ts"],"sourcesContent":["import { MainRuntime, CLIMain, CLIAspect } from '@teambit/cli';\nimport { flatten, head } from 'lodash';\nimport { AspectLoaderMain, AspectLoaderAspect } from '@teambit/aspect-loader';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { BitError } from '@teambit/bit-error';\nimport { BuilderAspect, BuilderMain } from '@teambit/builder';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport ComponentAspect, { ComponentMain, ComponentID } from '@teambit/component';\nimport { ApplicationType } from './application-type';\nimport { Application } from './application';\nimport { DeploymentProvider } from './deployment-provider';\nimport { AppNotFound } from './exceptions';\nimport { ApplicationAspect } from './application.aspect';\nimport { AppListCmdDeprecated } from './app-list.cmd';\nimport { AppsBuildTask } from './build.task';\nimport { RunCmd } from './run.cmd';\nimport { AppService } from './application.service';\nimport { AppCmd, AppListCmd } from './app.cmd';\nimport { AppPlugin } from './app.plugin';\nimport { AppTypePlugin } from './app-type.plugin';\nimport { AppContext } from './app-context';\nimport { DeployTask } from './deploy.task';\nimport { AppNoSsr } from './exceptions/app-no-ssr';\n\nexport type ApplicationTypeSlot = SlotRegistry<ApplicationType<unknown>[]>;\nexport type ApplicationSlot = SlotRegistry<Application[]>;\nexport type DeploymentProviderSlot = SlotRegistry<DeploymentProvider[]>;\n\nexport type ApplicationAspectConfig = {};\n\nexport type ServeAppOptions = {\n /**\n * default port range used to serve applications.\n */\n defaultPortRange?: [start: number, end: number];\n\n /**\n * determine whether to start the application in dev mode.\n */\n dev: boolean;\n\n /**\n * actively watch and compile the workspace (like the bit watch command)\n * @default true\n */\n watch?: boolean;\n\n /**\n * determine whether to start the application in server side mode.\n * @default false\n */\n ssr?: boolean;\n};\n\nexport class ApplicationMain {\n constructor(\n private appSlot: ApplicationSlot,\n // TODO unused\n private appTypeSlot: ApplicationTypeSlot,\n private deploymentProviderSlot: DeploymentProviderSlot,\n private envs: EnvsMain,\n private componentAspect: ComponentMain,\n private appService: AppService,\n private aspectLoader: AspectLoaderMain,\n private workspace: Workspace,\n private logger: Logger\n ) {}\n\n /**\n * register a new app.\n */\n registerApp(app: Application) {\n this.appSlot.register([app]);\n return this;\n }\n\n /**\n * list all registered apps.\n */\n listApps(): Application[] {\n return flatten(this.appSlot.values());\n }\n\n /**\n * map all apps by component ID.\n */\n mapApps() {\n return this.appSlot.toArray();\n }\n\n /**\n * list apps by a component id.\n */\n listAppsById(id?: ComponentID): Application[] | undefined {\n if (!id) return undefined;\n return this.appSlot.get(id.toString());\n }\n\n /**\n * get an application by a component id.\n */\n getAppById(id: ComponentID) {\n const apps = this.listAppsById(id);\n if (!apps) return undefined;\n return head(apps);\n }\n\n /**\n * get an app.\n */\n getApp(appName: string, id?: ComponentID): Application | undefined {\n const apps = this.listAppsById(id) || this.listApps();\n return apps.find((app) => app.name === appName);\n }\n\n getAppByNameOrId(appNameOrId: string): Application | undefined {\n const byName = this.getApp(appNameOrId);\n if (byName) return byName;\n const byId = this.appSlot.get(appNameOrId);\n if (!byId || !byId.length) return undefined;\n if (byId.length > 1) {\n throw new BitError(\n `unable to figure out what app to retrieve. the id \"${appNameOrId}\" has more than one app. please use the app-name`\n );\n }\n return byId[0];\n }\n\n /**\n * registers a new app and sets a plugin for it.\n */\n registerAppType<T>(appType: ApplicationType<T>) {\n const plugin = new AppTypePlugin(`*.${appType.name}.*`, appType, this.appSlot);\n this.aspectLoader.registerPlugins([plugin]);\n this.appTypeSlot.register([appType]);\n return this;\n }\n\n /**\n * get an app AspectId.\n */\n getAppAspect(appName: string): string | undefined {\n return this.appSlot.toArray().find(([, apps]) => apps.find((app) => app.name === appName))?.[0];\n }\n\n /**\n * get app to throw.\n */\n getAppOrThrow(appName: string) {\n const app = this.getAppByNameOrId(appName);\n if (!app) throw new AppNotFound(appName);\n return app;\n }\n\n defaultOpts: ServeAppOptions = {\n dev: false,\n ssr: false,\n watch: true,\n defaultPortRange: [3100, 3500],\n };\n private computeOptions(opts: Partial<ServeAppOptions> = {}) {\n return {\n ...this.defaultOpts,\n ...opts,\n };\n }\n\n async runApp(appName: string, options?: ServeAppOptions) {\n options = this.computeOptions(options);\n const app = this.getAppOrThrow(appName);\n const context = await this.createAppContext(app.name);\n if (!context) throw new AppNotFound(appName);\n\n if (options.ssr) {\n if (!app.runSsr) throw new AppNoSsr(appName);\n\n const result = await app.runSsr(context);\n return { app, ...result };\n }\n\n const port = await app.run(context);\n if (options.watch) {\n this.workspace.watcher\n .watchAll({\n preCompile: false,\n })\n .catch((err) => {\n // don't throw an error, we don't want to break the \"run\" process\n this.logger.error(`compilation failed`, err);\n });\n }\n return { app, port, errors: undefined };\n }\n\n /**\n * get the component ID of a certain app.\n */\n getAppIdOrThrow(appName: string) {\n const maybeApp = this.appSlot.toArray().find(([, apps]) => {\n return apps.find((app) => app.name === appName);\n });\n\n if (!maybeApp) throw new AppNotFound(appName);\n return ComponentID.fromString(maybeApp[0]);\n }\n\n private async createAppContext(appName: string): Promise<AppContext> {\n const host = this.componentAspect.getHost();\n const components = await host.list();\n const id = this.getAppIdOrThrow(appName);\n const component = components.find((c) => c.id.isEqual(id));\n if (!component) throw new AppNotFound(appName);\n // console.log(comp)\n\n const env = await this.envs.createEnvironment([component]);\n const res = await env.run(this.appService);\n const context = res.results[0].data;\n if (!context) throw new AppNotFound(appName);\n const hostRootDir = this.workspace.getComponentPackagePath(component);\n const appContext = new AppContext(appName, context.dev, component, this.workspace.path, context, hostRootDir);\n return appContext;\n }\n\n static runtime = MainRuntime;\n static dependencies = [\n CLIAspect,\n LoggerAspect,\n BuilderAspect,\n EnvsAspect,\n ComponentAspect,\n AspectLoaderAspect,\n WorkspaceAspect,\n ];\n\n static slots = [\n Slot.withType<ApplicationType<unknown>[]>(),\n Slot.withType<Application[]>(),\n Slot.withType<DeploymentProvider[]>(),\n ];\n\n static async provider(\n [cli, loggerAspect, builder, envs, component, aspectLoader, workspace]: [\n CLIMain,\n LoggerMain,\n BuilderMain,\n EnvsMain,\n ComponentMain,\n AspectLoaderMain,\n Workspace\n ],\n config: ApplicationAspectConfig,\n [appTypeSlot, appSlot, deploymentProviderSlot]: [ApplicationTypeSlot, ApplicationSlot, DeploymentProviderSlot]\n ) {\n const logger = loggerAspect.createLogger(ApplicationAspect.id);\n const appService = new AppService();\n const application = new ApplicationMain(\n appSlot,\n appTypeSlot,\n deploymentProviderSlot,\n envs,\n component,\n appService,\n aspectLoader,\n workspace,\n logger\n );\n const appCmd = new AppCmd();\n appCmd.commands = [new AppListCmd(application), new RunCmd(application, logger)];\n aspectLoader.registerPlugins([new AppPlugin(appSlot)]);\n builder.registerBuildTasks([new AppsBuildTask(application)]);\n builder.registerSnapTasks([new DeployTask(application, builder)]);\n builder.registerTagTasks([new DeployTask(application, builder)]);\n cli.registerGroup('apps', 'Applications');\n cli.register(new RunCmd(application, logger), new AppListCmdDeprecated(application), appCmd);\n if (workspace) {\n workspace.onComponentLoad(async (loadedComponent) => {\n const app = application.getAppById(loadedComponent.id);\n if (!app) return {};\n return {\n appName: app?.name,\n type: app?.applicationType,\n };\n });\n }\n\n return application;\n }\n}\n\nApplicationAspect.addRuntime(ApplicationMain);\n"],"mappings":";;;;;;;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gBAAgB,CAAC,CAAC,KAAID,oBAAU,EAACV,WAAW,EAAEL,OAAO,CAAC,CAAC,CAAC;IAChEF,GAAG,CAACmB,aAAa,CAAC,MAAM,EAAE,cAAc,CAAC;IACzCnB,GAAG,CAACzE,QAAQ,CAAC,KAAIqF,aAAM,EAACL,WAAW,EAAEvF,MAAM,CAAC,EAAE,KAAIoG,+BAAoB,EAACb,WAAW,CAAC,EAAEC,MAAM,CAAC;IAC5F,IAAIzF,SAAS,EAAE;MACbA,SAAS,CAACsG,eAAe,CAAC,MAAOC,eAAe,IAAK;QACnD,MAAMhG,GAAG,GAAGiF,WAAW,CAACrE,UAAU,CAACoF,eAAe,CAACxF,EAAE,CAAC;QACtD,IAAI,CAACR,GAAG,EAAE,OAAO,CAAC,CAAC;QACnB,OAAO;UACLgB,OAAO,EAAEhB,GAAG,aAAHA,GAAG,uBAAHA,GAAG,CAAEkB,IAAI;UAClB+E,IAAI,EAAEjG,GAAG,aAAHA,GAAG,uBAAHA,GAAG,CAAEkG;QACb,CAAC;MACH,CAAC,CAAC;IACJ;IAEA,OAAOjB,WAAW;EACpB;AACF;AAAC;AAAA,gCAzOYjG,eAAe,aAyKTmH,kBAAW;AAAA,gCAzKjBnH,eAAe,kBA0KJ,CACpBoH,gBAAS,EACTC,sBAAY,EACZC,wBAAa,EACbC,kBAAU,EACVC,oBAAe,EACfC,kCAAkB,EAClBC,oBAAe,CAChB;AAAA,gCAlLU1H,eAAe,WAoLX,CACb2H,eAAI,CAACC,QAAQ,EAA8B,EAC3CD,eAAI,CAACC,QAAQ,EAAiB,EAC9BD,eAAI,CAACC,QAAQ,EAAwB,CACtC;AAmDH7B,gCAAiB,CAAC8B,UAAU,CAAC7H,eAAe,CAAC"}
|
|
@@ -1,38 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.promise.js");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.AppService = void 0;
|
|
11
|
-
|
|
12
9
|
function _defineProperty2() {
|
|
13
10
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
-
|
|
15
11
|
_defineProperty2 = function () {
|
|
16
12
|
return data;
|
|
17
13
|
};
|
|
18
|
-
|
|
19
14
|
return data;
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
class AppService {
|
|
23
17
|
constructor() {
|
|
24
18
|
(0, _defineProperty2().default)(this, "name", 'app');
|
|
25
19
|
}
|
|
26
|
-
|
|
27
20
|
async run(context) {
|
|
28
21
|
const appContext = Object.assign(context, {
|
|
29
22
|
dev: true
|
|
30
23
|
});
|
|
31
24
|
return appContext;
|
|
32
25
|
}
|
|
33
|
-
|
|
34
26
|
}
|
|
35
|
-
|
|
36
27
|
exports.AppService = AppService;
|
|
37
28
|
|
|
38
29
|
//# sourceMappingURL=application.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AppService","run","context","appContext","Object","assign","dev"],"sources":["application.service.ts"],"sourcesContent":["import { EnvService, ExecutionContext } from '@teambit/envs';\n\nexport class AppService implements EnvService<any> {\n name = 'app';\n\n async run(context: ExecutionContext) {\n const appContext = Object.assign(context, {\n dev: true,\n });\n\n return appContext;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["AppService","run","context","appContext","Object","assign","dev"],"sources":["application.service.ts"],"sourcesContent":["import { EnvService, ExecutionContext } from '@teambit/envs';\n\nexport class AppService implements EnvService<any> {\n name = 'app';\n\n async run(context: ExecutionContext) {\n const appContext = Object.assign(context, {\n dev: true,\n });\n\n return appContext;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAEO,MAAMA,UAAU,CAA4B;EAAA;IAAA,8CAC1C,KAAK;EAAA;EAEZ,MAAMC,GAAG,CAACC,OAAyB,EAAE;IACnC,MAAMC,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACH,OAAO,EAAE;MACxCI,GAAG,EAAE;IACP,CAAC,CAAC;IAEF,OAAOH,UAAU;EACnB;AACF;AAAC"}
|