You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2022/09/12 18:31:42 UTC

[echarts-examples] branch gh-pages updated (16b6c9de -> a5f0dd47)

This is an automated email from the ASF dual-hosted git repository.

sushuang pushed a change to branch gh-pages
in repository https://gitbox.apache.org/repos/asf/echarts-examples.git


    from 16b6c9de chore: add .asf.yaml
     new 621ce6c2 fix: fix ts type.
     new bda4d6aa fix: make the build guide clear in README.md
     new b5cfaaee fix: (1). add back the e2e/package.json, otherwise the dependent packages will be installed into echarts-examples/node_modules. And make some process to prevent it from committing modifications. (2). Fix some dependency install (of zrender, which is the dependency of echarts and echarts-gl).
     new a5f0dd47 fix: tweak readme and add some build commands into package.json.

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitignore                         |   5 +-
 README.md                          | 144 ++++++++++++++++++++++---------------
 e2e/main.js                        |  98 ++++++++++++++++++-------
 e2e/package.tpl.json               |  12 ++++
 package.json                       |   2 +-
 public/examples/ts/mix-line-bar.ts |  12 ++--
 6 files changed, 179 insertions(+), 94 deletions(-)
 create mode 100644 e2e/package.tpl.json


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[echarts-examples] 04/04: fix: tweak readme and add some build commands into package.json.

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sushuang pushed a commit to branch gh-pages
in repository https://gitbox.apache.org/repos/asf/echarts-examples.git

commit a5f0dd47e73bdcb6fc3e1d95163df9730317e41c
Author: 100pah <su...@gmail.com>
AuthorDate: Tue Sep 13 02:31:26 2022 +0800

    fix: tweak readme and add some build commands into package.json.
---
 .gitignore   |  3 ++-
 README.md    | 13 +++++++++----
 package.json |  2 +-
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore
index 158ffaee..15d78737 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,4 +20,5 @@ public/vendors/echarts/map/raw
 /e2e/node_modules
 
 tmp
-.webm
\ No newline at end of file
+.webm
+result.log
diff --git a/README.md b/README.md
index 7d84a7ee..1af09024 100644
--- a/README.md
+++ b/README.md
@@ -150,9 +150,9 @@ Note: the commands below will execute `npm install` in these local directories.
 
 ```shell
 # run e2e using local dependent repos and webpack.
-npm run test:e2e:local
+npm run test:e2e:local > result.log 2>&1
 # run e2e using local dependent repos and esbuild, which is much faster.
-npm run test:e2e:esbuild:local
+npm run test:e2e:esbuild:local > result.log 2>&1
 ```
 
 ### Run e2e test using remote dependent repos
@@ -161,11 +161,16 @@ Note: the commands below will download the repos listed in `echarts-examples/e2e
 
 ```shell
 # run e2e using remote dependent repos and webpack.
-npm run test:e2e
+npm run test:e2e > result.log 2>&1
 # run e2e using remote dependent repos and esbuild, which is much faster.
