@teambit/application 1.0.62 → 1.0.64
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 +60 -3
- package/dist/app-context.js +58 -6
- package/dist/app-context.js.map +1 -1
- package/dist/app-instance.d.ts +31 -0
- package/dist/app-instance.js +3 -0
- package/dist/app-instance.js.map +1 -0
- package/dist/app.plugin.js +1 -1
- package/dist/app.plugin.js.map +1 -1
- package/dist/application.d.ts +5 -7
- package/dist/application.js.map +1 -1
- package/dist/application.main.runtime.d.ts +6 -8
- package/dist/application.main.runtime.js +18 -22
- package/dist/application.main.runtime.js.map +1 -1
- package/dist/apps-env-type.d.ts +1 -1
- package/dist/apps-env-type.js.map +1 -1
- package/dist/deploy.task.js +26 -9
- package/dist/deploy.task.js.map +1 -1
- package/dist/esm.d.mts +5 -0
- package/dist/esm.mjs +9 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js.map +1 -1
- package/dist/{preview-1700709510910.js → preview-1700991709206.js} +2 -2
- package/dist/run.cmd.d.ts +2 -1
- package/dist/run.cmd.js +10 -6
- package/dist/run.cmd.js.map +1 -1
- package/esm.mjs +9 -0
- package/package.json +18 -11
- package/run.cmd.tsx +10 -7
package/dist/app-context.d.ts
CHANGED
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
import { ExecutionContext } from '@teambit/envs';
|
|
2
|
+
import { Harmony } from '@teambit/harmony';
|
|
2
3
|
import { Component } from '@teambit/component';
|
|
4
|
+
import { Logger } from '@teambit/logger';
|
|
3
5
|
export declare class AppContext extends ExecutionContext {
|
|
6
|
+
/**
|
|
7
|
+
* name of the app
|
|
8
|
+
*/
|
|
4
9
|
readonly appName: string;
|
|
10
|
+
/**
|
|
11
|
+
* instance of harmony.
|
|
12
|
+
*/
|
|
13
|
+
readonly harmony: Harmony;
|
|
5
14
|
/**
|
|
6
15
|
* determine whether to serve the application in dev mode.
|
|
7
16
|
*/
|
|
8
17
|
readonly dev: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* application component instance.
|
|
20
|
+
*/
|
|
9
21
|
readonly appComponent: Component;
|
|
22
|
+
/**
|
|
23
|
+
* working directory of the component.
|
|
24
|
+
*/
|
|
10
25
|
readonly workdir: string;
|
|
26
|
+
/**
|
|
27
|
+
* execution context of the app.
|
|
28
|
+
*/
|
|
29
|
+
readonly execContext: ExecutionContext;
|
|
11
30
|
/**
|
|
12
31
|
* A path for the host root dir
|
|
13
32
|
* Host root dir is the dir where we run the app from
|
|
@@ -19,11 +38,35 @@ export declare class AppContext extends ExecutionContext {
|
|
|
19
38
|
* A port to run the app on
|
|
20
39
|
*/
|
|
21
40
|
readonly port?: number | undefined;
|
|
22
|
-
|
|
41
|
+
/**
|
|
42
|
+
* path to the application component in the workspace
|
|
43
|
+
*/
|
|
44
|
+
readonly workspaceComponentPath?: string | undefined;
|
|
45
|
+
constructor(
|
|
46
|
+
/**
|
|
47
|
+
* name of the app
|
|
48
|
+
*/
|
|
49
|
+
appName: string,
|
|
50
|
+
/**
|
|
51
|
+
* instance of harmony.
|
|
52
|
+
*/
|
|
53
|
+
harmony: Harmony,
|
|
23
54
|
/**
|
|
24
55
|
* determine whether to serve the application in dev mode.
|
|
25
56
|
*/
|
|
26
|
-
dev: boolean,
|
|
57
|
+
dev: boolean,
|
|
58
|
+
/**
|
|
59
|
+
* application component instance.
|
|
60
|
+
*/
|
|
61
|
+
appComponent: Component,
|
|
62
|
+
/**
|
|
63
|
+
* working directory of the component.
|
|
64
|
+
*/
|
|
65
|
+
workdir: string,
|
|
66
|
+
/**
|
|
67
|
+
* execution context of the app.
|
|
68
|
+
*/
|
|
69
|
+
execContext: ExecutionContext,
|
|
27
70
|
/**
|
|
28
71
|
* A path for the host root dir
|
|
29
72
|
* Host root dir is the dir where we run the app from
|
|
@@ -34,5 +77,19 @@ export declare class AppContext extends ExecutionContext {
|
|
|
34
77
|
/**
|
|
35
78
|
* A port to run the app on
|
|
36
79
|
*/
|
|
37
|
-
port?: number | undefined
|
|
80
|
+
port?: number | undefined,
|
|
81
|
+
/**
|
|
82
|
+
* path to the application component in the workspace
|
|
83
|
+
*/
|
|
84
|
+
workspaceComponentPath?: string | undefined);
|
|
85
|
+
/**
|
|
86
|
+
* return a logger instance for the env.
|
|
87
|
+
*/
|
|
88
|
+
createLogger(name?: string): Logger;
|
|
89
|
+
/**
|
|
90
|
+
* get an instance of an aspect.
|
|
91
|
+
* make sure it is loaded prior to requesting it.
|
|
92
|
+
*/
|
|
93
|
+
getAspect<T>(aspectId: string): T | undefined;
|
|
94
|
+
static compose(appContext: AppContext, overrides?: Partial<AppContext>): AppContext;
|
|
38
95
|
}
|
package/dist/app-context.js
CHANGED
|
@@ -11,12 +11,39 @@ function _envs() {
|
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
|
+
function _logger() {
|
|
15
|
+
const data = require("@teambit/logger");
|
|
16
|
+
_logger = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
14
21
|
class AppContext extends _envs().ExecutionContext {
|
|
15
|
-
constructor(
|
|
22
|
+
constructor(
|
|
23
|
+
/**
|
|
24
|
+
* name of the app
|
|
25
|
+
*/
|
|
26
|
+
appName,
|
|
27
|
+
/**
|
|
28
|
+
* instance of harmony.
|
|
29
|
+
*/
|
|
30
|
+
harmony,
|
|
16
31
|
/**
|
|
17
32
|
* determine whether to serve the application in dev mode.
|
|
18
33
|
*/
|
|
19
|
-
dev,
|
|
34
|
+
dev,
|
|
35
|
+
/**
|
|
36
|
+
* application component instance.
|
|
37
|
+
*/
|
|
38
|
+
appComponent,
|
|
39
|
+
/**
|
|
40
|
+
* working directory of the component.
|
|
41
|
+
*/
|
|
42
|
+
workdir,
|
|
43
|
+
/**
|
|
44
|
+
* execution context of the app.
|
|
45
|
+
*/
|
|
46
|
+
execContext,
|
|
20
47
|
/**
|
|
21
48
|
* A path for the host root dir
|
|
22
49
|
* Host root dir is the dir where we run the app from
|
|
@@ -27,18 +54,43 @@ class AppContext extends _envs().ExecutionContext {
|
|
|
27
54
|
/**
|
|
28
55
|
* A port to run the app on
|
|
29
56
|
*/
|
|
30
|
-
port
|
|
57
|
+
port,
|
|
58
|
+
/**
|
|
59
|
+
* path to the application component in the workspace
|
|
60
|
+
*/
|
|
61
|
+
workspaceComponentPath) {
|
|
31
62
|
super(execContext.upper, execContext.envRuntime, execContext.components);
|
|
32
63
|
this.appName = appName;
|
|
64
|
+
this.harmony = harmony;
|
|
33
65
|
this.dev = dev;
|
|
34
66
|
this.appComponent = appComponent;
|
|
35
67
|
this.workdir = workdir;
|
|
68
|
+
this.execContext = execContext;
|
|
36
69
|
this.hostRootDir = hostRootDir;
|
|
37
70
|
this.port = port;
|
|
71
|
+
this.workspaceComponentPath = workspaceComponentPath;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* return a logger instance for the env.
|
|
76
|
+
*/
|
|
77
|
+
createLogger(name) {
|
|
78
|
+
const loggerMain = this.harmony.get(_logger().LoggerAspect.id);
|
|
79
|
+
const appComponentId = this.appComponent.id;
|
|
80
|
+
const loggerName = name ? `${appComponentId.toString()}::${name}` : appComponentId.toString();
|
|
81
|
+
return loggerMain.createLogger(loggerName);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* get an instance of an aspect.
|
|
86
|
+
* make sure it is loaded prior to requesting it.
|
|
87
|
+
*/
|
|
88
|
+
getAspect(aspectId) {
|
|
89
|
+
return this.harmony.get(aspectId);
|
|
90
|
+
}
|
|
91
|
+
static compose(appContext, overrides) {
|
|
92
|
+
return new AppContext((overrides === null || overrides === void 0 ? void 0 : overrides.appName) || appContext.appName, (overrides === null || overrides === void 0 ? void 0 : overrides.harmony) || appContext.harmony, (overrides === null || overrides === void 0 ? void 0 : overrides.dev) || appContext.dev, (overrides === null || overrides === void 0 ? void 0 : overrides.appComponent) || appContext.appComponent, (overrides === null || overrides === void 0 ? void 0 : overrides.workdir) || appContext.workdir, (overrides === null || overrides === void 0 ? void 0 : overrides.execContext) || appContext.execContext, (overrides === null || overrides === void 0 ? void 0 : overrides.hostRootDir) || appContext.hostRootDir, (overrides === null || overrides === void 0 ? void 0 : overrides.port) || appContext.port, (overrides === null || overrides === void 0 ? void 0 : overrides.workspaceComponentPath) || appContext.workspaceComponentPath);
|
|
38
93
|
}
|
|
39
|
-
// static fromExecContext() {
|
|
40
|
-
// return new AppContext();
|
|
41
|
-
// }
|
|
42
94
|
}
|
|
43
95
|
exports.AppContext = AppContext;
|
|
44
96
|
|
package/dist/app-context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_envs","data","require","AppContext","ExecutionContext","constructor","appName","dev","appComponent","workdir","execContext","hostRootDir","port","upper","envRuntime","components","exports"],"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
|
|
1
|
+
{"version":3,"names":["_envs","data","require","_logger","AppContext","ExecutionContext","constructor","appName","harmony","dev","appComponent","workdir","execContext","hostRootDir","port","workspaceComponentPath","upper","envRuntime","components","createLogger","name","loggerMain","get","LoggerAspect","id","appComponentId","loggerName","toString","getAspect","aspectId","compose","appContext","overrides","exports"],"sources":["app-context.ts"],"sourcesContent":["import { ExecutionContext } from '@teambit/envs';\nimport { Harmony } from '@teambit/harmony';\nimport { Component } from '@teambit/component';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\n\nexport class AppContext extends ExecutionContext {\n constructor(\n /**\n * name of the app\n */\n readonly appName: string,\n\n /**\n * instance of harmony.\n */\n readonly harmony: Harmony,\n\n /**\n * determine whether to serve the application in dev mode.\n */\n readonly dev: boolean,\n\n /**\n * application component instance.\n */\n readonly appComponent: Component,\n\n /**\n * working directory of the component.\n */\n readonly workdir: string,\n\n /**\n * execution context of the app.\n */\n readonly 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 /**\n * path to the application component in the workspace\n */\n readonly workspaceComponentPath?: string,\n ) {\n super(execContext.upper, execContext.envRuntime, execContext.components);\n }\n\n /**\n * return a logger instance for the env.\n */\n createLogger(name?: string): Logger {\n const loggerMain = this.harmony.get<LoggerMain>(LoggerAspect.id);\n const appComponentId = this.appComponent.id;\n const loggerName = name ? `${appComponentId.toString()}::${name}` : appComponentId.toString();\n\n return loggerMain.createLogger(loggerName);\n }\n\n /**\n * get an instance of an aspect. \n * make sure it is loaded prior to requesting it.\n */\n getAspect<T>(aspectId: string): T|undefined {\n return this.harmony.get<T>(aspectId);\n }\n\n static compose(appContext: AppContext, overrides?: Partial<AppContext>) {\n return new AppContext(\n overrides?.appName || appContext.appName,\n overrides?.harmony || appContext.harmony,\n overrides?.dev || appContext.dev,\n overrides?.appComponent || appContext.appComponent,\n overrides?.workdir || appContext.workdir,\n overrides?.execContext || appContext.execContext,\n overrides?.hostRootDir || appContext.hostRootDir,\n overrides?.port || appContext.port,\n overrides?.workspaceComponentPath || appContext.workspaceComponentPath,\n );\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OA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app is running.
|
|
4
|
+
*/
|
|
5
|
+
port?: number;
|
|
6
|
+
/**
|
|
7
|
+
* name of the app
|
|
8
|
+
*/
|
|
9
|
+
appName: string;
|
|
10
|
+
/**
|
|
11
|
+
* url of the running app.
|
|
12
|
+
*/
|
|
13
|
+
url?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* an instance of an application deployment.
|
|
17
|
+
*/
|
|
18
|
+
export declare type ApplicationDeployment = {
|
|
19
|
+
/**
|
|
20
|
+
* timestamp of the deployment.
|
|
21
|
+
*/
|
|
22
|
+
timestamp?: string;
|
|
23
|
+
/**
|
|
24
|
+
* name of the deployed app.
|
|
25
|
+
*/
|
|
26
|
+
appName?: string;
|
|
27
|
+
/**
|
|
28
|
+
* url the deployed app.
|
|
29
|
+
*/
|
|
30
|
+
url?: string;
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["app-instance.ts"],"sourcesContent":["\n\nexport type ApplicationInstance = {\n /**\n * port in which app is running.\n */\n port?: number;\n\n /**\n * name of the app\n */\n appName: string;\n\n /**\n * url of the running app.\n */\n url?: string;\n};\n\n\n/**\n * an instance of an application deployment.\n */\nexport type ApplicationDeployment = {\n /**\n * timestamp of the deployment.\n */\n timestamp?: string;\n\n /**\n * name of the deployed app.\n */\n appName?: string;\n\n /**\n * url the deployed app.\n */\n url?: string; \n};\n"],"mappings":""}
|
package/dist/app.plugin.js
CHANGED
|
@@ -18,7 +18,7 @@ class AppPlugin {
|
|
|
18
18
|
constructor(appSlot) {
|
|
19
19
|
this.appSlot = appSlot;
|
|
20
20
|
// TODO - this matches NOTHING
|
|
21
|
-
_defineProperty(this, "pattern", '*.app
|
|
21
|
+
_defineProperty(this, "pattern", '*.bit-app.*');
|
|
22
22
|
_defineProperty(this, "runtimes", [_cli().MainRuntime.name]);
|
|
23
23
|
}
|
|
24
24
|
register(object) {
|
package/dist/app.plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_cli","data","require","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","AppPlugin","constructor","appSlot","MainRuntime","name","register","object","exports"],"sources":["app.plugin.ts"],"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 // TODO - this matches NOTHING\n pattern = '*.app
|
|
1
|
+
{"version":3,"names":["_cli","data","require","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","AppPlugin","constructor","appSlot","MainRuntime","name","register","object","exports"],"sources":["app.plugin.ts"],"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 // TODO - this matches NOTHING\n pattern = '*.bit-app.*';\n\n runtimes = [MainRuntime.name];\n\n register(object: any) {\n return this.appSlot.register([object]);\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA2C,SAAAE,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,GAAA,QAAAR,GAAA,GAAAS,YAAA,CAAAD,GAAA,2BAAAR,GAAA,gBAAAA,GAAA,GAAAU,MAAA,CAAAV,GAAA;AAAA,SAAAS,aAAAE,KAAA,EAAAC,IAAA,eAAAD,KAAA,iBAAAA,KAAA,kBAAAA,KAAA,MAAAE,IAAA,GAAAF,KAAA,CAAAG,MAAA,CAAAC,WAAA,OAAAF,IAAA,KAAAG,SAAA,QAAAC,GAAA,GAAAJ,IAAA,CAAAK,IAAA,CAAAP,KAAA,EAAAC,IAAA,2BAAAK,GAAA,sBAAAA,GAAA,YAAAE,SAAA,4DAAAP,IAAA,gBAAAF,MAAA,GAAAU,MAAA,EAAAT,KAAA;AAGpC,MAAMU,SAAS,CAA6B;EACjDC,WAAWA,CAASC,OAAwB,EAAE;IAAA,KAA1BA,OAAwB,GAAxBA,OAAwB;IAE5C;IAAAzB,eAAA,kBACU,aAAa;IAAAA,eAAA,mBAEZ,CAAC0B,kBAAW,CAACC,IAAI,CAAC;EALkB;EAO/CC,QAAQA,CAACC,MAAW,EAAE;IACpB,OAAO,IAAI,CAACJ,OAAO,CAACG,QAAQ,CAAC,CAACC,MAAM,CAAC,CAAC;EACxC;AACF;AAACC,OAAA,CAAAP,SAAA,GAAAA,SAAA"}
|
package/dist/application.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ import { AppContext } from './app-context';
|
|
|
2
2
|
import { AppDeployContext } from './app-deploy-context';
|
|
3
3
|
import { AppBuildContext } from './app-build-context';
|
|
4
4
|
import { AppBuildResult } from './app-build-result';
|
|
5
|
-
|
|
5
|
+
import { ApplicationDeployment, ApplicationInstance } from './app-instance';
|
|
6
|
+
export declare type DeployFn = (context: AppDeployContext) => Promise<ApplicationDeployment | undefined>;
|
|
7
|
+
export declare type BuildFn = (context: AppBuildContext) => Promise<AppBuildResult>;
|
|
6
8
|
export declare type AppResult = {
|
|
7
9
|
port?: number;
|
|
8
10
|
errors?: Error[];
|
|
@@ -15,15 +17,11 @@ export interface Application {
|
|
|
15
17
|
/**
|
|
16
18
|
* run the application.
|
|
17
19
|
*/
|
|
18
|
-
run(context: AppContext): Promise<
|
|
19
|
-
/**
|
|
20
|
-
* run the application in ssr mode
|
|
21
|
-
*/
|
|
22
|
-
runSsr?(context: AppContext): Promise<AppResult>;
|
|
20
|
+
run(context: AppContext): Promise<ApplicationInstance>;
|
|
23
21
|
/**
|
|
24
22
|
* build the application.
|
|
25
23
|
*/
|
|
26
|
-
build
|
|
24
|
+
build?: BuildFn;
|
|
27
25
|
/**
|
|
28
26
|
* application deployment. this is a build task.
|
|
29
27
|
*/
|
package/dist/application.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["application.ts"],"sourcesContent":["import { AppContext } from './app-context';\nimport { AppDeployContext } from './app-deploy-context';\nimport { AppBuildContext } from './app-build-context';\nimport { AppBuildResult } from './app-build-result';\n\nexport type DeployFn = (context: AppDeployContext) => Promise<
|
|
1
|
+
{"version":3,"names":[],"sources":["application.ts"],"sourcesContent":["import { AppContext } from './app-context';\nimport { AppDeployContext } from './app-deploy-context';\nimport { AppBuildContext } from './app-build-context';\nimport { AppBuildResult } from './app-build-result';\nimport { ApplicationDeployment, ApplicationInstance } from './app-instance';\n\nexport type DeployFn = (context: AppDeployContext) => Promise<ApplicationDeployment|undefined>;\n\nexport type BuildFn = (context: AppBuildContext) => Promise<AppBuildResult>;\n\nexport type AppResult = {\n port?: number;\n errors?: Error[];\n};\n\nexport interface Application {\n /**\n * name of the application. e.g. ripple-ci.\n */\n name: string;\n\n /**\n * run the application.\n */\n run(context: AppContext): Promise<ApplicationInstance>;\n\n /**\n * build the application.\n */\n build?: BuildFn;\n\n /**\n * application deployment. this is a build task.\n */\n deploy?: DeployFn;\n\n /**\n * Type of the application\n */\n applicationType?: string;\n}\n"],"mappings":""}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CLIMain } from '@teambit/cli';
|
|
2
2
|
import { AspectLoaderMain } from '@teambit/aspect-loader';
|
|
3
|
-
import { SlotRegistry } from '@teambit/harmony';
|
|
3
|
+
import { SlotRegistry, Harmony } from '@teambit/harmony';
|
|
4
4
|
import { Workspace } from '@teambit/workspace';
|
|
5
5
|
import { WatcherMain } from '@teambit/watcher';
|
|
6
6
|
import { BuilderMain } from '@teambit/builder';
|
|
@@ -63,7 +63,8 @@ export declare class ApplicationMain {
|
|
|
63
63
|
private workspace;
|
|
64
64
|
private logger;
|
|
65
65
|
private watcher;
|
|
66
|
-
|
|
66
|
+
private harmony;
|
|
67
|
+
constructor(appSlot: ApplicationSlot, appTypeSlot: ApplicationTypeSlot, deploymentProviderSlot: DeploymentProviderSlot, config: ApplicationAspectConfig, envs: EnvsMain, componentAspect: ComponentMain, appService: AppService, aspectLoader: AspectLoaderMain, workspace: Workspace, logger: Logger, watcher: WatcherMain, harmony: Harmony);
|
|
67
68
|
/**
|
|
68
69
|
* register a new app.
|
|
69
70
|
*/
|
|
@@ -122,13 +123,10 @@ export declare class ApplicationMain {
|
|
|
122
123
|
private computeOptions;
|
|
123
124
|
loadAppsToSlot(): Promise<this>;
|
|
124
125
|
runApp(appName: string, options?: ServeAppOptions): Promise<{
|
|
125
|
-
port?: number | undefined;
|
|
126
|
-
errors?: Error[] | undefined;
|
|
127
126
|
app: Application;
|
|
128
|
-
|
|
129
|
-
app: Application;
|
|
130
|
-
port: number | void;
|
|
127
|
+
port: number | undefined;
|
|
131
128
|
errors: undefined;
|
|
129
|
+
isOldApi: boolean;
|
|
132
130
|
}>;
|
|
133
131
|
/**
|
|
134
132
|
* get the component ID of a certain app.
|
|
@@ -147,5 +145,5 @@ export declare class ApplicationMain {
|
|
|
147
145
|
AspectLoaderMain,
|
|
148
146
|
Workspace,
|
|
149
147
|
WatcherMain
|
|
150
|
-
], config: ApplicationAspectConfig, [appTypeSlot, appSlot, deploymentProviderSlot]: [ApplicationTypeSlot, ApplicationSlot, DeploymentProviderSlot]): Promise<ApplicationMain>;
|
|
148
|
+
], config: ApplicationAspectConfig, [appTypeSlot, appSlot, deploymentProviderSlot]: [ApplicationTypeSlot, ApplicationSlot, DeploymentProviderSlot], harmony: Harmony): Promise<ApplicationMain>;
|
|
151
149
|
}
|
|
@@ -158,13 +158,6 @@ function _deploy() {
|
|
|
158
158
|
};
|
|
159
159
|
return data;
|
|
160
160
|
}
|
|
161
|
-
function _appNoSsr() {
|
|
162
|
-
const data = require("./exceptions/app-no-ssr");
|
|
163
|
-
_appNoSsr = function () {
|
|
164
|
-
return data;
|
|
165
|
-
};
|
|
166
|
-
return data;
|
|
167
|
-
}
|
|
168
161
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
169
162
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
170
163
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -178,7 +171,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
178
171
|
class ApplicationMain {
|
|
179
172
|
constructor(appSlot,
|
|
180
173
|
// TODO unused
|
|
181
|
-
appTypeSlot, deploymentProviderSlot, config, envs, componentAspect, appService, aspectLoader, workspace, logger, watcher) {
|
|
174
|
+
appTypeSlot, deploymentProviderSlot, config, envs, componentAspect, appService, aspectLoader, workspace, logger, watcher, harmony) {
|
|
182
175
|
this.appSlot = appSlot;
|
|
183
176
|
this.appTypeSlot = appTypeSlot;
|
|
184
177
|
this.deploymentProviderSlot = deploymentProviderSlot;
|
|
@@ -190,6 +183,7 @@ class ApplicationMain {
|
|
|
190
183
|
this.workspace = workspace;
|
|
191
184
|
this.logger = logger;
|
|
192
185
|
this.watcher = watcher;
|
|
186
|
+
this.harmony = harmony;
|
|
193
187
|
_defineProperty(this, "defaultOpts", {
|
|
194
188
|
dev: false,
|
|
195
189
|
ssr: false,
|
|
@@ -285,9 +279,14 @@ class ApplicationMain {
|
|
|
285
279
|
});
|
|
286
280
|
|
|
287
281
|
// const app = require(appPath);
|
|
288
|
-
const appManifests = (0, _lodash().compact)(pluginsToLoad.map(pluginPath => {
|
|
282
|
+
const appManifests = Promise.all((0, _lodash().compact)(pluginsToLoad.map(async pluginPath => {
|
|
289
283
|
try {
|
|
290
284
|
var _require;
|
|
285
|
+
const isModule = await this.aspectLoader.isEsmModule(pluginPath);
|
|
286
|
+
if (isModule) {
|
|
287
|
+
const appManifest = await this.aspectLoader.loadEsm(pluginPath);
|
|
288
|
+
return appManifest;
|
|
289
|
+
}
|
|
291
290
|
// eslint-disable-next-line
|
|
292
291
|
const appManifest = (_require = require(pluginPath)) === null || _require === void 0 ? void 0 : _require.default;
|
|
293
292
|
return appManifest;
|
|
@@ -295,7 +294,7 @@ class ApplicationMain {
|
|
|
295
294
|
this.logger.error(`failed loading app manifest: ${pluginPath}`);
|
|
296
295
|
return undefined;
|
|
297
296
|
}
|
|
298
|
-
}));
|
|
297
|
+
})));
|
|
299
298
|
return appManifests;
|
|
300
299
|
}
|
|
301
300
|
async loadAppsFromComponent(component, rootDir) {
|
|
@@ -384,14 +383,7 @@ class ApplicationMain {
|
|
|
384
383
|
const app = this.getAppOrThrow(appName);
|
|
385
384
|
const context = await this.createAppContext(app.name, options.port);
|
|
386
385
|
if (!context) throw new (_exceptions().AppNotFound)(appName);
|
|
387
|
-
|
|
388
|
-
if (!app.runSsr) throw new (_appNoSsr().AppNoSsr)(appName);
|
|
389
|
-
const result = await app.runSsr(context);
|
|
390
|
-
return _objectSpread({
|
|
391
|
-
app
|
|
392
|
-
}, result);
|
|
393
|
-
}
|
|
394
|
-
const port = await app.run(context);
|
|
386
|
+
const instance = await app.run(context);
|
|
395
387
|
if (options.watch) {
|
|
396
388
|
this.watcher.watch({
|
|
397
389
|
preCompile: false,
|
|
@@ -401,10 +393,13 @@ class ApplicationMain {
|
|
|
401
393
|
this.logger.error(`compilation failed`, err);
|
|
402
394
|
});
|
|
403
395
|
}
|
|
396
|
+
const isOldApi = typeof instance === 'number';
|
|
397
|
+
const port = isOldApi ? instance : instance === null || instance === void 0 ? void 0 : instance.port;
|
|
404
398
|
return {
|
|
405
399
|
app,
|
|
406
400
|
port,
|
|
407
|
-
errors: undefined
|
|
401
|
+
errors: undefined,
|
|
402
|
+
isOldApi
|
|
408
403
|
};
|
|
409
404
|
}
|
|
410
405
|
|
|
@@ -431,13 +426,14 @@ class ApplicationMain {
|
|
|
431
426
|
const context = res.results[0].data;
|
|
432
427
|
if (!context) throw new (_exceptions().AppNotFound)(appName);
|
|
433
428
|
const hostRootDir = await this.workspace.getComponentPackagePath(component);
|
|
434
|
-
const
|
|
429
|
+
const workspaceComponentDir = this.workspace.componentDir(component.id);
|
|
430
|
+
const appContext = new (_appContext().AppContext)(appName, this.harmony, context.dev, component, this.workspace.path, context, hostRootDir, port, workspaceComponentDir);
|
|
435
431
|
return appContext;
|
|
436
432
|
}
|
|
437
|
-
static async provider([cli, loggerAspect, builder, envs, component, aspectLoader, workspace, watcher], config, [appTypeSlot, appSlot, deploymentProviderSlot]) {
|
|
433
|
+
static async provider([cli, loggerAspect, builder, envs, component, aspectLoader, workspace, watcher], config, [appTypeSlot, appSlot, deploymentProviderSlot], harmony) {
|
|
438
434
|
const logger = loggerAspect.createLogger(_application().ApplicationAspect.id);
|
|
439
435
|
const appService = new (_application2().AppService)();
|
|
440
|
-
const application = new ApplicationMain(appSlot, appTypeSlot, deploymentProviderSlot, config, envs, component, appService, aspectLoader, workspace, logger, watcher);
|
|
436
|
+
const application = new ApplicationMain(appSlot, appTypeSlot, deploymentProviderSlot, config, envs, component, appService, aspectLoader, workspace, logger, watcher, harmony);
|
|
441
437
|
appService.registerAppType = application.registerAppType.bind(application);
|
|
442
438
|
const appCmd = new (_app().AppCmd)();
|
|
443
439
|
appCmd.commands = [new (_app().AppListCmd)(application), new (_run().RunCmd)(application, logger)];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_cli","data","require","_lodash","_aspectLoader","_harmony","_workspace","_interopRequireDefault","_bitError","_watcher","_builder","_logger","_envs","_component","_exceptions","_application","_appList","_buildApplication","_run","_application2","_app","_app2","_appType","_appContext","_deploy","_appNoSsr","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","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","get","toString","getAppById","apps","head","calculateAppByComponent","component","listAppTypes","listAppsFromComponents","listAppsComponents","components","getHost","list","appTypesPatterns","getAppPatterns","appsComponents","hasAppTypePattern","patterns","files","filesystem","byGlob","appTypes","map","appType","getAppPattern","loadApps","pluginsToLoad","flatMap","appComponent","file","path","appManifests","compact","pluginPath","_require","appManifest","err","error","loadAppsFromComponent","rootDir","isApp","allPluginDefs","getPluginDefs","appsPluginDefs","pluginDef","includes","pattern","plugins","getPluginsFromDefs","loadedPlugins","has","load","MainRuntime","name","loadExtensionsByManifests","seeders","getApp","appName","find","getAppByNameOrId","appNameOrId","byName","byId","BitError","globPattern","registerAppType","AppTypePlugin","registerPlugins","getAppAspect","_this$appSlot$toArray","getAppOrThrow","AppNotFound","computeOptions","opts","defaultOpts","loadAppsToSlot","runApp","options","context","createAppContext","port","runSsr","AppNoSsr","result","run","preCompile","compile","catch","errors","getAppIdOrThrow","maybeApp","host","resolveComponentId","env","createEnvironment","results","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","exports","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-application.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 /**\n * @deprecated use `listAppsComponents` instead.\n * @returns\n */\n async listAppsFromComponents(): Promise<Component[]> {\n return this.listAppsComponents();\n }\n\n async listAppsComponents(): Promise<Component[]> {\n const components = await this.componentAspect.getHost().list();\n const appTypesPatterns = this.getAppPatterns();\n const appsComponents = components.filter((component) => this.hasAppTypePattern(component, appTypesPatterns));\n return appsComponents;\n }\n\n private hasAppTypePattern(component: Component, appTypesPatterns?: string[]): boolean {\n const patterns = appTypesPatterns || this.getAppPatterns();\n // has app plugin from registered types.\n const files = component.filesystem.byGlob(patterns);\n return !!files.length;\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.listAppsComponents();\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\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 async loadAppsFromComponent(component: Component, rootDir: string): Promise<Application[] | undefined> {\n const appTypesPatterns = this.getAppPatterns();\n const isApp = this.hasAppTypePattern(component, appTypesPatterns);\n if (!isApp) return undefined;\n\n const allPluginDefs = this.aspectLoader.getPluginDefs();\n\n const appsPluginDefs = allPluginDefs.filter((pluginDef) => {\n return appTypesPatterns.includes(pluginDef.pattern.toString());\n });\n // const fileResolver = this.aspectLoader.pluginFileResolver(component, rootDir);\n\n const plugins = this.aspectLoader.getPluginsFromDefs(component, rootDir, appsPluginDefs);\n let loadedPlugins;\n if (plugins.has()) {\n loadedPlugins = await plugins.load(MainRuntime.name);\n await this.aspectLoader.loadExtensionsByManifests([loadedPlugins], { seeders: [component.id.toString()] });\n }\n\n const listAppsById = this.listAppsById(component.id);\n return listAppsById;\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>(...appTypes: Array<ApplicationType<T>>) {\n const plugins = appTypes.map((appType) => {\n return new AppTypePlugin(this.getAppPattern(appType), appType, this.appSlot);\n });\n\n this.aspectLoader.registerPlugins(plugins);\n this.appTypeSlot.register(appTypes);\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 compile: true,\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 = await 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,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,cAAA;EAA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,eAAA,CApWYsB,eAAe,aA2RT+E,kBAAW;AAAArG,eAAA,CA3RjBsB,eAAe,kBA4RJ,CACpB2J,gBAAS,EACTC,sBAAY,EACZC,wBAAa,EACbC,kBAAU,EACVC,oBAAe,EACfC,kCAAkB,EAClBC,oBAAe,EACfC,kBAAa,CACd;AAAAxL,eAAA,CArSUsB,eAAe,WAuSX,CACbmK,eAAI,CAACC,QAAQ,CAA6B,CAAC,EAC3CD,eAAI,CAACC,QAAQ,CAAgB,CAAC,EAC9BD,eAAI,CAACC,QAAQ,CAAuB,CAAC,CACtC;AA2DHhC,gCAAiB,CAACiC,UAAU,CAACrK,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"names":["_cli","data","require","_lodash","_aspectLoader","_harmony","_workspace","_interopRequireDefault","_bitError","_watcher","_builder","_logger","_envs","_component","_exceptions","_application","_appList","_buildApplication","_run","_application2","_app","_app2","_appType","_appContext","_deploy","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","ApplicationMain","constructor","appSlot","appTypeSlot","deploymentProviderSlot","config","envs","componentAspect","appService","aspectLoader","workspace","logger","watcher","harmony","dev","ssr","watch","defaultPortRange","registerApp","app","register","listApps","flatten","values","mapApps","toArray","listAppsById","id","get","toString","getAppById","apps","head","calculateAppByComponent","component","listAppTypes","listAppsFromComponents","listAppsComponents","components","getHost","list","appTypesPatterns","getAppPatterns","appsComponents","hasAppTypePattern","patterns","files","filesystem","byGlob","appTypes","map","appType","getAppPattern","loadApps","pluginsToLoad","flatMap","appComponent","file","path","appManifests","Promise","all","compact","pluginPath","_require","isModule","isEsmModule","appManifest","loadEsm","err","error","loadAppsFromComponent","rootDir","isApp","allPluginDefs","getPluginDefs","appsPluginDefs","pluginDef","includes","pattern","plugins","getPluginsFromDefs","loadedPlugins","has","load","MainRuntime","name","loadExtensionsByManifests","seeders","getApp","appName","find","getAppByNameOrId","appNameOrId","byName","byId","BitError","globPattern","registerAppType","AppTypePlugin","registerPlugins","getAppAspect","_this$appSlot$toArray","getAppOrThrow","AppNotFound","computeOptions","opts","defaultOpts","loadAppsToSlot","runApp","options","context","createAppContext","port","instance","run","preCompile","compile","catch","isOldApi","errors","getAppIdOrThrow","maybeApp","host","resolveComponentId","env","createEnvironment","results","hostRootDir","getComponentPackagePath","workspaceComponentDir","componentDir","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","exports","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, Harmony } 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-application.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';\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 private harmony: Harmony\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 /**\n * @deprecated use `listAppsComponents` instead.\n * @returns\n */\n async listAppsFromComponents(): Promise<Component[]> {\n return this.listAppsComponents();\n }\n\n async listAppsComponents(): Promise<Component[]> {\n const components = await this.componentAspect.getHost().list();\n const appTypesPatterns = this.getAppPatterns();\n const appsComponents = components.filter((component) => this.hasAppTypePattern(component, appTypesPatterns));\n return appsComponents;\n }\n\n private hasAppTypePattern(component: Component, appTypesPatterns?: string[]): boolean {\n const patterns = appTypesPatterns || this.getAppPatterns();\n // has app plugin from registered types.\n const files = component.filesystem.byGlob(patterns);\n return !!files.length;\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.listAppsComponents();\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\n // const app = require(appPath);\n const appManifests = Promise.all(\n compact(\n pluginsToLoad.map(async (pluginPath) => {\n try {\n const isModule = await this.aspectLoader.isEsmModule(pluginPath);\n if (isModule) {\n const appManifest = await this.aspectLoader.loadEsm(pluginPath);\n return appManifest;\n }\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\n return appManifests;\n }\n\n async loadAppsFromComponent(component: Component, rootDir: string): Promise<Application[] | undefined> {\n const appTypesPatterns = this.getAppPatterns();\n const isApp = this.hasAppTypePattern(component, appTypesPatterns);\n if (!isApp) return undefined;\n\n const allPluginDefs = this.aspectLoader.getPluginDefs();\n\n const appsPluginDefs = allPluginDefs.filter((pluginDef) => {\n return appTypesPatterns.includes(pluginDef.pattern.toString());\n });\n // const fileResolver = this.aspectLoader.pluginFileResolver(component, rootDir);\n\n const plugins = this.aspectLoader.getPluginsFromDefs(component, rootDir, appsPluginDefs);\n let loadedPlugins;\n if (plugins.has()) {\n loadedPlugins = await plugins.load(MainRuntime.name);\n await this.aspectLoader.loadExtensionsByManifests([loadedPlugins], { seeders: [component.id.toString()] });\n }\n\n const listAppsById = this.listAppsById(component.id);\n return listAppsById;\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>(...appTypes: Array<ApplicationType<T>>) {\n const plugins = appTypes.map((appType) => {\n return new AppTypePlugin(this.getAppPattern(appType), appType, this.appSlot);\n });\n\n this.aspectLoader.registerPlugins(plugins);\n this.appTypeSlot.register(appTypes);\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 const instance = await app.run(context);\n if (options.watch) {\n this.watcher\n .watch({\n preCompile: false,\n compile: true,\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\n const isOldApi = typeof instance === 'number'\n const port = isOldApi\n ? instance\n : instance?.port;\n\n return { app, port, errors: undefined, isOldApi };\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 = await this.workspace.getComponentPackagePath(component);\n const workspaceComponentDir = this.workspace.componentDir(component.id);\n\n const appContext = new AppContext(\n appName,\n this.harmony,\n context.dev,\n component,\n this.workspace.path,\n context,\n hostRootDir,\n port,\n workspaceComponentDir\n );\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 harmony: Harmony\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 harmony\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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E,cAAc,CAAC;IACzCpB,GAAG,CAACnH,QAAQ,CAAC,KAAI+H,aAAM,EAACN,WAAW,EAAElI,MAAM,CAAC,EAAE,KAAIiJ,+BAAoB,EAACf,WAAW,CAAC,EAAEE,MAAM,CAAC;IAC5F;IACA;IACA;IACA,IAAIrI,SAAS,EAAE;MACbA,SAAS,CAACmJ,eAAe,CAAC,MAAOC,eAAe,IAA+C;QAC7F,MAAM3I,GAAG,GAAG0H,WAAW,CAAC5G,uBAAuB,CAAC6H,eAAe,CAAC;QAChE,IAAI,CAAC3I,GAAG,EAAE,OAAOxB,SAAS;QAC1B,OAAO;UACL+F,OAAO,EAAEvE,GAAG,CAACmE,IAAI;UACjByE,IAAI,EAAE5I,GAAG,CAAC6I;QACZ,CAAC;MACH,CAAC,CAAC;IACJ;IAEA,OAAOnB,WAAW;EACpB;AACF;AAACoB,OAAA,CAAAjK,eAAA,GAAAA,eAAA;AAAAtB,eAAA,CAzXYsB,eAAe,aA8STqF,kBAAW;AAAA3G,eAAA,CA9SjBsB,eAAe,kBA+SJ,CACpBkK,gBAAS,EACTC,sBAAY,EACZC,wBAAa,EACbC,kBAAU,EACVC,oBAAe,EACfC,kCAAkB,EAClBC,oBAAe,EACfC,kBAAa,CACd;AAAA/L,eAAA,CAxTUsB,eAAe,WA0TX,CACb0K,eAAI,CAACC,QAAQ,CAA6B,CAAC,EAC3CD,eAAI,CAACC,QAAQ,CAAgB,CAAC,EAC9BD,eAAI,CAACC,QAAQ,CAAuB,CAAC,CACtC;AA6DHhC,gCAAiB,CAACiC,UAAU,CAAC5K,eAAe,CAAC"}
|
package/dist/apps-env-type.d.ts
CHANGED
|
@@ -1 +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":""}
|
|
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/deploy.task.js
CHANGED
|
@@ -57,12 +57,28 @@ class DeployTask {
|
|
|
57
57
|
}
|
|
58
58
|
const apps = await this.application.loadAppsFromComponent(component, capsule.path);
|
|
59
59
|
if (!apps || !apps.length) return undefined;
|
|
60
|
-
await (0, _pMapSeries().default)((0, _lodash().compact)(apps), async app => this.runForOneApp(app, capsule, context));
|
|
61
|
-
|
|
60
|
+
const appDeployments = await (0, _pMapSeries().default)((0, _lodash().compact)(apps), async app => this.runForOneApp(app, capsule, context));
|
|
61
|
+
const deploys = (0, _lodash().compact)(appDeployments);
|
|
62
|
+
return {
|
|
63
|
+
component,
|
|
64
|
+
deploys
|
|
65
|
+
};
|
|
62
66
|
});
|
|
63
|
-
const _componentsResults = (0, _lodash().compact)(components).map(
|
|
67
|
+
const _componentsResults = (0, _lodash().compact)(components).map(({
|
|
68
|
+
component,
|
|
69
|
+
deploys
|
|
70
|
+
}) => {
|
|
64
71
|
return {
|
|
65
|
-
component
|
|
72
|
+
component,
|
|
73
|
+
metadata: {
|
|
74
|
+
deployments: deploys.map(deploy => {
|
|
75
|
+
return {
|
|
76
|
+
appName: deploy.appName,
|
|
77
|
+
timestamp: deploy.timestamp,
|
|
78
|
+
url: deploy.url
|
|
79
|
+
};
|
|
80
|
+
})
|
|
81
|
+
}
|
|
66
82
|
};
|
|
67
83
|
});
|
|
68
84
|
return {
|
|
@@ -71,20 +87,21 @@ class DeployTask {
|
|
|
71
87
|
}
|
|
72
88
|
async runForOneApp(app, capsule, context) {
|
|
73
89
|
const aspectId = this.application.getAppAspect(app.name);
|
|
74
|
-
if (!aspectId) return;
|
|
75
|
-
if (!capsule || !(capsule !== null && capsule !== void 0 && capsule.component)) return;
|
|
90
|
+
if (!aspectId) return undefined;
|
|
91
|
+
if (!capsule || !(capsule !== null && capsule !== void 0 && capsule.component)) return undefined;
|
|
76
92
|
const buildTask = this.getBuildTask(context.previousTasksResults, context.envRuntime.id);
|
|
77
93
|
const metadata = this.getBuildMetadata(buildTask, capsule.component);
|
|
78
|
-
if (!metadata) return;
|
|
94
|
+
if (!metadata) return undefined;
|
|
79
95
|
const buildDeployContexts = metadata.find(ctx => ctx.name === app.name && ctx.appType === app.applicationType);
|
|
80
|
-
if (!buildDeployContexts) return;
|
|
96
|
+
if (!buildDeployContexts) return undefined;
|
|
81
97
|
const appDeployContext = Object.assign(context, buildDeployContexts.deployContext, {
|
|
82
98
|
capsule,
|
|
83
99
|
appComponent: capsule.component
|
|
84
100
|
});
|
|
85
101
|
if (app && typeof app.deploy === 'function') {
|
|
86
|
-
|
|
102
|
+
return app.deploy(appDeployContext);
|
|
87
103
|
}
|
|
104
|
+
return undefined;
|
|
88
105
|
}
|
|
89
106
|
getBuildMetadata(buildTask, component) {
|
|
90
107
|
var _componentResults$met;
|
package/dist/deploy.task.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_pMapSeries","data","_interopRequireDefault","require","_lodash","_application","_buildApplication","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","DEPLOY_TASK","exports","DeployTask","constructor","application","builder","ApplicationAspect","id","execute","context","originalSeedersIds","capsuleNetwork","originalSeedersCapsules","map","c","component","toString","components","mapSeries","capsule","length","includes","apps","loadAppsFromComponent","path","compact","app","runForOneApp","_componentsResults","componentsResults","aspectId","getAppAspect","name","buildTask","getBuildTask","previousTasksResults","envRuntime","
|
|
1
|
+
{"version":3,"names":["_pMapSeries","data","_interopRequireDefault","require","_lodash","_application","_buildApplication","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","DEPLOY_TASK","exports","DeployTask","constructor","application","builder","ApplicationAspect","id","execute","context","originalSeedersIds","capsuleNetwork","originalSeedersCapsules","map","c","component","toString","components","mapSeries","capsule","length","includes","apps","loadAppsFromComponent","path","appDeployments","compact","app","runForOneApp","deploys","_componentsResults","metadata","deployments","deploy","appName","timestamp","url","componentsResults","aspectId","getAppAspect","name","buildTask","getBuildTask","previousTasksResults","envRuntime","getBuildMetadata","buildDeployContexts","find","ctx","appType","applicationType","appDeployContext","assign","deployContext","appComponent","_componentResults$met","appData","getDataByAspect","componentResults","isEqual","ignoreVersion","taskResults","runtime","task","env","BUILD_TASK"],"sources":["deploy.task.ts"],"sourcesContent":["import mapSeries from 'p-map-series';\nimport { BuilderMain, BuildTask, BuildContext, ComponentResult, TaskResults, BuiltTaskResult } from '@teambit/builder';\nimport { compact } from 'lodash';\nimport { Capsule } from '@teambit/isolator';\nimport { Component } from '@teambit/component';\nimport { ApplicationAspect } from './application.aspect';\nimport { ApplicationMain } from './application.main.runtime';\nimport { BUILD_TASK, BuildDeployContexts } from './build-application.task';\nimport { AppDeployContext } from './app-deploy-context';\nimport { Application } from './application';\nimport { ApplicationDeployment } from './app-instance';\n\nexport const DEPLOY_TASK = 'deploy_application';\n\nexport class DeployTask implements BuildTask {\n name = DEPLOY_TASK;\n aspectId = ApplicationAspect.id;\n readonly location = 'end';\n constructor(private application: ApplicationMain, private builder: BuilderMain) {}\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n const originalSeedersIds = context.capsuleNetwork.originalSeedersCapsules.map((c) => c.component.id.toString());\n const { capsuleNetwork } = context;\n\n const components = await mapSeries(capsuleNetwork.originalSeedersCapsules, async (capsule) => {\n const component = capsule.component;\n if (originalSeedersIds && originalSeedersIds.length && !originalSeedersIds.includes(component.id.toString())) {\n return undefined;\n }\n const apps = await this.application.loadAppsFromComponent(component, capsule.path);\n if (!apps || !apps.length) return undefined;\n const appDeployments = await mapSeries(compact(apps), async (app) => this.runForOneApp(app, capsule, context));\n const deploys = compact(appDeployments);\n return { component, deploys };\n });\n\n const _componentsResults: ComponentResult[] = compact(components).map(({ component, deploys }) => {\n return { \n component,\n metadata: {\n deployments: deploys.map((deploy) => {\n return {\n appName: deploy.appName,\n timestamp: deploy.timestamp,\n url: deploy.url\n }\n })\n }\n };\n });\n\n return {\n componentsResults: _componentsResults,\n };\n }\n\n private async runForOneApp(\n app: Application, \n capsule: Capsule, \n context: BuildContext\n ): Promise<ApplicationDeployment|undefined> {\n const aspectId = this.application.getAppAspect(app.name);\n if (!aspectId) return undefined;\n\n if (!capsule || !capsule?.component) return undefined;\n\n const buildTask = this.getBuildTask(context.previousTasksResults, context.envRuntime.id);\n\n const metadata = this.getBuildMetadata(buildTask, capsule.component);\n if (!metadata) return undefined;\n const buildDeployContexts = metadata.find((ctx) => ctx.name === app.name && ctx.appType === app.applicationType);\n if (!buildDeployContexts) return undefined;\n\n const appDeployContext: AppDeployContext = Object.assign(context, buildDeployContexts.deployContext, {\n capsule,\n appComponent: capsule.component,\n });\n\n if (app && typeof app.deploy === 'function') {\n return app.deploy(appDeployContext);\n }\n\n return undefined;\n }\n\n private getBuildMetadata(\n buildTask: TaskResults | undefined,\n component: Component\n ): BuildDeployContexts[] | undefined {\n if (!buildTask) {\n const appData = this.builder.getDataByAspect(component, ApplicationAspect.id);\n if (!appData) return undefined;\n return appData.buildDeployContexts;\n }\n const componentResults = buildTask?.componentsResults.find((res) =>\n res.component.id.isEqual(component.id, { ignoreVersion: true })\n );\n return componentResults?.metadata?.buildDeployContexts;\n }\n\n private getBuildTask(taskResults: TaskResults[], runtime: string) {\n return taskResults.find(\n ({ task, env }) => task.aspectId === ApplicationAspect.id && task.name === BUILD_TASK && env.id === runtime\n );\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAA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xD;EAEQJ,YAAYA,CAACmB,WAA0B,EAAEC,OAAe,EAAE;IAChE,OAAOD,WAAW,CAACd,IAAI,CACrB,CAAC;MAAEgB,IAAI;MAAEC;IAAI,CAAC,KAAKD,IAAI,CAACzB,QAAQ,KAAKhC,gCAAiB,CAACC,EAAE,IAAIwD,IAAI,CAACvB,IAAI,KAAKyB,8BAAU,IAAID,GAAG,CAACzD,EAAE,KAAKuD,OACtG,CAAC;EACH;AACF;AAAC7D,OAAA,CAAAC,UAAA,GAAAA,UAAA"}
|
package/dist/esm.d.mts
ADDED
package/dist/esm.mjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-unresolved
|
|
2
|
+
import cjsModule from './index.js';
|
|
3
|
+
|
|
4
|
+
export const AppContext = cjsModule.AppContext;
|
|
5
|
+
export const ApplicationAspect = cjsModule.ApplicationAspect;
|
|
6
|
+
export const APPS_ARTIFACTS_DIR_NAME = cjsModule.APPS_ARTIFACTS_DIR_NAME;
|
|
7
|
+
export const AppTypeList = cjsModule.AppTypeList;
|
|
8
|
+
|
|
9
|
+
export default cjsModule;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { ApplicationAspect } from './application.aspect';
|
|
2
|
+
export type { ApplicationInstance } from './app-instance';
|
|
2
3
|
export type { ApplicationMain, ApplicationMetadata } from './application.main.runtime';
|
|
3
|
-
export type { Application, DeployFn, AppResult } from './application';
|
|
4
|
+
export type { Application, DeployFn, BuildFn, AppResult } from './application';
|
|
4
5
|
export { AppContext } from './app-context';
|
|
5
6
|
export { DeploymentProvider } from './deployment-provider';
|
|
6
7
|
export { ApplicationType } from './application-type';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_application","data","require","_appContext","_deploymentProvider","_applicationType","_appDeployContext","_appBuildContext","_appBuildResult","_buildApplication","_appTypeList"],"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-application.task';\nexport type { AppsEnv } from './apps-env-type';\nexport { AppTypeList } from './app-type-list';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAAA,aAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,YAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;
|
|
1
|
+
{"version":3,"names":["_application","data","require","_appContext","_deploymentProvider","_applicationType","_appDeployContext","_appBuildContext","_appBuildResult","_buildApplication","_appTypeList"],"sources":["index.ts"],"sourcesContent":["export { ApplicationAspect } from './application.aspect';\nexport type { ApplicationInstance } from './app-instance';\nexport type { ApplicationMain, ApplicationMetadata } from './application.main.runtime';\nexport type { Application, DeployFn, BuildFn, 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-application.task';\nexport type { AppsEnv } from './apps-env-type';\nexport { AppTypeList } from './app-type-list';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAAA,aAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,YAAA,YAAAA,CAAA;IAAA,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import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_application@1.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_application@1.0.64/dist/application.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_application@1.0.64/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
|
@@ -7,6 +7,7 @@ declare type RunOptions = {
|
|
|
7
7
|
dev: boolean;
|
|
8
8
|
verbose: boolean;
|
|
9
9
|
skipWatch: boolean;
|
|
10
|
+
watch: boolean;
|
|
10
11
|
ssr: boolean;
|
|
11
12
|
port: string;
|
|
12
13
|
};
|
|
@@ -31,6 +32,6 @@ export declare class RunCmd implements Command {
|
|
|
31
32
|
* access to the extension instance.
|
|
32
33
|
*/
|
|
33
34
|
application: ApplicationMain, logger: Logger);
|
|
34
|
-
render([appName]: [string], { dev,
|
|
35
|
+
render([appName]: [string], { dev, watch, ssr, port: exactPort }: RunOptions): Promise<React.ReactElement | RenderResult>;
|
|
35
36
|
}
|
|
36
37
|
export {};
|
package/dist/run.cmd.js
CHANGED
|
@@ -46,21 +46,25 @@ class RunCmd {
|
|
|
46
46
|
}]);
|
|
47
47
|
_defineProperty(this, "alias", 'c');
|
|
48
48
|
_defineProperty(this, "group", 'apps');
|
|
49
|
-
_defineProperty(this, "options", [['d', 'dev', 'start the application in dev mode.'], ['p', 'port [port-number]', 'port to run the app on'], ['v', 'verbose', 'show verbose output for inspection and print stack trace'],
|
|
49
|
+
_defineProperty(this, "options", [['d', 'dev', 'start the application in dev mode.'], ['p', 'port [port-number]', 'port to run the app on'], ['v', 'verbose', 'show verbose output for inspection and print stack trace'],
|
|
50
|
+
// ['', 'skip-watch', 'avoid running the watch process that compiles components in the background'],
|
|
51
|
+
['w', 'watch', 'watch and compile your components upon changes']]);
|
|
50
52
|
}
|
|
51
53
|
async render([appName], {
|
|
52
54
|
dev,
|
|
53
|
-
|
|
55
|
+
watch,
|
|
54
56
|
ssr,
|
|
55
57
|
port: exactPort
|
|
56
58
|
}) {
|
|
57
59
|
// remove wds logs until refactoring webpack to a worker through the Worker aspect.
|
|
60
|
+
this.logger.off();
|
|
58
61
|
const {
|
|
59
62
|
port,
|
|
60
|
-
errors
|
|
63
|
+
errors,
|
|
64
|
+
isOldApi
|
|
61
65
|
} = await this.application.runApp(appName, {
|
|
62
66
|
dev,
|
|
63
|
-
watch
|
|
67
|
+
watch,
|
|
64
68
|
ssr,
|
|
65
69
|
port: +exactPort
|
|
66
70
|
});
|
|
@@ -72,10 +76,10 @@ class RunCmd {
|
|
|
72
76
|
})
|
|
73
77
|
};
|
|
74
78
|
}
|
|
75
|
-
if (
|
|
79
|
+
if (isOldApi) {
|
|
76
80
|
return /*#__PURE__*/_react().default.createElement(_ink().Text, null, appName, " app is running on http://localhost:", port);
|
|
77
81
|
}
|
|
78
|
-
return /*#__PURE__*/_react().default.createElement(
|
|
82
|
+
return /*#__PURE__*/_react().default.createElement(_react().default.Fragment, null);
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
85
|
exports.RunCmd = RunCmd;
|
package/dist/run.cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","data","_interopRequireDefault","require","_pluralize","_ink","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","RunCmd","constructor","application","logger","name","description","render","appName","dev","
|
|
1
|
+
{"version":3,"names":["_react","data","_interopRequireDefault","require","_pluralize","_ink","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","RunCmd","constructor","application","logger","name","description","render","appName","dev","watch","ssr","port","exactPort","off","errors","isOldApi","runApp","code","createElement","ShowErrors","Text","Fragment","exports","Newline","underline","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 watch: boolean;\n ssr: boolean;\n port: string;\n};\n\nexport class RunCmd implements Command {\n name = 'run <app-name>';\n description = \"locally run an app component (independent of bit's dev server)\";\n helpUrl = 'reference/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 to run the app on'],\n ['v', 'verbose', 'show verbose output for inspection and print stack trace'],\n // ['', 'skip-watch', 'avoid running the watch process that compiles components in the background'],\n ['w', 'watch', 'watch and compile your components upon changes']\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, watch, ssr, port: exactPort }: RunOptions\n ): Promise<React.ReactElement | RenderResult> {\n // remove wds logs until refactoring webpack to a worker through the Worker aspect.\n this.logger.off();\n const { port, errors, isOldApi } = await this.application.runApp(appName, {\n dev,\n watch,\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 (isOldApi) {\n return (\n <Text>\n {appName} app is running on http://localhost:{port}\n </Text>\n );\n }\n\n return <></>;\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,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,WAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,KAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,IAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAoC,SAAAC,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,gBAAAH,GAAA,EAAAI,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAJ,GAAA,IAAAO,MAAA,CAAAC,cAAA,CAAAR,GAAA,EAAAI,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAX,GAAA,CAAAI,GAAA,IAAAC,KAAA,WAAAL,GAAA;AAAA,SAAAM,eAAAM,GAAA,QAAAR,GAAA,GAAAS,YAAA,CAAAD,GAAA,2BAAAR,GAAA,gBAAAA,GAAA,GAAAU,MAAA,CAAAV,GAAA;AAAA,SAAAS,aAAAE,KAAA,EAAAC,IAAA,eAAAD,KAAA,iBAAAA,KAAA,kBA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
|
|
2
|
+
import cjsModule from './index.js';
|
|
3
|
+
|
|
4
|
+
export const AppContext = cjsModule.AppContext;
|
|
5
|
+
export const ApplicationAspect = cjsModule.ApplicationAspect;
|
|
6
|
+
export const APPS_ARTIFACTS_DIR_NAME = cjsModule.APPS_ARTIFACTS_DIR_NAME;
|
|
7
|
+
export const AppTypeList = cjsModule.AppTypeList;
|
|
8
|
+
|
|
9
|
+
export default cjsModule;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/application",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.64",
|
|
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": "1.0.
|
|
9
|
+
"version": "1.0.64"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
@@ -16,18 +16,18 @@
|
|
|
16
16
|
"pluralize": "8.0.0",
|
|
17
17
|
"core-js": "^3.0.0",
|
|
18
18
|
"@babel/runtime": "7.20.0",
|
|
19
|
-
"@teambit/bit-error": "0.0.404",
|
|
20
19
|
"@teambit/harmony": "0.4.6",
|
|
21
|
-
"@teambit/
|
|
22
|
-
"@teambit/
|
|
23
|
-
"@teambit/
|
|
24
|
-
"@teambit/
|
|
20
|
+
"@teambit/bit-error": "0.0.404",
|
|
21
|
+
"@teambit/builder": "1.0.64",
|
|
22
|
+
"@teambit/component": "1.0.64",
|
|
23
|
+
"@teambit/isolator": "1.0.64",
|
|
24
|
+
"@teambit/envs": "1.0.64",
|
|
25
|
+
"@teambit/logger": "0.0.915",
|
|
25
26
|
"@teambit/cli-table": "0.0.45",
|
|
26
27
|
"@teambit/cli": "0.0.822",
|
|
27
|
-
"@teambit/aspect-loader": "1.0.
|
|
28
|
-
"@teambit/
|
|
29
|
-
"@teambit/
|
|
30
|
-
"@teambit/workspace": "1.0.62"
|
|
28
|
+
"@teambit/aspect-loader": "1.0.64",
|
|
29
|
+
"@teambit/watcher": "1.0.64",
|
|
30
|
+
"@teambit/workspace": "1.0.64"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/react": "^17.0.8",
|
|
@@ -45,6 +45,13 @@
|
|
|
45
45
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
46
46
|
},
|
|
47
47
|
"license": "Apache-2.0",
|
|
48
|
+
"exports": {
|
|
49
|
+
"node": {
|
|
50
|
+
"require": "./dist/index.js",
|
|
51
|
+
"import": "./dist/esm.mjs"
|
|
52
|
+
},
|
|
53
|
+
"default": "./dist/index.js"
|
|
54
|
+
},
|
|
48
55
|
"private": false,
|
|
49
56
|
"engines": {
|
|
50
57
|
"node": ">=12.22.0"
|
package/run.cmd.tsx
CHANGED
|
@@ -10,6 +10,7 @@ type RunOptions = {
|
|
|
10
10
|
dev: boolean;
|
|
11
11
|
verbose: boolean;
|
|
12
12
|
skipWatch: boolean;
|
|
13
|
+
watch: boolean;
|
|
13
14
|
ssr: boolean;
|
|
14
15
|
port: string;
|
|
15
16
|
};
|
|
@@ -31,8 +32,8 @@ export class RunCmd implements Command {
|
|
|
31
32
|
['d', 'dev', 'start the application in dev mode.'],
|
|
32
33
|
['p', 'port [port-number]', 'port to run the app on'],
|
|
33
34
|
['v', 'verbose', 'show verbose output for inspection and print stack trace'],
|
|
34
|
-
['', 'skip-watch', 'avoid running the watch process that compiles components in the background'],
|
|
35
|
-
['', '
|
|
35
|
+
// ['', 'skip-watch', 'avoid running the watch process that compiles components in the background'],
|
|
36
|
+
['w', 'watch', 'watch and compile your components upon changes']
|
|
36
37
|
] as CommandOptions;
|
|
37
38
|
|
|
38
39
|
constructor(
|
|
@@ -46,12 +47,13 @@ export class RunCmd implements Command {
|
|
|
46
47
|
|
|
47
48
|
async render(
|
|
48
49
|
[appName]: [string],
|
|
49
|
-
{ dev,
|
|
50
|
+
{ dev, watch, ssr, port: exactPort }: RunOptions
|
|
50
51
|
): Promise<React.ReactElement | RenderResult> {
|
|
51
52
|
// remove wds logs until refactoring webpack to a worker through the Worker aspect.
|
|
52
|
-
|
|
53
|
+
this.logger.off();
|
|
54
|
+
const { port, errors, isOldApi } = await this.application.runApp(appName, {
|
|
53
55
|
dev,
|
|
54
|
-
watch
|
|
56
|
+
watch,
|
|
55
57
|
ssr,
|
|
56
58
|
port: +exactPort,
|
|
57
59
|
});
|
|
@@ -63,14 +65,15 @@ export class RunCmd implements Command {
|
|
|
63
65
|
};
|
|
64
66
|
}
|
|
65
67
|
|
|
66
|
-
if (
|
|
68
|
+
if (isOldApi) {
|
|
67
69
|
return (
|
|
68
70
|
<Text>
|
|
69
71
|
{appName} app is running on http://localhost:{port}
|
|
70
72
|
</Text>
|
|
71
73
|
);
|
|
72
74
|
}
|
|
73
|
-
|
|
75
|
+
|
|
76
|
+
return <></>;
|
|
74
77
|
}
|
|
75
78
|
}
|
|
76
79
|
|