Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

fix(one-app-runner): single serve-module invocation #622

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/one-app-runner/__tests__/src/startApp.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Array [
'-v=/path/to-module-b:/opt/module-workspace/to-module-b',
'-v=/home/user/.one-app:/home/node/.one-app',
]);
expect(mockSpawn.calls[1].args[mockSpawn.calls[1].args.indexOf('-c') + 1]).toMatchInlineSnapshot('"npm config set update-notifier false && npm run serve-module \'/opt/module-workspace/module-a\' &&npm run serve-module \'/opt/module-workspace/to-module-b\' && node lib/server/index.js --root-module-name=frank-lloyd-root --module-map-url=https://example.com/module-map.json"');
expect(mockSpawn.calls[1].args[mockSpawn.calls[1].args.indexOf('-c') + 1]).toMatchInlineSnapshot('"npm config set update-notifier false && npm run serve-module \'/opt/module-workspace/module-a\' \'/opt/module-workspace/to-module-b\' && node lib/server/index.js --root-module-name=frank-lloyd-root --module-map-url=https://example.com/module-map.json"');
});

it('mounts and serves modules in docker run if module paths are provided and moduleMapUrl is not', async () => {
Expand All @@ -153,7 +153,7 @@ Array [
'-v=/path/to-module-b:/opt/module-workspace/to-module-b',
'-v=/home/user/.one-app:/home/node/.one-app',
]);
expect(mockSpawn.calls[1].args[mockSpawn.calls[1].args.indexOf('-c') + 1]).toMatchInlineSnapshot('"npm config set update-notifier false && npm run serve-module \'/opt/module-workspace/module-a\' &&npm run serve-module \'/opt/module-workspace/to-module-b\' && node lib/server/index.js --root-module-name=frank-lloyd-root"');
expect(mockSpawn.calls[1].args[mockSpawn.calls[1].args.indexOf('-c') + 1]).toMatchInlineSnapshot('"npm config set update-notifier false && npm run serve-module \'/opt/module-workspace/module-a\' \'/opt/module-workspace/to-module-b\' && node lib/server/index.js --root-module-name=frank-lloyd-root"');
});

it('runs set middleware command and starts one app with mock flag in docker run if parrot middleware file is provided', async () => {
Expand Down
16 changes: 9 additions & 7 deletions packages/one-app-runner/src/startApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,16 @@ const generateUseMocksFlag = (shouldUseMocks) => (shouldUseMocks ? '-m' : '');
const generateNpmConfigCommands = () => 'npm config set update-notifier false &&';

const generateServeModuleCommands = (modules) => {
let command = '';
if (modules && modules.length > 0) {
modules.forEach((modulePath) => {
const moduleRootDir = path.basename(modulePath);
command += `npm run serve-module '/opt/module-workspace/${moduleRootDir}' &&`;
});
if (!modules || modules.length === 0) {
return '';
}
return command;

let command = 'npm run serve-module';
modules.forEach((modulePath) => {
const moduleRootDir = path.basename(modulePath);
command += ` '/opt/module-workspace/${moduleRootDir}'`;
});
return `${command} &&`;
};

const generateModuleMap = (moduleMapUrl) => (moduleMapUrl ? `--module-map-url=${moduleMapUrl}` : '');
Expand Down
Loading