From 4c7c2aff5181a10d37222582910c302f0cf09a97 Mon Sep 17 00:00:00 2001 From: Samuel Weibel Date: Thu, 24 Sep 2020 15:13:57 +0200 Subject: [PATCH 1/3] Simplified parcel polling by using built-in Chokidar polling. --- CHANGELOG.md | 2 + docs/updates/20200924_devcontainer_parcel.md | 62 +++++++++++++++++++ templates/_devcontainer/docker-compose.yml.ts | 2 + templates/_devcontainer/parcel/_Dockerfile.ts | 3 - templates/_devcontainer/parcel/run-sync.sh.ts | 21 ------- templates/_devcontainer/parcel/run.sh.ts | 10 +-- templates/_devcontainer/parcel/sync.sh.ts | 17 ----- templates/index.ts | 2 - 8 files changed, 68 insertions(+), 51 deletions(-) create mode 100644 docs/updates/20200924_devcontainer_parcel.md delete mode 100644 templates/_devcontainer/parcel/run-sync.sh.ts delete mode 100644 templates/_devcontainer/parcel/sync.sh.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 3919d2b0..69e837e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ ## __WORK IN PROGRESS__ (at the beginning of a new line ) --> +## __WORK IN PROGRESS__ +* (UncleSamSwiss) Remove rsync from parcel devcontainer · [Migration guide](docs/updates/20200924_devcontainer_parcel.md) ## 1.29.0 (2020-09-22) * (AlCalzone) Add Badge for Github Actions to Readme (#585) diff --git a/docs/updates/20200924_devcontainer_parcel.md b/docs/updates/20200924_devcontainer_parcel.md new file mode 100644 index 00000000..6e0d5f3d --- /dev/null +++ b/docs/updates/20200924_devcontainer_parcel.md @@ -0,0 +1,62 @@ +# Remove rsync from parcel devcontainer + +This migration is **only relevant** if you're using a **React UI** for Admin. + +Since the introduction of [VSCode devcontainers](./20200902_vscode_devcontainers.md) we were using our own file system polling for the `parcel` container. +Because parcel (or rather Chokidar) supports polling, the container setup can be simplified. + +## Simple migration + +- Recreate the `.devcontainer` folder or copy it from the template on GitHub +- Replace the `parcel` container definition in `./.devcontainers/docker-compose.yml` with the newly created +- Delete the folder `./.devcontainers/parcel` and replace it with the newly generated folder of the same name +- Rebuild the remote container with the following command in VS Code: + `Remote-Containers: Rebuild Container` + +## Manual migration + +- Change the `parcel` section of `./.devcontainers/docker-compose.yml` to the following (add the environment variable `CHOKIDAR_USEPOLLING`): + +```yml +parcel: + container_name: parcel- + build: ./parcel + expose: + - 1234 + ports: + - "1235:1235" + volumes: + - ..:/workspace:cached + environment: + - CHOKIDAR_USEPOLLING=1 +``` + +- Remove the following two scripts in `./.devcontainers/parcel/` + - `run-sync.sh` + - `sync.sh` +- Change `./.devcontainers/parcel/run.sh` to contain the following: + +```bash +#!/bin/bash +cd /workspace + +echo "Installing all dependencies..." +npm install + +npm run watch:parcel +``` + +- Change `./.devcontainers/parcel/Dockerfile` to contain the following: + +```Dockerfile +FROM node:12 + +RUN mkdir -p /usr/app + +COPY *.sh /usr/app/ + +CMD /bin/bash -c "/usr/app/run.sh" +``` + +- Rebuild the remote container with the following command in VS Code: + `Remote-Containers: Rebuild Container` diff --git a/templates/_devcontainer/docker-compose.yml.ts b/templates/_devcontainer/docker-compose.yml.ts index 1784a1e7..5c1fa09e 100644 --- a/templates/_devcontainer/docker-compose.yml.ts +++ b/templates/_devcontainer/docker-compose.yml.ts @@ -38,6 +38,8 @@ ${needsParcel ? (` - '1235:1235' volumes: - ..:/workspace:cached + environment: + - CHOKIDAR_USEPOLLING=1 `) : ""} # Reverse proxy to load up-to-date admin sources from the repo nginx: diff --git a/templates/_devcontainer/parcel/_Dockerfile.ts b/templates/_devcontainer/parcel/_Dockerfile.ts index 40ba7a9f..e37eafce 100644 --- a/templates/_devcontainer/parcel/_Dockerfile.ts +++ b/templates/_devcontainer/parcel/_Dockerfile.ts @@ -8,10 +8,7 @@ const templateFunction: TemplateFunction = answers => { const template = ` FROM node:12 -RUN apt-get update && apt-get install -y rsync - RUN mkdir -p /usr/app -RUN mkdir -p /usr/workspace COPY *.sh /usr/app/ diff --git a/templates/_devcontainer/parcel/run-sync.sh.ts b/templates/_devcontainer/parcel/run-sync.sh.ts deleted file mode 100644 index e1f59e32..00000000 --- a/templates/_devcontainer/parcel/run-sync.sh.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { TemplateFunction } from "../../../src/lib/createAdapter"; - -const templateFunction: TemplateFunction = answers => { - - const devcontainer = answers.tools && answers.tools.includes("devcontainer"); - if (!devcontainer) return; - - const template = ` -#!/bin/bash -while : -do - /usr/app/sync.sh - sleep 1 -done -`; - return template.trim(); -}; - -templateFunction.customPath = ".devcontainer/parcel/run-sync.sh"; -templateFunction.noReformat = true; -export = templateFunction; diff --git a/templates/_devcontainer/parcel/run.sh.ts b/templates/_devcontainer/parcel/run.sh.ts index b343ab66..bc71bd82 100644 --- a/templates/_devcontainer/parcel/run.sh.ts +++ b/templates/_devcontainer/parcel/run.sh.ts @@ -7,18 +7,12 @@ const templateFunction: TemplateFunction = answers => { const template = ` #!/bin/bash -echo "Starting initial sync..." -/usr/app/sync.sh - -cd /usr/workspace +cd /workspace echo "Installing all dependencies..." npm install -# run the following two commands in parallel (honoring Ctrl-C) -# - npm run watch:parcel -# - /usr/app/run-sync.sh -(echo "npm run watch:parcel"; echo "/usr/app/run-sync.sh") | xargs -I{} -n 1 -P 2 /bin/bash -c "{}" +npm run watch:parcel `; return template.trim(); }; diff --git a/templates/_devcontainer/parcel/sync.sh.ts b/templates/_devcontainer/parcel/sync.sh.ts deleted file mode 100644 index e960bdf8..00000000 --- a/templates/_devcontainer/parcel/sync.sh.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { TemplateFunction } from "../../../src/lib/createAdapter"; - -const templateFunction: TemplateFunction = answers => { - - const devcontainer = answers.tools && answers.tools.includes("devcontainer"); - if (!devcontainer) return; - - const template = ` -#!/bin/bash -rsync -aiz --inplace --exclude={'node_modules','.git','.cache','admin/build'} /workspace/ /usr/workspace -`; - return template.trim(); -}; - -templateFunction.customPath = ".devcontainer/parcel/sync.sh"; -templateFunction.noReformat = true; -export = templateFunction; diff --git a/templates/index.ts b/templates/index.ts index efc27e3a..7d6c51e1 100644 --- a/templates/index.ts +++ b/templates/index.ts @@ -47,9 +47,7 @@ const templates: { name: string, templateFunction: TemplateFunction }[] = [ { name: "_devcontainer/docker-compose.yml.ts", templateFunction: require("./_devcontainer/docker-compose.yml") }, { name: "_devcontainer/iobroker/_Dockerfile.ts", templateFunction: require("./_devcontainer/iobroker/_Dockerfile") }, { name: "_devcontainer/nginx/nginx.conf.ts", templateFunction: require("./_devcontainer/nginx/nginx.conf") }, - { name: "_devcontainer/parcel/run-sync.sh.ts", templateFunction: require("./_devcontainer/parcel/run-sync.sh") }, { name: "_devcontainer/parcel/run.sh.ts", templateFunction: require("./_devcontainer/parcel/run.sh") }, - { name: "_devcontainer/parcel/sync.sh.ts", templateFunction: require("./_devcontainer/parcel/sync.sh") }, { name: "_devcontainer/parcel/_Dockerfile.ts", templateFunction: require("./_devcontainer/parcel/_Dockerfile") }, { name: "_devcontainer/README.md.ts", templateFunction: require("./_devcontainer/README.md") }, { name: "_eslintrc_javascript.json.ts", templateFunction: require("./_eslintrc_javascript.json") }, From 2328bb482324a28959563ba4121f4d1681303d58 Mon Sep 17 00:00:00 2001 From: Samuel Weibel Date: Thu, 24 Sep 2020 15:16:13 +0200 Subject: [PATCH 2/3] update baselines (including creator version update) --- test/baselines/TS_SingleQuotes/src/main.ts | 2 +- .../.create-adapter.json | 2 +- .../main.js | 2 +- .../.create-adapter.json | 2 +- .../main.js | 2 +- .../.create-adapter.json | 2 +- .../src/main.ts | 2 +- .../.create-adapter.json | 2 +- .../src/main.ts | 2 +- test/baselines/adapter_TS_React/.create-adapter.json | 2 +- test/baselines/adapter_TS_React/src/main.ts | 2 +- test/baselines/connectionIndicator_yes/src/main.ts | 2 +- test/baselines/customAdapterSettings/src/main.ts | 2 +- .../devcontainer/.devcontainer/parcel/Dockerfile | 3 --- .../devcontainer/.devcontainer/parcel/run-sync.sh | 6 ------ .../baselines/devcontainer/.devcontainer/parcel/run.sh | 10 ++-------- .../devcontainer/.devcontainer/parcel/sync.sh | 2 -- test/baselines/vis_Widget/.create-adapter.json | 2 +- test/baselines/vis_Widget_Travis/.create-adapter.json | 2 +- 19 files changed, 17 insertions(+), 34 deletions(-) delete mode 100644 test/baselines/devcontainer/.devcontainer/parcel/run-sync.sh delete mode 100644 test/baselines/devcontainer/.devcontainer/parcel/sync.sh diff --git a/test/baselines/TS_SingleQuotes/src/main.ts b/test/baselines/TS_SingleQuotes/src/main.ts index 9a051a8a..45b3cf33 100644 --- a/test/baselines/TS_SingleQuotes/src/main.ts +++ b/test/baselines/TS_SingleQuotes/src/main.ts @@ -1,5 +1,5 @@ /* - * Created with @iobroker/create-adapter v1.28.0 + * Created with @iobroker/create-adapter v1.29.0 */ // The adapter-core module gives you access to the core ioBroker functions diff --git a/test/baselines/adapter_JS_ES6Class_ESLint_TypeChecking_Spaces_SingleQuotes_Apache-2.0/.create-adapter.json b/test/baselines/adapter_JS_ES6Class_ESLint_TypeChecking_Spaces_SingleQuotes_Apache-2.0/.create-adapter.json index 7772fe21..0d4618a7 100644 --- a/test/baselines/adapter_JS_ES6Class_ESLint_TypeChecking_Spaces_SingleQuotes_Apache-2.0/.create-adapter.json +++ b/test/baselines/adapter_JS_ES6Class_ESLint_TypeChecking_Spaces_SingleQuotes_Apache-2.0/.create-adapter.json @@ -26,5 +26,5 @@ "ci": "gh-actions", "dependabot": "yes", "license": "Apache License 2.0", - "creatorVersion": "1.28.0" + "creatorVersion": "1.29.0" } \ No newline at end of file diff --git a/test/baselines/adapter_JS_ES6Class_ESLint_TypeChecking_Spaces_SingleQuotes_Apache-2.0/main.js b/test/baselines/adapter_JS_ES6Class_ESLint_TypeChecking_Spaces_SingleQuotes_Apache-2.0/main.js index 5fe32f10..426b7541 100644 --- a/test/baselines/adapter_JS_ES6Class_ESLint_TypeChecking_Spaces_SingleQuotes_Apache-2.0/main.js +++ b/test/baselines/adapter_JS_ES6Class_ESLint_TypeChecking_Spaces_SingleQuotes_Apache-2.0/main.js @@ -1,7 +1,7 @@ 'use strict'; /* - * Created with @iobroker/create-adapter v1.28.0 + * Created with @iobroker/create-adapter v1.29.0 */ // The adapter-core module gives you access to the core ioBroker functions diff --git a/test/baselines/adapter_JS_ESLint_TypeChecking_Spaces_SingleQuotes_Apache-2.0/.create-adapter.json b/test/baselines/adapter_JS_ESLint_TypeChecking_Spaces_SingleQuotes_Apache-2.0/.create-adapter.json index 86ca9e02..8c185c59 100644 --- a/test/baselines/adapter_JS_ESLint_TypeChecking_Spaces_SingleQuotes_Apache-2.0/.create-adapter.json +++ b/test/baselines/adapter_JS_ESLint_TypeChecking_Spaces_SingleQuotes_Apache-2.0/.create-adapter.json @@ -26,5 +26,5 @@ "ci": "gh-actions", "dependabot": "yes", "license": "Apache License 2.0", - "creatorVersion": "1.28.0" + "creatorVersion": "1.29.0" } \ No newline at end of file diff --git a/test/baselines/adapter_JS_ESLint_TypeChecking_Spaces_SingleQuotes_Apache-2.0/main.js b/test/baselines/adapter_JS_ESLint_TypeChecking_Spaces_SingleQuotes_Apache-2.0/main.js index 0c091589..4712f8f4 100644 --- a/test/baselines/adapter_JS_ESLint_TypeChecking_Spaces_SingleQuotes_Apache-2.0/main.js +++ b/test/baselines/adapter_JS_ESLint_TypeChecking_Spaces_SingleQuotes_Apache-2.0/main.js @@ -1,7 +1,7 @@ 'use strict'; /* - * Created with @iobroker/create-adapter v1.28.0 + * Created with @iobroker/create-adapter v1.29.0 */ // The adapter-core module gives you access to the core ioBroker functions diff --git a/test/baselines/adapter_TS_ES6Class_ESLint_Tabs_DoubleQuotes_MIT/.create-adapter.json b/test/baselines/adapter_TS_ES6Class_ESLint_Tabs_DoubleQuotes_MIT/.create-adapter.json index 83e8e281..6f4c9a52 100644 --- a/test/baselines/adapter_TS_ES6Class_ESLint_Tabs_DoubleQuotes_MIT/.create-adapter.json +++ b/test/baselines/adapter_TS_ES6Class_ESLint_Tabs_DoubleQuotes_MIT/.create-adapter.json @@ -25,5 +25,5 @@ "ci": "gh-actions", "dependabot": "yes", "license": "MIT License", - "creatorVersion": "1.28.0" + "creatorVersion": "1.29.0" } \ No newline at end of file diff --git a/test/baselines/adapter_TS_ES6Class_ESLint_Tabs_DoubleQuotes_MIT/src/main.ts b/test/baselines/adapter_TS_ES6Class_ESLint_Tabs_DoubleQuotes_MIT/src/main.ts index a42d092c..43f3ee24 100644 --- a/test/baselines/adapter_TS_ES6Class_ESLint_Tabs_DoubleQuotes_MIT/src/main.ts +++ b/test/baselines/adapter_TS_ES6Class_ESLint_Tabs_DoubleQuotes_MIT/src/main.ts @@ -1,5 +1,5 @@ /* - * Created with @iobroker/create-adapter v1.28.0 + * Created with @iobroker/create-adapter v1.29.0 */ // The adapter-core module gives you access to the core ioBroker functions diff --git a/test/baselines/adapter_TS_ESLint_Tabs_DoubleQuotes_MIT/.create-adapter.json b/test/baselines/adapter_TS_ESLint_Tabs_DoubleQuotes_MIT/.create-adapter.json index 2f94e531..0ed0104f 100644 --- a/test/baselines/adapter_TS_ESLint_Tabs_DoubleQuotes_MIT/.create-adapter.json +++ b/test/baselines/adapter_TS_ESLint_Tabs_DoubleQuotes_MIT/.create-adapter.json @@ -28,5 +28,5 @@ "ci": "gh-actions", "dependabot": "yes", "license": "MIT License", - "creatorVersion": "1.28.0" + "creatorVersion": "1.29.0" } \ No newline at end of file diff --git a/test/baselines/adapter_TS_ESLint_Tabs_DoubleQuotes_MIT/src/main.ts b/test/baselines/adapter_TS_ESLint_Tabs_DoubleQuotes_MIT/src/main.ts index e477e637..38786481 100644 --- a/test/baselines/adapter_TS_ESLint_Tabs_DoubleQuotes_MIT/src/main.ts +++ b/test/baselines/adapter_TS_ESLint_Tabs_DoubleQuotes_MIT/src/main.ts @@ -1,5 +1,5 @@ /* - * Created with @iobroker/create-adapter v1.28.0 + * Created with @iobroker/create-adapter v1.29.0 */ // The adapter-core module gives you access to the core ioBroker functions diff --git a/test/baselines/adapter_TS_React/.create-adapter.json b/test/baselines/adapter_TS_React/.create-adapter.json index 475d2174..5116302e 100644 --- a/test/baselines/adapter_TS_React/.create-adapter.json +++ b/test/baselines/adapter_TS_React/.create-adapter.json @@ -25,5 +25,5 @@ "ci": "gh-actions", "dependabot": "yes", "license": "MIT License", - "creatorVersion": "1.28.0" + "creatorVersion": "1.29.0" } \ No newline at end of file diff --git a/test/baselines/adapter_TS_React/src/main.ts b/test/baselines/adapter_TS_React/src/main.ts index a42d092c..43f3ee24 100644 --- a/test/baselines/adapter_TS_React/src/main.ts +++ b/test/baselines/adapter_TS_React/src/main.ts @@ -1,5 +1,5 @@ /* - * Created with @iobroker/create-adapter v1.28.0 + * Created with @iobroker/create-adapter v1.29.0 */ // The adapter-core module gives you access to the core ioBroker functions diff --git a/test/baselines/connectionIndicator_yes/src/main.ts b/test/baselines/connectionIndicator_yes/src/main.ts index ff0ea406..82e95b06 100644 --- a/test/baselines/connectionIndicator_yes/src/main.ts +++ b/test/baselines/connectionIndicator_yes/src/main.ts @@ -1,5 +1,5 @@ /* - * Created with @iobroker/create-adapter v1.28.0 + * Created with @iobroker/create-adapter v1.29.0 */ // The adapter-core module gives you access to the core ioBroker functions diff --git a/test/baselines/customAdapterSettings/src/main.ts b/test/baselines/customAdapterSettings/src/main.ts index 955a1262..7fce26da 100644 --- a/test/baselines/customAdapterSettings/src/main.ts +++ b/test/baselines/customAdapterSettings/src/main.ts @@ -1,5 +1,5 @@ /* - * Created with @iobroker/create-adapter v1.28.0 + * Created with @iobroker/create-adapter v1.29.0 */ // The adapter-core module gives you access to the core ioBroker functions diff --git a/test/baselines/devcontainer/.devcontainer/parcel/Dockerfile b/test/baselines/devcontainer/.devcontainer/parcel/Dockerfile index 6df14671..cd3bc5c0 100644 --- a/test/baselines/devcontainer/.devcontainer/parcel/Dockerfile +++ b/test/baselines/devcontainer/.devcontainer/parcel/Dockerfile @@ -1,9 +1,6 @@ FROM node:12 -RUN apt-get update && apt-get install -y rsync - RUN mkdir -p /usr/app -RUN mkdir -p /usr/workspace COPY *.sh /usr/app/ diff --git a/test/baselines/devcontainer/.devcontainer/parcel/run-sync.sh b/test/baselines/devcontainer/.devcontainer/parcel/run-sync.sh deleted file mode 100644 index fce4e8f6..00000000 --- a/test/baselines/devcontainer/.devcontainer/parcel/run-sync.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -while : -do - /usr/app/sync.sh - sleep 1 -done \ No newline at end of file diff --git a/test/baselines/devcontainer/.devcontainer/parcel/run.sh b/test/baselines/devcontainer/.devcontainer/parcel/run.sh index 398a1431..eec1a86e 100644 --- a/test/baselines/devcontainer/.devcontainer/parcel/run.sh +++ b/test/baselines/devcontainer/.devcontainer/parcel/run.sh @@ -1,13 +1,7 @@ #!/bin/bash -echo "Starting initial sync..." -/usr/app/sync.sh - -cd /usr/workspace +cd /workspace echo "Installing all dependencies..." npm install -# run the following two commands in parallel (honoring Ctrl-C) -# - npm run watch:parcel -# - /usr/app/run-sync.sh -(echo "npm run watch:parcel"; echo "/usr/app/run-sync.sh") | xargs -I{} -n 1 -P 2 /bin/bash -c "{}" \ No newline at end of file +npm run watch:parcel \ No newline at end of file diff --git a/test/baselines/devcontainer/.devcontainer/parcel/sync.sh b/test/baselines/devcontainer/.devcontainer/parcel/sync.sh deleted file mode 100644 index e6bb188b..00000000 --- a/test/baselines/devcontainer/.devcontainer/parcel/sync.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -rsync -aiz --inplace --exclude={'node_modules','.git','.cache','admin/build'} /workspace/ /usr/workspace \ No newline at end of file diff --git a/test/baselines/vis_Widget/.create-adapter.json b/test/baselines/vis_Widget/.create-adapter.json index fb3a614e..cd560fe4 100644 --- a/test/baselines/vis_Widget/.create-adapter.json +++ b/test/baselines/vis_Widget/.create-adapter.json @@ -14,5 +14,5 @@ "ci": "gh-actions", "dependabot": "yes", "license": "MIT License", - "creatorVersion": "1.28.0" + "creatorVersion": "1.29.0" } \ No newline at end of file diff --git a/test/baselines/vis_Widget_Travis/.create-adapter.json b/test/baselines/vis_Widget_Travis/.create-adapter.json index fc0741d8..95cf6514 100644 --- a/test/baselines/vis_Widget_Travis/.create-adapter.json +++ b/test/baselines/vis_Widget_Travis/.create-adapter.json @@ -14,5 +14,5 @@ "ci": "travis", "dependabot": "yes", "license": "MIT License", - "creatorVersion": "1.28.0" + "creatorVersion": "1.29.0" } \ No newline at end of file From 0f34a9de148270f8e844aadff838012892846ff6 Mon Sep 17 00:00:00 2001 From: Samuel Weibel Date: Thu, 24 Sep 2020 15:19:45 +0200 Subject: [PATCH 3/3] Self-referencing the PR. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69e837e9..f692176a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ (at the beginning of a new line ) --> ## __WORK IN PROGRESS__ -* (UncleSamSwiss) Remove rsync from parcel devcontainer · [Migration guide](docs/updates/20200924_devcontainer_parcel.md) +* (UncleSamSwiss) Remove rsync from parcel devcontainer (#589) · [Migration guide](docs/updates/20200924_devcontainer_parcel.md) ## 1.29.0 (2020-09-22) * (AlCalzone) Add Badge for Github Actions to Readme (#585)