-npm run test:e2e:esbuild
+npm run test:e2e:esbuild > result.log 2>&1
 ```
 
+### Check the test result
+The test result is in:
++ the `result.log`
++ `echarts-examples/e2e/report.html`, the file should be opened in your own local http server.
+
 ### Run partial tests.
 
 > Note: This can only be used when you run the whole e2e test at least once.
diff --git a/package.json b/package.json
index f58ae57d..3aee8af4 100644
--- a/package.json
+++ b/package.json
@@ -9,7 +9,7 @@
     "release": "npm run compile:example && npm run build && node build/copyResource.js --env asf",
     "dev": "npx concurrently --kill-others \"npm:watch\" \"npm:server\"",
     "build:example": "npm run compile:example && node tool/build-example.js && node tool/build-example.js --gl",
-    "build:examplelist": "npm run compile:example && node tool/build-example.js --no-thumb",
+    "build:examplelist": "npm run compile:example && node tool/build-example.js --no-thumb && node tool/build-example.js --no-thumb --gl",
     "compile:example": "node tool/compile-example.js",
     "test:e2e": "node e2e/main.js --bundler webpack -m",
     "test:e2e:local": "node e2e/main.js --bundler webpack -m --local",


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[echarts-examples] 03/04: fix: (1). add back the e2e/package.json, otherwise the dependent packages will be installed into echarts-examples/node_modules. And make some process to prevent it from committing modifications. (2). Fix some dependency install (of zrender, which is the dependency of echarts and echarts-gl).

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sushuang pushed a commit to branch gh-pages
in repository https://gitbox.apache.org/repos/asf/echarts-examples.git

commit b5cfaaeee9aaac4a3c03f02ebe87009300258067
Author: 100pah <su...@gmail.com>
AuthorDate: Tue Sep 13 01:49:01 2022 +0800

    fix:
    (1). add back the e2e/package.json, otherwise the dependent packages will be installed into echarts-examples/node_modules. And make some process to prevent it from committing modifications.
    (2). Fix some dependency install (of zrender, which is the dependency of echarts and echarts-gl).
---
 .gitignore           |  2 ++
 e2e/main.js          | 98 +++++++++++++++++++++++++++++++++++++---------------
 e2e/package.tpl.json | 12 +++++++
 3 files changed, 85 insertions(+), 27 deletions(-)

diff --git a/.gitignore b/.gitignore
index 5e01c252..158ffaee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,6 +16,8 @@ public/vendors/echarts/map/raw
 /public/data-gl/option
 /public/examples/js
 /e2e/package-lock.json
+/e2e/package.json
+/e2e/node_modules
 
 tmp
 .webm
\ No newline at end of file
diff --git a/e2e/main.js b/e2e/main.js
index 2d114367..cb8de9a5 100644
--- a/e2e/main.js
+++ b/e2e/main.js
@@ -129,6 +129,10 @@ async function prepare() {
   fse.removeSync(REPO_DIR);
   fse.removeSync(PACKAGE_DIR);
 
+  fse.removeSync(nodePath.join(__dirname, 'package.json'));
+  fse.removeSync(nodePath.join(__dirname, 'package-lock.json'));
+  fse.copySync(nodePath.join(__dirname, 'package.tpl.json'), nodePath.join(__dirname, 'package.json'));
+
   fse.ensureDirSync(TMP_DIR);
   fse.ensureDirSync(RUN_CODE_DIR);
   fse.ensureDirSync(BUNDLE_DIR);
@@ -175,45 +179,82 @@ async function installPackages(config) {
 
     shell.cd(pkg.dir);
 
-    const packageJson = JSON.parse(
-      fs.readFileSync(nodePath.join(pkg.dir, 'package.json'))
-    );
+    const packageJsonPath = nodePath.join(pkg.dir, 'package.json');
+    const packageJsonRaw = fs.readFileSync(packageJsonPath, {encoding: 'utf-8'});
+    const packageJson = JSON.parse(packageJsonRaw);
     const tgzFileName = `${packageJson.name}-${packageJson.version}.tgz`;
     const targetTgzFilePath = nodePath.join(PACKAGE_DIR, tgzFileName);
+    let needModifyPackageJSON = false;
+
+    function doesConfigIncludesDepPkg(depPkgName) {
+      return !!config.packages.find((a) => a.name === depPkgName)
+    }
 
     if (packageJson.dependencies) {
       for (let depPkgName in packageJson.dependencies) {
-        const depPkg = config.packages.find((a) => a.name === depPkgName);
-        if (depPkg && !publishedPackages[depPkgName]) {
-          publishPackage(depPkg);
-          // Come back.
-          shell.cd(pkg.dir);
+        if (!doesConfigIncludesDepPkg(depPkgName) || publishedPackages[depPkgName]) {
+          continue;
         }
+        publishPackage(depPkg);
+        // Come back.
+        shell.cd(pkg.dir);
+      }
 
-        shell.exec(`npm install`);
+      if (shell.exec(`npm install`).code !== 0) {
+        console.error(`shell fail: npm install in ${pkg.dir}`);
+        process.exit(1);
+      }
 
-        if (depPkg) {
-          console.log(
-            chalk.gray(
-              `Installing dependency ${depPkgName} from "${publishedPackages[depPkgName]}" ...`
-            )
-          );
-          shell.exec(`npm install ${publishedPackages[depPkgName]} --no-save`);
-          console.log(chalk.gray(`Install dependency ${depPkgName} done.`));
+      for (let depPkgName in packageJson.dependencies) {
+        if (!doesConfigIncludesDepPkg(depPkgName)) {
+          continue;
         }
+        console.log(
+          chalk.gray(
+            `Installing dependency ${depPkgName} from "${publishedPackages[depPkgName].targetTgzFilePath}" ...`
+          )
+        );
+        if (shell.exec(`npm install ${publishedPackages[depPkgName].targetTgzFilePath}`).code !== 0) {
+          console.error(`shell fail: npm install ${publishedPackages[depPkgName].targetTgzFilePath}`);
+          process.exit(1);
+        }
+        // After the npm install above, the package.json will be modifiedt to like:
+        // "dependencies": ["zredner": "file:../echarts-examples/e2e/tmp/packages/zrender-5.3.2.tgz"]
+        // which is a relative path and not correct if the tgz is copied to another place in
+        // the latter process.
+        // If we use --no-save, the latter npm install by tgz may not use the version of zrender that
+        // config.js specified.
+        // So we modifiy the version mandatorily to the version that config.js specified.
+        // In the latter npm install by tgz, the zrender will be installed firstly. And when echarts
+        // is installing, it found the right version of zrender has been installed, and do not install
+        // zrender separately.
+        needModifyPackageJSON = true;
+        packageJson.dependencies[depPkgName] = publishedPackages[depPkgName].version;
+        console.log(chalk.gray(`Install dependency ${depPkgName} done.`));
       }
     }
 
-    shell.exec(`npm pack`);
+    if (needModifyPackageJSON) {
+      // Modify package.json for npm pack.
+      fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson), {encoding: 'utf-8'});
+    }
+    if (shell.exec(`npm pack`).code !== 0) {
+      console.error(`shell fail: npm pack in ${pkg.dir}`);
+      shell.exit(1);
+    }
     fs.renameSync(nodePath.join(pkg.dir, tgzFileName), targetTgzFilePath);
-    publishedPackages[packageJson.name] = targetTgzFilePath;
+    publishedPackages[packageJson.name] = {targetTgzFilePath, version: packageJson.version};
+
+    if (needModifyPackageJSON) {
+      // Restore modified package.json
+      fs.writeFileSync(packageJsonPath, packageJsonRaw, {encoding: 'utf-8'});
+    }
   }
 
   for (let pkg of config.packages) {
     if (!checkFolder(pkg)) {
-      return;
+      process.exit(1);
     }
-
     publishPackage(pkg);
   }
 
@@ -221,10 +262,13 @@ async function installPackages(config) {
   for (let pkg of config.packages) {
     console.log(
       chalk.gray(
-        `Installing ${pkg.name} from "${publishedPackages[pkg.name]}" ...`
+        `Installing ${pkg.name} from "${publishedPackages[pkg.name].targetTgzFilePath}" ...`
       )
     );
-    shell.exec(`npm install ${publishedPackages[pkg.name]} --no-save`);
+    if (shell.exec(`npm install ${publishedPackages[pkg.name].targetTgzFilePath}`).code !== 0) {
+      console.log(`shell fail: npm install ${publishedPackages[pkg.name].targetTgzFilePath}`);
+      process.exit(1);
+    }
     console.log(chalk.gray(`Install ${pkg.name} done.`));
   }
 
@@ -783,8 +827,8 @@ async function main() {
         fs.readFileSync(__dirname + '/tmp/result.json', 'utf-8')
       );
     } catch (e) {
-      console.error(e);
-      throw 'Must run full e2e test without --skip and --tests at least once.';
+      console.log(`Can not find ${__dirname}/tmp/result.json. Make a new one.`);
+      result = {};
     }
   }
 
@@ -882,7 +926,7 @@ async function main() {
 main()
   .catch((e) => {
     console.error(e);
-    process.exit();
+    process.exit(1);
   })
   .then(() => {
     process.exit();
@@ -891,5 +935,5 @@ main()
 process.on('SIGINT', function () {
   console.log('Closing');
   // Close through ctrl + c;
-  process.exit();
+  process.exit(1);
 });
diff --git a/e2e/package.tpl.json b/e2e/package.tpl.json
new file mode 100644
index 00000000..ce3fba7b
--- /dev/null
+++ b/e2e/package.tpl.json
@@ -0,0 +1,12 @@
+{
+  "description": "DO NOT remove this file, otherwise when e2e/main.js execute npm install, packages will be installed in echarst-examples/node_modules and will be removed because --no-save is used.",
+  "name": "echarts-examples-e2e",
+  "version": "1.0.0",
+  "main": "main.js",
+  "scripts": {},
+  "author": "",
+  "license": "ISC",
+  "dependencies": {
+    "zrender": "file:tmp/packages/zrender-5.3.2.tgz"
+  }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[echarts-examples] 02/04: fix: make the build guide clear in README.md

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sushuang pushed a commit to branch gh-pages
in repository https://gitbox.apache.org/repos/asf/echarts-examples.git

commit bda4d6aa756e35d53afa35cb35e09eea01e19569
Author: 100pah <su...@gmail.com>
AuthorDate: Tue Sep 13 01:45:08 2022 +0800

    fix: make the build guide clear in README.md
---
 README.md | 139 ++++++++++++++++++++++++++++++++++++--------------------------
 1 file changed, 80 insertions(+), 59 deletions(-)

diff --git a/README.md b/README.md
index d2c73149..7d84a7ee 100644
--- a/README.md
+++ b/README.md
@@ -6,26 +6,10 @@
 npm install
 ```
 
