Переглянути джерело

Fix documentation previews in pull requests (#2015)

* migrate to openzeppelin-docs-preview script

* update netlify configuration

* update docs-preview-script dependency

* remove old docs directory from gitignore

* update oz-docs script for live reload

* update oz-docs scripts to latest

* replace child_process.execFileSync with spawnSync

* update oz-docs-preview
Francisco Giordano 5 роки тому
батько
коміт
b56e00eb61
7 змінених файлів з 367 додано та 364 видалено
  1. 0 1
      .gitignore
  2. 2 2
      netlify.toml
  3. 356 325
      package-lock.json
  4. 3 4
      package.json
  5. 0 26
      scripts/docs.sh
  6. 5 1
      scripts/prepare-docs.sh
  7. 1 5
      scripts/prepare.js

+ 0 - 1
.gitignore

@@ -43,7 +43,6 @@ build/
 
 # docs artifacts
 docs/modules/api
-openzeppelin-docs
 
 # only used to package @openzeppelin/contracts
 contracts/build/

+ 2 - 2
netlify.toml

@@ -1,3 +1,3 @@
 [build]
-command = "npm run docs build"
-publish = "openzeppelin-docs/build/site"
+command = "npm run docs"
+publish = "build/site"

Різницю між файлами не показано, бо вона завелика
+ 356 - 325
package-lock.json


+ 3 - 4
package.json

@@ -12,7 +12,8 @@
   "scripts": {
     "compile": "scripts/compile.sh",
     "coverage": "scripts/coverage.sh",
-    "docs": "scripts/docs.sh",
+    "docs": "oz-docs -c docs",
+    "docs:watch": "npm run docs watch contracts 'docs/*.hbs'",
     "prepare-docs": "scripts/prepare-docs.sh",
     "lint": "npm run lint:js && npm run lint:sol",
     "lint:fix": "npm run lint:js:fix",
@@ -49,7 +50,6 @@
     "@openzeppelin/test-environment": "^0.1.1",
     "@openzeppelin/test-helpers": "^0.5.4",
     "chai": "^4.2.0",
-    "concurrently": "^5.0.0",
     "eslint": "^6.5.1",
     "eslint-config-standard": "^14.1.0",
     "eslint-plugin-import": "^2.18.2",
@@ -59,11 +59,10 @@
     "eslint-plugin-standard": "^4.0.1",
     "ethereumjs-util": "^6.2.0",
     "ganache-core-coverage": "https://github.com/OpenZeppelin/ganache-core-coverage/releases/download/2.5.3-coverage/ganache-core-coverage-2.5.3.tgz",
-    "http-server": "^0.11.1",
     "lodash.startcase": "^4.4.0",
     "micromatch": "^4.0.2",
     "mocha": "^6.2.2",
-    "nodemon": "^2.0.1",
+    "openzeppelin-docs-preview": "github:OpenZeppelin/docs-preview-script",
     "solhint": "2.3.0",
     "solidity-coverage": "github:rotcivegaf/solidity-coverage#5875f5b7bc74d447f3312c9c0e9fc7814b482477",
     "solidity-docgen": "^0.3.13"

+ 0 - 26
scripts/docs.sh

@@ -1,26 +0,0 @@
-#!/usr/bin/env bash
-
-if [ "$1" != "build" -a "$1" != "start" ];then
-  echo "usage: npm run docs (build|start)" >&2
-  exit 1
-fi
-
-set -o errexit
-
-if [ ! -d openzeppelin-docs ]; then
-  git clone https://github.com/frangio/openzeppelin-docs.git openzeppelin-docs
-fi
-
-git -C openzeppelin-docs pull -q
-
-if [ "$1" = "build" ]; then
-  npm run prepare-docs
-  cd docs
-  env DISABLE_PREPARE_DOCS= node ../openzeppelin-docs/build-local.js
-
-elif [ "$1" = "start" ]; then
-  npx concurrently \
-    'nodemon --delay 1 -e "*" -w contracts -w "docs/*.hbs" -x npm run prepare-docs' \
-    'cd docs; env DISABLE_PREPARE_DOCS= nodemon --delay 1 -e adoc,yml ../openzeppelin-docs/build-local.js' \
-    'http-server -c-1 openzeppelin-docs/build/site'
-fi

+ 5 - 1
scripts/prepare-docs.sh

@@ -1,8 +1,12 @@
 #!/usr/bin/env bash
 
+set -o errexit
+
 OUTDIR=docs/modules/api/pages/
 
-npm ci
+if [ ! -d node_modules ]; then
+  npm ci
+fi
 
 rm -rf "$OUTDIR"
 solidity-docgen -t docs -o "$OUTDIR" -e contracts/mocks,contracts/examples

+ 1 - 5
scripts/prepare.js

@@ -7,15 +7,11 @@ const path = require('path');
 const cp = require('child_process');
 const match = require('micromatch');
 
-function exec (cmd, ...args) {
-  cp.execFileSync(cmd, args, { stdio: 'inherit' });
-}
-
 function readJSON (path) {
   return JSON.parse(fs.readFileSync(path));
 }
 
-exec('npm', 'run', 'compile');
+cp.spawnSync('npm', ['run', 'compile'], { stdio: 'inherit' });
 
 const pkgFiles = readJSON('package.json').files;
 

Деякі файли не було показано, через те що забагато файлів було змінено