Skip to content

Commit

Permalink
Support dependency management through npm
Browse files Browse the repository at this point in the history
- Add support for 'package.json' files
-- Listen to changes of 'package.json' files
-- Add VS code plugins to support editing 'package.json' files

- Add package manager for simple dependency management
-- Do not build 'package.json' files (as they do not match CM grammar)
-- Instead build up dependency graph based on package information
-- Consider models under 'package.json' directory part of the package

- Replace workspace-based scoping with package-based scoping
-- Only models within the same models or dependent models are visible
-- Ensure 'node_modules' directory is also scanned

Minor:
- Update to latest version of Langium
- Convert model service to shared service
-- Requires retrieval of serializer based on URI
-- Extend language model service to ensure we have serializer
- Fix eclipse-theia/theia#12260 locally

TODO:
- Requires reload after npm install (file watching issue?)
  • Loading branch information
martin-fleck-at committed Mar 17, 2023
1 parent 1143efe commit 27eb2ef
Show file tree
Hide file tree
Showing 82 changed files with 2,056 additions and 315 deletions.
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"--loglevel=debug",
"--hostname=localhost",
"--no-cluster",
"--root-dir=${workspaceRoot}/examples/workspace",
"--app-project-path=${workspaceFolder}/applications/electron-app",
"--remote-debugging-port=9222",
"--no-app-auto-install",
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,24 @@ To package the application use

Depending on the platform, this will produce an executable or an installer for the application under `applications/electron-app/dist`.
Details about the packaging can be configured in `applications/electron-app/electron-builder.yml`.

## Example Workspace

Under `examples/workspace` we provide an example workspace with some demo packages containing entities, relationships and system diagrams.
Each package represents a dedicated system or library and may depend on other packages.

Using a known package structure - npm in our case - we can re-use large parts of the package management to download dependencies that are not locally available from an external package registry.
In order to test this behavior, we use verdaccio as a local npm registry that provides some models that are needed by our workspace packages.
You can start verdaccio using

yarn start:verdaccio

The local npm registry will be available under `http://localhost:4873/` where we already provide four packages by default.

After opening the workspace, you can install the necessary dependencies in the example workspace by opening a terminal in `examples/workspace` and execute

npm install

This should download all dependencies into dedicated `node_modules` directories within the workspace.

Currently there is still an issue where new files are not recognized automatically, so you need to reload your workspace once for all the dependencies to be properly recognized.
9 changes: 7 additions & 2 deletions applications/browser-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
},
"scripts": {
"clean": "theia clean && rimraf lib && rimraf src-gen",
"prepare": "theia build --mode development",
"download:plugins": "theia download:plugins",
"prepare": "theia build --mode development && yarn download:plugins",
"rebuild": "theia rebuild:browser --cacheRoot ../..",
"start": "yarn rebuild && theia start --plugins=local-dir:plugins",
"watch": "theia build --watch --mode development"
Expand Down Expand Up @@ -59,6 +60,10 @@
}
}
},
"theiaPlugins": {},
"theiaPlugins": {
"vscode.json-1.66.2": "https://open-vsx.org/api/vscode/json/1.66.2/file/vscode.json-1.66.2.vsix",
"vscode.json-language-features-1.66.2": "https://open-vsx.org/api/vscode/json-language-features/1.66.2/file/vscode.json-language-features-1.66.2.vsix",
"vscode.npm-1.66.2": "https://open-vsx.org/api/vscode/npm/1.66.2/file/vscode.npm-1.66.2.vsix"
},
"theiaPluginsDir": "plugins"
}
6 changes: 5 additions & 1 deletion applications/electron-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
}
}
},
"theiaPlugins": {},
"theiaPlugins": {
"vscode.json-1.66.2": "https://open-vsx.org/api/vscode/json/1.66.2/file/vscode.json-1.66.2.vsix",
"vscode.json-language-features-1.66.2": "https://open-vsx.org/api/vscode/json-language-features/1.66.2/file/vscode.json-language-features-1.66.2.vsix",
"vscode.npm-1.66.2": "https://open-vsx.org/api/vscode/npm/1.66.2/file/vscode.npm-1.66.2.vsix"
},
"theiaPluginsDir": "plugins"
}
11 changes: 0 additions & 11 deletions examples/examples.theia-workspace

This file was deleted.

