@teambit/application 0.0.197 → 0.0.201
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/package.json +27 -12
- package/tsconfig.json +1 -1
- package/app-context.ts +0 -8
- package/app-list.cmd.tsx +0 -34
- package/app-server.ts +0 -9
- package/app-type.plugin.ts +0 -14
- package/app.cmd.ts +0 -44
- package/app.plugin.ts +0 -15
- package/application-type.ts +0 -13
- package/application.aspect.ts +0 -5
- package/application.main.runtime.ts +0 -203
- package/application.service.ts +0 -13
- package/application.ts +0 -32
- package/deploy-context.ts +0 -11
- package/deploy.task.ts +0 -49
- package/deployment-provider.ts +0 -5
- package/exceptions/app-not-found.ts +0 -5
- package/exceptions/index.ts +0 -1
- package/index.ts +0 -7
- package/package-tar/teambit-application-0.0.197.tgz +0 -0
- package/run.cmd.tsx +0 -55
- package/types/asset.d.ts +0 -29
- package/types/style.d.ts +0 -42
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/application",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.201",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/harmony/application",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.harmony",
|
|
8
8
|
"name": "application",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.201"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"ink": "3.0.8",
|
|
17
17
|
"@babel/runtime": "7.12.18",
|
|
18
18
|
"core-js": "^3.0.0",
|
|
19
|
-
"@teambit/envs": "0.0.
|
|
20
|
-
"@teambit/cli-table": "0.0.
|
|
21
|
-
"@teambit/cli": "0.0.
|
|
22
|
-
"@teambit/aspect-loader": "0.0.
|
|
23
|
-
"@teambit/builder": "0.0.
|
|
24
|
-
"@teambit/component": "0.0.
|
|
25
|
-
"@teambit/logger": "0.0.
|
|
26
|
-
"@teambit/isolator": "0.0.
|
|
19
|
+
"@teambit/envs": "0.0.559",
|
|
20
|
+
"@teambit/cli-table": "0.0.12",
|
|
21
|
+
"@teambit/cli": "0.0.389",
|
|
22
|
+
"@teambit/aspect-loader": "0.0.559",
|
|
23
|
+
"@teambit/builder": "0.0.559",
|
|
24
|
+
"@teambit/component": "0.0.559",
|
|
25
|
+
"@teambit/logger": "0.0.474",
|
|
26
|
+
"@teambit/isolator": "0.0.559"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/lodash": "4.14.165",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@types/node": "12.20.4"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@teambit/legacy": "1.0.
|
|
38
|
+
"@teambit/legacy": "1.0.175",
|
|
39
39
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
40
40
|
"react": "^16.8.0 || ^17.0.0"
|
|
41
41
|
},
|
|
@@ -63,12 +63,27 @@
|
|
|
63
63
|
"react": "-"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"@teambit/legacy": "1.0.
|
|
66
|
+
"@teambit/legacy": "1.0.175",
|
|
67
67
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
68
68
|
"react": "^16.8.0 || ^17.0.0"
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
|
+
"files": [
|
|
73
|
+
"dist",
|
|
74
|
+
"!dist/tsconfig.tsbuildinfo",
|
|
75
|
+
"**/*.md",
|
|
76
|
+
"**/*.mdx",
|
|
77
|
+
"**/*.js",
|
|
78
|
+
"**/*.json",
|
|
79
|
+
"**/*.sass",
|
|
80
|
+
"**/*.scss",
|
|
81
|
+
"**/*.less",
|
|
82
|
+
"**/*.css",
|
|
83
|
+
"**/*.css",
|
|
84
|
+
"**/*.jpeg",
|
|
85
|
+
"**/*.gif"
|
|
86
|
+
],
|
|
72
87
|
"private": false,
|
|
73
88
|
"engines": {
|
|
74
89
|
"node": ">=12.22.0"
|
package/tsconfig.json
CHANGED
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"skipLibCheck": true,
|
|
16
16
|
"moduleResolution": "node",
|
|
17
17
|
"esModuleInterop": true,
|
|
18
|
-
"outDir": "dist",
|
|
19
18
|
"composite": true,
|
|
20
19
|
"emitDeclarationOnly": true,
|
|
20
|
+
"outDir": "dist",
|
|
21
21
|
"experimentalDecorators": true,
|
|
22
22
|
"emitDecoratorMetadata": true,
|
|
23
23
|
"allowSyntheticDefaultImports": true,
|
package/app-context.ts
DELETED
package/app-list.cmd.tsx
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Command, CommandOptions } from '@teambit/cli';
|
|
2
|
-
// import { Logger } from '@teambit/logger';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import { CLITable } from '@teambit/cli-table';
|
|
5
|
-
import { ApplicationMain } from './application.main.runtime';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated use AppListCmd class
|
|
9
|
-
*/
|
|
10
|
-
export class AppListCmdDeprecated implements Command {
|
|
11
|
-
name = 'app-list';
|
|
12
|
-
description = 'DEPRECATED. use "bit app list"';
|
|
13
|
-
alias = '';
|
|
14
|
-
group = 'apps';
|
|
15
|
-
options = [['j', 'json', 'return the component data in json format']] as CommandOptions;
|
|
16
|
-
|
|
17
|
-
constructor(private applicationAspect: ApplicationMain) {}
|
|
18
|
-
|
|
19
|
-
async report(args: [string], { json }: { json: boolean }) {
|
|
20
|
-
const apps = this.applicationAspect.listApps();
|
|
21
|
-
if (json) return JSON.stringify(apps, null, 2);
|
|
22
|
-
const deprecationStr = `this command is deprecated. please use "bit app list" instead\n`;
|
|
23
|
-
// eslint-disable-next-line no-console
|
|
24
|
-
console.log(chalk.red());
|
|
25
|
-
if (!apps.length) return chalk.yellow(`${deprecationStr}no apps found`);
|
|
26
|
-
|
|
27
|
-
const rows = apps.map((app) => {
|
|
28
|
-
return [app.name];
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const table = new CLITable([], rows);
|
|
32
|
-
return deprecationStr + table.render();
|
|
33
|
-
}
|
|
34
|
-
}
|
package/app-server.ts
DELETED
package/app-type.plugin.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { PluginDefinition } from '@teambit/aspect-loader';
|
|
2
|
-
import { MainRuntime } from '@teambit/cli';
|
|
3
|
-
import { ApplicationType } from './application-type';
|
|
4
|
-
import { ApplicationSlot } from './application.main.runtime';
|
|
5
|
-
|
|
6
|
-
export class AppTypePlugin implements PluginDefinition {
|
|
7
|
-
constructor(readonly pattern: string, private appType: ApplicationType<unknown>, private appSlot: ApplicationSlot) {}
|
|
8
|
-
|
|
9
|
-
runtimes = [MainRuntime.name];
|
|
10
|
-
|
|
11
|
-
register(object: any) {
|
|
12
|
-
this.appSlot.register([this.appType.createApp(object)]);
|
|
13
|
-
}
|
|
14
|
-
}
|
package/app.cmd.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line max-classes-per-file
|
|
2
|
-
import { Command, CommandOptions } from '@teambit/cli';
|
|
3
|
-
// import { Logger } from '@teambit/logger';
|
|
4
|
-
import chalk from 'chalk';
|
|
5
|
-
import { CLITable } from '@teambit/cli-table';
|
|
6
|
-
import { ApplicationMain } from './application.main.runtime';
|
|
7
|
-
|
|
8
|
-
export class AppListCmd implements Command {
|
|
9
|
-
name = 'list';
|
|
10
|
-
description = 'list all registered applications';
|
|
11
|
-
alias = '';
|
|
12
|
-
group = 'apps';
|
|
13
|
-
options = [['j', 'json', 'return the component data in json format']] as CommandOptions;
|
|
14
|
-
|
|
15
|
-
constructor(private applicationAspect: ApplicationMain) {}
|
|
16
|
-
|
|
17
|
-
async report(args: [string], { json }: { json: boolean }) {
|
|
18
|
-
const apps = this.applicationAspect.listApps();
|
|
19
|
-
if (json) return JSON.stringify(apps, null, 2);
|
|
20
|
-
if (!apps.length) return chalk.yellow('no apps found');
|
|
21
|
-
|
|
22
|
-
const rows = apps.map((app) => {
|
|
23
|
-
return [app.name];
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const table = new CLITable([], rows);
|
|
27
|
-
return table.render();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export class AppCmd implements Command {
|
|
32
|
-
name = 'app <sub-command>';
|
|
33
|
-
description = 'manage applications';
|
|
34
|
-
alias = '';
|
|
35
|
-
group = 'apps';
|
|
36
|
-
commands: Command[] = [];
|
|
37
|
-
options = [] as CommandOptions;
|
|
38
|
-
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
40
|
-
async report(args: [string]) {
|
|
41
|
-
// it should never be here. Yargs throws an error before reaching this method.
|
|
42
|
-
return `Please specify a sub-command`;
|
|
43
|
-
}
|
|
44
|
-
}
|
package/app.plugin.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { PluginDefinition } from '@teambit/aspect-loader';
|
|
2
|
-
import { MainRuntime } from '@teambit/cli';
|
|
3
|
-
import { ApplicationSlot } from './application.main.runtime';
|
|
4
|
-
|
|
5
|
-
export class AppPlugin implements PluginDefinition {
|
|
6
|
-
constructor(private appSlot: ApplicationSlot) {}
|
|
7
|
-
|
|
8
|
-
pattern = '*.app.*';
|
|
9
|
-
|
|
10
|
-
runtimes = [MainRuntime.name];
|
|
11
|
-
|
|
12
|
-
register(object: any) {
|
|
13
|
-
return this.appSlot.register([object]);
|
|
14
|
-
}
|
|
15
|
-
}
|
package/application-type.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Application } from './application';
|
|
2
|
-
|
|
3
|
-
export interface ApplicationType<T> {
|
|
4
|
-
/**
|
|
5
|
-
* name of the type of the app. e.g. `react-app`
|
|
6
|
-
*/
|
|
7
|
-
name: string;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* a function that creates the app instance.
|
|
11
|
-
*/
|
|
12
|
-
createApp(options: T): Application;
|
|
13
|
-
}
|
package/application.aspect.ts
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { MainRuntime, CLIMain, CLIAspect } from '@teambit/cli';
|
|
2
|
-
import { flatten } from 'lodash';
|
|
3
|
-
import { AspectLoaderMain, AspectLoaderAspect } from '@teambit/aspect-loader';
|
|
4
|
-
import { Slot, SlotRegistry } from '@teambit/harmony';
|
|
5
|
-
import { BuilderAspect, BuilderMain } from '@teambit/builder';
|
|
6
|
-
import { LoggerAspect, LoggerMain } from '@teambit/logger';
|
|
7
|
-
import { EnvsAspect, EnvsMain } from '@teambit/envs';
|
|
8
|
-
import ComponentAspect, { ComponentMain, ComponentID } from '@teambit/component';
|
|
9
|
-
import { ApplicationType } from './application-type';
|
|
10
|
-
import { Application } from './application';
|
|
11
|
-
import { DeploymentProvider } from './deployment-provider';
|
|
12
|
-
import { AppNotFound } from './exceptions';
|
|
13
|
-
import { ApplicationAspect } from './application.aspect';
|
|
14
|
-
import { AppListCmdDeprecated } from './app-list.cmd';
|
|
15
|
-
import { DeployTask } from './deploy.task';
|
|
16
|
-
import { RunCmd } from './run.cmd';
|
|
17
|
-
import { AppService } from './application.service';
|
|
18
|
-
import { AppCmd, AppListCmd } from './app.cmd';
|
|
19
|
-
import { AppPlugin } from './app.plugin';
|
|
20
|
-
import { AppTypePlugin } from './app-type.plugin';
|
|
21
|
-
|
|
22
|
-
export type ApplicationTypeSlot = SlotRegistry<ApplicationType<unknown>[]>;
|
|
23
|
-
export type ApplicationSlot = SlotRegistry<Application[]>;
|
|
24
|
-
export type DeploymentProviderSlot = SlotRegistry<DeploymentProvider[]>;
|
|
25
|
-
|
|
26
|
-
export type ApplicationAspectConfig = {};
|
|
27
|
-
|
|
28
|
-
export type ServeAppOptions = {
|
|
29
|
-
/**
|
|
30
|
-
* default port range used to serve applications.
|
|
31
|
-
*/
|
|
32
|
-
defaultPortRange?: number[];
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* determine whether to start the application in dev mode.
|
|
36
|
-
*/
|
|
37
|
-
dev: boolean;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export class ApplicationMain {
|
|
41
|
-
constructor(
|
|
42
|
-
private appSlot: ApplicationSlot,
|
|
43
|
-
private appTypeSlot: ApplicationTypeSlot,
|
|
44
|
-
private deploymentProviderSlot: DeploymentProviderSlot,
|
|
45
|
-
private envs: EnvsMain,
|
|
46
|
-
private componentAspect: ComponentMain,
|
|
47
|
-
private appService: AppService,
|
|
48
|
-
private aspectLoader: AspectLoaderMain
|
|
49
|
-
) {}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* register a new app.
|
|
53
|
-
*/
|
|
54
|
-
registerApp(app: Application) {
|
|
55
|
-
this.appSlot.register([app]);
|
|
56
|
-
return this;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* list all registered apps.
|
|
61
|
-
*/
|
|
62
|
-
listApps(): Application[] {
|
|
63
|
-
return flatten(this.appSlot.values());
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* register new deployment provider like netlify, cloudflare pages or custom deployment.
|
|
68
|
-
*/
|
|
69
|
-
registerDeploymentProvider(provider: DeploymentProvider) {
|
|
70
|
-
this.deploymentProviderSlot.register([provider]);
|
|
71
|
-
return this;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* list all deployment providers
|
|
76
|
-
*/
|
|
77
|
-
listProviders() {
|
|
78
|
-
return flatten(this.deploymentProviderSlot.values());
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* get an app.
|
|
83
|
-
*/
|
|
84
|
-
getApp(appName: string): Application | undefined {
|
|
85
|
-
const apps = this.listApps();
|
|
86
|
-
return apps.find((app) => app.name === appName);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* registers a new app and sets a plugin for it.
|
|
91
|
-
*/
|
|
92
|
-
registerAppType<T>(appType: ApplicationType<T>) {
|
|
93
|
-
const plugin = new AppTypePlugin(`*.${appType.name}.*`, appType, this.appSlot);
|
|
94
|
-
this.aspectLoader.registerPlugins([plugin]);
|
|
95
|
-
this.appTypeSlot.register([appType]);
|
|
96
|
-
return this;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* get an app AspectId.
|
|
101
|
-
*/
|
|
102
|
-
getAppAspect(appName: string): string | undefined {
|
|
103
|
-
return this.appSlot.toArray().find(([, apps]) => apps.find((app) => app.name === appName))?.[0];
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* get app to throw.
|
|
108
|
-
*/
|
|
109
|
-
getAppOrThrow(appName: string) {
|
|
110
|
-
const app = this.getApp(appName);
|
|
111
|
-
if (!app) throw new AppNotFound(appName);
|
|
112
|
-
return app;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
private computeOptions(opts: Partial<ServeAppOptions>) {
|
|
116
|
-
const defaultOpts: ServeAppOptions = {
|
|
117
|
-
dev: false,
|
|
118
|
-
defaultPortRange: [3100, 3500],
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
defaultOpts,
|
|
123
|
-
...opts,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
async runApp(appName: string, options: Partial<ServeAppOptions> = {}) {
|
|
128
|
-
const app = this.getAppOrThrow(appName);
|
|
129
|
-
this.computeOptions(options);
|
|
130
|
-
const context = await this.createAppContext(appName);
|
|
131
|
-
if (!context) throw new AppNotFound(appName);
|
|
132
|
-
const port = await app.run(context);
|
|
133
|
-
return { app, port };
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* get the component ID of a certain app.
|
|
138
|
-
*/
|
|
139
|
-
getAppIdOrThrow(appName: string) {
|
|
140
|
-
const maybeApp = this.appSlot.toArray().find(([, apps]) => {
|
|
141
|
-
return apps.find((app) => app.name === appName);
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
if (!maybeApp) throw new AppNotFound(appName);
|
|
145
|
-
return ComponentID.fromString(maybeApp[0]);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
private async createAppContext(appName: string) {
|
|
149
|
-
const host = this.componentAspect.getHost();
|
|
150
|
-
const components = await host.list();
|
|
151
|
-
const id = this.getAppIdOrThrow(appName);
|
|
152
|
-
const component = components.find((c) => c.id.isEqual(id));
|
|
153
|
-
if (!component) throw new AppNotFound(appName);
|
|
154
|
-
|
|
155
|
-
const env = await this.envs.createEnvironment([component]);
|
|
156
|
-
const res = await env.run(this.appService);
|
|
157
|
-
return res.results[0].data;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
static runtime = MainRuntime;
|
|
161
|
-
static dependencies = [CLIAspect, LoggerAspect, BuilderAspect, EnvsAspect, ComponentAspect, AspectLoaderAspect];
|
|
162
|
-
|
|
163
|
-
static slots = [
|
|
164
|
-
Slot.withType<ApplicationType<unknown>[]>(),
|
|
165
|
-
Slot.withType<Application[]>(),
|
|
166
|
-
Slot.withType<DeploymentProvider[]>(),
|
|
167
|
-
];
|
|
168
|
-
|
|
169
|
-
static async provider(
|
|
170
|
-
[cli, loggerAspect, builder, envs, component, aspectLoader]: [
|
|
171
|
-
CLIMain,
|
|
172
|
-
LoggerMain,
|
|
173
|
-
BuilderMain,
|
|
174
|
-
EnvsMain,
|
|
175
|
-
ComponentMain,
|
|
176
|
-
AspectLoaderMain
|
|
177
|
-
],
|
|
178
|
-
config: ApplicationAspectConfig,
|
|
179
|
-
[appTypeSlot, appSlot, deploymentProviderSlot]: [ApplicationTypeSlot, ApplicationSlot, DeploymentProviderSlot]
|
|
180
|
-
) {
|
|
181
|
-
const logger = loggerAspect.createLogger(ApplicationAspect.id);
|
|
182
|
-
const appService = new AppService();
|
|
183
|
-
const application = new ApplicationMain(
|
|
184
|
-
appSlot,
|
|
185
|
-
appTypeSlot,
|
|
186
|
-
deploymentProviderSlot,
|
|
187
|
-
envs,
|
|
188
|
-
component,
|
|
189
|
-
appService,
|
|
190
|
-
aspectLoader
|
|
191
|
-
);
|
|
192
|
-
const appCmd = new AppCmd();
|
|
193
|
-
appCmd.commands = [new AppListCmd(application)];
|
|
194
|
-
aspectLoader.registerPlugins([new AppPlugin(appSlot)]);
|
|
195
|
-
builder.registerTagTasks([new DeployTask(application)]);
|
|
196
|
-
cli.registerGroup('apps', 'Applications');
|
|
197
|
-
cli.register(new RunCmd(application, logger), new AppListCmdDeprecated(application), appCmd);
|
|
198
|
-
|
|
199
|
-
return application;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
ApplicationAspect.addRuntime(ApplicationMain);
|
package/application.service.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { EnvService, ExecutionContext } from '@teambit/envs';
|
|
2
|
-
|
|
3
|
-
export class AppService implements EnvService<any> {
|
|
4
|
-
name = 'app';
|
|
5
|
-
|
|
6
|
-
async run(context: ExecutionContext) {
|
|
7
|
-
const appContext = Object.assign(context, {
|
|
8
|
-
dev: true,
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
return appContext;
|
|
12
|
-
}
|
|
13
|
-
}
|
package/application.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { BuildContext } from '@teambit/builder';
|
|
2
|
-
import { Capsule } from '@teambit/isolator';
|
|
3
|
-
import { AppContext } from './app-context';
|
|
4
|
-
import { DeployContext } from './deploy-context';
|
|
5
|
-
|
|
6
|
-
export interface Application {
|
|
7
|
-
/**
|
|
8
|
-
* name of the application. e.g. ripple-ci.
|
|
9
|
-
*/
|
|
10
|
-
name: string;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* run the application.
|
|
14
|
-
*/
|
|
15
|
-
run(context: AppContext): Promise<number>;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* build the application.
|
|
19
|
-
*/
|
|
20
|
-
build(context: BuildContext, aspectId: string, capsule: Capsule): Promise<DeployContext>;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* application deployment. this is a build task.
|
|
24
|
-
*/
|
|
25
|
-
deploy?(context: BuildContext): Promise<void>;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* prerender routes of application (will create static file for the route)
|
|
29
|
-
* e.g ['/plugins', '/learn', '/docs/quick-start]
|
|
30
|
-
*/
|
|
31
|
-
prerenderRoutes?: string[];
|
|
32
|
-
}
|
package/deploy-context.ts
DELETED
package/deploy.task.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import mapSeries from 'p-map-series';
|
|
2
|
-
import { Capsule } from '@teambit/isolator';
|
|
3
|
-
import { BuildTask, BuiltTaskResult, BuildContext, ComponentResult } from '@teambit/builder';
|
|
4
|
-
import { ComponentID } from '@teambit/component';
|
|
5
|
-
import { ApplicationAspect } from './application.aspect';
|
|
6
|
-
import { ApplicationMain } from './application.main.runtime';
|
|
7
|
-
import { DeployContext } from './deploy-context';
|
|
8
|
-
|
|
9
|
-
export const BUILD_UI_TASK = 'build_ui_application';
|
|
10
|
-
|
|
11
|
-
export class DeployTask implements BuildTask {
|
|
12
|
-
name = BUILD_UI_TASK;
|
|
13
|
-
aspectId = ApplicationAspect.id;
|
|
14
|
-
|
|
15
|
-
constructor(private application: ApplicationMain) {}
|
|
16
|
-
|
|
17
|
-
async execute(context: BuildContext): Promise<BuiltTaskResult> {
|
|
18
|
-
const apps = this.application.listApps();
|
|
19
|
-
const componentsResultsUi = await mapSeries(
|
|
20
|
-
apps,
|
|
21
|
-
async (app): Promise<ComponentResult | undefined> => {
|
|
22
|
-
const aspectId = this.application.getAppAspect(app.name);
|
|
23
|
-
if (!aspectId) return undefined;
|
|
24
|
-
const capsules = context.capsuleNetwork.seedersCapsules;
|
|
25
|
-
const capsule = this.getCapsule(capsules, aspectId);
|
|
26
|
-
if (!capsule) return undefined;
|
|
27
|
-
const deployContext = await app.build(context, aspectId, capsule);
|
|
28
|
-
if (!deployContext.publicDir) return undefined;
|
|
29
|
-
if (app.deploy) await app.deploy(deployContext);
|
|
30
|
-
await this.deployToProviders(deployContext);
|
|
31
|
-
return { component: capsule.component, metadata: { publicDir: deployContext.publicDir } };
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
componentsResults: componentsResultsUi.flatMap((f) => (f ? [f] : [])),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
private getCapsule(capsules: Capsule[], aspectId: string) {
|
|
41
|
-
const aspectCapsuleId = ComponentID.fromString(aspectId).toStringWithoutVersion();
|
|
42
|
-
return capsules.find((capsule) => capsule.component.id.toStringWithoutVersion() === aspectCapsuleId);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
private async deployToProviders(deployContext: DeployContext) {
|
|
46
|
-
const providers = this.application.listProviders();
|
|
47
|
-
await mapSeries(providers, async (provider) => provider.deploy(deployContext));
|
|
48
|
-
}
|
|
49
|
-
}
|
package/deployment-provider.ts
DELETED
package/exceptions/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { AppNotFound } from './app-not-found';
|
package/index.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { ApplicationAspect } from './application.aspect';
|
|
2
|
-
export type { ApplicationMain } from './application.main.runtime';
|
|
3
|
-
export type { Application } from './application';
|
|
4
|
-
export { AppContext } from './app-context';
|
|
5
|
-
export { DeploymentProvider } from './deployment-provider';
|
|
6
|
-
export { ApplicationType } from './application-type';
|
|
7
|
-
export { DeployContext } from './deploy-context';
|
|
Binary file
|
package/run.cmd.tsx
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Command, CommandOptions } from '@teambit/cli';
|
|
3
|
-
import { Text } from 'ink';
|
|
4
|
-
import { Logger } from '@teambit/logger';
|
|
5
|
-
import { ApplicationMain } from './application.main.runtime';
|
|
6
|
-
|
|
7
|
-
export class RunCmd implements Command {
|
|
8
|
-
name = 'run <app>';
|
|
9
|
-
description = 'run an application';
|
|
10
|
-
alias = 'c';
|
|
11
|
-
group = 'apps';
|
|
12
|
-
options = [
|
|
13
|
-
['d', 'dev', 'start the application in dev mode.'],
|
|
14
|
-
['v', 'verbose', 'showing verbose output for inspection and prints stack trace'],
|
|
15
|
-
] as CommandOptions;
|
|
16
|
-
|
|
17
|
-
constructor(
|
|
18
|
-
/**
|
|
19
|
-
* access to the extension instance.
|
|
20
|
-
*/
|
|
21
|
-
private application: ApplicationMain,
|
|
22
|
-
|
|
23
|
-
private logger: Logger
|
|
24
|
-
) {}
|
|
25
|
-
|
|
26
|
-
async report(
|
|
27
|
-
[appName]: [string],
|
|
28
|
-
{ dev }: { dev: boolean; port: string; rebuild: boolean; verbose: boolean; suppressBrowserLaunch: boolean }
|
|
29
|
-
): Promise<string> {
|
|
30
|
-
this.logger.off();
|
|
31
|
-
|
|
32
|
-
const { port } = await this.application.runApp(appName, {
|
|
33
|
-
dev,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
return `${appName} app is running on http://localhost:${port}`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async render(
|
|
40
|
-
[appName]: [string],
|
|
41
|
-
{ dev }: { dev: boolean; rebuild: boolean; verbose: boolean; suppressBrowserLaunch: boolean }
|
|
42
|
-
): Promise<React.ReactElement> {
|
|
43
|
-
// remove wds logs until refactoring webpack to a worker through the Worker aspect.
|
|
44
|
-
const { port } = await this.application.runApp(appName, {
|
|
45
|
-
dev,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<Text>
|
|
50
|
-
{appName} app is running on http://localhost:{port}
|
|
51
|
-
</Text>
|
|
52
|
-
);
|
|
53
|
-
// return <UIServerConsole appName={appName} futureUiServer={uiServer} />;
|
|
54
|
-
}
|
|
55
|
-
}
|
package/types/asset.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
declare module '*.png' {
|
|
2
|
-
const value: any;
|
|
3
|
-
export = value;
|
|
4
|
-
}
|
|
5
|
-
declare module '*.svg' {
|
|
6
|
-
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
-
|
|
8
|
-
export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
|
|
9
|
-
const src: string;
|
|
10
|
-
export default src;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// @TODO Gilad
|
|
14
|
-
declare module '*.jpg' {
|
|
15
|
-
const value: any;
|
|
16
|
-
export = value;
|
|
17
|
-
}
|
|
18
|
-
declare module '*.jpeg' {
|
|
19
|
-
const value: any;
|
|
20
|
-
export = value;
|
|
21
|
-
}
|
|
22
|
-
declare module '*.gif' {
|
|
23
|
-
const value: any;
|
|
24
|
-
export = value;
|
|
25
|
-
}
|
|
26
|
-
declare module '*.bmp' {
|
|
27
|
-
const value: any;
|
|
28
|
-
export = value;
|
|
29
|
-
}
|
package/types/style.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
declare module '*.module.css' {
|
|
2
|
-
const classes: { readonly [key: string]: string };
|
|
3
|
-
export default classes;
|
|
4
|
-
}
|
|
5
|
-
declare module '*.module.scss' {
|
|
6
|
-
const classes: { readonly [key: string]: string };
|
|
7
|
-
export default classes;
|
|
8
|
-
}
|
|
9
|
-
declare module '*.module.sass' {
|
|
10
|
-
const classes: { readonly [key: string]: string };
|
|
11
|
-
export default classes;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
declare module '*.module.less' {
|
|
15
|
-
const classes: { readonly [key: string]: string };
|
|
16
|
-
export default classes;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
declare module '*.less' {
|
|
20
|
-
const classes: { readonly [key: string]: string };
|
|
21
|
-
export default classes;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
declare module '*.css' {
|
|
25
|
-
const classes: { readonly [key: string]: string };
|
|
26
|
-
export default classes;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
declare module '*.sass' {
|
|
30
|
-
const classes: { readonly [key: string]: string };
|
|
31
|
-
export default classes;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
declare module '*.scss' {
|
|
35
|
-
const classes: { readonly [key: string]: string };
|
|
36
|
-
export default classes;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
declare module '*.mdx' {
|
|
40
|
-
const component: any;
|
|
41
|
-
export default component;
|
|
42
|
-
}
|