@teambit/application 0.0.161 → 0.0.165
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/app-type.plugin.ts +14 -0
- package/app.plugin.ts +15 -0
- package/application-type.ts +11 -2
- package/application.main.runtime.ts +36 -14
- package/dist/app-type.plugin.d.ts +11 -0
- package/dist/app-type.plugin.js +46 -0
- package/dist/app-type.plugin.js.map +1 -0
- package/dist/app.plugin.d.ts +9 -0
- package/dist/app.plugin.js +45 -0
- package/dist/app.plugin.js.map +1 -0
- package/dist/application-type.d.ts +3 -2
- package/dist/application.main.runtime.d.ts +14 -5
- package/dist/application.main.runtime.js +47 -13
- package/dist/application.main.runtime.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/index.ts +1 -0
- package/package-tar/teambit-application-0.0.165.tgz +0 -0
- package/package.json +8 -7
- package/package-tar/teambit-application-0.0.161.tgz +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PluginDefinition } from '@teambit/aspect-loader';
|
|
2
|
+
import { MainRuntime } from '@teambit/cli';
|
|
3
|
+
import { ApplicationType } from './application-type';
|
|
4
|
+
import { ApplicationSlot } from './application.main.runtime';
|
|
5
|
+
|
|
6
|
+
export class AppTypePlugin implements PluginDefinition {
|
|
7
|
+
constructor(readonly pattern: string, private appType: ApplicationType<unknown>, private appSlot: ApplicationSlot) {}
|
|
8
|
+
|
|
9
|
+
runtimes = [MainRuntime.name];
|
|
10
|
+
|
|
11
|
+
register(object: any) {
|
|
12
|
+
this.appSlot.register([this.appType.createApp(object)]);
|
|
13
|
+
}
|
|
14
|
+
}
|
package/app.plugin.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PluginDefinition } from '@teambit/aspect-loader';
|
|
2
|
+
import { MainRuntime } from '@teambit/cli';
|
|
3
|
+
import { ApplicationSlot } from './application.main.runtime';
|
|
4
|
+
|
|
5
|
+
export class AppPlugin implements PluginDefinition {
|
|
6
|
+
constructor(private appSlot: ApplicationSlot) {}
|
|
7
|
+
|
|
8
|
+
pattern = '*.app.*';
|
|
9
|
+
|
|
10
|
+
runtimes = [MainRuntime.name];
|
|
11
|
+
|
|
12
|
+
register(object: any) {
|
|
13
|
+
return this.appSlot.register([object]);
|
|
14
|
+
}
|
|
15
|
+
}
|
package/application-type.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { Application } from './application';
|
|
2
|
+
|
|
3
|
+
export interface ApplicationType<T> {
|
|
4
|
+
/**
|
|
5
|
+
* name of the type of the app. e.g. `react-app`
|
|
6
|
+
*/
|
|
2
7
|
name: string;
|
|
3
|
-
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* a function that creates the app instance.
|
|
11
|
+
*/
|
|
12
|
+
createApp(options: T): Application;
|
|
4
13
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MainRuntime, CLIMain, CLIAspect } from '@teambit/cli';
|
|
2
2
|
import { flatten } from 'lodash';
|
|
3
|
+
import { AspectLoaderMain, AspectLoaderAspect } from '@teambit/aspect-loader';
|
|
3
4
|
import { Slot, SlotRegistry } from '@teambit/harmony';
|
|
4
5
|
import { BuilderAspect, BuilderMain } from '@teambit/builder';
|
|
5
6
|
import { LoggerAspect, LoggerMain } from '@teambit/logger';
|
|
@@ -15,8 +16,10 @@ import { DeployTask } from './deploy.task';
|
|
|
15
16
|
import { RunCmd } from './run.cmd';
|
|
16
17
|
import { AppService } from './application.service';
|
|
17
18
|
import { AppCmd, AppListCmd } from './app.cmd';
|
|
19
|
+
import { AppPlugin } from './app.plugin';
|
|
20
|
+
import { AppTypePlugin } from './app-type.plugin';
|
|
18
21
|
|
|
19
|
-
export type ApplicationTypeSlot = SlotRegistry<ApplicationType[]>;
|
|
22
|
+
export type ApplicationTypeSlot = SlotRegistry<ApplicationType<unknown>[]>;
|
|
20
23
|
export type ApplicationSlot = SlotRegistry<Application[]>;
|
|
21
24
|
export type DeploymentProviderSlot = SlotRegistry<DeploymentProvider[]>;
|
|
22
25
|
|
|
@@ -41,7 +44,8 @@ export class ApplicationMain {
|
|
|
41
44
|
private deploymentProviderSlot: DeploymentProviderSlot,
|
|
42
45
|
private envs: EnvsMain,
|
|
43
46
|
private componentAspect: ComponentMain,
|
|
44
|
-
private appService: AppService
|
|
47
|
+
private appService: AppService,
|
|
48
|
+
private aspectLoader: AspectLoaderMain
|
|
45
49
|
) {}
|
|
46
50
|
|
|
47
51
|
/**
|
|
@@ -52,14 +56,6 @@ export class ApplicationMain {
|
|
|
52
56
|
return this;
|
|
53
57
|
}
|
|
54
58
|
|
|
55
|
-
/**
|
|
56
|
-
* register multiple apps.
|
|
57
|
-
*/
|
|
58
|
-
registerApps(apps: Application[]) {
|
|
59
|
-
this.appSlot.register(apps);
|
|
60
|
-
return this;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
59
|
/**
|
|
64
60
|
* list all registered apps.
|
|
65
61
|
*/
|
|
@@ -90,6 +86,16 @@ export class ApplicationMain {
|
|
|
90
86
|
return apps.find((app) => app.name === appName);
|
|
91
87
|
}
|
|
92
88
|
|
|
89
|
+
/**
|
|
90
|
+
* registers a new app and sets a plugin for it.
|
|
91
|
+
*/
|
|
92
|
+
registerAppType<T>(appType: ApplicationType<T>) {
|
|
93
|
+
const plugin = new AppTypePlugin(`*.${appType.name}.*`, appType, this.appSlot);
|
|
94
|
+
this.aspectLoader.registerPlugins([plugin]);
|
|
95
|
+
this.appTypeSlot.register([appType]);
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
|
|
93
99
|
/**
|
|
94
100
|
* get an app AspectId.
|
|
95
101
|
*/
|
|
@@ -152,24 +158,40 @@ export class ApplicationMain {
|
|
|
152
158
|
}
|
|
153
159
|
|
|
154
160
|
static runtime = MainRuntime;
|
|
155
|
-
static dependencies = [CLIAspect, LoggerAspect, BuilderAspect, EnvsAspect, ComponentAspect];
|
|
161
|
+
static dependencies = [CLIAspect, LoggerAspect, BuilderAspect, EnvsAspect, ComponentAspect, AspectLoaderAspect];
|
|
156
162
|
|
|
157
163
|
static slots = [
|
|
158
|
-
Slot.withType<ApplicationType[]>(),
|
|
164
|
+
Slot.withType<ApplicationType<unknown>[]>(),
|
|
159
165
|
Slot.withType<Application[]>(),
|
|
160
166
|
Slot.withType<DeploymentProvider[]>(),
|
|
161
167
|
];
|
|
162
168
|
|
|
163
169
|
static async provider(
|
|
164
|
-
[cli, loggerAspect, builder, envs, component]: [
|
|
170
|
+
[cli, loggerAspect, builder, envs, component, aspectLoader]: [
|
|
171
|
+
CLIMain,
|
|
172
|
+
LoggerMain,
|
|
173
|
+
BuilderMain,
|
|
174
|
+
EnvsMain,
|
|
175
|
+
ComponentMain,
|
|
176
|
+
AspectLoaderMain
|
|
177
|
+
],
|
|
165
178
|
config: ApplicationAspectConfig,
|
|
166
179
|
[appTypeSlot, appSlot, deploymentProviderSlot]: [ApplicationTypeSlot, ApplicationSlot, DeploymentProviderSlot]
|
|
167
180
|
) {
|
|
168
181
|
const logger = loggerAspect.createLogger(ApplicationAspect.id);
|
|
169
182
|
const appService = new AppService();
|
|
170
|
-
const application = new ApplicationMain(
|
|
183
|
+
const application = new ApplicationMain(
|
|
184
|
+
appSlot,
|
|
185
|
+
appTypeSlot,
|
|
186
|
+
deploymentProviderSlot,
|
|
187
|
+
envs,
|
|
188
|
+
component,
|
|
189
|
+
appService,
|
|
190
|
+
aspectLoader
|
|
191
|
+
);
|
|
171
192
|
const appCmd = new AppCmd();
|
|
172
193
|
appCmd.commands = [new AppListCmd(application)];
|
|
194
|
+
aspectLoader.registerPlugins([new AppPlugin(appSlot)]);
|
|
173
195
|
builder.registerTagTasks([new DeployTask(application)]);
|
|
174
196
|
cli.registerGroup('apps', 'Applications');
|
|
175
197
|
cli.register(new RunCmd(application, logger), new AppListCmdDeprecated(application), appCmd);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PluginDefinition } from '@teambit/aspect-loader';
|
|
2
|
+
import { ApplicationType } from './application-type';
|
|
3
|
+
import { ApplicationSlot } from './application.main.runtime';
|
|
4
|
+
export declare class AppTypePlugin implements PluginDefinition {
|
|
5
|
+
readonly pattern: string;
|
|
6
|
+
private appType;
|
|
7
|
+
private appSlot;
|
|
8
|
+
constructor(pattern: string, appType: ApplicationType<unknown>, appSlot: ApplicationSlot);
|
|
9
|
+
runtimes: string[];
|
|
10
|
+
register(object: any): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.AppTypePlugin = void 0;
|
|
9
|
+
|
|
10
|
+
function _defineProperty2() {
|
|
11
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
+
|
|
13
|
+
_defineProperty2 = function () {
|
|
14
|
+
return data;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function _cli() {
|
|
21
|
+
const data = require("@teambit/cli");
|
|
22
|
+
|
|
23
|
+
_cli = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
class AppTypePlugin {
|
|
31
|
+
constructor(pattern, appType, appSlot) {
|
|
32
|
+
this.pattern = pattern;
|
|
33
|
+
this.appType = appType;
|
|
34
|
+
this.appSlot = appSlot;
|
|
35
|
+
(0, _defineProperty2().default)(this, "runtimes", [_cli().MainRuntime.name]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
register(object) {
|
|
39
|
+
this.appSlot.register([this.appType.createApp(object)]);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
exports.AppTypePlugin = AppTypePlugin;
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=app-type.plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["app-type.plugin.ts"],"names":["AppTypePlugin","constructor","pattern","appType","appSlot","MainRuntime","name","register","object","createApp"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIO,MAAMA,aAAN,CAAgD;AACrDC,EAAAA,WAAW,CAAUC,OAAV,EAAmCC,OAAnC,EAA8EC,OAA9E,EAAwG;AAAA,SAA9FF,OAA8F,GAA9FA,OAA8F;AAAA,SAArEC,OAAqE,GAArEA,OAAqE;AAAA,SAA1BC,OAA0B,GAA1BA,OAA0B;AAAA,sDAExG,CAACC,mBAAYC,IAAb,CAFwG;AAAE;;AAIrHC,EAAAA,QAAQ,CAACC,MAAD,EAAc;AACpB,SAAKJ,OAAL,CAAaG,QAAb,CAAsB,CAAC,KAAKJ,OAAL,CAAaM,SAAb,CAAuBD,MAAvB,CAAD,CAAtB;AACD;;AAPoD","sourcesContent":["import { PluginDefinition } from '@teambit/aspect-loader';\nimport { MainRuntime } from '@teambit/cli';\nimport { ApplicationType } from './application-type';\nimport { ApplicationSlot } from './application.main.runtime';\n\nexport class AppTypePlugin implements PluginDefinition {\n constructor(readonly pattern: string, private appType: ApplicationType<unknown>, private appSlot: ApplicationSlot) {}\n\n runtimes = [MainRuntime.name];\n\n register(object: any) {\n this.appSlot.register([this.appType.createApp(object)]);\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PluginDefinition } from '@teambit/aspect-loader';
|
|
2
|
+
import { ApplicationSlot } from './application.main.runtime';
|
|
3
|
+
export declare class AppPlugin implements PluginDefinition {
|
|
4
|
+
private appSlot;
|
|
5
|
+
constructor(appSlot: ApplicationSlot);
|
|
6
|
+
pattern: string;
|
|
7
|
+
runtimes: string[];
|
|
8
|
+
register(object: any): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.AppPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
function _defineProperty2() {
|
|
11
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
+
|
|
13
|
+
_defineProperty2 = function () {
|
|
14
|
+
return data;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function _cli() {
|
|
21
|
+
const data = require("@teambit/cli");
|
|
22
|
+
|
|
23
|
+
_cli = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
class AppPlugin {
|
|
31
|
+
constructor(appSlot) {
|
|
32
|
+
this.appSlot = appSlot;
|
|
33
|
+
(0, _defineProperty2().default)(this, "pattern", '*.app.*');
|
|
34
|
+
(0, _defineProperty2().default)(this, "runtimes", [_cli().MainRuntime.name]);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
register(object) {
|
|
38
|
+
return this.appSlot.register([object]);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
exports.AppPlugin = AppPlugin;
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=app.plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["app.plugin.ts"],"names":["AppPlugin","constructor","appSlot","MainRuntime","name","register","object"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,SAAN,CAA4C;AACjDC,EAAAA,WAAW,CAASC,OAAT,EAAmC;AAAA,SAA1BA,OAA0B,GAA1BA,OAA0B;AAAA,qDAEpC,SAFoC;AAAA,sDAInC,CAACC,mBAAYC,IAAb,CAJmC;AAAE;;AAMhDC,EAAAA,QAAQ,CAACC,MAAD,EAAc;AACpB,WAAO,KAAKJ,OAAL,CAAaG,QAAb,CAAsB,CAACC,MAAD,CAAtB,CAAP;AACD;;AATgD","sourcesContent":["import { PluginDefinition } from '@teambit/aspect-loader';\nimport { MainRuntime } from '@teambit/cli';\nimport { ApplicationSlot } from './application.main.runtime';\n\nexport class AppPlugin implements PluginDefinition {\n constructor(private appSlot: ApplicationSlot) {}\n\n pattern = '*.app.*';\n\n runtimes = [MainRuntime.name];\n\n register(object: any) {\n return this.appSlot.register([object]);\n }\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CLIMain } from '@teambit/cli';
|
|
2
|
+
import { AspectLoaderMain } from '@teambit/aspect-loader';
|
|
2
3
|
import { SlotRegistry } from '@teambit/harmony';
|
|
3
4
|
import { BuilderMain } from '@teambit/builder';
|
|
4
5
|
import { LoggerMain } from '@teambit/logger';
|
|
@@ -8,7 +9,7 @@ import { ApplicationType } from './application-type';
|
|
|
8
9
|
import { Application } from './application';
|
|
9
10
|
import { DeploymentProvider } from './deployment-provider';
|
|
10
11
|
import { AppService } from './application.service';
|
|
11
|
-
export declare type ApplicationTypeSlot = SlotRegistry<ApplicationType[]>;
|
|
12
|
+
export declare type ApplicationTypeSlot = SlotRegistry<ApplicationType<unknown>[]>;
|
|
12
13
|
export declare type ApplicationSlot = SlotRegistry<Application[]>;
|
|
13
14
|
export declare type DeploymentProviderSlot = SlotRegistry<DeploymentProvider[]>;
|
|
14
15
|
export declare type ApplicationAspectConfig = {};
|
|
@@ -23,13 +24,14 @@ export declare class ApplicationMain {
|
|
|
23
24
|
private envs;
|
|
24
25
|
private componentAspect;
|
|
25
26
|
private appService;
|
|
26
|
-
|
|
27
|
+
private aspectLoader;
|
|
28
|
+
constructor(appSlot: ApplicationSlot, appTypeSlot: ApplicationTypeSlot, deploymentProviderSlot: DeploymentProviderSlot, envs: EnvsMain, componentAspect: ComponentMain, appService: AppService, aspectLoader: AspectLoaderMain);
|
|
27
29
|
registerApp(app: Application): this;
|
|
28
|
-
registerApps(apps: Application[]): this;
|
|
29
30
|
listApps(): Application[];
|
|
30
31
|
registerDeploymentProvider(provider: DeploymentProvider): this;
|
|
31
32
|
listProviders(): DeploymentProvider[];
|
|
32
33
|
getApp(appName: string): Application | undefined;
|
|
34
|
+
registerAppType<T>(appType: ApplicationType<T>): this;
|
|
33
35
|
getAppAspect(appName: string): string | undefined;
|
|
34
36
|
getAppOrThrow(appName: string): Application;
|
|
35
37
|
private computeOptions;
|
|
@@ -41,6 +43,13 @@ export declare class ApplicationMain {
|
|
|
41
43
|
private createAppContext;
|
|
42
44
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
43
45
|
static dependencies: import("@teambit/harmony").Aspect[];
|
|
44
|
-
static slots: (((registerFn: () => string) => SlotRegistry<ApplicationType[]>) | ((registerFn: () => string) => SlotRegistry<Application[]>) | ((registerFn: () => string) => SlotRegistry<DeploymentProvider[]>))[];
|
|
45
|
-
static provider([cli, loggerAspect, builder, envs, component
|
|
46
|
+
static slots: (((registerFn: () => string) => SlotRegistry<ApplicationType<unknown>[]>) | ((registerFn: () => string) => SlotRegistry<Application[]>) | ((registerFn: () => string) => SlotRegistry<DeploymentProvider[]>))[];
|
|
47
|
+
static provider([cli, loggerAspect, builder, envs, component, aspectLoader]: [
|
|
48
|
+
CLIMain,
|
|
49
|
+
LoggerMain,
|
|
50
|
+
BuilderMain,
|
|
51
|
+
EnvsMain,
|
|
52
|
+
ComponentMain,
|
|
53
|
+
AspectLoaderMain
|
|
54
|
+
], config: ApplicationAspectConfig, [appTypeSlot, appSlot, deploymentProviderSlot]: [ApplicationTypeSlot, ApplicationSlot, DeploymentProviderSlot]): Promise<ApplicationMain>;
|
|
46
55
|
}
|
|
@@ -41,6 +41,16 @@ function _lodash() {
|
|
|
41
41
|
return data;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
function _aspectLoader() {
|
|
45
|
+
const data = require("@teambit/aspect-loader");
|
|
46
|
+
|
|
47
|
+
_aspectLoader = function () {
|
|
48
|
+
return data;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
|
|
44
54
|
function _harmony() {
|
|
45
55
|
const data = require("@teambit/harmony");
|
|
46
56
|
|
|
@@ -161,6 +171,26 @@ function _app() {
|
|
|
161
171
|
return data;
|
|
162
172
|
}
|
|
163
173
|
|
|
174
|
+
function _app2() {
|
|
175
|
+
const data = require("./app.plugin");
|
|
176
|
+
|
|
177
|
+
_app2 = function () {
|
|
178
|
+
return data;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
return data;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function _appType() {
|
|
185
|
+
const data = require("./app-type.plugin");
|
|
186
|
+
|
|
187
|
+
_appType = function () {
|
|
188
|
+
return data;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
return data;
|
|
192
|
+
}
|
|
193
|
+
|
|
164
194
|
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); }
|
|
165
195
|
|
|
166
196
|
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; }
|
|
@@ -170,13 +200,14 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
170
200
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
171
201
|
|
|
172
202
|
class ApplicationMain {
|
|
173
|
-
constructor(appSlot, appTypeSlot, deploymentProviderSlot, envs, componentAspect, appService) {
|
|
203
|
+
constructor(appSlot, appTypeSlot, deploymentProviderSlot, envs, componentAspect, appService, aspectLoader) {
|
|
174
204
|
this.appSlot = appSlot;
|
|
175
205
|
this.appTypeSlot = appTypeSlot;
|
|
176
206
|
this.deploymentProviderSlot = deploymentProviderSlot;
|
|
177
207
|
this.envs = envs;
|
|
178
208
|
this.componentAspect = componentAspect;
|
|
179
209
|
this.appService = appService;
|
|
210
|
+
this.aspectLoader = aspectLoader;
|
|
180
211
|
}
|
|
181
212
|
/**
|
|
182
213
|
* register a new app.
|
|
@@ -187,15 +218,6 @@ class ApplicationMain {
|
|
|
187
218
|
this.appSlot.register([app]);
|
|
188
219
|
return this;
|
|
189
220
|
}
|
|
190
|
-
/**
|
|
191
|
-
* register multiple apps.
|
|
192
|
-
*/
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
registerApps(apps) {
|
|
196
|
-
this.appSlot.register(apps);
|
|
197
|
-
return this;
|
|
198
|
-
}
|
|
199
221
|
/**
|
|
200
222
|
* list all registered apps.
|
|
201
223
|
*/
|
|
@@ -230,6 +252,17 @@ class ApplicationMain {
|
|
|
230
252
|
const apps = this.listApps();
|
|
231
253
|
return apps.find(app => app.name === appName);
|
|
232
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* registers a new app and sets a plugin for it.
|
|
257
|
+
*/
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
registerAppType(appType) {
|
|
261
|
+
const plugin = new (_appType().AppTypePlugin)(`*.${appType.name}.*`, appType, this.appSlot);
|
|
262
|
+
this.aspectLoader.registerPlugins([plugin]);
|
|
263
|
+
this.appTypeSlot.register([appType]);
|
|
264
|
+
return this;
|
|
265
|
+
}
|
|
233
266
|
/**
|
|
234
267
|
* get an app AspectId.
|
|
235
268
|
*/
|
|
@@ -296,12 +329,13 @@ class ApplicationMain {
|
|
|
296
329
|
return res.results[0].data;
|
|
297
330
|
}
|
|
298
331
|
|
|
299
|
-
static async provider([cli, loggerAspect, builder, envs, component], config, [appTypeSlot, appSlot, deploymentProviderSlot]) {
|
|
332
|
+
static async provider([cli, loggerAspect, builder, envs, component, aspectLoader], config, [appTypeSlot, appSlot, deploymentProviderSlot]) {
|
|
300
333
|
const logger = loggerAspect.createLogger(_application().ApplicationAspect.id);
|
|
301
334
|
const appService = new (_application2().AppService)();
|
|
302
|
-
const application = new ApplicationMain(appSlot, appTypeSlot, deploymentProviderSlot, envs, component, appService);
|
|
335
|
+
const application = new ApplicationMain(appSlot, appTypeSlot, deploymentProviderSlot, envs, component, appService, aspectLoader);
|
|
303
336
|
const appCmd = new (_app().AppCmd)();
|
|
304
337
|
appCmd.commands = [new (_app().AppListCmd)(application)];
|
|
338
|
+
aspectLoader.registerPlugins([new (_app2().AppPlugin)(appSlot)]);
|
|
305
339
|
builder.registerTagTasks([new (_deploy().DeployTask)(application)]);
|
|
306
340
|
cli.registerGroup('apps', 'Applications');
|
|
307
341
|
cli.register(new (_run().RunCmd)(application, logger), new (_appList().AppListCmdDeprecated)(application), appCmd);
|
|
@@ -312,7 +346,7 @@ class ApplicationMain {
|
|
|
312
346
|
|
|
313
347
|
exports.ApplicationMain = ApplicationMain;
|
|
314
348
|
(0, _defineProperty2().default)(ApplicationMain, "runtime", _cli().MainRuntime);
|
|
315
|
-
(0, _defineProperty2().default)(ApplicationMain, "dependencies", [_cli().CLIAspect, _logger().LoggerAspect, _builder().BuilderAspect, _envs().EnvsAspect, _component().default]);
|
|
349
|
+
(0, _defineProperty2().default)(ApplicationMain, "dependencies", [_cli().CLIAspect, _logger().LoggerAspect, _builder().BuilderAspect, _envs().EnvsAspect, _component().default, _aspectLoader().AspectLoaderAspect]);
|
|
316
350
|
(0, _defineProperty2().default)(ApplicationMain, "slots", [_harmony().Slot.withType(), _harmony().Slot.withType(), _harmony().Slot.withType()]);
|
|
317
351
|
|
|
318
352
|
_application().ApplicationAspect.addRuntime(ApplicationMain);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["application.main.runtime.ts"],"names":["ApplicationMain","constructor","appSlot","appTypeSlot","deploymentProviderSlot","envs","componentAspect","appService","registerApp","app","register","registerApps","apps","listApps","values","registerDeploymentProvider","provider","listProviders","getApp","appName","find","name","getAppAspect","toArray","getAppOrThrow","AppNotFound","computeOptions","opts","defaultOpts","dev","defaultPortRange","runApp","options","context","createAppContext","port","run","getAppIdOrThrow","maybeApp","ComponentID","fromString","host","getHost","components","list","id","component","c","isEqual","env","createEnvironment","res","results","data","cli","loggerAspect","builder","config","logger","createLogger","ApplicationAspect","AppService","application","appCmd","AppCmd","commands","AppListCmd","registerTagTasks","DeployTask","registerGroup","RunCmd","AppListCmdDeprecated","MainRuntime","CLIAspect","LoggerAspect","BuilderAspect","EnvsAspect","ComponentAspect","Slot","withType","addRuntime"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAA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AAD,EAAYC,sBAAZ,EAA0BC,wBAA1B,EAAyCC,kBAAzC,EAAqDC,oBAArD,C;gCAtHX7E,e,WAwHI,CACb8E,gBAAKC,QAAL,EADa,EAEbD,gBAAKC,QAAL,EAFa,EAGbD,gBAAKC,QAAL,EAHa,C;;AAwBjBnB,iCAAkBoB,UAAlB,CAA6BhF,eAA7B","sourcesContent":["import { MainRuntime, CLIMain, CLIAspect } from '@teambit/cli';\nimport { flatten } from 'lodash';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { BuilderAspect, BuilderMain } from '@teambit/builder';\nimport { 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 { DeployTask } from './deploy.task';\nimport { RunCmd } from './run.cmd';\nimport { AppService } from './application.service';\nimport { AppCmd, AppListCmd } from './app.cmd';\n\nexport type ApplicationTypeSlot = SlotRegistry<ApplicationType[]>;\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?: number[];\n\n /**\n * determine whether to start the application in dev mode.\n */\n dev: boolean;\n};\n\nexport class ApplicationMain {\n constructor(\n private appSlot: ApplicationSlot,\n private appTypeSlot: ApplicationTypeSlot,\n private deploymentProviderSlot: DeploymentProviderSlot,\n private envs: EnvsMain,\n private componentAspect: ComponentMain,\n private appService: AppService\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 * register multiple apps.\n */\n registerApps(apps: Application[]) {\n this.appSlot.register(apps);\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 * register new deployment provider like netlify, cloudflare pages or custom deployment.\n */\n registerDeploymentProvider(provider: DeploymentProvider) {\n this.deploymentProviderSlot.register([provider]);\n return this;\n }\n\n /**\n * list all deployment providers\n */\n listProviders() {\n return flatten(this.deploymentProviderSlot.values());\n }\n\n /**\n * get an app.\n */\n getApp(appName: string): Application | undefined {\n const apps = this.listApps();\n return apps.find((app) => app.name === appName);\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.getApp(appName);\n if (!app) throw new AppNotFound(appName);\n return app;\n }\n\n private computeOptions(opts: Partial<ServeAppOptions>) {\n const defaultOpts: ServeAppOptions = {\n dev: false,\n defaultPortRange: [3100, 3500],\n };\n\n return {\n defaultOpts,\n ...opts,\n };\n }\n\n async runApp(appName: string, options: Partial<ServeAppOptions> = {}) {\n const app = this.getAppOrThrow(appName);\n this.computeOptions(options);\n const context = await this.createAppContext(appName);\n if (!context) throw new AppNotFound(appName);\n const port = await app.run(context);\n return { app, port };\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) {\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\n const env = await this.envs.createEnvironment([component]);\n const res = await env.run(this.appService);\n return res.results[0].data;\n }\n\n static runtime = MainRuntime;\n static dependencies = [CLIAspect, LoggerAspect, BuilderAspect, EnvsAspect, ComponentAspect];\n\n static slots = [\n Slot.withType<ApplicationType[]>(),\n Slot.withType<Application[]>(),\n Slot.withType<DeploymentProvider[]>(),\n ];\n\n static async provider(\n [cli, loggerAspect, builder, envs, component]: [CLIMain, LoggerMain, BuilderMain, EnvsMain, ComponentMain],\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(appSlot, appTypeSlot, deploymentProviderSlot, envs, component, appService);\n const appCmd = new AppCmd();\n appCmd.commands = [new AppListCmd(application)];\n builder.registerTagTasks([new DeployTask(application)]);\n cli.registerGroup('apps', 'Applications');\n cli.register(new RunCmd(application, logger), new AppListCmdDeprecated(application), appCmd);\n\n return application;\n }\n}\n\nApplicationAspect.addRuntime(ApplicationMain);\n"]}
|
|
1
|
+
{"version":3,"sources":["application.main.runtime.ts"],"names":["ApplicationMain","constructor","appSlot","appTypeSlot","deploymentProviderSlot","envs","componentAspect","appService","aspectLoader","registerApp","app","register","listApps","values","registerDeploymentProvider","provider","listProviders","getApp","appName","apps","find","name","registerAppType","appType","plugin","AppTypePlugin","registerPlugins","getAppAspect","toArray","getAppOrThrow","AppNotFound","computeOptions","opts","defaultOpts","dev","defaultPortRange","runApp","options","context","createAppContext","port","run","getAppIdOrThrow","maybeApp","ComponentID","fromString","host","getHost","components","list","id","component","c","isEqual","env","createEnvironment","res","results","data","cli","loggerAspect","builder","config","logger","createLogger","ApplicationAspect","AppService","application","appCmd","AppCmd","commands","AppListCmd","AppPlugin","registerTagTasks","DeployTask","registerGroup","RunCmd","AppListCmdDeprecated","MainRuntime","CLIAspect","LoggerAspect","BuilderAspect","EnvsAspect","ComponentAspect","AspectLoaderAspect","Slot","withType","addRuntime"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AA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,MAAM,CAACE,QAAP,GAAkB,CAAC,KAAIC,iBAAJ,EAAeJ,WAAf,CAAD,CAAlB;AACA3D,IAAAA,YAAY,CAACkB,eAAb,CAA6B,CAAC,KAAI8C,iBAAJ,EAActE,OAAd,CAAD,CAA7B;AACA2D,IAAAA,OAAO,CAACY,gBAAR,CAAyB,CAAC,KAAIC,oBAAJ,EAAeP,WAAf,CAAD,CAAzB;AACAR,IAAAA,GAAG,CAACgB,aAAJ,CAAkB,MAAlB,EAA0B,cAA1B;AACAhB,IAAAA,GAAG,CAAChD,QAAJ,CAAa,KAAIiE,aAAJ,EAAWT,WAAX,EAAwBJ,MAAxB,CAAb,EAA8C,KAAIc,+BAAJ,EAAyBV,WAAzB,CAA9C,EAAqFC,MAArF;AAEA,WAAOD,WAAP;AACD;;AAhK0B;;;gCAAhBnE,e,aAwHM8E,kB;gCAxHN9E,e,kBAyHW,CAAC+E,gBAAD,EAAYC,sBAAZ,EAA0BC,wBAA1B,EAAyCC,kBAAzC,EAAqDC,oBAArD,EAAsEC,kCAAtE,C;gCAzHXpF,e,WA2HI,CACbqF,gBAAKC,QAAL,EADa,EAEbD,gBAAKC,QAAL,EAFa,EAGbD,gBAAKC,QAAL,EAHa,C;;AAwCjBrB,iCAAkBsB,UAAlB,CAA6BvF,eAA7B","sourcesContent":["import { MainRuntime, CLIMain, CLIAspect } from '@teambit/cli';\nimport { flatten } from 'lodash';\nimport { AspectLoaderMain, AspectLoaderAspect } from '@teambit/aspect-loader';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { BuilderAspect, BuilderMain } from '@teambit/builder';\nimport { 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 { DeployTask } from './deploy.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';\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?: number[];\n\n /**\n * determine whether to start the application in dev mode.\n */\n dev: boolean;\n};\n\nexport class ApplicationMain {\n constructor(\n private appSlot: ApplicationSlot,\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 ) {}\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 * register new deployment provider like netlify, cloudflare pages or custom deployment.\n */\n registerDeploymentProvider(provider: DeploymentProvider) {\n this.deploymentProviderSlot.register([provider]);\n return this;\n }\n\n /**\n * list all deployment providers\n */\n listProviders() {\n return flatten(this.deploymentProviderSlot.values());\n }\n\n /**\n * get an app.\n */\n getApp(appName: string): Application | undefined {\n const apps = this.listApps();\n return apps.find((app) => app.name === appName);\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.getApp(appName);\n if (!app) throw new AppNotFound(appName);\n return app;\n }\n\n private computeOptions(opts: Partial<ServeAppOptions>) {\n const defaultOpts: ServeAppOptions = {\n dev: false,\n defaultPortRange: [3100, 3500],\n };\n\n return {\n defaultOpts,\n ...opts,\n };\n }\n\n async runApp(appName: string, options: Partial<ServeAppOptions> = {}) {\n const app = this.getAppOrThrow(appName);\n this.computeOptions(options);\n const context = await this.createAppContext(appName);\n if (!context) throw new AppNotFound(appName);\n const port = await app.run(context);\n return { app, port };\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) {\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\n const env = await this.envs.createEnvironment([component]);\n const res = await env.run(this.appService);\n return res.results[0].data;\n }\n\n static runtime = MainRuntime;\n static dependencies = [CLIAspect, LoggerAspect, BuilderAspect, EnvsAspect, ComponentAspect, AspectLoaderAspect];\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]: [\n CLIMain,\n LoggerMain,\n BuilderMain,\n EnvsMain,\n ComponentMain,\n AspectLoaderMain\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 );\n const appCmd = new AppCmd();\n appCmd.commands = [new AppListCmd(application)];\n aspectLoader.registerPlugins([new AppPlugin(appSlot)]);\n builder.registerTagTasks([new DeployTask(application)]);\n cli.registerGroup('apps', 'Applications');\n cli.register(new RunCmd(application, logger), new AppListCmdDeprecated(application), appCmd);\n\n return application;\n }\n}\n\nApplicationAspect.addRuntime(ApplicationMain);\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export type { ApplicationMain } from './application.main.runtime';
|
|
|
3
3
|
export type { Application } from './application';
|
|
4
4
|
export { AppContext } from './app-context';
|
|
5
5
|
export { DeploymentProvider } from './deployment-provider';
|
|
6
|
+
export { ApplicationType } from './application-type';
|
|
6
7
|
export { DeployContext } from './deploy-context';
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,12 @@ Object.defineProperty(exports, "DeploymentProvider", {
|
|
|
21
21
|
return _deploymentProvider().DeploymentProvider;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
+
Object.defineProperty(exports, "ApplicationType", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _applicationType().ApplicationType;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
24
30
|
Object.defineProperty(exports, "DeployContext", {
|
|
25
31
|
enumerable: true,
|
|
26
32
|
get: function () {
|
|
@@ -58,6 +64,16 @@ function _deploymentProvider() {
|
|
|
58
64
|
return data;
|
|
59
65
|
}
|
|
60
66
|
|
|
67
|
+
function _applicationType() {
|
|
68
|
+
const data = require("./application-type");
|
|
69
|
+
|
|
70
|
+
_applicationType = function () {
|
|
71
|
+
return data;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return data;
|
|
75
|
+
}
|
|
76
|
+
|
|
61
77
|
function _deployContext() {
|
|
62
78
|
const data = require("./deploy-context");
|
|
63
79
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA","sourcesContent":["export { ApplicationAspect } from './application.aspect';\nexport type { ApplicationMain } from './application.main.runtime';\nexport type { Application } from './application';\nexport { AppContext } from './app-context';\nexport { DeploymentProvider } from './deployment-provider';\nexport { ApplicationType } from './application-type';\nexport { DeployContext } from './deploy-context';\n"]}
|
package/index.ts
CHANGED
|
@@ -3,4 +3,5 @@ export type { ApplicationMain } from './application.main.runtime';
|
|
|
3
3
|
export type { Application } from './application';
|
|
4
4
|
export { AppContext } from './app-context';
|
|
5
5
|
export { DeploymentProvider } from './deployment-provider';
|
|
6
|
+
export { ApplicationType } from './application-type';
|
|
6
7
|
export { DeployContext } from './deploy-context';
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/application",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.165",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/harmony/application",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.harmony",
|
|
8
8
|
"name": "application",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.165"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
@@ -16,13 +16,14 @@
|
|
|
16
16
|
"ink": "3.0.8",
|
|
17
17
|
"@babel/runtime": "7.12.18",
|
|
18
18
|
"core-js": "^3.0.0",
|
|
19
|
-
"@teambit/envs": "0.0.
|
|
19
|
+
"@teambit/envs": "0.0.523",
|
|
20
20
|
"@teambit/cli-table": "0.0.2",
|
|
21
21
|
"@teambit/cli": "0.0.379",
|
|
22
|
-
"@teambit/
|
|
23
|
-
"@teambit/
|
|
24
|
-
"@teambit/
|
|
25
|
-
"@teambit/
|
|
22
|
+
"@teambit/aspect-loader": "0.0.523",
|
|
23
|
+
"@teambit/builder": "0.0.523",
|
|
24
|
+
"@teambit/component": "0.0.523",
|
|
25
|
+
"@teambit/logger": "0.0.449",
|
|
26
|
+
"@teambit/isolator": "0.0.523"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@types/lodash": "4.14.165",
|
|
Binary file
|