Repository: serverless/serverless-azure-functions
Pull request #267 (2019-08-27 17:32:43)

fix: Don't remove local.settings.json in offline cleanup
Fixes issue of removing `local.settings.json` in offline cleanup. There might be project sensitive information there, and it would be inconvenient for the developer if that were removed.

Resolves AB#929


Patch:
diff --git a/.codecov.yml b/.codecov.yml
new file mode 100644
index 0000000..aae9ac9
--- /dev/null
+++ b/.codecov.yml
@@ -0,0 +1,17 @@
+# Validate changes
+# cat .codecov.yml | curl --data-binary @- https://codecov.io/validate
+
+comment:  on # enable pull request comment
+coverage:
+  range: 70..100
+  round: down # round down to the precision point
+  precision: 2
+  status:
+    project: # compare project coverage against the base of pr
+      default:
+        target: 75%  # min coverage ratio to be considered a success
+        threshold: null  # allow coverage to drop by X%
+        base: auto
+    patch:  # provides an indication on how well the pull request is tested
+      default:
+        target: 70% # min coverage ratio to be considered a success
diff --git a/package-lock.json b/package-lock.json
index 2a845b2..712b014 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
 {
   "name": "serverless-azure-functions",
-  "version": "1.0.0-15",
+  "version": "1.0.0-18",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {
@@ -3616,19 +3616,6 @@
         }
       }
     },
-    "coveralls": {
-      "version": "git+https://github.com/nickmerwin/node-coveralls.git#f0ddec529c8271ea193bfab41de12b6c06d533f5",
-      "from": "git+https://github.com/nickmerwin/node-coveralls.git#f0ddec529c8271ea193bfab41de12b6c06d533f5",
-      "dev": true,
-      "requires": {
-        "growl": "~> 1.10.0",
-        "js-yaml": "^3.11.0",
-        "lcov-parse": "^0.0.10",
-        "log-driver": "^1.2.7",
-        "minimist": "^1.2.0",
-        "request": "^2.86.0"
-      }
-    },
     "crc": {
       "version": "3.8.0",
       "resolved": "https://registry.npmjs.org/crc/-/crc-3.8.0.tgz",
@@ -5741,12 +5728,6 @@
         "lodash": "^4.17.5"
       }
     },
-    "growl": {
-      "version": "1.10.5",
-      "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz",
-      "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==",
-      "dev": true
-    },
     "growly": {
       "version": "1.3.0",
       "resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
@@ -7742,12 +7723,6 @@
         "invert-kv": "^1.0.0"
       }
     },
-    "lcov-parse": {
-      "version": "0.0.10",
-      "resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-0.0.10.tgz",
-      "integrity": "sha1-GwuP+ayceIklBYK3C3ExXZ2m2aM=",
-      "dev": true
-    },
     "left-pad": {
       "version": "1.3.0",
       "resolved": "https://registry.npmjs.org/left-pad/-/left-pad-1.3.0.tgz",
@@ -7880,12 +7855,6 @@
       "integrity": "sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=",
       "dev": true
     },