3 changes: 3 additions & 0 deletions examples/libraries/entities/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
registry=http://localhost:4873/
//localhost:4873/:_authToken="fooBar"
always-auth=true
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions examples/libraries/entities/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "@crossbreeze/entities",
"version": "1.0.0"
}
3 changes: 3 additions & 0 deletions examples/libraries/example-library/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
registry=http://localhost:4873/
//localhost:4873/:_authToken="fooBar"
always-auth=true
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
entity C {
entity B {
description := "hello";
}
7 changes: 7 additions & 0 deletions examples/libraries/example-library/entities/entityC.cm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
entity C {
description := "hello";
attributes {
name := 'A';
}
}

File renamed without changes.
4 changes: 4 additions & 0 deletions examples/libraries/example-library/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "@crossbreeze/example-library",
"version": "1.0.0"
}
24 changes: 24 additions & 0 deletions examples/libraries/example-library/views/system.diagram.cm
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diagram {
node nodeA for A {
x := 10;
y := 10;
width := 76;
height := 32;
};
node nodeB for B {
x := 122;
y := 8;
width := 70;
height := 37;
};
node nodeD for D {
x := 222;
y := 11;
width := 77;
height := 33;
};
edge aToB for aToB {
source := nodeA;
target := nodeB;
};
}
3 changes: 3 additions & 0 deletions examples/libraries/relationships/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
registry=http://localhost:4873/
//localhost:4873/:_authToken="fooBar"
always-auth=true
5 changes: 5 additions & 0 deletions examples/libraries/relationships/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "@crossbreeze/relationships",
"version": "1.0.0",
"dependencies": { "@crossbreeze/entities": "1.0.0" }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
relationship aToB {
source := @crossbreeze/entities@1-0-0_A;
target := @crossbreeze/entities@1-0-0_B;
type := 1:1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
relationship cToD {
source := @crossbreeze/entities@1-0-0_C with @crossbreeze/entities@1-0-0_C.name;
target := @crossbreeze/entities@1-0-0_D;
type := 1:n;
}
3 changes: 3 additions & 0 deletions examples/libraries/system/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
registry=http://localhost:4873/
//localhost:4873/:_authToken="fooBar"
always-auth=true
3 changes: 3 additions & 0 deletions examples/libraries/system/entities/entityE.cm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
entity E {
description := "hello";
}
5 changes: 5 additions & 0 deletions examples/libraries/system/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "@crossbreeze/system",
"version": "1.0.0",
"dependencies": { "@crossbreeze/relationships": "1.0.0" }
}
24 changes: 24 additions & 0 deletions examples/libraries/system/views/system.diagram.cm
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diagram {
node nodeA for @crossbreeze/entities@1-0-0_A {
x := 10;
y := 10;
width := 76;
height := 32;
};
node nodeB for @crossbreeze/entities@1-0-0_B {
x := 122;
y := 8;
width := 70;
height := 37;
};
node nodeD for E {
x := 222;
y := 11;
width := 77;
height := 33;
};
edge aToB for @crossbreeze/relationships@1-0-0_aToB {
source := nodeA;
target := nodeB;
};
}
1 change: 1 addition & 0 deletions examples/registry/.verdaccio-db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"list":["@crossbreeze/example-library","@crossbreeze/entities","@crossbreeze/relationships","@crossbreeze/system"],"secret":"60c39cc34e5c891842c84a74f177baa1cc229cc7a7d8594242f9ec131f7573ba"}
Binary file not shown.
39 changes: 39 additions & 0 deletions examples/registry/@crossbreeze/entities/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "@crossbreeze/entities",
"versions": {
"1.0.0": {
"name": "@crossbreeze/entities",
"version": "1.0.0",
"gitHead": "04c8aaff5b1ab8919446643ad34705bbb483004e",
"_id": "@crossbreeze/[email protected]",
"_nodeVersion": "16.19.1",
"_npmVersion": "8.19.3",
"dist": {
"integrity": "sha512-vBdcse9+d+Pn39iyz5R+MuGUSmxc1d9NR7/8UZqHwmhloSa9cgfkWOLRtSF6ygot0U+n+j6C0Ft3RjlDx+RcfA==",
"shasum": "bcab1949357f3d2200608c1a22e53a28e4731673",
"tarball": "http://localhost:4873/@crossbreeze/entities/-/@crossbreeze/entities-1.0.0.tgz"
},
"contributors": []
}
},
"time": {
"modified": "2023-03-08T19:16:17.040Z",
"created": "2023-03-08T19:16:17.040Z",
"1.0.0": "2023-03-08T19:16:17.040Z"
},
"users": {},
"dist-tags": {
"latest": "1.0.0"
},
"_uplinks": {},
"_distfiles": {},
"_attachments": {
"entities-1.0.0.tgz": {
"shasum": "bcab1949357f3d2200608c1a22e53a28e4731673",
"version": "1.0.0"
}
},
"_rev": "3-8ff6fa263a2d326b",
"_id": "@crossbreeze/entities",
"readme": "ERROR: No README data found!"
}
Binary file not shown.
39 changes: 39 additions & 0 deletions examples/registry/@crossbreeze/example-library/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "@crossbreeze/example-library",
"versions": {
"1.0.0": {
"name": "@crossbreeze/example-library",
"version": "1.0.0",
"gitHead": "04c8aaff5b1ab8919446643ad34705bbb483004e",
"_id": "@crossbreeze/[email protected]",
"_nodeVersion": "16.19.1",
"_npmVersion": "8.19.3",
"dist": {
"integrity": "sha512-61sJCOXPB6KB9NyaI0JnAT+Y2OfZrb33MMeV2006pntb0B7TDKcHkYPnN4w9gFGUdRnNFp61k7vLCyUAl8zOUQ==",
"shasum": "90c05db207fc2621ec1a2aa9ea9052ba98cb24c0",
"tarball": "http://localhost:4873/@crossbreeze/example-library/-/@crossbreeze/example-library-1.0.0.tgz"
},
"contributors": []
}
},
"time": {
"modified": "2023-03-08T19:14:02.451Z",
"created": "2023-03-08T19:14:02.451Z",
"1.0.0": "2023-03-08T19:14:02.451Z"
},
"users": {},
"dist-tags": {
"latest": "1.0.0"
},
"_uplinks": {},
"_distfiles": {},
"_attachments": {
"example-library-1.0.0.tgz": {
"shasum": "90c05db207fc2621ec1a2aa9ea9052ba98cb24c0",
"version": "1.0.0"
}
},
"_rev": "3-5ae5b718d1b2503f",
"_id": "@crossbreeze/example-library",
"readme": "ERROR: No README data found!"
}
42 changes: 42 additions & 0 deletions examples/registry/@crossbreeze/relationships/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "@crossbreeze/relationships",
"versions": {
"1.0.0": {
"name": "@crossbreeze/relationships",
"version": "1.0.0",
"dependencies": {
"@crossbreeze/entities": "1.0.0"
},
"gitHead": "04c8aaff5b1ab8919446643ad34705bbb483004e",
"_id": "@crossbreeze/[email protected]",
"_nodeVersion": "16.19.1",
"_npmVersion": "8.19.3",
"dist": {
"integrity": "sha512-xQTnINR1RR2B2HFVtU0rETlzIg0monRKxL3EXlB4saXasBiq4VTDL1LOjQ59Y/J09JZ9ESXl7ahqHH0+D3yIIg==",
"shasum": "cfe226ce35ef93861aefece1506dad6183842608",
"tarball": "http://localhost:4873/@crossbreeze/relationships/-/@crossbreeze/relationships-1.0.0.tgz"
},
"contributors": []
}
},
"time": {
"modified": "2023-03-08T19:18:01.564Z",
"created": "2023-03-08T19:18:01.564Z",
"1.0.0": "2023-03-08T19:18:01.564Z"
},
"users": {},
"dist-tags": {
"latest": "1.0.0"
},
"_uplinks": {},
"_distfiles": {},
"_attachments": {
"relationships-1.0.0.tgz": {
"shasum": "cfe226ce35ef93861aefece1506dad6183842608",
"version": "1.0.0"
}
},
"_rev": "3-c527784b438a9861",
"_id": "@crossbreeze/relationships",
"readme": "ERROR: No README data found!"
}
Binary file not shown.
42 changes: 42 additions & 0 deletions examples/registry/@crossbreeze/system/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "@crossbreeze/system",
"versions": {
"1.0.0": {
"name": "@crossbreeze/system",
"version": "1.0.0",
"dependencies": {
"@crossbreeze/relationships": "1.0.0"
},
"gitHead": "04c8aaff5b1ab8919446643ad34705bbb483004e",
"_id": "@crossbreeze/[email protected]",
"_nodeVersion": "16.19.1",
"_npmVersion": "8.19.3",
"dist": {
"integrity": "sha512-YCyLc7Mp+g9O2CGYahPGAHVuLfq1aD02w7++dhRo02JrFgg2qTSoEn9t6CXcnsTWLy+Y2vZ4XjX8yODjMZvkRg==",
"shasum": "df078510ff479d45ca193e812a7946d19cd9fc25",
"tarball": "http://localhost:4873/@crossbreeze/system/-/@crossbreeze/system-1.0.0.tgz"
},
"contributors": []
}
},
"time": {
"modified": "2023-03-08T19:21:18.988Z",
"created": "2023-03-08T19:21:18.988Z",
"1.0.0": "2023-03-08T19:21:18.988Z"
},
"users": {},
"dist-tags": {
"latest": "1.0.0"
},
"_uplinks": {},
"_distfiles": {},
"_attachments": {
"system-1.0.0.tgz": {
"shasum": "df078510ff479d45ca193e812a7946d19cd9fc25",
"version": "1.0.0"
}
},
"_rev": "3-54b73fe736964d2f",
"_id": "@crossbreeze/system",
"readme": "ERROR: No README data found!"
}
Binary file not shown.
Loading

0 comments on commit 27eb2ef

Please sign in to comment.