@teambit/node 1.0.219 → 1.0.221
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/{preview-1712174136349.js → preview-1712287228511.js} +2 -2
- package/index.ts +6 -0
- package/node-app-options.ts +46 -0
- package/node.app-type.ts +21 -0
- package/node.application.ts +59 -0
- package/node.aspect.ts +9 -0
- package/node.env.ts +80 -0
- package/node.main.runtime.ts +190 -0
- package/node.templates.ts +29 -0
- package/package.json +19 -19
- package/artifacts/env-template/public/310.8db029366a3258c07bf7.js +0 -998
- package/artifacts/env-template/public/359.0a1f1ff12be5124a0f7c.js +0 -255
- package/artifacts/env-template/public/700.f5fce5db582bd65bc0df.js +0 -216
- package/artifacts/env-template/public/851.d2664a57f5d46b636e5f.js +0 -41
- package/artifacts/env-template/public/assets-manifest.json +0 -58
- package/artifacts/env-template/public/compositions.80e27e53f2fff80d5d85.js +0 -17
- package/artifacts/env-template/public/compositions.html +0 -2
- package/artifacts/env-template/public/overview.9d4e394d0a8637ad9c78.js +0 -5
- package/artifacts/env-template/public/overview.html +0 -2
- package/artifacts/env-template/public/peers.b2cb9b2cfc8ffa2fc062.js +0 -1
- package/artifacts/env-template/public/preview-root.93da260e5cd4522c90ed.js +0 -1
- package/artifacts/env-template/public/static/css/310.cdd78dee.css +0 -1
- package/artifacts/env-template/public/static/css/compositions.2a7f63f9.css +0 -1
- package/artifacts/env-template/public/static/css/preview-root.5fd7d59d.css +0 -1
- /package/{compositions-1712174136349.js → compositions-1712287228511.js} +0 -0
- /package/{overview-1712174136349.js → overview-1712287228511.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_node@1.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_node@1.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_node@1.0.221/dist/node.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_node@1.0.221/dist/node.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
package/index.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import jestConfig from './jest/jest.config';
|
|
2
|
+
|
|
3
|
+
export { jestConfig };
|
|
4
|
+
export type { NodeMain } from './node.main.runtime';
|
|
5
|
+
export type { NodeAppOptions, DeployContext } from './node-app-options';
|
|
6
|
+
export { NodeAspect, NodeAspect as default } from './node.aspect';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { DeployFn, AppBuildResult } from '@teambit/application';
|
|
2
|
+
|
|
3
|
+
export interface DeployContext extends AppBuildResult {
|
|
4
|
+
metadata: NodeAppMetadata;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @todo: remove this. it's already part of `metadata`.
|
|
8
|
+
* it's here only for backward compatibility.
|
|
9
|
+
*/
|
|
10
|
+
mainFile?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface NodeAppMetadata {
|
|
14
|
+
/**
|
|
15
|
+
* the main file of the app e.g: dist/app.js
|
|
16
|
+
*/
|
|
17
|
+
mainFile: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* the directory where the artifacts are saved.
|
|
21
|
+
*/
|
|
22
|
+
artifactsDir: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type NodeAppOptions = {
|
|
26
|
+
/**
|
|
27
|
+
* name of the application.
|
|
28
|
+
*/
|
|
29
|
+
name: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* path to entry file of the application.
|
|
33
|
+
* e.g: '/index.js'
|
|
34
|
+
*/
|
|
35
|
+
entry: string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* ranges of ports to use to run the app server.
|
|
39
|
+
*/
|
|
40
|
+
portRange?: number[];
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* deploy function.
|
|
44
|
+
*/
|
|
45
|
+
deploy?: DeployFn;
|
|
46
|
+
};
|
package/node.app-type.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Logger } from '@teambit/logger';
|
|
2
|
+
import { ApplicationType } from '@teambit/application';
|
|
3
|
+
import { ReactEnv } from '@teambit/react';
|
|
4
|
+
import { NodeEnv } from './node.env';
|
|
5
|
+
import { NodeApp } from './node.application';
|
|
6
|
+
import type { NodeAppOptions } from './node-app-options';
|
|
7
|
+
|
|
8
|
+
export class NodeAppType implements ApplicationType<NodeAppOptions> {
|
|
9
|
+
constructor(readonly name: string, private nodeEnv: NodeEnv & ReactEnv, private logger: Logger) {}
|
|
10
|
+
|
|
11
|
+
createApp(options: NodeAppOptions) {
|
|
12
|
+
return new NodeApp(
|
|
13
|
+
options.name,
|
|
14
|
+
options.entry,
|
|
15
|
+
options.portRange || [3000, 4000],
|
|
16
|
+
this.nodeEnv,
|
|
17
|
+
this.logger,
|
|
18
|
+
options.deploy
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { execFile } from 'child_process';
|
|
2
|
+
import { parse, join } from 'path';
|
|
3
|
+
import { Logger } from '@teambit/logger';
|
|
4
|
+
import { ReactEnv } from '@teambit/react';
|
|
5
|
+
import { Application, DeployFn, AppBuildContext, AppContext, ApplicationInstance } from '@teambit/application';
|
|
6
|
+
import { Port } from '@teambit/toolbox.network.get-port';
|
|
7
|
+
import { NodeEnv } from './node.env';
|
|
8
|
+
import { DeployContext, NodeAppMetadata } from './node-app-options';
|
|
9
|
+
|
|
10
|
+
export class NodeApp implements Application {
|
|
11
|
+
constructor(
|
|
12
|
+
readonly name: string,
|
|
13
|
+
readonly entry: string,
|
|
14
|
+
readonly portRange: number[],
|
|
15
|
+
readonly nodeEnv: NodeEnv & ReactEnv,
|
|
16
|
+
readonly logger: Logger,
|
|
17
|
+
readonly deploy?: DeployFn
|
|
18
|
+
) {}
|
|
19
|
+
|
|
20
|
+
applicationType = 'node';
|
|
21
|
+
|
|
22
|
+
async run(context: AppContext): Promise<ApplicationInstance> {
|
|
23
|
+
const logger = this.logger;
|
|
24
|
+
const [from, to] = this.portRange;
|
|
25
|
+
const port = context.port || (await Port.getPort(from, to));
|
|
26
|
+
const child = execFile('node', [this.entry, port.toString()], (error) => {
|
|
27
|
+
if (error) {
|
|
28
|
+
// @todo: this is causing uncaughtException in the main process. a better way to handle this would be to use promise.
|
|
29
|
+
// however, since it expects to return a number, it would require a bigger refactor.
|
|
30
|
+
throw error as Error;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
child.stdout?.on('data', function (data) {
|
|
34
|
+
logger.console(data.toString());
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
this.logger.console(`${context.appName} is listening on http://localhost:${port}`);
|
|
38
|
+
return {
|
|
39
|
+
appName: context.appName,
|
|
40
|
+
port,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async build(context: AppBuildContext): Promise<DeployContext> {
|
|
45
|
+
const { base } = parse(this.entry);
|
|
46
|
+
const { distDir } = this.nodeEnv.getCompiler();
|
|
47
|
+
const mainFile = join(distDir, base);
|
|
48
|
+
const metadata: NodeAppMetadata = {
|
|
49
|
+
mainFile,
|
|
50
|
+
artifactsDir: context.artifactsDir,
|
|
51
|
+
};
|
|
52
|
+
const deployContext: DeployContext = {
|
|
53
|
+
...context, // @todo: is this needed?
|
|
54
|
+
mainFile, // @todo: remove this when possible. only metadata should be used.
|
|
55
|
+
metadata,
|
|
56
|
+
};
|
|
57
|
+
return deployContext;
|
|
58
|
+
}
|
|
59
|
+
}
|
package/node.aspect.ts
ADDED
package/node.env.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { DependenciesEnv, PackageEnv, PipeServiceModifier, PipeServiceModifiersMap } from '@teambit/envs';
|
|
2
|
+
import { VariantPolicyConfigObject } from '@teambit/dependency-resolver';
|
|
3
|
+
import { TsConfigTransformer, TypescriptMain } from '@teambit/typescript';
|
|
4
|
+
import { ReactMain } from '@teambit/react';
|
|
5
|
+
import { Tester } from '@teambit/tester';
|
|
6
|
+
import { BuildTask } from '@teambit/builder';
|
|
7
|
+
import { COMPONENT_PREVIEW_STRATEGY_NAME, PreviewStrategyName } from '@teambit/preview';
|
|
8
|
+
import { SchemaExtractor } from '@teambit/schema';
|
|
9
|
+
import { TsConfigSourceFile } from 'typescript';
|
|
10
|
+
|
|
11
|
+
export const NodeEnvType = 'node';
|
|
12
|
+
|
|
13
|
+
type GetBuildPipeModifiers = PipeServiceModifiersMap & {
|
|
14
|
+
tsModifier?: PipeServiceModifier;
|
|
15
|
+
};
|
|
16
|
+
export class NodeEnv implements DependenciesEnv, PackageEnv {
|
|
17
|
+
constructor(protected tsAspect: TypescriptMain, protected reactAspect: ReactMain) {}
|
|
18
|
+
|
|
19
|
+
icon = 'https://static.bit.dev/extensions-icons/nodejs.svg';
|
|
20
|
+
|
|
21
|
+
getDependencies(): VariantPolicyConfigObject {
|
|
22
|
+
return {
|
|
23
|
+
devDependencies: {
|
|
24
|
+
'@types/jest': '26.0.20',
|
|
25
|
+
'@types/node': '12.20.4',
|
|
26
|
+
// This is added as dev dep since our jest file transformer uses babel plugins that require this to be installed
|
|
27
|
+
'@babel/runtime': '7.20.0',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getCompiler(transformers: TsConfigTransformer[] = [], tsModule) {
|
|
33
|
+
return this.reactAspect.reactEnv.getTsCjsCompiler('dev', transformers, tsModule);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* returns the component build pipeline.
|
|
38
|
+
*/
|
|
39
|
+
getBuildPipe(modifiers: GetBuildPipeModifiers = {}): BuildTask[] {
|
|
40
|
+
const tsTransformers: TsConfigTransformer[] =
|
|
41
|
+
(modifiers?.tsModifier?.transformers as any as TsConfigTransformer[]) || [];
|
|
42
|
+
const compilerTask = this.reactAspect.reactEnv.getCjsCompilerTask(tsTransformers, modifiers?.tsModifier?.module);
|
|
43
|
+
|
|
44
|
+
const pipeWithoutCompiler = this.reactAspect.reactEnv.getBuildPipeWithoutCompiler();
|
|
45
|
+
return [compilerTask, ...pipeWithoutCompiler];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* returns a component tester.
|
|
50
|
+
*/
|
|
51
|
+
getTester(jestConfigPath: string, jestModulePath?: string): Tester {
|
|
52
|
+
const config = jestConfigPath || require.resolve('./jest/jest.config');
|
|
53
|
+
return this.reactAspect.reactEnv.getCjsJestTester(config, jestModulePath);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
getPreviewConfig() {
|
|
57
|
+
return {
|
|
58
|
+
strategyName: COMPONENT_PREVIEW_STRATEGY_NAME as PreviewStrategyName,
|
|
59
|
+
splitComponentBundle: false,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
getPackageJsonProps() {
|
|
64
|
+
return this.tsAspect.getCjsPackageJsonProps();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
getSchemaExtractor(tsconfig: TsConfigSourceFile, tsserverPath?: string, contextPath?: string): SchemaExtractor {
|
|
68
|
+
return this.tsAspect.createSchemaExtractor(
|
|
69
|
+
this.reactAspect.reactEnv.getTsConfig(tsconfig),
|
|
70
|
+
tsserverPath,
|
|
71
|
+
contextPath
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async __getDescriptor() {
|
|
76
|
+
return {
|
|
77
|
+
type: NodeEnvType,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { Harmony } from '@teambit/harmony';
|
|
2
|
+
import { EnvPolicyConfigObject } from '@teambit/dependency-resolver';
|
|
3
|
+
import { TsConfigSourceFile } from 'typescript';
|
|
4
|
+
import { TsCompilerOptionsWithoutTsConfig, TypescriptAspect, TypescriptMain } from '@teambit/typescript';
|
|
5
|
+
import { ApplicationAspect, ApplicationMain } from '@teambit/application';
|
|
6
|
+
import { merge } from 'lodash';
|
|
7
|
+
import { LoggerAspect, LoggerMain } from '@teambit/logger';
|
|
8
|
+
import { MainRuntime } from '@teambit/cli';
|
|
9
|
+
import { GeneratorAspect, GeneratorMain } from '@teambit/generator';
|
|
10
|
+
import { BuildTask } from '@teambit/builder';
|
|
11
|
+
import { ComponentID } from '@teambit/component-id';
|
|
12
|
+
import { WorkerAspect, WorkerMain } from '@teambit/worker';
|
|
13
|
+
import { Compiler } from '@teambit/compiler';
|
|
14
|
+
import { PackageJsonProps } from '@teambit/pkg';
|
|
15
|
+
import { EnvsAspect, EnvsMain, EnvTransformer, Environment, EnvContext } from '@teambit/envs';
|
|
16
|
+
import { ReactAspect, ReactEnv, ReactMain, UseTypescriptModifiers } from '@teambit/react';
|
|
17
|
+
import { NodeAspect } from './node.aspect';
|
|
18
|
+
import { NodeEnv } from './node.env';
|
|
19
|
+
import { getTemplates } from './node.templates';
|
|
20
|
+
import { NodeAppType } from './node.app-type';
|
|
21
|
+
|
|
22
|
+
export class NodeMain {
|
|
23
|
+
constructor(
|
|
24
|
+
private react: ReactMain,
|
|
25
|
+
|
|
26
|
+
private tsAspect: TypescriptMain,
|
|
27
|
+
|
|
28
|
+
readonly nodeEnv: NodeEnv,
|
|
29
|
+
|
|
30
|
+
private envs: EnvsMain
|
|
31
|
+
) {}
|
|
32
|
+
|
|
33
|
+
icon() {
|
|
34
|
+
return 'https://static.bit.dev/extensions-icons/nodejs.svg';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated use useTypescript()
|
|
39
|
+
* override the TS config of the environment.
|
|
40
|
+
*/
|
|
41
|
+
overrideTsConfig: (
|
|
42
|
+
tsconfig: TsConfigSourceFile,
|
|
43
|
+
compilerOptions?: Partial<TsCompilerOptionsWithoutTsConfig>,
|
|
44
|
+
tsModule?: any
|
|
45
|
+
) => EnvTransformer = this.react.overrideTsConfig.bind(this.react);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* override the jest config of the environment.
|
|
49
|
+
*/
|
|
50
|
+
overrideJestConfig = this.react.overrideJestConfig.bind(this.react);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* override the env build pipeline.
|
|
54
|
+
*/
|
|
55
|
+
overrideBuildPipe: (tasks: BuildTask[]) => EnvTransformer = this.react.overrideBuildPipe.bind(this.react);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* override the env compilers list.
|
|
59
|
+
*/
|
|
60
|
+
overrideCompiler: (compiler: Compiler) => EnvTransformer = this.react.overrideCompiler.bind(this.react);
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* override the env compilers tasks in the build pipe.
|
|
64
|
+
*/
|
|
65
|
+
overrideCompilerTasks: (tasks: BuildTask[]) => EnvTransformer = this.react.overrideCompilerTasks.bind(this.react);
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @deprecated use useTypescript()
|
|
69
|
+
* override the build ts config.
|
|
70
|
+
*/
|
|
71
|
+
overrideBuildTsConfig: (
|
|
72
|
+
tsconfig: any,
|
|
73
|
+
compilerOptions?: Partial<TsCompilerOptionsWithoutTsConfig>
|
|
74
|
+
) => EnvTransformer = this.react.overrideBuildTsConfig.bind(this.react);
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* override package json properties.
|
|
78
|
+
*/
|
|
79
|
+
overridePackageJsonProps: (props: PackageJsonProps) => EnvTransformer = this.react.overridePackageJsonProps.bind(
|
|
80
|
+
this.react
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @deprecated - use useWebpack
|
|
85
|
+
* override the preview config in the env.
|
|
86
|
+
*/
|
|
87
|
+
overridePreviewConfig = this.react.overridePreviewConfig.bind(this.react);
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @deprecated - use useWebpack
|
|
91
|
+
* override the dev server configuration.
|
|
92
|
+
*/
|
|
93
|
+
overrideDevServerConfig = this.react.overrideDevServerConfig.bind(this.react);
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* override the env's typescript config for both dev and build time.
|
|
97
|
+
* Replaces both overrideTsConfig (devConfig) and overrideBuildTsConfig (buildConfig)
|
|
98
|
+
*/
|
|
99
|
+
useTypescript(modifiers?: UseTypescriptModifiers, tsModule?: any) {
|
|
100
|
+
const overrides: any = {};
|
|
101
|
+
const devTransformers = modifiers?.devConfig;
|
|
102
|
+
if (devTransformers) {
|
|
103
|
+
overrides.getCompiler = () => this.nodeEnv.getCompiler(devTransformers, tsModule);
|
|
104
|
+
}
|
|
105
|
+
const buildTransformers = modifiers?.buildConfig;
|
|
106
|
+
if (buildTransformers) {
|
|
107
|
+
const buildPipeModifiers = {
|
|
108
|
+
tsModifier: {
|
|
109
|
+
transformers: buildTransformers,
|
|
110
|
+
module: tsModule,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
overrides.getBuildPipe = () => this.nodeEnv.getBuildPipe(buildPipeModifiers);
|
|
114
|
+
}
|
|
115
|
+
return this.envs.override(overrides);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* override the env's dev server and preview webpack configurations.
|
|
120
|
+
* Replaces both overrideDevServerConfig and overridePreviewConfig
|
|
121
|
+
*/
|
|
122
|
+
useWebpack = this.react.useWebpack.bind(this.react);
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* An API to mutate the prettier config
|
|
126
|
+
*/
|
|
127
|
+
usePrettier = this.react.usePrettier.bind(this.react);
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* An API to mutate the eslint config
|
|
131
|
+
*/
|
|
132
|
+
useEslint = this.react.useEslint.bind(this.react);
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* override the dependency configuration of the component environment.
|
|
136
|
+
*/
|
|
137
|
+
overrideDependencies(dependencyPolicy: EnvPolicyConfigObject) {
|
|
138
|
+
return this.envs.override({
|
|
139
|
+
getDependencies: () => merge(this.nodeEnv.getDependencies(), dependencyPolicy),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
overrideMounter = this.react.overrideMounter.bind(this.react);
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* create a new composition of the node environment.
|
|
147
|
+
*/
|
|
148
|
+
compose(transformers: EnvTransformer[], targetEnv: Environment = {}) {
|
|
149
|
+
return this.envs.compose(this.envs.merge(targetEnv, this.nodeEnv), transformers);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
static runtime = MainRuntime;
|
|
153
|
+
static dependencies = [
|
|
154
|
+
LoggerAspect,
|
|
155
|
+
EnvsAspect,
|
|
156
|
+
ApplicationAspect,
|
|
157
|
+
ReactAspect,
|
|
158
|
+
GeneratorAspect,
|
|
159
|
+
TypescriptAspect,
|
|
160
|
+
WorkerAspect,
|
|
161
|
+
];
|
|
162
|
+
|
|
163
|
+
static async provider(
|
|
164
|
+
[loggerAspect, envs, application, react, generator, tsAspect, workerMain]: [
|
|
165
|
+
LoggerMain,
|
|
166
|
+
EnvsMain,
|
|
167
|
+
ApplicationMain,
|
|
168
|
+
ReactMain,
|
|
169
|
+
GeneratorMain,
|
|
170
|
+
TypescriptMain,
|
|
171
|
+
WorkerMain
|
|
172
|
+
],
|
|
173
|
+
config,
|
|
174
|
+
slots,
|
|
175
|
+
harmony: Harmony
|
|
176
|
+
) {
|
|
177
|
+
const logger = loggerAspect.createLogger(NodeAspect.id);
|
|
178
|
+
const nodeEnv = envs.merge<NodeEnv, ReactEnv>(new NodeEnv(tsAspect, react), react.reactEnv);
|
|
179
|
+
envs.registerEnv(nodeEnv);
|
|
180
|
+
const nodeAppType = new NodeAppType('node-app', nodeEnv, logger);
|
|
181
|
+
application.registerAppType(nodeAppType);
|
|
182
|
+
if (generator) {
|
|
183
|
+
const envContext = new EnvContext(ComponentID.fromString(ReactAspect.id), loggerAspect, workerMain, harmony);
|
|
184
|
+
generator.registerComponentTemplate(getTemplates(envContext));
|
|
185
|
+
}
|
|
186
|
+
return new NodeMain(react, tsAspect, nodeEnv, envs);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
NodeAspect.addRuntime(NodeMain);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NodeModuleTemplate,
|
|
3
|
+
NodeAppTemplate,
|
|
4
|
+
PlatformTemplate,
|
|
5
|
+
GraphQLServerTemplate,
|
|
6
|
+
EntityTemplate,
|
|
7
|
+
ExpressAppTemplate,
|
|
8
|
+
NodeEnvTemplate,
|
|
9
|
+
BitAppTemplate,
|
|
10
|
+
} from '@bitdev/node.generators.node-templates';
|
|
11
|
+
|
|
12
|
+
import { EnvContext } from '@teambit/envs';
|
|
13
|
+
import { ComponentTemplate, TemplateList } from '@teambit/generator';
|
|
14
|
+
|
|
15
|
+
const templateListHandler = TemplateList.from([
|
|
16
|
+
NodeModuleTemplate.from({ env: 'bitdev.node/node-env' }),
|
|
17
|
+
GraphQLServerTemplate.from({ env: 'bitdev.node/node-env' }),
|
|
18
|
+
EntityTemplate.from({ env: 'bitdev.node/node-env' }),
|
|
19
|
+
ExpressAppTemplate.from({ env: 'bitdev.node/node-env' }),
|
|
20
|
+
BitAppTemplate.from({ env: 'bitdev.node/node-env' }),
|
|
21
|
+
PlatformTemplate.from({ env: 'bitdev.node/node-env' }),
|
|
22
|
+
NodeAppTemplate.from({ env: 'bitdev.node/node-env' }),
|
|
23
|
+
NodeEnvTemplate.from({}),
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
export function getTemplates(envContext: EnvContext): ComponentTemplate[] {
|
|
27
|
+
const templateList = templateListHandler(envContext);
|
|
28
|
+
return templateList.compute();
|
|
29
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/node",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.221",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/harmony/node",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.harmony",
|
|
8
8
|
"name": "node",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.221"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"typescript": "5.3.3",
|
|
@@ -27,24 +27,24 @@
|
|
|
27
27
|
"@teambit/component-id": "1.2.0",
|
|
28
28
|
"@bitdev/node.generators.node-templates": "1.0.15",
|
|
29
29
|
"@teambit/design.ui.empty-box": "0.0.363",
|
|
30
|
-
"@teambit/application": "1.0.
|
|
31
|
-
"@teambit/logger": "0.0.
|
|
32
|
-
"@teambit/react": "1.0.
|
|
30
|
+
"@teambit/application": "1.0.221",
|
|
31
|
+
"@teambit/logger": "0.0.952",
|
|
32
|
+
"@teambit/react": "1.0.221",
|
|
33
33
|
"@teambit/toolbox.network.get-port": "1.0.6",
|
|
34
|
-
"@teambit/builder": "1.0.
|
|
35
|
-
"@teambit/dependency-resolver": "1.0.
|
|
36
|
-
"@teambit/envs": "1.0.
|
|
37
|
-
"@teambit/preview": "1.0.
|
|
38
|
-
"@teambit/schema": "1.0.
|
|
39
|
-
"@teambit/tester": "1.0.
|
|
40
|
-
"@teambit/typescript": "1.0.
|
|
41
|
-
"@teambit/cli": "0.0.
|
|
42
|
-
"@teambit/compiler": "1.0.
|
|
43
|
-
"@teambit/generator": "1.0.
|
|
44
|
-
"@teambit/pkg": "1.0.
|
|
45
|
-
"@teambit/worker": "0.0.
|
|
46
|
-
"@teambit/compositions": "1.0.
|
|
47
|
-
"@teambit/ui": "1.0.
|
|
34
|
+
"@teambit/builder": "1.0.221",
|
|
35
|
+
"@teambit/dependency-resolver": "1.0.221",
|
|
36
|
+
"@teambit/envs": "1.0.221",
|
|
37
|
+
"@teambit/preview": "1.0.221",
|
|
38
|
+
"@teambit/schema": "1.0.221",
|
|
39
|
+
"@teambit/tester": "1.0.221",
|
|
40
|
+
"@teambit/typescript": "1.0.221",
|
|
41
|
+
"@teambit/cli": "0.0.859",
|
|
42
|
+
"@teambit/compiler": "1.0.221",
|
|
43
|
+
"@teambit/generator": "1.0.222",
|
|
44
|
+
"@teambit/pkg": "1.0.221",
|
|
45
|
+
"@teambit/worker": "0.0.1163",
|
|
46
|
+
"@teambit/compositions": "1.0.221",
|
|
47
|
+
"@teambit/ui": "1.0.221"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/react": "^17.0.8",
|