Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: refactor into monorepo with compile and cli packages #192

Merged
merged 34 commits into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6286bd8
refactor: drop support for web app generation (--genhtml) and related…
chrispcampbell Jun 4, 2022
a578827
docs: remove mention of --genhtml feature from README
chrispcampbell Jun 4, 2022
b63f25b
build: add top-level scripts
chrispcampbell Jun 4, 2022
13f30cc
test: move integration tests to top level
chrispcampbell Jun 4, 2022
90ded07
refactor: move existing sdeverywhere packages sources into new compil…
chrispcampbell Jun 4, 2022
fbe337a
fix: drop code related to --genhtml
chrispcampbell Jun 4, 2022
2adcd2e
refactor: move helper functions that are dependent on shelljs to cli …
chrispcampbell Jun 5, 2022
35f7a71
refactor: export parseModel from compile package so that cli doesn't …
chrispcampbell Jun 5, 2022
d712273
refactor: move modelPathProps function to cli package
chrispcampbell Jun 5, 2022
5671fb6
refactor: export readDat from compile package
chrispcampbell Jun 5, 2022
d46caf1
refactor: export preprocessModel from compile package
chrispcampbell Jun 5, 2022
42539cc
refactor: move buildDir and outputDir helpers to cli package and drop…
chrispcampbell Jun 5, 2022
3900ef7
refactor: export canonicalName function from compile package
chrispcampbell Jun 5, 2022
99ca71b
refactor: export generateCode function from compile package (shorter …
chrispcampbell Jun 5, 2022
755dc83
refactor: use new createParser function to reduce repeated boilerplate
chrispcampbell Jun 5, 2022
7cbfe50
refactor: drop unused digraph-sort dependency
chrispcampbell Jun 5, 2022
76f2a30
refactor: move core parse-and-generate steps from sde-generate.js to …
chrispcampbell Jun 6, 2022
a2d7e68
fix: remove unused code in sde-causes.js
chrispcampbell Jun 6, 2022
4e05f36
fix: add createParser import that was missing from an earlier commit
chrispcampbell Jun 6, 2022
11bf388
refactor: define parseSpec once instead of having it duplicated in 3 …
chrispcampbell Jun 6, 2022
e17ec02
refactor: simplify write call
chrispcampbell Jun 6, 2022
bd35af5
refactor: move implementation of sde-names to compile package to avoi…
chrispcampbell Jun 6, 2022
3d66c81
fix: make parseAndGenerate async
chrispcampbell Jun 6, 2022
34108c4
build: add minimal ci:build script for both packages
chrispcampbell Jun 6, 2022
93018fd
test: fix path to sde command in tests
chrispcampbell Jun 6, 2022
bd95466
build: re-enable test step in ci-build
chrispcampbell Jun 6, 2022
0419dcd
build: restore fs-extra dependency, since we need it in one place in …
chrispcampbell Jun 6, 2022
6b68706
fix: correct issues with imports
chrispcampbell Jun 6, 2022
350bdb7
fix: update yargs usage to handle new package layout
chrispcampbell Jun 6, 2022
7ee9271
build: update yargs to latest and add package.json for tests directory
chrispcampbell Jun 6, 2022
ab2faf1
docs: update README to account for new cli package
chrispcampbell Jun 6, 2022
9655c5e
fix: correct causes command spec to account for case sensitivity
chrispcampbell Jun 6, 2022
3674574
fix: update clean command since html dir is no longer created by sde
chrispcampbell Jun 6, 2022
a68fc8c
fix: remove export of createParser (does not need to be part of publi…
chrispcampbell Jun 6, 2022
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
5 changes: 2 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ jobs:
run: |
pnpm install

- name: Run tests
- name: Build and test
run: |
pnpm prettier:check
pnpm test
./scripts/ci-build
6 changes: 2 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ jobs:
run: |
pnpm install

- name: Build
id: build
- name: Build and test
run: |
pnpm prettier:check
pnpm test
./scripts/ci-build

# Save the npmjs auth token so that the workflow can publish packages to the registry
- name: Configure npm auth token
Expand Down
3 changes: 0 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
src/web
.vscode
CHANGELOG.md
pnpm-lock.yaml
3 changes: 2 additions & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
".": "0.6.0"
"packages/compile": "0.6.0",
"packages/cli": "0.6.0"
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016-19 Todd Fincannon and Climate Interactive/New Venture Fund
Copyright (c) 2016-2022 Todd Fincannon and Climate Interactive / New Venture Fund

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
19 changes: 4 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ If you want to use the stable release of SDEverywhere, simply install the npm pa
**Install the stable release version of SDEverywhere**

```
npm install sdeverywhere -g
npm install @sdeverywhere/cli -g
```

**Install the development version of SDEverywhere**

If you previously installed the SDEverywhere package using npm, uninstall that package first before installing your new, local copy.

```
npm rm sdeverywhere -g
npm rm @sdeverywhere/cli -g
```

Clone the `SDEverywhere` and `antlr4-vensim` repos in a project directory of your choice using either `git` on the command line or Sourcetree (see below).
Expand Down Expand Up @@ -287,17 +287,6 @@ sde test {model}
sde clean {model}
```

**Generate a web app to run the model and graph the results**

Note that the `generate --genhtml` command currently uses [Browserify](http://browserify.org)
to bundle the web app. The `browserify` package is not included with SDEverywhere by
default, so you will need to install it first as a dev dependency.

```
npm install --save-dev browserify
sde generate --genhtml {model}
```

**Print variable dependencies**

```
Expand Down Expand Up @@ -406,7 +395,7 @@ SDEverywhere covers a subset of the Vensim modeling language used in models that

If you are using Atom, you can run the Chrome debugger inside Atom using the [Atom IDE](https://ide.atom.io/).

To run in the Chrome debugger, start Node with the `--inspect-brk` flag. Use `node sde.js` from the SDEverywhere `src` directory.
To run in the Chrome debugger, start Node with the `--inspect-brk` flag. Use `node main.js` from the `packages/cli/src` directory.

[Debugging Node.js with Chrome DevTools](https://medium.com/@paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27)

Expand Down Expand Up @@ -442,7 +431,7 @@ The `Variable` class is the heart of SDEverywhere. An equation has a left-hand s

### Parsing

The `sdegen` command reads the model file, an optional model spec JSON file detailing input and output variables, and an optional subscript JSON file detailing dimensions, indices, and mappings. Each file is parsed and then handed off to the `CodeGen` object.
The `sde generate` command reads the model file, an optional model spec JSON file detailing input and output variables, and an optional subscript JSON file detailing dimensions, indices, and mappings. Each file is parsed and then handed off to the `CodeGen` object.

The model file is parsed using a grammar generated by [ANTLR 4](http://www.antlr.org/). The parser constructs a parse tree that the code generator works with. The model file is passed through a preprocessor first to handle some things the grammar can't work with yet, such as macros and tabbed arrays. See the [antlr4-vensim](https://github.com/climateinteractive/antlr4-vensim) package for more on the parser.

Expand Down
2 changes: 1 addition & 1 deletion models/comments/comments_check.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

MODEL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SDE='node ../../src/sde.js'
SDE='node ../../packages/cli/src/main.js'

cd $MODEL_DIR
$SDE generate --preprocess comments.mdl
Expand Down
2 changes: 1 addition & 1 deletion models/flatten/flatten_check.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

MODEL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SDE='node ../../src/sde.js'
SDE='node ../../packages/cli/src/main.js'

cd $MODEL_DIR
$SDE flatten output.mdl --inputs input1.mdl input2.mdl
Expand Down
2 changes: 1 addition & 1 deletion models/preprocess/preprocess_check.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

MODEL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SDE='node ../../src/sde.js'
SDE='node ../../packages/cli/src/main.js'

cd $MODEL_DIR
$SDE generate --preprocess input.mdl
Expand Down
111 changes: 0 additions & 111 deletions notes/SDEverywhere Web App Configuration Reference.md

This file was deleted.

Binary file not shown.
1 change: 0 additions & 1 deletion notes/config/app.csv

This file was deleted.

6 changes: 0 additions & 6 deletions notes/config/colors.csv

This file was deleted.

1 change: 0 additions & 1 deletion notes/config/graphs.csv

This file was deleted.

1 change: 0 additions & 1 deletion notes/config/sliders.csv

This file was deleted.

1 change: 0 additions & 1 deletion notes/config/views.csv

This file was deleted.

50 changes: 17 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,30 @@
{
"name": "sdeverywhere",
"version": "0.6.0",
"name": "sdeverywhere-monorepo",
"private": true,
"description": "SDEverywhere translates System Dynamics models from Vensim to C and WebAssembly",
"type": "module",
"files": [
"src/**",
"!.DS_Store"
],
"bin": {
"sde": "src/index.js"
},
"scripts": {
"prettier:check": "prettier --check .",
"prettier:fix": "prettier --write .",
"test": "cd src/tests && ./modeltests"
},
"dependencies": {
"antlr4": "4.9.2",
"antlr4-vensim": "0.6.0",
"bufx": "^1.0.5",
"byline": "^5.0.0",
"chart.js": "^2.9.4",
"csv-parse": "^4.15.4",
"digraph-sort": "^0.2.1",
"fs-extra": "^9.0.0",
"he": "^1.2.0",
"js-yaml": "^3.13.1",
"minimist": "^1.2.5",
"numbro": "1.11.1",
"ramda": "^0.27.0",
"shelljs": "^0.8.3",
"split-string": "^6.0.0",
"xlsx": "^0.17.0",
"yargs": "^17.2.1"
"clean": "pnpm -r clean",
"lint-pkgs": "pnpm -r lint",
"lint": "pnpm lint-pkgs",
"prettier-local:check": "prettier --check \"./*.{js,json,md,yaml}\"",
"prettier-local:fix": "prettier --write \"./*.{js,json,md,yaml}\"",
"prettier-pkgs:check": "pnpm -r prettier:check",
"prettier-pkgs:fix": "pnpm -r prettier:fix",
"prettier:check": "run-s prettier-local:check prettier-pkgs:check",
"prettier:fix": "run-s prettier-local:fix prettier-pkgs:fix",
"precommit": "pnpm -r precommit",
"build": "pnpm run -r --workspace-concurrency=1 build",
"test:e2e": "./tests/modeltests",
"test": "run-s test:e2e"
},
"devDependencies": {
"prettier": "^2.3.2"
"npm-run-all": "^4.1.5",
"prettier": "^2.6.2"
},
"author": "Climate Interactive",
"license": "MIT",
"homepage": "https://sdeverywhere.org",
"readmeFilename": "README.md",
"repository": {
"type": "git",
"url": "https://github.com/climateinteractive/SDEverywhere.git"
Expand Down
1 change: 1 addition & 0 deletions packages/cli/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHANGELOG.md
File renamed without changes.
14 changes: 14 additions & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# @sdeverywhere/cli

This package contains the `sde` command line interface for the SDEverywhere
suite of tools.

SDEverywhere can be used to translate System Dynamics models from Vensim to C and WebAssembly.

## Documentation

TODO

## License

SDEverywhere is distributed under the MIT license. See `LICENSE` for more details.
40 changes: 40 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@sdeverywhere/cli",
"version": "0.7.0",
"description": "Contains the `sde` command line interface for the SDEverywhere tool suite.",
"type": "module",
"files": [
"src/**",
"!.DS_Store"
],
"bin": {
"sde": "src/main.js"
},
"scripts": {
"lint": "echo No lint step yet",
"prettier:check": "prettier --check .",
"prettier:fix": "prettier --write .",
"precommit": "../../scripts/precommit",
"ci:build": "run-s lint prettier:check"
},
"dependencies": {
"@sdeverywhere/compile": "^0.7.0",
"bufx": "^1.0.5",
"byline": "^5.0.0",
"fs-extra": "^10.1.0",
"ramda": "^0.27.0",
"shelljs": "^0.8.3",
"yargs": "^17.5.1"
},
"author": "Climate Interactive",
"license": "MIT",
"homepage": "https://sdeverywhere.org",
"repository": {
"type": "git",
"url": "https://github.com/climateinteractive/SDEverywhere.git",
"directory": "packages/cli"
},
"bugs": {
"url": "https://github.com/climateinteractive/SDEverywhere/issues"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading