diff --git a/examples/electron-app/package.json b/examples/electron-app/package.json index 5878b921a..d7e408577 100644 --- a/examples/electron-app/package.json +++ b/examples/electron-app/package.json @@ -1,6 +1,6 @@ { "name": "@example/electron-app", - "version": "15.0.0", + "version": "15.1.0-rc.0", "main": "index.js", "scripts": { "start": "electron ." diff --git a/examples/file-server/package.json b/examples/file-server/package.json index 730b65eb3..2b3c872fd 100644 --- a/examples/file-server/package.json +++ b/examples/file-server/package.json @@ -1,6 +1,6 @@ { "name": "@example/file-server", - "version": "15.0.0", + "version": "15.1.0-rc.0", "scripts": { "start": "engine start", "test": "yarn test:ix && yarn test:unit", diff --git a/examples/playground/package.json b/examples/playground/package.json index 3991242ac..45dfa90e8 100644 --- a/examples/playground/package.json +++ b/examples/playground/package.json @@ -1,6 +1,6 @@ { "name": "@example/playground", - "version": "15.0.0", + "version": "15.1.0-rc.0", "scripts": { "start": "engine start" }, diff --git a/lerna.json b/lerna.json index fa31965da..c4a55f7b7 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "15.0.0", + "version": "15.1.0-rc.0", "npmClient": "yarn", "useWorkspaces": true } diff --git a/packages/core-node/package.json b/packages/core-node/package.json index bf5b51678..a5badba16 100644 --- a/packages/core-node/package.json +++ b/packages/core-node/package.json @@ -1,6 +1,6 @@ { "name": "@wixc3/engine-core-node", - "version": "15.0.0", + "version": "15.1.0-rc.0", "main": "cjs/index.js", "types": "cjs/index.d.ts", "scripts": { @@ -12,7 +12,7 @@ "prepack": "yarn build" }, "dependencies": { - "@wixc3/engine-core": "^15.0.0", + "@wixc3/engine-core": "^15.1.0-rc.0", "create-listening-server": "^1.0.0", "express": "^4.17.1", "socket.io": "^2.3.0" diff --git a/packages/core/package.json b/packages/core/package.json index f49d24655..aa7cb6848 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@wixc3/engine-core", - "version": "15.0.0", + "version": "15.1.0-rc.0", "main": "cjs/index.js", "types": "cjs/index.d.ts", "scripts": { diff --git a/packages/engineer/feature/dev-server.dev-server.env.ts b/packages/engineer/feature/dev-server.dev-server.env.ts index 74e686db7..f3dda0450 100644 --- a/packages/engineer/feature/dev-server.dev-server.env.ts +++ b/packages/engineer/feature/dev-server.dev-server.env.ts @@ -40,7 +40,10 @@ const attachWSHost = (socketServer: SocketIO.Server, envName: string, communicat devServerFeature.setup( devServerEnv, - ({ run, devServerConfig, engineerWebpackConfigs, serverListeningHandlerSlot }, { COM: { communication } }) => { + ( + { run, devServerConfig, engineerWebpackConfigs, serverListeningHandlerSlot, onDispose }, + { COM: { communication } } + ) => { const { httpServerPort, featureName, @@ -57,12 +60,7 @@ devServerFeature.setup( defaultRuntimeOptions, outputPath, } = devServerConfig; - - const appStartArgs = outputPath - ? { basePath, nodeEnvironmentsMode, outputPath } - : { basePath, nodeEnvironmentsMode }; - - const application = new TargetApplication(appStartArgs); + const application = new TargetApplication({ basePath, nodeEnvironmentsMode, outputPath }); const disposables = new Set<() => unknown>(); // Extract these into a service @@ -76,6 +74,8 @@ devServerFeature.setup( disposables.clear(); }; + onDispose(close); + run(async () => { // Should engine config be part of the dev experience of the engine???? const engineConfig = await application.getEngineConfig(); diff --git a/packages/engineer/package.json b/packages/engineer/package.json index 73e332b0d..6d527660b 100644 --- a/packages/engineer/package.json +++ b/packages/engineer/package.json @@ -1,6 +1,6 @@ { "name": "@wixc3/engineer", - "version": "15.0.0", + "version": "15.1.0-rc.0", "license": "MIT", "main": "cjs/src/index.js", "types": "cjs/src/index.d.ts", @@ -18,9 +18,9 @@ }, "dependencies": { "@file-services/node": "^4.1.2", - "@wixc3/engine-core": "^15.0.0", - "@wixc3/engine-core-node": "^15.0.0", - "@wixc3/engine-scripts": "^15.0.0", + "@wixc3/engine-core": "^15.1.0-rc.0", + "@wixc3/engine-core-node": "^15.1.0-rc.0", + "@wixc3/engine-scripts": "^15.1.0-rc.0", "commander": "^6.1.0", "open": "^7.3.0", "react": "^16.13.1", diff --git a/packages/engineer/src/utils.ts b/packages/engineer/src/utils.ts index bc9000c44..a6ccdee76 100644 --- a/packages/engineer/src/utils.ts +++ b/packages/engineer/src/utils.ts @@ -6,13 +6,13 @@ import { runNodeEnvironment, TopLevelConfigProvider, } from '@wixc3/engine-scripts'; -import { RuntimeEngine, BaseHost, TopLevelConfig } from '@wixc3/engine-core'; +import { RuntimeEngine, BaseHost, TopLevelConfig, RuntimeFeature } from '@wixc3/engine-core'; import devServerFeature, { devServerEnv } from '../feature/dev-server.feature'; import guiFeature from '../feature/gui.feature'; export interface IStartOptions { - publicPath: string; + publicPath?: string; targetApplicationPath: string; outputPath?: string; featureName?: string; @@ -27,16 +27,17 @@ export interface IStartOptions { autoLaunch?: boolean; engineerEntry?: string; overrideConfig?: TopLevelConfig | TopLevelConfigProvider; + inspect?: boolean; } -export function startDevServer({ +export async function startDevServer({ featureName, configName, httpServerPort = 3000, singleRun, singleFeature, pathsToRequire = [], - publicPath, + publicPath = '/', mode = 'development', title, publicConfigsRoute = 'configs/', @@ -45,9 +46,11 @@ export function startDevServer({ engineerEntry = 'engineer/gui', overrideConfig = [], outputPath, + inspect, }: IStartOptions): Promise<{ dispose: () => Promise; engine: RuntimeEngine; + devServerFeature: RuntimeFeature; }> { const basePath = resolve(__dirname, '../feature'); const featurePaths = fs.findFilesSync(basePath, { @@ -57,7 +60,7 @@ export function startDevServer({ const features = loadFeaturesFromPaths(new Set(featurePaths), new Set([basePath]), fs).features; - return runNodeEnvironment({ + const { engine, dispose } = await runNodeEnvironment({ featureName: engineerEntry, features: [...features], name: devServerEnv.env, @@ -79,6 +82,7 @@ export function startDevServer({ basePath: targetApplicationPath, overrideConfig, outputPath, + inspect, }, }), guiFeature.use({ @@ -88,6 +92,12 @@ export function startDevServer({ }), ], }); + + return { + engine, + dispose, + devServerFeature: engine.features.get(features.get('engineer/dev-server')!.exportedFeature) as RuntimeFeature, + }; } function preRequire(pathsToRequire: string[], basePath: string) { diff --git a/packages/engineer/test/dev-server.unit.ts b/packages/engineer/test/dev-server.unit.ts index 7af73a492..37f51ac85 100644 --- a/packages/engineer/test/dev-server.unit.ts +++ b/packages/engineer/test/dev-server.unit.ts @@ -1,15 +1,10 @@ +import { expect } from 'chai'; +import type { Page } from 'puppeteer'; import { createBrowserProvider } from '@wixc3/engine-test-kit'; -import devServerFeature, { devServerEnv } from '../feature/dev-server.feature'; import fs from '@file-services/node'; -import { createDisposables, BaseHost, RuntimeFeature, TopLevelConfig, RuntimeEngine } from '@wixc3/engine-core'; -import type { Page } from 'puppeteer'; -import { expect } from 'chai'; -import { - runNodeEnvironment, - loadFeaturesFromPackages, - resolvePackages, - TopLevelConfigProvider, -} from '@wixc3/engine-scripts'; +import { createDisposables, RuntimeFeature, TopLevelConfig, RuntimeEngine } from '@wixc3/engine-core'; +import type { TopLevelConfigProvider } from '@wixc3/engine-scripts'; +import { startDevServer } from '../src/utils'; const engineFeatureFixturePath = fs.join(__dirname, '../fixtures/engine-feature'); const multiFeatureFixturePath = fs.join(__dirname, '../fixtures/engine-multi-feature'); @@ -51,43 +46,28 @@ describe('engineer:dev-server', function () { runtimeFeature: RuntimeFeature | undefined; config: { featureName: string | undefined; port: number }; }> => { - const { dispose, engine } = await runNodeEnvironment({ - featureName: 'engineer/dev-server', - features: [...loadFeaturesFromPackages(resolvePackages('../'), fs).features], - name: devServerEnv.env, - type: 'node', - host: new BaseHost(), - config: [ - devServerFeature.use({ - devServerConfig: { - basePath, - httpServerPort: port, - singleRun: true, - featureName, - autoLaunch, - configName, - inspect, - overrideConfig, - outputPath, - }, - }), - ], + const { dispose, engine, devServerFeature } = await startDevServer({ + engineerEntry: 'engineer/dev-server', + targetApplicationPath: basePath, + httpServerPort: port, + featureName, + autoLaunch, + configName, + inspect, + overrideConfig, + outputPath, + singleRun: true, }); - const runtimeFeature: RuntimeFeature | undefined = engine.features.get(devServerFeature); - runtimeFeature?.addOnDisposeHandler(async () => { - await runtimeFeature.api.devServerActions.close(); - }, devServerEnv.env); - const runningPort: number = await new Promise((resolve) => { - runtimeFeature!.api.serverListeningHandlerSlot.register(({ port }: { port: number }) => { + devServerFeature.api.serverListeningHandlerSlot.register(({ port }: { port: number }) => { resolve(port); }); }); disposables.add(() => dispose()); - return { dispose, engine, runtimeFeature, config: { featureName, port: runningPort } }; + return { dispose, engine, runtimeFeature: devServerFeature, config: { featureName, port: runningPort } }; }; const loadPage = async (url: string) => { diff --git a/packages/engineer/test/gui.unit.ts b/packages/engineer/test/gui.unit.ts index c922d9710..086b44266 100644 --- a/packages/engineer/test/gui.unit.ts +++ b/packages/engineer/test/gui.unit.ts @@ -1,11 +1,10 @@ -import { createDisposables, RuntimeFeature, BaseHost } from '@wixc3/engine-core'; +import { createDisposables, RuntimeFeature } from '@wixc3/engine-core'; import { createBrowserProvider } from '@wixc3/engine-test-kit'; -import { runNodeEnvironment, loadFeaturesFromPackages, resolvePackages } from '@wixc3/engine-scripts'; import fs from '@file-services/node'; -import devServerFeature, { devServerEnv } from '../feature/dev-server.feature'; import guiFeature from '../feature/gui.feature'; import { expect } from 'chai'; import type { Page } from 'puppeteer'; +import { startDevServer } from '../src'; function getBodyContent(page: Page) { return page.evaluate(() => document.body.textContent!.trim()); @@ -17,35 +16,15 @@ describe('engineer:gui', function () { const browserProvider = createBrowserProvider(); const setup = async ({ featureName, basePath }: { featureName?: string; basePath: string }) => { - const features = loadFeaturesFromPackages(resolvePackages(__dirname + '../'), fs).features; - const { dispose, engine } = await runNodeEnvironment({ - featureName: 'engineer/gui', - features: [...features], - name: devServerEnv.env, - type: 'node', - host: new BaseHost(), - config: [ - devServerFeature.use({ - devServerConfig: { - basePath, - }, - }), - guiFeature.use({ - engineerConfig: { - features, - }, - }), - ], + const { dispose, engine, devServerFeature } = await startDevServer({ + engineerEntry: 'engineer/gui', + targetApplicationPath: basePath, }); const runtimeFeature = engine.features.get(guiFeature) as RuntimeFeature; - const devServerRuntime = engine.features.get(devServerFeature) as RuntimeFeature; - runtimeFeature.addOnDisposeHandler(async () => { - await devServerRuntime.api.devServerActions.close(); - }, devServerEnv.env); const runningPort: number = await new Promise((resolve) => { - devServerRuntime.api.serverListeningHandlerSlot.register(({ port }: { port: number }) => { + devServerFeature.api.serverListeningHandlerSlot.register(({ port }: { port: number }) => { resolve(port); }); }); diff --git a/packages/scripts/package.json b/packages/scripts/package.json index 25cb48369..14209516b 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -1,6 +1,6 @@ { "name": "@wixc3/engine-scripts", - "version": "15.0.0", + "version": "15.1.0-rc.0", "main": "cjs/index.js", "types": "cjs/index.d.ts", "scripts": { @@ -19,8 +19,8 @@ "@file-services/node": "^4.1.2", "@file-services/types": "^4.1.0", "@wixc3/cross-performance": "^14.3.1", - "@wixc3/engine-core": "^15.0.0", - "@wixc3/engine-core-node": "^15.0.0", + "@wixc3/engine-core": "^15.1.0-rc.0", + "@wixc3/engine-core-node": "^15.1.0-rc.0", "commander": "^6.1.0", "cors": "^2.8.5", "create-listening-server": "^1.0.0", diff --git a/packages/test-kit/package.json b/packages/test-kit/package.json index 60625d6ab..ca38c3bba 100644 --- a/packages/test-kit/package.json +++ b/packages/test-kit/package.json @@ -1,6 +1,6 @@ { "name": "@wixc3/engine-test-kit", - "version": "15.0.0", + "version": "15.1.0-rc.0", "main": "cjs/index.js", "types": "cjs/index.d.ts", "scripts": { @@ -14,7 +14,7 @@ "typescript": ">=3.0.0" }, "dependencies": { - "@wixc3/engine-scripts": "^15.0.0", + "@wixc3/engine-scripts": "^15.1.0-rc.0", "is-ci": "^2.0.0", "promise-assist": "^1.3.0", "sinon": "^9.1.0"