Skip to content

Commit

Permalink
Merge pull request #27 from mdvanes/feature/dockerlist
Browse files Browse the repository at this point in the history
Feature/dockerlist
  • Loading branch information
mdvanes authored May 23, 2021
2 parents 3db1535 + f97d361 commit c5989a4
Show file tree
Hide file tree
Showing 42 changed files with 5,146 additions and 3,609 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ lerna-debug.log*

# Dependency directories
/node_modules/
/packages/*/node_modules/.bin

# dotenv environment variables file
.env
Expand All @@ -27,3 +28,5 @@ repl-temp-*

/old
/storybook-static

/packages/dockerlist-client/lib
2 changes: 1 addition & 1 deletion .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = {
webpackFinal: (config) => {
const {
module: {
rules: [, , , , , , { oneOf }],
rules: [, , , , , { oneOf }],
},
} = config;
const babelLoader = oneOf.find(({ test }) =>
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Server: [/packages/server](/packages/server)
* `yarn build`
* `yarn validate`
* commit changes (lib dirs should eventually be in git ignore)
* optionally: `lerna changed`
* `lerna publish`
* optionally: `yarn lerna changed`
* `yarn lerna publish`
* on each push to the main branch, CI builds and publishes storybook, see .github/workflows

## Running
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "1.6.3",
"version": "1.7.1",
"npmClient": "yarn",
"useWorkspaces": true
}
18 changes: 18 additions & 0 deletions mocks/api/dockerlist/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"status": "received",
"containers": [
{
"Id": "245425425245afafaffaaafaffaaffaa43542524524524524542542444452532",
"Names": ["/determined_edison"],
"State": "running",
"Status": "Up 11 days"
},

{
"Id": "245425425245afafaffaaafaffaaffaa43542524524524524542542444452531",
"Names": ["/hello_world"],
"State": "exited",
"Status": "Exited (0) 42 hours ago"
}
]
}
41 changes: 21 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,30 @@
"name": "root",
"private": true,
"devDependencies": {
"@babel/core": "^7.12.3",
"@storybook/addon-actions": "^6.0.28",
"@storybook/addon-controls": "^6.0.28",
"@storybook/addon-essentials": "^6.0.28",
"@storybook/addon-links": "^6.0.28",
"@storybook/addon-storysource": "^6.0.28",
"@storybook/addons": "^6.0.28",
"@storybook/node-logger": "^6.0.28",
"@storybook/preset-create-react-app": "^3.1.4",
"@storybook/react": "^6.0.28",
"@storybook/source-loader": "^6.0.28",
"@storybook/theming": "^6.0.28",
"@testing-library/dom": "^7.26.5",
"@testing-library/jest-dom": "^5.11.5",
"@testing-library/react": "^11.1.1",
"@testing-library/user-event": "^12.2.0",
"@babel/core": "^7.14.3",
"@storybook/addon-actions": "^6.2.9",
"@storybook/addon-controls": "^6.2.9",
"@storybook/addon-essentials": "^6.2.9",
"@storybook/addon-links": "^6.2.9",
"@storybook/addon-storysource": "^6.2.9",
"@storybook/addons": "^6.2.9",
"@storybook/node-logger": "^6.2.9",
"@storybook/preset-create-react-app": "^3.1.7",
"@storybook/react": "^6.2.9",
"@storybook/source-loader": "^6.2.9",
"@storybook/theming": "^6.2.9",
"@testing-library/dom": "^7.31.0",
"@testing-library/jest-dom": "^5.12.0",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^13.1.9",
"@types/express": "^4.17.8",
"@types/jest": "^26.0.15",
"@typescript-eslint/eslint-plugin": "^4.6.1",
"@typescript-eslint/parser": "^4.6.1",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.1.0",
"babel-loader": "^8.2.2",
"babel-plugin-polyfill-corejs2": "^0.2.1",
"babel-plugin-polyfill-regenerator": "^0.2.1",
"babel-preset-react-app": "^10.0.0",
"concurrently": "^5.3.0",
"elm": "^0.19.1-3",
Expand All @@ -40,7 +42,6 @@
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"jest": "26.6.3",
"jest-environment-jsdom-fourteen": "1.0.1",
"jest-resolve": "26.6.2",
"jest-watch-typeahead": "0.6.1",
"lerna": "^3.20.2",
Expand All @@ -51,7 +52,7 @@
"react-dom": "^16.13.1",
"react-elm-components": "^1.1.0",
"react-is": "^16.13.1",
"react-scripts": "3.4.4",
"react-scripts": "^4.0.3",
"serve": "^11.3.2",
"ts-jest": "^26.4.3",
"ts-node": "^9.0.0",
Expand All @@ -60,7 +61,7 @@
"webpack-cli": "^4.2.0"
},
"scripts": {
"start": "concurrently -c \"blue,magenta\" \"npm:storybook\" \"npm:storybook:api\"",
"start": "concurrently -c \"blue,magenta,green\" \"npm:storybook -- --quiet\" \"npm:storybook:api\" \"cd packages/dockerlist-client && yarn re:start\"",
"storybook": "start-storybook -p 6006 --ci",
"storybook:api": "ts-node storybookMockServer.ts --CORS=debug",
"build-storybook": "STORYBOOK_MODE=PROD build-storybook -s mocks",
Expand Down
1 change: 1 addition & 0 deletions packages/dockerlist-client/.bsb.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
398540
14 changes: 14 additions & 0 deletions packages/dockerlist-client/.merlin
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
####{BSB GENERATED: NO EDIT
B lib/bs
FLG -open MdworldHomeremoteDockerlist
FLG -ppx '/home/martin/ZNoBackup/repos/homeremote-plugins/node_modules/rescript/linux/bsc.exe -as-ppx -bs-jsx 3'
S /home/martin/ZNoBackup/repos/homeremote-plugins/node_modules/rescript/lib/ocaml
B /home/martin/ZNoBackup/repos/homeremote-plugins/node_modules/rescript/lib/ocaml
FLG -w +a-4-9-20-40-41-42-50-61-102
S /home/martin/ZNoBackup/repos/homeremote-plugins/node_modules/@rescript/react/lib/ocaml
B /home/martin/ZNoBackup/repos/homeremote-plugins/node_modules/@rescript/react/lib/ocaml
S /home/martin/ZNoBackup/repos/homeremote-plugins/node_modules/bs-fetch/lib/ocaml
B /home/martin/ZNoBackup/repos/homeremote-plugins/node_modules/bs-fetch/lib/ocaml
S src
B lib/bs/src
####BSB GENERATED: NO EDIT}
2 changes: 2 additions & 0 deletions packages/dockerlist-client/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src
stories
39 changes: 39 additions & 0 deletions packages/dockerlist-client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# homeremote-stream-player

Show a list of docker containers and start or stop them

See https://github.com/mdvanes/homeremote/issues/9

## How this project was set up

- nvm use 15
- copied package.json from other client package in the monorepo
- `yarn lerna add rescript -D --scope=@mdworld/homeremote-dockerlist`
- add bsconfig.json following https://rescript-lang.org/docs/manual/latest/installation#integrate-into-an-existing-js-project
- add `"re:build": "rescript", "re:start": "rescript build -w"` to package.json/scripts
- create a file /packages/dockerlist-client/src/Test.res with the button example from https://rescript-lang.org/try
- in /packages/dockerlist-client run `yarn re:build`
- now get an error that is probably caused because rescript-react is not yet installed, see https://rescript-lang.org/docs/react/latest/introduction
- compilation indeed does work, when Test.res only contains `Js.log("Hello, World!")`
- Add rescript-react: `yarn lerna add @rescript/react --scope=@mdworld/homeremote-dockerlist`
- Add {
"reason": { "react-jsx": 3 },
"bs-dependencies": ["@rescript/react"]
} in bsconfig.json
- in /packages/dockerlist-client run `yarn re:build`
- Add fetch to endpoint: `yarn lerna add bs-fetch --scope=@mdworld/homeremote-dockerlist` and add to bsconfig.json: "bs-dependencies": ["bs-fetch"]

## Running

- dev: run in root: `yarn start` and it will start storybook, mock api, and `yarn re:start` (in this dir)

## TODO

- Fix building, exclude "dist" from the build?
- Add DockerList to the Example app
- For now XHR works in Rescript, but Fetch only works in Reason files. Mainly decoding the JSON fails, even with "@glennsl/bs-json"
- Material UI bindings seem very unstable: https://jsiebern.github.io/bs-material-ui Adding it breaks the build sometimes
- Clean up old Elm deps from package.json
- Builders (like webpack) are discouraged: https://rescript-lang.org/docs/manual/latest/interop-with-js-build-systems
- Snowpack build to `dist` dir like in https://github.com/jihchi/rescript-react-realworld-example-app/blob/main/package.json https://www.snowpack.dev/
- Storybook like in https://raw.githubusercontent.com/elfsternberg/doc-rescript-with-storybook/main/src/stories/02_Noncard.stories.mdx
22 changes: 22 additions & 0 deletions packages/dockerlist-client/bsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "@mdworld/homeremote-dockerlist",
"sources": [
{
"dir": "src",
"subdirs": true
}
],
"package-specs": [
{
"module": "commonjs",
"in-source": true
}
],
"suffix": ".bs.js",
"reason": { "react-jsx": 3 },
"bs-dependencies": ["@rescript/react", "bs-fetch"],
"namespace": true,
"gentypeconfig": {
"language": "typescript"
}
}
99 changes: 99 additions & 0 deletions packages/dockerlist-client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"name": "@mdworld/homeremote-dockerlist",
"version": "1.7.1",
"main": "./src/DockerList.bs.js",
"types": "./src/DockerList.gen.tsx",
"repository": {
"type": "git",
"url": "https://github.com/mdvanes/homeremote-plugins.git"
},
"scripts": {
"clean": "rm src/*.bs.js && rm src/*.gen.tsx",
"build": "yarn re:build",
"re:build": "rescript",
"re:start": "rescript build -w"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"jest": {
"roots": [
"<rootDir>/src"
],
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts"
],
"setupFiles": [
"react-app-polyfill/jsdom"
],
"setupFilesAfterEnv": [
"<rootDir>/src/setupTests.js"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
],
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$"
],
"modulePaths": [
"/usr/lib/nodejs",
"/usr/lib/node_modules",
"/usr/share/javascript"
],
"moduleNameMapper": {
"^react-native$": "react-native-web",
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"web.js",
"js",
"web.ts",
"ts",
"web.tsx",
"tsx",
"json",
"web.jsx",
"jsx",
"node"
],
"watchPlugins": [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname"
]
},
"babel": {
"presets": [
"react-app"
]
},
"license": "MIT",
"gitHead": "1c79d816ed2921cfe7c8a6a64fd84a339984f774",
"publishConfig": {
"access": "public"
},
"devDependencies": {
"gentype": "^3.50.0",
"rescript": "^9.1.2"
},
"dependencies": {
"@rescript/react": "^0.10.3",
"bs-fetch": "^0.6.2"
}
}
56 changes: 56 additions & 0 deletions packages/dockerlist-client/src/ButtonWithConfirm.bs.js

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

Loading

0 comments on commit c5989a4

Please sign in to comment.