@teambit/application 0.0.719 → 0.0.721
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.d.ts +9 -1
- package/dist/app-context.js +6 -1
- package/dist/app-context.js.map +1 -1
- package/dist/application.main.runtime.d.ts +4 -0
- package/dist/application.main.runtime.js +3 -3
- package/dist/application.main.runtime.js.map +1 -1
- package/dist/{preview-1686712699037.js → preview-1686886045563.js} +2 -2
- package/dist/run.cmd.d.ts +2 -1
- package/dist/run.cmd.js +5 -3
- package/dist/run.cmd.js.map +1 -1
- package/package-tar/teambit-application-0.0.721.tgz +0 -0
- package/package.json +12 -12
- package/run.cmd.tsx +7 -1
- package/package-tar/teambit-application-0.0.719.tgz +0 -0
package/dist/app-context.d.ts
CHANGED
|
@@ -15,6 +15,10 @@ export declare class AppContext extends ExecutionContext {
|
|
|
15
15
|
* for example when configuring webpack aliases or webpack expose loader on the peers deps
|
|
16
16
|
*/
|
|
17
17
|
readonly hostRootDir?: string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* A port to run the app on
|
|
20
|
+
*/
|
|
21
|
+
readonly port?: number | undefined;
|
|
18
22
|
constructor(appName: string,
|
|
19
23
|
/**
|
|
20
24
|
* determine whether to serve the application in dev mode.
|
|
@@ -26,5 +30,9 @@ export declare class AppContext extends ExecutionContext {
|
|
|
26
30
|
* This can be used in different bundle options which run require.resolve
|
|
27
31
|
* for example when configuring webpack aliases or webpack expose loader on the peers deps
|
|
28
32
|
*/
|
|
29
|
-
hostRootDir?: string | undefined
|
|
33
|
+
hostRootDir?: string | undefined,
|
|
34
|
+
/**
|
|
35
|
+
* A port to run the app on
|
|
36
|
+
*/
|
|
37
|
+
port?: number | undefined);
|
|
30
38
|
}
|
package/dist/app-context.js
CHANGED
|
@@ -23,13 +23,18 @@ class AppContext extends _envs().ExecutionContext {
|
|
|
23
23
|
* This can be used in different bundle options which run require.resolve
|
|
24
24
|
* for example when configuring webpack aliases or webpack expose loader on the peers deps
|
|
25
25
|
*/
|
|
26
|
-
hostRootDir
|
|
26
|
+
hostRootDir,
|
|
27
|
+
/**
|
|
28
|
+
* A port to run the app on
|
|
29
|
+
*/
|
|
30
|
+
port) {
|
|
27
31
|
super(execContext.upper, execContext.envRuntime, execContext.components);
|
|
28
32
|
this.appName = appName;
|
|
29
33
|
this.dev = dev;
|
|
30
34
|
this.appComponent = appComponent;
|
|
31
35
|
this.workdir = workdir;
|
|
32
36
|
this.hostRootDir = hostRootDir;
|
|
37
|
+
this.port = port;
|
|
33
38
|
}
|
|
34
39
|
// static fromExecContext() {
|
|
35
40
|
// return new AppContext();
|
package/dist/app-context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AppContext","ExecutionContext","constructor","appName","dev","appComponent","workdir","execContext","hostRootDir","upper","envRuntime","components"],"sources":["app-context.ts"],"sourcesContent":["import { ExecutionContext } from '@teambit/envs';\nimport { Component } from '@teambit/component';\n\nexport class AppContext extends ExecutionContext {\n constructor(\n readonly appName: string,\n\n /**\n * determine whether to serve the application in dev mode.\n */\n readonly dev: boolean,\n\n readonly appComponent: Component,\n\n readonly workdir: string,\n\n execContext: ExecutionContext,\n\n /**\n * A path for the host root dir\n * Host root dir is the dir where we run the app from\n * This can be used in different bundle options which run require.resolve\n * for example when configuring webpack aliases or webpack expose loader on the peers deps\n */\n readonly hostRootDir?: string\n ) {\n super(execContext.upper, execContext.envRuntime, execContext.components);\n }\n // static fromExecContext() {\n // return new AppContext();\n // }\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGO,MAAMA,UAAU,SAASC,wBAAgB,CAAC;EAC/CC,WAAW,CACAC,OAAe;EAExB;AACJ;AACA;EACaC,GAAY,EAEZC,YAAuB,EAEvBC,OAAe,EAExBC,WAA6B;EAE7B;AACJ;AACA;AACA;AACA;AACA;EACaC,WAAoB,
|
|
1
|
+
{"version":3,"names":["AppContext","ExecutionContext","constructor","appName","dev","appComponent","workdir","execContext","hostRootDir","port","upper","envRuntime","components"],"sources":["app-context.ts"],"sourcesContent":["import { ExecutionContext } from '@teambit/envs';\nimport { Component } from '@teambit/component';\n\nexport class AppContext extends ExecutionContext {\n constructor(\n readonly appName: string,\n\n /**\n * determine whether to serve the application in dev mode.\n */\n readonly dev: boolean,\n\n readonly appComponent: Component,\n\n readonly workdir: string,\n\n execContext: ExecutionContext,\n\n /**\n * A path for the host root dir\n * Host root dir is the dir where we run the app from\n * This can be used in different bundle options which run require.resolve\n * for example when configuring webpack aliases or webpack expose loader on the peers deps\n */\n readonly hostRootDir?: string,\n\n /**\n * A port to run the app on\n */\n readonly port?: number\n ) {\n super(execContext.upper, execContext.envRuntime, execContext.components);\n }\n // static fromExecContext() {\n // return new AppContext();\n // }\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGO,MAAMA,UAAU,SAASC,wBAAgB,CAAC;EAC/CC,WAAW,CACAC,OAAe;EAExB;AACJ;AACA;EACaC,GAAY,EAEZC,YAAuB,EAEvBC,OAAe,EAExBC,WAA6B;EAE7B;AACJ;AACA;AACA;AACA;AACA;EACaC,WAAoB;EAE7B;AACJ;AACA;EACaC,IAAa,EACtB;IACA,KAAK,CAACF,WAAW,CAACG,KAAK,EAAEH,WAAW,CAACI,UAAU,EAAEJ,WAAW,CAACK,UAAU,CAAC;IAAC,KA1BhET,OAAe,GAAfA,OAAe;IAAA,KAKfC,GAAY,GAAZA,GAAY;IAAA,KAEZC,YAAuB,GAAvBA,YAAuB;IAAA,KAEvBC,OAAe,GAAfA,OAAe;IAAA,KAUfE,WAAoB,GAApBA,WAAoB;IAAA,KAKpBC,IAAa,GAAbA,IAAa;EAGxB;EACA;EACA;EACA;AACF;AAAC"}
|
|
@@ -352,7 +352,7 @@ class ApplicationMain {
|
|
|
352
352
|
async runApp(appName, options) {
|
|
353
353
|
options = this.computeOptions(options);
|
|
354
354
|
const app = this.getAppOrThrow(appName);
|
|
355
|
-
const context = await this.createAppContext(app.name);
|
|
355
|
+
const context = await this.createAppContext(app.name, options.port);
|
|
356
356
|
if (!context) throw new (_exceptions().AppNotFound)(appName);
|
|
357
357
|
if (options.ssr) {
|
|
358
358
|
if (!app.runSsr) throw new (_appNoSsr().AppNoSsr)(appName);
|
|
@@ -388,7 +388,7 @@ class ApplicationMain {
|
|
|
388
388
|
const host = this.componentAspect.getHost();
|
|
389
389
|
return host.resolveComponentId(maybeApp[0]);
|
|
390
390
|
}
|
|
391
|
-
async createAppContext(appName) {
|
|
391
|
+
async createAppContext(appName, port) {
|
|
392
392
|
const host = this.componentAspect.getHost();
|
|
393
393
|
// const components = await host.list();
|
|
394
394
|
const id = await this.getAppIdOrThrow(appName);
|
|
@@ -400,7 +400,7 @@ class ApplicationMain {
|
|
|
400
400
|
const context = res.results[0].data;
|
|
401
401
|
if (!context) throw new (_exceptions().AppNotFound)(appName);
|
|
402
402
|
const hostRootDir = this.workspace.getComponentPackagePath(component);
|
|
403
|
-
const appContext = new (_appContext().AppContext)(appName, context.dev, component, this.workspace.path, context, hostRootDir);
|
|
403
|
+
const appContext = new (_appContext().AppContext)(appName, context.dev, component, this.workspace.path, context, hostRootDir, port);
|
|
404
404
|
return appContext;
|
|
405
405
|
}
|
|
406
406
|
static async provider([cli, loggerAspect, builder, envs, component, aspectLoader, workspace, watcher], config, [appTypeSlot, appSlot, deploymentProviderSlot]) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ApplicationMain","constructor","appSlot","appTypeSlot","deploymentProviderSlot","config","envs","componentAspect","appService","aspectLoader","workspace","logger","watcher","dev","ssr","watch","defaultPortRange","registerApp","app","register","listApps","flatten","values","mapApps","toArray","listAppsById","id","undefined","get","toString","getAppById","apps","head","calculateAppByComponent","component","listAppTypes","listAppsFromComponents","components","getHost","list","appTypesPatterns","getAppPatterns","filter","files","filesystem","byGlob","length","appTypes","map","appType","getAppPattern","loadApps","pluginsToLoad","flatMap","appComponent","file","path","appManifests","compact","pluginPath","appManifest","require","default","err","error","getApp","appName","find","name","getAppByNameOrId","appNameOrId","byName","byId","BitError","globPattern","registerAppType","plugin","AppTypePlugin","registerPlugins","getAppAspect","getAppOrThrow","AppNotFound","computeOptions","opts","defaultOpts","loadAppsToSlot","runApp","options","context","createAppContext","runSsr","AppNoSsr","result","port","run","preCompile","catch","errors","getAppIdOrThrow","maybeApp","host","resolveComponentId","env","createEnvironment","res","results","data","hostRootDir","getComponentPackagePath","appContext","AppContext","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","WatcherAspect","Slot","withType","addRuntime"],"sources":["application.main.runtime.ts"],"sourcesContent":["import { MainRuntime, CLIMain, CLIAspect } from '@teambit/cli';\nimport { compact, 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 WatcherAspect, { WatcherMain } from '@teambit/watcher';\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 private watcher: WatcherMain\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 listAppTypes() {\n return flatten(this.appTypeSlot.values());\n }\n\n async listAppsFromComponents() {\n const components = await this.componentAspect.getHost().list();\n const appTypesPatterns = this.getAppPatterns();\n const apps = components.filter((component) => {\n // has app plugin from registered types.\n const files = component.filesystem.byGlob(appTypesPatterns);\n return !!files.length;\n });\n\n return apps;\n }\n\n getAppPatterns() {\n const appTypes = this.listAppTypes();\n const appTypesPatterns = appTypes.map((appType) => {\n return this.getAppPattern(appType);\n });\n\n return appTypesPatterns;\n }\n\n async loadApps(): Promise<Application[]> {\n const apps = await this.listAppsFromComponents();\n const appTypesPatterns = this.getAppPatterns();\n\n const pluginsToLoad = apps.flatMap((appComponent) => {\n const files = appComponent.filesystem.byGlob(appTypesPatterns);\n return files.map((file) => file.path);\n });\n // const app = require(appPath);\n const appManifests = compact(\n pluginsToLoad.map((pluginPath) => {\n try {\n // eslint-disable-next-line\n const appManifest = require(pluginPath)?.default;\n return appManifest;\n } catch (err) {\n this.logger.error(`failed loading app manifest: ${pluginPath}`);\n return undefined;\n }\n })\n );\n\n return appManifests;\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 getAppPattern(appType: ApplicationType<unknown>) {\n if (appType.globPattern) return appType.globPattern;\n return `*.${appType.name}.*`;\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(this.getAppPattern(appType), 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 loadAppsToSlot() {\n const apps = await this.loadApps();\n this.appSlot.register(apps);\n return this;\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.watcher\n .watch({\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 async 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\n const host = this.componentAspect.getHost();\n return host.resolveComponentId(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 = await this.getAppIdOrThrow(appName);\n // const component = components.find((c) => c.id.isEqual(id));\n const component = await host.get(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 WatcherAspect,\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, watcher]: [\n CLIMain,\n LoggerMain,\n BuilderMain,\n EnvsMain,\n ComponentMain,\n AspectLoaderMain,\n Workspace,\n WatcherMain\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 watcher\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 // cli.registerOnStart(async () => {\n // await application.loadAppsToSlot();\n // });\n if (workspace) {\n workspace.onComponentLoad(async (loadedComponent): Promise<ApplicationMetadata | undefined> => {\n const app = application.calculateAppByComponent(loadedComponent);\n if (!app) return undefined;\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;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;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A2DHhC,gCAAiB,CAACiC,UAAU,CAACrJ,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"names":["ApplicationMain","constructor","appSlot","appTypeSlot","deploymentProviderSlot","config","envs","componentAspect","appService","aspectLoader","workspace","logger","watcher","dev","ssr","watch","defaultPortRange","registerApp","app","register","listApps","flatten","values","mapApps","toArray","listAppsById","id","undefined","get","toString","getAppById","apps","head","calculateAppByComponent","component","listAppTypes","listAppsFromComponents","components","getHost","list","appTypesPatterns","getAppPatterns","filter","files","filesystem","byGlob","length","appTypes","map","appType","getAppPattern","loadApps","pluginsToLoad","flatMap","appComponent","file","path","appManifests","compact","pluginPath","appManifest","require","default","err","error","getApp","appName","find","name","getAppByNameOrId","appNameOrId","byName","byId","BitError","globPattern","registerAppType","plugin","AppTypePlugin","registerPlugins","getAppAspect","getAppOrThrow","AppNotFound","computeOptions","opts","defaultOpts","loadAppsToSlot","runApp","options","context","createAppContext","port","runSsr","AppNoSsr","result","run","preCompile","catch","errors","getAppIdOrThrow","maybeApp","host","resolveComponentId","env","createEnvironment","res","results","data","hostRootDir","getComponentPackagePath","appContext","AppContext","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","WatcherAspect","Slot","withType","addRuntime"],"sources":["application.main.runtime.ts"],"sourcesContent":["import { MainRuntime, CLIMain, CLIAspect } from '@teambit/cli';\nimport { compact, 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 WatcherAspect, { WatcherMain } from '@teambit/watcher';\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 /**\n * exact port to run the app\n */\n port?: number;\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 private watcher: WatcherMain\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 listAppTypes() {\n return flatten(this.appTypeSlot.values());\n }\n\n async listAppsFromComponents() {\n const components = await this.componentAspect.getHost().list();\n const appTypesPatterns = this.getAppPatterns();\n const apps = components.filter((component) => {\n // has app plugin from registered types.\n const files = component.filesystem.byGlob(appTypesPatterns);\n return !!files.length;\n });\n\n return apps;\n }\n\n getAppPatterns() {\n const appTypes = this.listAppTypes();\n const appTypesPatterns = appTypes.map((appType) => {\n return this.getAppPattern(appType);\n });\n\n return appTypesPatterns;\n }\n\n async loadApps(): Promise<Application[]> {\n const apps = await this.listAppsFromComponents();\n const appTypesPatterns = this.getAppPatterns();\n\n const pluginsToLoad = apps.flatMap((appComponent) => {\n const files = appComponent.filesystem.byGlob(appTypesPatterns);\n return files.map((file) => file.path);\n });\n // const app = require(appPath);\n const appManifests = compact(\n pluginsToLoad.map((pluginPath) => {\n try {\n // eslint-disable-next-line\n const appManifest = require(pluginPath)?.default;\n return appManifest;\n } catch (err) {\n this.logger.error(`failed loading app manifest: ${pluginPath}`);\n return undefined;\n }\n })\n );\n\n return appManifests;\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 getAppPattern(appType: ApplicationType<unknown>) {\n if (appType.globPattern) return appType.globPattern;\n return `*.${appType.name}.*`;\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(this.getAppPattern(appType), 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 loadAppsToSlot() {\n const apps = await this.loadApps();\n this.appSlot.register(apps);\n return this;\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, options.port);\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.watcher\n .watch({\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 async 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\n const host = this.componentAspect.getHost();\n return host.resolveComponentId(maybeApp[0]);\n }\n\n private async createAppContext(appName: string, port?: number): Promise<AppContext> {\n const host = this.componentAspect.getHost();\n // const components = await host.list();\n const id = await this.getAppIdOrThrow(appName);\n // const component = components.find((c) => c.id.isEqual(id));\n const component = await host.get(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, port);\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 WatcherAspect,\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, watcher]: [\n CLIMain,\n LoggerMain,\n BuilderMain,\n EnvsMain,\n ComponentMain,\n AspectLoaderMain,\n Workspace,\n WatcherMain\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 watcher\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 // cli.registerOnStart(async () => {\n // await application.loadAppsToSlot();\n // });\n if (workspace) {\n workspace.onComponentLoad(async (loadedComponent): Promise<ApplicationMetadata | undefined> => {\n const app = application.calculateAppByComponent(loadedComponent);\n if (!app) return undefined;\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;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAA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,EAAEhD,GAAG,CAACkD,IAAI;UACjBoE,IAAI,EAAEtH,GAAG,CAACuH;QACZ,CAAC;MACH,CAAC,CAAC;IACJ;IAEA,OAAOnB,WAAW;EACpB;AACF;AAAC;AAAA,gCA9TYtH,eAAe,aAqPT0I,kBAAW;AAAA,gCArPjB1I,eAAe,kBAsPJ,CACpB2I,gBAAS,EACTC,sBAAY,EACZC,wBAAa,EACbC,kBAAU,EACVC,oBAAe,EACfC,kCAAkB,EAClBC,oBAAe,EACfC,kBAAa,CACd;AAAA,gCA/PUlJ,eAAe,WAiQX,CACbmJ,eAAI,CAACC,QAAQ,EAA8B,EAC3CD,eAAI,CAACC,QAAQ,EAAiB,EAC9BD,eAAI,CAACC,QAAQ,EAAwB,CACtC;AA2DHhC,gCAAiB,CAACiC,UAAU,CAACrJ,eAAe,CAAC"}
|
|
@@ -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.721/dist/application.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_application@0.0.721/dist/application.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
package/dist/run.cmd.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ declare type RunOptions = {
|
|
|
8
8
|
verbose: boolean;
|
|
9
9
|
skipWatch: boolean;
|
|
10
10
|
ssr: boolean;
|
|
11
|
+
port: string;
|
|
11
12
|
};
|
|
12
13
|
export declare class RunCmd implements Command {
|
|
13
14
|
/**
|
|
@@ -30,6 +31,6 @@ export declare class RunCmd implements Command {
|
|
|
30
31
|
* access to the extension instance.
|
|
31
32
|
*/
|
|
32
33
|
application: ApplicationMain, logger: Logger);
|
|
33
|
-
render([appName]: [string], { dev, skipWatch, ssr }: RunOptions): Promise<React.ReactElement | RenderResult>;
|
|
34
|
+
render([appName]: [string], { dev, skipWatch, ssr, port: exactPort }: RunOptions): Promise<React.ReactElement | RenderResult>;
|
|
34
35
|
}
|
|
35
36
|
export {};
|
package/dist/run.cmd.js
CHANGED
|
@@ -52,12 +52,13 @@ class RunCmd {
|
|
|
52
52
|
}]);
|
|
53
53
|
(0, _defineProperty2().default)(this, "alias", 'c');
|
|
54
54
|
(0, _defineProperty2().default)(this, "group", 'apps');
|
|
55
|
-
(0, _defineProperty2().default)(this, "options", [['d', 'dev', 'start the application in dev mode.'], ['v', 'verbose', 'showing verbose output for inspection and prints stack trace'], ['', 'skip-watch', 'avoid running the watch process that compiles components in the background'], ['', 'ssr', 'run app in server side rendering mode.']]);
|
|
55
|
+
(0, _defineProperty2().default)(this, "options", [['d', 'dev', 'start the application in dev mode.'], ['p', 'port [port-number]', 'port of the app'], ['v', 'verbose', 'showing verbose output for inspection and prints stack trace'], ['', 'skip-watch', 'avoid running the watch process that compiles components in the background'], ['', 'ssr', 'run app in server side rendering mode.']]);
|
|
56
56
|
}
|
|
57
57
|
async render([appName], {
|
|
58
58
|
dev,
|
|
59
59
|
skipWatch,
|
|
60
|
-
ssr
|
|
60
|
+
ssr,
|
|
61
|
+
port: exactPort
|
|
61
62
|
}) {
|
|
62
63
|
// remove wds logs until refactoring webpack to a worker through the Worker aspect.
|
|
63
64
|
const {
|
|
@@ -66,7 +67,8 @@ class RunCmd {
|
|
|
66
67
|
} = await this.application.runApp(appName, {
|
|
67
68
|
dev,
|
|
68
69
|
watch: !skipWatch,
|
|
69
|
-
ssr
|
|
70
|
+
ssr,
|
|
71
|
+
port: +exactPort
|
|
70
72
|
});
|
|
71
73
|
if (errors) {
|
|
72
74
|
return {
|
package/dist/run.cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RunCmd","constructor","application","logger","name","description","render","appName","dev","skipWatch","ssr","port","errors","runApp","watch","code","data","ShowErrors","pluralize","length","map","x","idx","toString"],"sources":["run.cmd.tsx"],"sourcesContent":["import React from 'react';\nimport pluralize from 'pluralize';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { Newline, Text } from 'ink';\nimport { Logger } from '@teambit/logger';\nimport type { RenderResult } from '@teambit/legacy/dist/cli/command';\nimport { ApplicationMain } from './application.main.runtime';\n\ntype RunOptions = {\n dev: boolean;\n verbose: boolean;\n skipWatch: boolean;\n ssr: boolean;\n};\n\nexport class RunCmd implements Command {\n name = 'run <app-name>';\n description = \"run an app (independent of bit's dev server)\";\n helpUrl = 'docs/apps/apps-overview';\n arguments = [\n {\n name: 'app-name',\n description:\n \"the app's name is registered by the app (run 'bit app list' to list the names of the available apps)\",\n },\n ];\n alias = 'c';\n group = 'apps';\n options = [\n ['d', 'dev', 'start the application in dev mode.'],\n ['v', 'verbose', 'showing verbose output for inspection and prints stack trace'],\n ['', 'skip-watch', 'avoid running the watch process that compiles components in the background'],\n ['', 'ssr', 'run app in server side rendering mode.'],\n ] as CommandOptions;\n\n constructor(\n /**\n * access to the extension instance.\n */\n private application: ApplicationMain,\n\n private logger: Logger\n ) {}\n\n async render([appName]: [string]
|
|
1
|
+
{"version":3,"names":["RunCmd","constructor","application","logger","name","description","render","appName","dev","skipWatch","ssr","port","exactPort","errors","runApp","watch","code","data","ShowErrors","pluralize","length","map","x","idx","toString"],"sources":["run.cmd.tsx"],"sourcesContent":["import React from 'react';\nimport pluralize from 'pluralize';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { Newline, Text } from 'ink';\nimport { Logger } from '@teambit/logger';\nimport type { RenderResult } from '@teambit/legacy/dist/cli/command';\nimport { ApplicationMain } from './application.main.runtime';\n\ntype RunOptions = {\n dev: boolean;\n verbose: boolean;\n skipWatch: boolean;\n ssr: boolean;\n port: string;\n};\n\nexport class RunCmd implements Command {\n name = 'run <app-name>';\n description = \"run an app (independent of bit's dev server)\";\n helpUrl = 'docs/apps/apps-overview';\n arguments = [\n {\n name: 'app-name',\n description:\n \"the app's name is registered by the app (run 'bit app list' to list the names of the available apps)\",\n },\n ];\n alias = 'c';\n group = 'apps';\n options = [\n ['d', 'dev', 'start the application in dev mode.'],\n ['p', 'port [port-number]', 'port of the app'],\n ['v', 'verbose', 'showing verbose output for inspection and prints stack trace'],\n ['', 'skip-watch', 'avoid running the watch process that compiles components in the background'],\n ['', 'ssr', 'run app in server side rendering mode.'],\n ] as CommandOptions;\n\n constructor(\n /**\n * access to the extension instance.\n */\n private application: ApplicationMain,\n\n private logger: Logger\n ) {}\n\n async render(\n [appName]: [string],\n { dev, skipWatch, ssr, port: exactPort }: RunOptions\n ): Promise<React.ReactElement | RenderResult> {\n // remove wds logs until refactoring webpack to a worker through the Worker aspect.\n const { port, errors } = await this.application.runApp(appName, {\n dev,\n watch: !skipWatch,\n ssr,\n port: +exactPort,\n });\n\n if (errors) {\n return {\n code: 1,\n data: <ShowErrors errors={errors} />,\n };\n }\n\n if (port) {\n return (\n <Text>\n {appName} app is running on http://localhost:{port}\n </Text>\n );\n }\n return <Text>{appName} app is running</Text>;\n }\n}\n\nfunction ShowErrors({ errors }: { errors: Error[] }) {\n return (\n <>\n <Newline />\n <Text underline>Fatal {pluralize('error', errors.length)}:</Text>\n {errors.map((x, idx) => (\n <Text key={idx}>{x.toString()}</Text>\n ))}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAaO,MAAMA,MAAM,CAAoB;EAqBrCC,WAAW;EACT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,UAAU,CAAC;EAAEL;AAA4B,CAAC,EAAE;EACnD,oBACE,6EACE,+BAAC,cAAO,OAAG,eACX,+BAAC,WAAI;IAAC,SAAS;EAAA,GAAC,QAAM,EAAC,IAAAM,oBAAS,EAAC,OAAO,EAAEN,MAAM,CAACO,MAAM,CAAC,EAAC,GAAC,CAAO,EAChEP,MAAM,CAACQ,GAAG,CAAC,CAACC,CAAC,EAAEC,GAAG,kBACjB,+BAAC,WAAI;IAAC,GAAG,EAAEA;EAAI,GAAED,CAAC,CAACE,QAAQ,EAAE,CAC9B,CAAC,CACD;AAEP"}
|
|
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.721",
|
|
4
4
|
"homepage": "https://bit.cloud/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.721"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
@@ -17,17 +17,17 @@
|
|
|
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.1079",
|
|
21
|
+
"@teambit/component": "0.0.1079",
|
|
22
|
+
"@teambit/isolator": "0.0.1079",
|
|
23
|
+
"@teambit/envs": "0.0.1079",
|
|
24
24
|
"@teambit/cli-table": "0.0.41",
|
|
25
|
-
"@teambit/cli": "0.0.
|
|
26
|
-
"@teambit/aspect-loader": "0.0.
|
|
25
|
+
"@teambit/cli": "0.0.727",
|
|
26
|
+
"@teambit/aspect-loader": "0.0.1079",
|
|
27
27
|
"@teambit/bit-error": "0.0.402",
|
|
28
|
-
"@teambit/logger": "0.0.
|
|
29
|
-
"@teambit/watcher": "0.0.
|
|
30
|
-
"@teambit/workspace": "0.0.
|
|
28
|
+
"@teambit/logger": "0.0.820",
|
|
29
|
+
"@teambit/watcher": "0.0.91",
|
|
30
|
+
"@teambit/workspace": "0.0.1079"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/react": "^17.0.8",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@types/testing-library__jest-dom": "5.9.5"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@teambit/legacy": "1.0.
|
|
43
|
+
"@teambit/legacy": "1.0.507",
|
|
44
44
|
"react": "^16.8.0 || ^17.0.0",
|
|
45
45
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
46
46
|
},
|
package/run.cmd.tsx
CHANGED
|
@@ -11,6 +11,7 @@ type RunOptions = {
|
|
|
11
11
|
verbose: boolean;
|
|
12
12
|
skipWatch: boolean;
|
|
13
13
|
ssr: boolean;
|
|
14
|
+
port: string;
|
|
14
15
|
};
|
|
15
16
|
|
|
16
17
|
export class RunCmd implements Command {
|
|
@@ -28,6 +29,7 @@ export class RunCmd implements Command {
|
|
|
28
29
|
group = 'apps';
|
|
29
30
|
options = [
|
|
30
31
|
['d', 'dev', 'start the application in dev mode.'],
|
|
32
|
+
['p', 'port [port-number]', 'port of the app'],
|
|
31
33
|
['v', 'verbose', 'showing verbose output for inspection and prints stack trace'],
|
|
32
34
|
['', 'skip-watch', 'avoid running the watch process that compiles components in the background'],
|
|
33
35
|
['', 'ssr', 'run app in server side rendering mode.'],
|
|
@@ -42,12 +44,16 @@ export class RunCmd implements Command {
|
|
|
42
44
|
private logger: Logger
|
|
43
45
|
) {}
|
|
44
46
|
|
|
45
|
-
async render(
|
|
47
|
+
async render(
|
|
48
|
+
[appName]: [string],
|
|
49
|
+
{ dev, skipWatch, ssr, port: exactPort }: RunOptions
|
|
50
|
+
): Promise<React.ReactElement | RenderResult> {
|
|
46
51
|
// remove wds logs until refactoring webpack to a worker through the Worker aspect.
|
|
47
52
|
const { port, errors } = await this.application.runApp(appName, {
|
|
48
53
|
dev,
|
|
49
54
|
watch: !skipWatch,
|
|
50
55
|
ssr,
|
|
56
|
+
port: +exactPort,
|
|
51
57
|
});
|
|
52
58
|
|
|
53
59
|
if (errors) {
|
|
Binary file
|