Skip to content
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
3 changes: 2 additions & 1 deletion Tryouts/Prototypes/Shell/Node-launcher/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
output/
output/
coverage/
11 changes: 0 additions & 11 deletions Tryouts/Prototypes/Shell/Node-launcher/Demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,7 @@
"main": "example.js",
"module": "example.js",
"type": "module",
"scripts": {
"clean": "rimraf output",
"build": "npm run clean && rollup -c"
},
"dependencies": {
"@morgan-stanley/composeui-node-launcher": "*"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.0.1",
"rimraf": "4.1.2",
"rollup": "^2.76.0",
"tslib": "^2.4.0",
"typescript": "^4.7.4"
}
}
13 changes: 0 additions & 13 deletions Tryouts/Prototypes/Shell/Node-launcher/Demo/rollup.config.js

This file was deleted.

10 changes: 10 additions & 0 deletions Tryouts/Prototypes/Shell/Node-launcher/Lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,13 @@ The CLI enables you to execute your app with compose by executing the following
```
composeui myapp.js
```

### Local Development

If you're developing the CLI itself you need to execute the following command

```
npm link
```

in the `.\Tryouts\Prototypes\Shell\Node-launcher\Lib` folder
14 changes: 0 additions & 14 deletions Tryouts/Prototypes/Shell/Node-launcher/Lib/cli/cli.js

This file was deleted.

21 changes: 21 additions & 0 deletions Tryouts/Prototypes/Shell/Node-launcher/Lib/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/configuration
*/

export default {
// Automatically clear mock calls, instances, contexts and results before every test
clearMocks: true,

// Indicates whether the coverage information should be collected while executing the test
collectCoverage: true,

// The directory where Jest should output its coverage files
coverageDirectory: "coverage",

// Indicates which provider should be used to instrument code for coverage
coverageProvider: "v8",

// A preset that is used as a base for Jest's configuration
preset: "ts-jest"
};
12 changes: 7 additions & 5 deletions Tryouts/Prototypes/Shell/Node-launcher/Lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@
"type": "module",
"scripts": {
"clean": "rimraf output",
"build": "npm run clean && tsc && rollup -c"
"build": "npm run clean && tsc",
"test": "jest"
},
"bin": {
"composeui": "./cli/cli.js"
"composeui": "./output/cli/cli.js"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-typescript": "11.0.0",
"@types/jest": "29.4.0",
"@types/node": "^18.11.18",
"jest": "29.4.3",
"rimraf": "4.1.2",
"rollup": "^2.76.0",
"ts-jest": "29.0.5",
"ts-node": "10.9.1",
"tslib": "^2.4.0",
"typescript": "^4.7.4"
}
Expand Down
12 changes: 0 additions & 12 deletions Tryouts/Prototypes/Shell/Node-launcher/Lib/rollup.config.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { WindowConfig } from './WindowConfig.js';
import { Launcher } from './Launcher.js';
import { WindowConfig } from './WindowConfig';
import { Launcher } from './launcher.js';

export class BrowserWindow {
private launcher: Launcher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,7 @@ export class Launcher {
}
});

let exithandler = function() { process.exit() };
child.on('close', exithandler);
}
}
}
13 changes: 13 additions & 0 deletions Tryouts/Prototypes/Shell/Node-launcher/Lib/src/cli/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env node

"use strict";

import { executeScriptFile } from './executeScrtiptFile.js';

let fileName = process.argv[2];

try {
executeScriptFile(fileName);
} catch (error) {
console.error(error);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { executeScriptFile } from './executeScrtiptFile';

describe('CLI', () => {
let testFileName: string;

test('executeScriptFile() - No filename specified', () => {
expect(() => {
executeScriptFile(testFileName);
}).toThrow("Specify filename.");
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { fork } from 'child_process';
import { resolve } from 'path';

"use strict";

export function executeScriptFile(fileName: string){
if (fileName) {
let filePath: string = resolve(fileName);
const child = fork(filePath);
} else {
throw new Error("Specify filename.");
}
}
6 changes: 4 additions & 2 deletions Tryouts/Prototypes/Shell/Node-launcher/Lib/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export { BrowserWindow } from './BrowserWindow.js';
export { Launcher } from './Launcher.js';
export { WindowConfig } from './WindowConfig.js';
export { Launcher } from './launcher.js';
export { WindowConfig } from './WindowConfig.js';
export * from './cli/cli.js';
export { executeScriptFile } from './cli/executeScrtiptFile.js';
19 changes: 19 additions & 0 deletions Tryouts/Prototypes/Shell/Node-launcher/Lib/src/launcher.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Launcher } from './launcher';
import { WindowConfig } from './WindowConfig';

describe('Launcher', () => {
let testWindowConfig: WindowConfig;
let testLauncher: Launcher;

beforeAll( () => {
testLauncher = new Launcher();
});

test('launch() - "Window config has no parameters', () => {
testWindowConfig = {};

expect(() => {
testLauncher.launch(testWindowConfig);
}).toThrow("At least the url must be specified!");
});
});
2 changes: 1 addition & 1 deletion Tryouts/Prototypes/Shell/Node-launcher/Lib/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"moduleResolution": "node",
"types": [ "node" ],
"types": [ "node", "jest" ],
"experimentalDecorators": true,
"module": "es2022",
"esModuleInterop": true,
Expand Down
Loading