@teambit/application 0.0.587 → 0.0.588
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-type-list.d.ts +13 -0
- package/dist/app-type-list.js +25 -0
- package/dist/app-type-list.js.map +1 -0
- package/dist/application.main.runtime.d.ts +15 -4
- package/dist/application.main.runtime.js +20 -8
- package/dist/application.main.runtime.js.map +1 -1
- package/dist/application.service.d.ts +8 -1
- package/dist/application.service.js +16 -1
- package/dist/application.service.js.map +1 -1
- package/dist/apps-env-type.d.ts +8 -0
- package/dist/apps-env-type.js +3 -0
- package/dist/apps-env-type.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/{preview-1672284308356.js → preview-1672331186584.js} +2 -2
- package/package-tar/teambit-application-0.0.588.tgz +0 -0
- package/package.json +8 -8
- package/package-tar/teambit-application-0.0.587.tgz +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EnvContext, EnvHandler } from "@teambit/envs";
|
|
2
|
+
import { ApplicationType } from "./application-type";
|
|
3
|
+
export declare type AppTypeListOptions = {
|
|
4
|
+
name?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare class AppTypeList {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
private appTypes;
|
|
9
|
+
private context;
|
|
10
|
+
constructor(name: string, appTypes: EnvHandler<ApplicationType<any>>[], context: EnvContext);
|
|
11
|
+
compute(): ApplicationType<any>[];
|
|
12
|
+
static from(appTypes: EnvHandler<ApplicationType<any>>[], options?: AppTypeListOptions): EnvHandler<AppTypeList>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AppTypeList = void 0;
|
|
7
|
+
class AppTypeList {
|
|
8
|
+
constructor(name, appTypes, context) {
|
|
9
|
+
this.name = name;
|
|
10
|
+
this.appTypes = appTypes;
|
|
11
|
+
this.context = context;
|
|
12
|
+
}
|
|
13
|
+
compute() {
|
|
14
|
+
return this.appTypes.map(appType => appType(this.context));
|
|
15
|
+
}
|
|
16
|
+
static from(appTypes, options = {}) {
|
|
17
|
+
return context => {
|
|
18
|
+
const name = options.name || 'app-type-list';
|
|
19
|
+
return new AppTypeList(name, appTypes, context);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.AppTypeList = AppTypeList;
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=app-type-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AppTypeList","constructor","name","appTypes","context","compute","map","appType","from","options"],"sources":["app-type-list.ts"],"sourcesContent":["import { EnvContext, EnvHandler } from \"@teambit/envs\";\nimport { ApplicationType } from \"./application-type\";\n\nexport type AppTypeListOptions = {\n name?: string;\n};\n\nexport class AppTypeList {\n constructor(\n readonly name: string,\n private appTypes: EnvHandler<ApplicationType<any>>[],\n private context: EnvContext\n ) {}\n\n compute(): ApplicationType<any>[] {\n return this.appTypes.map((appType) => appType(this.context))\n }\n\n static from(appTypes: EnvHandler<ApplicationType<any>>[], options: AppTypeListOptions = {}): EnvHandler<AppTypeList> {\n return (context: EnvContext) => {\n const name = options.name || 'app-type-list';\n return new AppTypeList(name, appTypes, context);\n };\n }\n}\n"],"mappings":";;;;;;AAOO,MAAMA,WAAW,CAAC;EACvBC,WAAW,CACAC,IAAY,EACbC,QAA4C,EAC5CC,OAAmB,EAC3B;IAAA,KAHSF,IAAY,GAAZA,IAAY;IAAA,KACbC,QAA4C,GAA5CA,QAA4C;IAAA,KAC5CC,OAAmB,GAAnBA,OAAmB;EAC1B;EAEHC,OAAO,GAA2B;IAChC,OAAO,IAAI,CAACF,QAAQ,CAACG,GAAG,CAAEC,OAAO,IAAKA,OAAO,CAAC,IAAI,CAACH,OAAO,CAAC,CAAC;EAC9D;EAEA,OAAOI,IAAI,CAACL,QAA4C,EAAEM,OAA2B,GAAG,CAAC,CAAC,EAA2B;IACnH,OAAQL,OAAmB,IAAK;MAC9B,MAAMF,IAAI,GAAGO,OAAO,CAACP,IAAI,IAAI,eAAe;MAC5C,OAAO,IAAIF,WAAW,CAACE,IAAI,EAAEC,QAAQ,EAAEC,OAAO,CAAC;IACjD,CAAC;EACH;AACF;AAAC"}
|
|
@@ -5,7 +5,7 @@ import { Workspace } from '@teambit/workspace';
|
|
|
5
5
|
import { BuilderMain } from '@teambit/builder';
|
|
6
6
|
import { Logger, LoggerMain } from '@teambit/logger';
|
|
7
7
|
import { EnvsMain } from '@teambit/envs';
|
|
8
|
-
import { ComponentMain, ComponentID } from '@teambit/component';
|
|
8
|
+
import { ComponentMain, ComponentID, Component } from '@teambit/component';
|
|
9
9
|
import { ApplicationType } from './application-type';
|
|
10
10
|
import { Application } from './application';
|
|
11
11
|
import { DeploymentProvider } from './deployment-provider';
|
|
@@ -13,7 +13,12 @@ import { AppService } from './application.service';
|
|
|
13
13
|
export declare type ApplicationTypeSlot = SlotRegistry<ApplicationType<unknown>[]>;
|
|
14
14
|
export declare type ApplicationSlot = SlotRegistry<Application[]>;
|
|
15
15
|
export declare type DeploymentProviderSlot = SlotRegistry<DeploymentProvider[]>;
|
|
16
|
-
export declare type ApplicationAspectConfig = {
|
|
16
|
+
export declare type ApplicationAspectConfig = {
|
|
17
|
+
/**
|
|
18
|
+
* envs ids to load app types.
|
|
19
|
+
*/
|
|
20
|
+
envs?: string[];
|
|
21
|
+
};
|
|
17
22
|
/**
|
|
18
23
|
* Application meta data that is stored on the component on load if it's an application.
|
|
19
24
|
*/
|
|
@@ -45,13 +50,14 @@ export declare class ApplicationMain {
|
|
|
45
50
|
private appSlot;
|
|
46
51
|
private appTypeSlot;
|
|
47
52
|
private deploymentProviderSlot;
|
|
53
|
+
private config;
|
|
48
54
|
private envs;
|
|
49
55
|
private componentAspect;
|
|
50
56
|
private appService;
|
|
51
57
|
private aspectLoader;
|
|
52
58
|
private workspace;
|
|
53
59
|
private logger;
|
|
54
|
-
constructor(appSlot: ApplicationSlot, appTypeSlot: ApplicationTypeSlot, deploymentProviderSlot: DeploymentProviderSlot, envs: EnvsMain, componentAspect: ComponentMain, appService: AppService, aspectLoader: AspectLoaderMain, workspace: Workspace, logger: Logger);
|
|
60
|
+
constructor(appSlot: ApplicationSlot, appTypeSlot: ApplicationTypeSlot, deploymentProviderSlot: DeploymentProviderSlot, config: ApplicationAspectConfig, envs: EnvsMain, componentAspect: ComponentMain, appService: AppService, aspectLoader: AspectLoaderMain, workspace: Workspace, logger: Logger);
|
|
55
61
|
/**
|
|
56
62
|
* register a new app.
|
|
57
63
|
*/
|
|
@@ -71,7 +77,12 @@ export declare class ApplicationMain {
|
|
|
71
77
|
/**
|
|
72
78
|
* get an application by a component id.
|
|
73
79
|
*/
|
|
74
|
-
getAppById(id: ComponentID): Application | undefined
|
|
80
|
+
getAppById(id: ComponentID): Promise<Application | undefined>;
|
|
81
|
+
/**
|
|
82
|
+
* calculate an application by a component.
|
|
83
|
+
* This should be only used during the on component load slot
|
|
84
|
+
*/
|
|
85
|
+
calculateAppByComponent(component: Component): Application | undefined;
|
|
75
86
|
/**
|
|
76
87
|
* get an app.
|
|
77
88
|
*/
|
|
@@ -175,10 +175,11 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
175
175
|
class ApplicationMain {
|
|
176
176
|
constructor(appSlot,
|
|
177
177
|
// TODO unused
|
|
178
|
-
appTypeSlot, deploymentProviderSlot, envs, componentAspect, appService, aspectLoader, workspace, logger) {
|
|
178
|
+
appTypeSlot, deploymentProviderSlot, config, envs, componentAspect, appService, aspectLoader, workspace, logger) {
|
|
179
179
|
this.appSlot = appSlot;
|
|
180
180
|
this.appTypeSlot = appTypeSlot;
|
|
181
181
|
this.deploymentProviderSlot = deploymentProviderSlot;
|
|
182
|
+
this.config = config;
|
|
182
183
|
this.envs = envs;
|
|
183
184
|
this.componentAspect = componentAspect;
|
|
184
185
|
this.appService = appService;
|
|
@@ -226,8 +227,18 @@ class ApplicationMain {
|
|
|
226
227
|
/**
|
|
227
228
|
* get an application by a component id.
|
|
228
229
|
*/
|
|
229
|
-
getAppById(id) {
|
|
230
|
-
const apps = this.listAppsById(id);
|
|
230
|
+
async getAppById(id) {
|
|
231
|
+
const apps = await this.listAppsById(id);
|
|
232
|
+
if (!apps) return undefined;
|
|
233
|
+
return (0, _lodash().head)(apps);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* calculate an application by a component.
|
|
238
|
+
* This should be only used during the on component load slot
|
|
239
|
+
*/
|
|
240
|
+
calculateAppByComponent(component) {
|
|
241
|
+
const apps = this.appSlot.get(component.id.toString());
|
|
231
242
|
if (!apps) return undefined;
|
|
232
243
|
return (0, _lodash().head)(apps);
|
|
233
244
|
}
|
|
@@ -236,7 +247,8 @@ class ApplicationMain {
|
|
|
236
247
|
* get an app.
|
|
237
248
|
*/
|
|
238
249
|
getApp(appName, id) {
|
|
239
|
-
const apps = this.listAppsById(id)
|
|
250
|
+
const apps = id ? this.listAppsById(id) : this.listApps();
|
|
251
|
+
if (!apps) return undefined;
|
|
240
252
|
return apps.find(app => app.name === appName);
|
|
241
253
|
}
|
|
242
254
|
getAppByNameOrId(appNameOrId) {
|
|
@@ -323,8 +335,6 @@ class ApplicationMain {
|
|
|
323
335
|
const id = this.getAppIdOrThrow(appName);
|
|
324
336
|
const component = components.find(c => c.id.isEqual(id));
|
|
325
337
|
if (!component) throw new (_exceptions().AppNotFound)(appName);
|
|
326
|
-
// console.log(comp)
|
|
327
|
-
|
|
328
338
|
const env = await this.envs.createEnvironment([component]);
|
|
329
339
|
const res = await env.run(this.appService);
|
|
330
340
|
const context = res.results[0].data;
|
|
@@ -336,18 +346,20 @@ class ApplicationMain {
|
|
|
336
346
|
static async provider([cli, loggerAspect, builder, envs, component, aspectLoader, workspace], config, [appTypeSlot, appSlot, deploymentProviderSlot]) {
|
|
337
347
|
const logger = loggerAspect.createLogger(_application().ApplicationAspect.id);
|
|
338
348
|
const appService = new (_application2().AppService)();
|
|
339
|
-
const application = new ApplicationMain(appSlot, appTypeSlot, deploymentProviderSlot, envs, component, appService, aspectLoader, workspace, logger);
|
|
349
|
+
const application = new ApplicationMain(appSlot, appTypeSlot, deploymentProviderSlot, config, envs, component, appService, aspectLoader, workspace, logger);
|
|
350
|
+
appService.registerAppType = application.registerAppType.bind(application);
|
|
340
351
|
const appCmd = new (_app().AppCmd)();
|
|
341
352
|
appCmd.commands = [new (_app().AppListCmd)(application), new (_run().RunCmd)(application, logger)];
|
|
342
353
|
aspectLoader.registerPlugins([new (_app2().AppPlugin)(appSlot)]);
|
|
343
354
|
builder.registerBuildTasks([new (_build().AppsBuildTask)(application)]);
|
|
344
355
|
builder.registerSnapTasks([new (_deploy().DeployTask)(application, builder)]);
|
|
345
356
|
builder.registerTagTasks([new (_deploy().DeployTask)(application, builder)]);
|
|
357
|
+
envs.registerService(appService);
|
|
346
358
|
cli.registerGroup('apps', 'Applications');
|
|
347
359
|
cli.register(new (_run().RunCmd)(application, logger), new (_appList().AppListCmdDeprecated)(application), appCmd);
|
|
348
360
|
if (workspace) {
|
|
349
361
|
workspace.onComponentLoad(async loadedComponent => {
|
|
350
|
-
const app = application.
|
|
362
|
+
const app = application.calculateAppByComponent(loadedComponent);
|
|
351
363
|
if (!app) return {};
|
|
352
364
|
return {
|
|
353
365
|
appName: app === null || app === void 0 ? void 0 : app.name,
|
|
@@ -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\n/**\n * Application meta data that is stored on the component on load if it's an application.\n */\nexport type ApplicationMetadata = {\n appName?: string;\n type?: string;\n};\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;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAmD;AAAA;AAAA;AAAA;AAwC5C,MAAMA,eAAe,CAAC;EAC3BC,WAAW,CACDC,OAAwB;EAChC;EACQC,WAAgC,EAChCC,sBAA8C,EAC9CC,IAAc,EACdC,eAA8B,EAC9BC,UAAsB,EACtBC,YAA8B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"version":3,"names":["ApplicationMain","constructor","appSlot","appTypeSlot","deploymentProviderSlot","config","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","calculateAppByComponent","component","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","c","isEqual","env","createEnvironment","res","results","data","hostRootDir","getComponentPackagePath","appContext","AppContext","path","provider","cli","loggerAspect","builder","createLogger","ApplicationAspect","AppService","application","bind","appCmd","AppCmd","commands","AppListCmd","RunCmd","AppPlugin","registerBuildTasks","AppsBuildTask","registerSnapTasks","DeployTask","registerTagTasks","registerService","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, Component } 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 /**\n * envs ids to load app types.\n */\n envs?: string[];\n};\n\n/**\n * Application meta data that is stored on the component on load if it's an application.\n */\nexport type ApplicationMetadata = {\n appName?: string;\n type?: string;\n};\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 config: ApplicationAspectConfig,\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 async getAppById(id: ComponentID) {\n const apps = await this.listAppsById(id);\n if (!apps) return undefined;\n return head(apps);\n }\n\n /**\n * calculate an application by a component.\n * This should be only used during the on component load slot\n */\n calculateAppByComponent(component: Component) {\n const apps = this.appSlot.get(component.id.toString());\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 = id ? this.listAppsById(id) : this.listApps();\n if (!apps) return undefined;\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): Application {\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\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 config,\n envs,\n component,\n appService,\n aspectLoader,\n workspace,\n logger\n );\n appService.registerAppType = application.registerAppType.bind(application);\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 envs.registerService(appService);\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.calculateAppByComponent(loadedComponent);\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;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAA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,eAAe,CAACvG,UAAU,CAAC;IAChCoF,GAAG,CAACoB,aAAa,CAAC,MAAM,EAAE,cAAc,CAAC;IACzCpB,GAAG,CAAC1E,QAAQ,CAAC,KAAIsF,aAAM,EAACN,WAAW,EAAEvF,MAAM,CAAC,EAAE,KAAIsG,+BAAoB,EAACf,WAAW,CAAC,EAAEE,MAAM,CAAC;IAC5F,IAAI1F,SAAS,EAAE;MACbA,SAAS,CAACwG,eAAe,CAAC,MAAOC,eAAe,IAAK;QACnD,MAAMlG,GAAG,GAAGiF,WAAW,CAAClE,uBAAuB,CAACmF,eAAe,CAAC;QAChE,IAAI,CAAClG,GAAG,EAAE,OAAO,CAAC,CAAC;QACnB,OAAO;UACLkB,OAAO,EAAElB,GAAG,aAAHA,GAAG,uBAAHA,GAAG,CAAEoB,IAAI;UAClB+E,IAAI,EAAEnG,GAAG,aAAHA,GAAG,uBAAHA,GAAG,CAAEoG;QACb,CAAC;MACH,CAAC,CAAC;IACJ;IAEA,OAAOnB,WAAW;EACpB;AACF;AAAC;AAAA,gCAvPYlG,eAAe,aAoLTsH,kBAAW;AAAA,gCApLjBtH,eAAe,kBAqLJ,CACpBuH,gBAAS,EACTC,sBAAY,EACZC,wBAAa,EACbC,kBAAU,EACVC,oBAAe,EACfC,kCAAkB,EAClBC,oBAAe,CAChB;AAAA,gCA7LU7H,eAAe,WA+LX,CACb8H,eAAI,CAACC,QAAQ,EAA8B,EAC3CD,eAAI,CAACC,QAAQ,EAAiB,EAC9BD,eAAI,CAACC,QAAQ,EAAwB,CACtC;AAsDH/B,gCAAiB,CAACgC,UAAU,CAAChI,eAAe,CAAC"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import { EnvService, ExecutionContext } from '@teambit/envs';
|
|
1
|
+
import { EnvService, Env, EnvContext, ServiceTransformationMap, ExecutionContext } from '@teambit/envs';
|
|
2
|
+
import { ApplicationType } from './application-type';
|
|
3
|
+
declare type ApplicationTransformationMap = ServiceTransformationMap & {
|
|
4
|
+
getAppTypes: () => ApplicationType<any>[];
|
|
5
|
+
};
|
|
2
6
|
export declare class AppService implements EnvService<any> {
|
|
3
7
|
name: string;
|
|
8
|
+
registerAppType: (appType: ApplicationType<any>) => void;
|
|
4
9
|
run(context: ExecutionContext): Promise<ExecutionContext & {
|
|
5
10
|
dev: boolean;
|
|
6
11
|
errors: never[];
|
|
7
12
|
}>;
|
|
13
|
+
transform(env: Env, context: EnvContext): ApplicationTransformationMap | undefined;
|
|
8
14
|
}
|
|
15
|
+
export {};
|
|
@@ -15,7 +15,8 @@ function _defineProperty2() {
|
|
|
15
15
|
}
|
|
16
16
|
class AppService {
|
|
17
17
|
constructor() {
|
|
18
|
-
(0, _defineProperty2().default)(this, "name", '
|
|
18
|
+
(0, _defineProperty2().default)(this, "name", 'application');
|
|
19
|
+
(0, _defineProperty2().default)(this, "registerAppType", void 0);
|
|
19
20
|
}
|
|
20
21
|
async run(context) {
|
|
21
22
|
const appContext = Object.assign(context, {
|
|
@@ -24,6 +25,20 @@ class AppService {
|
|
|
24
25
|
});
|
|
25
26
|
return appContext;
|
|
26
27
|
}
|
|
28
|
+
transform(env, context) {
|
|
29
|
+
// Old env
|
|
30
|
+
if (!(env !== null && env !== void 0 && env.apps)) return undefined;
|
|
31
|
+
const appTypesList = env.apps()(context);
|
|
32
|
+
const appTypes = appTypesList.compute();
|
|
33
|
+
appTypes.forEach(appType => {
|
|
34
|
+
this.registerAppType(appType);
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
getAppTypes: () => {
|
|
38
|
+
return appTypes;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
27
42
|
}
|
|
28
43
|
exports.AppService = AppService;
|
|
29
44
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AppService","run","context","appContext","Object","assign","dev","errors"],"sources":["application.service.ts"],"sourcesContent":["import { EnvService, ExecutionContext } from '@teambit/envs';\n\nexport class AppService implements EnvService<any> {\n name = '
|
|
1
|
+
{"version":3,"names":["AppService","run","context","appContext","Object","assign","dev","errors","transform","env","apps","undefined","appTypesList","appTypes","compute","forEach","appType","registerAppType","getAppTypes"],"sources":["application.service.ts"],"sourcesContent":["import { EnvService, Env, EnvContext, ServiceTransformationMap, ExecutionContext } from '@teambit/envs';\nimport { ApplicationType } from './application-type';\n\ntype ApplicationTransformationMap = ServiceTransformationMap & {\n getAppTypes: () => ApplicationType<any>[];\n}\nexport class AppService implements EnvService<any> {\n name = 'application';\n registerAppType: (appType: ApplicationType<any>) => void;\n\n async run(context: ExecutionContext) {\n const appContext = Object.assign(context, {\n dev: true,\n errors: [],\n });\n\n return appContext;\n }\n\n transform(env: Env, context: EnvContext): ApplicationTransformationMap | undefined {\n // Old env\n if (!env?.apps) return undefined;\n const appTypesList = env.apps()(context);\n const appTypes = appTypesList.compute();\n appTypes.forEach(appType => {\n this.registerAppType(appType);\n });\n return {\n getAppTypes: () => {\n return appTypes;\n },\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAMO,MAAMA,UAAU,CAA4B;EAAA;IAAA,8CAC1C,aAAa;IAAA;EAAA;EAGpB,MAAMC,GAAG,CAACC,OAAyB,EAAE;IACnC,MAAMC,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACH,OAAO,EAAE;MACxCI,GAAG,EAAE,IAAI;MACTC,MAAM,EAAE;IACV,CAAC,CAAC;IAEF,OAAOJ,UAAU;EACnB;EAEAK,SAAS,CAACC,GAAQ,EAAEP,OAAmB,EAA4C;IACjF;IACA,IAAI,EAACO,GAAG,aAAHA,GAAG,eAAHA,GAAG,CAAEC,IAAI,GAAE,OAAOC,SAAS;IAChC,MAAMC,YAAY,GAAGH,GAAG,CAACC,IAAI,EAAE,CAACR,OAAO,CAAC;IACxC,MAAMW,QAAQ,GAAGD,YAAY,CAACE,OAAO,EAAE;IACvCD,QAAQ,CAACE,OAAO,CAACC,OAAO,IAAI;MAC1B,IAAI,CAACC,eAAe,CAACD,OAAO,CAAC;IAC/B,CAAC,CAAC;IACF,OAAO;MACLE,WAAW,EAAE,MAAM;QACjB,OAAOL,QAAQ;MACjB;IACF,CAAC;EACH;AACF;AAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["apps-env-type.ts"],"sourcesContent":["import { EnvHandler } from \"@teambit/envs\";\nimport { AppTypeList } from \"./app-type-list\";\n\nexport interface AppsEnv {\n /**\n * return a template list instance.\n */\n apps(): EnvHandler<AppTypeList>;\n}\n"],"mappings":""}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,3 +8,5 @@ export { AppDeployContext } from './app-deploy-context';
|
|
|
8
8
|
export { AppBuildContext } from './app-build-context';
|
|
9
9
|
export { AppBuildResult } from './app-build-result';
|
|
10
10
|
export { ARTIFACTS_DIR_NAME as APPS_ARTIFACTS_DIR_NAME } from './build.task';
|
|
11
|
+
export type { AppsEnv } from './apps-env-type';
|
|
12
|
+
export { AppTypeList } from './app-type-list';
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,12 @@ Object.defineProperty(exports, "AppDeployContext", {
|
|
|
33
33
|
return _appDeployContext().AppDeployContext;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
+
Object.defineProperty(exports, "AppTypeList", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _appTypeList().AppTypeList;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
36
42
|
Object.defineProperty(exports, "ApplicationAspect", {
|
|
37
43
|
enumerable: true,
|
|
38
44
|
get: function () {
|
|
@@ -107,5 +113,12 @@ function _build() {
|
|
|
107
113
|
};
|
|
108
114
|
return data;
|
|
109
115
|
}
|
|
116
|
+
function _appTypeList() {
|
|
117
|
+
const data = require("./app-type-list");
|
|
118
|
+
_appTypeList = function () {
|
|
119
|
+
return data;
|
|
120
|
+
};
|
|
121
|
+
return data;
|
|
122
|
+
}
|
|
110
123
|
|
|
111
124
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { ApplicationAspect } from './application.aspect';\nexport type { ApplicationMain, ApplicationMetadata } from './application.main.runtime';\nexport type { Application, DeployFn, AppResult } from './application';\nexport { AppContext } from './app-context';\nexport { DeploymentProvider } from './deployment-provider';\nexport { ApplicationType } from './application-type';\nexport { AppDeployContext } from './app-deploy-context';\nexport { AppBuildContext } from './app-build-context';\nexport { AppBuildResult } from './app-build-result';\nexport { ARTIFACTS_DIR_NAME as APPS_ARTIFACTS_DIR_NAME } from './build.task';\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { ApplicationAspect } from './application.aspect';\nexport type { ApplicationMain, ApplicationMetadata } from './application.main.runtime';\nexport type { Application, DeployFn, AppResult } from './application';\nexport { AppContext } from './app-context';\nexport { DeploymentProvider } from './deployment-provider';\nexport { ApplicationType } from './application-type';\nexport { AppDeployContext } from './app-deploy-context';\nexport { AppBuildContext } from './app-build-context';\nexport { AppBuildResult } from './app-build-result';\nexport { ARTIFACTS_DIR_NAME as APPS_ARTIFACTS_DIR_NAME } from './build.task';\nexport type { AppsEnv } from './apps-env-type';\nexport { AppTypeList } from './app-type-list';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_application@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_application@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_application@0.0.588/dist/application.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_application@0.0.588/dist/application.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
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.588",
|
|
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.588"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
@@ -17,16 +17,16 @@
|
|
|
17
17
|
"core-js": "^3.0.0",
|
|
18
18
|
"@babel/runtime": "7.20.0",
|
|
19
19
|
"@teambit/harmony": "0.4.6",
|
|
20
|
-
"@teambit/builder": "0.0.
|
|
21
|
-
"@teambit/component": "0.0.
|
|
22
|
-
"@teambit/isolator": "0.0.
|
|
23
|
-
"@teambit/envs": "0.0.
|
|
20
|
+
"@teambit/builder": "0.0.946",
|
|
21
|
+
"@teambit/component": "0.0.946",
|
|
22
|
+
"@teambit/isolator": "0.0.946",
|
|
23
|
+
"@teambit/envs": "0.0.946",
|
|
24
24
|
"@teambit/cli-table": "0.0.41",
|
|
25
25
|
"@teambit/cli": "0.0.633",
|
|
26
|
-
"@teambit/aspect-loader": "0.0.
|
|
26
|
+
"@teambit/aspect-loader": "0.0.946",
|
|
27
27
|
"@teambit/bit-error": "0.0.402",
|
|
28
28
|
"@teambit/logger": "0.0.726",
|
|
29
|
-
"@teambit/workspace": "0.0.
|
|
29
|
+
"@teambit/workspace": "0.0.946"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/react": "^17.0.8",
|
|
Binary file
|