-## Dev
 
-```shell
-npm run dev
-```
-
-## Release
-
-```shell
-npm run release
-```
+## Edit examples
 
-It will copy all the build resources to echarts-website/next/examples
-
-## Use local echarts build
-
-1. Update the URL of localEChartsMinJS in `common/config.js`
-2. Add `local=1` in URL. For example: `editor.html?c=area-basic&local=1`
-
-## Edit example
+### How
 
 All test cases are in the `public/examples/ts` folder. The comment in the header
 
@@ -58,9 +42,9 @@ Most of examples are written in `TypeScript`. You need to comile it to `JavaScri
 npm run compile:example
 ```
 
-## Some built-in features available in examples
+### Some built-in features available in examples
 
-### Import third-party library
+#### Import third-party library
 
 For example:
 
@@ -75,37 +59,37 @@ $.when(
 });
 ```
 
-### Controller panel
+#### Controller panel
 
 Use this code to enable controller panel for a example:
 
 ```js
 app.config = {
-    aNameForTheSelectWidget: 'This is the initial value'
-    aNameForTheRangeWidget: 45,
-    aNameForTheButtonWidget: function () {
-        // Do something.
-    },
-    onChange: function () {
-        // Do something.
-    }
+  aNameForTheSelectWidget: 'This is the initial value'
+  aNameForTheRangeWidget: 45,
+  aNameForTheButtonWidget: function () {
+    // Do something.
+  },
+  onChange: function () {
+    // Do something.
+  }
 };
 app.configParameters = {
-    aNameForTheSelectWidget: {
-        options: [
-            'This is the initial value',
-            'This is another value',
-            'This is the third value'
-        ]
-    },
-    aNameForTheRangeWidget: {
-        min: -90,
-        max: 90
-    }
+  aNameForTheSelectWidget: {
+    options: [
+      'This is the initial value',
+      'This is another value',
+      'This is the third value'
+    ]
+  },
+  aNameForTheRangeWidget: {
+    min: -90,
+    max: 90
+  }
 };
 ```
 
-### Resize
+#### Resize
 
 ```js
 app.onresize = function () {
@@ -113,57 +97,76 @@ app.onresize = function () {
 };
 ```
 
-### Get width and height of the chart area
+#### Get width and height of the chart area
 
 ```js
 var width = myChart.getWidth();
 var height = myChart.getHeight();
 ```
 
-## Update example snapshots
 
-```shell
-npm run build:example
-```
+## View and edit echarts-examples website
 
-Only for default theme
+### Dev and view examples in website
 
 ```shell
-node tool/build-example.js -t default
+npm run dev
 ```
 
+### Use local echarts build
+
+1. Update the URL of `localEChartsDir` & `localEChartsGLJS` in `src/common/config.js`
+2. Add `local=1` in URL. For example:
+  + `editor.html?c=area-basic&local=1`
+
+
 ## Run e2e tests.
 
 Run all the examples to test package publishing and install, module importing, minimal bundling and DTS correctness.
 
-Before run the tests. you need to update the examples.
+Before run the tests. you need to update the examples list.
 
 ```shell
-npm run build:example
+npm run build:examplelist
 ```
 
-Then run the tests.
+If puppeteer has not been installed:
+```shell
+npm i puppeteer
+```
 
+If you want to save the log:
 ```shell
-npm run test:e2e
+exe_something > 1.log 2>&1
 ```
 
-You can change the testing branch or local dir, which is available when add `--local` in `e2e/config.js`
+### Run e2e test using local dependent repos
 
-If you want to test with esbuild bundler. Which is much faster.
+If you are testing a new version of echarts or zrender, which are not released in github yet, you need run e2e test with local dependent repos.
+
+Firstly, make sure the dependent repos listed in `dir` attributes in `echarts-examples/e2e/config.js` existing and having release built.
+
+Note: the commands below will execute `npm install` in these local directories.
 
 ```shell
-npm run test:e2e:esbuild
+# run e2e using local dependent repos and webpack.
+npm run test:e2e:local
+# run e2e using local dependent repos and esbuild, which is much faster.
+npm run test:e2e:esbuild:local
 ```
 
-If you want use the packages in your local folder which is still in developing. Please update the `dir` path in `test/config.js` for all packages first. Then run the script directly with `--local` arg.
+### Run e2e test using remote dependent repos
+
+Note: the commands below will download the repos listed in `echarts-examples/e2e/config.js` to a temporary folder.
 
 ```shell
-node e2e/main.js --bundler esbuild -m --local
-node e2e/main.js --bundler webpack -m --local
+# run e2e using remote dependent repos and webpack.
+npm run test:e2e
+# run e2e using remote dependent repos and esbuild, which is much faster.
+npm run test:e2e:esbuild
 ```
 
-#### Run partial tests.
+### Run partial tests.
 
 > Note: This can only be used when you run the whole e2e test at least once.
 
@@ -178,3 +181,21 @@ Specify matched tests.
 ```shell
 node e2e/main.js --skip npm --tests bar3D*
 ```
+
+
+## Release
+
+1. Update example snapshots
+  ```shell
+  npm run build:example
+
+  # Node: If only build for default theme:
+  node tool/build-example.js -t default
+  ```
+2. Build and copy all the build resources to `echarts-website`
+  ```shell
+  npm run release
+
+  # Note: the config of the dir of echarts-website is in
+  # `echarts-examples/config/**`
+  ```


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[echarts-examples] 01/04: fix: fix ts type.

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sushuang pushed a commit to branch gh-pages
in repository https://gitbox.apache.org/repos/asf/echarts-examples.git

commit 621ce6c20414f2b28cf6d374f9c25a0bf728c643
Author: 100pah <su...@gmail.com>
AuthorDate: Sat Sep 10 16:56:43 2022 +0800

    fix: fix ts type.
---
 public/examples/ts/mix-line-bar.ts | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/public/examples/ts/mix-line-bar.ts b/public/examples/ts/mix-line-bar.ts
index 423c33fa..9bb8f3dc 100644
--- a/public/examples/ts/mix-line-bar.ts
+++ b/public/examples/ts/mix-line-bar.ts
@@ -62,8 +62,8 @@ option = {
       name: 'Evaporation',
       type: 'bar',
       tooltip: {
-        valueFormatter: function (value: number) {
-          return value + ' ml';
+        valueFormatter: function (value) {
+          return value as number + ' ml';
         }
       },
       data: [
@@ -74,8 +74,8 @@ option = {
       name: 'Precipitation',
       type: 'bar',
       tooltip: {
-        valueFormatter: function (value: number) {
-          return value + ' ml';
+        valueFormatter: function (value) {
+          return value as number + ' ml';
         }
       },
       data: [
@@ -87,8 +87,8 @@ option = {
       type: 'line',
       yAxisIndex: 1,
       tooltip: {
-        valueFormatter: function (value: number) {
-          return value + ' °C';
+        valueFormatter: function (value) {
+          return value as number + ' °C';
         }
       },
       data: [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org