-    "log-driver": {
-      "version": "1.2.7",
-      "resolved": "https://registry.npmjs.org/log-driver/-/log-driver-1.2.7.tgz",
-      "integrity": "sha512-U7KCmLdqsGHBLeWqYlFA0V0Sl6P08EE1ZrmA9cxjUE0WVqT9qnyVDPz1kzpFEP0jdJuFnasWIfSd7fsaNXkpbg==",
-      "dev": true
-    },
     "longest": {
       "version": "1.0.1",
       "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz",
diff --git a/package.json b/package.json
index 25cc848..de0a35f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "serverless-azure-functions",
-  "version": "1.0.0-15",
+  "version": "1.0.0-18",
   "description": "Provider plugin for the Serverless Framework v1.x which adds support for Azure Functions.",
   "license": "MIT",
   "main": "./lib/index.js",
@@ -75,7 +75,6 @@
     "axios-mock-adapter": "^1.16.0",
     "babel-jest": "^24.8.0",
     "babel-preset-react-app": "^9.0.0",
-    "coveralls": "https://github.com/nickmerwin/node-coveralls.git#f0ddec529c8271ea193bfab41de12b6c06d533f5",
     "eslint": "^5.16.0",
     "jest": "^24.8.0",
     "jest-cli": "^24.8.0",
diff --git a/pipelines/ci.yml b/pipelines/ci.yml
index f2c712c..93c73f2 100644
--- a/pipelines/ci.yml
+++ b/pipelines/ci.yml
@@ -7,7 +7,7 @@ pr:
   - dev
 
 variables:
-- group: coveralls-credentials  # variable group
+- group: code-coverage-credentials  # variable group
 
 jobs:
 - template: templates/unit-tests.yml  # path relative to this file
diff --git a/scripts/build.sh b/scripts/build.sh
old mode 100644
new mode 100755
diff --git a/scripts/publish.sh b/scripts/publish.sh
old mode 100644
new mode 100755
index 23f5f45..4383cdd
--- a/scripts/publish.sh
+++ b/scripts/publish.sh
@@ -1,7 +1,11 @@
 #!/bin/bash
 set -eo pipefail
 
-./$(pwd)/scripts/build.sh
+$(pwd)/scripts/build.sh
+
+# set up .npmrc to authenticate with the provided token
+echo "Set up .npmrc ..."
+echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc
 
 # NOTE: auth is taken care of via NPM_TOKEN env variable
 if [ -z "$1" ]; then
diff --git a/src/services/offlineService.ts b/src/services/offlineService.ts
index 7288c6c..48da80e 100644
--- a/src/services/offlineService.ts
+++ b/src/services/offlineService.ts
@@ -42,13 +42,6 @@ export class OfflineService extends BaseService {
   public async cleanup() {
     this.log("Cleaning up offline files")
     await this.packageService.cleanUp();
-    const filenames = Object.keys(this.localFiles);
-    for (const filename of filenames) {
-      if (fs.existsSync(filename)) {
-        this.log(`Removing file '${filename}'`);
-        fs.unlinkSync(filename)
-      }
-    }
     this.log("Finished cleaning up offline files");
   }
 


Test patch:
diff --git a/pipelines/templates/unit-tests.yml b/pipelines/templates/unit-tests.yml
index f98b67a..452862a 100644
--- a/pipelines/templates/unit-tests.yml
+++ b/pipelines/templates/unit-tests.yml
@@ -26,9 +26,17 @@ jobs:
 
   - ${{ if eq(parameters.nodeVersion, '8') }}:
     - bash: |
-        cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage
+        set -e
+
+        token=$(CODECOV_TOKEN)
+        if [[ -z "${token}" ]]; then
+          echo "Need to set CODECOV_TOKEN"
+          exit 1
+        fi
+
+        # https://docs.codecov.io/docs/about-the-codecov-bash-uploader
+        bash <(curl -s https://codecov.io/bash) -t ${token}
       displayName: 'Upload code coverage report'
       env:
-        COVERALLS_SERVICE_NAME: "Azure DevOps"
-        COVERALLS_REPO_TOKEN: $(COVERALLS_REPO_TOKEN)
+        CODECOV_TOKEN: $(CODECOV_TOKEN)
       condition: eq(variables['imageName'], 'ubuntu-16.04')
diff --git a/scripts/version.sh b/scripts/version.sh
old mode 100644
new mode 100755
diff --git a/src/services/offlineService.test.ts b/src/services/offlineService.test.ts
index e9b1427..a26fb24 100644
--- a/src/services/offlineService.test.ts
+++ b/src/services/offlineService.test.ts
@@ -47,7 +47,6 @@ describe("Offline Service", () => {
         MockFactory.createTestBindingsObject(`..${path.sep}${name}.js`)
       );
     }
-    expect(calls[calls.length - 1][0]).toEqual("local.settings.json");
     writeFileSpy.mockRestore();
   });
 
@@ -80,9 +79,9 @@ describe("Offline Service", () => {
     const rmdirSpy = jest.spyOn(fs, "rmdirSync")
     await service.cleanup();
     const unlinkCalls = unlinkSpy.mock.calls;
+    expect(unlinkCalls).toHaveLength(2);
     expect(unlinkCalls[0][0]).toBe(`hello${path.sep}function.json`);
     expect(unlinkCalls[1][0]).toBe(`goodbye${path.sep}function.json`);
-    expect(unlinkCalls[2][0]).toBe("local.settings.json");
     const rmdirCalls = rmdirSpy.mock.calls;
     expect(rmdirCalls[0][0]).toBe("hello");
     expect(rmdirCalls[1][0]).toBe("goodbye");
@@ -193,10 +192,9 @@ describe("Offline Service", () => {
 
     const unlinkCalls = unlinkSpy.mock.calls;
 
-    expect(unlinkCalls).toHaveLength(3);
+    expect(unlinkCalls).toHaveLength(2);
     expect(unlinkCalls[0][0]).toBe(`hello${path.sep}function.json`);
     expect(unlinkCalls[1][0]).toBe(`goodbye${path.sep}function.json`);
-    expect(unlinkCalls[2][0]).toBe("local.settings.json");
 
     const rmdirCalls = rmdirSpy.mock.calls;