diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 27153f3d1..b3c177343 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,7 +38,7 @@ jobs: coverage-reports: ./coverage/cobertura-coverage.xml - name: Build Ionic - run: ionic build + run: npm run build - name: Build Android run: | diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a70db7c00..551005339 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -30,7 +30,7 @@ jobs: run: npm install - name: Build Ionic - run: ionic build -- --base-href=/capture-lite/ + run: npm run build -- --base-href=/capture-lite/ - name: Deploy uses: JamesIves/github-pages-deploy-action@3.7.1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 82dcb21b5..7297f65d4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,7 +30,7 @@ jobs: npm install -g @angular/cli npm install -g @ionic/cli npm install - ionic build + npm run build npx cap sync cd android/ ./gradlew assembleDebug diff --git a/README.md b/README.md index d680bac41..ab03da839 100644 --- a/README.md +++ b/README.md @@ -5,19 +5,6 @@ | master | [![build](https://github.com/numbersprotocol/capture-lite/workflows/build/badge.svg)](https://github.com/numbersprotocol/capture-lite/actions?query=workflow%3Abuild) | [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/45ae18aaa6a7474497e0efd818452a46)](https://www.codacy.com/gh/numbersprotocol/capture-lite?utm_source=github.com&utm_medium=referral&utm_content=numbersprotocol/capture-lite&utm_campaign=Badge_Coverage) | [![Codacy Badge](https://app.codacy.com/project/badge/Grade/45ae18aaa6a7474497e0efd818452a46)](https://www.codacy.com/gh/numbersprotocol/capture-lite?utm_source=github.com&utm_medium=referral&utm_content=numbersprotocol/capture-lite&utm_campaign=Badge_Grade) | | develop | [![build](https://github.com/numbersprotocol/capture-lite/workflows/build/badge.svg?branch=develop)](https://github.com/numbersprotocol/capture-lite/actions?query=workflow%3Abuild) | [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/45ae18aaa6a7474497e0efd818452a46?branch=develop)](https://www.codacy.com/gh/numbersprotocol/capture-lite?utm_source=github.com&utm_medium=referral&utm_content=numbersprotocol/capture-lite&utm_campaign=Badge_Coverage) | [![Codacy Badge](https://app.codacy.com/project/badge/Grade/45ae18aaa6a7474497e0efd818452a46?branch=develop)](https://www.codacy.com/gh/numbersprotocol/capture-lite?utm_source=github.com&utm_medium=referral&utm_content=numbersprotocol/capture-lite&utm_campaign=Badge_Grade) -## Internal Branch - -__This is an internal branch which cannot be built without further configurations.__ - -### Ignore Secrets in Git - -1. Create an empty `secret.ts` file with empty variables (e.g. empty string). -1. Push the empty secret file to remote repo so the CI can still build the project. -1. Make git ignore the modification of the secret file locally with the command `git update-index --skip-worktree `. -1. Now, you can modify the secret file without the fear of pushing it to the public repo. - -> You don't even need to add the secret file to `.gitignore`. - ## Highlight Features * Generate digital proofs on media assets created. @@ -39,10 +26,16 @@ Install the dependencies. npm i ``` +Set the system environment variable `NUMBERS_STORAGE_BASE_URL` before build the app by appending the following string in `~/.profile`: + +``` txt +export NUMBERS_STORAGE_BASE_URL="THE PRIVATE BASE URL" +``` + Preview the app in web browser. ``` bash -ionic serve +npm run serve ``` ### Verification @@ -101,7 +94,7 @@ If your operating system is Linux, set the `linuxAndroidStudioPath` in `capacito Before running the app with Android Studio, build and sync the dependencies and web assets. ``` bash -ionic build +npm run build npx cap sync ``` diff --git a/package.json b/package.json index 5bed91905..31195bb72 100644 --- a/package.json +++ b/package.json @@ -5,13 +5,14 @@ "homepage": "https://numbersprotocol.io/", "scripts": { "ng": "ng", - "start": "ng serve", - "build": "ng build", - "build-android": "ionic build && cap sync && cap open android", - "test": "ng test", - "test-ci": "ng test --no-watch --no-progress --browsers=ChromeHeadlessCI", - "lint": "ng lint", - "e2e": "ng e2e" + "preconfig": "node set-secret.js", + "serve": "npm run preconfig && ionic serve", + "build": "npm run preconfig && ionic build", + "build-android": "npm run build && cap sync && cap open android", + "test": "npm run preconfig && ng test", + "test-ci": "npm run preconfig && ng test --no-watch --no-progress --browsers=ChromeHeadlessCI", + "lint": "npm run preconfig && ng lint", + "e2e": "npm run preconfig && ng e2e" }, "private": true, "dependencies": { @@ -63,4 +64,4 @@ "typescript": "~3.9.7" }, "description": "Capture lite app." -} +} \ No newline at end of file diff --git a/set-secret.js b/set-secret.js new file mode 100644 index 000000000..95419057a --- /dev/null +++ b/set-secret.js @@ -0,0 +1,14 @@ +const fs = require('fs'); + +// Configure Angular `secret.ts` file path +const targetPath = './src/environments/secret.ts'; + +// `secret.ts` file structure +const envConfigFile = `export const secret = { + numbersStorageBaseUrl: '${process.env.NUMBERS_STORAGE_BASE_URL}' +}; +`; +fs.writeFile(targetPath, envConfigFile, err => { + if (err) { throw console.error(err); } + else { console.log(`Angular secrets.ts file generated correctly at ${targetPath} \n`); } +}); diff --git a/src/app/components/header/header.component.html b/src/app/components/header/header.component.html deleted file mode 100644 index ebd3ec2e6..000000000 --- a/src/app/components/header/header.component.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - {{ t('all') }} - - - - - {{ t('tags') }} - - - - - - - - - - - - - - - - - - {{ t('settings') }} - - - - - - - - {{ t('general') }} - - - - - - {{ t('defaultInformationProvider') }} - - - - - - {{ t('defaultSignature') }} - - - - - - {{ t('informationProvider') }} - - - - - - {{ t('about') }} - - - - - - {{ t('logout') }} - - - - - \ No newline at end of file diff --git a/src/app/services/publisher/numbers-storage/numbers-storage-api.service.ts b/src/app/services/publisher/numbers-storage/numbers-storage-api.service.ts index 4c950f706..9039e4c85 100644 --- a/src/app/services/publisher/numbers-storage/numbers-storage-api.service.ts +++ b/src/app/services/publisher/numbers-storage/numbers-storage-api.service.ts @@ -1,24 +1,19 @@ import { HttpClient, HttpHeaders } from '@angular/common/http'; import { Injectable } from '@angular/core'; - import { of, zip } from 'rxjs'; import { concatMap, concatMapTo, first, map, pluck } from 'rxjs/operators'; import { base64ToBlob$ } from 'src/app/utils/encoding/encoding'; -import { - PreferenceManager, -} from 'src/app/utils/preferences/preference-manager'; - +import { PreferenceManager } from 'src/app/utils/preferences/preference-manager'; +import { secret } from '../../../../environments/secret'; import { Proof } from '../../data/proof/proof'; import { Signature } from '../../data/signature/signature'; -import { - SerializationService, -} from '../../serialization/serialization.service'; -import { baseUrl } from './secret'; +import { SerializationService } from '../../serialization/serialization.service'; export const enum TargetProvider { Numbers = 'Numbers' } +const baseUrl = secret.numbersStorageBaseUrl; const preference = PreferenceManager.NUMBERS_STORAGE_PUBLISHER_PREF; const enum PrefKeys { Enabled = 'enabled', diff --git a/src/app/services/publisher/numbers-storage/secret.ts b/src/app/services/publisher/numbers-storage/secret.ts deleted file mode 100644 index f6e2d6f84..000000000 --- a/src/app/services/publisher/numbers-storage/secret.ts +++ /dev/null @@ -1 +0,0 @@ -export const baseUrl = '';