diff --git a/.editorconfig b/.editorconfig index 2ad092369f..3aa4c6a984 100644 --- a/.editorconfig +++ b/.editorconfig @@ -24,3 +24,7 @@ insert_final_newline = true [*.md] trim_trailing_whitespace = false + +[*.{yml,yaml}] +indent_style = space +indent_size = 2 diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 66e849f804..480bc57ebe 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,21 +7,21 @@ trigger: - master pool: - vmImage: 'ubuntu-latest' + vmImage: 'ubuntu-18.04' variables: - SOFTHSM2_CONF: './test/fixtures/hsm/softhsm2.conf' + SOFTHSM2_CONF: "$(Build.Repository.LocalPath)/test/fixtures/hsm/softhsm2.conf" steps: - task: NodeTool@0 inputs: - versionSpec: '8.x' + versionSpec: '10.x' displayName: 'Install Node.js' - script: | sudo apt-get install softhsm2 softhsm2-util --init-token --slot 0 --label "My token 1" --pin 98765432 --so-pin 98765432 - displayName: 'Install and configure SoftHSM' + displayName: 'Install SoftHSM' - script: npm install displayName: 'npm install' @@ -35,15 +35,19 @@ steps: - script: npx gulp run-test-all displayName: 'Run tests' -# - script: scripts/ci_scripts/azurePublishNpmPackages.sh -# displayName: 'Publish npm packages' -# env: -# NPM_TOKEN: ${NPM_TOKEN} - -# - script: scripts/ci_scripts/azurePublishApiDocs.sh -# displayName: 'Publish API documentation' -# env: -# GITHUB_USER: 'fabric-sdk-node' -# GITHUB_EMAIL: 'fabricsdknode@gmail.com' -# GITHUB_PASSWORD: $(GITHUB_PASSWORD) -# PUBLISH_REPOSITORY: 'fabric-sdk-node/fabric-sdk-node' +#- script: scripts/ci_scripts/azurePublishNpmPackages.sh +# condition: and(succeeded(), eq(variables['Build.Reason'], 'IndividualCI')) +# displayName: 'Publish npm packages' +# env: +# NPM_TOKEN: $(NPM) +# PROJECT_DIR: "$(Build.Repository.LocalPath)" + +- script: scripts/ci_scripts/azurePublishApiDocs.sh + condition: and(succeeded(), eq(variables['Build.Reason'], 'IndividualCI')) + displayName: 'Publish API documentation' + env: + GITHUB_USER: 'Hyperledger Bot' + GITHUB_EMAIL: 'hlfdev.azp@gmail.com' + PUBLISH_URL: "https://$(GITHUB-PAT)@github.com/hyperledger/fabric-sdk-node.git" + PROJECT_DIR: "$(Build.Repository.LocalPath)" + STAGING_DIR: "$(Build.StagingDirectory)/gh-pages" diff --git a/fabric-ca-client/package.json b/fabric-ca-client/package.json index dc4acd52d3..5c2a61399c 100644 --- a/fabric-ca-client/package.json +++ b/fabric-ca-client/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/hyperledger/fabric-sdk-node" }, "engines": { - "node": "^8.9.0 || ^10.15.3", + "node": "^8.9.0 || ^10.15.3 || ^12.13.1", "npm": "^5.5.1 || ^6.4.1" }, "types": "./types/index.d.ts", diff --git a/fabric-client/package.json b/fabric-client/package.json index 88bc98dbd6..9776458728 100644 --- a/fabric-client/package.json +++ b/fabric-client/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/hyperledger/fabric-sdk-node" }, "engines": { - "node": "^8.9.0 || ^10.15.3", + "node": "^8.9.0 || ^10.15.3 || ^12.13.1", "npm": "^5.5.1 || ^6.4.1" }, "types": "./types/index.d.ts", diff --git a/fabric-common/package.json b/fabric-common/package.json index 14c0fe9481..709d98d1b4 100644 --- a/fabric-common/package.json +++ b/fabric-common/package.json @@ -21,7 +21,7 @@ "test": "nyc mocha --exclude 'test/data/**/*.js' --recursive -t 10000" }, "engines": { - "node": "^8.9.0 || ^10.15.3", + "node": "^8.9.0 || ^10.15.3 || ^12.13.1", "npm": "^5.5.1 || ^6.4.1" }, "types": "./types/index.d.ts", diff --git a/fabric-network/package.json b/fabric-network/package.json index 406bbdf6c5..96e9d91227 100644 --- a/fabric-network/package.json +++ b/fabric-network/package.json @@ -21,7 +21,7 @@ "test": "nyc mocha --recursive -t 10000" }, "engines": { - "node": "^8.9.0 || ^10.15.3", + "node": "^8.9.0 || ^10.15.3 || ^12.13.1", "npm": "^5.5.1 || ^6.4.1" }, "types": "./types/index.d.ts", diff --git a/fabric-protos/package.json b/fabric-protos/package.json index 4486ecb9a1..d494b65a3d 100644 --- a/fabric-protos/package.json +++ b/fabric-protos/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/hyperledger/fabric-sdk-node" }, "engines": { - "node": "^8.9.0 || ^10.15.3", + "node": "^8.9.0 || ^10.15.3 || ^12.13.1", "npm": "^5.5.1 || ^6.4.1" }, "keywords": [ diff --git a/package.json b/package.json index 4b07142071..3aef2df214 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "retrieve-images": "./scripts/utility/fabric_images.sh amd64 2.0.0-stable" }, "devDependencies": { - "@ampretia/x509": "0.4.0", + "@ampretia/x509": "0.4.7", "@cloudant/cloudant": "^2.1.0", "@types/chai": "^4.2.1", "@types/chai-as-promised": "^7.1.2", @@ -59,7 +59,6 @@ "fabric-protos": "file:./fabric-protos", "gulp": "^3.9.1", "gulp-add-src": "^1.0.0", - "gulp-debug": "^4.0.0", "gulp-eslint": "^3.0.1", "gulp-jsdoc3": "^2.0.0", "gulp-mocha": "^6.0.0", @@ -104,8 +103,7 @@ } ], "dependencies": { - "fs-extra": "^6.0.1", - "x509": "^0.3.4" + "fs-extra": "^6.0.1" }, "nyc": { "exclude": [ diff --git a/scripts/ci_scripts/azurePublishApiDocs.sh b/scripts/ci_scripts/azurePublishApiDocs.sh index ceed0a0308..d7509df49d 100755 --- a/scripts/ci_scripts/azurePublishApiDocs.sh +++ b/scripts/ci_scripts/azurePublishApiDocs.sh @@ -8,61 +8,66 @@ # Input environment variables: : "${GITHUB_USER:?}" # The GitHub user name for publishing : "${GITHUB_EMAIL:?}" # Email address of the GitHub user -: "${GITHUB_PASSWORD:?}" # Password or token for GitHub user -: "${PUBLISH_REPOSITORY:?}" # Qualified GitHub publish repository name (i.e. "organization/repository") - -readonly PROJECT_DIR=$(cd -P "$(dirname "$0")"/../.. >/dev/null 2>&1 && pwd) +: "${PUBLISH_URL:?}" # Git URL used to push published content +: "${PROJECT_DIR:?}" # Root directory for the Git project +: "${STAGING_DIR:?}" # Directory used to store content to publish to GitHub Pages readonly COMMIT_HASH=$(git rev-parse HEAD) -readonly REPOSITORY_URL="https://github.com/${PUBLISH_REPOSITORY}.git" -readonly PUBLISH_URL="https://${GITHUB_USER}:${GITHUB_PASSWORD}@github.com/${PUBLISH_REPOSITORY}.git" readonly BUILD_DIR="${PROJECT_DIR}/docs/gen" -readonly PUBLISH_DIR="${PROJECT_DIR}/$(basename "${PUBLISH_REPOSITORY}")" +readonly DOCS_BRANCH='gh-pages' + +prepareStaging() { + echo "Preparing staging directory: ${STAGING_DIR}" + rm -rf "${STAGING_DIR}" + rsync -r --exclude-from=${PROJECT_DIR}/.gitignore "${PROJECT_DIR}/" "${STAGING_DIR}" + (cd "${STAGING_DIR}" && _stagingGitSetUp) +} -clonePublishRepository() { - rm -rf "${PUBLISH_DIR}" - git clone "${REPOSITORY_URL}" "${PUBLISH_DIR}" +_stagingGitSetUp() { + git config --local user.name "${GITHUB_USER}" + git config --local user.email "${GITHUB_EMAIL}" + git reset --hard + git clean -xdf + git fetch origin + git checkout -B "${DOCS_BRANCH}" "origin/${DOCS_BRANCH}" + git clean -xdf } buildDocs() { + echo 'Building documentation' rm -rf "${BUILD_DIR}" npx gulp docs - cleanPublishDirectory - cp -r "${BUILD_DIR}"/* "${PUBLISH_DIR}" } -cleanPublishDirectory() { - # Root files should only be removed from the top-level publish directory if building the master branch - # removePublishRootFiles - removePublishDirectories +copyToStaging() { + echo "Copying built documentation from ${BUILD_DIR} to ${STAGING_DIR}" + cleanStaging + cp -r "${BUILD_DIR}"/* "${STAGING_DIR}" } -removePublishRootFiles() { - find "${PUBLISH_DIR}" -type f -maxdepth 1 -depth 1 -print | while read -r file; do - echo "Removing ${file}" - rm -f "${file}" - done -} - -removePublishDirectories() { +cleanStaging() { + local releaseDir targetDir + # Remove release sub-directories that have been re-built find "${BUILD_DIR}" -type d -maxdepth 1 -depth 1 -print | while read -r subdir; do - local sourceDir=$(basename "${subdir}") - local targetDir="${PUBLISH_DIR}/${sourceDir}" + releaseDir=$(basename "${subdir}") + targetDir="${STAGING_DIR}/${releaseDir}" echo "Removing ${targetDir}" rm -rf "${targetDir}" done } publishDocs() { - git config --local user.name "${GITHUB_USER}" - git config --local user.email "${GITHUB_EMAIL}" + echo 'Publishing documentation from staging' + (cd "${STAGING_DIR}" && _stagingPushDocs) +} +_stagingPushDocs() { git add . git commit -m "Commit ${COMMIT_HASH}" - git remote add publish "${PUBLISH_URL}" - # git push publish master + git push "${PUBLISH_URL}" "${DOCS_BRANCH}" } -clonePublishRepository +prepareStaging buildDocs -(cd "${PUBLISH_DIR}" && publishDocs) +copyToStaging +publishDocs diff --git a/scripts/ci_scripts/azurePublishNpmPackages.sh b/scripts/ci_scripts/azurePublishNpmPackages.sh index 0de8fe648f..efb9a5b219 100755 --- a/scripts/ci_scripts/azurePublishNpmPackages.sh +++ b/scripts/ci_scripts/azurePublishNpmPackages.sh @@ -7,8 +7,8 @@ # Input environment variables: : "${NPM_TOKEN:?}" # The npm publishing auth token +: "${PROJECT_DIR:?}" # The project root directory -readonly PROJECT_DIR=$(cd -P "$(dirname "$0")"/../.. >/dev/null 2>&1 && pwd) readonly NODE_MODULES="fabric-protos fabric-common fabric-ca-client fabric-client fabric-network" npmPublish() {