Skip to content

Commit

Permalink
ComposeUI Node.js CLI (#156)
Browse files Browse the repository at this point in the history
* composeui-cli

* fix csproj file

* Renaming package and command
  • Loading branch information
kruplm authored Feb 22, 2023
1 parent 6d01d0d commit ea5e162
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 73 deletions.
5 changes: 2 additions & 3 deletions Tryouts/Prototypes/Shell/Node-launcher/Demo/example.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BrowserWindow } from '@morgan-stanley/compose-node-launcher';
import { BrowserWindow } from '@morgan-stanley/composeui-node-launcher';

function windowOpenExample() {
const window = new BrowserWindow(
Expand All @@ -12,8 +12,6 @@ function windowOpenExample() {
window.open();
}

windowOpenExample();

function loadUrlExample() {
const window = new BrowserWindow(
{
Expand All @@ -24,4 +22,5 @@ function loadUrlExample() {
window.loadUrl("https://github.com/morganstanley/fdc3-dotnet");
}

windowOpenExample();
loadUrlExample();
6 changes: 3 additions & 3 deletions Tryouts/Prototypes/Shell/Node-launcher/Demo/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@morgan-stanley/compose-node-launcher-example",
"name": "@morgan-stanley/composeui-node-launcher-example",
"version": "0.1.0",
"description": "",
"description": "Example usage of @morgan-stanley/composeui-node-launcher-example",
"main": "example.js",
"module": "example.js",
"type": "module",
Expand All @@ -10,7 +10,7 @@
"build": "npm run clean && rollup -c"
},
"dependencies": {
"@morgan-stanley/compose-node-launcher": "*"
"@morgan-stanley/composeui-node-launcher": "*"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.0.1",
Expand Down
48 changes: 48 additions & 0 deletions Tryouts/Prototypes/Shell/Node-launcher/Lib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!-- Morgan Stanley makes this available to you under the Apache License, Version 2.0 (the "License"). You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->

# @morgan-stanley/composeui-node-launcher

## Library

The library enables you to dynmically set properties for your window in your javascript code.

```
function windowOpenExample() {
const window = new BrowserWindow(
{
url: "https://github.com/morganstanley/composeui",
title: "My Web App",
width: 1600,
height: 800
});
window.open();
}
windowOpenExample();
```

Or with loadUrl

```
function loadUrlExample() {
const window = new BrowserWindow(
{
width: 1600,
height: 800
});
window.loadUrl("https://github.com/morganstanley/composeui");
}
loadUrlExample();
```

## CLI

The CLI enables you to execute your app with compose by executing the following command:

```
composeui myapp.js
```
14 changes: 14 additions & 0 deletions Tryouts/Prototypes/Shell/Node-launcher/Lib/cli/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env node

import { execFile } from 'child_process';
import { resolve } from 'path';

let filename = process.argv.slice(2)[0];
let filePath= resolve(filename);

const child = execFile("node", [filePath], (error, stdout, stderr) => {
console.log(stdout);
if (error) {
throw error;
}
});
5 changes: 4 additions & 1 deletion Tryouts/Prototypes/Shell/Node-launcher/Lib/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@morgan-stanley/compose-node-launcher",
"name": "@morgan-stanley/composeui-node-launcher",
"version": "0.1.0",
"description": "Package to launch Compose from Node.js",
"main": "output/index.js",
Expand All @@ -9,6 +9,9 @@
"clean": "rimraf output",
"build": "npm run clean && tsc && rollup -c"
},
"bin": {
"composeui": "./cli/cli.js"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-typescript": "11.0.0",
Expand Down
135 changes: 69 additions & 66 deletions Tryouts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ea5e162

Please sign in to comment.